00001
00114 #ifndef INC_MGUI_TOOLPOLYLINE_H
00115 #define INC_MGUI_TOOLPOLYLINE_H
00116
00117 #ifndef INC_MGUI_TOOLGPS_H
00118 #include <mgui/toolgps.h>
00119 #endif
00120
00121 #ifndef INC_MI32_POLYLINE_H
00122 #include <mi32/polyline.h>
00123 #endif
00124
00125 namespace MGUI {
00126
00127
00128
00130 class TOOL_POLYLINE : public TOOL_GPS {
00131 public:
00133 enum DRAWMODE {
00134 DRAWMODE_Draw = 256,
00135 DRAWMODE_Stretch
00136 };
00137
00139 enum EDITMODE {
00140 EDITMODE_Automatic = 0,
00141 EDITMODE_AddEnd,
00142 EDITMODE_AddStart,
00143 EDITMODE_InsertVertex,
00144 EDITMODE_DragVertex,
00145 EDITMODE_DeleteVertex,
00146 EDITMODE_Move
00147 };
00148
00150 explicit TOOL_POLYLINE (
00151 TOOLCANVAS *canvas,
00152 bool AllowMulti = false
00153 );
00154
00155 typedef fastdelegate::FastDelegate<bool(CHANGESEQ, EDITMODE, DPOINT3D&)> DELEGATE_ONSETVERTEX;
00156 typedef fastdelegate::FastDelegate<bool(POLYLINE&)> DELEGATE_ONVERTICESCHANGED;
00157
00159 virtual ~TOOL_POLYLINE ();
00160
00164 const POLYLINE& GetActiveLine (
00165 ) const { return (*m_pActiveLine); }
00166
00168 EDITMODE GetEditMode (
00169 ) const { return (m_EditMode); }
00170
00172 const POLYLINELIST& GetLineList (
00173 ) const { return (m_LineList); }
00174
00176 int GetNumLines (
00177 ) const { return (m_LineList.GetNumItems()); }
00178
00181 bool IsActiveValid (
00182 ) const { return (m_pActiveLine != 0); }
00183
00185 bool IsClosed (
00186 ) const { return (m_IsClosed); }
00187
00189 void LockEndPoint (
00190 bool locked = true
00191 );
00192
00194 void LockStartPoint (
00195 bool locked = true
00196 );
00197
00200 void SetClosed (
00201 bool closed = true
00202 );
00203
00207 void SetDelegateOnSetVertex (
00208 DELEGATE_ONSETVERTEX delegate
00209 ) { m_DelegateOnSetVertex = delegate; }
00210
00214 void SetDelegateOnVerticesChanged (
00215 DELEGATE_ONVERTICESCHANGED delegate
00216 ) { m_DelegateOnVerticesChanged = delegate; }
00217
00220 void SetDrawMode (
00221 DRAWMODE DrawMode
00222 );
00223
00225 void SetEditMode (
00226 EDITMODE EditMode
00227 );
00228
00230 void SetFilterDistance (
00231 double distance
00232 );
00233
00235 void SetLine (
00236 const POLYLINE& polyline
00237 );
00238
00240 void SetLineList (
00241 const POLYLINELIST& LineList
00242 );
00243
00245 void SetMarkerColors (
00246 PENCOLOR startcolor,
00247 PENCOLOR endcolor
00248 );
00249
00251 void SetMarkers (
00252 MARKER startmarker,
00253 MARKER endmarker,
00254 UINT16 startmarkersize = 0,
00255 UINT16 endmarkersize = 0
00256 );
00257
00259 void UpdateActiveLine (
00260 const POLYLINE& polyline
00261 );
00262
00263 private:
00264 #ifndef GENERATING_DOXYGEN_OUTPUT
00265
00266 enum ZONE {
00267 ZONE_NoFunction = 0,
00268 ZONE_Outside,
00269 ZONE_Vertex,
00270 ZONE_Segment,
00271 ZONE_StartVertex
00272 };
00273
00274
00275 bool m_AllowMulti;
00276 bool m_IsClosed;
00277 bool m_LockStart;
00278 bool m_LockEnd;
00279 bool m_ShowPrefiltered;
00280 MARKER m_startmarker;
00281 MARKER m_endmarker;
00282 UINT16 m_startmarkersize;
00283 UINT16 m_endmarkersize;
00284 PENCOLOR m_startmarkercolor;
00285 PENCOLOR m_endmarkercolor;
00286 EDITMODE m_EditMode;
00287
00288 POLYLINELIST m_LineList;
00289 POLYLINE *m_pActiveLine;
00290
00291 ZONE m_CursorZone;
00292 DPOINT3D m_prevpt;
00293 double m_MaxZoneDist;
00294 double m_MaxVertexDist;
00295 double m_FilterDistance;
00296 int m_ActivePoint;
00297 bool m_RubberBand;
00298 bool m_AutoEditMode;
00299 INT32 m_CurVertexNum;
00300 INT32 m_BeginVertexNum;
00301 INT32 m_EndVertexNum;
00302 ZONE m_CurCursorZone;
00303 POLYLINE m_LastDrawnSection;
00304 TRANS2D_AFFINE m_TransToolToLastDrawn;
00305
00306
00307 DELEGATE_ONSETVERTEX m_DelegateOnSetVertex;
00308 DELEGATE_ONVERTICESCHANGED m_DelegateOnVerticesChanged;
00309
00310
00311 class MANUAL_POLYLINE;
00312 friend class MANUAL_POLYLINE;
00313 class FORM_POLYLINE;
00314 FORM_POLYLINE* m_pFormPolyLine;
00315
00316
00317 void AddLineIfNoActive ();
00318 void AddPoint (const DPOINT3D&, EDITMODE);
00319 void AdjustTool (DPOINT3D&, CHANGESEQ, KEYSTATE);
00320 bool CloseLine ();
00321 void ComputeCursorZone (const DPOINT2D&, bool showmarker);
00322 void DeletePoint (int);
00323 void DeletePoints (MGUI::POINT devpt);
00324 void DrawLastDrawnSection ();
00325 void DrawMarkerCursor (const DPOINT3D& markpt);
00326 void DrawMarkerEnd ();
00327 void DrawMarkerStart ();
00328 void DrawNeighborSegments (const LRECT2D& rectCanvas, bool SkipActive=true, int SkipSegment1=-2, int SkipSegment2=-2);
00329 void DrawNeighborSegments (const DRECT2D& rectTool, const POLYLINE& plTool, int SkipSegment1=-2, int SkipSegment2=-2);
00330 void DrawSegment (const POLYLINE&, int);
00331 void DrawSegment (int, bool);
00332 void DrawSingleLine (const POLYLINE&);
00333 void EraseLine ();
00334 void EraseMarkerCursor ();
00335 void EraseMarkerEnd (bool DrawSegment, bool RestoreActiveLineEnds);
00336 void EraseMarkerStart (bool DrawSegment, bool RestoreActiveLineEnds);
00337 void ErasePoint (int);
00338 void EraseSegment (int);
00339 void FilterVertices (bool FirstTime);
00340 void InsertPoint (int, const DPOINT3D&, UINT32);
00341 void MovePoint (int PointIndex, const DPOINT3D&, UINT32);
00342 bool PrefilterVertices (POLYLINE& PolyLine) const;
00343 void ResetLastDrawnSection (bool UpdateDisplay);
00344 bool SelectNextLine (bool SelectNext);
00345 void UpdateCursor () const;
00346
00347
00348 virtual MGUI::FORM* v_CreateControlForm (LAYOUT_PANE_BASE& ParentPane, CTRLOPT ctrlopt);
00349 virtual MANUAL_BASE* v_CreateManualBase ();
00350 virtual void v_DoDraw ();
00351 virtual int v_GenerateRegion (REGION2D& region) const;
00352 virtual void v_OnClear ();
00353 virtual bool v_OnKey (MGUI::POINT point, KEYCODE keycode, KEYSTATE keystate);
00354 virtual bool v_OnPointerButtonDown (MGUI::POINT point, POINTERBUTTON button, KEYSTATE keystate);
00355 virtual bool v_OnPointerButtonUp (MGUI::POINT point, POINTERBUTTON button, KEYSTATE keystate);
00356 virtual void v_OnPointerMove (MGUI::POINT point, POINTERBUTTON button, KEYSTATE keystate);
00357 virtual void v_OnPointerLeave ();
00358 virtual void v_OnSet3D ();
00359 virtual void v_OnSetTransToWindow ();
00360
00361
00362 virtual void v_OnGPSCoordinate (const DPOINT3D& point);
00363 #endif // GENERATING_DOXYGEN_OUTPUT
00364 };
00365
00366
00367
00368 }
00369
00370 #endif // INC_MGUI_TOOLPOLYLINE_H