mgui/toolpoly.h

Go to the documentation of this file.
00001 /**
00002  * \file mgui/toolpoly.h
00003  * \brief MGUI::TOOL_POLYLINE class definition
00004  *
00005  * \if NODOC
00006  * $Id: toolpoly.h_v 1.3 2003/10/03 19:58:19 linux32build!build Exp $
00007  *
00008  * $Log: toolpoly.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:34  mju
00016  * Initial revision
00017  *
00018  * \endif
00019 **/
00020 
00021 #ifndef  INC_MGUI_TOOLPOLY_H
00022 #define  INC_MGUI_TOOLPOLY_H
00023 
00024 #ifndef  INC_MGUI_TOOLBASE_H
00025 #include <mgui/toolbase.h>
00026 #endif
00027 
00028 #ifndef  INC_MI32_POLYLINE_H
00029 #include <mi32/polyline.h>
00030 #endif
00031 
00032 namespace MGUI {
00033 
00034 
00035 //! TOOL_POLYLINE - Polyline / polygon tool
00036 //!
00037 class TOOL_POLYLINE : public TOOL_BASE {
00038    public:
00039 
00040       //! Editing modes.
00041       enum EDITMODE {
00042          EDITMODE_AddEnd,                    //!< Add vertices to end of active line (default)
00043          EDITMODE_AddStart,                  //!< Add vertices to start of active line
00044          EDITMODE_InsertVertex,              //!< Insert vertex
00045          EDITMODE_DragVertex,                //!< Drag nearest vertex
00046          EDITMODE_DeleteVertex,              //!< Delete nearest vertex
00047          EDITMODE_Move                       //!< Move active line
00048          };
00049 
00050       //! Constructor.
00051       explicit TOOL_POLYLINE (
00052          TOOLCANVAS *canvas,                    //!< View to contain tool
00053          bool AllowMulti = false             //!< Allow multiple lines
00054          );
00055 
00056       //! Destructor.
00057       virtual ~TOOL_POLYLINE ();
00058 
00059       //! Get reference to active line.
00060       //! IsActiveValid() should be used first to determine if the active line is
00061       //! valid.  Failure to do so will likely result in an exception.
00062       const POLYLINE& GetActiveLine (
00063          ) const { return (*m_ActiveLine); }
00064 
00065       //! Get list of lines.
00066       const MILIST<POLYLINE>& GetLineList (
00067          ) const { return (m_LineList); }
00068 
00069       //! Get number of valid lines.
00070       int GetNumLines (
00071          ) const { return (m_LineList.GetNumItems()); }
00072 
00073       //! Determine if tool points are 3D.
00074       bool Is3D (
00075          ) const { return (m_Is3D); };
00076 
00077       //! Determine if active line is valid.
00078       //! In single-line mode the active line is always valid.
00079       bool IsActiveValid (
00080          ) const { return (m_ActiveLine != 0); }
00081 
00082       //! Lock or unlock end point of active line.
00083       void LockEndPoint (
00084          bool locked = true                  //!< 'true' to lock, 'false' to unlock
00085          );
00086 
00087       //! Lock or unlock start point of active line.
00088       void LockStartPoint (
00089          bool locked = true                  //!< 'true' to lock, 'false' to unlock
00090          );
00091 
00092       //! Set whether points are 3D.
00093       void Set3D (
00094          bool set3d = true
00095          );
00096 
00097       //! Set line to draw as "closed".
00098       //! This only affects how the tool is drawn, it does not add a closing point to the POLYLINE.
00099       void SetClosed (
00100          bool closed = true
00101          );
00102 
00103       //! Set line editing mode.
00104       void SetEditMode (
00105          EDITMODE EditMode                   //!< New editing mode
00106          );
00107 
00108       //! Set markers for start and end points.
00109       void SetMarkers (
00110          MARKER startmarker,                 //!< Starting point marker type
00111          MARKER endmarker,                   //!< Ending point marker type
00112          UINT16 startmarkersize = 0,         //!< Starting point marker size, 0 to retain current size
00113          UINT16 endmarkersize = 0            //!< Ending point marker size, 0 to retain current size
00114          );
00115 
00116    protected:
00117 
00118       //! Called when "active element" changed.
00119       virtual void v_OnChangeActiveElem (
00120          );
00121 
00122    private:
00123 
00124       #ifndef GENERATING_DOXYGEN_OUTPUT
00125 
00126       //! Enumeration constants
00127       enum ZONE {
00128          ZONE_NoFunction = 0,
00129          ZONE_Outside
00130          };
00131 
00132       //! Tool settings
00133       bool m_AllowMulti;
00134       bool m_IsClosed;
00135       bool m_Is3D;
00136       bool m_LockStart;
00137       bool m_LockEnd;
00138       MARKER m_startmarker;
00139       MARKER m_endmarker;
00140       UINT16 m_startmarkersize;
00141       UINT16 m_endmarkersize;
00142       EDITMODE m_EditMode;
00143       //! Tool position values
00144       MILIST<POLYLINE> m_LineList;
00145       POLYLINE *m_ActiveLine;             //!< Pointer to active line
00146       //! Values used during interaction
00147       ZONE m_CursorZone;                  //!< Current cursor zone
00148       DPOINT2D m_prevpt;                  //!< Previous point during button-down
00149       int m_ActivePoint;
00150       bool m_RubberBand;
00151       
00152       //! Methods
00153       void AddPoint (MGD::CONTEXT*, const DPOINT2D&, EDITMODE);
00154       void AdjustTool (DPOINT2D&, CHANGESEQ);
00155       void ComputeCursorZone (const DPOINT2D&);
00156       void DeletePoint (MGD::CONTEXT*, int);
00157       void DrawMarkerEnd (MGD::CONTEXT*);
00158       void DrawMarkerStart (MGD::CONTEXT*);
00159       void DrawNeighborSegments (MGD::CONTEXT*, const LRECT2D&, bool SkipActive=true, int SkipSegment1=-2, int SkipSegment2=-2);
00160       void DrawSegment (MGD::CONTEXT*, const POLYLINE&, int);
00161       void DrawSegment (MGD::CONTEXT*, int, bool);
00162       void DrawSingleLine (MGD::CONTEXT*, const POLYLINE&);
00163       void EraseLine (MGD::CONTEXT*);
00164       void EraseMarkerEnd (MGD::CONTEXT*, bool);
00165       void EraseMarkerStart (MGD::CONTEXT*, bool);
00166       void ErasePoint (MGD::CONTEXT*, int);
00167       void EraseSegment (MGD::CONTEXT*, int);
00168       void InsertPoint (MGD::CONTEXT*, int, const DPOINT2D&, UINT32);
00169       void MovePoint (MGD::CONTEXT*, const DPOINT2D&, UINT32);
00170       void UpdateCursor () const;
00171 
00172       //! TOOL_BASE overrides.
00173       virtual MGUI::FORM* v_CreateControlForm (LAYOUT_PANE_BASE& ParentPane, CTRLOPT ctrlopt);
00174       virtual void v_DoDraw (MGD::CONTEXT*);
00175       virtual int v_GenerateRegion (REGION2D& region) const;
00176       virtual void v_OnClear ();
00177       virtual bool v_OnKey (MGUI::POINT point, KEYCODE keycode, KEYSTATE keystate);
00178       virtual void v_OnLButtonDown (MGUI::POINT point, KEYSTATE keystate);
00179       virtual void v_OnLButtonUp (MGUI::POINT point, KEYSTATE keystate);
00180       virtual void v_OnMouseMove (MGUI::POINT point, KEYSTATE keystate);
00181       
00182       #endif // GENERATING_DOXYGEN_OUTPUT
00183    };
00184 
00185 
00186 }  // End namespace MGUI
00187 
00188 
00189 #endif   // INC_MGUI_TOOLPOLY_H

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