00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #ifndef INC_MI32_GRTOOL_H
00048 #define INC_MI32_GRTOOL_H
00049
00050 #ifndef INC_MI32_STDAFX_H
00051 #include <mi32/stdafx.h>
00052 #endif
00053
00054 #ifndef INC_MGUI_DLGBASE_H
00055 #include <mgui/dlgbase.h>
00056 #endif
00057
00058 #ifndef INC_MGUI_COMMAND_H
00059 #include <mgui/command.h>
00060 #endif
00061
00062 #ifndef INC_MI32_TRANS2DC_H
00063 #include <mi32/trans2dc.h>
00064 #endif
00065
00066 #ifndef INC_MI32_REGION2D_H
00067 #include <mi32/region2d.h>
00068 #endif
00069
00070 #ifndef INC_MI32_DOUBLEAR_H
00071 #include <mi32/doublear.h>
00072 #endif
00073
00074 #ifndef INC_MI32_ELEMSTYL_H
00075 #include <mi32/elemstyl.h>
00076 #endif
00077
00078 #include <list>
00079
00080 namespace MicroImages {
00081
00082 class GRTOOLVIEW;
00083
00084
00085
00086
00087
00088
00089 class GRTOOL {
00090 public:
00091
00092
00093 enum ADJUSTFLAGS {
00094 ADJUST_Default = 0x00,
00095 ADJUST_Absolute = 0x01,
00096 ADJUST_ScreenCoords = 0x02,
00097 ADJUST_Notify = 0x80
00098 };
00099
00100 enum CTRLOPT {
00101 CTRLOPT_Default = 0x00,
00102 CTRLOPT_Manual = 0x01,
00103 CTRLOPT_GPS = 0x02,
00104 CTRLOPT_SnapGrid = 0x04,
00105 CTRLOPT_NoManualProj = 0x08
00106 };
00107
00108 enum MOVESEQ {
00109 MOVESEQ_Begin = 1,
00110 MOVESEQ_Continue = 2,
00111 MOVESEQ_End = 3,
00112 MOVESEQ_Cancel = 4
00113 };
00114
00115 enum MOVETYPE {
00116 MOVETYPE_None = 0,
00117 MOVETYPE_Shift = 1,
00118 MOVETYPE_Resize = 2,
00119 MOVETYPE_Rotate = 3,
00120 MOVETYPE_Shear = 4,
00121 MOVETYPE_Edit = 5,
00122 MOVETYPE_Create = 6,
00123 MOVETYPE_Clear = 7
00124 };
00125
00126
00127 enum MARKER {
00128 MARKER_X = 0,
00129 MARKER_Plus = 1,
00130 MARKER_ArrowIn = 2,
00131 MARKER_ArrowOut = 3,
00132 MARKER_None = 4,
00133 MARKER_Circle = 5,
00134 MARKER_Flat = 6,
00135 MARKER_Square = 7,
00136 };
00137
00138 enum PENCOLOR {
00139 PENCOLOR_Primary,
00140 PENCOLOR_Inactive,
00141 PENCOLOR_Highlight,
00142 PENCOLOR_COUNT
00143 };
00144
00145 struct SNAPGRIDPARMS {
00146 DPOINT3D BasePt;
00147 double xsize;
00148 double ysize;
00149 double zsize;
00150 double rotate;
00151 MAT3X3 OtoS, StoO;
00152 };
00153
00154
00155
00156 static DWORD GetPenColor (
00157 PENCOLOR pencolor
00158 );
00159
00160
00161 static void SetPenColor (
00162 PENCOLOR pencolor,
00163 DWORD ColorRef
00164 );
00165
00166
00167 virtual ~GRTOOL () = 0;
00168
00169
00170
00171 void Activate (
00172 );
00173
00174
00175 void ClearPosition (
00176 );
00177
00178
00179 virtual MGUI::CTRL* CreateControlForm (
00180 MGUI::LAYOUT_PANE_BASE& ParentPane,
00181 CTRLOPT ctrlopt
00182 );
00183
00184
00185 virtual MGUI::CTRL* CreateManualForm (
00186 MGUI::LAYOUT_PANE_BASE& ParentPane,
00187 CTRLOPT ctrlopt
00188 );
00189
00190
00191 void Deactivate (
00192 );
00193
00194
00195
00196 virtual int GenerateRegion (
00197 REGION2D& region
00198 ) const;
00199
00200
00201
00202 const DPOINT2D& GetArrowKeyDeltas (
00203 ) const { return (m_ArrowDelta); }
00204
00205
00206 CTRLOPT GetControlOptions (
00207 ) const { return (m_ctrlopt); }
00208
00209
00210 const TRANS2D_AFFINE& GetTransToWindow (
00211 ) const { return (m_ToolToWindow); }
00212
00213
00214 GRTOOLVIEW* GetView (
00215 ) const { return (m_view); }
00216
00217
00218 inline const DRECT2D& GetViewExtents (
00219 ) const;
00220
00221
00222 bool HasControls (
00223 ) const { return (m_ControlNeed != CONTROLNEED_None); }
00224
00225
00226 bool HasManualControls (
00227 ) const { return (m_HasManualControls); };
00228
00229
00230 bool IsActive (
00231 ) const { return (m_IsActive); }
00232
00233
00234 bool IsResizable (
00235 ) const { return (m_Resizable); }
00236
00237
00238 bool IsRotatable (
00239 ) const { return (m_Rotatable); }
00240
00241
00242 bool IsSuspended (
00243 ) const { return (m_SuspendCount > 0); }
00244
00245
00246 bool HasPosition (
00247 ) const { return (m_PosnSet); }
00248
00249
00250 void Move (
00251 double dx,
00252 double dy,
00253 ADJUSTFLAGS flags
00254 );
00255
00256
00257 void Resize (
00258 double dx,
00259 double dy,
00260 ADJUSTFLAGS flags
00261 );
00262
00263
00264 void Resume (
00265 );
00266
00267
00268 void SetArrowKeyDeltas (
00269 double dx,
00270 double dy
00271 );
00272
00273
00274 void SetCanStartNew (
00275 bool canstartnew
00276 ) { m_CanStartNew = canstartnew; return; }
00277
00278
00279
00280 void SetControlOptions (
00281 CTRLOPT ctrlopt
00282 ) { m_ctrlopt = ctrlopt; return; }
00283
00284
00285 void SetResizable (
00286 bool resizable
00287 ) { m_Resizable = resizable; return; }
00288
00289
00290 void SetRotatable (
00291 bool rotatable
00292 ) { m_Rotatable = rotatable; return; }
00293
00294
00295 void SetTransToWindow (
00296 const TRANS2D_AFFINE& trans
00297 );
00298
00299
00300 bool SnapGridIsActive (
00301 ) const { return (m_UseSnapGrid); }
00302
00303
00304 const SNAPGRIDPARMS& SnapGridGet (
00305 ) const { return (m_sgparms); }
00306
00307
00308 void SnapGridSet (
00309 SNAPGRIDPARMS& parms
00310 );
00311
00312
00313 void SnapGridSetActive (
00314 bool active
00315 ) { m_UseSnapGrid = active; }
00316
00317
00318 void Suspend (
00319 );
00320
00321 protected:
00322
00323 enum CONTROLNEED {
00324 CONTROLNEED_None,
00325 CONTROLNEED_Optional,
00326 CONTROLNEED_Required
00327 };
00328
00329 enum PENSTYLE {
00330 PENSTYLE_Solid,
00331 PENSTYLE_Dash,
00332 PENSTYLE_COUNT
00333 };
00334
00335
00336
00337 static CPen* GetPen (
00338 PENCOLOR PenColor = PENCOLOR_Primary,
00339 PENSTYLE PenStyle = PENSTYLE_Solid
00340 );
00341
00342
00343 explicit GRTOOL (
00344 GRTOOLVIEW *view,
00345 CONTROLNEED ControlNeed,
00346 bool HasManualControls
00347 );
00348
00349
00350
00351
00352
00353 virtual void OnActivate (
00354 );
00355
00356
00357
00358 virtual void OnCancel (
00359 );
00360
00361
00362
00363 virtual void OnClear (
00364 );
00365
00366
00367
00368 virtual void OnDeactivate (
00369 );
00370
00371
00372
00373 virtual void OnMove (
00374 MOVESEQ moveseq,
00375 MOVETYPE movetype
00376 );
00377
00378
00379
00380
00381 virtual void OnRButtonDown (UINT nFlags, const CPoint& mpoint);
00382
00383
00384
00385
00386 virtual void OnRButtonUp (UINT nFlags, const CPoint& mpoint);
00387
00388
00389
00390 virtual void OnResume (
00391 );
00392
00393
00394
00395 virtual void OnSetTransToWindow (
00396 );
00397
00398
00399
00400 virtual void DoDraw (CDC*) = 0;
00401 virtual void DoMove (double, double, ADJUSTFLAGS);
00402 virtual void DoResize (double, double, ADJUSTFLAGS);
00403
00404
00405
00406
00407 virtual void OnCaptureChanged (CWnd *pWnd);
00408
00409
00410
00411 virtual bool OnKey (UINT nChar, UINT nRepCnt, UINT nFlags);
00412
00413 virtual void OnLButtonDown (UINT nFlags, const CPoint& mpoint) = 0;
00414 virtual void OnLButtonUp (UINT nFlags, const CPoint& mpoint);
00415 virtual void OnMouseMove (UINT nFlags, const CPoint& mpoint) = 0;
00416 virtual void OnSize ();
00417
00418
00419
00420 virtual void AdjustBegin (MOVETYPE movetype, bool redraw = true);
00421
00422 virtual void AdjustEnd (bool releasecapture = true, bool cancel = false);
00423
00424 void ApplyMoveDeltas (
00425 DPOINT2D& point,
00426 double dx,
00427 double dy,
00428 ADJUSTFLAGS flags
00429 ) const;
00430
00431
00432 void ApplySnap (
00433 DPOINT2D& point
00434 ) const;
00435
00436 bool CanStartNew (
00437 ) const {
00438 return (m_CanStartNew);
00439 }
00440
00441
00442 int CheckBounds (const DRECT2D&, DRECT2D*) const;
00443
00444
00445 void DrawMarker (CDC* pDC, const POINT& centerpoint, const POINT& dirpoint, MARKER marker, UINT16 size) const;
00446
00447 bool GetArrowDeltas (int, double*, double*);
00448
00449 CDC *GetDC ();
00450
00451 MOVETYPE GetMoveType (
00452 ) const { return (m_MoveType); }
00453
00454 inline bool IsMouseCaptured (
00455 ) const;
00456
00457 inline void ReleaseDC (CDC* pDC);
00458
00459
00460 void RestoreBackground () const;
00461
00462
00463 void RestoreBackground (
00464 const LRECT2D& rect,
00465 bool AddLineWidth = true
00466 ) const;
00467
00468 void SetHasPosition (
00469 bool HasPosition = true
00470 ) { m_PosnSet = HasPosition; return; }
00471
00472
00473 POINT TransToolToWindow (
00474 const DPOINT2D& point
00475 ) const;
00476
00477
00478 POINT TransToolToWindow (
00479 const DPOINT3D& point
00480 ) const;
00481
00482
00483 DPOINT2D TransWindowToTool (
00484 const POINT& point
00485 ) const { return (m_ToolToWindow.ConvertInverse(point.x,point.y)); }
00486
00487
00488 private:
00489 #ifndef GENERATING_DOXYGEN_OUTPUT
00490
00491 class TOOLDLG : public MGUI::DLG_BASE {
00492 public:
00493 TOOLDLG (GRTOOL& tool);
00494 virtual const char* GetDialogHelpID () const;
00495 virtual const char* GetDialogName () const;
00496 virtual ERRVALUE OnInitDialog ();
00497 class PAGECONTROLS : public MGUI::LAYOUT_PAGE {
00498 public:
00499 PAGECONTROLS (TOOLDLG& dlg): m_dlg(dlg) { }
00500 virtual ~PAGECONTROLS () { }
00501 protected:
00502 virtual void OnInitPage ();
00503 private:
00504 TOOLDLG& m_dlg;
00505 };
00506 class PAGEMANUAL : public MGUI::LAYOUT_PAGE {
00507 public:
00508 PAGEMANUAL (TOOLDLG& dlg): m_dlg(dlg) { }
00509 virtual ~PAGEMANUAL () { }
00510 protected:
00511 virtual void OnInitPage ();
00512 private:
00513 TOOLDLG& m_dlg;
00514 };
00515 GRTOOL& m_tool;
00516 MGUI::LAYOUT_BOOK m_TabBook;
00517 PAGECONTROLS m_PageControls;
00518 PAGECONTROLS m_PageManual;
00519 };
00520
00521
00522
00523 static DWORD s_PenColor[PENCOLOR_COUNT];
00524 static CPen s_Pen[PENCOLOR_COUNT*PENSTYLE_COUNT];
00525
00526
00527 GRTOOLVIEW *m_view;
00528 CONTROLNEED m_ControlNeed;
00529 bool m_HasManualControls;
00530 INT8 m_LineWidth;
00531 DPOINT2D m_ArrowDelta;
00532 INT32 m_SuspendCount;
00533 MOVETYPE m_MoveType;
00534 bool m_IsActive;
00535 bool m_PosnSet;
00536 bool m_UseSnapGrid;
00537 bool m_HasSnapGrid;
00538 bool m_HasArrowDeltas;
00539 bool m_IsUserModifying;
00540 bool m_InDeactivateFunc;
00541 bool m_CanStartNew;
00542 bool m_Resizable;
00543 bool m_Rotatable;
00544 CTRLOPT m_ctrlopt;
00545 TOOLDLG m_ToolDlg;
00546
00547
00548 TRANS2D_AFFINE m_ToolToWindow;
00549 SNAPGRIDPARMS m_sgparms;
00550
00551 void CreateToolDlg ();
00552 void DrawTool (CDC*);
00553 void DrawTool (CDC*, UINT32);
00554 void DrawTool (UINT32);
00555 void SetView (GRTOOLVIEW *newview) { m_view = newview; return; }
00556
00557 friend class GRTOOL::TOOLDLG;
00558 friend class GRTOOLVIEW;
00559 #endif // GENERATING_DOXYGEN_OUTPUT
00560 };
00561 DEFINE_ENUM_OPERATORS(GRTOOL::ADJUSTFLAGS);
00562 DEFINE_ENUM_OPERATORS(GRTOOL::CTRLOPT);
00563
00564
00565
00566
00567
00568 class GRTOOL_LIMITED : public GRTOOL {
00569 public:
00570
00571
00572 virtual ~GRTOOL_LIMITED ();
00573
00574
00575 void SetLimits (
00576 const DRECT2D& rect
00577 );
00578
00579
00580
00581 void SetLimitsEnforced (
00582 bool enforced = true
00583 );
00584
00585 protected:
00586
00587
00588 explicit GRTOOL_LIMITED (
00589 GRTOOLVIEW *view,
00590 CONTROLNEED ControlNeed,
00591 bool HasManualControls
00592 );
00593
00594
00595 const DRECT2D& GetLimits (
00596 ) const { return (m_Limits); }
00597
00598
00599 bool IsLimitsEnforced (
00600 ) const { return (m_LimitsEnforced); }
00601
00602
00603
00604 virtual void OnActivate (
00605 );
00606
00607
00608
00609 virtual void OnChangeLimits (
00610 );
00611
00612
00613
00614 virtual void OnSetTransToWindow (
00615 );
00616
00617 private:
00618 bool m_LimitsEnforced;
00619 bool m_LimitsSet;
00620 DRECT2D m_Limits;
00621
00622 virtual void OnSize ();
00623 void UpdateLimits ();
00624 };
00625
00626
00627
00628
00629
00630 class GRTOOL_SELECTPOINT : public GRTOOL_LIMITED {
00631 public:
00632
00633
00634 explicit GRTOOL_SELECTPOINT (
00635 GRTOOLVIEW *view
00636 );
00637
00638
00639 virtual ~GRTOOL_SELECTPOINT ();
00640
00641
00642 const DPOINT2D& GetPoint (
00643 ) const { return (m_point); }
00644
00645 private:
00646
00647 enum ZONE {
00648 ZONE_NoFunction = 0,
00649 ZONE_Outside,
00650 };
00651
00652 class CONTROLFORM : public MGUI::CTRL {
00653 public:
00654 CONTROLFORM (
00655 );
00656 virtual ~CONTROLFORM (
00657 );
00658 private:
00659 };
00660
00661
00662 DPOINT2D m_point;
00663
00664
00665 ZONE m_CursorZone;
00666
00667
00668 virtual void DoDraw (CDC*);
00669 virtual void DoMove (double dx, double dy, ADJUSTFLAGS flags);
00670
00671 virtual void OnLButtonDown (UINT nFlags, const CPoint& mpoint);
00672 virtual void OnMouseMove (UINT nFlags, const CPoint& mpoint);
00673
00674
00675 void ComputeCursorZone (const DPOINT2D&);
00676 void UpdateCursor () const;
00677 };
00678
00679
00680
00681
00682
00683 class GRTOOL_POINT : public GRTOOL_LIMITED {
00684 public:
00685
00686
00687 explicit GRTOOL_POINT (
00688 GRTOOLVIEW *view
00689 );
00690
00691
00692 virtual ~GRTOOL_POINT ();
00693
00694
00695 GRTOOL_POINT& operator= (
00696 const DPOINT2D& rhs
00697 );
00698
00699
00700 GRTOOL_POINT& operator= (
00701 const DPOINT3D& rhs
00702 );
00703
00704
00705 const DPOINT3D& GetPoint (
00706 ) const { return (m_point); }
00707
00708
00709
00710 void SetMarker (
00711 MARKER marker,
00712 UINT16 size = 0
00713 );
00714
00715 private:
00716
00717 enum ZONE {
00718 ZONE_NoFunction = 0,
00719 ZONE_Outside,
00720 };
00721
00722 MARKER m_marker;
00723 UINT16 m_markersize;
00724
00725 DPOINT3D m_point;
00726
00727 ZONE m_CursorZone;
00728
00729
00730 virtual void DoDraw (CDC*);
00731 virtual void DoMove (double dx, double dy, ADJUSTFLAGS flags);
00732
00733 virtual void OnLButtonDown (UINT nFlags, const CPoint& mpoint);
00734 virtual void OnMouseMove (UINT nFlags, const CPoint& mpoint);
00735
00736
00737 void ComputeCursorZone (const DPOINT2D&);
00738 void UpdateCursor () const;
00739 };
00740
00741
00742
00743
00744
00745 class GRTOOL_MULTIPOINT : public GRTOOL {
00746 public:
00747
00748
00749 explicit GRTOOL_MULTIPOINT (
00750 GRTOOLVIEW *view
00751 );
00752
00753
00754 virtual ~GRTOOL_MULTIPOINT ();
00755
00756
00757 virtual MGUI::CTRL* CreateControlForm (
00758 MGUI::LAYOUT_PANE_BASE& ParentPane,
00759 CTRLOPT ctrlopt
00760 );
00761
00762
00763 const DPOINT3D& GetActivePoint (
00764 ) const { return (m_Points[m_ActiveIndex]); }
00765
00766
00767 int GetNumPoints (
00768 ) const { return (m_Points.GetNumItems()); }
00769
00770
00771
00772 const DPOINT3D& GetPoint (
00773 int index
00774 ) const { return (m_Points[index]); }
00775
00776
00777 const DOUBLE_ARRAY<DPOINT3D> GetPoints (
00778 ) const { return (m_Points); }
00779
00780
00781 bool IsActiveValid (
00782 ) const { return (m_ActiveIndex >= 0 && m_ActiveIndex < m_Points.GetNumItems()); }
00783
00784
00785
00786 void SetMarker (
00787 MARKER marker,
00788 UINT16 size = 0
00789 );
00790
00791 protected:
00792
00793
00794
00795 virtual void OnChangeActiveElem (
00796 );
00797
00798
00799
00800 virtual void OnClear (
00801 );
00802
00803 private:
00804
00805 enum EDITMODE {
00806 EDITMODE_Automatic,
00807 EDITMODE_Add,
00808 EDITMODE_Move,
00809 EDITMODE_Select
00810 };
00811
00812 enum ZONE {
00813 ZONE_NoFunction = 0,
00814 ZONE_Outside,
00815 };
00816
00817
00818 MARKER m_marker;
00819 UINT16 m_markersize;
00820 EDITMODE m_EditMode;
00821
00822 DOUBLE_ARRAY<DPOINT3D> m_Points;
00823 int m_ActiveIndex;
00824
00825 ZONE m_CursorZone;
00826 DPOINT2D m_prevpt;
00827 bool m_NotifyChangeElem;
00828
00829 void ActivateClosestPoint (const DPOINT2D&);
00830 void AddPoint (CDC*, const DPOINT2D&);
00831 void AdjustTool (DPOINT2D&, MOVESEQ);
00832 void ComputeCursorZone (const DPOINT2D&);
00833 void DeletePoint ();
00834 virtual void DoDraw (CDC*);
00835 virtual void DoMove (double dx, double dy, ADJUSTFLAGS flags);
00836 void DrawNeighborPoints (CDC*, const LRECT2D&) const;
00837 void DrawPoint (CDC*, int) const;
00838 void ErasePoint (CDC*, bool circleonly = false) const;
00839 int FindClosestPoint (const DPOINT2D&) const;
00840 virtual bool OnKey (UINT nChar, UINT nRepCnt, UINT nFlags);
00841 virtual void OnLButtonDown (UINT nFlags, const CPoint& mpoint);
00842 virtual void OnLButtonUp (UINT nFlags, const CPoint& mpoint);
00843 virtual void OnMouseMove (UINT nFlags, const CPoint& mpoint);
00844 void SetActiveIndex (int);
00845 void UpdateCursor () const;
00846 };
00847
00848
00849
00850
00851
00852 class GRTOOL_CROSSHAIR : public GRTOOL_LIMITED {
00853 public:
00854
00855
00856 explicit GRTOOL_CROSSHAIR (
00857 GRTOOLVIEW *view
00858 );
00859
00860
00861 virtual ~GRTOOL_CROSSHAIR ();
00862
00863
00864 GRTOOL_CROSSHAIR& operator= (
00865 const DPOINT2D& rhs
00866 );
00867
00868
00869
00870 double GetAngle (
00871 ) const { return (m_angle); }
00872
00873
00874 const DPOINT2D& GetPoint (
00875 ) const { return (m_point); }
00876
00877 private:
00878
00879 enum ZONE {
00880 ZONE_NoFunction = 0,
00881 ZONE_Outside,
00882 };
00883
00884 DPOINT2D m_point;
00885 double m_angle;
00886
00887 ZONE m_CursorZone;
00888
00889
00890 virtual void DoDraw (CDC*);
00891 virtual void DoMove (double dx, double dy, ADJUSTFLAGS flags);
00892
00893 virtual void OnLButtonDown (UINT nFlags, const CPoint& mpoint);
00894 virtual void OnMouseMove (UINT nFlags, const CPoint& mpoint);
00895
00896
00897 void ComputeCursorZone (const DPOINT2D&);
00898 void UpdateCursor () const;
00899 };
00900
00901
00902
00903
00904
00905 class GRTOOL_SEGMENT : public GRTOOL_LIMITED {
00906 public:
00907
00908
00909 explicit GRTOOL_SEGMENT (
00910 GRTOOLVIEW *view
00911 );
00912
00913
00914 virtual ~GRTOOL_SEGMENT ();
00915
00916
00917 const DPOINT2D& GetEnd (
00918 ) const { return (m_endpoint); }
00919
00920
00921 const DPOINT2D& GetStart (
00922 ) const { return (m_startpoint); }
00923
00924
00925 void SetMarkers (
00926 MARKER startmarker,
00927 MARKER endmarker,
00928 UINT16 startmarkersize = 0,
00929 UINT16 endmarkersize = 0
00930 );
00931
00932 private:
00933
00934 enum ZONE {
00935 ZONE_NoFunction = 0,
00936 ZONE_Outside,
00937 ZONE_Inside,
00938 ZONE_Start,
00939 ZONE_End
00940 };
00941
00942 MARKER m_startmarker;
00943 MARKER m_endmarker;
00944 UINT16 m_startmarkersize;
00945 UINT16 m_endmarkersize;
00946
00947 DPOINT2D m_endpoint;
00948 DPOINT2D m_startpoint;
00949
00950 ZONE m_CursorZone;
00951 DPOINT2D m_prevpt;
00952 UINT8 m_AdjustMode;
00953
00954
00955 virtual void DoDraw (CDC*);
00956 virtual void DoMove (double dx, double dy, ADJUSTFLAGS flags);
00957
00958 virtual void OnLButtonDown (UINT nFlags, const CPoint& mpoint);
00959 virtual void OnMouseMove (UINT nFlags, const CPoint& mpoint);
00960
00961
00962 void AdjustTool (const DPOINT2D&, bool firsttime=false);
00963 void ComputeCursorZone (const DPOINT2D&);
00964 void StartTool (const DPOINT2D&);
00965 void UpdateCursor () const;
00966 };
00967
00968
00969
00970
00971
00972 class GRTOOL_CIRCLE : public GRTOOL {
00973 public:
00974
00975
00976 explicit GRTOOL_CIRCLE (
00977 GRTOOLVIEW *view
00978 );
00979
00980
00981 virtual ~GRTOOL_CIRCLE ();
00982
00983
00984
00985 virtual int GenerateRegion (
00986 REGION2D& region
00987 ) const;
00988
00989
00990 double GetAngle (
00991 ) const { return (m_angle); }
00992
00993
00994 const DPOINT2D& GetCenter (
00995 ) const { return (m_center); }
00996
00997
00998 double GetRadius (
00999 ) const { return (m_radius); }
01000
01001
01002
01003 void SetAngle (
01004 double angle
01005 );
01006
01007
01008
01009 void SetAngleVisible (
01010 bool anglevisible = true
01011 );
01012
01013
01014 void SetCenter (
01015 const DPOINT2D& center
01016 );
01017
01018
01019
01020 void SetMarker (
01021 MARKER marker,
01022 UINT16 size = 0
01023 );
01024
01025
01026 void SetRadius (
01027 double radius
01028 );
01029
01030
01031 void SetRadiusRange (
01032 double minradius,
01033 double maxradius
01034 );
01035
01036 private:
01037
01038 enum ZONE {
01039 ZONE_NoFunction = 0,
01040 ZONE_Outside,
01041 ZONE_Inside,
01042 ZONE_Perimeter,
01043 ZONE_SetCenter,
01044 ZONE_Rotate,
01045 };
01046
01047 MARKER m_marker;
01048 UINT16 m_markersize;
01049 double m_minradius;
01050 double m_maxradius;
01051 bool m_anglevisible;
01052
01053 DPOINT2D m_center;
01054 double m_radius;
01055 double m_angle;
01056
01057 ZONE m_CursorZone;
01058 DPOINT2D m_prevpt;
01059
01060
01061 virtual void DoDraw (CDC*);
01062 virtual void DoMove (double dx, double dy, ADJUSTFLAGS flags);
01063
01064 virtual void OnLButtonDown (UINT nFlags, const CPoint& mpoint);
01065 virtual void OnMouseMove (UINT nFlags, const CPoint& mpoint);
01066
01067
01068 void AdjustTool (const DPOINT2D&, bool firsttime=false);
01069 void ComputeCursorZone (const DPOINT2D&);
01070 void StartTool (const DPOINT2D&);
01071 void UpdateCursor (const DPOINT2D&) const;
01072 };
01073
01074
01075
01076
01077
01078 class GRTOOL_ELLIPSE : public GRTOOL {
01079 public:
01080
01081
01082 explicit GRTOOL_ELLIPSE (
01083 GRTOOLVIEW *view
01084 );
01085
01086
01087 virtual ~GRTOOL_ELLIPSE ();
01088
01089
01090
01091 virtual int GenerateRegion (
01092 REGION2D& region
01093 ) const;
01094
01095
01096 double GetAngle (
01097 ) const { return (m_angle); }
01098
01099
01100 const DPOINT2D& GetCenter (
01101 ) const { return (m_center); }
01102
01103
01104 const DPOINT2D& GetRadius (
01105 ) const { return (m_radius); }
01106
01107
01108 void SetAngle (
01109 double angle
01110 );
01111
01112
01113
01114 void SetAngleVisible (
01115 bool anglevisible = true
01116 );
01117
01118
01119 void SetCenter (
01120 const DPOINT2D& center
01121 );
01122
01123
01124
01125 void SetMarker (
01126 MARKER marker,
01127 UINT16 size = 0
01128 );
01129
01130
01131 void SetRadius (
01132 DPOINT2D& radius
01133 );
01134
01135
01136 void SetRadiusRange (
01137 double minradius,
01138 double maxradius
01139 );
01140
01141 private:
01142
01143 enum ZONE {
01144 ZONE_NoFunction = 0,
01145 ZONE_Outside,
01146 ZONE_Inside,
01147 ZONE_ResizeX,
01148 ZONE_ResizeY,
01149 ZONE_Perimeter,
01150 ZONE_SetCenter,
01151 ZONE_Rotate,
01152 };
01153
01154 MARKER m_marker;
01155 UINT16 m_markersize;
01156 double m_minradius;
01157 double m_maxradius;
01158 bool m_anglevisible;
01159
01160 DPOINT2D m_center;
01161 DPOINT2D m_radius;
01162 double m_angle;
01163
01164 ZONE m_CursorZone;
01165 DPOINT2D m_prevpt;
01166 TRANS2D_AFFINE m_trans;
01167
01168
01169 virtual void DoDraw (CDC*);
01170 virtual void DoMove (double dx, double dy, ADJUSTFLAGS flags);
01171
01172 virtual void OnLButtonDown (UINT nFlags, const CPoint& mpoint);
01173 virtual void OnMouseMove (UINT nFlags, const CPoint& mpoint);
01174
01175
01176 void AdjustTool (const DPOINT2D&, bool firsttime=false);
01177 void ComputeCursorZone (const DPOINT2D&);
01178 void StartTool (const DPOINT2D&);
01179 void UpdateCursor (const DPOINT2D&) const;
01180 };
01181
01182
01183
01184
01185
01186 class GRTOOL_ARC : public GRTOOL {
01187 public:
01188
01189 enum CLOSURE {
01190 CLOSURE_None,
01191 CLOSURE_Chord,
01192 CLOSURE_Wedge
01193 };
01194
01195
01196 explicit GRTOOL_ARC (
01197 GRTOOLVIEW *view
01198 );
01199
01200
01201 virtual ~GRTOOL_ARC ();
01202
01203
01204
01205 virtual int GenerateRegion (
01206 REGION2D& region
01207 ) const;
01208
01209
01210 const DPOINT2D& GetCenter (
01211 ) const { return (m_center); }
01212
01213
01214 CLOSURE GetClosure (
01215 ) const { return (m_closure); }
01216
01217
01218 double GetRadius (
01219 ) const { return (m_radius); }
01220
01221
01222
01223 double GetStartAngle (
01224 ) const { return (m_StartAngle); }
01225
01226
01227
01228 double GetSweepAngle (
01229 ) const { return (m_SweepAngle); }
01230
01231
01232 void SetCenter (
01233 const DPOINT2D& newcenter
01234 );
01235
01236
01237 void SetClosure (
01238 CLOSURE closure
01239 );
01240
01241
01242
01243 void SetMarker (
01244 MARKER marker,
01245 UINT16 size = 0
01246 );
01247
01248 void SetRadius (
01249 double newradius
01250 );
01251
01252 void SetRadiusRange (
01253 double newminradius,
01254 double newmaxradius
01255 );
01256
01257
01258 void SetStartAngle (
01259 double startangle
01260 );
01261
01262
01263 void SetSweepAngle (
01264 double sweepangle
01265 );
01266
01267 private:
01268
01269 enum ZONE {
01270 ZONE_NoFunction = 0,
01271 ZONE_Outside,
01272 ZONE_Inside,
01273 ZONE_Perimeter,
01274 ZONE_SetCenter,
01275 ZONE_Start,
01276 ZONE_End
01277 };
01278
01279 MARKER m_marker;
01280 UINT16 m_markersize;
01281 double m_minradius;
01282 double m_maxradius;
01283 CLOSURE m_closure;
01284
01285 DPOINT2D m_center;
01286 double m_radius;
01287 double m_StartAngle;
01288 double m_SweepAngle;
01289
01290 ZONE m_CursorZone;
01291 DPOINT2D m_prevpt;
01292
01293
01294 virtual void