wxArt2D
edit.cpp
1 /*! \file editor/src/edit.cpp
2  \author Klaas Holwerda
3 
4  Copyright: 2000-2004 (c) Klaas Holwerda
5 
6  Licence: wxWidgets Licence
7 
8  RCS-ID: $Id: edit.cpp,v 1.173 2009/07/04 10:26:39 titato Exp $
9 */
10 
11 #include "a2dprec.h"
12 
13 #ifdef __BORLANDC__
14 #pragma hdrstop
15 #endif
16 
17 #ifndef WX_PRECOMP
18 #include "wx/wx.h"
19 #endif
20 
21 #include "wx/canvas/canmod.h"
22 
23 #include "wx/canvas/edit.h"
24 
25 #include <wx/wfstream.h>
26 #include <math.h>
27 
28 IMPLEMENT_CLASS( a2dRecursiveEditTool, a2dObjectEditTool )
29 
30 const a2dCommandId a2dRecursiveEditTool::COMID_PushTool_RecursiveEdit( wxT( "PushTool_RecursiveEdit" ) );
31 const a2dCommandId a2dMultiEditTool::COMID_PushTool_MultiEdit( wxT( "PushTool_MultiEdit" ) );
32 
33 
34 BEGIN_EVENT_TABLE( a2dRecursiveEditTool, a2dObjectEditTool )
35  EVT_COM_EVENT( a2dRecursiveEditTool::OnComEvent )
36  EVT_MOUSE_EVENTS( a2dRecursiveEditTool::OnMouseEvent )
37  EVT_IDLE( a2dRecursiveEditTool::OnIdle )
38  EVT_CHAR( a2dRecursiveEditTool::OnChar )
39  EVT_UNDO( a2dRecursiveEditTool::OnUndoEvent )
40  EVT_REDO( a2dRecursiveEditTool::OnRedoEvent )
41  EVT_KEY_UP( a2dRecursiveEditTool::OnKeyUp )
42 END_EVENT_TABLE()
43 
44 a2dRecursiveEditTool::a2dRecursiveEditTool( a2dStToolContr* controller, a2dIterC& ic, int editmode, bool SingleClickToEnd )
45  : a2dObjectEditTool( controller, ic, editmode, SingleClickToEnd )
46 {
47  m_oneshot = false;
48 }
49 
50 a2dRecursiveEditTool::a2dRecursiveEditTool( a2dStToolContr* controller, int editmode, bool SingleClickToEnd )
51  : a2dObjectEditTool( controller, editmode, SingleClickToEnd )
52 {
53  m_oneshot = false;
54 }
55 
57 {
58 }
59 
60 void a2dRecursiveEditTool::OnMouseEvent( wxMouseEvent& event )
61 {
62  if ( !m_active || m_halted )
63  {
64  event.Skip();
65  return;
66  }
67 
68  m_x = event.GetX();
69  m_y = event.GetY();
70 
71  //to world coordinates to do hit test in world coordinates
72  double xw, yw;
73  MouseToToolWorld( m_x, m_y, xw, yw );
74  m_xwprev = xw;
75  m_ywprev = yw;
76 
77  if ( event.Dragging() )
78  {
79 
80  }
81  else if ( event.Moving() && !GetBusy() )
82  {
83  a2dCanvasObject* hit = GetDrawingPart()->IsHitWorld( xw, yw );
84  if ( hit && hit->GetDraggable() )
85  GetDrawingPart()->SetCursor( m_toolBusyCursor );
86  else
87  GetDrawingPart()->SetCursor( m_toolcursor );
88 
89  }
90 
91  if ( event.LeftDClick() )
92  {
93  if ( GetBusy() )
95  else
96  StopTool();
97  }
98  else if ( event.LeftDown() && !GetBusy() )
99  {
100  // if there is a hit on a a2dCanvasObject, the editing starts on that object
101  a2dIterC ic( GetDrawingPart() );
103  a2dHitEvent hitevent = a2dHitEvent( xw, yw, false, a2dCANOBJHITOPTION_LAYERS );
104  m_original = m_parentobject->ChildIsHitWorld( ic, hitevent );
105 
106  if ( !m_original.Get() )
107  return; //no hit
108 
109  if ( !EnterBusyMode() )
110  return; //not editable object
111 
112  //RedirectToEditObject( event );
113  }
114  else if ( event.LeftDown() && GetBusy() )
115  {
116  //maybe go to another object for editing, even subediting might
117  //have bin initiated in the a2dCanvasObject that is being edited.
118 
119  //goto the edit object itself, maybe for sub-editing.
120  //Halted if sub-editing ( another tool is pushed on the tool stack )
121  if ( RedirectToEditObject( event ) || m_stop || m_halted )
122  return;
123 
124  //in case of not having a oneshot action, we can go to another object
125  //while editing this one.
126  if ( !m_oneshot )
127  {
128  a2dCanvasObject* neweditobject = NULL;
129  a2dIterC ic( GetDrawingPart() );
131  a2dHitEvent hitevent = a2dHitEvent( xw, yw, false, a2dCANOBJHITOPTION_LAYERS );
132  neweditobject = m_parentobject->ChildIsHitWorld( ic, hitevent );
133 
134  if ( neweditobject == m_original || neweditobject == m_canvasobject )
135  //nothing new, stay with the object until a double click.
136  return;
137 
138  if ( !neweditobject )
139  {
140  if ( m_SingleClickToEnd )
141  {
142  FinishBusyMode();
143 
144  a2dToolList::const_iterator iter = m_controller->GetToolList().begin();
145  iter++;
146 
147  if ( iter != m_controller->GetToolList().end() )
148  {
149  //! test for subediting ( next tool is also editing tool )
151  if ( c )
152  StopTool();
153  }
154  }
155 
156  //nothing new, stay with the object until a double click.
157  return;
158  }
159 
160  if ( !neweditobject->GetEditable() )
161  return;
162 
163  //the other object is hit, and oke for editing
164  //Stop the current one, and go to the new object
165  FinishBusyMode();
166 
167  m_original = neweditobject;
168 
169  if ( !EnterBusyMode() )
170  return;
171 
172  RedirectToEditObject( event );
173  }
174  else
175  {
176  a2dCanvasObject* neweditobject = NULL;
177  a2dIterC ic( GetDrawingPart() );
179  a2dHitEvent hitevent = a2dHitEvent( xw, yw, false, a2dCANOBJHITOPTION_LAYERS );
180  neweditobject = m_parentobject->ChildIsHitWorld( ic, hitevent );
181 
182  if ( !neweditobject && !m_SingleClickToEnd || neweditobject == m_original || neweditobject == m_canvasobject )
183  //nothing new so continue with current editobject
184  return;
185 
186  StopTool();
187  }
188  }
189  else if ( event.LeftUp() && GetBusy() )
190  {
191  if ( !RedirectToEditObject( event ) )
192  event.Skip();
193  }
194  else if ( GetBusy() )
195  {
196  if ( !RedirectToEditObject( event ) )
197  event.Skip();
198  }
199  else
200  {
201  event.Skip();
202  }
203 }
204 
205 
206 void a2dRecursiveEditTool::OnComEvent( a2dComEvent& event )
207 {
208  if ( GetBusy() )
209  {
210  if ( event.GetId() == a2dStTool::sig_toolBeforePush )
211  {
212  // If tool is busy, it will enter halted state
213  if ( GetBusy() && !m_halted )
214  {
215  m_halted = true;
217  }
218  m_pending = true;
219  }
220  else if ( event.GetId() == a2dDrawingPart::sig_changedShowObject )
221  {
222  a2dCanvasObject* newtop = wxStaticCast( event.GetProperty()->GetRefObject(), a2dCanvasObject );
223  if ( newtop )
224  {
225  AbortBusyMode();
226  a2dCorridor corridor;
227  corridor.push_back( newtop );
228  SetCorridor( corridor );
229  }
230  else
231  StopTool();
232  }
233  else
234  event.Skip();
235  }
236 
237  event.Skip();
238 }
239 
240 
241 //! used to add object to a a2dCanvasDocument in the current parent
242 /*!
243 
244  \ingroup commands
245 */
246 class A2DCANVASDLLEXP a2dCommand_AddObjectToGroup: public a2dCommand
247 {
248 
249 public:
250  //! used to add object to a a2dCanvasDocument in the current parent
251  /*! \ingroup commandid
252  */
253  static const a2dCommandId Id;
254 
255  a2dCommand_AddObjectToGroup( a2dMultiEditTool* tool = NULL, a2dCanvasObject* object = NULL );
256 
258 
259  bool Do();
260  bool Undo();
261 
262  inline a2dCanvasCommandProcessor* GetCanvasCmp() { return wxStaticCast( m_cmp, a2dCanvasCommandProcessor ); }
263 
264  a2dCanvasObject* GetCanvasObject() { return m_canvasobject; }
265 
266 protected:
267  a2dCanvasObjectPtr m_canvasobject;
268  a2dMultiEditTool* m_tool;
269 };
270 
271 //! used to release object from a a2dCanvasDocument in the current parent
272 /*!
273 
274  \ingroup commands
275 */
276 class A2DCANVASDLLEXP a2dCommand_ReleaseObjectFromGroup: public a2dCommand
277 {
278 public:
279 
280  //! used to release object from a a2dCanvasDocument in the current parent
281  /*! \ingroup commandid
282  */
283  static const a2dCommandId Id;
284 
286 
288 
289  bool Do();
290  bool Undo();
291 
292  inline a2dCanvasCommandProcessor* GetCanvasCmp() { return wxStaticCast( m_cmp, a2dCanvasCommandProcessor ); }
293 
294 protected:
295 
296  a2dCanvasObjectPtr m_canvasobject;
297  int m_index;
298  a2dMultiEditTool* m_tool;
299 };
300 
301 const a2dCommandId a2dCommand_AddObjectToGroup::Id( wxT( "AddObjectToGroup" ) );
302 const a2dCommandId a2dCommand_ReleaseObjectFromGroup::Id( wxT( "ReleaseObjectFromGroup" ) );
303 
304 /*
305 * a2dCommand_AddObjectToGroup
306 */
307 a2dCommand_AddObjectToGroup::a2dCommand_AddObjectToGroup( a2dMultiEditTool* tool, a2dCanvasObject* object ):
309 {
310  m_canvasobject = object;
311  m_tool = tool;
312 }
313 
314 a2dCommand_AddObjectToGroup::~a2dCommand_AddObjectToGroup( void )
315 {
316 }
317 
319 {
320  m_tool->AddToGroup( m_canvasobject );
321  return true;
322 }
323 
325 {
326  m_tool->RemoveFromGroup( m_canvasobject, 0 );
327  return true;
328 }
329 
330 /*
331 * a2dCommand_ReleaseObjectFromGroup
332 */
333 a2dCommand_ReleaseObjectFromGroup::a2dCommand_ReleaseObjectFromGroup( a2dMultiEditTool* tool, a2dCanvasObject* object ):
335 {
336  m_canvasobject = object;
337  //for undo preserve location
338  m_index = 0;
339  m_tool = tool;
340 }
341 
342 a2dCommand_ReleaseObjectFromGroup::~a2dCommand_ReleaseObjectFromGroup( void )
343 {
344 }
345 
347 {
348  m_tool->RemoveFromGroup( m_canvasobject, m_index );
349 
350  if ( m_index == -1 )
352 
353  return true;
354 }
355 
357 {
358  m_tool->AddToGroup( m_canvasobject );
359  return true;
360 }
361 
362 
363 //----------------------------------------------------------------------------
364 // a2dMultiSelectGroup
365 //----------------------------------------------------------------------------
366 //! a2dRecursiveEditTool holds multiple edit object in here
367 /*! When this object is set pending also its child objects are set pending.
368 
369  \ingroup tools commands
370 */
371 class A2DCANVASDLLEXP a2dMultiSelectGroup: public a2dCanvasObject
372 {
373  DECLARE_EVENT_TABLE()
374 
375 public:
376 
377  //!constructor
379 
380  //!destructor
382 
383  a2dMultiSelectGroup( const a2dMultiSelectGroup& other, CloneOptions options, a2dRefMap* refs );
384 
385  a2dCanvasObject* CloneShallow();
386 
387  virtual a2dCanvasObject* StartEdit( a2dBaseTool* tool, wxUint16 editmode, wxEditStyle editstyle = wxEDITSTYLE_COPY, a2dRefMap* refs = NULL );
388 
389 protected:
390 
391  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
392 
393  virtual void RenderChildObjects( a2dIterC& ic, RenderChild& whichchilds, a2dAffineMatrix* tworld, OVERLAP clipparent );
394 
396 
397  void OnHandleEvent( a2dHandleMouseEvent& event );
398 
399 
400 private:
401  //!this is a not implemented copy constructor that avoids automatic creation of one
403 };
404 
405 template class A2DCANVASDLLEXP a2dSmrtPtr<a2dMultiSelectGroup>;
406 
407 
408 BEGIN_EVENT_TABLE( a2dMultiSelectGroup, a2dCanvasObject )
409  EVT_CANVASOBJECT_MOUSE_EVENT( a2dMultiSelectGroup::OnCanvasObjectMouseEvent )
411 END_EVENT_TABLE()
412 
414 {
415  m_childobjects = new a2dCanvasObjectList();
416 }
417 
418 a2dMultiSelectGroup::a2dMultiSelectGroup( const a2dMultiSelectGroup& other, CloneOptions options, a2dRefMap* refs )
419  : a2dCanvasObject( other, options, refs )
420 {
421 }
422 
424 {
425  return new a2dMultiSelectGroup( *this, options, refs );
426 }
427 
428 a2dCanvasObject* a2dMultiSelectGroup::CloneShallow()
429 {
431  for( a2dCanvasObjectList::iterator iter = m_childobjects->begin(); iter != m_childobjects->end(); ++iter )
432  {
433  a2dCanvasObject* obj = *iter;
434  newgr->Append( obj );
435  }
436  return newgr;
437 }
438 
439 void a2dMultiSelectGroup::OnHandleEvent( a2dHandleMouseEvent& event )
440 {
441  a2dIterC* ic = event.GetIterC();
442 
444  {
445  a2dRestrictionEngine* restrictEngine = GetHabitat()->GetRestrictionEngine();
446 
447  a2dHandle* draghandle = event.GetCanvasHandle();
448 
449  //to world group coordinates to do hit test in world group coordinates
450  double xw, yw;
451  xw = event.GetX();
452  yw = event.GetY();
453 
454  //matrix to convert from absolute world coordinates to local object coordinates,
455  //with m_lworld included.
456  double xwi;
457  double ywi;
458  ic->GetInverseTransform().TransformPoint( xw, yw, xwi, ywi );
459 
460  bool __includeChildren__ = PROPID_IncludeChildren->GetPropertyValue( this );
461  a2dBoundingBox untrans;
462  if ( __includeChildren__ )
464  else
466 
467  double xmin, ymin, xmax, ymax, w, h;
468  xmin = untrans.GetMinX();
469  ymin = untrans.GetMinY();
470  xmax = untrans.GetMaxX();
471  ymax = untrans.GetMaxY();
472  w = untrans.GetWidth();
473  h = untrans.GetHeight();
474 
475  a2dAffineMatrix origworld = m_lworld;
476  double x1, y1, x2, y2;
477 
478  a2dCanvasObject* original = PROPID_Original->GetPropertyValue( this );
479 
480  if ( event.GetMouseEvent().LeftDown() )
481  {
482  if ( restrictEngine )
483  restrictEngine->SetRestrictPoint( xw, yw );
484  }
485  else if ( event.GetMouseEvent().LeftUp() )
486  {
487  if ( m_lworld != original->GetTransformMatrix() )
488  {
489  for( a2dCanvasObjectList::iterator iter = original->GetChildObjectList()->begin(); iter != original->GetChildObjectList()->end(); iter++ )
490  {
491  a2dCanvasObject* obj = *iter;
492  a2dAffineMatrix newtrans = m_lworld;
493  newtrans *= obj->GetTransformMatrix();
494  m_root->GetCommandProcessor()->Submit( new a2dCommand_SetCanvasProperty( obj, a2dCanvasObject::PROPID_TransformMatrix, newtrans ) );
495  }
496  for( a2dCanvasObjectList::iterator iter2 = GetChildObjectList()->begin(); iter2 != GetChildObjectList()->end(); iter2++ )
497  {
498  a2dCanvasObject* obj = *iter2;
499  if ( obj->GetBin2() )
500  {
501  a2dAffineMatrix newtrans = m_lworld;
502  newtrans *= obj->GetTransformMatrix();
503  obj->SetTransformMatrix( newtrans );
504  }
505  }
506  // matrix is set to children, now reset group matrix of editcopy (original is always identity matrix )
508  }
509  }
510  else if ( event.GetMouseEvent().Dragging() )
511  {
512  if ( restrictEngine )
513  restrictEngine->RestrictPoint( xw, yw );
514  ic->GetInverseTransform().TransformPoint( xw, yw, xwi, ywi );
515 
516  if ( draghandle->GetName() == wxT( "handle1" ) )
517  {
518  //modify object
519  double dx, dy;
520  dx = xwi - xmin;
521  dy = ywi - ymin;
522 
523  double sx;
524  double sy;
525  if ( w )
526  sx = ( w - dx / 2 ) / w;
527  else
528  sx = 0;
529  if ( h )
530  sy = ( h - dy / 2 ) / h;
531  else
532  sy = 0;
533 
534  origworld.TransformPoint( xmax, ymax, x2, y2 );
535 
536  //reset matrix to identity
538  Scale( sx, sy );
539  Transform( origworld );
540  m_lworld.TransformPoint( xmax, ymax, x1, y1 );
541  Translate( x2 - x1, y2 - y1 );
542  }
543  else if ( draghandle->GetName() == wxT( "handle2" ) )
544  {
545  //modify object
546  double dx, dy;
547  dx = xwi - xmin;
548  dy = ywi - ymax;
549 
550  double sx;
551  double sy;
552  if ( w )
553  sx = ( w - dx / 2 ) / w;
554  else
555  sx = 0;
556  if ( h )
557  sy = ( h + dy / 2 ) / h;
558  else
559  sy = 0;
560 
561  origworld.TransformPoint( xmax, ymin, x2, y2 );
562 
563  //reset matrix to identity
565  Scale( sx, sy );
566  Transform( origworld );
567  m_lworld.TransformPoint( xmax, ymin, x1, y1 );
568  Translate( x2 - x1, y2 - y1 );
569  }
570  else if ( draghandle->GetName() == wxT( "handle3" ) )
571  {
572  //modify object
573  double dx, dy;
574  dx = xwi - xmax;
575  dy = ywi - ymax;
576 
577  double sx;
578  double sy;
579  if ( w )
580  sx = ( w + dx / 2 ) / w;
581  else
582  sx = 0;
583  if ( h )
584  sy = ( h + dy / 2 ) / h;
585  else
586  sy = 0;
587 
588  origworld.TransformPoint( xmin, ymin, x2, y2 );
589 
590  //reset matrix to identity
592  Scale( sx, sy );
593  Transform( origworld );
594  m_lworld.TransformPoint( xmin, ymin, x1, y1 );
595  Translate( x2 - x1, y2 - y1 );
596  }
597  else if ( draghandle->GetName() == wxT( "handle4" ) )
598  {
599  //modify object
600  double dx, dy;
601  dx = xwi - xmax;
602  dy = ywi - ymin;
603 
604  double sx;
605  double sy;
606  if ( w )
607  sx = ( w + dx / 2 ) / w;
608  else
609  sx = 0;
610  if ( h )
611  sy = ( h - dy / 2 ) / h;
612  else
613  sy = 0;
614 
615  origworld.TransformPoint( xmin, ymax, x2, y2 );
616 
617  //reset matrix to identity
619  Scale( sx, sy );
620  Transform( origworld );
621  m_lworld.TransformPoint( xmin, ymax, x1, y1 );
622  Translate( x2 - x1, y2 - y1 );
623  }
624  else if ( draghandle->GetName() == wxT( "rotate" ) )
625  {
626  double xr, yr;
627  m_lworld.TransformPoint( xmin + w / 2, ymin + h / 2, xr, yr );
628 
629  //modify object
630  double dx, dy;
631 
632  dx = xw - xr;
633  dy = yw - yr;
634  double angn;
635  if ( !dx && !dy )
636  angn = 0;
637  else
638  angn = wxRadToDeg( atan2( dy, dx ) );
639 
640  m_lworld = m_lworld.Rotate( angn - m_lworld.GetRotation(), xr, yr );
641 
642  //rotate.Translate( xr, yr);
643  //rotate.Rotate(wxRadToDeg(-ang));
644  //rotate.Translate( xr, yr);
645  //Transform(rotate);
646  }
647  else if ( draghandle->GetName() == wxT( "skewx" ) )
648  {
649  //modify object
650  double dx, dy;
651 
652  dx = xwi - ( xmin + w * 3 / 4 );
653  dy = ywi - ( ymin + h / 2 );
654 
655  origworld.TransformPoint( xmin + w / 2, ymin + h / 2, x2, y2 );
656 
657  //reset matrix to identity
659  SkewX( wxRadToDeg( atan2( dx, dy ) ) );
660  Transform( origworld );
661  m_lworld.TransformPoint( xmin + w / 2, ymin + h / 2, x1, y1 );
662  Translate( x2 - x1, y2 - y1 );
663  }
664  else if ( draghandle->GetName() == wxT( "skewy" ) )
665  {
666  //modify object
667  double dx, dy;
668 
669  dx = xwi - ( xmin + w / 2 );
670  dy = ywi - ( ymin + h * 3 / 4 );
671 
672  origworld.TransformPoint( xmin + w / 2, ymin + h / 2, x2, y2 );
673 
674  //reset matrix to identity
676  SkewY( wxRadToDeg( atan2( dy, dx ) ) );
677  Transform( origworld );
678  m_lworld.TransformPoint( xmin + w / 2, ymin + h / 2, x1, y1 );
679  Translate( x2 - x1, y2 - y1 );
680  }
681  else if ( draghandle->GetName() == wxT( "handle12" ) )
682  {
683  //modify object
684  double dx;
685 
686  dx = xwi - xmin;
687 
688  double sx;
689  if ( w )
690  sx = ( w - dx / 2 ) / w;
691  else
692  sx = 0;
693 
694  origworld.TransformPoint( xmax, ymax, x2, y2 );
695 
696  //reset matrix to identity
698  Scale( sx, 1 );
699  Transform( origworld );
700  m_lworld.TransformPoint( xmax, ymax, x1, y1 );
701  Translate( x2 - x1, y2 - y1 );
702  }
703  else if ( draghandle->GetName() == wxT( "handle23" ) )
704  {
705  //modify object
706  double dy;
707 
708  dy = ywi - ymax;
709 
710  double sy;
711  if ( h )
712  sy = ( h + dy / 2 ) / h;
713  else
714  sy = 0;
715 
716  origworld.TransformPoint( xmax, ymin, x2, y2 );
717 
718  //reset matrix to identity
720  Scale( 1, sy );
721  Transform( origworld );
722  m_lworld.TransformPoint( xmax, ymin, x1, y1 );
723  Translate( x2 - x1, y2 - y1 );
724  }
725  else if ( draghandle->GetName() == wxT( "handle34" ) )
726  {
727  //modify object
728  double dx;
729 
730  dx = xwi - xmax;
731 
732  double sx;
733  if ( w )
734  sx = ( w + dx / 2 ) / w;
735  else
736  sx = 0;
737 
738  origworld.TransformPoint( xmin, ymin, x2, y2 );
739 
740  //reset matrix to identity
742  Scale( sx, 1 );
743  Transform( origworld );
744  m_lworld.TransformPoint( xmin, ymin, x1, y1 );
745  Translate( x2 - x1, y2 - y1 );
746  }
747  else if ( draghandle->GetName() == wxT( "handle41" ) )
748  {
749  //modify object
750  double dy;
751 
752  dy = ywi - ymin;
753 
754  double sy;
755  if ( h )
756  sy = ( h - dy / 2 ) / h;
757  else
758  sy = 0;
759 
760  origworld.TransformPoint( xmin, ymax, x2, y2 );
761 
762  //reset matrix to identity
764  Scale( 1, sy );
765  Transform( origworld );
766  m_lworld.TransformPoint( xmin, ymax, x1, y1 );
767  Translate( x2 - x1, y2 - y1 );
768  }
769  else
770  event.Skip();
771  SetPending( true );
772  }
773  }
774 }
775 
777 {
778  a2dIterC* ic = event.GetIterC();
779  ic->SetPerLayerMode( false );
780 
781  if ( event.GetMouseEvent().RightDown() )
782  {
783  //wxWindow* win = ic->GetDrawingPart()->GetDisplayWindow();
784  //win->PopupMenu(mousemenu,event.GetX(), event.GetY());
785  //wxLogDebug( wxT(" reached vertex curve with left down ") );
786  a2dCanvasObjectMouseEvent popup( ic, this, wxEVT_CANVASOBJECT_POPUPMENU_EVENT, event.GetX(), event.GetY(), event.m_mouseevent );
787  popup.SetEventObject( this );
788 
789  if ( !this->ProcessEvent( popup ) )
790  event.Skip();
791  }
792  // editing of an object is based on the editcopy flag, which is only set at the top object of an editclone.
793  // So the children of the object being edited does not have the flag set.
794  else if ( m_flags.m_editingCopy && m_flags.m_editable )
795  {
796  a2dRestrictionEngine* restrictEngine = GetHabitat()->GetRestrictionEngine();
797  a2dCanvasObject* original = PROPID_Original->GetPropertyValue( this );
798  a2dCanvasObject* parent = PROPID_Parent->GetPropertyValue( this );
799 
800  static double xshift;
801  static double yshift;
802 
803  double xw, yw;
804  xw = event.GetX();
805  yw = event.GetY();
806 
807  double xh, yh;
808  ic->GetInverseTransform().TransformPoint( xw, yw, xh, yh );
809 
810  if ( event.GetMouseEvent().Moving() )///&& m_flags.m_subEditAsChild )
811  {
812  ic->GetDrawingPart()->SetCursor( a2dCanvasGlobals->GetCursor( a2dCURSOR_HAND ) );
813  }
814  else if ( event.GetMouseEvent().LeftDClick() )
815  {
816  // double click while the object is in edit mode (m_flags.m_editingCopy)
817  // will result in stopping the oneshot edit tool.
818  EndEdit();
819  }
820  else if ( event.GetMouseEvent().LeftDown() )
821  {
822  // if the object is hit, we can test for sub editing of child objects.
823  // The special case is the object called LABEL, which has priority.
824  // Next candidate is the child hit.
825  a2dHitEvent hitevent = a2dHitEvent( xw, yw, false );
826  if ( IsHitWorld( *ic, hitevent ) )
827  {
828  if ( restrictEngine )
829  restrictEngine->SetRestrictPoint( xw, yw );
830 
831  if ( 1 )
832  {
833  a2dCanvasObject* hit = NULL;
834  if ( hit && hit->GetEditable() ) //subediting of child or labels, is we have a hit.
835  {
836  a2dIterCU cu( *ic, original );
837  a2dToolContr* controller = wxStaticCast( PROPID_Controller->GetPropertyValue( this ).Get(), a2dToolContr );
838 
839  //editing is always a oneshot, since editing of children here is under control of the
840  //a2dCanvasObject (can be different for derived classes). So editing tool should not take over
841  //the decision to edit one after another child.
842  ic->SetCorridorPath( true, NULL );
843  controller->StartEditingObject( hit, *ic );
844  }
845  //subediting was not wanted or hit, therefore now start dragging the object itself
846  //at mouse LeftDown
847  else if ( IsDraggable() )
848  {
849  // Corridor is already in place, since edit tool is active.
850  // Set corridor captured on this object, in order to drag.
851  ic->SetCorridorPathCaptureObject( this );
852  xshift = GetPosX() - xh;
853  yshift = GetPosY() - yh;
854  }
855  }
856  }
857  // left down and no hit on this object, while the object is in edit mode (m_flags.m_editingCopy)
858  // will result in stopping the oneshot edit tool.
859  else
860  {
861  EndEdit();
862  }
863  }
864  else if ( event.GetMouseEvent().LeftUp() && ic->GetDrawingPart()->GetCaptured() )
865  {
866  // the corridor was captured at Left Down.
867  ic->SetCorridorPathCaptureObject( NULL );
868  ic->GetDrawingPart()->GetCanvas()->SetCursor( a2dCanvasGlobals->GetCursor( a2dCURSOR_HAND ) );
869 
870  if ( original->GetTransformMatrix() != m_lworld )
871  {
872  for( a2dCanvasObjectList::iterator iter = original->GetChildObjectList()->begin(); iter != original->GetChildObjectList()->end(); iter++ )
873  {
874  a2dCanvasObject* obj = *iter;
875  a2dAffineMatrix newtrans = m_lworld;
876  newtrans *= obj->GetTransformMatrix();
877  m_root->GetCommandProcessor()->Submit( new a2dCommand_SetCanvasProperty( obj, a2dCanvasObject::PROPID_TransformMatrix, newtrans ) );
878  }
879  for( a2dCanvasObjectList::iterator iter2 = GetChildObjectList()->begin(); iter2 != GetChildObjectList()->end(); iter2++ )
880  {
881  a2dCanvasObject* obj = *iter2;
882  if ( obj->GetBin2() )
883  {
884  a2dAffineMatrix newtrans = m_lworld;
885  newtrans *= obj->GetTransformMatrix();
886  obj->SetTransformMatrix( newtrans );
887  }
888  }
889  // matrix is set to children, now reset group matrix of editcopy (original is always identity matrix )
891  }
892  }
893  else if ( IsDraggable() && event.GetMouseEvent().Dragging() && ic->GetDrawingPart()->GetCaptured() )
894  {
895  double x, y;
896  x = xh + xshift;
897  y = yh + yshift;
898 
899  if( restrictEngine )
900  {
901  //temporarily restore position according to the mouse position, which is the unrestricted position.
902  SetPosXY( x, y );
903 
904  a2dPoint2D point;
905  double dx, dy; //detect restriction distance of any point.
906  if ( restrictEngine->RestrictCanvasObjectAtVertexes( this, point, dx, dy ) )
907  {
908  //restrict the object drawing to that point
909  x += dx;
910  y += dy;
911  }
912  }
913  SetPosXY( x, y );
914  }
915  else
916  event.Skip();
917  }
918  else
919  event.Skip();
920 
921 }
922 void a2dMultiSelectGroup::RenderChildObjects( a2dIterC& ic, RenderChild& whichchilds, a2dAffineMatrix* WXUNUSED( tworld ), OVERLAP clipparent )
923 {
924  //ic.GetDrawer2D()->SetDrawStyle( a2dWIREFRAME_INVERT_ZERO_WIDTH );
926  a2dCanvasObject::RenderChildObjects( ic, whichchilds, clipparent );
927  //ic.GetDrawer2D()->SetDrawStyle( a2dFILLED );
928 }
929 
931 {
932  if ( m_flags.m_editable )
933  {
934  a2dCanvasObjectPtr editcopy;
935  editcopy = TClone( clone_flat | clone_seteditcopy | clone_setoriginal, refs );
936 
937  editcopy->DoConnect( false );
938  SetSnapTo( false );
939  editcopy->SetSnapTo( false );
940  SetSelected( false );
941  editcopy->SetSelected( false );
942 
943  if ( ! PROPID_Allowrotation->GetPropertyValue( this ) )
944  PROPID_Allowrotation->SetPropertyToObject( editcopy, true );
945  if ( ! PROPID_Allowsizing->GetPropertyValue( this ) )
946  PROPID_Allowsizing->SetPropertyToObject( editcopy, true );
947  if ( ! PROPID_Allowskew->GetPropertyValue( this ) )
948  PROPID_Allowskew->SetPropertyToObject( editcopy, true );
949  PROPID_Parent->SetPropertyToObject( editcopy, tool->GetParentObject() );
950  editcopy->SetEditingRender( true );
951 
952  editcopy->Update( updatemask_force );
953 
954  m_flags.m_editing = true;
955 
956  PROPID_Editmode->SetPropertyToObject( editcopy, editmode );
957  PROPID_Editstyle->SetPropertyToObject( editcopy, ( wxUint16 ) editstyle );
958 
959  //the next maybe overruled in derived class
960  PROPID_IncludeChildren->SetPropertyToObject( editcopy, true );
961  PROPID_Controller->SetPropertyToObject( editcopy, tool->GetToolController() );
963  //new start edit, so no event yet
965 
966  if ( !editcopy->DoStartEdit( editmode, editstyle ) )
967  {
968  EndEdit();
969  return NULL;
970  }
971 
972  // Add the editcopy to the parent and set some flags
973  tool->AddEditobject( editcopy );
974 
975  return editcopy;
976  }
977 
978  return NULL;
979 }
980 
981 IMPLEMENT_CLASS( a2dMultiEditTool, a2dObjectEditTool )
982 
983 BEGIN_EVENT_TABLE( a2dMultiEditTool, a2dObjectEditTool )
984  EVT_COM_EVENT( a2dMultiEditTool::OnComEvent )
985  EVT_MOUSE_EVENTS( a2dMultiEditTool::OnMouseEvent )
986  EVT_IDLE( a2dMultiEditTool::OnIdle )
987  EVT_CHAR( a2dMultiEditTool::OnChar )
988  EVT_UNDO( a2dMultiEditTool::OnUndoEvent )
989  EVT_REDO( a2dMultiEditTool::OnRedoEvent )
990 END_EVENT_TABLE()
991 
992 a2dMultiEditTool::a2dMultiEditTool( a2dStToolContr* controller ): a2dObjectEditTool( controller )
993 {
994  GetDrawingPart()->SetMouseEvents( false );
995  m_toolcursor = a2dCanvasGlobals->GetCursor( a2dCURSOR_PENCIL );
996  m_oneshot = false;
997 }
998 
999 a2dMultiEditTool::~a2dMultiEditTool()
1000 {
1001  if ( GetDrawingPart() )
1002  GetDrawingPart()->SetMouseEvents( true );
1003 }
1004 
1006 {
1008 
1009 // m_controller->SetEvtHandlerEnabled( false );
1010 // SetEvtHandlerEnabled( false );
1011 
1012  a2dBaseTool::DoStopTool( abort );
1013 
1014  if ( GetDrawingPart() )
1016 
1018 
1019 // SetEvtHandlerEnabled( true );
1020 // m_controller->SetEvtHandlerEnabled( true );
1021 }
1022 
1023 bool a2dMultiEditTool::AddToGroup( a2dCanvasObject* canvasobject )
1024 {
1026  inverse.Invert();
1027  canvasobject->Transform( inverse );
1028  m_original->Append( canvasobject );
1029  m_canvasobject->Append( canvasobject );
1032  return true;
1033 }
1034 
1035 bool a2dMultiEditTool::RemoveFromGroup( a2dCanvasObject* canvasobject, int index )
1036 {
1037  m_canvasobject->ReleaseChild( canvasobject, false, false, true );
1038  m_original->ReleaseChild( canvasobject, false, false, true );
1042  return true;
1043 }
1044 
1045 void a2dMultiEditTool::OnMouseEvent( wxMouseEvent& event )
1046 {
1047  if ( !m_active )
1048  {
1049  event.Skip();
1050  return;
1051  }
1052 
1053  m_x = event.GetX();
1054  m_y = event.GetY();
1055 
1056  //to world coordinates to do hit test in world coordinates
1057  double xw = GetDrawer2D()->DeviceToWorldX( m_x );
1058  double yw = GetDrawer2D()->DeviceToWorldY( m_y );
1059  m_xwprev = xw;
1060  m_ywprev = yw;
1061 
1062  if ( event.Moving() && !GetBusy() )
1063  {
1064  if ( GetDrawingPart()->IsHitWorld( xw, yw ) )
1065  GetDrawingPart()->SetCursor( a2dCanvasGlobals->GetCursor( a2dCURSOR_HAND ) );
1066  else
1067  GetDrawingPart()->SetCursor( a2dCanvasGlobals->GetCursor( a2dCURSOR_ARROW ) );
1068 
1069  }
1070 
1071  if ( event.LeftDown() && !GetBusy() )
1072  {
1073  a2dCanvasObject* hitobject = GetDrawingPart()->IsHitWorld( xw, yw );
1074 
1075  if ( !hitobject )
1076  return;
1077 
1078  a2dAffineMatrix inverse = hitobject->GetTransformMatrix();
1080  m_original->Append( hitobject );
1081  m_original->SetVisible( false );
1082 
1083  if ( !EditStart() )
1084  return;
1085 
1086  RedirectToEditObject( event );
1087 
1088  }
1089  else if ( event.LeftDown() && GetBusy() )
1090  {
1091  a2dCanvasObject* hitobject = NULL;
1092  hitobject = GetDrawingPart()->IsHitWorld( xw, yw );
1093 
1094  if ( hitobject == m_canvasobject || hitobject == m_original )
1095  {
1096  //test the edit copy object, to test on handles
1098  a2dIterC ic( GetDrawingPart() );
1099  a2dIterCU cu( ic, selectworld );
1100  a2dHitEvent hitevent = a2dHitEvent( xw, yw, false, a2dCANOBJHITOPTION_LAYERS );
1101  hitobject = m_canvasobject->ChildIsHitWorld( ic, hitevent );
1102  if ( hitobject )
1103  {
1104  if ( !event.m_shiftDown )
1105  {
1106  RedirectToEditObject( event );
1107  }
1108  else
1109  {
1110  //remove object hit from selection by setting its bin flag off
1111  if ( m_original->Find( hitobject ) )
1112  {
1114  }
1115  }
1116  return;
1117  }
1118  }
1119 
1120  {
1121  //no hit in selection
1122  if ( !m_oneshot )
1123  {
1124  hitobject = GetDrawingPart()->IsHitWorld( xw, yw );
1125 
1126  if ( !hitobject )
1127  {
1128  //nothing new so continue with current editobject
1129  RedirectToEditObject( event );
1130  return;
1131  }
1132 
1133  if ( !hitobject->GetEditable() || hitobject == m_canvasobject )
1134  {
1135  return;
1136  }
1137 
1138  if ( event.m_shiftDown ) //user wants to add object to the multigroup
1139  {
1141  }
1142  else
1143  {
1144  }
1145  }
1146  else
1147  {
1148  FinishBusyMode();
1149  //RedirectToEditObject( event );
1150  }
1151  }
1152  }
1153  else if ( event.LeftDClick() && GetBusy() )
1154  {
1155  if ( GetBusy() )
1156  FinishBusyMode();
1157  else
1158  StopTool();
1159  }
1160  else if ( GetBusy() )
1161  {
1162  if ( event.RightDown() )
1163  event.Skip();
1164  else
1165  RedirectToEditObject( event );
1166  }
1167  else
1168  {
1169  event.Skip();
1170  }
1171 }
1172 
1173 bool a2dMultiEditTool::RedirectToEditObject( wxMouseEvent& event )
1174 {
1176  return false;
1177 
1178  bool isHit;
1179  bool processed = false;
1180 
1181  int margin = GetDrawing()->GetHabitat()->GetHitMarginDevice();
1182 
1183  a2dAffineMatrix cWorld;
1184 
1185  processed = GetDrawingPart()->ProcessCanvasObjectEvent( event, isHit, m_xwprev, m_ywprev, margin );
1186 
1187  wxPoint pos = m_stcontroller->GetMousePosition();
1188  GetDrawingPart()->UpdateCrossHair( pos.x, pos.y );
1189 
1190  //the event did stop the editing of the object
1192  {
1193  if ( m_halted )
1195  else
1196  FinishBusyMode();
1197  }
1198 
1199  return processed;
1200 }
1201 
1203 {
1205  m_original->Append( startobject );
1206  m_original->SetVisible( false );
1207  EditStart();
1208  return true;
1209 }
1210 
1211 bool a2dMultiEditTool::StartEditingSelected()
1212 {
1214  a2dCanvasObjectList* objs = objects->Clone( a2dCanvasOFlags::SELECTED, a2dObject::clone_flat );
1215 
1217  m_original->SetVisible( false );
1219  {
1220  a2dCanvasObject* obj = *iter;
1221  m_original->Append( obj );
1222  }
1223  delete objs;
1224  EditStart();
1225  return true;
1226 }
1227 
1228 bool a2dMultiEditTool::EditStart()
1229 {
1230  //temporary add the a2dMultiSelectGroup object for editing the group.
1232 
1233  //to be able to do mouse hits already bbox's need to be up to date.
1235 
1236  //m_original->SetFill( a2dTRANSPARENT_FILL );
1237  //m_original->SetStroke( GetDrawing()->GetHabitat()->GetHandle()->GetStroke() );
1238 
1239  EnterBusyMode();
1240 
1241  return true;
1242 }
1243 
1245 {
1246  SetEditObject( NULL );
1247 
1248  if ( GetBusy() )
1249  {
1252 
1253  if ( GetDrawingPart() ) //in case of destruction this is set to NULL
1254  GetDrawingPart()->SetCursor( *wxSTANDARD_CURSOR );
1255 
1258 
1261 
1262  m_parentobject->ReleaseChild( m_original, false, false, true );
1263 
1265 
1266  GetDrawing()->GetHabitat()->GetConnectionGenerator()->RerouteWires( true );
1267 
1268  if ( !m_halted )
1270 
1271  if ( m_disableOtherViews && GetDrawingPart() )
1272  {
1273  //GetDrawingPart()->GetCanvasDocument()->EnableAllViews( true, GetDrawingPart() );
1274  }
1275  }
1277 
1278  m_original = 0;
1279  m_canvasobject = 0;
1280 }
1281 
1282 void a2dMultiEditTool::OnIdle( wxIdleEvent& event )
1283 {
1284  if ( m_original )
1285  {
1286  if ( m_pending )
1287  {
1288  //m_editobject->SetPending( true );
1289  //m_pending = false;
1290  }
1291  }
1292  else
1293  a2dStTool::OnIdle( event );
1294 }
1295 
1296 void a2dMultiEditTool::OnChar( wxKeyEvent& event )
1297 {
1298  event.Skip();
1299 }
1300 
1301 void a2dMultiEditTool::OnComEvent( a2dComEvent& event )
1302 {
1303  event.Skip();
1304 }
1305 
1306 
1307 void a2dMultiEditTool::SetActive( bool active )
1308 {
1309  if ( active )
1310  {
1311  if ( m_halted )
1312  {
1313  m_halted = false;
1314  //RESTART editing so the edit copy becomes updated from the original.
1315  //original may have changed because of sub-editing of child objects.
1317  m_active = true;
1318  }
1319  m_pending = true;
1320  a2dBaseTool::SetActive( active );
1321  }
1322  else
1323  {
1324  //the subedit or other subtools should not influence style of the object.
1325  //When this tool is activated again, the CurrentCanvasObject is set right again.
1326  //SetEditObject( NULL );
1327 
1328  m_pending = true;
1329  a2dBaseTool::SetActive( active );
1330  }
1331 }
1332 
1333 void a2dMultiEditTool::OnUndoEvent( a2dCommandProcessorEvent& WXUNUSED( event ) )
1334 {
1335  if ( GetBusy() && !m_halted )
1336  {
1337  // recreate edit copies so the edit copy becomes updated from the original.
1338  wxUint16 editmode = a2dCanvasObject::PROPID_Editmode->GetPropertyValue( m_canvasobject );
1339  ReStartEdit( editmode );
1340  }
1341 }
1342 
1343 void a2dMultiEditTool::OnRedoEvent( a2dCommandProcessorEvent& event )
1344 {
1345  OnUndoEvent( event );
1346 }
1347 
1348 
1349 
1350 
1351 //----------------------------------------------------------------------------
1352 // a2dObjectEditTool
1353 //----------------------------------------------------------------------------
1354 
1355 
1356 
1357 DEFINE_EVENT_TYPE( a2dObjectEditTool::sig_toolStartEditObject )
1358 
1359 IMPLEMENT_CLASS( a2dObjectEditTool, a2dStTool )
1360 
1361 const a2dCommandId a2dObjectEditTool::COMID_PushTool_ObjectEdit( wxT( "PushTool_ObjectEdit" ) );
1362 
1363 BEGIN_EVENT_TABLE( a2dObjectEditTool, a2dStTool )
1364  EVT_COM_EVENT( a2dObjectEditTool::OnComEvent )
1365  EVT_MOUSE_EVENTS( a2dObjectEditTool::OnMouseEvent )
1366  EVT_IDLE( a2dObjectEditTool::OnIdle )
1367  EVT_CHAR( a2dObjectEditTool::OnChar )
1368  EVT_UNDO( a2dObjectEditTool::OnUndoEvent )
1369  EVT_REDO( a2dObjectEditTool::OnRedoEvent )
1370  EVT_DO( a2dRecursiveEditTool::OnDoEvent )
1371  EVT_KEY_UP( a2dObjectEditTool::OnKeyUp )
1372  EVT_KEY_DOWN( a2dObjectEditTool::OnKeyDown )
1373 END_EVENT_TABLE()
1374 
1375 a2dObjectEditTool::a2dObjectEditTool( a2dStToolContr* controller, a2dIterC& ic, int editmode, bool SingleClickToEnd )
1376  : a2dStTool( controller )
1377 {
1378  m_mode = editmode;
1379 
1380  GetDrawingPart()->SetMouseEvents( false );
1381  m_toolcursor = a2dCanvasGlobals->GetCursor( a2dCURSOR_PENCIL );
1382  m_canvasobject = 0;
1383  m_halted = false;
1384  m_oneshot = true;
1385  m_triggerRestart = false;
1386 
1387  m_SingleClickToEnd = SingleClickToEnd;
1388 
1389  m_disableOtherViews = false;//true;
1390 
1391  // overrule corridor of base class setting, which is based on the view is less flexible,
1392  // matrixes calculated might not contain all in case of complex object in corridor.
1393  SetContext( ic, NULL );
1394 
1395  a2dCanvasCommandProcessor* docCmdh = GetCanvasCommandProcessor();
1396  docCmdh->ConnectEvent( wxEVT_DO, this );
1397  docCmdh->ConnectEvent( wxEVT_UNDO, this );
1398  docCmdh->ConnectEvent( wxEVT_REDO, this );
1399  docCmdh->ConnectEvent( a2dEVT_COM_EVENT, this );
1400 }
1401 
1402 a2dObjectEditTool::a2dObjectEditTool( a2dStToolContr* controller, int editmode, bool SingleClickToEnd )
1403  : a2dStTool( controller )
1404 {
1406  m_parentobject = m_corridor.back();
1407 
1408  m_original = NULL;
1409  m_mode = editmode;
1410 
1411  GetDrawingPart()->SetMouseEvents( false );
1412  m_toolcursor = a2dCanvasGlobals->GetCursor( a2dCURSOR_PENCIL );
1413  m_canvasobject = 0;
1414  m_halted = false;
1415  m_oneshot = true;
1416  m_triggerRestart = false;
1417 
1418  m_SingleClickToEnd = SingleClickToEnd;
1419 
1420  m_disableOtherViews = false;//true;
1421 
1422  if ( m_parentobject != GetDrawingPart()->GetShowObject() )
1424 
1426  docCmdh->ConnectEvent( wxEVT_DO, this );
1427  docCmdh->ConnectEvent( wxEVT_UNDO, this );
1428  docCmdh->ConnectEvent( wxEVT_REDO, this );
1429  docCmdh->ConnectEvent( a2dEVT_COM_EVENT, this );
1430 }
1431 
1433 {
1434  m_corridor = a2dCorridor( ic );
1435  m_parentobject = m_corridor.back();
1436 
1437  StartToEdit( objectToEdit );
1438 
1439  // add captured editclone too
1440  m_corridor = a2dCorridor( ic );
1441 
1442  return true;
1443 }
1444 
1446 {
1447  if ( !GetDrawingPart()->GetDrawing()->GetMayEdit() )
1448  {
1449  wxLogWarning( _T( "You may not edit this drawing" ) );
1450  return;
1451  }
1452 
1453  m_original = objectToEdit;
1454 
1455  if ( m_parentobject != GetDrawingPart()->GetShowObject() )
1457 
1458  bool ret = true;
1459  if ( m_original )
1460  ret = EnterBusyMode();
1461 
1462  if ( !ret || !objectToEdit || ( objectToEdit && !m_canvasobject ) )
1463  {
1464  wxMessageBox( _( "wanted object can not be edited" ), _( "Editing Component" ), wxOK );
1465  return;
1466  }
1467 
1468  // the editing process was started, but maybe if ended by the object directly.
1469  // ( e.g. just a dialog editing, and no mouse handling ).
1470  if ( m_original && !m_original->GetEditing() )
1471  {
1472  // in pinciple this signals to objects that editing was canceled, using bin2 flag.
1473  if ( m_canvasobject->GetBin2() )
1474  AbortBusyMode();
1475  else
1476  FinishBusyMode();
1477  }
1478  // todo ic.SetCorridorPathCaptureObject( m_canvasobject );
1479 }
1480 
1482 {
1483  if ( GetDrawingPart() )
1484  GetDrawingPart()->SetMouseEvents( true );
1485 
1487  docCmdh->DisconnectEvent( wxEVT_DO, this );
1488  docCmdh->DisconnectEvent( wxEVT_UNDO, this );
1489  docCmdh->DisconnectEvent( wxEVT_REDO, this );
1490  docCmdh->DisconnectEvent( a2dEVT_COM_EVENT, this );
1491 }
1492 
1494 {
1495  if ( GetDrawingPart() )
1496  {
1497  a2dComEvent event( this, objectToEdit, sig_toolComEventSetEditObject );
1498  ProcessEvent( event );
1499  }
1500 }
1501 
1503 {
1506 
1507  m_mode = mode;
1508  if ( m_mode > 2 ) m_mode = 0;
1509 
1511 }
1512 
1514 {
1516 
1517 // m_controller->SetEvtHandlerEnabled( false );
1518 // SetEvtHandlerEnabled( false );
1519 
1520  a2dBaseTool::DoStopTool( abort );
1521 
1522  if ( GetDrawingPart() )
1524 
1526 
1527 // SetEvtHandlerEnabled( true );
1528 // m_controller->SetEvtHandlerEnabled( true );
1529 }
1530 
1532 {
1533  switch( m_stcontroller->GetDragMode() )
1534  {
1535  case wxDRAW_RECTANGLE:
1536  m_renderOriginal = true;
1537  m_renderEditcopy = false;
1538  m_renderEditcopyOnTop = false;
1539  m_renderEditcopyEdit = true;
1540  m_renderEditcopyRectangle = false;
1541  break;
1542 
1543  case wxDRAW_ONTOP:
1544  m_renderOriginal = false;
1545  m_renderEditcopy = false;
1546  m_renderEditcopyOnTop = true;
1547  m_renderEditcopyEdit = false;
1548  m_renderEditcopyRectangle = false;
1549  break;
1550 
1551  case wxDRAW_REDRAW:
1552  wxASSERT_MSG( 0, _( "m_renderEditcopy is not yet implemented, m_renderEditcopyOnTop used instead" ) );
1553  m_renderOriginal = false;
1554  m_renderEditcopy = false;
1555  m_renderEditcopyOnTop = true;
1556  m_renderEditcopyEdit = false;
1557  m_renderEditcopyRectangle = false;
1558  break;
1559  default:
1560  ;
1561  }
1562 }
1563 
1565 {
1566  return a2dStTool::EnterBusyMode();
1567 }
1568 
1569 void a2dObjectEditTool::FinishBusyMode( bool closeCommandGroup )
1570 {
1571  if ( m_oneshot && !m_halted )
1572  {
1574  }
1576 }
1577 
1579 {
1581 }
1582 
1583 void a2dObjectEditTool::OnMouseEvent( wxMouseEvent& event )
1584 {
1585  if ( !m_active || m_halted )
1586  {
1587  event.Skip();
1588  return;
1589  }
1590 
1591  m_x = event.GetX();
1592  m_y = event.GetY();
1593 
1594  //to world coordinates to do hit test in world coordinates
1595  double xw, yw;
1596  MouseToToolWorld( m_x, m_y, xw, yw );
1597  m_xwprev = xw;
1598  m_ywprev = yw;
1599 
1600  if ( event.Dragging() )
1601  {
1602 
1603  }
1604 
1605  if ( event.LeftDClick() )
1606  {
1607  if ( GetBusy() )
1608  FinishBusyMode();
1609  else
1610  StopTool();
1611  }
1612  else if ( event.LeftDown() && GetBusy() )
1613  {
1614  //goto the edit object itself, maybe for sub-editing.
1615  //Halted if sub-editing ( another tool is pushed on the tool stack )
1616  if ( RedirectToEditObject( event ) || m_stop || m_halted )
1617  return;
1618 
1619  // if left down was not handle inside object that is being edited,
1620  // that should lead to an end edit of the object, if the hit is outside the object.
1621  a2dCanvasObject* neweditobject = NULL;
1622  a2dIterC ic( GetDrawingPart() );
1624  a2dHitEvent hitevent = a2dHitEvent( xw, yw, false, a2dCANOBJHITOPTION_LAYERS );
1625  neweditobject = m_parentobject->ChildIsHitWorld( ic, hitevent );
1626 
1627  if ( !neweditobject && !m_SingleClickToEnd || neweditobject == m_original || neweditobject == m_canvasobject )
1628  //nothing new so continue with current editobject
1629  return;
1630 
1631  StopTool();
1632  }
1633  else if ( event.LeftUp() && GetBusy() )
1634  {
1635  if ( !RedirectToEditObject( event ) )
1636  event.Skip();
1637  }
1638  else if ( GetBusy() )
1639  {
1640  if ( !RedirectToEditObject( event ) )
1641  event.Skip();
1642  }
1643  else
1644  {
1645  event.Skip();
1646  }
1647 }
1648 
1649 bool a2dObjectEditTool::RedirectToEditObject( wxMouseEvent& event )
1650 {
1652  return false;
1653 
1654  //SetStateString( "", 10 );
1655  //SetStateString( "", 11 );
1656 
1657  bool isHit;
1658  bool processed = false;
1659 
1660  int margin = GetDrawing()->GetHabitat()->GetHitMarginDevice();
1661 
1662  // the next NOT to tool world but to view world coordinates, since the event is going
1663  // from ShowObject all the way down.
1664  double xw = GetDrawer2D()->DeviceToWorldX( m_x );
1665  double yw = GetDrawer2D()->DeviceToWorldY( m_y );
1666  processed = GetDrawingPart()->ProcessCanvasObjectEvent( event, isHit, xw, yw, margin );
1667 
1668  if ( m_canvasobject )
1669  {
1671 
1672  // a2dIterC ic( GetDrawingPart() );
1673  // ic.SetHitMarginDevice( ( int ) ( GetDrawing()->GetHabitat()->GetPin()->GetWidth() / 2.0 ) );
1674  // GetDrawing()->GetHabitat()->GetConnectionGenerator()->GeneratePinsToConnectObject( ic, m_parentobject, m_canvasobject );
1675  GetDrawing()->GetHabitat()->GetConnectionGenerator()->RerouteWires( false );
1676 
1677  double unitScale = GetDrawing()->GetUnitsScale();
1678  wxString state, form;
1679  //if ( m_stcontroller->GetStatusStrings()[10].IsEmpty() )
1680  {
1681  form = m_stcontroller->GetFormat() + " " + m_stcontroller->GetFormat();
1682  state.Printf( form, m_canvasobject->GetBboxMinX()*unitScale, m_canvasobject->GetBboxMinY()*unitScale );
1683  SetStateString( state, 10 );
1684  }
1685  //if ( m_stcontroller->GetStatusStrings()[11].IsEmpty() )
1686  {
1687  form = _T("width = ") + m_stcontroller->GetFormat() + _T(" height = ") + m_stcontroller->GetFormat();
1688  state.Printf( form, m_canvasobject->GetBboxWidth()*unitScale, m_canvasobject->GetBboxHeight()*unitScale );
1689  SetStateString( state, 11 );
1690  }
1691  }
1692 
1693  wxPoint pos = m_stcontroller->GetMousePosition();
1694  GetDrawingPart()->UpdateCrossHair( pos.x, pos.y );
1695 
1696  // If the event did stop the editing of the object, the editing flag is gone.
1697  // This may be because the object inside decided to stop editing,
1698  // OR it started pushing another subediting tool, and this tool should
1699  // continue later.
1700  if ( m_original && !m_original->GetEditing() )
1701  {
1702  if ( m_halted )
1704  else
1705  FinishBusyMode();
1706  }
1707  return processed;
1708 }
1709 
1710 bool a2dObjectEditTool::ReStartEdit( wxUint16 editmode )
1711 {
1714  SetEditObject( NULL );
1715 
1716  if ( GetBusy() )
1717  {
1720 
1722  GetDrawing()->GetHabitat()->GetConnectionGenerator()->RerouteWires( true );
1723  }
1725 
1726  m_canvasobject = 0;
1727 
1728  m_mode = editmode;
1729 
1730  return CreateToolObjects();
1731 }
1732 
1734 {
1737 
1739  m_original->SetSelected( false );
1740  m_original->SetSelected2( false );
1741 
1742  a2dRefMap refs;
1744 
1745  if ( !m_canvasobject )
1746  return false; //not editable object
1747 
1748  m_canvasobject->SetSelected( false );
1749  m_original->SetSnapTo( false );
1750 
1751 #ifdef EDITBUF
1752  m_original->SetVisible( false );
1754  GetCanvasDocument()->SetUpdatesPending( false );
1756  GetCanvasDocument()->SetIgnorePendingObjects( true );
1757 #endif
1758  //! event to make it possible to set style in for instance modeless style dialog
1760  ProcessEvent( event );
1761 
1762 
1763  //drag is comming so first create wires where there are non.
1764  a2dCanvasObjectList dragList;
1765  dragList.push_back( m_original );
1766  if ( m_canvasobject->IsConnect() ) // for a wire, we do not want extra wires at its ends, for normal objects they are often needed.
1767  PrepareForRewire( dragList, true, false, false, false, &refs );
1768  else
1769  PrepareForRewire( dragList, true, false, false, true, &refs );
1770 
1771 
1772  // only now we call this, earlier not possible, because clones of connectedwires not setup yet.
1773  //m_canvasobject->SetBin2( true );
1774  //m_canvasobject->SetBin( true );
1775  refs.LinkReferences( true );
1776 
1777 
1778  // Set the visibility of the original dragged object and the original connected wires.
1779  // When object itself sets the original invisible, that has priority. This is used in ediitng text,
1780  // where original visible is not wanted.
1781  if ( m_original->GetVisible() )
1783 
1784  //we have a hit on an object to be edited
1785  GetDrawingPart()->SetCursor( m_toolcursor );
1786 
1788 
1789  //if ( m_disableOtherViews )
1790  // GetDrawingPart()->GetCanvasDocument()->EnableAllViews( false, GetDrawingPart() );
1791 
1792  return true;
1793 }
1794 
1796 {
1797  SetEditObject( NULL );
1798 
1799  if ( GetBusy() )
1800  {
1801  GetDrawing()->GetHabitat()->GetConnectionGenerator()->RerouteWires( true );
1802 
1803  //if ( m_original->GetFlag( a2dCanvasOFlags::Editing ) )
1804  if ( m_canvasobject )
1806 
1807  if ( GetDrawingPart() ) //in case of destruction this is set to NULL
1808  GetDrawingPart()->SetCursor( *wxSTANDARD_CURSOR );
1809 
1812 
1814  {
1817  }
1819 
1820  if ( !m_halted )
1822 
1823 #ifdef EDITBUF
1824  GetDrawingPart()->SetDocumentDrawStyle( RenderLAYERED | GetDrawing()->GetHabitat()->GetSelectDrawStyle() );
1825  GetCanvasDocument()->SetIgnorePendingObjects( false );
1826 #endif
1827 
1828  if ( m_disableOtherViews && GetDrawingPart() )
1829  {
1830  //GetDrawingPart()->GetCanvasDocument()->EnableAllViews( true, GetDrawingPart() );
1831  }
1832  }
1834  m_canvasobject = 0;
1835 }
1836 
1838 {
1839  if ( m_original && GetBusy() )
1840  {
1841  // Render edit objects in Edit mode
1842  //if( m_renderEditcopyEdit )
1843  {
1845  {
1849  }
1851  {
1852  a2dFill fill = *a2dTRANSPARENT_FILL;
1853  a2dStroke stroke = GetDrawing()->GetHabitat()->GetHandle()->GetStroke();
1855  GetDrawingPart()->SetFixedStyleFill( fill );
1856  GetDrawingPart()->SetFixedStyleStroke( stroke );
1859  }
1861  {
1865  }
1866  else //if ( m_useEditOpaque == a2dOpaqueMode_Off )
1867  {
1868  a2dFill fill = *a2dTRANSPARENT_FILL;
1869  a2dStroke stroke = GetDrawing()->GetHabitat()->GetHandle()->GetStroke();
1871  GetDrawingPart()->SetFixedStyleFill( fill );
1872  GetDrawingPart()->SetFixedStyleStroke( stroke );
1874  }
1875  }
1876  }
1877 }
1878 
1879 void a2dObjectEditTool::TriggerReStartEdit( wxUint16 editmode )
1880 {
1881  m_triggerRestart = true;
1882 }
1883 
1884 void a2dObjectEditTool::OnIdle( wxIdleEvent& event )
1885 {
1886  if ( m_triggerRestart && GetBusy() && !m_halted )
1887  {
1888  // recreate edit copies so the edit copy becomes updated from the original.
1889  wxUint16 editmode = a2dCanvasObject::PROPID_Editmode->GetPropertyValue( m_canvasobject );
1890  ReStartEdit( editmode );
1891  m_triggerRestart = false;
1892  }
1893 
1894 #ifdef EDITBUF
1895  if ( m_canvasobject )
1896  if ( m_canvasobject->GetPending() )
1897  GetDrawingPart()->AddPendingObject( m_canvasobject );
1898 #endif
1899 
1900  if ( m_original )
1901  {
1902  if ( m_pending )
1903  {
1904  //m_canvasobject->SetPending( true );
1905  //m_pending = false;
1906  }
1907  }
1908  else
1909  a2dStTool::OnIdle( event );
1910 }
1911 
1912 void a2dObjectEditTool::OnKeyDown( wxKeyEvent& event )
1913 {
1914  if ( GetBusy() )
1915  {
1916  switch( event.GetKeyCode() )
1917  {
1918  case WXK_ESCAPE:
1919  {
1920  StopTool();
1921  break;
1922  }
1923  default:
1924  event.Skip();
1925  break;
1926  }
1927  }
1928  else
1929  //all text like keys should arrive in a text object when its edited.
1930  event.Skip();
1931 }
1932 
1933 void a2dObjectEditTool::OnKeyUp( wxKeyEvent& event )
1934 {
1935  if ( GetBusy() && m_pending )
1936  {
1937  switch( event.GetKeyCode() )
1938  {
1939  case WXK_UP:
1940  case WXK_DOWN:
1941  case WXK_LEFT:
1942  case WXK_RIGHT:
1943  {
1944  a2dDrawing* drawing = GetDrawingPart()->GetDrawing();
1945  drawing->GetCommandProcessor()->Submit(
1946  new a2dCommand_SetCanvasProperty( m_original, a2dCanvasObject::PROPID_TransformMatrix,
1948 
1949  }
1950  break;
1951  default:
1952  {
1953  event.Skip();
1954  }
1955  }
1956  }
1957  else
1958  event.Skip();
1959 }
1960 
1961 void a2dObjectEditTool::OnChar( wxKeyEvent& event )
1962 {
1963  if ( GetBusy() )
1964  {
1965  switch( event.GetKeyCode() )
1966  {
1967  case WXK_TAB:
1968  {
1969  if ( event.m_shiftDown )
1970  {
1971  int mode = m_mode;
1972  SetMode( ++mode );
1973  }
1974  else if ( !m_canvasobject || !m_canvasobject->ProcessEvent( event ) ) //handover event to object.
1975  event.Skip();
1976  }
1977  break;
1978  default:
1979  {
1980  bool processed = false;
1981  if( m_canvasobject )
1982  processed = m_canvasobject->ProcessEvent( event ); //handover event to object.
1983 
1984  if ( !processed && m_canvasobject )
1985  {
1986  if ( m_canvasobject->IsDraggable() )
1987  {
1988  double shiftx;
1989  double shifty;
1990  GetKeyIncrement( &shiftx, &shifty );
1991 
1992  //now shift with snap distances in X or Y
1993 
1994  switch( event.GetKeyCode() )
1995  {
1996  case WXK_UP:
1997  shiftx = 0;
1998  break;
1999 
2000  case WXK_DOWN:
2001  shiftx = 0;
2002  shifty = -shifty;
2003  break;
2004 
2005  case WXK_LEFT:
2006  shiftx = -shiftx;
2007  shifty = 0;
2008  break;
2009 
2010  case WXK_RIGHT:
2011  shifty = 0;
2012  break;
2013  default:
2014  {
2015  shiftx = 0;
2016  shifty = 0;
2017  event.Skip();
2018  }
2019  }
2020 
2021  m_canvasobject->Translate( shiftx, shifty );
2022  event.Skip( false );
2023  m_pending = true;
2024  }
2025  else
2026  event.Skip( false );
2027  }
2028  if( !m_canvasobject )
2029  event.Skip();
2030  }
2031  }
2032 
2033  if( m_canvasobject )
2034  {
2036  GetDrawing()->GetHabitat()->GetConnectionGenerator()->RerouteWires( false );
2037  }
2038  }
2039  else
2040  event.Skip();
2041 }
2042 
2043 void a2dObjectEditTool::OnComEvent( a2dComEvent& event )
2044 {
2045  if ( GetBusy() )
2046  {
2047  if ( event.GetId() == a2dStTool::sig_toolBeforePush )
2048  {
2049  // If tool is busy, it will enter halted state
2050  if ( GetBusy() && !m_halted )
2051  {
2052  m_halted = true;
2054  }
2055  m_pending = true;
2056  }
2057  else if ( GetDrawingPart() && event.GetId() == a2dDrawingPart::sig_changedShowObject )
2058  {
2059  if ( event.GetEventObject() == GetDrawingPart() )
2060  {
2061  StopTool();
2062  }
2063  }
2064  else
2065  event.Skip();
2066  }
2067 
2068  event.Skip();
2069 }
2070 
2071 void a2dObjectEditTool::SetActive( bool active )
2072 {
2073  if ( active )
2074  {
2075  if ( m_halted )
2076  {
2077  m_halted = false;
2078  //RESTART editing so the edit copy becomes updated from the original.
2079  //original may have changed because of sub-editing of child objects.
2081  m_active = true;
2082  }
2083  m_pending = true;
2084  a2dBaseTool::SetActive( active );
2085  }
2086  else
2087  {
2088  //the subedit or other subtools should not influence style of the object.
2089  //When this tool is activated again, the CurrentCanvasObject is set right again.
2090  SetEditObject( NULL );
2091 
2092  m_pending = true;
2093  a2dBaseTool::SetActive( active );
2094  }
2095 }
2096 
2097 void a2dObjectEditTool::OnUndoEvent( a2dCommandProcessorEvent& event )
2098 {
2099  if ( GetBusy() && !m_halted )
2100  {
2101  if ( event.GetCommand()->GetCommandId() == &a2dCommand_ChangeText::Id )
2102  {
2104  if ( cmd )
2105  {
2106  a2dText* textorg = cmd->GetTextObject();
2107  a2dText* textcopy = wxStaticCast( m_canvasobject.Get(), a2dText );
2108  textcopy->SetText( textorg->GetText() );
2109  textcopy->SetCaret( textorg->GetCaret() );
2110  }
2111  }
2112  else
2113  {
2114  if ( m_canvasobject ) //dlg editing does not create editcopies
2115  {
2116  // recreate edit copies so the edit copy becomes updated from the original.
2117  wxUint16 editmode = a2dCanvasObject::PROPID_Editmode->GetPropertyValue( m_canvasobject );
2118  TriggerReStartEdit( editmode );
2119  }
2120  }
2121  }
2122  event.Skip();
2123 }
2124 
2125 void a2dObjectEditTool::OnRedoEvent( a2dCommandProcessorEvent& event )
2126 {
2127  OnUndoEvent( event );
2128  event.Skip();
2129 }
2130 
2131 void a2dObjectEditTool::OnDoEvent( a2dCommandProcessorEvent& event )
2132 {
2133  const a2dCommandId* comId = event.GetCommand()->GetCommandId();
2134  if ( GetBusy() )
2135  {
2136  if ( ( comId == &a2dCommand_ChangeText::Id ) && wxDynamicCast( m_original.Get(), a2dText ) )
2137  {
2138  a2dText* text = wxDynamicCast( m_original.Get(), a2dText );
2139  if ( text )
2140  {
2141  //WHY text->SetFont( GetDrawing()->GetHabitat()->GetTextTemplateObject()->GetFont() );
2142  //WHY a2dText* texteditobj = wxDynamicCast( m_canvasobject.Get(), a2dText );
2143  //WHY texteditobj->SetFont( GetDrawing()->GetHabitat()->GetTextTemplateObject()->GetFont() );
2144  }
2145  }
2146  /* a COMMAND WHICH CHANGES CENTRAL STORED THINGS IN GetDrawing()->GetHabitat(), MAY CHANGE EDIT OBJECT ITS STYLE LIKE DOWN HERE.
2147  But not any commands should lead to changes (e.g. fixed style objects should not change ).
2148 
2149  if ( wxDynamicCast( m_original.Get(), a2dPolylineL ) )
2150  {
2151  a2dPolylineL* poly = wxDynamicCast( m_original.Get(), a2dPolylineL );
2152  if ( poly )
2153  {
2154  if ( poly->GetSpline() != GetDrawing()->GetHabitat()->GetSpline() )
2155  poly->SetSpline( GetDrawing()->GetHabitat()->GetSpline() );
2156  if ( poly->GetBegin() != GetDrawing()->GetHabitat()->GetLineBegin() )
2157  poly->SetBegin( GetDrawing()->GetHabitat()->GetLineBegin() );
2158  if ( poly->GetEnd() != GetDrawing()->GetHabitat()->GetLineEnd() )
2159  poly->SetEnd( GetDrawing()->GetHabitat()->GetLineEnd() );
2160  if ( poly->GetEndScaleX() != GetDrawing()->GetHabitat()->GetEndScaleX() )
2161  poly->SetEndScaleX( GetDrawing()->GetHabitat()->GetEndScaleX() );
2162  if ( poly->GetEndScaleY() != GetDrawing()->GetHabitat()->GetEndScaleY() )
2163  poly->SetEndScaleY( GetDrawing()->GetHabitat()->GetEndScaleY() );
2164  }
2165  }
2166  if ( wxDynamicCast( m_original.Get(), a2dEndsLine ) )
2167  {
2168  a2dEndsLine* line = wxDynamicCast( m_original.Get(), a2dEndsLine );
2169  if ( line )
2170  {
2171  if ( line->GetBegin() != GetDrawing()->GetHabitat()->GetLineBegin() )
2172  line->SetBegin( GetDrawing()->GetHabitat()->GetLineBegin() );
2173  if ( line->GetEnd() != GetDrawing()->GetHabitat()->GetLineEnd() )
2174  line->SetEnd( GetDrawing()->GetHabitat()->GetLineEnd() );
2175  if ( line->GetEndScaleX() != GetDrawing()->GetHabitat()->GetEndScaleX() )
2176  line->SetEndScaleX( GetDrawing()->GetHabitat()->GetEndScaleX() );
2177  if ( line->GetEndScaleY() != GetDrawing()->GetHabitat()->GetEndScaleY() )
2178  line->SetEndScaleY( GetDrawing()->GetHabitat()->GetEndScaleY() );
2179  }
2180  }
2181  if ( m_original && m_original->GetContourWidth() != GetDrawing()->GetHabitat()->GetContourWidthInDataBaseUnits() )
2182  {
2183  m_contourwidth = GetDrawing()->GetHabitat()->GetContourWidthInDataBaseUnits();
2184  m_canvasobject->SetContourWidth( m_contourwidth );
2185  m_original->SetContourWidth( m_contourwidth );
2186  }
2187  a2dPolylineL* poly = wxDynamicCast( m_original.Get(), a2dPolylineL );
2188  if ( poly && poly->GetPathType() != GetDrawing()->GetHabitat()->GetPathType() )
2189  poly->SetPathType( GetDrawing()->GetHabitat()->GetPathType() );
2190  a2dSLine* line = wxDynamicCast( m_canvasobject.Get(), a2dSLine );
2191  if ( line && line->GetPathType() != GetDrawing()->GetHabitat()->GetPathType() )
2192  line->SetPathType( GetDrawing()->GetHabitat()->GetPathType() );
2193 
2194  */
2195  }
2196  event.Skip();
2197 }
2198 
2199 
2200 
2201 
2202 
2203 
static const a2dCanvasObjectFlagsMask SELECTED2
Definition: candefs.h:181
bool m_renderEditcopy
if yes, the editcopy is rendered in place
Definition: sttool.h:400
wxPoint2DDouble a2dPoint2D
this to define if coordinate numbers are integer or doubles
Definition: artglob.h:47
void OnHandleEvent(a2dHandleMouseEvent &event)
called if a mouse event occured on a child object, that is a handle
Definition: canobj.cpp:2061
double GetHeight() const
returns height of the boundingbox
Definition: bbox.cpp:334
virtual bool Undo()=0
Override this to undo a command.
void DoStopTool(bool abort)
To stop this tools from inside or from the outside, sets m_stop = true.
Definition: edit.cpp:1005
a2dCanvasObjectPtr m_canvasobject
This is the object currently edited.
Definition: sttool.h:381
virtual void CleanupToolObjects()
stop editing of m_canvasobject if busy editing
Definition: edit.cpp:1795
#define wxDynamicCast(obj, className)
Define wxDynamicCast so that it will give a compiler error for unrelated types.
Definition: gen.h:75
virtual a2dCanvasObject * StartEdit(a2dBaseTool *tool, wxUint16 editmode, wxEditStyle editstyle=wxEDITSTYLE_COPY, a2dRefMap *refs=NULL)
create an editcopy and initialize editing of the editcopy
Definition: edit.cpp:930
Base class for all types of strokes, understood by a2dDrawer2D classes.
Definition: stylebase.h:378
a2dCanvasObjectPtr m_parentobject
( if needed ) parent a2dCanvasObject relative to which the tool actions take place.
Definition: tools.h:854
bool m_renderEditcopyEdit
if yes, the editcopy is rendered on top in edit style
Definition: sttool.h:404
bool m_pending
set when tool needs an redraw (after a a2dCanvas Repaint etc.)
Definition: tools.h:814
void OnMouseEvent(wxMouseEvent &event)
Definition: edit.cpp:60
a2dHandle is used inside editing versions of a certain objects.
Definition: canpin.h:30
a2dCanvasCommandProcessor * GetCanvasCommandProcessor()
Returns a pointer to the command processor associated with this document.
Definition: tools.cpp:976
bool GetEditable() const
get if the object may be edited
Definition: canobj.h:1584
The a2dBaseTool is used to derive tools from that are controlled by.
Definition: tools.h:379
mouse event sent from a2dCanvasObject to itself
Definition: canglob.h:223
void SetDrawStyle(a2dDrawStyle drawstyle)
set drawstyle to use for drawing,
Definition: drawer2d.cpp:557
const a2dAffineMatrix & GetTransformMatrix() const
get the matrix used to position the object
Definition: canobj.h:500
wxCursor m_toolcursor
cursor to use
Definition: tools.h:768
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: canobj.cpp:1426
bool m_editing
true if the object is currently being edited
Definition: candefs.h:301
if set, set in the clone the PROPID_Original property to the copied object
Definition: gen.h:1212
void OnCanvasObjectMouseEvent(a2dCanvasObjectMouseEvent &event)
default handler for mouse events, sent to the object from the a2dDrawingPart.
Definition: canobj.cpp:2391
void GetKeyIncrement(double *xIncr, double *yIncr)
get the increments used when moving is done with cursor keys
Definition: sttool.cpp:1316
class to map references to objects stored in XML, in order to make the connection later on...
Definition: gen.h:3462
virtual a2dCanvasObject * StartEdit(a2dBaseTool *tool, wxUint16 editmode, wxEditStyle editstyle=wxEDITSTYLE_COPY, a2dRefMap *refs=NULL)
create an editcopy and initialize editing of the editcopy
Definition: canobj.cpp:1640
a2dDrawing * m_root
root group for rendering and accessing the canvas&#39;s also contains layer settings
Definition: canobj.h:2525
bool GetSelectionStateUndo() const
set if selection state of tools object is set during undo.
Definition: sttool.h:682
a2dCanvasOFlags m_flags
holds flags for objects
Definition: canobj.h:2528
a2dCommand * GetCommand()
the command ( if there was one ) that did it.
Definition: comevt.h:759
virtual bool Do()=0
Override this to perform a command.
virtual void AbortBusyMode()
Called when the user aborts editing a distinct object */.
Definition: edit.cpp:1578
const a2dAffineMatrix & GetInverseTransform() const
Inverse of GetTransform()
Definition: canobj.cpp:699
virtual bool AdjustPinLocation()
Allow change in pin location when wiring things up.
Definition: canobj.h:2058
int m_x
x of mouse in device
Definition: sttool.h:352
void SetSelected2(bool selected)
Set the object selected2 flag if allowed.
Definition: canobj.h:1639
a2dCanvasObjectPtr m_original
This is the original object selected for editing.
Definition: sttool.h:388
Ref Counted base object.
Definition: gen.h:1045
bool GetPending() const
is this object pending for update?
Definition: canobj.h:1162
void SetTransformMatrix(const a2dAffineMatrix &mat=a2dIDENTITY_MATRIX)
Returns the matrix used to position the object.
Definition: canobj.h:509
bool Rotate(double angle)
Rotate clockwise by the given number of degrees:
Definition: afmatrix.cpp:432
wxPoint GetMousePosition()
return mouse position in device coordinates
Definition: sttool.h:631
void SetMode(int mode)
set editing mode to start editing objects
Definition: edit.cpp:1502
The a2dStTool is used to derive tools from.
Definition: sttool.h:115
#define EVT_DO(func)
event sent from a2DocumentCommandProcessor when a command is initially done
Definition: comevt.h:795
a2dCanvasObject * GetCaptured() const
are events redirected to a captured corridor? if so return the captured object in it...
Definition: drawer.h:641
double GetBboxMinY()
get minimum Y of the boundingbox in world coordinates relative to its parents
Definition: canobj.h:682
bool ReStartEdit(wxUint16 editmode)
restart editing (after undo event or when changing editing mode )
Definition: edit.cpp:1710
a2dDrawingPart * GetDrawingPart()
Access to the tool controllers drawer.
Definition: tools.h:632
wxUint16 GetHitMarginDevice() const
hit marging in pixels.
Definition: canglob.h:609
virtual bool Update(UpdateMode mode)
Update the state of the object according to its current position etc.
Definition: canobj.cpp:5149
virtual bool RestrictCanvasObjectAtVertexes(a2dCanvasObject *object, a2dPoint2D &point, double &dx, double &dy, wxUint32 sourceRequired=snapToAll, bool ignoreEngine=false)
return the clossest vertex which can be snapped if any.
Definition: restrict.cpp:685
void ConnectEvent(wxEventType type, wxEvtHandler *eventSink)
Definition: gen.cpp:876
#define EVT_CANVASHANDLE_MOUSE_EVENT(func)
static event table macro for a2dHandle mouse event
Definition: canglob.h:318
virtual bool EnterBusyMode()
starts a new action (e.g drawing something ) in a tool that is already pushed.
Definition: edit.cpp:1564
a2dOpaqueMode m_useEditOpaque
when true editcopies are using a half transparent cloned style.
Definition: sttool.h:415
void DoStopTool(bool abort)
To stop this tools from inside or from the outside, sets m_stop = true.
Definition: edit.cpp:1513
a2dStToolContr * m_stcontroller
controller for canvas
Definition: sttool.h:391
a2dDrawing * GetDrawing()
Returns a pointer to the drawing.
Definition: tools.cpp:969
void Update(unsigned int how=(a2dCANVIEW_UPDATE_ALL|a2dCANVIEW_UPDATE_BLIT), wxObject *hintObject=NULL)
see OnUpdate
Definition: drawer.cpp:1744
a command processor specially designed to work with a a2dCanvasDocument
Definition: drawing.h:1046
virtual void SetPending(bool pending)
set this object pending for update
Definition: canobj.cpp:2585
#define EVT_REDO(func)
event sent from a2DocumentCommandProcessor when a command is redone
Definition: comevt.h:799
OVERLAP
Result of a a2dBoundingBox intersection or hittest.
Definition: bbox.h:24
void OnCanvasObjectMouseEvent(a2dCanvasObjectMouseEvent &event)
Definition: edit.cpp:776
bool m_active
tool is operational
Definition: tools.h:777
a2dToolContr * GetToolController()
to get the tool controller to which this tool is attached.
Definition: tools.h:627
double m_ywprev
y world coordinates old or new value of mouse
Definition: sttool.h:366
void SetDocumentDrawStyle(wxUint32 drawstyle)
set drawstyles to use for drawing the document
Definition: drawer.cpp:1016
wxUint8 GetOpacityFactorEditcopy()
see SetOpacityFactorEditcopy()
Definition: sttool.h:658
void OnIdle(wxIdleEvent &event)
handler for idle events
Definition: sttool.cpp:1370
virtual void FinishBusyMode(bool closeCommandGroup=true)
Called when the user finishes editing a distinct object */.
Definition: sttool.cpp:1161
double GetBboxMinX()
get minimum X of the boundingbox in world coordinates relative to its parents
Definition: canobj.h:676
bool GetFlag(const a2dCanvasObjectFlagsMask which) const
get specific bitflag value
Definition: canobj.cpp:2655
a2dCanvasObject is the base class for Canvas Objects.
Definition: canobj.h:371
used to add object to a a2dCanvasDocument in the current parent
Definition: edit.cpp:246
draw a rectangle the size of the bounding box of the object draged.
Definition: sttool.h:79
void SetFixedStyleStroke(const a2dStroke &fixStroke)
set a2dStroke to use when RenderFIX_STYLE is set.
Definition: drawer.h:845
bool m_renderEditcopyOnTop
if yes, the editcopy is rendered on top in usual style
Definition: sttool.h:402
a2dCanvas * GetCanvas() const
Get the Display window of the a2dView. But casted to a a2dCanvas.
Definition: drawer.h:525
virtual a2dObject * GetRefObject() const
when a2dProperty, return its value else assert
Definition: gen.cpp:1976
void ReStartEdit(wxUint16 editmode)
to restart editing in a different mode
Definition: canobj.cpp:1693
a2dCanvasObjectList * GetChildObjectList()
get the list where the child objects are stored in.
Definition: canobj.cpp:2551
void TransformPoint(double x, double y, double &tx, double &ty) const
Transform a point.
Definition: afmatrix.cpp:559
void SetActive(bool active)
used extarnal by controller to activate or deactivate this tool.
Definition: edit.cpp:2071
double GetRotation() const
return rotation
Definition: afmatrix.cpp:799
wxString GetName() const
get the name given to the handle.
Definition: canpin.h:56
virtual void EndEdit()
cleanup an editcopy object
Definition: canobj.cpp:1828
static const a2dSignal sig_toolComEventSetEditObject
Definition: sttool.h:124
bool GetSelected() const
is the object selected flag set
Definition: canobj.h:1603
return to contain edit bbox, suitable for editing matrix of object
Definition: canobj.h:666
void SetSelected(bool selected)
Set the object selected flag if allowed.
Definition: canobj.h:1620
double GetBboxWidth()
get width of the boundingbox in world coordinates relative to its parents
Definition: canobj.h:700
bool m_renderEditcopyRectangle
if yes, the editcopy is rendered on top as bounding box rectangle
Definition: sttool.h:406
virtual void AdjustRenderOptions()
Adjust the rendering options to the needs of this tool.
Definition: edit.cpp:1531
bool ProcessEvent(wxEvent &event)
events recieved from controller processed here
Definition: tools.cpp:668
static const a2dCommandId Id
used to release object from a a2dCanvasDocument in the current parent
Definition: edit.cpp:283
int ReleaseChild(a2dCanvasObject *obj, bool backwards=false, bool all=false, bool now=false, bool undoCommands=false)
remove the given object from the childobjects
Definition: canobj.cpp:6260
static a2dPropertyIdBool * PROPID_FirstEventInObject
set in Startedit(), to be used to detect first (mouse)event sent to object.
Definition: canobj.h:2694
virtual void FinishBusyMode(bool closeCommandGroup=true)
Called when the user finishes editing a distinct object */.
Definition: edit.cpp:1569
bool RedirectToEditObject(wxMouseEvent &event)
redirect event to editng object or to a captured object ( handle or object itself. )
Definition: edit.cpp:1649
a2dAffineMatrix m_lworld
used for positioning the object (x,y,ang,scale etc.)
Definition: canobj.h:2559
static a2dPropertyIdRefObject * PROPID_ViewSpecific
Definition: canobj.h:2691
bool Do()
Override this to perform a command.
Definition: edit.cpp:318
const a2dAffineMatrix & GetInverseTransform() const
Inverse of GetTransform()
Definition: objlist.h:344
~a2dMultiSelectGroup()
destructor
Definition: edit.cpp:381
bool Undo()
Override this to undo a command.
Definition: edit.cpp:324
wxMouseEvent & GetMouseEvent()
return the original mouse event that was redirected to the a2dHandle
Definition: canglob.h:290
~a2dRecursiveEditTool()
destuctor
Definition: edit.cpp:56
a2dCommandGroup * GetCurrentGroup() const
return current group
Definition: comevt.h:928
a2dDrawer2D * GetDrawer2D()
Access to the tool controllers drawers drawer2d.
Definition: tools.cpp:959
a2dText is an abstract base class.
Definition: cantext.h:93
used to change a property on objects
Definition: drawing.h:2244
a2dObjectEditTool(a2dStToolContr *controller, int editmode=1, bool SingleClickToEnd=true)
constructor
Definition: edit.cpp:1402
double DeviceToWorldY(double y) const
convert y from device to world coordinates
Definition: drawer2d.h:439
static const a2dCanvasObjectFlagsMask HighLight
Definition: candefs.h:210
virtual a2dBoundingBox GetUnTransformedBbox(a2dBboxFlags flags=a2dCANOBJ_BBOX_CHILDREN) const
Get boundingbox without the affine matrix transform included.
Definition: canobj.cpp:5036
double GetMinX() const
get minimum X of the boundingbox
Definition: bbox.cpp:304
a2dCanvasObjectList * m_childobjects
holds child objects
Definition: canobj.h:2562
a2dCommandGroup * GetCommandgroup()
return the command group that is open else NULL.
Definition: tools.h:664
static const a2dSignal sig_changedShowObject
Definition: drawer.h:1513
void Transform(const a2dAffineMatrix &tworld)
transform the object using the given matrix
Definition: canobj.h:577
#define forEachIn(listtype, list)
easy iteration for a2dlist
Definition: a2dlist.h:111
The a2dStToolContr is a Tool Controller specialized for working with a2dCanvasView.
Definition: sttool.h:485
void SetPropertyToObject(a2dObject *obj, const basetype &value, SetFlags setflags=set_none) const
Set the property in obj to value.
Definition: id.inl:238
virtual void DoStopTool(bool abort)
to do tool specific stuff to stop a tool. Called from StopTool().
Definition: tools.cpp:796
a2dHandle * GetHandle()
get default handle for editing
Definition: canglob.cpp:740
double GetPosX() const
get x position from affine matrix
Definition: canobj.h:527
bool StartEditing(a2dCanvasObject *startobject)
start editing object
Definition: edit.cpp:1202
#define EVT_COM_EVENT(func)
static wxEvtHandler for communication event
Definition: gen.h:564
void SetFixedStyleFill(const a2dFill &fixFill)
set a2dFill to use when RenderFIX_STYLE is set.
Definition: drawer.h:842
void SkewY(double angle)
Skew in Y.
Definition: canobj.cpp:2627
static const a2dSignal sig_toolStartEditObject
when starting editing an object, this event is sent to tool
Definition: edit.h:83
const a2dCommandId * GetCommandId()
a specific id for this command.
Definition: comevt.h:179
wxCursor m_toolBusyCursor
cursor to use when the tool is busy doing something.
Definition: tools.h:771
a2dRecursiveEditTool holds multiple edit object in here
Definition: edit.cpp:371
const a2dError a2dError_canvasObjectRelease
a2dDrawer2D * GetDrawer2D() const
get current a2dDrawer2D
Definition: canobj.cpp:636
#define wxStaticCast(obj, className)
The wxWindows 2.4.2 wxStaticCast is buggy. It evaluates its argument twice.
Definition: gen.h:123
void SetCorridorPathCaptureObject(a2dCanvasObject *captureObject)
Definition: canobj.cpp:799
bool m_editable
object can be edited
Definition: candefs.h:295
static const a2dCommandId Id
used to add object to a a2dCanvasDocument in the current parent
Definition: edit.cpp:253
bool m_oneshot
do it only once
Definition: tools.h:817
double wxRadToDeg(double rad)
conversion from radians to degrees
Definition: artglob.cpp:31
void SkewX(double angle)
Skew in X.
Definition: canobj.cpp:2621
void SetSpecificFlags(bool setOrClear, a2dCanvasObjectFlagsMask which)
set all bit flags in object that or true in mask to true or false
Definition: canobj.cpp:2645
#define EVT_CANVASOBJECT_MOUSE_EVENT(func)
static event table macro for a2dCanvasObject mouse event
Definition: canglob.h:312
void SetMouseEvents(bool onoff)
If not set do not process mouse events.
Definition: drawer.cpp:1081
bool m_SingleClickToEnd
a single non hit Left Down click is enough to end editing of an object.
Definition: edit.h:204
DRAGMODE GetDragMode()
Returns drag mode.
Definition: sttool.h:567
void SetPerLayerMode(bool value)
if set the rendering is done layers by layer from the top
Definition: canobj.h:3427
A2DGENERALDLLEXP a2dSmrtPtr< a2dGeneralGlobal > a2dGeneralGlobals
a global pointer to get to global instance of important classes.
Definition: comevt.cpp:1148
void SetActive(bool active)
used extarnal by controller to activate or deactivate this tool.
Definition: edit.cpp:1307
int m_mode
general operation mode setting for a tool.
Definition: tools.h:845
void Translate(double x, double y)
relative translate the object to position x,y in world coordinates
Definition: canobj.h:569
general event sent from a2dHandle to its parent a2dCanvasObject
Definition: canglob.h:273
Restriction engine for editing restrictions like snapping.
Definition: restrict.h:88
a2dMultiSelectGroup()
constructor
Definition: edit.cpp:413
a2dDrawer2D * GetDrawer2D()
get the internal m_drawer2D that is used for rendering the document
Definition: drawer.h:1125
This tool does do a hit test on objects to edit, and then starts editing the object.
Definition: edit.h:226
if set, respect layer order, hit testing is done per layer from the top.
Definition: canobj.h:82
static const a2dCanvasObjectFlagsMask SELECTED
Definition: candefs.h:180
a2dToolContr * m_controller
under control of this toolcontroller, to give me events.
Definition: tools.h:774
a2dHandle * GetCanvasHandle()
return the handle object hit
Definition: canglob.h:287
static const a2dCanvasObjectFlagsMask Editing
Definition: candefs.h:206
virtual bool CreateToolObjects()
start editing at m_canvasobject
Definition: edit.cpp:1733
a2dCorridor m_corridor
Definition: tools.h:795
This tool is for editing a single object.
Definition: edit.h:73
Each a2dCommand is given a command id at construction.
Definition: comevt.h:99
virtual bool Submit(a2dCommand *command, bool storeIt=true)
next to the base class submit, it sets a2DocumentCommandProcessor for a2dCommand
Definition: comevt.cpp:842
corridor as a direct event path to a a2dCanvasObject
Definition: objlist.h:313
a2dCanvasObject * ChildIsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent, bool filterSelectableLayers=false)
Do hittest on children.
Definition: canobj.cpp:3289
void SetVisible(bool visible)
set if this object will visible (be rendered or not)
Definition: canobj.h:1303
virtual bool DoStartEdit(wxUint16 editmode, wxEditStyle editstyle)
only used for editable objects and under control of a editing tool.
Definition: canobj.cpp:1739
void SetSnapTo(bool snap)
Sets snap_to flag.
Definition: canobj.h:1704
A 2x3 affine matrix class for 2D transformations.
Definition: afmatrix.h:53
wxMouseEvent & GetMouseEvent()
return the original mouse event that was redirected to the a2dCanvasObject
Definition: canglob.h:243
double m_xwprev
x world coordinates old or new value of mouse
Definition: sttool.h:363
double GetMaxX() const
get maximum X of the boundingbox
Definition: bbox.cpp:316
void CleanupToolObjects()
stop editing of m_canvasobject if busy editing
Definition: edit.cpp:1244
bool DoConnect()
if return true, connection with other object on this object its pins is allowed.
Definition: canobj.h:1845
if set, set in the clone the PROPID_editcopy property to the original object
Definition: gen.h:1215
double GetPosY() const
get y position from affine matrix
Definition: canobj.h:530
bool m_stop
stop the tool
Definition: tools.h:820
object stay in document and it is redrawn while dragging, and so are all objects above and below it...
Definition: sttool.h:83
virtual void AbortBusyMode()
Called when the user aborts editing a distinct object */.
Definition: sttool.cpp:1178
void Render()
implement rendering
Definition: edit.cpp:1837
while iterating a a2dCanvasDocument, this holds the context.
Definition: canobj.h:3212
bool m_halted
if a tool is deactivated while m_busy is true, this flag is set
Definition: tools.h:810
All updates of these modes force an update (e.g. update non-pending valid bounding boxes) ...
Definition: canobj.h:1107
bool GetUseOpaqueEditcopy()
see SetUseOpaqueEditcopy()
Definition: sttool.h:669
a2dCommandProcessor * GetCommandProcessor() const
Returns a pointer to the command processor associated with this document.
Definition: drawing.h:549
a2dConnectionGenerator * GetConnectionGenerator() const
Get class for generating new connection objects between object and pins.
Definition: canglob.h:601
virtual bool Submit(a2dCommand *command, bool storeIt=true)
Definition: drawing.cpp:5966
bool ClearCommandsById(const a2dCommandId &commandId, a2dCommand *fromcommand=NULL)
erase commands with a certain id, starting at fromcommand
Definition: comevt.cpp:291
void Scale(double scalex, double scaley)
Scale in x and y ( &gt; zero)
Definition: canobj.cpp:2633
a2dRecursiveEditTool(a2dStToolContr *controller, int editmode=1, bool SingleClickToEnd=true)
constructor
Definition: edit.cpp:50
bool Do()
Override this to perform a command.
Definition: edit.cpp:346
int m_y
y of mouse in device
Definition: sttool.h:354
void SetCorridor(const a2dCorridor &corridor)
set a corridor from a list of objects
Definition: tools.cpp:900
a2dRestrictionEngine * GetRestrictionEngine()
Get restriction engine (grid snapping)
Definition: canglob.cpp:934
static const a2dSignal sig_toolBeforePush
Definition: tools.h:389
void SetText(const wxString &text)
set the text for the object &#39; &#39; in string means new line
Definition: cantext.h:165
double GetUnitsScale()
this is the number that defines the physical dimension in meters / inch/ etc.
Definition: drawing.h:676
bool m_preserve_select
preserve the a2dCANVAS_SELECT flag after editing.
Definition: edit.h:201
void AddEditobject(a2dCanvasObject *object)
Add an editcopy object to the tool/document.
Definition: tools.cpp:916
editing tool for a2dCanvasObject&#39;s
double DeviceToWorldX(double x) const
convert x from device to world coordinates
Definition: drawer2d.h:437
virtual void CleanupToolObjects()
Cleanup the editcopy other tool objects (e.g. decorations)
Definition: sttool.cpp:1265
virtual void UpdateCrossHair(int x, int y)
blit old areas to remove last drawn crosshair and draw the cross hair at this new position...
Definition: drawer.cpp:3361
bool IsDraggable() const
get if the object can be dragged
Definition: canobj.h:1683
double GetMaxY() const
get maximum Y of the boundingbox
Definition: bbox.cpp:322
double GetWidth() const
returns width of the boundingbox
Definition: bbox.cpp:328
a2dCanvasObject * GetParentObject()
parent object relative to which the actions take place.
Definition: tools.h:684
An object of this class will update a a2dIterC with the required information.
Definition: canobj.h:3123
int GetCaret() const
Get position of caret (-1 means off)
Definition: cantext.h:257
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: edit.cpp:423
return to contain children bbox
Definition: canobj.h:667
void SetPosXY(double x, double y, bool restrict=false)
set position to x,y
Definition: canobj.cpp:1624
a2dCanvasObject * IsHitWorld(double x, double y, int layer=wxLAYER_ALL, a2dHitOption option=a2dCANOBJHITOPTION_NONE, bool filterSelectableLayers=false)
do a hittest on the view at coordinates x,y
Definition: drawer.cpp:1565
double GetBboxHeight()
get height of the boundingbox in world coordinates relative to its parents
Definition: canobj.h:706
wxUint8 m_editOpacityFactor
when using cloned style for editcopy, use this opacity.
Definition: sttool.h:412
bool m_editingCopy
true if the object needs to be rendered in edit mode.
Definition: candefs.h:304
Event sent to a2dCommandProcessor.
Definition: comevt.h:701
This tool does do a hit test on objects to edit, and then starts editing the object.
Definition: edit.h:286
see a2dComEvent
Definition: gen.h:371
virtual bool ProcessCanvasObjectEvent(wxEvent &event, bool &isHit, double x, double y, int margin, int layer=wxLAYER_ALL)
Corridor and captured object event processing.
Definition: drawer.cpp:1304
bool Undo()
Override this to undo a command.
Definition: edit.cpp:356
bool GetVisible() const
get visibility (rendering depends on layer settings also)
Definition: canobj.h:1309
bool SetContext(a2dIterC &ic, a2dCanvasObject *startObject)
start editing object within the given iteration context its coordinate system
Definition: edit.cpp:1432
~a2dObjectEditTool()
destuctor
Definition: edit.cpp:1481
a2dCanvasObject * IsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent)
If the position (x,y) is within the object return this.
Definition: canobj.cpp:3415
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
Definition: bbox.h:39
bool Invert(void)
Invert matrix.
Definition: afmatrix.cpp:197
virtual void TriggerReStartEdit(wxUint16 editmode)
trigger restart editing (after undo event or when changing editing mode )
Definition: edit.cpp:1879
a2dCanvasObjectList * Clone(a2dObject::CloneOptions options) const
Clone everything ( Clones objects also) in a new created list.
Definition: objlist.cpp:173
double GetMinY() const
get minimum Y of the boundingbox
Definition: bbox.cpp:310
const a2dToolList & GetToolList() const
return reference to tool list
Definition: tools.h:130
a2dDrawing * GetDrawing() const
get drawing via top object
Definition: drawer.cpp:726
bool AddPendingUpdatesOldNew()
adds current and future boundingbox of the objects with pending flag set, to the pendinglist of all a...
Definition: drawing.cpp:525
virtual bool EnterBusyMode()
starts a new action (e.g drawing something ) in a tool that is already pushed.
Definition: sttool.cpp:1147
void SetCaret(int position)
set position of caret (-1 means off)
Definition: cantext.h:254
basetype GetPropertyValue(const a2dObject *obj) const
Get the property value in obj.
Definition: id.inl:325
a2dCanvasGlobal * a2dCanvasGlobals
global a2dCanvasGlobal to have easy access to global settings
Definition: canglob.cpp:1234
all headers of the canvas module
#define EVT_UNDO(func)
event sent from a2DocumentCommandProcessor when a command is undone
Definition: comevt.h:797
virtual bool StartEditingObject(a2dCanvasObject *objectToEdit)
start editing object using existing corridor to object
Definition: tools.cpp:425
The a2dToolContr is the base class for Tool controller classes.
Definition: tools.h:87
void MouseToToolWorld(int x, int y, double &xWorldLocal, double &yWorldLocal)
calculate world coordinates from devide coordinates
Definition: sttool.cpp:1622
used to release object from a a2dCanvasDocument in the current parent
Definition: edit.cpp:276
a2dDrawingPart * GetDrawingPart() const
get current a2dDrawingPart
Definition: canobj.cpp:631
bool GetBusy()
Check if the tool is busy editing a distinct object */.
Definition: tools.h:513
virtual void RenderChildObjects(a2dIterC &ic, RenderChild &whichchilds, OVERLAP clipparent)
render only the child objects
Definition: canobj.cpp:5951
virtual void RenderTopObject(wxUint32 documentDrawStyle, wxUint8 id)
does render the top object in the given style.
Definition: drawer.cpp:2306
a2dCanvasObject * Find(const wxString &objectname, const wxString &classname=wxT(""), a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL, const a2dPropertyId *propid=NULL, const wxString &valueAsString=wxT(""), wxUint32 id=0) const
return the object which fits the filter.
Definition: canobj.cpp:4505
void Append(a2dCanvasObject *obj)
append a a2dCanvasObject to the childobjects
Definition: canobj.cpp:6224
virtual void SetActive(bool active=true)
set the tool active or inactive.
Definition: tools.cpp:648
bool m_renderOriginal
if yes, the original object is rendered in place
Definition: sttool.h:397
used to change text and caret of canvas text objects in a a2dCanvasDocument
Definition: drawing.h:2167
wxString GetText() const
get the text of the object &#39; &#39; in string means new line
Definition: cantext.h:168
void SetOpacityFactor(wxUint8 OpacityFactor)
when enabling m_useOpacityFactor, this is how transparent
Definition: drawer2d.cpp:550
seperate the object from the document, and layer, so it will be draged on top of all other objects...
Definition: sttool.h:81
virtual bool IsConnect() const
return true, if this object is used to connect other object&#39;s using rubberband like structures...
Definition: canobj.h:1831
virtual bool LinkReferences(bool ignoreNonResolved=false)
link references to their destination
Definition: gen.cpp:4862
void SetRestrictPoint(double xSnap, double ySnap)
sets the point for snapping to
Definition: restrict.h:337
void StopTool(bool abort=false)
call to stop a tool, internal and external.
Definition: tools.cpp:785
edit a copy of the original object
Definition: canobj.h:132
CloneOptions
options for cloning
Definition: gen.h:1200
bool DisconnectEvent(wxEventType type, wxEvtHandler *eventSink)
Definition: gen.cpp:902
void SetEditObject(a2dCanvasObject *objectToEdit)
send an event with id sig_toolComEventSetEditObject to this tool.
Definition: edit.cpp:1493
bool GetDraggable() const
get if the object can be dragged
Definition: canobj.h:1676
void SetCorridorPath(bool OnOff, a2dCanvasObject *captureObject=NULL)
to set corridor path ( also to captured object), its a2dCanvasOFlags::IsOnCorridorPath flag is set on...
Definition: canobj.cpp:739
virtual void CloseCommandGroup()
called when ending an editing operation (e.g. mouse up)
Definition: tools.cpp:883
structure to give as parameter to member functions of a2dCanvasObject
Definition: canobj.h:252
Contain one drawing as hierarchical tree of a2dCanvasObject&#39;s.
Definition: drawing.h:434
virtual bool RestrictPoint(double &x, double &y, wxUint32 sourceRequired=snapToAll, bool ignoreEngine=false)
Restrict a single point of a line or polyline.
Definition: restrict.cpp:227
void StartToEdit(a2dCanvasObject *startObject)
start editing this object
Definition: edit.cpp:1445
const a2dFill * a2dTRANSPARENT_FILL
global a2dFill stock object for TRANSPARENT filling
wxEditStyle
Definition: canobj.h:109
a base command for the a2dCommandProcessor
Definition: comevt.h:140
edit.cpp Source File -- Sun Oct 12 2014 17:04:19 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation