home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / macraysh.sit / Code / Source / maceditor.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-05-18  |  18.7 KB  |  724 lines

  1. /*
  2.  * Maceditor.c
  3.  */
  4.  
  5. #include <MacHeaders>
  6. #include <Windows.h>
  7. #include <QuickDraw.h>
  8. #include <Dialogs.h>
  9. #include <Lists.h>
  10. #include <Types.h>
  11.  
  12. #include "geom.h"
  13. #include "list.h"
  14. #include "grid.h"
  15. #include "sampling.h"
  16. #include "csg.h"
  17. #include "instance.h"
  18.  
  19. #include "light.h"
  20. #include "point.h"
  21. #include "infinite.h"
  22. #include "spot.h"
  23. #include "jittered.h"
  24. #include "extended.h"
  25.  
  26. #include "surface.h"
  27. #include "texture.h"
  28. #include "image.h"
  29.  
  30. #include "blotch.h"
  31. #include "bump.h"
  32. #include "checker.h"
  33. #include "cloud.h"
  34. #include "fbm.h"
  35. #include "fbmbump.h"
  36. #include "gloss.h"
  37. #include "imagetext.h"
  38. #include "marble.h"
  39. #include "mount.h"
  40. #include "sky.h"
  41. #include "stripe.h"
  42. #include "windy.h"
  43. #include "wood.h"
  44.  
  45. #include "rotate.h"
  46. #include "scale.h"
  47. #include "translate.h"
  48.  
  49. #include "maceditor.h"
  50. #include "macdialog.h"
  51.  
  52. extern void HandleMouseDown (EventRecord    *theEvent);
  53. extern void HandleEvent(void);
  54. extern void DisplayView() ;
  55. extern void DrawCoordinateInfo(Float x, Float y, Float z) ;
  56.  
  57. Geom *GetCurrentParent();
  58.  
  59. char *ObjectName(short type) ;
  60. void UpdateEditor() ;
  61. void InsertObjectList(Geom *obj) ;
  62. void DisplayObjectList() ;
  63. void ConstructAndDisplayObjectList() ;
  64. void InitObjectList() ;
  65. void DestroyObjectList() ;
  66. ControlHandle SnatchHandle(DialogPtr thebox, short theGetItem) ;
  67. pascal void DrawCoordInfo(WindowPtr window, short item) ;
  68. pascal void DoWorldList(WindowPtr window, short item) ;
  69. pascal void DrawPopUps(WindowPtr window, short item) ;
  70. pascal void DrawTopView(WindowPtr window, short item) ;
  71. pascal void DrawSideView(WindowPtr window, short item) ;
  72. pascal void DrawFrontView(WindowPtr window, short item) ;
  73.  
  74. extern GeomList *Defstack;
  75. extern Geom *World ;
  76. extern Vector crosshair, old_crosshair ;
  77. extern Float zoom ;
  78.  
  79. /* Exportable variables */
  80.  
  81. DialogPtr editorDialog = NULL;
  82. Geom *hiliteobject = NULL ;
  83. unsigned long FilterFlags = 0 ;
  84.  
  85. /* Some private ones */
  86.  
  87. static ListHandle editorList ;
  88. static struct ObjectStack *objectstack;
  89. static Geom *chosen_object = NULL;
  90.  
  91. /* 
  92.  * Since any modifications we make to a scene might fall outside bounds we have to recompute
  93.  * everything.
  94.  */ 
  95. void ReComputeBounds(Geom *obj)
  96. {
  97.     short loop ;
  98.  
  99.     if(obj) GeomBounds(obj,obj->bounds) ;
  100.     for(loop = objectstack->numparents ; loop >= 0 ; loop--) {
  101.         if(objectstack->parentlist[loop])
  102.             GeomBounds(objectstack->parentlist[loop],objectstack->parentlist[loop]->bounds) ;
  103.     }
  104. }
  105.  
  106. void SetButtons()
  107. {
  108. /*    if(chosen_object != NULL) {
  109.         HiliteControl(SnatchHandle(editorDialog,ewdeleteBU),0) ;
  110.         HiliteControl(SnatchHandle(editorDialog,ewmodifyBU),0) ;
  111.     }
  112.     else {
  113.         HiliteControl(SnatchHandle(editorDialog,ewdeleteBU),255) ;
  114.         HiliteControl(SnatchHandle(editorDialog,ewmodifyBU),255) ;
  115.     } */
  116. }
  117.  
  118.  
  119. /* Initialise all user items, so that the correct procedures are called */
  120. void OpenEditorDialog()
  121. {
  122.     short itemType, loop ;
  123.     Handle itemHandle ;
  124.     Rect itemRect ;
  125.     GeomRef ref ;
  126.  
  127.     if(editorDialog) return ; /* Something wierd has happened */
  128.  
  129.     objectstack = malloc((size_t)sizeof(struct ObjectStack));
  130.     objectstack->parentlist[0] = World ;
  131.     objectstack->numparents = 0 ;
  132.     crosshair.x = crosshair.y = crosshair.z = 0 ;
  133.  
  134.     editorDialog = GetNewDialog(editordialogR, 0L, (WindowPtr)-1);
  135.     SetPort(editorDialog) ;
  136.     ShowWindow(editorDialog);
  137.     
  138.     GetDItem(editorDialog, worldlistUI, &itemType, &itemHandle, &itemRect);
  139.     SetDItem(editorDialog, worldlistUI, itemType, (ProcPtr) DoWorldList, &itemRect);
  140.     InitObjectList() ;
  141.     GetDItem(editorDialog, topUI, &itemType, &itemHandle, &itemRect);
  142.     SetDItem(editorDialog, topUI, itemType, (ProcPtr) DrawTopView, &itemRect);
  143.     GetDItem(editorDialog, sideUI, &itemType, &itemHandle, &itemRect);
  144.     SetDItem(editorDialog, sideUI, itemType, (ProcPtr) DrawSideView, &itemRect);
  145.     GetDItem(editorDialog, frontUI, &itemType, &itemHandle, &itemRect);    
  146.     SetDItem(editorDialog, frontUI, itemType, (ProcPtr) DrawFrontView, &itemRect);
  147.     GetDItem(editorDialog, coordinfoUI, &itemType, &itemHandle, &itemRect);
  148.     SetDItem(editorDialog, coordinfoUI, itemType, (ProcPtr) DrawCoordInfo, &itemRect);
  149.     InvalRect(&editorDialog->portRect) ;
  150.     SetButtons();
  151.     chosen_object = NULL;
  152. }
  153.  
  154. void CloseEditorDialog()
  155. {
  156.     if(editorDialog) {
  157.         free(objectstack);
  158.         DestroyObjectList() ;
  159.         DisposDialog(editorDialog) ;
  160.         editorDialog  = NULL ;
  161.         chosen_object = NULL ;
  162.     }
  163. }
  164.  
  165. void HandleEditorEvent(EventRecord    *theEvent)
  166. {
  167.     short theItem, itype ;
  168.     DialogPtr theDialog ;
  169.     ControlHandle itemHandle ;
  170.     Rect itemRect ;
  171.     GrafPtr currPort ;
  172.     Point mousePoint ;
  173.     Boolean doubleClick ;
  174.     short ox,oy ;
  175.     Cell theCell, myCell ;
  176.  
  177.     SetPort(editorDialog) ;
  178.     if(DialogSelect(theEvent, &theDialog, &theItem)) {
  179.         switch(theItem) {
  180.             case worldlistUI:
  181.                 GetMouse(&mousePoint);
  182.                 doubleClick = LClick(mousePoint,theEvent->modifiers,editorList) ;
  183.                 myCell.v = myCell.h = 0;                
  184.                 if(LGetSelect(TRUE, &myCell, editorList)) {
  185.                     chosen_object = objectstack->objectlist[theCell.v] ;
  186.                 }
  187.                 else {
  188.                     chosen_object = NULL;
  189.                 }
  190.                 if(doubleClick) {
  191.                     theCell = LLastClick(editorList) ;
  192.                     chosen_object = objectstack->objectlist[theCell.v] ;
  193.                     if(chosen_object && IsAggregate(chosen_object)) {
  194.                         DestroyObjectList() ;
  195.                         objectstack->numparents++ ;
  196.                         objectstack->parentlist[objectstack->numparents] = chosen_object ;
  197.                         InitObjectList() ;
  198.                         chosen_object = NULL;
  199.                     }
  200.                     else {
  201.                         doObjectModify(chosen_object) ;
  202.                         ReComputeBounds(chosen_object) ;
  203.                     }
  204.                 }
  205.                 SetButtons();
  206.                 break ;
  207.             case backBU:
  208.                 DestroyObjectList() ;
  209.                 if(objectstack->numparents > 0) {
  210.                     chosen_object = NULL;
  211.                     objectstack->parentlist[objectstack->numparents] = NULL ;
  212.                     objectstack->numparents-- ;
  213.                 }
  214.                 InitObjectList() ;
  215.                 SetButtons();
  216.                 break ;
  217.             case sphereselectIC:
  218.                 if(FILTER_SET(F_SPHERE))
  219.                     UNSET_FILTER(F_SPHERE) ;
  220.                 else
  221.                     SET_FILTER(F_SPHERE) ;
  222.                 InvalRect(&editorDialog->portRect) ;
  223.                 break ;
  224.             case cylinderselectIC:
  225.                 if(FILTER_SET(F_CYLINDER))
  226.                     UNSET_FILTER(F_CYLINDER) ;
  227.                 else
  228.                     SET_FILTER(F_CYLINDER) ;
  229.                 InvalRect(&editorDialog->portRect) ;
  230.                 break ;
  231.             case coneselectIC:
  232.                 if(FILTER_SET(F_CONE))
  233.                     UNSET_FILTER(F_CONE) ;
  234.                 else
  235.                     SET_FILTER(F_CONE) ;
  236.                 InvalRect(&editorDialog->portRect) ;
  237.                 break ;
  238.             case triangleselectIC:
  239.                 if(FILTER_SET(F_TRIANGLE))
  240.                     UNSET_FILTER(F_TRIANGLE) ;
  241.                 else
  242.                     SET_FILTER(F_TRIANGLE) ;
  243.                 InvalRect(&editorDialog->portRect) ;
  244.                 break ;
  245.             case torusselectIC:
  246.                 if(FILTER_SET(F_TORUS))
  247.                     UNSET_FILTER(F_TORUS) ;
  248.                 else
  249.                     SET_FILTER(F_TORUS) ;
  250.                 InvalRect(&editorDialog->portRect) ;
  251.                 break ;
  252.             case blobselectIC:
  253.                 if(FILTER_SET(F_BLOB))
  254.                     UNSET_FILTER(F_BLOB) ;
  255.                 else
  256.                     SET_FILTER(F_BLOB) ;
  257.                 InvalRect(&editorDialog->portRect) ;
  258.                 break ;
  259.             case boxselectIC:
  260.                 if(FILTER_SET(F_BOX))
  261.                     UNSET_FILTER(F_BOX) ;
  262.                 else
  263.                     SET_FILTER(F_BOX) ;
  264.                 InvalRect(&editorDialog->portRect) ;
  265.                 break ;
  266.             case discselectIC:
  267.                 if(FILTER_SET(F_DISC))
  268.                     UNSET_FILTER(F_DISC) ;
  269.                 else
  270.                     SET_FILTER(F_DISC) ;
  271.                 InvalRect(&editorDialog->portRect) ;
  272.                 break ;
  273.             case polyselectIC:
  274.                 if(FILTER_SET(F_POLYGON))
  275.                     UNSET_FILTER(F_POLYGON) ;
  276.                 else
  277.                     SET_FILTER(F_POLYGON) ;
  278.                 InvalRect(&editorDialog->portRect) ;
  279.                 break ;
  280.             case csgselectIC:
  281.                 if(FILTER_SET(F_CSG))
  282.                     UNSET_FILTER(F_CSG) ;
  283.                 else
  284.                     SET_FILTER(F_CSG) ;
  285.                 InvalRect(&editorDialog->portRect) ;
  286.                 break ;
  287.             case lightsselectIC:
  288.                 if(FILTER_SET(F_LIGHTS))
  289.                     UNSET_FILTER(F_LIGHTS) ;
  290.                 else
  291.                     SET_FILTER(F_LIGHTS) ;
  292.                 InvalRect(&editorDialog->portRect) ;
  293.                 break ;
  294.             case cameraselectIC:
  295.                 if(FILTER_SET(F_CAMERA))
  296.                     UNSET_FILTER(F_CAMERA) ;
  297.                 else
  298.                     SET_FILTER(F_CAMERA) ;
  299.                 InvalRect(&editorDialog->portRect) ;
  300.                 break ;
  301.             case topUI:
  302.                 GetMouse(&mousePoint) ;
  303.                 GetDItem(editorDialog,theItem,&itype,&itemHandle,&itemRect) ;
  304.                 ox = mousePoint.h - (itemRect.left+(itemRect.right-itemRect.left)/2) ;
  305.                 oy = (itemRect.top+(itemRect.bottom-itemRect.top)/2) - mousePoint.v;
  306.                 DrawCoordinateInfo((Float)ox/zoom,(Float)oy/zoom,crosshair.z) ;
  307.                 DrawCrossHair() ;
  308.                 break ;
  309.             case sideUI:
  310.                 GetMouse(&mousePoint) ;
  311.                 GetDItem(editorDialog,theItem,&itype,&itemHandle,&itemRect) ;
  312.                 ox = mousePoint.h - (itemRect.left+(itemRect.right-itemRect.left)/2) ;
  313.                 oy = (itemRect.top+(itemRect.bottom-itemRect.top)/2) - mousePoint.v;
  314.                 DrawCoordinateInfo(crosshair.x,(Float)ox/zoom,(Float)oy/zoom) ;
  315.                 DrawCrossHair() ;
  316.                 break ;
  317.             case frontUI:
  318.                 GetMouse(&mousePoint) ;
  319.                 GetDItem(editorDialog,theItem,&itype,&itemHandle,&itemRect) ;
  320.                 ox = mousePoint.h - (itemRect.left+(itemRect.right-itemRect.left)/2) ;
  321.                 oy = (itemRect.top+(itemRect.bottom-itemRect.top)/2) - mousePoint.v;
  322.                 DrawCoordinateInfo((Float)ox/zoom,crosshair.y,(Float)oy/zoom) ;
  323.                 DrawCrossHair() ;
  324.                 break ;
  325.             case zoominBU:
  326.                 zoom /= 2.;
  327.                 crosshair = old_crosshair;
  328.                 InvalRect(&editorDialog->portRect) ;
  329.                 break ;
  330.             case zoomoutBU:
  331.                 zoom *= 2.;
  332.                 crosshair = old_crosshair;
  333.                 InvalRect(&editorDialog->portRect) ;
  334.                 break ;
  335.             case ewdeleteBU:
  336.                 theCell = LLastClick(editorList) ;
  337.                 myCell.v = myCell.h = 0;                
  338.                 if(LGetSelect(TRUE, &myCell, editorList)) {
  339.                     chosen_object = objectstack->objectlist[theCell.v] ;
  340.                 }
  341.                 else
  342.                     chosen_object = NULL;
  343.                 if(chosen_object && UnlinkObject(chosen_object,GetCurrentParent())) {
  344.                     DeleteObject(chosen_object);
  345.                     DestroyObjectList() ;
  346.                     InitObjectList() ;
  347.                     chosen_object = NULL;
  348.                     SetPort(editorDialog);
  349.                     InvalRect(&editorDialog->portRect);
  350.                 }
  351.                 SetButtons();
  352.                 break;        
  353.             case ewmodifyBU:
  354.                 theCell = LLastClick(editorList) ;
  355.                 myCell.v = myCell.h = 0;                
  356.                 if(LGetSelect(TRUE, &myCell, editorList)) {
  357.                     chosen_object = objectstack->objectlist[theCell.v] ;
  358.                 }
  359.                 else
  360.                     chosen_object = NULL;
  361.                 SetButtons();
  362.                 if(chosen_object) {
  363.                     doObjectModify(chosen_object) ;
  364.                     ReComputeBounds(chosen_object) ;
  365.                 }
  366.                 break ;
  367.             case ewcreateBU:
  368.                 CreateNewObject() ;
  369.                 DestroyObjectList() ;
  370.                 InitObjectList() ;
  371.                 chosen_object = NULL;
  372.                 SetButtons();
  373.                 break ;
  374.             case ewlightsBU:
  375.                 EditLights();
  376.                 break;
  377.         } 
  378.     }
  379.     else {
  380.         switch(theEvent->what) {
  381.             case mouseDown:
  382.                 HandleMouseDown(theEvent);
  383.                 break ;
  384.             case updateEvt:
  385.                 UpdateWind() ;
  386.                 UpdateEditor() ;
  387.                 break ;
  388.             case keyDown: 
  389.             case autoKey:
  390.                 if ((theEvent->modifiers & cmdKey) != 0) {
  391.                     AdjustMenus();
  392.                     HandleMenu(MenuKey((char) (theEvent->message & charCodeMask)));
  393.                 }
  394.                 break;
  395.         }
  396.     }
  397. }
  398.  
  399. void DestroyObjectList()
  400. {
  401.     LDispose(editorList) ;
  402. }
  403.  
  404. void InitObjectList()
  405. {
  406.     short itemType ;
  407.     Handle itemHandle ;
  408.     Rect itemRect, bounds ;
  409.     Point cellSize = {0,0} ;
  410.  
  411.     SetRect(&bounds,0,0,1,0) ;
  412.     GetDItem(editorDialog, worldlistUI, &itemType, &itemHandle, &itemRect);
  413.     itemRect.right -= 15 ;
  414.     editorList = LNew(&itemRect,&bounds,cellSize,0,editorDialog,TRUE,FALSE,FALSE,TRUE) ;
  415.     ConstructAndDisplayObjectList() ;
  416. }
  417.  
  418.     
  419. pascal void DrawCoordInfo(WindowPtr window, short item)
  420. {
  421.     DrawCoordinateInfo(crosshair.x,crosshair.y,crosshair.z) ;
  422. }
  423.  
  424.  
  425. pascal void DoWorldList(WindowPtr window, short item)
  426. {
  427.     GrafPtr        currPort ;
  428.     PenState    saveState;
  429.     short        itemType;
  430.     Handle        itemHandle;
  431.     Rect        itemBox;
  432.  
  433.     GetPort(&currPort) ;
  434.     SetPort(editorDialog) ;
  435.     GetPenState(&saveState);
  436.     GetDItem(editorDialog, worldlistUI, &itemType, &itemHandle, &itemBox);
  437.     PenNormal() ;
  438.     InsetRect(&itemBox,-1,-1) ;
  439.     FrameRect(&itemBox);
  440.     LUpdate(editorDialog->visRgn, editorList) ;
  441.     SetPenState(&saveState);
  442.     SetPort(currPort) ;
  443. }
  444.  
  445. /* 
  446.  * Filter out the object type INSTANCE
  447.  */
  448. Geom *FilterInstances(Geom *obj)
  449. {
  450.     Instance *inst ;
  451.  
  452.     if(ObjectType(obj) == INSTANCE) {
  453.         inst = obj->obj ;
  454.         return inst->obj ;
  455.     }
  456.     return obj ;
  457. }
  458.  
  459. void ConstructAndDisplayObjectList()
  460. {
  461.     Geom *listItem, *parent;
  462.     List *listHead ;
  463.     Csg    *csgHead ;    
  464.     Instance *instance ;
  465.     Grid *grid ;
  466.     
  467.     /* Note that the object list must be constructed from an aggregate object type ie 
  468.      * list,csg, grid. Instances should be caught by the filter routine, but I will check for 
  469.      * them here anyway.
  470.      */
  471.  
  472.     HiliteControl(SnatchHandle(editorDialog,backBU),(objectstack->numparents)?0:255) ;
  473.     objectstack->numobjects = 0 ;
  474.     parent = objectstack->parentlist[objectstack->numparents] ;
  475.     switch(ObjectType(parent)) {
  476.         case LIST:
  477.             listHead = parent->obj ;
  478.             for(listItem = listHead->list ; listItem ; listItem = listItem->next) {
  479.                 objectstack->objectlist[objectstack->numobjects] = FilterInstances(listItem) ;
  480.                 objectstack->numobjects++  ;
  481.             }
  482.             for(listItem = listHead->unbounded ; listItem ; listItem = listItem->next) {
  483.                 objectstack->objectlist[objectstack->numobjects] = FilterInstances(listItem) ;
  484.                 objectstack->numobjects++  ;
  485.             }
  486.             break ;
  487.         case CSG:
  488.             csgHead = parent->obj ;
  489.             objectstack->objectlist[0] = FilterInstances(csgHead->obj1) ;
  490.             objectstack->objectlist[1] = FilterInstances(csgHead->obj2) ;
  491.             objectstack->numobjects = 2 ;
  492.             break ;
  493.         case GRID:
  494.             grid = parent->obj ;
  495.             for(listItem = grid->unbounded ; listItem ; listItem = listItem->next) {
  496.                 objectstack->objectlist[objectstack->numobjects] = FilterInstances(listItem) ;
  497.                 objectstack->numobjects++  ;
  498.             }
  499.             for(listItem = grid->objects ; listItem ; listItem = listItem->next) {
  500.                 objectstack->objectlist[objectstack->numobjects] = FilterInstances(listItem) ;
  501.                 objectstack->numobjects++  ;
  502.             }
  503.             break ;
  504.         case INSTANCE:
  505.             instance = parent->obj ;
  506.             objectstack->numobjects = 1 ;
  507.             objectstack->objectlist[0] = FilterInstances(instance->obj) ;
  508.             break ;
  509.     }
  510.     DisplayObjectList() ;
  511. }
  512.  
  513. void DisplayObjectList()
  514. {
  515.     GrafPtr        currPort ;
  516.     PenState    saveState;
  517.     short        itemType;
  518.     Handle        itemHandle;
  519.     Rect        itemBox;
  520.     WindowPtr    temp ;
  521.     int loop ;
  522.     
  523.     /* Want to draw a box around the list of items */
  524.  
  525.     GetPort(&currPort) ;
  526.     SetPort(editorDialog) ;
  527.     GetPenState(&saveState);
  528.     PenNormal() ;
  529.     GetDItem(editorDialog, worldlistUI, &itemType, &itemHandle, &itemBox);
  530.     itemBox.right -= 15 ;
  531.     EraseRect(&itemBox) ;
  532.     itemBox.right += 15 ;
  533.     InsetRect(&itemBox,-1,-1) ;
  534.     FrameRect(&itemBox);
  535.     LDoDraw(FALSE, editorList) ;
  536.     for(loop = objectstack->numobjects-1 ; loop >=0 ; loop--) {
  537.         InsertObjectList(objectstack->objectlist[loop]) ;
  538.     }
  539.     LDoDraw(TRUE,editorList) ;
  540.     LUpdate(editorDialog->visRgn,editorList) ;
  541.     SetPenState(&saveState);
  542.     SetPort(currPort) ;
  543. }
  544.  
  545. void InsertObjectList(Geom *obj)
  546. {
  547.     char name[255] ;
  548.     Cell cell = {0,0};
  549.     short loop ;
  550.  
  551.     if(obj->name)
  552.         sprintf(name,"%s(%s)%s", obj->name,obj->methods->name(),IsAggregate(obj)?"->":"") ;
  553.     else
  554.         sprintf(name,"%s%s",obj->methods->name(),IsAggregate(obj)?"->":"") ;
  555.     for(loop = strlen(name) ; loop<255 ; loop++) name[loop] = ' ';
  556.     LAddRow(1,cell.v,editorList) ;
  557.     LSetCell(name, 255, cell, editorList); 
  558. }
  559.  
  560. /* Identify each light type by its intensity procedure */
  561. int LightType(Light *l)
  562. {
  563.     extern LightMethods
  564.                     *iExtendedMethods, *iInfMethods, *iJitteredMethods, *iPointMethods,
  565.                     *iSpotMethods ;
  566.     
  567.     if((l == NULL) || (l->methods==NULL))
  568.         return -1 ;
  569.     else if(l->methods == iPointMethods)
  570.         return L_POINT ;
  571.     else if(l->methods == iInfMethods)
  572.         return L_INFINITE ;
  573.     else if(l->methods == iSpotMethods)
  574.         return L_SPOT ;
  575.     else if(l->methods == iJitteredMethods)
  576.         return L_JITTERED ;
  577.     else if(l->methods == iExtendedMethods)
  578.         return L_EXTENDED ;
  579.     else
  580.         return -1 ;
  581. }
  582.  
  583. /* Identify each texture type by the Application prodecure it uses */
  584. int TextureType(Texture *t)
  585. {
  586.     if(t == NULL)
  587.         return -1 ;
  588.     else if(t->method == BlotchApply)
  589.         return T_BLOTCH ;
  590.     else if(t->method == BumpApply)
  591.         return T_BUMP ;
  592.     else if(t->method == CheckerApply)
  593.         return T_CHECKER ;
  594.     else if(t->method == CloudTextApply)
  595.         return T_CLOUD ;
  596.     else if(t->method == FBmApply)
  597.         return T_FBM ;
  598.     else if(t->method == FBmBumpApply)
  599.         return T_FBMBUMP ;
  600.     else if(t->method == GlossApply)
  601.         return T_GLOSS ;
  602.     else if(t->method == ImageTextApply)
  603.         return T_IMAGE ;
  604.     else if(t->method == MarbleApply)
  605.         return T_MARBLE ;
  606.     else if(t->method == SkyApply)
  607.         return T_SKY ;
  608.     else if(t->method == StripeApply)
  609.         return T_STRIPE ;
  610.     else if(t->method == WoodApply)
  611.         return T_WOOD ;
  612.     else 
  613.         return -1 ;
  614. }
  615.  
  616.  
  617. int TransformType(Trans *t)
  618. {
  619.     extern TransMethods *iRotateMethods, *iScaleMethods, *iTranslateMethods ;
  620.  
  621.     if(t == NULL)
  622.         return -1 ;
  623.     else if(t->methods == iScaleMethods)
  624.         return TR_SCALE ;
  625.     else if(t->methods == iTranslateMethods)
  626.         return TR_TRANSLATE ;
  627.     else if(t->methods == iRotateMethods)
  628.         return TR_ROTATE ;
  629.     else
  630.         return -1 ;
  631. }
  632.  
  633. /* Identify each primitive/aggregate from its associated methods procedure */
  634. int ObjectType(Geom *o)
  635. {
  636.     extern Methods     *iBlobMethods, *iBoxMethods, *iConeMethods, *iCsgMethods,
  637.                     *iCylinderMethods, *iDiscMethods, *iGridMethods , *iHfMethods,
  638.                     *iListMethods,*iInstanceMethods, *iPlaneMethods, *iPolygonMethods,
  639.                     *iSphereMethods, *iTorusMethods, *iTriangleMethods ;
  640.  
  641.     if(o == NULL)
  642.         return -1 ;
  643.     else if(o->methods == iPlaneMethods)
  644.         return PLANE ;
  645.     else if(o->methods == iSphereMethods)
  646.         return SPHERE ;
  647.     else if(o->methods == iConeMethods)
  648.         return CONE ;
  649.     else if(o->methods == iBoxMethods)
  650.         return BOX ;
  651.     else if(o->methods == iTorusMethods)
  652.         return TORUS ;
  653.     else if(o->methods == iBlobMethods)
  654.         return BLOB ;
  655.     else if(o->methods == iDiscMethods)
  656.         return DISC ;
  657.     else if(o->methods == iTriangleMethods)
  658.         return TRIANGLE ;
  659.     else if(o->methods == iPolygonMethods)
  660.         return POLYGON ;
  661.     else if(o->methods == iHfMethods)
  662.         return HF ;
  663.     else if(o->methods == iCylinderMethods)
  664.         return CYLINDER ;
  665.     else if(o->methods == iCsgMethods)
  666.         return CSG ;
  667.     else if(o->methods == iListMethods)
  668.         return LIST ;
  669.     else if(o->methods == iGridMethods)
  670.         return GRID ;
  671.     else if(o->methods == iInstanceMethods)
  672.         return INSTANCE ;
  673.     else 
  674.         return -1 ;
  675. }
  676.  
  677. Geom *GetCurrentParent()
  678. {
  679.     return objectstack->parentlist[objectstack->numparents] ;
  680. }
  681.  
  682. void dummy()
  683. {
  684. }
  685.  
  686. void UpdateEditor()
  687. {
  688.     GrafPtr currPort ;
  689.     int invert ;
  690.     short itype,loop ;
  691.     ControlHandle itemHandle ;
  692.     Rect itemRect ;
  693.     
  694.     if(editorDialog) {
  695.         GetPort(&currPort) ;
  696.         SetPort(editorDialog);
  697.         BeginUpdate(editorDialog);
  698.         UpdtDialog(editorDialog,editorDialog->visRgn);
  699.         EndUpdate(editorDialog);
  700.         for(loop = sphereselectIC ; loop <= cameraselectIC; loop++) {
  701.             invert = 0 ;
  702.             switch(loop) {
  703.                 case sphereselectIC:    invert = FILTER_SET(F_SPHERE);        break ;
  704.                 case cylinderselectIC:    invert = FILTER_SET(F_CYLINDER);    break ;
  705.                 case coneselectIC:        invert = FILTER_SET(F_CONE);        break ;
  706.                 case triangleselectIC:    invert = FILTER_SET(F_TRIANGLE);    break ;
  707.                 case torusselectIC:        invert = FILTER_SET(F_TORUS);        break ;
  708.                 case blobselectIC:        invert = FILTER_SET(F_BLOB);        break ;
  709.                 case boxselectIC:        invert = FILTER_SET(F_BOX);            break ;
  710.                 case discselectIC:        invert = FILTER_SET(F_DISC);        break ;
  711.                 case polyselectIC:        invert = FILTER_SET(F_POLYGON);        break ;
  712.                 case csgselectIC:        invert = FILTER_SET(F_CSG);            break ;
  713.                 case lightsselectIC:    invert = FILTER_SET(F_LIGHTS);        break ;
  714.                 case cameraselectIC:    invert = FILTER_SET(F_CAMERA);        break ;
  715.             }
  716.             if(invert) {
  717.                 GetDItem(editorDialog,loop,&itype,&itemHandle,&itemRect) ;
  718.                 InvertRect(&itemRect) ;
  719.             }
  720.         }
  721.         SetPort(currPort);
  722.     }
  723. }
  724.