home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Applications / UIFlow 1.0.1 / UIFlow Source / CFDFront / UIFlow.cp < prev    next >
Encoding:
Text File  |  1993-04-14  |  23.8 KB  |  797 lines  |  [TEXT/MPS ]

  1. #pragma segment geometry
  2. #include "Globals.h"
  3. #include "NewStuff.h"
  4. // #include "DTMClass.h"
  5. #include "CFDFront.h"                                                                                // all class headers
  6.  
  7. #include "CFunctions.c"
  8. #include "TWarnDialog.cp"                                                                        // error dialog
  9.  
  10. // #include "TFilterDialog.cp"
  11. #include "TModelessDialog.cp"                                                                    // modeless dialog base class
  12. #include "TModalDialog.cp"                                                                        // modal dialogs
  13. #include "TDataView.cp"                                                                            // segment data view class
  14. #include "TInformationView.cp"                                                                // info view at bottom of geom view
  15.  
  16. #include "TOptPrint.cp"                                                                            // print options dialog
  17. #include "TOptFlow.cp"                                                                                // flow parameters dialog
  18. #include "TOptSolution.cp"                                                                        // solutions parameters dialog
  19. #include "TOptRelax.cp"                                                                            // relaxation parameters
  20.  
  21. #include "CFDFrontDocument.cp"
  22. #include "TFortranView.cp"                                                                // info view at bottom of geom view
  23. #include "TPctsView.cp"
  24. #include "TTrash.cp"
  25.  
  26. extern pascal void INITFORTRAN();
  27. extern pascal void EXITFORTRAN();
  28.  
  29. // **********************************************************************
  30. //    TGeomView Methods.
  31. // **********************************************************************
  32. // --------------------------------------------------------------------------------------------------
  33. //    init this from our own resource.
  34. // --------------------------------------------------------------------------------------------------
  35. pascal void TGeomView::IRes (TDocument * itsDocument, TView * itsSuperView, Ptr * itsParams)
  36.     {
  37.     TView::IRes(itsDocument, itsSuperView, itsParams);
  38.     fDocument    = itsDocument;
  39.     fCDocument    = (TCFDFrontDocument *) itsDocument;
  40.     fDragging    =    true;
  41.     fSPoint        =    NULL;                                                                                // store the point
  42.     fSSide        =     NULL;
  43.     fSegment    =    false;
  44.     fHorizSize =    0;
  45.     fVertSize    =    0;
  46.     fMagnify    =    0;
  47.     fMCount    =    0;
  48.     return;
  49.     }
  50.  
  51. // --------------------------------------------------------------------------------------------------
  52. //    get the size of the geometry subview.
  53. // --------------------------------------------------------------------------------------------------
  54. void TGeomView::SetGeomViewSize (void)
  55.     {
  56.     if ( fCDocument->fWidth > fCDocument->fHeight)                                                        // calculate the size of the view
  57.         {
  58.         fHorizSize = cMaxSize + 5;
  59.         fCDocument->fUnitFraction = fCDocument->fWidth / cMaxSize;
  60.         fVertSize = (short)((fCDocument->fHeight / fCDocument->fWidth) * (float)cMaxSize) + 5;
  61.         }
  62.     else    
  63.         {
  64.         fVertSize = cMaxSize +5;
  65.         fCDocument->fUnitFraction = fCDocument->fHeight / cMaxSize;
  66.         fHorizSize = (short) ((fCDocument->fWidth / fCDocument->fHeight) * (float)cMaxSize) + 5;
  67.         }
  68.     
  69.     this->AdjustSize();                                                                                                            // now resize the view.
  70.     }
  71.  
  72. // --------------------------------------------------------------------------------------------------
  73. //    get the size of the geometry subview.
  74. // --------------------------------------------------------------------------------------------------
  75. void TGeomView::MagnifyView (float mag)
  76.     {
  77.     VPoint     newView;
  78.     Rect     oRect;
  79.     
  80.     oRect.top             = 0;
  81.     oRect.left            = 0;
  82.     oRect.right        = (short) fSize.h;
  83.     oRect.bottom    = (short) fSize.v;
  84.     HLock((Handle) this);
  85.     this->InvalidRect(&oRect);
  86.     HUnlock((Handle) this);
  87.     
  88.     if (mag == 0)
  89.         {
  90.         newView.h = (cMaxSize + (2 * cGeomViewBorder)) ;
  91.         newView.v = (cMaxSize + (2 * cGeomViewBorder));
  92.         }
  93.     else
  94.         {
  95.         newView.h = (cMaxSize + (2 * cGeomViewBorder)) * mag;
  96.         newView.v = (cMaxSize + (2 * cGeomViewBorder)) * mag;
  97.         }
  98.     Resize(newView.h,newView.v,false);                                                                            // now resize the view.
  99.     }
  100.  
  101. // --------------------------------------------------------------------------------------------------
  102. //    Draws the rectangle
  103. // --------------------------------------------------------------------------------------------------
  104. pascal void TGeomView::Draw(Rect * /*tRect*/)
  105.     {
  106.     Point pen;
  107.     Rect  tRect;
  108.     pen.v = 1;     pen.h = 1;
  109.     tRect.top = 0;
  110.     tRect.left = 0;
  111.     tRect.right = (short) fSize.h;
  112.     tRect.bottom = (short) fSize.v;
  113.  
  114.     HLock((Handle) this);
  115.     RGBForeColor(&GridLineColor);                                                                    // set color
  116.     PenPixPat(GridLinePat);
  117.     
  118.     this->Adorn(&tRect,pen,adnLineRight);
  119.     this->Adorn(&tRect,pen,adnLineBottom);
  120.     HUnlock((Handle) this);
  121.     fCDocument->fPointMatrix->DoDraw();
  122.     }
  123.  
  124. // --------------------------------------------------------------------------------------------------
  125. //     calculate a minimum size
  126. //--------------------------------------------------------------------------------------------------
  127. pascal void TGeomView::CalcMinSize(VPoint * minSize)
  128.     {     
  129.     minSize->h = fHorizSize + cGeomViewBorder*2;
  130.     minSize->v = fVertSize + cGeomViewBorder*2;
  131.     }
  132.  
  133. // --------------------------------------------------------------------------------------------------
  134. //    Do the mouse command.
  135. // --------------------------------------------------------------------------------------------------
  136. pascal struct TCommand * TGeomView::DoMouseCommand(Point * theMouse, EventInfo *  eInfo,
  137.                             Point * /*hysteresis*/)
  138.     {
  139.     char strng[255];                                                                                                        // temp string
  140.     int n = 0;
  141.     Point mMouse;
  142.     
  143.     mMouse = AntiTransform(* theMouse, fMagnify);
  144. // what mouse action mode is available?
  145. //
  146. //    Get Mouse Action returns the palette number... telling the program which function is
  147. //    currently being executed.
  148. //
  149.     fCDocument->fInfoView->ClrInfo();
  150.     switch (fCDocument->GetMouseAction())
  151.         {
  152.         TPoint * tPt;                                                                                            // the point
  153.         TBoundry * side;
  154.  
  155.         case cDragTool:                                                                                        // palette option #0
  156.             HLock((Handle) this);
  157.             if ((tPt = (TPoint *) (fCDocument->fPointMatrix)->FindPoint(theMouse)) == NULL) // on a point?
  158.                 {
  159.                 HUnlock((Handle) this);
  160.                 return gNoChanges;                                                                            // LAM -- give message
  161.                 }
  162.                 
  163.             HUnlock((Handle) this);
  164.             this->Focus();
  165.             fCDocument->fPointMatrix->DoHighlight();
  166.             side = (TBoundry *) fCDocument->fPointMatrix->GetCurrentBoundry();
  167.             this->UnSelect();                                                                                    // unselect the current stuff
  168.             this->Select(tPt,false,side);                                                                    // select new point
  169.  
  170.             fCDocument->fPointMatrix->DoHighlight();
  171.             TDragCommand * nDrag;
  172.             nDrag = new TDragCommand;                                                                // allocate space
  173.             if (nDrag == NULL)
  174.                 return gNoChanges;                                                                            // LAM -- give message
  175.             HLock((Handle) this);
  176.             if (nDrag->IDragCommand(this,tPt,theMouse) == 1)                                // init the dragger
  177.                 {
  178.                 HUnlock((Handle) this);
  179.                 return gNoChanges;                                                                            // LAM -- give message
  180.                 }
  181.             HUnlock((Handle) this);
  182.             return nDrag;
  183. //
  184. //     Add a Segment
  185. //
  186.         case cSegmentTool:                                                                                    // palette option #1
  187. //
  188. //    A BOUNDRY operation.....
  189. //    the point does not already exist so create it.
  190. //
  191.             HLock((Handle) this);
  192.             if ((tPt = (TPoint *) (fCDocument->fPointMatrix)->FindBoundryPoint (theMouse)) != NULL)
  193.                 {
  194.                 HUnlock((Handle) this);
  195.                 if (!tPt->IsCornor() && tPt->IsSegment())                                        // make sure is a segment
  196.                     {                        
  197.                     TDeletePointCommand * deletePoint;                                                // create delete command object
  198.                     deletePoint = new TDeletePointCommand;
  199.                     if (deletePoint == NULL) {}                                                            // LAM - error processing
  200.                     if (!deletePoint->IDeletePointCommand(this,tPt))                             // init the delete object
  201.                         return gNoChanges;
  202.                     return deletePoint;
  203.                     }
  204.                 return gNoChanges;
  205.                 }
  206.         
  207.             HUnlock((Handle) this);
  208.             TNewSegmentCommand * nSegment;                                                        // declare command
  209.             nSegment = new TNewSegmentCommand;                                                 // create a command object to handle this one.
  210.                 FailNIL (nSegment);                                                                            // creation sucessful?
  211.             nSegment->INewSegmentCommand (this, fCDocument);                            // init the command object
  212.             return nSegment;                                                                                    // return the command object to MacApp
  213. //
  214. //     Add a Section
  215. //
  216.         case cGridTool:                                                                                            // palette option #2
  217. //
  218. //    A BOUNDRY operation.....
  219. //    the point does not already exist so create it.
  220. //
  221.             HLock((Handle) this);
  222.             if ((tPt = (TPoint *) (fCDocument->fPointMatrix)->FindBoundryPoint (theMouse)) != NULL)
  223.                 {
  224.                 HUnlock((Handle) this);
  225.                 if (!tPt->IsCornor() && tPt->IsBoundryPt() && !tPt->IsSegment())    // make sure on the boundry
  226.                     {                        
  227.                     TDeleteGridCommand * deletePoint;                                                // create delete command object
  228.                     deletePoint = new TDeleteGridCommand;
  229.                     if (deletePoint == NULL) {}                                                            // LAM - error processing
  230.                     if (!deletePoint->IDeleteGridCommand(this,tPt))                             // init the delete object
  231.                         return gNoChanges;
  232.                     return deletePoint;
  233.                     }
  234.                 return gNoChanges;
  235.                 }
  236.                 
  237.             HUnlock((Handle) this);
  238.             TNewSectionCommand * nSection;                                                        // declare command
  239.             nSection = new TNewSectionCommand;                                                     // create a command object to handle this one.
  240.                 FailNIL (nSection);                                                                // creation sucessful?
  241.             nSection->INewSectionCommand (this, fCDocument);                                    // init the command object
  242.             return nSection;                                                                    // return the command object to MacApp
  243.  
  244. //
  245. //        Baffle Operations
  246. //
  247.         case cBaffle:
  248.             {
  249.             short         tDirection;
  250.             PointInfo     info;
  251.             Boolean        t1, t2;
  252.             
  253.             HLock((Handle) this);
  254.             tDirection = fCDocument->fPointMatrix->FindLine(&mMouse,&info);                        // get associated segment
  255.             HUnlock((Handle) this);
  256.             if (tDirection == 0)
  257.                 break;
  258.                 
  259.             t1 = TRUE;
  260.             t2 = TRUE;
  261.             if (info.above == NULL)
  262.                 t1 = FALSE;
  263.             else if (info.above->fBaffBelow == NULL)
  264.                 t1 = FALSE;
  265.             if (info.left == NULL)
  266.                 t2 = FALSE;
  267.             else if (info.left->fBaffRight == NULL)
  268.                 t2 = FALSE;
  269.             if ((tDirection == 1 && t1) || (tDirection == 2 && t2))
  270.                 {
  271.                 if (info.above->fBaffBelow == NULL)
  272.                     break;
  273.                 TDeleteBaffleCommand * dCommand;
  274.                 dCommand = new TDeleteBaffleCommand;
  275.                     FailNIL (dCommand);
  276.                 HLock((Handle) this);
  277.                 if (!(dCommand->IDeleteBaffleCommand (this, fCDocument, &info, tDirection)))    // initialize delete obstacle
  278.                     {
  279.                     HUnlock((Handle) this);
  280.                     return gNoChanges;
  281.                     }
  282.                 HUnlock((Handle) this);
  283.                 return dCommand;
  284.                 }
  285.                 
  286.             TBaffleCommand * bCommand;
  287.             bCommand = new TBaffleCommand;
  288.                 FailNIL (bCommand);                                                                // LAM
  289.             HLock((Handle) this);
  290.             bCommand->IBaffleCommand (this, fCDocument, &info,tDirection);                        // initialize command
  291.             HUnlock((Handle) this);
  292.             return bCommand;
  293.             }
  294.             break;
  295. //
  296. //        Obstacle Operations
  297. //
  298.         case cObstacle:
  299.             {
  300.             TPoint                         *    tPt;
  301.             PointInfo                     info;
  302.             
  303.             HLock((Handle) this);
  304.             tPt = fCDocument->fPointMatrix->FindCell(&mMouse,&info);                            // get associated segment
  305.             HUnlock((Handle) this);
  306.             if (tPt == NULL)
  307.                 break;
  308.  
  309.             if (tPt->GetObsQuad(4) != NULL)                                                        // already an obstacle
  310.                 {
  311.                 TDeleteObstacleCommand * dCommand;
  312.                 dCommand = new TDeleteObstacleCommand;
  313.                     FailNIL (dCommand);
  314.                 HLock((Handle) this);
  315.                 if (!(dCommand->IDeleteObstacleCommand (this, fCDocument, &info)))                // initialize delete obstacle
  316.                     {
  317.                     HUnlock((Handle) this);
  318.                     return gNoChanges;
  319.                     }
  320.                 HUnlock((Handle) this);
  321.                 return dCommand;
  322.                 }
  323.         
  324.             TObstacleCommand     * oCommand;
  325.             oCommand = new TObstacleCommand;
  326.                 FailNIL (oCommand);                                                                            // LAM
  327.             HLock((Handle) this);
  328.             oCommand->IObstacleCommand(this, fCDocument,&info);
  329.             HUnlock((Handle) this);
  330.             return oCommand;
  331.             }
  332. //
  333. //    View segment data
  334. //
  335.         case cData:                                                                                                // segment data
  336.             {
  337.             TSegPoint    * sPt;
  338.             
  339.             HLock((Handle) this);
  340.             tPt = fCDocument->fPointMatrix->FindSection(&mMouse);                        // returns boundry point is on
  341.             HUnlock((Handle) this);
  342.             if (tPt == NULL)
  343.                 {
  344.                 if (fSPoint != NULL && fSPoint->IsBoundryPt())
  345.                     fCDocument->fPointMatrix->DoHighlight();
  346.                 this->UnSelect();
  347.                 this->Select(fCDocument->fInterior,false,NULL);
  348.                 fCDocument->fDataView->ShowData(fCDocument->fInterior);
  349.                 break;
  350.                 }
  351.             side = (TBoundry *) fCDocument->fPointMatrix->GetCurrentBoundry();
  352.                                                                                                                         // also sets fRow & fCol to current section
  353.             sPt = fCDocument->fPointMatrix->FindSegment(tPt,side);                        // get associated segment
  354.             
  355.             if (sPt == NULL)                                                                                    // not on a boundry
  356.                 return gNoChanges;                                                                            // return nothing
  357.  
  358.             if (fSPoint != NULL && !fSPoint->IsInterior())
  359.                 fCDocument->fPointMatrix->DoHighlight();
  360.             this->UnSelect();                                                                                    // unselect the current stuff
  361.         
  362.             this->Select(sPt,true,side);                                                                    // select new point
  363.             fCDocument->fPointMatrix->DoHighlight();                                            // highlight the selection
  364.             fCDocument->fDataView->ShowData(sPt);                                                // show the data
  365.             break;
  366.             }
  367. //
  368. //    Magnify
  369. //
  370.         case cMagnify:                                                                                            // segment data
  371.             {
  372.             if (!eInfo->theCmdKey)
  373.                 {
  374.                 if (fMCount == 7.5)
  375.                     {
  376.                     SysBeep (3);
  377.                     return gNoChanges;
  378.                     }
  379.                 fMCount += 1.5;
  380.                 }
  381.             else
  382.                 {
  383.                 if (fMCount == -7.5)
  384.                     {
  385.                     SysBeep (3);
  386.                     return gNoChanges;
  387.                     }
  388.                 fMCount -= 1.5;
  389.                 }
  390.             if (fMCount > 0)
  391.                 fMagnify = fMCount;
  392.             else if (fMCount < 0)
  393.                 fMagnify = 1 / (-1 * fMCount);
  394.             else
  395.                 fMagnify = 0;
  396.             
  397.             PointInfo     info;
  398.             TPoint         * tPt;
  399.  
  400.             info.gridOnly     = false;
  401.             info.magnify        = fMagnify;
  402.             info.lrc                = NULL;
  403.             
  404.             HLock((Handle) this);
  405.             fCDocument->fPointMatrix->Each(TransformGrid,&info);
  406.             tPt = (TPoint *) (fCDocument->fPointMatrix->fRight)->Last();
  407.             tPt->TransformPoint(fMagnify);
  408.             HUnlock((Handle) this);
  409.             
  410.             this->MagnifyView(fMagnify);
  411.             this->ForceRedraw();
  412.             break;
  413.             }
  414.         } 
  415.     return gNoChanges;                                                                                        // no command.
  416.     }
  417.  
  418. // --------------------------------------------------------------------------------------------------
  419. //     unselected the segment
  420. //--------------------------------------------------------------------------------------------------
  421. void TGeomView::UnSelect(void)
  422.     {
  423.     if (fSPoint != NULL)                                                                                        // highlighted object is point
  424.         {
  425.         if (fSegment)
  426.             fCDocument->fPointMatrix->SelectSegment(fSPoint,fSSide,false);
  427.         else
  428.             fSPoint->SetSelection(false);
  429.  
  430.         fSPoint    =    NULL;                                                                                        // store the point
  431.         fSSide    =     NULL;
  432.         fSegment = false;
  433.         }
  434.     }
  435.     
  436. // --------------------------------------------------------------------------------------------------
  437. //     selected the segment
  438. //--------------------------------------------------------------------------------------------------
  439. void TGeomView::Select(TPoint * tPt, Boolean seg, TRow * side)
  440.     {
  441.     fSPoint        =    tPt;                                                                                            // store the point
  442.     fSSide        =    side;
  443.     fSegment    =    seg;                                                                                            // store the boundry
  444.  
  445.     if (seg)
  446.         fCDocument->fPointMatrix->SelectSegment(tPt,side,true);
  447.     else
  448.         tPt->SetSelection(true);
  449.     return;
  450.     }
  451.     
  452. // --------------------------------------------------------------------------------------------------
  453. //     change cursor?
  454. //--------------------------------------------------------------------------------------------------
  455. pascal Boolean TGeomView::DoSetCursor(Point localPoint, RgnHandle /*cursorRgn*/)
  456.     {
  457.     switch (fCDocument->GetMouseAction())
  458.         {
  459.         case cDragTool :
  460.         case cGridTool :
  461.         case cSegmentTool:
  462.             HLock((Handle) this);
  463.             if (fCDocument->fPointMatrix->FindPoint(&localPoint) == NULL)
  464.                 {
  465.                 HUnlock((Handle) this);
  466.                 InitCursor();
  467.                 return false;
  468.                 }
  469.                 
  470.             HUnlock((Handle) this);
  471.             SetCursor(*PointCursor);
  472.             return true;
  473.     
  474.         case cMagnify:
  475.             {
  476.             KeyMap     theKeys;
  477.             Boolean        t;
  478.             GetKeys(theKeys);
  479.     
  480.             t = BitTst(theKeys,(long) 48);
  481.             if (t)
  482.                 SetCursor(*MagCursorDn);
  483.             else
  484.                 SetCursor(*MagCursorUp);
  485.             return true;
  486.             }
  487.         default:
  488.             InitCursor();
  489.             return false;
  490.         } 
  491.     return false;
  492.     }
  493.     
  494. // --------------------------------------------------------------------------------------------------
  495. //    get the size of the geometry subview.
  496. // --------------------------------------------------------------------------------------------------
  497. Point TGeomView::DragCurrent (Point newPoint)
  498.     {
  499.     Point savePt;                                                                                            // temp storage
  500.     
  501.     savePt.v = 0;
  502.     savePt.h = 0;
  503.     this->Focus();
  504.     if (fSPoint != NULL)                                                                                    // if have a selected point
  505.         {
  506.         savePt = fSPoint->GetStart();
  507.         TDragCommand * nDrag;
  508.         nDrag = new TDragCommand;                                                                // allocate space
  509.             FailNIL(nDrag);
  510.             
  511.         HLock((Handle) this);
  512.         if (nDrag->IDragCommand(this,fSPoint,&newPoint) == 1)                        // init the dragger
  513.             {
  514.             HUnlock ((Handle) this);
  515.             return savePt;                                                                                    // LAM -- give message
  516.             }
  517.         
  518.         fCDocument->fPointMatrix->DoHighlight();                                            // unhighlight point
  519.         nDrag->MovePoint();                                                                            // move the point
  520.         HUnlock ((Handle) this);
  521.         }
  522.     return savePt;
  523.     }
  524.     
  525. // --------------------------------------------------------------------------------------------------
  526. //    The application initializer.
  527. // --------------------------------------------------------------------------------------------------
  528. pascal void TCFDFrontApplication::ICFDFrontApplication(OSType itsMainFileType)
  529.     {
  530.     int i;
  531.     
  532.     IApplication(itsMainFileType);
  533.     
  534.     fLaunchWithNewDocument = FALSE;
  535. // So my view will be substituted when MacAppĀ® creates the "default view"
  536.     RegisterStdType("\pTGeomView", 'DFLT');
  537.     
  538.     if (gDeadStripSuppression)                                                            // So the linker doesn't dead strip class info 
  539.         {
  540.         TWarning * warnMe = new TWarning;
  541.           TInformationView *infoView = new TInformationView;
  542.           TFortranView *fortView = new TFortranView;
  543.         TGeomView *aGeomView = new TGeomView;
  544.         TOpPict * aOpPict = new TOpPict;
  545.         TPctsView * aPctsView = new TPctsView;
  546.         TDimension * aDimension = new TDimension;
  547.         TDataView * aDataView = new TDataView;
  548.         TOptSolution * aSolution = new TOptSolution;
  549.         TOptPrint * anOptPrint = new TOptPrint;
  550.         TOptFlow * anOptFlow = new TOptFlow;
  551.         TOptSolution * anOptSolution = new TOptSolution;
  552.         TBoundryRadius * aRadius = new TBoundryRadius;
  553.         TPremix * aMix = new TPremix;
  554.         TDiffusion * aDiffusion = new TDiffusion;
  555.         TTurbulence * aTurbulence = new TTurbulence;
  556.         TRelax * aRelaxation = new TRelax;
  557.         TPressure * aPressure = new TPressure;
  558.         TWarnDelete * dWarn = new TWarnDelete;
  559.         TCTrash * trash = new TCTrash;
  560.         TAppDialog * app = new TAppDialog;
  561.         TImageDialog * img = new TImageDialog;
  562.         }
  563.       
  564.     for (i=0; i < NumSegmentTypes; i++)
  565.         GetIndPattern (SegPatterns[i], 0, pat[i]);
  566.         
  567.     fReadOld = false;
  568.     }
  569.  
  570. // --------------------------------------------------------------------------------------------------
  571. //    Watch for magnification icon
  572. // --------------------------------------------------------------------------------------------------
  573. pascal void TCFDFrontApplication::OpenOld(CmdNumber itsOpenCmd, AppFile *anAppFile)
  574.     {
  575.     fReadOld = true;
  576.     inherited::OpenOld(itsOpenCmd,anAppFile);
  577.     fReadOld = false;
  578.     }
  579.  
  580. // --------------------------------------------------------------------------------------------------
  581. //    Watch for magnification icon
  582. // --------------------------------------------------------------------------------------------------
  583. pascal void TCFDFrontApplication::Idle(IdlePhase phase)
  584.     {
  585.     TWindow         *     tWindow;
  586.     TGeomView    *    tGeom;
  587.     tWindow     = (TWindow *) this->GetActiveWindow();
  588.     if (tWindow == NULL)
  589.         {
  590.         inherited::Idle(phase);
  591.         return;
  592.         }
  593.     tGeom        = (TGeomView *) tWindow->FindSubView('geom');
  594.     if (tGeom == NULL)
  595.         {
  596.         inherited::Idle(phase);
  597.         return;
  598.         }
  599.     
  600.     if (((TCFDFrontDocument *) (tGeom->fCDocument))->GetMouseAction() == cMagnify)
  601.         {
  602.         KeyMap     theKeys;
  603.         Boolean        t;
  604.     
  605.         GetKeys(theKeys);
  606.         t = BitTst(theKeys,(long) 48);
  607.         if (t)
  608.             SetCursor(*MagCursorDn);
  609.         else
  610.             SetCursor(*MagCursorUp);
  611.         }
  612.  
  613.     inherited::Idle(phase);
  614.     }
  615.     
  616. // --------------------------------------------------------------------------------------------------
  617. //    Enable and disable menu items for this kind of application
  618. // --------------------------------------------------------------------------------------------------
  619. pascal void TCFDFrontApplication::DoSetupMenus (void)
  620.     {
  621.     // enable new
  622.     inherited::DoSetupMenus();
  623.     for (short menuIndex = cFirst; menuIndex <= cLast; menuIndex++)
  624.         Enable(menuIndex,true);
  625.     Enable(cPrintOne,false);
  626.     Enable(cPageSetup,false);
  627.     Enable(cPrint,false);
  628.     Enable(cSelectAll,false);
  629.     Enable(cShowClipboard,false);
  630.     }
  631.  
  632. // --------------------------------------------------------------------------------------------------
  633. //    Show About UIFlow Tool
  634. // --------------------------------------------------------------------------------------------------
  635. pascal void TCFDFrontApplication::DoShowAboutApp(void)
  636.     {
  637.     Str255    tmp;
  638.     StringHandle strHandle;
  639.     DialogPtr theSplash;
  640.     
  641.     // get the splash screen
  642.     tmp[0] = NULL;
  643.     strHandle = StringHandle (GetResource ('SPFW',0));
  644.     if (strHandle == NULL)
  645.         exit(0);
  646.     ParamText (*strHandle, tmp, tmp, tmp);
  647.     
  648.     theSplash = GetNewCenteredDialog (1000, NULL, (WindowPtr) -1);
  649.     
  650.     if (theSplash)
  651.         {
  652.         SetPort (theSplash);
  653.         DrawDialog (theSplash);
  654.         }
  655.     else
  656.         SysBeep (3);
  657.         
  658. // ditch the splash screen.
  659.     EventRecord theEvent;
  660.     Boolean         loop = TRUE;
  661.     while (loop)
  662.         {
  663.         GetOSEvent(keyDownMask+mDownMask,&theEvent);
  664.         if (theEvent.what == keyDown || theEvent.what == mouseDown)
  665.             loop = FALSE;
  666.         }
  667.  
  668.     if (theSplash)
  669.         DisposDialog (theSplash);
  670.     }
  671.         
  672. // --------------------------------------------------------------------------------------------------
  673. //    Enable and disable menu items for this kind of application
  674. // --------------------------------------------------------------------------------------------------
  675. pascal void TCFDFrontApplication::SetUndoText(Boolean cmdDone, CmdNumber aCmdNumber)
  676.     {
  677.     StringPtr pString;
  678.     char            string[80];
  679.     short        i;
  680.     
  681.     if (cmdDone)
  682.         i = sprintf(string,"Undo ");
  683.     else
  684.         i = sprintf(string,"Redo ");
  685.         
  686.     switch (aCmdNumber)
  687.         {
  688.         case cMakeBaffle:
  689.             sprintf(string+i,"Create Baffle");
  690.             break;
  691.         case cMakeObstacle:
  692.             sprintf(string+i,"Create Obstacle");
  693.             break;
  694.         case cDragPointCommand:
  695.             sprintf(string+i,"Drag Point");
  696.             break;
  697.         case cNewSegCommand:
  698.             sprintf(string+i,"Create Segment");
  699.             break;
  700.         case cNewSecCommand:
  701.             sprintf(string+i,"Create Section");
  702.             break;
  703.         case cDeleteSegCommand:
  704.             sprintf(string+i,"Delete Segment");
  705.             break;
  706.         case cDeleteSecCommand:
  707.             sprintf(string+i,"Delete Section");
  708.             break;
  709.         case cDeleteBaffle:
  710.             sprintf(string+i,"Delete Baffle");
  711.             break;
  712.         case cDeleteObstacle:
  713.             sprintf(string+i,"Delete Obstacle");
  714.             break;
  715.         default:
  716.             inherited::SetUndoText(cmdDone,aCmdNumber);
  717.             return;
  718.         }
  719.     pString = c2pstr(string);
  720.     SetCmdName(cUndo,pString);
  721.     gUndoState    =    cmdDone;
  722.     gUndoCmd        =    aCmdNumber;
  723.     return;
  724.     }
  725.  
  726. // -------------- main program -----------------------------------
  727. // GLOBALS
  728.  
  729. #pragma segment Main
  730.  
  731. void main ()
  732.     {
  733.     Str255    tmp;
  734.     StringHandle strHandle;
  735.     DialogPtr theSplash;
  736.  
  737.     InitToolBox();                                                                                        // init the mac tool box
  738.     PullApplicationToFront();                                                                        // bring the application to front
  739.     
  740. // does the mac have the hardware / software to run this program
  741.     if (ValidateConfiguration (&gConfiguration))
  742.         {
  743. // get the version number for the program.
  744.         tmp[0] = NULL;
  745.         strHandle = StringHandle (GetResource ('SPFW',0));
  746.         if (strHandle == NULL)
  747.             exit(0);
  748.         ParamText (*strHandle, tmp, tmp, tmp);
  749.         
  750. // get the splash screen
  751.         theSplash = GetNewCenteredDialog (1000, NULL, (WindowPtr) -1);
  752.  
  753.         if (theSplash)
  754.             {
  755.             SetPort (theSplash);
  756.             DrawDialog (theSplash);
  757.             }
  758.         else
  759.             SysBeep (3); 
  760.             
  761. // init the MacApp stuff. 
  762.         
  763.         INITFORTRAN();
  764.         InitUMacApp (8);                                                                                    // mac app mem management. 
  765.         InitUTEView ();                                                                                        // init the text edit stuff. 
  766.         InitUGridView ();                                                                                    // init the grid list manager.     
  767.         InitUDialog ();                                                                                        // init the dialog manager. 
  768.         InitColorPattern();                                                                                // initialize the color pix pattern
  769.         
  770.         PointCursor = GetCursor(128);
  771.         HLock((Handle) PointCursor);
  772.         MagCursorUp = GetCursor(131);
  773.         HLock((Handle) MagCursorUp);
  774.         MagCursorDn = GetCursor(132);
  775.         HLock((Handle) MagCursorDn);
  776.  
  777. //--------------------------------------------------------------------------------------------------------        
  778. // Allocate a new Application object, and check for errors
  779. //--------------------------------------------------------------------------------------------------------                
  780.         gUnloadAllSegs = false;
  781.         gCFDFrontApplication = new TCFDFrontApplication;
  782.         FailNIL(gCFDFrontApplication);
  783.         
  784. // Initialize the application object
  785.         gCFDFrontApplication->ICFDFrontApplication(kFileType);
  786.  
  787. // ditch the splash screen.
  788.         if (theSplash)
  789.             DisposDialog (theSplash);
  790.             
  791. // Run the application. When it's done, exit.
  792.         gCFDFrontApplication->Run();
  793.         EXITFORTRAN();
  794.         }        
  795. }
  796.         
  797.