1 /******************************************************************************* 2 3 BASIC.H 4 5 Author: Peter Loan 6 7 Date: 13-APR-89 8 9 Copyright (c) 1992-5 MusculoGraphics, Inc. 10 All rights reserved. 11 Portions of this source code are copyrighted by MusculoGraphics, Inc. 12 13 Basic #defines, enums, and structures needed by most/all ".c" files. 14 15 *******************************************************************************/ 16 17 #ifndef BASIC_H 18 #define BASIC_H 19 20 #define STRUCT typedef struct 21 #define UNION typedef union 22 #define ENUM typedef enum 23 24 #define public 25 26 #define SELECT_BUTTON RIGHTMOUSE 27 28 #define DUMMY_LONG 0 29 #define DUMMY_INT 0 30 31 #define ZERO 0 /* used like NULL, but is an int */ 32 #define NO 0 33 #define YES 1 34 35 #define SPACE ' ' 36 #define TAB '\t' 37 #define CARRIAGE_RETURN '\n' 38 #define STRING_TERMINATOR '\0' 39 #define LINE_FEED 13 40 41 #ifdef WIN32 42 #define DIR_SEP_CHAR '\\' 43 #define DIR_SEP_STRING "\\" 44 45 #define COPY_COMMAND "copy" 46 #else 47 #define DIR_SEP_CHAR '/' 48 #define DIR_SEP_STRING "/" 49 50 #define COPY_COMMAND "cp" 51 #endif 52 53 #define COMMAND_BUFFER 500 54 55 #define PIXELSPERINCH 96 56 #define PIXELSPERINCHF 96.0 57 58 #define MENU_ITEM_HEIGHT 24 59 #define FORM_FIELD_HEIGHT 21 60 #define FORM_FIELD_YSPACING 27 61 #define COMBO_ITEM_HEIGHT 20 62 #define COMBO_ITEM_SIZE 135 63 64 #define MAX_MGROUP_MENU_HEIGHT 540 65 #define MGROUP_MENU_SPACER 20 66 67 #define MAX_CHAR_WIDTH 13 68 69 #define MAX_NUM_MATERIALS 64 70 71 #define FORMITEM_XMARGIN 4 72 #define FORMITEM_YMARGIN 6 73 74 #define FORM_ITEM_STRING_MAX 256 75 #define FORM_BEGINNING 0 76 #define FORM_END 1 77 #define FORM_CURSOR 2 78 #define FORM_INSERT 3 79 #define FORM_NAVIGATE 4 80 81 #define MODEL_SELECTOR_X 20 82 #define MODEL_SELECTOR_Y -40 83 84 #define END_OF_ARRAY -1 85 86 #define NO_WINDOW -1 87 #define NO_SELECTION -1 88 89 #define FILLED 1 90 #define EMPTY 0 91 #define DID_NOT_PLACE_MENU 0 92 #define PLACED_MENU 1 93 94 #define NOITEM -1 95 #define TITLEBOX -2 96 97 #define TITLE_BAR -2 98 #define TITLE_AREA_HEIGHT 65 99 100 #define FUNCTION_ARRAY_INCREMENT 24 // might cause crashing, setting to 1 fixes this 101 #define MOTION_ARRAY_INCREMENT 4 102 #define DEFAULT_ARRAY_INCREMENT 10 103 104 #define CHARBUFFER 4096 105 #if ENGINE || CORTEX_PLUGIN 106 #define MODELBUFFER 4 107 #define PLOTBUFFER 1 108 #define TOOLBUFFER 1 109 #define SCENEBUFFER 4 110 #else 111 #define MODELBUFFER 32 112 #define PLOTBUFFER 24 113 #define TOOLBUFFER 16 114 #define SCENEBUFFER 32 115 #endif 116 #define COLORBUFFER 256 117 118 #define GENBUFFER 64 /* used only for gencoord help text in MV */ 119 #define GROUPBUFFER 96 /* used by JO and PM model options structs */ 120 #define COLUMNBUFFER 50 /* used by tools which place muscle menus */ 121 122 #define FIXED_SEGMENT 0 123 #define MAX_MUSCLE_POINTS 200 124 #define MAX_PLOT_CURVES 60 125 #define MAXMDOUBLE 99999999.999 126 #define MINMDOUBLE -99999999.999 127 #define TINY_NUMBER 0.0000001 128 #define ERROR_DOUBLE -999999.3 129 #define ROUNDOFF_ERROR 0.000000001 130 #define KEEPOLDDOUBLE -999999.4 131 #define DONT_CHECK_DOUBLE -999999.5 132 #define ERRORINT -32760 133 #define MAXIMUMERROR 0.01 134 #define DEG_TO_RAD 0.017453292519943 135 #define RAD_TO_DEG 57.295779513082323 136 #define DTOR DEG_TO_RAD 137 #define RTOD RAD_TO_DEG 138 #define DOUBLE_NOT_DONE -99999.73 139 #define MAX_MATRIX_SIZE 20 140 #define MAX_UINT ((unsigned int)~((unsigned int)0)) 141 #define MAX_INT ((int)(MAX_UINT >> 1)) 142 143 #define UNDEFINED_USERFUNCNUM -9999 144 #define INVALID_FUNCTION -1 145 #define INVALID_GENCOORD -1 146 147 #define STRING_DONE 0 148 #define STRING_NOT_DONE 1 149 #define KEEP_OLD_STRING 2 150 #define NULL_STRING_ENTERED 3 151 152 #define CHECKBOX_XSIZE 18 153 #define CHECKBOX_YSIZE 18 154 155 #define UPDATE_WINDOW 1 156 #define DONT_UPDATE_WINDOW 0 157 158 #define HELP_WINDOW_TEXT_Y_SPACING 20 159 #define HELP_WINDOW_X_MARGIN 40 160 161 #define HIGHLIGHT_TEXT 1 162 #define CENTER_JUSTIFY 2 163 #define NO_NEW_LINE 4 164 #define OVERWRITE_LAST_LINE 8 165 #define OVERWRITABLE 16 166 #define SPECIAL_COLOR 32 167 #define DEFAULT_MESSAGE_X_OFFSET 10 168 169 #define SHOW_MODEL 0x00000001 170 #define SHOW_PLOT 0x00000002 171 #define SHOW_HELP 0x00000004 172 173 #define NULL_SELECTED 0 174 #define MODEL_SELECTED 1 175 #define PLOT_SELECTED 2 176 #define HELP_SELECTED 3 177 178 #define NUM_DRAW_MODES 7 179 180 #ifndef FALSE 181 enum {FALSE, TRUE}; 182 #endif 183 enum {OFF, ON}; 184 185 enum {XX, YY, ZZ, WW}; 186 enum {RD, GR, BL}; 187 188 /* to go along with "typedef float Matrix[4][4]" in gl.h */ 189 typedef double DMatrix[4][4]; 190 191 typedef double DCoord[3]; 192 typedef double Quat[4]; 193 194 typedef unsigned __int64 PickIndex; 195 196 STRUCT { 197 double x1; /* minimum x */ 198 double y1; /* minimum y */ 199 double x2; /* maximum x */ 200 double y2; /* maximum y */ 201 } Ortho; /* values for ortho() commands */ 202 203 204 STRUCT { 205 double x; /* x coordinate */ 206 double y; /* y coordinate */ 207 } XYCoord; /* an (x,y) coordinate pair */ 208 209 210 STRUCT { 211 int x; /* x coordinate */ 212 int y; /* y coordinate */ 213 } XYIntCoord; /* an (x,y) integer coordinate pair */ 214 215 216 STRUCT { 217 int x1; /* minimum x */ 218 int y1; /* minimum y */ 219 int x2; /* maximum x */ 220 int y2; /* maximum y */ 221 } IntBox; /* a box in integer coordinates */ 222 223 224 STRUCT { 225 double x1; 226 double x2; 227 double y1; 228 double y2; 229 double z1; 230 double z2; 231 } BoundingCube; 232 233 234 STRUCT { 235 long x1; /* minimum x */ 236 long y1; /* minimum y */ 237 long x2; /* maximum x */ 238 long y2; /* maximum y */ 239 } LongBox; /* a box in long coordinates */ 240 241 STRUCT { 242 GLfloat rgb[3]; 243 } ColorRGB; /* an rgb triplet defining a color */ 244 245 ENUM { 246 defining_element, /* defining an element's properties */ 247 declaring_element, /* using the element name, not defining it */ 248 just_checking_element /* just checking to see if already defined */ 249 } EnterMode; /* modes when entering/defining model elements */ 250 251 ENUM { 252 type_int, /* integer */ 253 type_double, /* double */ 254 type_char, /* single character */ 255 type_string /* string */ 256 } VariableType; /* variable types that can be read from string */ 257 258 259 ENUM { 260 up_obj, /* object appears to come out of screen */ 261 down_obj /* object appears to go down into screen */ 262 } GUIObjectMode; 263 264 265 ENUM { 266 code_fine, /* fine, no error was encountered */ 267 code_bad /* bad, an error was encountered */ 268 } ReturnCode; /* error condition values */ 269 270 271 ENUM { 272 recover, /* recover from error */ 273 abort_action, /* abort action; critical error */ 274 exit_program, /* exit program; fatal error */ 275 none /* no action; no error */ 276 } ErrorAction; /* error recovery actions */ 277 278 279 ENUM { 280 horizontal_slider, /* */ 281 vertical_slider /* */ 282 } SliderType; /* */ 283 284 285 ENUM { 286 zeroth, /* zeroth derivative */ 287 first, /* first derivative */ 288 second /* second derivative */ 289 } Derivative; /* function derivative values */ 290 291 292 ENUM { 293 FORWARD, /* forward for converting a frame/point */ 294 INVERSE /* inverse for converting a frame/point */ 295 } Direction; /* directions used in joint traversal */ 296 297 298 ENUM { 299 from_ground, 300 to_ground 301 } GroundDirection; 302 303 ENUM { 304 no, /* no */ 305 yes /* yes */ 306 } SBoolean; /* conventional SBooleanean */ 307 308 309 ENUM 310 { 311 off, 312 on 313 } OnOffSwitch; 314 315 316 ENUM 317 { 318 right, 319 left 320 } Justification; 321 322 323 ENUM { 324 valid, /* clean, still valid */ 325 invalid /* dirty, no longer valid */ 326 } Condition; /* conditions for calculated values */ 327 328 329 ENUM { 330 gouraud_shading=1, 331 flat_shading, 332 solid_fill, 333 wireframe, 334 outlined_polygons, 335 bounding_box, 336 no_surface 337 } DrawingMode; 338 339 340 ENUM { 341 normal_menu, 342 toggle_menu 343 } MenuType; 344 345 346 ENUM { 347 normal_checkbox, 348 radio_checkbox 349 } CheckBoxType; 350 351 ENUM { 352 no_field_action, 353 goto_previous_field, 354 goto_next_field 355 } TextFieldAction; 356 357 ENUM { 358 left_arrow, 359 up_arrow, 360 right_arrow, 361 down_arrow 362 } ArrowDirection; 363 364 STRUCT { 365 ArrowDirection direction; 366 SBoolean pressed; 367 int color; 368 int pressed_color; 369 IntBox bounding_box; 370 XYIntCoord tip; 371 XYIntCoord base1; 372 XYIntCoord base2; 373 } ArrowButton; 374 375 STRUCT { 376 SBoolean visible; 377 SBoolean active; 378 SliderType type; 379 char label[3]; 380 double value; 381 double min_value; 382 double max_value; 383 double arrow_step; 384 int thumb_thickness; 385 int thumb_dist; 386 IntBox shaft; 387 ArrowButton decrease_arrow; 388 ArrowButton increase_arrow; 389 SBoolean thumb_pressed; 390 int thumb_color; 391 int background_color; 392 int border_color; 393 int pressed_thumb_color; 394 void* data; /* user-supplied data to identify slider */ 395 } Slider; 396 397 STRUCT { 398 int numsliders; 399 Slider* sl; 400 XYIntCoord origin; 401 } SliderArray; 402 403 STRUCT { 404 SBoolean visible; 405 SBoolean active; 406 char start_label[10]; 407 char end_label[10]; 408 double start_value; 409 double end_value; 410 double min_value; 411 double max_value; 412 double arrow_step; 413 int thumb_thickness; 414 int thumb_dist; 415 int thumb_x1; 416 int thumb_x2; 417 IntBox bounding_box; 418 IntBox shaft; 419 ArrowButton start_increase_arrow; 420 ArrowButton start_decrease_arrow; 421 ArrowButton end_increase_arrow; 422 ArrowButton end_decrease_arrow; 423 SBoolean thumb_pressed; 424 int thumb_color; 425 int background_color; 426 int border_color; 427 int pressed_thumb_color; 428 void* data; /* user-supplied data to identify slider */ 429 XYIntCoord origin; 430 } CropSlider; 431 432 433 STRUCT { 434 IntBox box; /* position of option box */ 435 char* name; /* name of option */ 436 SBoolean active; /* is this menu item active? */ 437 SBoolean visible; 438 } MenuItem; /* an Menu menu option */ 439 440 441 STRUCT { 442 MenuType type; /* toggle menu or normal menu */ 443 int numoptions; /* number of options */ 444 IntBox titlebox; /* position of title box */ 445 char* title; /* title of menu */ 446 IntBox bbox; /* bounding box of entire menu */ 447 MenuItem *option; /* list of menu-option structures */ 448 XYIntCoord origin; /* origin of menu */ 449 } Menu; /* properties of an Menu menu */ 450 451 452 STRUCT { 453 IntBox box; /* position of option box */ 454 char* name; /* name of option */ 455 char valuestr[FORM_ITEM_STRING_MAX]; /* string to hold current value */ 456 SBoolean justify; /* used for lining-up numbers */ 457 SBoolean active; /* whether or not this field is active */ 458 SBoolean visible; /* whether of not this field is visible */ 459 SBoolean editable; /* whether or not this field can be edited */ 460 SBoolean use_alternate_colors; /* use alternate colors for display? */ 461 int decimal_places; /* how many places to right of number */ 462 void* data; /* user-supplied data to identify form item */ 463 int firstVisible; /* first character that is visible in the box */ 464 int lastVisible; /* last character that is visible in the box */ 465 } FormItem; /* a Form menu option */ 466 467 468 STRUCT { 469 int numoptions; /* number of options */ 470 char* title; /* title of form */ 471 IntBox bbox; /* bounding box of entire form */ 472 FormItem *option; /* list of form-option structures */ 473 XYIntCoord origin; /* origin of menu */ 474 int selected_item; /* the selected option, if any */ 475 int cursor_position; /* where the cursor is in the selected string */ 476 int highlight_start; /* first character of selected text in string */ 477 } Form; /* properties of a Form */ 478 479 480 STRUCT { 481 IntBox box; /* position of option box */ 482 char* name; /* name of option */ 483 OnOffSwitch state; /* state of checkbox (yes,no) */ 484 Justification just; /* left or right justified text */ 485 SBoolean active; /* whether or not this checkbox is active */ 486 SBoolean visible; 487 SBoolean use_alternate_colors;//dkb 488 } CheckBox; /* a checkbox */ 489 490 491 STRUCT { 492 CheckBoxType type; /* normal (boxes) or radio button (diamonds) */ 493 int numoptions; /* number of options */ 494 char* title; /* title of menu */ 495 IntBox bbox; /* bounding box of entire checkbox region */ 496 CheckBox *checkbox; /* list of checkboxes */ 497 XYIntCoord origin; /* origin of menu */ 498 } CheckBoxPanel; /* holds panel of checkboxes */ 499 500 501 STRUCT { 502 IntBox box; /* position of combobox */ 503 char* defaultName; /* name to show when no selected option */ 504 const char* currentName; /* name of currently selected option */ 505 int currentMenuIndex; /* index in menu of currently selected option */ 506 SBoolean active; /* is this combobox active? */ 507 SBoolean visible; /* is this combobox visible? */ 508 long popupMenu; /* the popup menu of options to choose from */ 509 void (*menuCallback)(int menuValue, void* userData); /* callback for popup menu */ 510 void* userData; /* user data for popup menu callback */ 511 } ComboBox; /* a combobox for choosing one of several options */ 512 513 STRUCT { 514 char *title; 515 int numoptions; 516 IntBox bbox; /* bounding box of entire combobox region */ 517 ComboBox *combobox; /* list of combo boxes */ 518 XYIntCoord origin; /* origin of menu */ 519 int yPosition; 520 } ComboBoxPanel; 521 522 STRUCT { 523 OnOffSwitch state; /* whether this menu is on or off */ 524 int xo; /* x coordinate of menu origin */ 525 int yo; /* y coordinate of menu origin */ 526 int starting_column; /* first column this menu occupied, when on */ 527 } MuscleMenu; /* state and position of group menus */ 528 529 530 STRUCT { 531 int block_size; /* */ 532 int free_ptr; /* */ 533 void* memory; /* */ 534 } MEMORYBLOCK; /* */ 535 536 537 STRUCT { 538 double xyz[3]; /* x, y, and z coordinates */ 539 float normal[3]; /* vertex normal (float because of n3f()*/ 540 } Vertex; /* description of a polygon vertex */ 541 542 543 STRUCT { 544 int numpoints; /* number of vertices in polygon */ 545 int pts[25]; /* list of vertices in polygon */ 546 float normal[3]; /* polygon normal */ 547 } SimmPolygon; /* description of a polygon */ 548 549 550 STRUCT { 551 char* text; 552 int format; 553 int xoffset; 554 } TextLine; 555 556 557 STRUCT { 558 TextLine* line; 559 int num_lines_malloced; 560 int num_lines; 561 int window_id; 562 int window_width; 563 int window_height; 564 Slider sl; 565 int lines_per_page; 566 int starting_line; 567 int background_color; 568 } HelpStruct; 569 570 571 STRUCT { 572 void* defaultfont; /* */ 573 void* largefont; /* */ 574 void* smallfont; /* */ 575 void* italics; /* */ 576 void* bold; /* */ 577 } GlobalFonts; /* */ 578 579 580 /* TOOL QUERIES (sent to a tools query_handler routine) */ 581 ENUM 582 { 583 GET_TOOL_MODEL, 584 GET_TOOL_PLOT 585 } QueryType; 586 587 #endif /*BASIC_H*/ 588 589