mgui/toolmlpt.h

Go to the documentation of this file.
00001 /**
00002  * \file mgui/toolmlpt.h
00003  * \brief MGUI::TOOL_MULTIPOINT class definition
00004  *
00005  * \if NODOC
00006  * $Id: toolmlpt.h_v 1.3 2003/10/03 19:58:19 linux32build!build Exp $
00007  *
00008  * $Log: toolmlpt.h_v $
00009  * Revision 1.3  2003/10/03 19:58:19  linux32build!build
00010  * Doxygen
00011  *
00012  * Revision 1.2  2003/09/15 13:49:32  fileserver!dwilliss
00013  * Doxygen
00014  *
00015  * Revision 1.1  2003/01/10 23:08:25  mju
00016  * Initial revision
00017  *
00018  * \endif
00019 **/
00020 
00021 #ifndef  INC_MGUI_TOOLMLPT_H
00022 #define  INC_MGUI_TOOLMLPT_H
00023 
00024 #ifndef  INC_MGUI_TOOLBASE_H
00025 #include <mgui/toolbase.h>
00026 #endif
00027 
00028 #ifndef  INC_MI32_DOUBLEAR_H
00029 #include <mi32/doublear.h>
00030 #endif
00031 
00032 namespace MGUI {
00033 
00034 //! TOOL_MULTIPOINT - Multi-Point tool
00035 //!
00036 class TOOL_MULTIPOINT : public TOOL_BASE {
00037    public:
00038 
00039       //! Constructor.
00040       explicit TOOL_MULTIPOINT (
00041          TOOLCANVAS *canvas
00042          );
00043 
00044       //! Destructor.
00045       virtual ~TOOL_MULTIPOINT ();
00046 
00047       //! Get active point coordinates.
00048       const DPOINT3D& GetActivePoint (
00049          ) const { return (m_Points[m_ActiveIndex]); }
00050 
00051       //! Get number of points.
00052       int GetNumPoints (
00053          ) const { return (m_Points.GetNumItems()); }
00054 
00055       //! Get single point.
00056       //! If the index is out of range the results are unpredictable.
00057       const DPOINT3D& GetPoint (
00058          int index                           //!< Zero-based index of point to retrieve
00059          ) const { return (m_Points[index]); }
00060 
00061       //! Get points.
00062       const DOUBLE_ARRAY<DPOINT3D> GetPoints (
00063          ) const { return (m_Points); }
00064 
00065       //! Determine if "active" point is valid.
00066       bool IsActiveValid (
00067          ) const { return (m_ActiveIndex >= 0 && m_ActiveIndex < m_Points.GetNumItems()); }
00068 
00069       //! Set marker type and size.
00070       //! The default marker is MARKER_Plus with a size of 9 pixels.
00071       void SetMarker (
00072          MARKER marker,                      //!< New marker type
00073          UINT16 size = 0                     //!< New marker size, 0 to retain current size
00074          );
00075 
00076    protected:
00077 
00078       //! Called when "active element" changed.
00079       virtual void v_OnChangeActiveElem (
00080          );
00081 
00082    private:
00083 
00084       #ifndef GENERATING_DOXYGEN_OUTPUT
00085 
00086       enum EDITMODE {
00087          EDITMODE_Automatic,                 //!< Auto select when near point, move if selected, add if not near point
00088          EDITMODE_Add,                       //!< Always add new point
00089          EDITMODE_Move,                      //!< Move selected point to cursor
00090          EDITMODE_Select                     //!< Select point by clicking
00091          };
00092 
00093       enum ZONE {
00094          ZONE_NoFunction = 0,
00095          ZONE_Outside,
00096          };
00097 
00098       //! Tool settings
00099       MARKER m_marker;
00100       UINT16 m_markersize;
00101       EDITMODE m_EditMode;
00102       //! Tool position values
00103       DOUBLE_ARRAY<DPOINT3D> m_Points;    //!< Points
00104       int m_ActiveIndex;                  //!< Index of active point
00105       //! Values used during interaction
00106       ZONE m_CursorZone;                  //!< Current cursor zone
00107       DPOINT2D m_prevpt;
00108       bool m_NotifyChangeElem;
00109 
00110       void ActivateClosestPoint (const DPOINT2D&);
00111       void AddPoint (MGD::CONTEXT*, const DPOINT2D&);
00112       void AdjustTool (DPOINT2D&, CHANGESEQ);
00113       void ComputeCursorZone (const DPOINT2D&);
00114       void DeletePoint ();
00115       void DrawNeighborPoints (MGD::CONTEXT*, const LRECT2D&) const;
00116       void DrawPoint (MGD::CONTEXT*, int) const;
00117       void ErasePoint (MGD::CONTEXT*, bool circleonly = false) const;
00118       int FindClosestPoint (const DPOINT2D&) const;
00119       void SetActiveIndex (int);
00120       void UpdateCursor () const;
00121 
00122       //! TOOL_BASE overrides.
00123       virtual MGUI::FORM* v_CreateControlForm (LAYOUT_PANE_BASE& ParentPane, CTRLOPT ctrlopt);
00124       virtual void v_DoDraw (MGD::CONTEXT*);
00125       virtual void v_DoMove (double dx, double dy, ADJUSTFLAGS flags);
00126       virtual void v_OnClear ();
00127       virtual bool v_OnKey (MGUI::POINT point, KEYCODE keycode, KEYSTATE keystate);
00128       virtual void v_OnLButtonDown (MGUI::POINT point, KEYSTATE keystate);
00129       virtual void v_OnLButtonUp (MGUI::POINT point, KEYSTATE keystate);
00130       virtual void v_OnMouseMove (MGUI::POINT point, KEYSTATE keystate);
00131 
00132       #endif // GENERATING_DOXYGEN_OUTPUT
00133    };
00134 
00135 
00136 }  // End namespace MGUI
00137 
00138 
00139 #endif   // INC_MGUI_TOOLMLPT_H

Generated on Thu Aug 12 06:18:29 2004 for TNTsdk by doxygen 1.3.4-20031026