wxArt2D
sttool2.cpp
1 /*! \file editor/src/sttool2.cpp
2  \author Klaas Holwerda
3 
4  Copyright: 2001-2004 (c) Klaas Holwerda
5 
6  Licence: wxWidgets Licence
7 
8  RCS-ID: $Id: sttool2.cpp,v 1.36 2009/08/20 18:59:15 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 #include "wx/canvas/sttool2.h"
23 
24 IMPLEMENT_CLASS( a2dZoomFast, a2dStTool )
25 IMPLEMENT_CLASS( a2dFastSelect, a2dStTool )
26 IMPLEMENT_CLASS( a2dFastSelect2, a2dStTool )
27 IMPLEMENT_CLASS( a2dFastDragMultiTool, a2dStTool )
28 IMPLEMENT_CLASS( a2dFastCopyMultiTool, a2dFastDragMultiTool )
29 IMPLEMENT_CLASS( a2dStDrawToolFast, a2dStDrawTool )
30 
31 const a2dCommandId a2dZoomFast::COMID_PushTool_ZoomFast( wxT( "PushTool_ZoomFast" ) );
32 const a2dCommandId a2dFastSelect::COMID_PushTool_FastSelect( wxT( "PushTool_FastSelect" ) );
33 const a2dCommandId a2dFastSelect2::COMID_PushTool_FastSelect2( wxT( "PushTool_FastDeSelect" ) );
34 const a2dCommandId a2dFastDragMultiTool::COMID_PushTool_FastDragMulti( wxT( "PushTool_FastDragMulti" ) );
35 const a2dCommandId a2dFastCopyMultiTool::COMID_PushTool_FastCopyMulti( wxT( "PushTool_FastCopyMulti" ) );
36 const a2dCommandId a2dDrawRectangleToolFast::COMID_PushTool_DrawRectangleFast( wxT( "PushTool_DrawRectangleFast" ) );
37 const a2dCommandId a2dDrawCircleToolFast::COMID_PushTool_DrawCircleFast( wxT( "PushTool_DrawCircleFast" ) );
38 const a2dCommandId a2dDrawPolygonLToolFast::COMID_PushTool_DrawPolygonLFast( wxT( "PushTool_DrawPolygonLFast" ) );
39 const a2dCommandId a2dDrawPolygonLToolFast::COMID_PushTool_DrawPolygonLFast_Splined( wxT( "PushTool_DrawPolygonLFast_Splined" ) );
40 const a2dCommandId a2dDrawPolylineLToolFast::COMID_PushTool_DrawPolylineLFast( wxT( "PushTool_DrawPolylineLFast" ) );
41 const a2dCommandId a2dDrawPolylineLToolFast::COMID_PushTool_DrawPolylineLFast_Splined( wxT( "PushTool_DrawPolylineLFast_Splined" ) );
42 
43 /********************************************************************************
44 a2dStDrawToolFast
45 ********************************************************************************/
46 
47 
48 BEGIN_EVENT_TABLE( a2dStDrawToolFast, a2dStDrawTool )
49 END_EVENT_TABLE()
50 
51 a2dStDrawToolFast::a2dStDrawToolFast( a2dStToolContr* controller ): a2dStDrawTool( controller )
52 {
53  // the base tool sets layer style using a2dBLACK_STROKE->Clone()->SetNoStroke() etc.
54  // This for debug.
55  m_stroke = a2dStroke( *wxBLACK, 0 );
56  m_fill = a2dFill( *wxRED );
57  m_AllowModifyTemplate = true;
58 }
59 
61 {
62 }
63 
65 {
67 
68  // Clone the original drag object
71  GetDrawingPart()->SetOverlayDrawStyle( RenderLAYERED );
72  if ( GetDrawingPart()->GetDrawer2D()->HasAlpha() || GetDrawingPart()->GetTrippleBuf() )
73  {
74  m_canvasobject->SetFill( a2dFill( wxColour( 66, 159, 235, 50 ) ) );
75  m_canvasobject->SetStroke( a2dStroke( wxColour( 66, 159, 235, 165 ), 2, a2dSTROKE_LONG_DASH ) );
76  }
77  else
78  {
81  //m_canvasobject->SetStroke( a2dStroke(*wxBLACK, 1, a2dSTROKE_LONG_DASH) );
82  }
83 
84  m_canvasobject->SetSelected( false );
85 
88  m_original->SetSnapTo( true );
90  m_original->SetVisible( false );
92  return true;
93 }
94 
96 {
98  GetDrawingPart()->SetOverlayDrawStyle( RenderWIREFRAME_HighLight );
99  m_original->SetVisible( true );
100 }
101 
103 {
104  if ( m_canvasobject && GetBusy() )
105  {
106  }
107 }
108 
109 /********************************************************************************
110 a2dZoomFast
111 ********************************************************************************/
112 
113 BEGIN_EVENT_TABLE( a2dZoomFast, a2dStTool )
114  EVT_CHAR( a2dZoomFast::OnChar )
115  EVT_MOUSE_EVENTS( a2dZoomFast::OnMouseEvent )
116 END_EVENT_TABLE()
117 
118 a2dZoomFast::a2dZoomFast( a2dStToolContr* controller ): a2dStTool( controller )
119 {
120  m_eventHandler = new a2dStToolFixedToolStyleEvtHandler( controller );
121 
122  m_anotate = false;
123  m_toolcursor = a2dCanvasGlobals->GetCursor( a2dCURSOR_MAGNIFIER );
124  m_toolBusyCursor = a2dCanvasGlobals->GetCursor( a2dCURSOR_CROSS );
125 
126  if ( GetDrawingPart()->GetDrawer2D()->HasAlpha() || GetDrawingPart()->GetTrippleBuf() )
127  {
128  SetFill( a2dFill( wxColour( 66, 159, 235, 50 ) ) );
129  SetStroke( a2dStroke( wxColour( 66, 159, 235, 165 ), 2, a2dSTROKE_LONG_DASH ) );
130  }
131  else
132  {
133  SetFill( *a2dTRANSPARENT_FILL );
134  SetStroke( a2dStroke( *wxBLACK, 1, a2dSTROKE_LONG_DASH ) );
135  }
136 }
137 
139  : a2dStTool( other, options, refs )
140 {
142 
143  m_anotate = other.m_anotate;
144  m_toolcursor = other.m_toolcursor;
146 
147  m_fill = other.m_fill;
148  m_stroke = other.m_stroke;
149 }
150 
151 a2dObject* a2dZoomFast::DoClone( CloneOptions options, a2dRefMap* refs ) const
152 {
153  return new a2dZoomFast( *this, options, refs );
154 }
155 
157 {
158 }
159 
161 {
162 }
163 
165 {
166  // Add old (and later new) annotation area to pending region
168 
169  a2dRect* rec = wxStaticCast( m_canvasobject.Get(), a2dRect );
170  m_anotation.Printf( _T( "w %6.3f h %6.3f" ), rec->GetWidth(), rec->GetHeight() );
171  m_xanotation = m_x;
172  m_yanotation = m_y;
173 
174  wxCoord w, h, descent, external;
175  GetTextExtent( m_anotation, &w, &h, &descent, &external );
176 
177  m_xanotation = m_x + h;
178  m_yanotation = m_y + h;
179 
181 }
182 
183 void a2dZoomFast::OnChar( wxKeyEvent& event )
184 {
185  if ( !GetBusy() )
186  {
187  switch( event.GetKeyCode() )
188  {
189  case WXK_RETURN:
190  {
192  }
193  break;
194  case WXK_SUBTRACT:
195  {
197  }
198  break;
199  default:
200  event.Skip();
201  }
202  }
203  else
204  event.Skip();
205 }
206 
207 void a2dZoomFast::OnMouseEvent( wxMouseEvent& event )
208 {
209  if ( !m_active )
210  {
211  event.Skip();
212  return;
213  }
214 
215  if ( GetBusy() )
216  GetDrawingPart()->SetCursor( m_toolBusyCursor );
217  else
218  GetDrawingPart()->SetCursor( m_toolcursor );
219 
220  m_x = event.GetX();
221  m_y = event.GetY();
222 
223  if ( event.LeftDClick() && !GetBusy() )
224  {
226  }
227  else if ( event.LeftDown() && !GetBusy() )
228  {
229  SetIgnorePendingObjects( true );
232  a2dRect* rec = new a2dRect( m_xwprev, m_ywprev, 0, 0, 0 );
233  m_canvasobject = rec;
234  if ( GetDrawingPart()->GetTrippleBuf() )
236  else
237  AddDecorationObject( rec );
238  rec->SetRoot( GetDrawingPart()->GetDrawing() );
239  rec->SetFill( m_fill );
240  rec->SetStroke( m_stroke );
242  m_pending = true;
243 
244  //special case to have the canvas itself recieve at least this one also.
245  //because often the zoomtool is active as only tool, but
246  //some object on the canvas are meant to react to MD (Href's etc.)
247  event.Skip();
248  EnterBusyMode();
249  }
250  else if ( event.LeftUp() /*event.LeftDown()*/ && GetBusy() )
251  {
252  SetIgnorePendingObjects( false );
253  a2dRect* rec = wxStaticCast( m_canvasobject.Get(), a2dRect );
254 
255  double w = GetDrawer2D()->WorldToDeviceXRel( rec->GetWidth() );
256  double h = GetDrawer2D()->WorldToDeviceYRel( rec->GetHeight() );
257 
258  //to be able to intercept doubleclick
259  //ignore the LeftDown and LeftUp if mouse position is the same
260  if ( fabs( w ) < 3 && fabs( h ) < 3 )
261  {
262  GetDisplayWindow()->Refresh();
263  FinishBusyMode();
264  event.Skip();
265  }
266  else
267  {
269  double x1 = rec->GetBbox().GetMinX();
270 
271  double y1 = rec->GetBbox().GetMinY();
272 
273  //Get the current window size to put on zoomstack
274  a2dBoundingBox* bbox = new a2dBoundingBox( GetDrawer2D()->GetVisibleMinX(),
275  GetDrawer2D()->GetVisibleMinY(),
276  GetDrawer2D()->GetVisibleMaxX(),
277  GetDrawer2D()->GetVisibleMaxY()
278  );
279 
280  m_stcontroller->GetZoomList().Insert( bbox );
281 
282  GetDrawer2D()->SetMappingWidthHeight( x1, y1, fabs( rec->GetWidth() ), fabs( rec->GetHeight() ) );
283 
284  a2dGeneralGlobals->RecordF( this, _T( "zoom %f %f %f %f" ), x1, y1, x1 + rec->GetWidth(), y1 + rec->GetHeight() );
285 
286  //generate an OnPaint event in order to redraw
287  //other tools that are busy at this moment
288  //GetDrawingPart()->Refresh();
289 
290  FinishBusyMode();
291  if ( GetDrawingPart()->GetTrippleBuf() )
293  event.Skip();
294  }
295  }
296  else if ( ( event.Dragging() && GetBusy() ) /*|| (event.Moving() && GetBusy())*/ )
297  {
298  a2dRect* rec = wxStaticCast( m_canvasobject.Get(), a2dRect );
299 
301 
302  rec->SetWidth( m_xwprev - rec->GetPosX() );
303  rec->SetHeight( m_ywprev - rec->GetPosY() );
304  rec->SetPending( true );
305  m_pending = true;
306  }
307  else
308  event.Skip();
309 }
310 
311 BEGIN_EVENT_TABLE( a2dFastSelect, a2dStTool )
312  EVT_CHAR( a2dFastSelect::OnChar )
313  EVT_MOUSE_EVENTS( a2dFastSelect::OnMouseEvent )
314 END_EVENT_TABLE()
315 
316 a2dFastSelect::a2dFastSelect( a2dStToolContr* controller ): a2dStTool( controller )
317 {
318  m_eventHandler = new a2dStToolFixedToolStyleEvtHandler( controller );
319 
320  m_shift_is_add = false;
321 
322  m_anotate = false;
323  m_toolcursor = a2dCanvasGlobals->GetCursor( a2dCURSOR_CROSS );
324  m_toolBusyCursor = a2dCanvasGlobals->GetCursor( a2dCURSOR_CROSS );
325 
326  if ( GetDrawingPart()->GetDrawer2D()->HasAlpha() || GetDrawingPart()->GetTrippleBufHasAlpha() )
327  {
328  SetFill( a2dFill( wxColour( 233, 15, 23, 20 ) ) );
329  SetStroke( a2dStroke( wxColour( 255, 59, 25, 65 ), 1, a2dSTROKE_LONG_DASH ) );
330  }
331  else
332  {
333  SetFill( *a2dTRANSPARENT_FILL );
334  SetStroke( a2dStroke( *wxRED, 1, a2dSTROKE_LONG_DASH ) );
335  }
336 }
337 
338 a2dFastSelect::~a2dFastSelect()
339 {
340 }
341 
343 {
344 }
345 
346 void a2dFastSelect::DeselectAll()
347 {
349 }
350 
352 {
353  // Add old (and later new) annotation area to pending region
355 
356  a2dRect* rec = wxStaticCast( m_canvasobject.Get(), a2dRect );
357  m_anotation.Printf( _T( "w %6.3f h %6.3f" ), rec->GetWidth(), rec->GetHeight() );
358  m_xanotation = m_x;
359  m_yanotation = m_y;
360 
361  wxCoord w, h, descent, external;
362  GetTextExtent( m_anotation, &w, &h, &descent, &external );
363 
364  m_xanotation = m_x + h;
365  m_yanotation = m_y + h;
366 
368 }
369 
370 void a2dFastSelect::OnChar( wxKeyEvent& event )
371 {
372  if ( !GetBusy() )
373  {
374  switch( event.GetKeyCode() )
375  {
376  case WXK_RETURN:
377  {
379  }
380  break;
381  case WXK_SUBTRACT:
382  {
384  }
385  break;
386  default:
387  event.Skip();
388  }
389  }
390  else
391  event.Skip();
392 }
393 
394 void a2dFastSelect::OnMouseEvent( wxMouseEvent& event )
395 {
396  if ( !m_active )
397  {
398  event.Skip();
399  return;
400  }
401 
402  m_x = event.GetX();
403  m_y = event.GetY();
404 
406 
407  a2dRestrictionEngine* restrict = GetDrawing()->GetHabitat()->GetRestrictionEngine();
408  if( restrict )
409  {
410  restrict->SetShiftKeyDown( event.ShiftDown() );
411  restrict->RestrictPoint( m_xwprev, m_ywprev );
412  }
413 
414  if ( event.Moving() )
415  {
416  if ( !GetBusy() )
417  {
418  double xWorld, yWorld;
419  GetDrawingPart()->MouseToToolWorld( m_x, m_y, xWorld, yWorld );
420 
421  static a2dCanvasObject* oldhitobject = NULL;
422  a2dCanvasObject* hitobject = NULL;
423  hitobject = GetDrawingPart()->IsHitWorld( xWorld, yWorld, wxLAYER_ALL, a2dCANOBJHITOPTION_LAYERS, true );
424  if ( hitobject )
425  {
426  GetDrawingPart()->SetCursor( a2dCanvasGlobals->GetCursor( a2dCURSOR_HAND ) );
427 
428  if ( oldhitobject )
429  {
430  if ( hitobject != oldhitobject )
431  {
433  GetDrawingPart()->RemoveOverlayObject( oldhitobject );
434  GetDrawingPart()->SetOverlayDrawStyle( RenderWIREFRAME_HighLight );
435  GetDrawingPart()->AddOverlayObject( hitobject );
436  hitobject->SetPending( true );
438  oldhitobject = hitobject;
439  }
440  }
441  else
442  {
444  GetDrawingPart()->SetOverlayDrawStyle( RenderWIREFRAME_HighLight );
445  GetDrawingPart()->AddOverlayObject( hitobject );
446  hitobject->SetPending( true );
448  oldhitobject = hitobject;
449  }
450  }
451  else if ( oldhitobject )
452  {
453  GetDrawingPart()->SetCursor( m_toolcursor );
455  GetDrawingPart()->RemoveOverlayObject( oldhitobject );
457  oldhitobject = NULL;
458  }
459  else
460  GetDrawingPart()->SetCursor( m_toolcursor );
461  }
462  else
463  GetDrawingPart()->SetCursor( m_toolBusyCursor );
464  }
465  else
466  {
467  GetDrawingPart()->SetOverlayDrawStyle( RenderLAYERED );
468  if ( GetBusy() )
469  GetDrawingPart()->SetCursor( m_toolBusyCursor );
470  else
471  GetDrawingPart()->SetCursor( m_toolcursor );
472  }
473 
474  if ( event.LeftDClick() && !GetBusy() )
475  {
477  }
478  else if ( event.LeftDown() && !GetBusy() )
479  {
480  SetIgnorePendingObjects( true );
482  a2dRect* rec = new a2dRect( m_xwprev, m_ywprev, 0, 0, 0 );
483  m_canvasobject = rec;
484  rec->SetFill( m_fill );
485  rec->SetStroke( m_stroke );
487  if ( GetDrawingPart()->GetTrippleBuf() )
488  rec->SetRoot( GetDrawingPart()->GetDrawing() );
489  else
491  GetDrawingPart()->SetOverlayDrawStyle( RenderLAYERED );
492  m_pending = true;
493 
494  //special case to have the canvas itself recieve at least this one also.
495  //because often the zoomtool is active as only tool, but
496  //some object on the canvas are meant to react to MD (Href's etc.)
497  event.Skip();
498  EnterBusyMode();
499  }
500  else if ( event.LeftUp() /*event.LeftDown()*/ && GetBusy() )
501  {
502  SetIgnorePendingObjects( false );
503 
504  a2dRect* rec = wxStaticCast( m_canvasobject.Get(), a2dRect );
508  GetDrawingPart()->SetOverlayDrawStyle( RenderWIREFRAME_HighLight );
509 
510  double w = GetDrawer2D()->WorldToDeviceXRel( rec->GetWidth() );
511  double h = GetDrawer2D()->WorldToDeviceYRel( rec->GetHeight() );
512 
513  if ( fabs( w ) < 3 && fabs( h ) < 3 )
514  {
515  // The user did click somewhere ( no drag )
516 
518 
519  if( m_shift_is_add )
520  {
521  if ( !event.m_shiftDown )
522  {
523  //if NOT shift down, deselect all and set selection to hit object.
524  DeselectAll();
525 
526  if ( hitobject ) //set selection to hit object.
527  {
529  new a2dCommand_SetFlag( hitobject, a2dCanvasOFlags::SELECTED, !hitobject->GetSelected() )
530  );
531  }
532  }
533  else
534  {
535  //if shift down, add to selection when hit on object, else nothing
536  if ( hitobject )
537  {
539  new a2dCommand_SetFlag( hitobject, a2dCanvasOFlags::SELECTED, true )
540  );
541  }
542  }
543 
544  if ( !hitobject )
545  {
546  if( !m_oneshot )
547  event.Skip();
548  FinishBusyMode();
549  return;
550  }
551  }
552  else
553  {
554  if ( !hitobject )
555  {
556  if( !m_oneshot )
557  event.Skip();
558  FinishBusyMode();
559  return;
560  }
561 
562  if ( event.m_shiftDown || hitobject->GetSelected() )
563  {
565  new a2dCommand_SetFlag( hitobject, a2dCanvasOFlags::SELECTED, false )
566  );
567  }
568  else
569  {
571  new a2dCommand_SetFlag( hitobject, a2dCanvasOFlags::SELECTED, true )
572  );
573  }
574  }
575  }
576  else
577  {
578  if( m_shift_is_add )
579  {
580  //if shift is not down, start a new selection, by first deslecting all,
581  //and dragging a new selection rectangle
582 
583  if ( !event.m_shiftDown )
584  {
585  DeselectAll();
589  .x1( rec->GetBbox().GetMinX() )
590  .y1( rec->GetBbox().GetMinY() )
591  .x2( rec->GetBbox().GetMaxX() )
592  .y2( rec->GetBbox().GetMaxY() )
593  )
594  );
595  }
596  else
597  {
601  .x1( rec->GetBbox().GetMinX() )
602  .y1( rec->GetBbox().GetMinY() )
603  .x2( rec->GetBbox().GetMaxX() )
604  .y2( rec->GetBbox().GetMaxY() )
605  )
606  );
607  }
608  }
609  else
610  {
611  if ( event.m_shiftDown )
612  {
616  .x1( rec->GetBbox().GetMinX() )
617  .y1( rec->GetBbox().GetMinY() )
618  .x2( rec->GetBbox().GetMaxX() )
619  .y2( rec->GetBbox().GetMaxY() )
620  )
621  );
622  }
623  else
624  {
628  .x1( rec->GetBbox().GetMinX() )
629  .y1( rec->GetBbox().GetMinY() )
630  .x2( rec->GetBbox().GetMaxX() )
631  .y2( rec->GetBbox().GetMaxY() )
632  )
633  );
634  }
635  }
636  }
637 
638  m_pending = true;
639  FinishBusyMode();
640  //if ( GetDrawingPart()->GetTrippleBuf() )
642  GetDrawingPart()->Update( a2dCANVIEW_UPDATE_SYNC_DRAWERS );
643  }
644  else if ( ( event.Dragging() && GetBusy() ) /*|| (event.Moving() && GetBusy())*/ )
645  {
646  a2dRect* rec = wxStaticCast( m_canvasobject.Get(), a2dRect );
647  if ( GetDrawingPart()->GetTrippleBuf() )
648  {
650 
651  int x, y, width, height;
652  a2dIterC ic( GetDrawingPart() );
653  a2dIterCU cu( ic, a2dIDENTITY_MATRIX );
654  wxRect absarea = rec->GetAbsoluteArea( ic );
655  x = absarea.GetX();
656  y = absarea.GetY();
657  width = absarea.GetWidth();
658  height = absarea.GetHeight();
659 
660  rec->SetWidth( m_xwprev - rec->GetPosX() );
661  rec->SetHeight( m_ywprev - rec->GetPosY() );
663  rec->SetPending( false );
664 
665  wxRect absarea2 = rec->GetAbsoluteArea( ic );
666  absarea2.Union( absarea );
667  x = absarea2.GetX();
668  y = absarea2.GetY();
669  width = absarea2.GetWidth();
670  height = absarea2.GetHeight();
671 
672  GetDrawingPart()->ClearArea( x, y, width, height );
673  GetDrawingPart()->SetOverlayDrawStyle( RenderTOOL_OBJECTS_STYLED );
674  GetDrawingPart()->RenderChildObject( rec );
675  GetDrawingPart()->BlitBuffer( x, y, width, height, 0, 0 );
676 
678  GetDrawingPart()->SetOverlayDrawStyle( RenderTOOL_OBJECTS_STYLED );
679  }
680  else
681  {
682  rec->SetWidth( m_xwprev - rec->GetPosX() );
683  rec->SetHeight( m_ywprev - rec->GetPosY() );
684  rec->SetPending( true );
685  }
686  }
687  else
688  event.Skip();
689 }
690 
691 BEGIN_EVENT_TABLE( a2dFastSelect2, a2dStTool )
692  EVT_CHAR( a2dFastSelect2::OnChar )
693  EVT_MOUSE_EVENTS( a2dFastSelect2::OnMouseEvent )
694 END_EVENT_TABLE()
695 
696 a2dFastSelect2::a2dFastSelect2( a2dStToolContr* controller ): a2dStTool( controller )
697 {
698  m_eventHandler = new a2dStToolFixedToolStyleEvtHandler( controller );
699 
700  m_selectMode = true;
701 
702  m_anotate = false;
703  m_toolcursor = a2dCanvasGlobals->GetCursor( a2dCURSOR_CROSS );
704  m_toolBusyCursor = a2dCanvasGlobals->GetCursor( a2dCURSOR_CROSS );
705 
706  //i like transparent fill and specific stroke
707  SetFill( *a2dTRANSPARENT_FILL );
708  SetStroke( a2dStroke( *wxBLACK, 2, a2dSTROKE_LONG_DASH ) );
709 }
710 
711 a2dFastSelect2::~a2dFastSelect2()
712 {
713 }
714 
715 void a2dFastSelect2::SelectAll( bool select )
716 {
717  a2dCanvasObjectList objects;
721  &objects
722  );
723 }
724 
726 {
727  // Add old (and later new) annotation area to pending region
729 
730  a2dRect* rec = wxStaticCast( m_canvasobject.Get(), a2dRect );
731  m_anotation.Printf( _T( "w %6.3f h %6.3f" ), rec->GetWidth(), rec->GetHeight() );
732  m_xanotation = m_x;
733  m_yanotation = m_y;
734 
735  wxCoord w, h, descent, external;
736  GetTextExtent( m_anotation, &w, &h, &descent, &external );
737 
738  m_xanotation = m_x + h;
739  m_yanotation = m_y + h;
740 
742 }
743 
744 void a2dFastSelect2::OnChar( wxKeyEvent& event )
745 {
746  if ( !GetBusy() )
747  {
748  switch( event.GetKeyCode() )
749  {
750  case WXK_RETURN:
751  {
753  }
754  break;
755  case WXK_SUBTRACT:
756  {
758  }
759  break;
760  default:
761  event.Skip();
762  }
763  }
764  else
765  event.Skip();
766 }
767 
768 void a2dFastSelect2::OnMouseEvent( wxMouseEvent& event )
769 {
770  if ( !m_active )
771  {
772  event.Skip();
773  return;
774  }
775 
776  if ( GetBusy() )
777  GetDrawingPart()->SetCursor( m_toolBusyCursor );
778  else
779  GetDrawingPart()->SetCursor( m_toolcursor );
780 
781  m_x = event.GetX();
782  m_y = event.GetY();
783 
785 
786  a2dRestrictionEngine* restrict = GetDrawing()->GetHabitat()->GetRestrictionEngine();
787  if( restrict )
788  {
789  restrict->SetShiftKeyDown( event.ShiftDown() );
790  restrict->RestrictPoint( m_xwprev, m_ywprev );
791  }
792 
793  if ( event.Moving() )
794  {
795  if ( !GetBusy() )
796  {
797  double xWorld, yWorld;
798  GetDrawingPart()->MouseToToolWorld( m_x, m_y, xWorld, yWorld );
799  if ( GetDrawingPart()->IsHitWorld( xWorld, yWorld, wxLAYER_ALL, a2dCANOBJHITOPTION_LAYERS, true ) )
800  GetDrawingPart()->SetCursor( a2dCanvasGlobals->GetCursor( a2dCURSOR_HAND ) );
801  else
802  GetDrawingPart()->SetCursor( m_toolcursor );
803 
804  }
805  else
806  GetDrawingPart()->SetCursor( m_toolBusyCursor );
807  }
808 
809  if ( event.LeftDClick() && !GetBusy() )
810  {
812  }
813  else if ( event.LeftDown() && !GetBusy() )
814  {
815  SetIgnorePendingObjects( true );
817  a2dRect* rec = new a2dRect( m_xwprev, m_ywprev, 0, 0, 0 );
818  m_canvasobject = rec;
819  rec->SetRoot( GetDrawingPart()->GetDrawing() );
820  rec->SetFill( m_fill );
821  rec->SetStroke( m_stroke );
823  m_pending = true;
824 
825  //special case to have the canvas itself recieve at least this one also.
826  //because often the zoomtool is active as only tool, but
827  //some object on the canvas are meant to react to MD (Href's etc.)
828  event.Skip();
829  EnterBusyMode();
830  }
831  else if ( event.LeftUp() /*event.LeftDown()*/ && GetBusy() )
832  {
833  SetIgnorePendingObjects( false );
834 
835  a2dRect* rec = wxStaticCast( m_canvasobject.Get(), a2dRect );
838 
839  double w = GetDrawer2D()->WorldToDeviceXRel( rec->GetWidth() );
840  double h = GetDrawer2D()->WorldToDeviceYRel( rec->GetHeight() );
841 
842  if ( fabs( w ) < 3 && fabs( h ) < 3 )
843  {
844  // The user did click somewhere ( no drag )
845 
847 
848  if ( event.m_shiftDown && event.m_controlDown )
849  {
850  if ( !hitobject )
851  {
852  if( !m_oneshot )
853  event.Skip();
854  FinishBusyMode();
855  return;
856  }
857 
858  //if NOT shift down, deselect all and set selection to hit object.
859  SelectAll( m_selectMode );
860 
862  new a2dCommand_SetFlag( hitobject, a2dCanvasOFlags::SELECTED, !hitobject->GetSelected() )
863  );
864  }
865  }
866  else
867  {
869  collector.SetRecursionDepth( 2 );
870  //collector.SetCheckLayerVisible( true );
871  //collector.SetCheckLayerSelectable( true );
872  collector.SetBoundingBox( rec->GetBbox() );
873  collector.SetSkipNotRenderedInDrawing( true );
874  collector.Start( GetDrawingPart()->GetShowObject() );
875 
876  if ( event.m_shiftDown && event.m_controlDown )
877  {
879  new a2dCommand_SetFlag( 0, a2dCanvasOFlags::SELECTED, !m_selectMode ),
880  &collector.m_found
881  );
882  }
883  else
884  {
886  new a2dCommand_SetFlag( 0, a2dCanvasOFlags::SELECTED, m_selectMode ),
887  &collector.m_found
888  );
889  }
890  }
891 
892  m_pending = true;
893  FinishBusyMode();
894  GetDrawingPart()->Update( a2dCANVIEW_UPDATE_SYNC_DRAWERS );
895  }
896  else if ( ( event.Dragging() && GetBusy() ) /*|| (event.Moving() && GetBusy())*/ )
897  {
898  a2dRect* rec = wxStaticCast( m_canvasobject.Get(), a2dRect );
899 
900  GetDrawer2D()->BeginDraw();
901  GetDrawer2D()->ResetStyle();
904  GetDrawer2D()->SetDrawerStroke( *a2dBLACK_STROKE );//m_stroke );
905  GetDrawer2D()->DrawRoundedRectangle( rec->GetPosX(), rec->GetPosY(),
906  rec->GetWidth(), rec->GetHeight(), 0 );
907 
908  rec->SetWidth( m_xwprev - rec->GetPosX() );
909  rec->SetHeight( m_ywprev - rec->GetPosY() );
910 
911  GetDrawer2D()->DrawRoundedRectangle( rec->GetPosX(), rec->GetPosY(),
912  rec->GetWidth(), rec->GetHeight(), 0 );
913 
914  GetDrawer2D()->BlitBuffer();
915 
916  GetDrawer2D()->EndDraw();
918 
919  }
920  else
921  event.Skip();
922 }
923 
924 
925 BEGIN_EVENT_TABLE( a2dFastDragMultiTool, a2dStTool )
926  EVT_IDLE( a2dFastDragMultiTool::OnIdle )
927  EVT_CHAR( a2dFastDragMultiTool::OnChar )
928  EVT_MOUSE_EVENTS( a2dFastDragMultiTool::OnMouseEvent )
929 END_EVENT_TABLE()
930 
932 {
933  m_eventHandler = new a2dStToolFixedToolStyleEvtHandler( controller );
934 
935  m_anotate = false;
936  m_mode = 0;
937  SetFill( *a2dTRANSPARENT_FILL );
938  SetStroke( a2dStroke( *wxRED, 0, a2dSTROKE_SOLID ) );
939  m_toolBusyCursor = a2dCanvasGlobals->GetCursor( a2dCURSOR_CROSS );
940 }
941 
942 a2dFastDragMultiTool::~a2dFastDragMultiTool()
943 {
944 }
945 
946 void a2dFastDragMultiTool::OnChar( wxKeyEvent& event )
947 {
948  switch( event.GetKeyCode() )
949  {
950  case WXK_TAB:
951  {
952  m_mode++;
953  SetMode( m_mode );
954  }
955  break;
956  case WXK_SPACE:
957  {
958  if ( GetBusy() )
959  {}
960  }
961  break;
962 
963  default:
964  event.Skip();
965  }
966 }
967 
968 bool a2dFastDragMultiTool::StartDragging( int x, int y, a2dCanvasObject* original )
969 {
970  m_x = x;
971  m_y = y;
973 
974  GetDrawing()->GetHabitat()->SetLastXyEntry( m_xwprev, m_ywprev );
975 
976  m_original = original;
977 
979  {
980  m_original = 0;
981  return false;
982  }
983 
984  // collect selected objects
986  EnterBusyMode();
987 
988  GetDrawingPart()->Freeze();
989  SetIgnorePendingObjects( true );
990 
991  m_startMousexw = m_xwprev;
992  m_startMouseyw = m_ywprev;
993  m_startObjectx = m_original->GetPosX();
994  m_startObjecty = m_original->GetPosY();
995  m_prevxanotation = m_x;
996  m_prevyanotation = m_y;
997 
998  m_pending = true;
999 
1000  a2dRestrictionEngine* restrict = GetDrawing()->GetHabitat()->GetRestrictionEngine();
1001  if( restrict )
1002  {
1003  restrict->SetRestrictPoint( m_startObjectx, m_startObjecty );
1004  }
1005  return true;
1006 }
1007 
1008 void a2dFastDragMultiTool::OnMouseEvent( wxMouseEvent& event )
1009 {
1010  if ( !m_active )
1011  {
1012  event.Skip();
1013  return;
1014  }
1015 
1016  m_x = event.GetX();
1017  m_y = event.GetY();
1019 
1020  a2dRestrictionEngine* restrict = GetDrawing()->GetHabitat()->GetRestrictionEngine();
1021  if( restrict )
1022  {
1023  restrict->SetShiftKeyDown( event.ShiftDown() );
1024  restrict->RestrictPoint( m_xwprev, m_ywprev );
1025  }
1026 
1027  if ( event.LeftDown() )
1028  {
1030  if ( !StartDragging( m_x, m_y, original ) )
1031  return;
1032  }
1033  else if ( event.LeftUp() && GetBusy() )
1034  {
1035  GetDrawingPart()->Thaw( false );
1036  SetIgnorePendingObjects( false );
1037  FinishBusyMode();
1038 
1039  //GetDrawingPart()->GetDrawing()->UpdateAllViews( NULL, a2dCANVIEW_UPDATE_ALL );
1040  //if (m_oneshot)
1041  // StopTool();
1042  }
1043  else if ( GetBusy() )
1044  {
1045  double dxm = m_xwprev - m_startMousexw;
1046  double dym = m_ywprev - m_startMouseyw;
1047  AdjustShift( &dxm, &dym );
1048  // drag and restrict main object
1049  // calculate the shift resulting from this
1050  double dx = m_canvasobject->GetPosX();
1051  double dy = m_canvasobject->GetPosY();
1052  m_canvasobject->SetPosXY( dxm + m_startObjectx, dym + m_startObjecty );
1053  dx = m_canvasobject->GetPosX() - dx;
1054  dy = m_canvasobject->GetPosY() - dy;
1055 
1056  DragRelative( dx, dy );
1057  }
1058  else
1059  {
1060  event.Skip();
1061  }
1062 }
1063 
1065 {
1066  if( !a2dStTool::EnterBusyMode() )
1067  return false;
1068  CaptureMouse();
1069  return true;
1070 }
1071 
1072 void a2dFastDragMultiTool::FinishBusyMode()
1073 {
1074  ReleaseMouse();
1075 
1076  double dx = m_canvasobject->GetPosX() - m_startObjectx;
1077  double dy = m_canvasobject->GetPosY() - m_startObjecty;
1078 
1079  GetCanvasCommandProcessor()->Submit( new a2dCommand_MoveMask( GetDrawingPart()->GetShowObject(), dx, dy ) );
1080 
1081  m_objects.clear();
1082 
1084 }
1085 
1087 {
1088  ReleaseMouse();
1090 }
1091 
1093 {
1094  wxASSERT( m_canvasobject );
1096  GetDrawingPart()->GetDisplayWindow()->CaptureMouse();
1097 }
1098 
1100 {
1101  GetDrawingPart()->SetCaptured( NULL );
1102  GetDrawingPart()->GetDisplayWindow()->ReleaseMouse();
1103 }
1104 
1105 void a2dFastDragMultiTool::DragRelative( double x, double y )
1106 {
1107  if( !x && !y )
1108  return;
1109 
1110  m_canvasobject->Translate( -x, -y );
1111 
1112  GetDrawer2D()->BeginDraw();
1113  GetDrawer2D()->ResetStyle();
1116  GetDrawer2D()->SetDrawerStroke( *a2dBLACK_STROKE );//m_stroke );
1117 
1118  a2dIterC ic( GetDrawingPart() );
1119  ic.SetDisableInvert( true );
1120  //at the top level the group its matrix is to be ignored.
1121  //Since it is normally NOT ignored within a2dCanvasObject, do an inverse first here.
1123  cworld.Invert();
1124 
1125  OVERLAP clipparent = _IN;
1127  ic.SetLayer( wxLAYER_ALL );
1128 
1129  a2dCanvasObjectList::iterator iter;
1130  for( iter = m_copies.begin(); iter != m_copies.end(); ++iter )
1131  {
1132  a2dCanvasObject* copy = *iter;
1133  a2dIterCU cu( ic, cworld );
1134  GetDrawer2D()->SetDisableDrawing( true );
1135  copy->SetHasToolObjectsBelow( true );
1136  copy->Render( ic, clipparent );
1137  ic.Reset();
1138  GetDrawer2D()->SetDisableDrawing( false );
1139  }
1140 
1141  //Translate all items selected
1142 
1143  for( iter = m_copies.begin(); iter != m_copies.end(); ++iter )
1144  {
1145  a2dCanvasObject* obj = *iter;
1146  obj->Translate( x, y );
1147  }
1148 
1149  for( iter = m_copies.begin(); iter != m_copies.end(); ++iter )
1150  {
1151  a2dCanvasObject* copy = *iter;
1152  a2dIterCU cu( ic, cworld );
1153  GetDrawer2D()->SetDisableDrawing( true );
1154  copy->SetHasToolObjectsBelow( true );
1155  copy->Render( ic, clipparent );
1156  ic.Reset();
1157  GetDrawer2D()->SetDisableDrawing( false );
1158  }
1159 
1161 
1162  GetDrawer2D()->BlitBuffer();
1163 
1164  GetDrawer2D()->EndDraw();
1166 
1167 
1168  m_pending = true;
1169 }
1170 
1172 {
1173  return;
1174  if ( m_canvasobject && GetBusy() )
1175  {
1176  a2dDrawer2D* draw = GetDrawer2D();
1177  GetDrawer2D()->BlitBuffer();
1178 
1179  wxClientDC* dc = new wxClientDC( GetDrawingPart()->GetDisplayWindow() );
1180 
1181  a2dDcDrawer* dcdrawer = new a2dDcDrawer( *GetDrawer2D() );
1182  dcdrawer->SetRenderDC( dc );
1183  dcdrawer->BeginDraw();
1184  dcdrawer->ResetStyle();
1185  dcdrawer->SetDrawerFill( m_fill );
1186  dcdrawer->SetDrawerStroke( m_stroke );
1187  dcdrawer->SetDrawerStroke( *a2dBLACK_STROKE );//m_stroke );
1188  dcdrawer->SetDrawStyle( a2dFIX_STYLE );
1189 
1190  a2dSmrtPtr< a2dDrawingPart > view = new a2dDrawingPart( dcdrawer );
1191  //view is a a2dView and therefore gets events, but this is not wanted here.
1192  view->SetEvtHandlerEnabled( false );
1193  view->SetShowObject( view->GetShowObject() );
1194 
1195 
1196  a2dIterC ic( view );
1197  ic.SetDisableInvert( true );
1198  //at the top level the group its matrix is to be ignored.
1199  //Since it is normally NOT ignored within a2dCanvasObject, do an inverse first here.
1201  cworld.Invert();
1202 
1203  OVERLAP clipparent = _IN;
1205  ic.SetLayer( wxLAYER_ALL );
1206 
1207  for( a2dCanvasObjectList::iterator iter = m_copies.begin(); iter != m_copies.end(); ++iter )
1208  {
1209  a2dCanvasObject* copy = *iter;
1210  a2dIterCU cu( ic, cworld );
1211  ic.GetDrawer2D()->SetDisableDrawing( true );
1212  copy->SetHasToolObjectsBelow( true );
1213  copy->Render( ic, clipparent );
1214  ic.Reset();
1215  ic.GetDrawer2D()->SetDisableDrawing( false );
1216  }
1217 
1218  if ( m_anotate )
1219  {
1221  }
1222 
1223  dcdrawer->EndDraw();
1224  dcdrawer->OverRuleFixedStyle();
1225  dcdrawer->SetRenderDC( NULL );
1226  delete dc;
1227  }
1228 }
1229 
1230 void a2dFastDragMultiTool::AdjustShift( double* WXUNUSED( dx ), double* WXUNUSED( dy ) )
1231 {
1232 }
1233 
1235 {
1237 
1238  a2dCanvasObjectList::iterator iter;
1239  // Clone all selected objects
1240  for( iter = m_objects.begin(); iter != m_objects.end(); ++iter )
1241  {
1242  a2dCanvasObjectPtr original = *iter;
1243  a2dCanvasObject* copy = original->TClone( clone_flat );
1244 
1245  copy->SetAlgoSkip( true );
1247  //a2dCanvasObject::PROPID_viewSpecific->SetPropertyToObject( copy, GetDrawingPart() );
1248 
1249  m_copies.push_back( copy );
1250  copy->SetSelected( false );
1251 
1252  if( original == m_original )
1253  m_canvasobject = copy;
1254  }
1255 
1256  m_pending = true;
1257 
1258  return true;
1259 }
1260 
1262 {
1264  // Clone all selected objects
1265  m_copies.clear();
1266 }
1267 
1268 
1269 void a2dFastDragMultiTool::OnIdle( wxIdleEvent& event )
1270 {
1271  if ( m_canvasobject && m_pending && GetBusy() )
1272  {
1273  m_pending = false;
1274 
1275  }
1276  else
1277  event.Skip();
1278 }
1279 
1281 {
1282  if ( m_anotate )
1283  {
1284  m_anotation.Printf( _T( "x %6.3f y %6.3f" ), m_canvasobject->GetPosX(), m_canvasobject->GetPosY() );
1285  wxCoord w, h, descent, external;
1286  GetTextExtent( m_anotation, &w, &h, &descent, &external );
1287  m_xanotation = m_x + h;
1288  m_yanotation = m_y + h;
1289 
1290  GetDrawer2D()->DeviceDrawAnnotation( m_anotation, m_prevxanotation, m_prevyanotation, m_annotateFont );
1291 
1293 
1294  m_prevxanotation = m_xanotation;
1295  m_prevyanotation = m_yanotation;
1296  }
1297 }
1298 
1300 {
1301  m_mode = mode;
1302  if ( m_mode > 2 ) m_mode = 0;
1303 
1304  if ( !m_canvasobject )
1305  return;
1306 
1307  m_pending = true;
1308 }
1309 
1310 BEGIN_EVENT_TABLE( a2dFastCopyMultiTool, a2dFastDragMultiTool )
1311  EVT_CHAR( a2dFastCopyMultiTool::OnChar )
1312  EVT_MOUSE_EVENTS( a2dFastCopyMultiTool::OnMouseEvent )
1313 END_EVENT_TABLE()
1314 
1316 {
1317  m_mindist = GetDrawer2D()->DeviceToWorldXRel( 5 ); //GetDrawing()->GetHabitat()->GetCopyMinDistance();
1318 }
1319 
1320 void a2dFastCopyMultiTool::OnChar( wxKeyEvent& event )
1321 {
1322  if ( GetBusy() )
1323  {
1324  switch( event.GetKeyCode() )
1325  {
1326  case WXK_SPACE:
1327  {
1328  }
1329  break;
1330  default:
1331  event.Skip();
1332  }
1333  }
1334  else
1335  event.Skip();
1336 
1337 }
1338 
1339 bool a2dFastCopyMultiTool::StartDragging( int x, int y, a2dCanvasObject* original )
1340 {
1341  m_x = x;
1342  m_y = y;
1344 
1345  GetDrawing()->GetHabitat()->SetLastXyEntry( m_xwprev, m_ywprev );
1346 
1347  m_original = original;
1348 
1350  {
1351  m_original = 0;
1352  return false;
1353  }
1354 
1355  // OpenCommandGroup must be issued before new objects are added
1356  // This is also done in EnterBusyMode, but it can be done more than once
1357  OpenCommandGroup( false );
1358 
1359  a2dRefMap refs;
1360 
1361  // Copy all selected objects
1362  // Deselect the original selected objects
1363  // Select the copied objects
1364  {
1365  bool originalfound = false;
1366  a2dCanvasObjectList::iterator iter;
1367  for( iter = m_parentobject->GetChildObjectList()->begin(); iter != m_parentobject->GetChildObjectList()->end(); ++iter )
1368  {
1369  a2dCanvasObject* obj = *iter;
1370  if( obj->GetSelected() )
1371  {
1372  a2dCanvasObject* objn = obj->TClone( clone_members | clone_childs, &refs );
1373  // Collect the new object into the active object list
1374  m_objects.push_back( objn );
1375  // Deselect the original objects
1377  // m_original must point to the copied object
1378  if( obj == m_original )
1379  {
1380  m_original = objn;
1381  originalfound = true;
1382  }
1383  }
1384  }
1385  wxASSERT( originalfound );
1386 
1387  for( iter = m_objects.begin(); iter != m_objects.end(); ++iter )
1388  {
1389  ( *iter )->SetSelected( true );
1390  // Add the new object
1392  }
1393 
1394  // Connect pins in copy as in source
1395  refs.LinkReferences();
1396  }
1397  EnterBusyMode();
1398 
1399  GetDrawingPart()->Freeze();
1400  SetIgnorePendingObjects( true );
1401 
1402  m_startMousexw = m_xwprev;
1403  m_startMouseyw = m_ywprev;
1404  m_startObjectx = m_original->GetPosX();
1405  m_startObjecty = m_original->GetPosY();
1406 
1407  a2dRestrictionEngine* restrict = GetDrawing()->GetHabitat()->GetRestrictionEngine();
1408  if( restrict )
1409  restrict->SetRestrictPoint( m_startObjectx, m_startObjecty );
1410 
1411  // Make one shift so that the copy is not over the original
1412  {
1413  double dxm = m_xwprev - m_startMousexw;
1414  double dym = m_ywprev - m_startMouseyw;
1415  AdjustShift( &dxm, &dym );
1416  // drag and restrict main object
1417  // calculate the shift resulting from this
1418  double dx = m_canvasobject->GetPosX();
1419  double dy = m_canvasobject->GetPosY();
1420  m_canvasobject->SetPosXY( dxm + m_startObjectx, dym + m_startObjecty );
1421  dx = m_canvasobject->GetPosX() - dx;
1422  dy = m_canvasobject->GetPosY() - dy;
1423  DragRelative( dx, dy );
1424  }
1425  m_pending = true;
1426  return true;
1427 }
1428 
1429 void a2dFastCopyMultiTool::OnMouseEvent( wxMouseEvent& event )
1430 {
1431  if ( !m_active )
1432  {
1433  event.Skip();
1434  return;
1435  }
1436 
1437  m_x = event.GetX();
1438  m_y = event.GetY();
1440 
1441  a2dRestrictionEngine* restrict = GetDrawing()->GetHabitat()->GetRestrictionEngine();
1442  if( restrict )
1443  {
1444  restrict->SetShiftKeyDown( event.ShiftDown() );
1445  restrict->RestrictPoint( m_xwprev, m_ywprev );
1446  }
1447 
1448  if ( event.LeftDown() )
1449  {
1451  if ( !StartDragging( m_x, m_y, original ) )
1452  return;
1453  }
1454  else if ( event.LeftUp() && GetBusy() )
1455  {
1456  event.Skip();
1457  }
1458  else if ( GetBusy() )
1459  {
1460  event.Skip();
1461  }
1462  else
1463  {
1464  event.Skip();
1465  }
1466 }
1467 
1468 void a2dFastCopyMultiTool::AdjustShift( double* dx, double* dy )
1469 {
1470  if( ( *dx ) * ( *dx ) + ( *dy ) * ( *dy ) < m_mindist )
1471  {
1472  if( ( *dx ) == 0 && ( *dy ) == 0 )
1473  {
1474  ( *dx ) = m_mindist * 1.0;
1475  ( *dy ) = m_mindist * 0.5;
1476  }
1477  else
1478  {
1479  double fac = m_mindist / sqrt( ( *dx ) * ( *dx ) + ( *dy ) * ( *dy ) );
1480  ( *dx ) *= fac;
1481  ( *dy ) *= fac;
1482  }
1483  }
1484 }
1485 
1486 void a2dFastCopyMultiTool::FinishBusyMode()
1487 {
1488  ReleaseMouse();
1489 
1490  double dx = m_canvasobject->GetPosX() - m_startObjectx;
1491  double dy = m_canvasobject->GetPosY() - m_startObjecty;
1492 
1493  GetCanvasCommandProcessor()->Submit( new a2dCommand_CopyMask( GetDrawingPart()->GetShowObject(), dx, dy ) );
1494  a2dCanvasObjectList::iterator iter;
1495  for( iter = m_objects.begin(); iter != m_objects.end(); ++iter )
1496  {
1497  a2dCanvasObject* obj = *iter;
1498  // Deselect the original objects
1499  obj->SetPending( true );
1501  }
1502  m_objects.clear();
1504 }
1505 
1506 //----------------------------------------------------------------------------
1507 // a2dDrawRectangleToolFast
1508 //----------------------------------------------------------------------------
1509 
1510 IMPLEMENT_CLASS( a2dDrawRectangleToolFast, a2dStDrawToolFast )
1511 
1512 BEGIN_EVENT_TABLE( a2dDrawRectangleToolFast, a2dStDrawToolFast )
1513  EVT_COM_EVENT( a2dDrawRectangleToolFast::OnComEvent )
1514  EVT_MOUSE_EVENTS( a2dDrawRectangleToolFast::OnMouseEvent )
1515 END_EVENT_TABLE()
1516 
1517 a2dDrawRectangleToolFast::a2dDrawRectangleToolFast( a2dStToolContr* controller ): a2dStDrawToolFast( controller )
1518 {
1519  m_radius = 0;
1520  SetFill( *a2dTRANSPARENT_FILL );
1521  SetStroke( a2dStroke( *wxBLACK, 2, a2dSTROKE_LONG_DASH ) );
1522  m_xwlast = 0;
1523  m_ywlast = 0;
1524  m_didDraw = false;
1525 }
1526 
1527 a2dDrawRectangleToolFast::~a2dDrawRectangleToolFast()
1528 {
1529 }
1530 
1531 void a2dDrawRectangleToolFast::OnComEvent( a2dComEvent& event )
1532 {
1533  if ( GetBusy() &&
1534  event.GetId() == a2dStToolContr::sm_showCursor &&
1535  m_stcontroller->GetFrame() &&
1536  m_stcontroller->GetFrame()->GetStatusBar() )
1537  {
1538  double mouse_worldx = m_xwprev;
1539  double mouse_worldy = m_ywprev;
1540 
1541  wxString unitmeasure = GetDrawing()->GetUnits();
1542  double scaleToMeters = GetDrawing()->GetUnitsScale();
1543 
1544  double multi = 1;
1545  a2dDoMu::GetMultiplierFromString( unitmeasure, multi );
1546 
1547  mouse_worldx *= scaleToMeters / multi;
1548  mouse_worldy *= scaleToMeters / multi;
1549 
1550  a2dRect* rec = wxStaticCast( m_original.Get(), a2dRect );
1551  wxString str;
1552  str.Printf( _T( "x=%6.3f, y=%6.3f, width=%6.3f, height=%6.3f" ),
1553  mouse_worldx, mouse_worldy,
1554  rec->GetWidth(), rec->GetHeight() );
1555  str = str + _T( " " ) + unitmeasure + _T( " :" ) + GetClassInfo()->GetClassName();
1556  m_stcontroller->GetFrame()->SetStatusText( str );
1557  }
1558  else
1559  event.Skip();
1560 }
1561 
1562 void a2dDrawRectangleToolFast::OnMouseEvent( wxMouseEvent& event )
1563 {
1564  if ( !m_active )
1565  {
1566  event.Skip();
1567  return;
1568  }
1569 
1570  if ( GetBusy() )
1571  GetDrawingPart()->SetCursor( m_toolBusyCursor );
1572  else
1573  GetDrawingPart()->SetCursor( m_toolcursor );
1574 
1575  m_x = event.GetX();
1576  m_y = event.GetY();
1578 
1579  a2dRestrictionEngine* restrict = GetDrawing()->GetHabitat()->GetRestrictionEngine();
1580  if( restrict )
1581  {
1582  restrict->SetShiftKeyDown( event.ShiftDown() );
1583  restrict->RestrictPoint( m_xwprev, m_ywprev );
1584  }
1585 
1586  double wr = GetDrawer2D()->DeviceToWorldXRel( 30 );
1587  if ( event.LeftDown() && !GetBusy() )
1588  {
1589  EnterBusyMode();
1590  }
1591  else if ( event.LeftDown() && GetBusy() )
1592  {
1593  a2dRect* rec = wxStaticCast( m_original.Get(), a2dRect );
1594  a2dGeneralGlobals->RecordF( this, _T( "rect %f %f %f %f" ), rec->GetPosX(), rec->GetPosY(), rec->GetWidth(), rec->GetHeight() );
1595  FinishBusyMode();
1596  }
1597  else if ( ( event.Dragging() && GetBusy() ) || ( event.Moving() && GetBusy() ) )
1598  {
1599  a2dRect* rec = wxStaticCast( m_canvasobject.Get(), a2dRect );
1600  //adjust the tool object
1601  rec->SetWidth( m_xwprev - rec->GetPosX() );
1602  rec->SetHeight( m_ywprev - rec->GetPosY() );
1604  a2dRect* recorg = wxStaticCast( m_original.Get(), a2dRect );
1605  recorg->SetWidth( rec->GetWidth() );
1606  recorg->SetHeight( rec->GetHeight() ); //event.Skip();
1608  }
1609  else if ( !GetBusy() )
1610  {
1611  event.Skip();
1612  }
1613  else
1614  event.Skip();
1615 }
1616 
1618 {
1619  a2dRect* rec = new a2dRect( m_xwprev, m_ywprev, 0, 0, m_radius );
1620  m_original = rec;
1621  rec->SetFill( m_fill );
1622  rec->SetStroke( m_stroke );
1623 
1625 }
1626 
1627 //----------------------------------------------------------------------------
1628 // a2dDrawCircleToolFast
1629 //----------------------------------------------------------------------------
1630 
1631 IMPLEMENT_CLASS( a2dDrawCircleToolFast, a2dStDrawToolFast )
1632 
1633 BEGIN_EVENT_TABLE( a2dDrawCircleToolFast, a2dStDrawToolFast )
1634  EVT_COM_EVENT( a2dDrawCircleToolFast::OnComEvent )
1635  EVT_CHAR( a2dDrawCircleToolFast::OnChar )
1636  EVT_MOUSE_EVENTS( a2dDrawCircleToolFast::OnMouseEvent )
1637 END_EVENT_TABLE()
1638 
1639 a2dDrawCircleToolFast::a2dDrawCircleToolFast( a2dStToolContr* controller ): a2dStDrawToolFast( controller )
1640 {
1641  m_toolcursor = a2dCanvasGlobals->GetCursor( a2dCURSOR_PENCIL );
1642  m_toolBusyCursor = a2dCanvasGlobals->GetCursor( a2dCURSOR_CROSS );
1643 }
1644 
1646 {
1647  if ( GetBusy() &&
1648  event.GetId() == a2dStToolContr::sm_showCursor &&
1649  m_stcontroller->GetFrame() &&
1650  m_stcontroller->GetFrame()->GetStatusBar() )
1651  {
1652  double mouse_worldx = m_xwprev;
1653  double mouse_worldy = m_ywprev;
1654 
1655  wxString unitmeasure = GetDrawing()->GetUnits();
1656  double scaleToMeters = GetDrawing()->GetUnitsScale();
1657 
1658  double multi = 1;
1659  a2dDoMu::GetMultiplierFromString( unitmeasure, multi );
1660 
1661  mouse_worldx *= scaleToMeters / multi;
1662  mouse_worldy *= scaleToMeters / multi;
1663 
1664  a2dCircle* cir = wxStaticCast( m_original.Get(), a2dCircle );
1665  wxString str;
1666  str.Printf( _T( "x=%6.3f, y=%6.3f, radius=%6.3f" ), mouse_worldx, mouse_worldy, cir->GetRadius() );
1667  str = str + _T( " " ) + unitmeasure + _T( " :" ) + GetClassInfo()->GetClassName();
1668  m_stcontroller->GetFrame()->SetStatusText( str );
1669  }
1670  else
1671  event.Skip();
1672 }
1673 
1674 
1675 void a2dDrawCircleToolFast::OnChar( wxKeyEvent& event )
1676 {
1677  if ( GetBusy() )
1678  {
1679  switch( event.GetKeyCode() )
1680  {
1681  case WXK_TAB:
1682  {
1683  m_mode++;
1684  }
1685  break;
1686 
1687  default:
1688  event.Skip();
1689  }
1690  }
1691  else
1692  event.Skip();
1693 
1694 }
1695 
1697 {
1698  m_mode = mode;
1699  if ( m_mode > 2 ) m_mode = 0;
1700 
1701  if ( !m_canvasobject )
1702  return;
1703 
1705  a2dCircle* cirorg = wxStaticCast( m_original.Get(), a2dCircle );
1706  switch ( m_mode )
1707  {
1708  case 0:
1709  {
1710  double dx, dy;
1711 
1712  if ( fabs( m_xwprev - m_start_x ) > fabs( m_ywprev - m_start_y ) )
1713  {
1714  dx = ( m_xwprev - m_start_x ) / 2 ;
1715  m_radius = fabs( dx );
1716  if ( m_ywprev > m_start_y )
1717  dy = m_radius;
1718  else
1719  dy = -m_radius;
1720  }
1721  else
1722  {
1723  dy = ( m_ywprev - m_start_y ) / 2 ;
1724  m_radius = fabs( dy );
1725  if ( m_xwprev > m_start_x )
1726  dx = m_radius;
1727  else
1728  dx = -m_radius;
1729  }
1730  cir->SetPosXY( m_start_x + dx , m_start_y + dy );
1731  cirorg->SetPosXY( m_start_x + dx , m_start_y + dy );
1732  break;
1733  }
1734  case 1:
1735  {
1736  cir->SetPosXY( m_start_x, m_start_y );
1737  cirorg->SetPosXY( m_start_x, m_start_y );
1738  m_radius = sqrt( pow( m_xwprev - cir->GetPosX(), 2 ) + pow( m_ywprev - cir->GetPosY(), 2 ) );
1739  break;
1740  }
1741  case 2:
1742  {
1743  cir->SetPosXY( ( m_xwprev + m_start_x ) / 2, ( m_ywprev + m_start_y ) / 2 );
1744  cirorg->SetPosXY( ( m_xwprev + m_start_x ) / 2, ( m_ywprev + m_start_y ) / 2 );
1745  m_radius = sqrt( pow( m_xwprev - m_start_x, 2 ) + pow( m_ywprev - m_start_y, 2 ) ) / 2;
1746  break;
1747  }
1748  default:
1749  break;
1750  }
1751 
1752  cir->SetRadius( m_radius );
1753  cirorg->SetRadius( m_radius );
1754  m_pending = true;
1755 }
1756 
1757 void a2dDrawCircleToolFast::OnMouseEvent( wxMouseEvent& event )
1758 {
1759  if ( !m_active )
1760  {
1761  event.Skip();
1762  return;
1763  }
1764 
1765  if ( GetBusy() )
1766  GetDrawingPart()->SetCursor( m_toolBusyCursor );
1767  else
1768  GetDrawingPart()->SetCursor( m_toolcursor );
1769 
1770  m_x = event.GetX();
1771  m_y = event.GetY();
1772  double newx, newy;
1773  MouseToToolWorld( m_x, m_y, newx, newy );
1774 
1775  a2dRestrictionEngine* restrict = GetDrawing()->GetHabitat()->GetRestrictionEngine();
1776  if( restrict )
1777  {
1778  restrict->SetShiftKeyDown( event.ShiftDown() );
1779  restrict->RestrictPoint( newx, newy );
1780  }
1781 
1782  if ( event.LeftDown() && !GetBusy() )
1783  {
1784  m_radius = 0;
1785  m_xwprev = newx;
1786  m_ywprev = newy;
1787  m_start_x = m_xwprev;
1788  m_start_y = m_ywprev;
1789  EnterBusyMode();
1790  }
1791  else if ( event.LeftDown() && GetBusy() )
1792  {
1793  a2dGeneralGlobals->RecordF( this, _T( "circle %f %f %f" ), m_original->GetPosX(), m_original->GetPosY(), m_radius );
1794 
1795  FinishBusyMode();
1796  }
1797  else if ( ( event.Dragging() && GetBusy() ) || ( event.Moving() && GetBusy() ) )
1798  {
1799  m_xwprev = newx;
1800  m_ywprev = newy;
1802  SetMode( m_mode );
1804  m_canvasobject->SetPending( true );
1805  }
1806  else
1807  event.Skip();
1808 }
1809 
1811 {
1812  m_original = new a2dCircle( m_xwprev, m_ywprev, m_radius );
1815 
1817 }
1818 
1819 IMPLEMENT_CLASS( a2dDrawPolygonLToolFast, a2dStDrawToolFast )
1820 
1821 BEGIN_EVENT_TABLE( a2dDrawPolygonLToolFast, a2dStDrawToolFast )
1822  EVT_IDLE( a2dDrawPolygonLToolFast::OnIdle )
1823  EVT_CHAR( a2dDrawPolygonLToolFast::OnChar )
1824  EVT_MOUSE_EVENTS( a2dDrawPolygonLToolFast::OnMouseEvent )
1825  EVT_UNDO( a2dDrawPolygonLToolFast::OnUndoEvent )
1826  EVT_REDO( a2dDrawPolygonLToolFast::OnRedoEvent )
1827 END_EVENT_TABLE()
1828 
1829 void a2dDrawPolygonLToolFast::AddPoint( a2dLineSegment* point )
1830 {
1831  if ( m_reverse )
1832  m_points->push_front( point );
1833  else
1834  m_points->push_back( point );
1835 }
1836 
1838 {
1839  m_toolcursor = a2dCanvasGlobals->GetCursor( a2dCURSOR_PENCIL );
1840  m_toolBusyCursor = a2dCanvasGlobals->GetCursor( a2dCURSOR_CROSS );
1842 
1844  m_points = ( a2dVertexList* ) 0;
1845 
1846  m_spline = GetDrawing()->GetHabitat()->GetSpline();
1847  m_reverse = false;
1848 
1849  m_templateObject = templateObject;
1850  if ( templateObject )
1852 }
1853 
1854 a2dDrawPolygonLToolFast::~a2dDrawPolygonLToolFast()
1855 {
1856 }
1857 
1859 {
1860  m_spline = spline;
1861 }
1862 
1863 void a2dDrawPolygonLToolFast::OnIdle( wxIdleEvent& event )
1864 {
1865  if ( m_pending && GetBusy() )
1866  {
1868 
1870  a2dRect* around = NULL;
1871  a2dPolygonL* nonSplined = NULL;
1872 
1873  switch ( m_mode )
1874  {
1875  case 2:
1876  {
1877  //a nice to see normal polygon around it and if stroke transparent show it.
1878  if ( poly->GetSpline() )
1879  {
1880  nonSplined = ( a2dPolygonL* ) poly->TClone( clone_childs );
1881  nonSplined->SetVisible( true );
1882  nonSplined->SetSpline( false );
1883  nonSplined->SetFill( *a2dTRANSPARENT_FILL );
1884 
1885  nonSplined->SetStroke( *wxBLACK, 0, a2dSTROKE_DOT_DASH );
1886  AddDecorationObject( nonSplined );
1887 
1888  }
1889  }
1890  case 1:
1891  {
1892  around = new a2dRect( poly->GetBboxMinX(), poly->GetBboxMinY(), poly->GetBboxWidth(), poly->GetBboxHeight() );
1893  around->SetStroke( *wxRED, 0, a2dSTROKE_DOT_DASH );
1894  around->SetFill( *a2dTRANSPARENT_FILL );
1895  around->SetRoot( GetDrawingPart()->GetDrawing() );
1896  AddDecorationObject( around );
1897  break;
1898  }
1899  default:
1900  break;
1901  }
1902 
1903  event.Skip();
1904  }
1905  else
1906  event.Skip();
1907 }
1908 
1909 void a2dDrawPolygonLToolFast::OnUndoEvent( a2dCommandProcessorEvent& event )
1910 {
1911 /*
1912  NOT like this, goes wrong if several instances of same tool.
1913  static long lastProcessedEventTimeStamp = -1; // for a2d...Events
1914  if( lastProcessedEventTimeStamp == event.GetTimestamp() )
1915  return;
1916  lastProcessedEventTimeStamp = event.GetTimestamp();
1917 */
1918 
1919  if ( GetBusy() && !m_halted )
1920  {
1921  // recreate edit copies so the edit copy becomes updated from the original.
1922 
1923  a2dPolygonL* poly = wxStaticCast( m_original.Get(), a2dPolygonL );
1924  if ( poly->GetNumberOfSegments() )
1925  {
1926  a2dLineSegmentPtr lastpoint = poly->GetSegments()->back();
1930  m_points = wxStaticCast( m_canvasobject.Get(), a2dPolygonL )->GetSegments();
1931  m_point = lastpoint;
1932  m_points->push_back( m_point );
1933  }
1934  }
1935 }
1936 
1937 void a2dDrawPolygonLToolFast::OnRedoEvent( a2dCommandProcessorEvent& event )
1938 {
1939  OnUndoEvent( event );
1940 }
1941 
1943 {
1944  m_mode = mode;
1945  if ( m_mode > 2 ) m_mode = 0;
1946 
1947  if ( !m_canvasobject )
1948  return;
1949 
1950  m_pending = true;
1951 }
1952 
1953 void a2dDrawPolygonLToolFast::OnChar( wxKeyEvent& event )
1954 {
1955  if ( GetBusy() && m_canvasobject )
1956  {
1957  double shiftx;
1958  double shifty;
1959  GetKeyIncrement( &shiftx, &shifty );
1960 
1961  switch( event.GetKeyCode() )
1962  {
1963  case WXK_TAB:
1964  {
1965  m_mode++;
1966  SetMode( m_mode );
1967  }
1968  break;
1969 
1970  case WXK_UP:
1971  shiftx = 0;
1972  break;
1973 
1974  case WXK_DOWN:
1975  shiftx = 0;
1976  shifty = -shifty;
1977  break;
1978 
1979  case WXK_LEFT:
1980  shiftx = -shiftx;
1981  shifty = 0;
1982  break;
1983 
1984  case WXK_RIGHT:
1985  shifty = 0;
1986  break;
1987 
1988  default:
1989  {
1990  shiftx = 0;
1991  shifty = 0;
1992  event.Skip();
1993  }
1994  }
1995 
1996  if ( event.m_controlDown )
1997  {
1998  m_point->m_x += shiftx;
1999  m_point->m_y += shifty;
2000  }
2001  else
2002  {
2003  double x = m_canvasobject->GetPosX();
2004  double y = m_canvasobject->GetPosY();
2005  m_canvasobject->SetPosXY( x + shiftx, y + shifty, true );
2007  poly->EliminateMatrix();
2008  }
2009 
2010  GetDisplayWindow()->WarpPointer( GetDrawer2D()->WorldToDeviceX( m_point->m_x ), GetDrawer2D()->WorldToDeviceY( m_point->m_y ) );
2011 
2012  m_pending = true;
2013  }
2014  else
2015  event.Skip();
2016 
2017 }
2018 
2019 void a2dDrawPolygonLToolFast::OnMouseEvent( wxMouseEvent& event )
2020 {
2021  if ( !m_active )
2022  {
2023  event.Skip();
2024  return;
2025  }
2026 
2027  if ( GetBusy() )
2028  GetDrawingPart()->SetCursor( m_toolBusyCursor );
2029  else
2030  GetDrawingPart()->SetCursor( m_toolcursor );
2031 
2032  m_x = event.GetX();
2033  m_y = event.GetY();
2034 
2035  a2dRestrictionEngine* restrict = GetDrawing()->GetHabitat()->GetRestrictionEngine();
2036  if ( event.LeftDown() && !GetBusy() )
2037  {
2038  SetIgnorePendingObjects( true );
2040  if( restrict )
2041  {
2042  restrict->SetShiftKeyDown( event.ShiftDown() );
2043  restrict->RestrictPoint( m_xwprev, m_ywprev );
2044  }
2045  GetDrawing()->GetHabitat()->SetLastXyEntry( m_xwprev, m_ywprev );
2046 
2047  if ( m_templateObject )
2048  {
2052  }
2053  else
2054  {
2055  m_original = new a2dPolygonL( new a2dVertexList(), m_spline );
2059  }
2060 
2061  EnterBusyMode();
2062 
2063  // Append first point to original
2066  );
2067  // Append first point to editcopy
2068  m_points = wxStaticCast( m_canvasobject.Get(), a2dPolygonL )->GetSegments();
2070  m_points->push_back( m_point );
2071 
2072  // Record commands
2073  a2dGeneralGlobals->RecordF( this, _T( "polygon" ) );
2074  a2dGeneralGlobals->RecordF( this, _T( "addpoint %f %f" ), m_xwprev, m_ywprev );
2075 
2076  //add second point to drag
2078  m_points->push_back( m_point );
2079 
2080  m_prev_x = m_xwprev;
2081  m_prev_y = m_ywprev;
2082  m_pending = true;
2083  if( restrict )
2084  restrict->SetRestrictPoint( m_xwprev, m_ywprev );
2085  }
2086  else if ( event.LeftDown() && GetBusy() )
2087  {
2089  if( restrict )
2090  restrict->RestrictPoint( m_xwprev, m_ywprev );
2091 
2092  GetDrawing()->GetHabitat()->SetLastXyEntry( m_xwprev, m_ywprev );
2093  int x = GetDrawer2D()->WorldToDeviceX( m_prev_x );
2094  int y = GetDrawer2D()->WorldToDeviceY( m_prev_y );
2095  if ( abs( m_x - x ) >= 3 || abs( m_y - y ) >= 3 )
2096  {
2099  );
2100 
2101  a2dGeneralGlobals->RecordF( this, _T( "addpoint %f %f " ), m_xwprev, m_ywprev );
2102 
2104  m_points->push_back( m_point );
2105  m_prev_x = m_xwprev;
2106  m_prev_y = m_ywprev;
2107  }
2108  if( restrict )
2109  restrict->SetRestrictPoint( m_xwprev, m_ywprev );
2110  }
2111  else if ( event.Moving() && GetBusy() )
2112  {
2113  SetMode( m_mode );
2114 
2116  if( restrict )
2117  restrict->RestrictPoint( m_xwprev, m_ywprev );
2118  m_point->m_x = m_xwprev;
2119  m_point->m_y = m_ywprev;
2120  m_canvasobject->SetPending( true );
2121 
2122  event.Skip();
2123  }
2124  else if ( event.LeftDClick() && GetBusy() )
2125  {
2127  if( restrict )
2128  restrict->RestrictPoint( m_xwprev, m_ywprev );
2129  GetDrawing()->GetHabitat()->SetLastXyEntry( m_xwprev, m_ywprev );
2130  a2dGeneralGlobals->RecordF( this, _T( "end" ) );
2131  FinishBusyMode();
2132  }
2133  else
2134  event.Skip();
2135 }
2136 
2138 {
2140 }
2141 
2142 IMPLEMENT_CLASS( a2dDrawPolylineLToolFast, a2dDrawPolygonLToolFast )
2143 
2144 BEGIN_EVENT_TABLE( a2dDrawPolylineLToolFast, a2dDrawPolygonLToolFast )
2145  EVT_MOUSE_EVENTS( a2dDrawPolylineLToolFast::OnMouseEvent )
2146  EVT_DO( a2dDrawPolylineLToolFast::OnDoEvent )
2147 END_EVENT_TABLE()
2148 
2149 a2dDrawPolylineLToolFast::a2dDrawPolylineLToolFast( a2dStToolContr* controller, a2dPolylineL* templateObject ):
2150  a2dDrawPolygonLToolFast( controller, templateObject )
2151 {
2152  m_xscale = 1;
2153  m_yscale = 1;
2154  m_begin = 0;
2155  m_end = 0;
2156  m_pathtype = GetDrawing()->GetHabitat()->GetPathType();
2157  m_contourwidth = GetDrawing()->GetHabitat()->GetContourWidthInDataBaseUnits();
2158 }
2159 
2160 a2dDrawPolylineLToolFast::~a2dDrawPolylineLToolFast()
2161 {
2162 }
2163 
2165 {
2166  if ( GetBusy() )
2167  {
2168  a2dPolylineL* poly = wxStaticCastNull( m_canvasobject.Get(), a2dPolylineL );
2169  poly->SetPathType( m_pathtype );
2170  a2dPolylineL* polyorg = wxStaticCastNull( m_original.Get(), a2dPolylineL );
2171  polyorg->SetPathType( m_pathtype );
2172  }
2173 
2174  m_pathtype = pathtype;
2175 }
2176 
2178 {
2179  if ( GetBusy() )
2180  {
2181  a2dPolylineL* poly = wxStaticCastNull( m_canvasobject.Get(), a2dPolylineL );
2182  poly->SetEndScaleX( m_yscale );
2183  poly->SetEndScaleY( m_xscale );
2184  poly->SetBegin( begin );
2185  a2dPolylineL* polyorg = wxStaticCastNull( m_original.Get(), a2dPolylineL );
2186  polyorg->SetEndScaleX( m_yscale );
2187  polyorg->SetEndScaleY( m_xscale );
2188  polyorg->SetBegin( begin );
2189  }
2190  m_begin = begin;
2191 }
2192 
2194 {
2195  if ( GetBusy() )
2196  {
2197  a2dPolylineL* poly = wxStaticCastNull( m_canvasobject.Get(), a2dPolylineL );
2198  poly->SetEndScaleX( m_yscale );
2199  poly->SetEndScaleY( m_xscale );
2200  poly->SetEnd( end );
2201  a2dPolylineL* polyorg = wxStaticCastNull( m_original.Get(), a2dPolylineL );
2202  polyorg->SetEndScaleX( m_yscale );
2203  polyorg->SetEndScaleY( m_xscale );
2204  polyorg->SetEnd( end );
2205  }
2206  m_end = end;
2207 }
2208 
2209 void a2dDrawPolylineLToolFast::OnDoEvent( a2dCommandProcessorEvent& event )
2210 {
2211  if ( !m_templateObject )
2212  {
2213  if ( event.GetId() == a2dHabitat::sig_SetContourWidth )
2214  {
2216  if ( GetBusy() )
2217  {
2220  }
2221  }
2222  if ( event.GetId() == a2dHabitat::sig_SetPathType )
2223  {
2224  m_pathtype = GetDrawing()->GetHabitat()->GetPathType();
2225  if ( GetBusy() )
2226  {
2228  poly->SetPathType( m_pathtype );
2229  poly = wxStaticCast( m_canvasobject.Get(), a2dPolylineL );
2230  poly->SetPathType( m_pathtype );
2231  }
2232  }
2233  }
2234  event.Skip();
2235 }
2236 
2237 void a2dDrawPolylineLToolFast::OnMouseEvent( wxMouseEvent& event )
2238 {
2239  if ( !m_active )
2240  {
2241  event.Skip();
2242  return;
2243  }
2244 
2245  if ( GetBusy() )
2246  GetDrawingPart()->SetCursor( m_toolBusyCursor );
2247  else
2248  GetDrawingPart()->SetCursor( m_toolcursor );
2249 
2250  m_x = event.GetX();
2251  m_y = event.GetY();
2253 
2254  a2dRestrictionEngine* restrict = GetDrawing()->GetHabitat()->GetRestrictionEngine();
2255  if ( event.LeftDown() && !GetBusy() )
2256  {
2257  SetIgnorePendingObjects( true );
2259 
2260  if( restrict )
2261  {
2262  restrict->SetShiftKeyDown( event.ShiftDown() );
2263  restrict->RestrictPoint( m_xwprev, m_ywprev );
2264  }
2265  GetDrawing()->GetHabitat()->SetLastXyEntry( m_xwprev, m_ywprev );
2266 
2267  if ( m_templateObject )
2268  {
2272  }
2273  else
2274  {
2281  poly->SetPathType( m_pathtype );
2282  if ( m_begin || m_end )
2283  {
2284  poly->SetEndScaleX( m_yscale );
2285  poly->SetEndScaleY( m_xscale );
2286  //we clone to have each line an endobject that is not shared with the tool line ends
2287  //Meaning it does not change when tool changes.
2288  if ( m_begin )
2289  poly->SetBegin( m_begin->TClone( clone_flat ) );
2290  if ( m_end )
2291  poly->SetEnd( m_end->TClone( clone_flat ) );
2292  }
2293  }
2294 
2295  EnterBusyMode();
2298  poly->SetPathType( m_pathtype );
2299 
2300  m_points = poly->GetSegments();
2301 
2302  a2dGeneralGlobals->RecordF( this, _T( "polyline" ) );
2303 
2305 
2306  // add point to the original
2307  if ( m_reverse )
2310  );
2311  else
2314  );
2315 
2317  AddPoint( m_point );
2318 
2319  a2dGeneralGlobals->RecordF( this, _T( "addpoint %f %f " ), m_xwprev, m_ywprev );
2320 
2321  //add second point to drag
2323  AddPoint( m_point );
2324 
2325  m_prev_x = m_xwprev;
2326  m_prev_y = m_ywprev;
2327 
2328  if( restrict )
2329  restrict->SetRestrictPoint( m_xwprev, m_ywprev );
2330  }
2331  else if ( event.Moving() && GetBusy() )
2332  {
2333  SetMode( m_mode );
2334 
2336  if( restrict )
2337  restrict->RestrictPoint( m_xwprev, m_ywprev );
2338  m_point->m_x = m_xwprev;
2339  m_point->m_y = m_ywprev;
2340  m_canvasobject->SetPending( true );
2341  }
2342  else
2343  event.Skip();
2344 }
2345 
2347 {
2349 }
Display Part of a a2dDrawing, in which a2dCanvasObjects are shown.
Definition: drawer.h:470
int WorldToDeviceXRel(double x) const
convert x relative from world to device coordinates
Definition: drawer2d.h:460
a2dCircle at x,y, and with radius
Definition: canprim.h:554
double m_prev_x
previous x
Definition: sttool2.h:467
void Freeze()
prevent changing the a2dDrawingPart buffer and blitting it to the window
Definition: drawer.cpp:1026
a2dCanvasObjectPtr m_canvasobject
This is the object currently edited.
Definition: sttool.h:381
a2dPATH_END_TYPE
defines the way a polyline with a contour width is ended.
Definition: polyver.h:31
virtual void Render(a2dIterC &ic, OVERLAP clipparent)
Render this object to the active a2dDrawingPart.
Definition: canobj.cpp:4712
bool CreateToolObjects()
Create the editcopy and other tool objects (e.g. decorations)
Definition: sttool2.cpp:1617
void OnChar(wxKeyEvent &event)
character handling
Definition: sttool2.cpp:370
Base class for all types of strokes, understood by a2dDrawer2D classes.
Definition: stylebase.h:378
void SetRoot(a2dDrawing *root, bool recurse=true)
Sets this object to a a2dCanvasDocument.
Definition: canobj.cpp:5933
a2dLineSegment * m_point
last point
Definition: sttool2.h:475
a2dZoomFast(a2dStToolContr *controller)
constructor
Definition: sttool2.cpp:118
a2dCanvasObjectPtr m_parentobject
( if needed ) parent a2dCanvasObject relative to which the tool actions take place.
Definition: tools.h:854
void Render()
implement rendering
Definition: sttool2.cpp:102
bool m_pending
set when tool needs an redraw (after a a2dCanvas Repaint etc.)
Definition: tools.h:814
Drag Selected canvasObjects.
Definition: sttool2.h:208
a2dCanvasCommandProcessor * GetCanvasCommandProcessor()
Returns a pointer to the command processor associated with this document.
Definition: tools.cpp:976
wxUint16 m_layer
layer for a new object
Definition: tools.h:832
void SetDrawStyle(a2dDrawStyle drawstyle)
set drawstyle to use for drawing,
Definition: drawer2d.cpp:557
int WorldToDeviceY(double y) const
convert y from world to device coordinates
Definition: drawer2d.h:455
const a2dStroke * a2dBLACK_STROKE
global a2dStroke stock object for BLACK stroking
filter for tool related a2dCanvasObject&#39;s
Definition: canobj.h:2969
virtual void DeviceDrawAnnotation(const wxString &text, wxCoord x, wxCoord y, const wxFont &font)
text drawn in device coordinates
Definition: dcdrawer.cpp:2370
const a2dAffineMatrix & GetTransformMatrix() const
get the matrix used to position the object
Definition: canobj.h:500
void SetEndScaleX(double xs)
scale begin and end object with this factor in X
Definition: polygon.h:386
wxCursor m_toolcursor
cursor to use
Definition: tools.h:768
if set, set in the clone the PROPID_Original property to the copied object
Definition: gen.h:1212
void GetKeyIncrement(double *xIncr, double *yIncr)
get the increments used when moving is done with cursor keys
Definition: sttool.cpp:1316
void SetPathType(a2dPATH_END_TYPE pathtype)
Set when m_contourwidth != 0 what is the end of the line should be.
Definition: sttool2.cpp:2164
class to map references to objects stored in XML, in order to make the connection later on...
Definition: gen.h:3462
virtual void CleanupToolObjects()
Cleanup the editcopy other tool objects (e.g. decorations)
Definition: sttool2.cpp:95
void SetIgnorePendingObjects(bool onoff)
Switches ignorance of pending objects on and off.
Definition: tools.cpp:628
a2dSmrtPtr< a2dObject > m_eventHandler
when set called before own event handler
Definition: tools.h:787
void SetLineBegin(a2dCanvasObject *begin)
defines line begin object for line and polyline drawing tools
Definition: sttool2.cpp:2177
void SetRadius(double radius)
set radius
Definition: canprim.h:578
double GetRadius() const
return radius
Definition: canprim.h:581
void ResetStyle()
set a pre-defined style reseting cashed values.
Definition: dcdrawer.cpp:479
void RemoveAllDecorations()
remove all object that were added as decorations.
Definition: tools.cpp:944
double m_contourwidth
if != 0 the polygon is contoured at distance m_contourwidth/2
Definition: tools.h:829
int m_x
x of mouse in device
Definition: sttool.h:352
virtual void OpenCommandGroup(bool restart)
called when starting an editing operation (e.g. on mouse down)
Definition: tools.cpp:852
a2dCanvasObjectPtr m_original
This is the original object selected for editing.
Definition: sttool.h:388
void AddDecorationObject(a2dCanvasObject *object)
Add a decoration object to be rendered by the tool.
Definition: tools.cpp:932
polygon defined with list of points.
Definition: polygon.h:45
virtual bool EnterBusyMode()
starts a new action (e.g drawing something ) in a tool that is already pushed.
Definition: sttool2.cpp:1064
used to add points to polygon objects
Definition: drawing.h:1959
static a2dPropertyIdVoidPtr * PROPID_ToolObject
set for objects that act as tool object, when a tool is in action.
Definition: canobj.h:2678
Ref Counted base object.
Definition: gen.h:1045
stack based tools for drawing and editing in a faster manner, but with less document feedback...
The a2dStTool is used to derive tools from.
Definition: sttool.h:115
void SetRenderDC(wxDC *dc)
set the DC that is used for rendering
Definition: dcdrawer.cpp:248
virtual void SetContourWidth(double width)
set the Contour width of the shape
Definition: canobj.h:1408
#define EVT_DO(func)
event sent from a2DocumentCommandProcessor when a command is initially done
Definition: comevt.h:795
double GetBboxMinY()
get minimum Y of the boundingbox in world coordinates relative to its parents
Definition: canobj.h:682
a2dVertexList * m_points
points sofar
Definition: sttool2.h:472
a2dDrawingPart * GetDrawingPart()
Access to the tool controllers drawer.
Definition: tools.h:632
wxZoomList & GetZoomList()
Get zoom stack list, that is use to store zooming areas.
Definition: sttool.h:616
virtual bool Update(UpdateMode mode)
Update the state of the object according to its current position etc.
Definition: canobj.cpp:5149
void SetSpline(bool on)
set to true, the polygon will be drawn as a spline
Definition: polygon.h:232
virtual void BeginDraw()
start to draw on this context (used to initialize a specific drawer)
Definition: dcdrawer.cpp:160
void SetDrawerStroke(const a2dStroke &stroke)
Used to set the current stroke.
Definition: drawer2d.cpp:565
a2dStToolContr * m_stcontroller
controller for canvas
Definition: sttool.h:391
void CaptureMouse()
redirect all mouse events for the canvas to this object
Definition: sttool2.cpp:1092
This class implements drawing functions for wxDC based drawing.
Definition: dcdrawer.h:43
a2dDrawing * GetDrawing()
Returns a pointer to the drawing.
Definition: tools.cpp:969
if set, clone childs, otherwise ref-copy them
Definition: gen.h:1207
a2dPATH_END_TYPE GetPathType()
get when m_contourwidth != 0 what is the end of the line looks like.
Definition: canglob.h:878
wxString m_anotation
anotation string, which is in general modified by the tools to display position etc.
Definition: sttool.h:340
void SetLineEnd(a2dCanvasObject *end)
defines line end object for line and polyline drawing tools
Definition: sttool2.cpp:2193
void Update(unsigned int how=(a2dCANVIEW_UPDATE_ALL|a2dCANVIEW_UPDATE_BLIT), wxObject *hintObject=NULL)
see OnUpdate
Definition: drawer.cpp:1744
bool m_anotate
when true anotation will be shown, if used inside a tool
Definition: tools.h:839
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 Render()
implement rendering
Definition: sttool2.cpp:342
virtual void AdjustShift(double *x, double *y)
This is overriden by copy tools to have a minimum distance between original and copy.
Definition: sttool2.cpp:1230
double m_yscale
end point scaling
Definition: sttool2.h:579
virtual bool CreateToolObjects()
Create the editcopy and other tool objects (e.g. decorations)
Definition: sttool2.cpp:1234
a2dPATH_END_TYPE m_pathtype
when m_contourwidth != 0 what is the end of the line looking like.
Definition: sttool2.h:582
bool m_active
tool is operational
Definition: tools.h:777
double m_ywprev
y world coordinates old or new value of mouse
Definition: sttool.h:366
virtual void FinishBusyMode(bool closeCommandGroup=true)
Called when the user finishes editing a distinct object */.
Definition: sttool.cpp:1737
a2dCanvasObjectPtr m_end
end point object for lines and polylines
Definition: sttool2.h:573
virtual void FinishBusyMode(bool closeCommandGroup=true)
Called when the user finishes editing a distinct object */.
Definition: sttool.cpp:1161
Interactive drawing of a polygon.
Definition: sttool2.h:409
double GetWidth() const
return width
Definition: canprim.h:337
double GetBboxMinX()
get minimum X of the boundingbox in world coordinates relative to its parents
Definition: canobj.h:676
virtual void CleanupToolObjects()
Cleanup the editcopy other tool objects (e.g. decorations)
Definition: sttool2.cpp:1261
virtual void GenerateAnotation()
to display a string along with a tool drawing.
Definition: sttool2.cpp:351
Interactive Zooming.
Definition: sttool2.h:69
a2dCanvasObject is the base class for Canvas Objects.
Definition: canobj.h:371
a2dAffineMatrix a2dIDENTITY_MATRIX
global a2dAffineMatrix to set/pass the identity matrix.
Definition: afmatrix.cpp:51
void Zoomout()
show all on canvas
Definition: sttool.cpp:378
for changing boolean values inside canvas objects
Definition: drawing.h:1585
void SetWidth(double w)
set width of rectangle
Definition: canprim.h:328
a2dCanvasObjectList * GetChildObjectList()
get the list where the child objects are stored in.
Definition: canobj.cpp:2551
vertex list of line and arc segments.
Definition: polyver.h:600
void SetObjectFilter(a2dCanvasObjectFilter *filter)
set object filter class.
Definition: canobj.h:3418
virtual void BlitBuffer(int x, int y, int width, int height, int xbuf, int ybuf)
blit part of the drawing buffer to the canvas
Definition: drawer.cpp:2154
bool GetSelected() const
is the object selected flag set
Definition: canobj.h:1603
void SetSelected(bool selected)
Set the object selected flag if allowed.
Definition: canobj.h:1620
bool GetSpline() const
certain drawing tools like polygon drawing use this setting
Definition: canglob.h:822
double GetBboxWidth()
get width of the boundingbox in world coordinates relative to its parents
Definition: canobj.h:700
a2dStroke m_stroke
stroke for new object
Definition: tools.h:826
bool EnterBusyMode()
starts a new action (e.g drawing something ) in a tool that is already pushed.
Definition: sttool.cpp:1731
void SetMode(int mode)
general integer to set operation modes for a tool (e.g the way it draws)
Definition: sttool2.cpp:1696
void ZoomUndo()
go to previous zoom area (used while another tool is active)
Definition: sttool.cpp:362
void SetDrawerFill(const a2dFill &fill)
Used to set the current fill.
Definition: drawer2d.cpp:621
int WorldToDeviceYRel(double y) const
convert y relative from world to device coordinates
Definition: drawer2d.h:465
void SetHeight(double h)
set height of rectangle
Definition: canprim.h:334
void AdjustShift(double *x, double *y)
This is overriden by copy tools to have a minimum distance between original and copy.
Definition: sttool2.cpp:1468
virtual bool SubmitMultiple(a2dCommand *command, a2dCanvasObjectList *objects, bool storeIt=true)
submit a command template with multiple objects
Definition: drawing.cpp:6035
a2dDrawer2D * GetDrawer2D()
Access to the tool controllers drawers drawer2d.
Definition: tools.cpp:959
Interactive (De)selection Selection of an Object(s).
Definition: sttool2.h:166
void SetHasToolObjectsBelow(bool value)
selected object itself or one of its recursive children
Definition: canobj.h:1770
collect a2dCanvasObject&#39;s in a hierarchy of a a2dCanvasDocument
Definition: algos.h:363
void GenerateAnotation()
to display a string along with a tool drawing.
Definition: sttool2.cpp:1280
base for tools that draw and are stack based.
Definition: sttool.h:427
void SetPathType(a2dPATH_END_TYPE pathtype)
Set when m_contourwidth != 0 what is the end of the line should be.
Definition: polygon.h:401
double GetMinX() const
get minimum X of the boundingbox
Definition: bbox.cpp:304
wxFrame * GetFrame()
what frame has the statusbar
Definition: sttool.h:634
virtual void DrawRoundedRectangle(double x, double y, double width, double height, double radius, bool pixelsize=false)
Draw RoundedRectangle in world coordinates.
Definition: drawer2d.cpp:2048
command on selected objects
Definition: drawing.h:2471
a2dFill m_fill
fill for new object
Definition: tools.h:823
void AddPendingUpdateArea(a2dCanvasObject *obj, wxUint8 id=0, bool refsalso=true)
add pending update for the area that is the boundingbox of the given object
Definition: drawer.cpp:2891
void AddAnotationToPendingUpdateArea()
after calculating anotation position and string, extend the boundingbox of the tools with it...
Definition: sttool.cpp:1358
void SetIgnorePendingObjects(bool onoff)
Switches ignorance of pending objects on and off.
Definition: drawing.cpp:432
virtual void ResetStyle()
set a pre-defined style reseting cashed values.
Definition: drawer2d.cpp:545
polyline defined with list of points.
Definition: polygon.h:332
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
wxWindow * GetDisplayWindow()
Access to the tool controllers drawers canvas.
Definition: tools.cpp:964
void AddOverlayObject(a2dCanvasObject *obj)
add to list of overlay objects (must be children of m_top)
Definition: drawer.cpp:973
double GetPosX() const
get x position from affine matrix
Definition: canobj.h:527
#define EVT_COM_EVENT(func)
static wxEvtHandler for communication event
Definition: gen.h:564
bool m_reverse
end to begin wire.
Definition: sttool2.h:481
Definition: bbox.h:26
wxCursor m_toolBusyCursor
cursor to use when the tool is busy doing something.
Definition: tools.h:771
virtual void DragRelative(double x, double y)
called for incremental keyboard shifts
Definition: sttool2.cpp:1105
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
a2dVertexListPtr GetSegments()
Get the list of points ( this is not a copy! )
Definition: polygon.h:219
Drawing context abstraction.
Definition: drawer2d.h:177
a2dCanvasObject * GetShowObject() const
return pointer of then currently shown object on the drawer.
Definition: drawer.h:680
bool m_oneshot
do it only once
Definition: tools.h:817
void SetDisableDrawing(bool disableDrawing)
when set, all drawing functions return immediately.
Definition: drawer2d.h:716
Normal straight line segment in a2dVertexList and a2dVertexArray.
Definition: polyver.h:163
void SetDisableInvert(bool disableInvert)
when true, disable inversion of matrixes
Definition: canobj.h:3237
int m_yanotation
y position of anotation text
Definition: sttool.h:346
void SetEndScaleY(double ys)
scale begin and end object with this factor in Y
Definition: polygon.h:395
A2DGENERALDLLEXP a2dSmrtPtr< a2dGeneralGlobal > a2dGeneralGlobals
a global pointer to get to global instance of important classes.
Definition: comevt.cpp:1148
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
de-select objects in a rectangle area
Definition: drawing.h:2489
Restriction engine for editing restrictions like snapping.
Definition: restrict.h:88
objects which fit the mask are copied to target and translated
Definition: drawing.h:3031
int CollectObjects(a2dCanvasObjectList *total, const wxString &type=wxT(""), a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL, const a2dPropertyId *id=NULL, const a2dBoundingBox &bbox=wxNonValidBbox)
Copy objects fitting the given filter to the total list.
Definition: objlist.cpp:663
static bool GetMultiplierFromString(const wxString &mul, double &multi)
calculate how to get to meters from a multiplier string e.g. um =&gt; 1e-6
Definition: artglob.cpp:293
int WorldToDeviceX(double x) const
convert x from world to device coordinates
Definition: drawer2d.h:453
void ReleaseMouse()
release the mouse capture for this object
Definition: sttool2.cpp:1099
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
bool IsSelected() const
Is the object selected flag set.
Definition: canobj.h:1610
void SetBegin(a2dCanvasObject *begin)
set object to draw as begin point
Definition: polygon.cpp:1832
bool GetSpline()
Get the polygon spline setting.
Definition: polygon.h:235
a2dCanvasObjectList m_objects
the list of selected objects
Definition: sttool2.h:256
Each a2dCommand is given a command id at construction.
Definition: comevt.h:99
bool m_spline
spline polygons
Definition: sttool2.h:478
used to add object to a a2dCanvasDocument in the current parent
Definition: drawing.h:1403
void SetMode(int mode)
general integer to set operation modes for a tool (e.g the way it draws)
Definition: sttool2.cpp:1299
void Thaw(bool update)
to release Freeze()
Definition: drawer.cpp:1031
a2dDrawPolygonLToolFast(a2dStToolContr *controller, a2dPolygonL *templateObject=NULL)
constructor
Definition: sttool2.cpp:1837
void SetVisible(bool visible)
set if this object will visible (be rendered or not)
Definition: canobj.h:1303
void SetLastXyEntry(double x, double y)
set last mouse X position in world coordinates, as set by tools.
Definition: canglob.h:774
void SetSnapTo(bool snap)
Sets snap_to flag.
Definition: canobj.h:1704
A 2x3 affine matrix class for 2D transformations.
Definition: afmatrix.h:53
makes a tool fixed in style.
Definition: sttool.h:2369
virtual void AbortBusyMode()
Called when the user aborts editing a distinct object */.
Definition: sttool2.cpp:1086
bool CreateToolObjects()
Create the editcopy and other tool objects (e.g. decorations)
Definition: sttool2.cpp:2346
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
Interactive Selection of an Object.
Definition: sttool2.h:120
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
virtual void AbortBusyMode()
Called when the user aborts editing a distinct object */.
Definition: sttool.cpp:1178
while iterating a a2dCanvasDocument, this holds the context.
Definition: canobj.h:3212
virtual void GenerateAnotation()
to display a string along with a tool drawing.
Definition: sttool2.cpp:725
double m_x
x endpoint of line
Definition: polyver.h:232
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
a2dSmrtPtr< a2dPolygonL > m_templateObject
object to clone to use as start
Definition: sttool2.h:464
Interactive drawing of a Rectangle.
Definition: sttool2.h:317
double m_y
y endpoint of line
Definition: polyver.h:235
virtual bool Submit(a2dCommand *command, bool storeIt=true)
Definition: drawing.cpp:5966
double m_prev_y
previous y
Definition: sttool2.h:469
void SetStroke(const wxColour &strokecolor, double width=0, a2dStrokeStyle style=a2dSTROKE_SOLID)
Set a stroke for the object which will be used instead of the layer stroke.
Definition: canobj.cpp:2924
static const a2dCanvasObjectFlagsMask VISIBLE
Definition: candefs.h:186
int m_y
y of mouse in device
Definition: sttool.h:354
bool CreateToolObjects()
Create the editcopy and other tool objects (e.g. decorations)
Definition: sttool2.cpp:2137
~a2dZoomFast()
destructor
Definition: sttool2.cpp:156
a2dRestrictionEngine * GetRestrictionEngine()
Get restriction engine (grid snapping)
Definition: canglob.cpp:934
virtual bool CreateToolObjects()
Create the editcopy and other tool objects (e.g. decorations)
Definition: sttool.cpp:1260
double GetUnitsScale()
this is the number that defines the physical dimension in meters / inch/ etc.
Definition: drawing.h:676
void Render()
implement rendering
Definition: sttool2.cpp:160
void SetSpline(bool spline)
certain drawing tools like polygon drawing use this setting
Definition: sttool2.cpp:1858
double m_xscale
begin point scaling
Definition: sttool2.h:576
virtual void BeginDraw()=0
start to draw on this context (used to initialize a specific drawer)
void SetShiftKeyDown(bool shiftDown)
some snapping may depend on shift key being down
Definition: restrict.h:390
virtual void CleanupToolObjects()
Cleanup the editcopy other tool objects (e.g. decorations)
Definition: sttool.cpp:1265
double GetMaxY() const
get maximum Y of the boundingbox
Definition: bbox.cpp:322
bool CreateToolObjects()
Create the editcopy and other tool objects (e.g. decorations)
Definition: sttool2.cpp:1810
An object of this class will update a a2dIterC with the required information.
Definition: canobj.h:3123
a2dCanvasObject * SetShowObject(const wxString &name)
set object available in the a2dDrawing to be shown on the drawer
Definition: drawer.cpp:2947
base for tools that draw and are stack based.
Definition: sttool2.h:27
virtual void DeviceDrawAnnotation(const wxString &text, wxCoord x, wxCoord y, const wxFont &font)
text drawn in device coordinates
Definition: drawer2d.h:672
virtual ~a2dStDrawToolFast()
destructor
Definition: sttool2.cpp:60
void BlitBuffer()
blit whole buffer to device
Definition: drawer2d.cpp:183
void OnChar(wxKeyEvent &event)
character handling
Definition: sttool2.cpp:183
void SetLayer(wxUint16 layer)
set the layer that is to be rendered
Definition: canobj.h:3288
select objects in a rectangle area
Definition: drawing.h:2488
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
wxString GetUnits()
this string defines the unit e.g. meters / inch/ etc.
Definition: drawing.h:707
Interactive drawing of a polyline.
Definition: sttool2.h:501
double GetBboxHeight()
get height of the boundingbox in world coordinates relative to its parents
Definition: canobj.h:706
Event sent to a2dCommandProcessor.
Definition: comevt.h:701
virtual bool EliminateMatrix()
reduce matrix to identity
Definition: canobj.cpp:6191
a2dCanvasObjectPtr m_begin
begin point object for lines and polylines
Definition: sttool2.h:570
if set, clone members (e.g. line end styles), otherwise ref-copy them
Definition: gen.h:1203
see a2dComEvent
Definition: gen.h:371
void RemoveOverlayObject(a2dCanvasObject *obj)
remove from the list of overlay objects (must be children of m_top)
Definition: drawer.cpp:979
double GetContourWidthInDataBaseUnits() const
get the Contour width of shapes in the document its units
Definition: canglob.cpp:1052
void GetTextExtent(const wxString &string, wxCoord *w, wxCoord *h, wxCoord *descent=NULL, wxCoord *externalLeading=NULL)
return text extends of string
Definition: sttool.cpp:1069
a2dRect
Definition: canprim.h:440
bool m_shift_is_add
false: shift key will unselect, true: shift will add to selection
Definition: sttool2.h:154
Interactive drawing of a Circle.
Definition: sttool2.h:362
static const wxEventType sm_showCursor
Definition: sttool.h:791
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
Definition: bbox.h:39
de-select all objects
Definition: drawing.h:2487
bool Invert(void)
Invert matrix.
Definition: afmatrix.cpp:197
wxFont m_annotateFont
font to use for anotation
Definition: tools.h:842
void OnChar(wxKeyEvent &event)
character handling
Definition: sttool2.cpp:744
void AssertUnique()
Check if all objects are only once in the list.
Definition: objlist.cpp:729
double GetMinY() const
get minimum Y of the boundingbox
Definition: bbox.cpp:310
virtual void EndDraw()=0
end drawing on this context (used to reset a specific drawer)
virtual bool EnterBusyMode()
starts a new action (e.g drawing something ) in a tool that is already pushed.
Definition: sttool.cpp:1147
void SetCaptured(a2dCanvasObject *captured)
set the object that is captured for events in the a2dDrawing.
Definition: drawer.h:638
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
size_t GetNumberOfSegments()
get the number of points in the pointlist
Definition: polygon.h:229
void MouseToToolWorld(int x, int y, double &xWorldLocal, double &yWorldLocal)
calculate world coordinates from devide coordinates
Definition: sttool.cpp:1622
Drag and Copy Selected canvasObjects.
Definition: sttool2.h:274
void AddCurrent(a2dCanvasObject *objectToAdd)
add the current canvas object to parent as child
Definition: sttool.cpp:1087
void Reset()
Reset this object for beeing reused. It will keep the drawer but NULL object infos.
Definition: canobj.cpp:588
virtual bool CreateToolObjects()
Create the editcopy and other tool objects (e.g. decorations)
Definition: sttool2.cpp:64
bool GetBusy()
Check if the tool is busy editing a distinct object */.
Definition: tools.h:513
wxRect GetAbsoluteArea(a2dIterC &ic, int inflate=2)
Get absolute occupied area in the device coordinates.
Definition: canobj.cpp:3199
objects which fit the mask are moved to target and translated
Definition: drawing.h:3078
int CollectObjects(a2dCanvasObjectList *total, const wxString &classname=wxT(""), a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL, const a2dPropertyId *id=0, const a2dBoundingBox &bbox=wxNonValidBbox) const
Copy objects with the right conditions to the total list.
Definition: canobj.cpp:4495
double GetHeight() const
return height
Definition: canprim.h:339
void OnComEvent(a2dComEvent &event)
tool specific statusbar
Definition: sttool2.cpp:1645
virtual void SetLayer(wxUint16 layer)
set layer index where this object is drawn upon.
Definition: canobj.cpp:5920
bool m_renderOriginal
if yes, the original object is rendered in place
Definition: sttool.h:397
void SetEnd(a2dCanvasObject *end)
set object to draw as end point
Definition: polygon.cpp:1840
virtual void EndDraw()
end drawing on this context (used to reset a specific drawer)
Definition: dcdrawer.cpp:192
void SetMode(int mode)
mode of drawing, can be swicthed with Tab key.
Definition: sttool2.cpp:1942
virtual bool LinkReferences(bool ignoreNonResolved=false)
link references to their destination
Definition: gen.cpp:4862
int m_xanotation
x position of anotation text
Definition: sttool.h:343
void SetRestrictPoint(double xSnap, double ySnap)
sets the point for snapping to
Definition: restrict.h:337
void MouseToToolWorld(int x, int y, double &xWorldLocal, double &yWorldLocal)
Definition: drawer.cpp:1097
double DeviceToWorldXRel(double x) const
convert x relative from device to world coordinates
Definition: drawer2d.h:444
CloneOptions
options for cloning
Definition: gen.h:1200
virtual void SetMappingWidthHeight(double vx1, double vy1, double width, double height)
Give the virtual size to be displayed, the mapping matrix will be calculated.
Definition: drawer2d.cpp:333
bool GetDraggable() const
get if the object can be dragged
Definition: canobj.h:1676
a2dBoundingBox & GetBbox()
get boundingbox in world coordinates exclusive stroke width relative to its parent ...
Definition: canobj.cpp:3175
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 SetFill(const a2dFill &fill)
Set a fill for the object which will be used instead of the layer fill.
Definition: canobj.cpp:2874
static void SetIgnoreAllSetpending(bool value=true)
set static IgnoreAllSetpending flag
Definition: canobj.h:2307
bool EliminateMatrix()
reduce matrix to identity without replacing object
Definition: polygon.cpp:812
virtual void GenerateAnotation()
to display a string along with a tool drawing.
Definition: sttool2.cpp:164
const a2dFill * a2dTRANSPARENT_FILL
global a2dFill stock object for TRANSPARENT filling
virtual void Render()
render in drag style
Definition: sttool2.cpp:1171
void OverRuleFixedStyle()
id style is FIXED, saves current style and sets style to a2dFILLED
Definition: drawer2d.cpp:697
sttool2.cpp Source File -- Sun Oct 12 2014 17:04:25 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation