wxArt2D
algos.cpp
1 /*! \file canvas/src/canglob.cpp
2  \author Klaas Holwerda
3 
4  Copyright: 2001-2004 (c) Klaas Holwerda
5 
6  Licence: wxWidgets Licence
7 
8  RCS-ID: $Id: algos.cpp,v 1.4 2009/09/03 20:09:53 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 <math.h>
22 #include <limits.h>
23 #include <float.h>
24 
25 #include <wx/wfstream.h>
26 
27 #include "wx/canvas/canglob.h"
28 #include "wx/canvas/algos.h"
29 #include "wx/canvas/layerinf.h"
30 #include "wx/canvas/canobj.h"
31 #include "wx/canvas/canprim.h"
32 #include "wx/canvas/drawer.h"
33 #include "wx/artbase/afmatrix.h"
34 #include "wx/artbase/drawer2d.h"
35 
36 
39 
40 //----------------------------------------------------------------------------
41 // a2dDumpWalker
42 //----------------------------------------------------------------------------
43 
44 
46 {
47  Initialize();
48 }
49 
50 a2dDumpWalker::~a2dDumpWalker()
51 {
52 }
53 
55 {
56 }
57 
59 {
60  object->Walker( NULL, *this );
61  return true;
62 }
63 
64 bool a2dDumpWalker::WalkTask( wxObject* parent, wxObject* object, a2dWalkEvent event )
65 {
66  if ( event == a2dWalker_a2dCanvasObjectStart )
67  {
68  // a2dCanvasObject* parentobj = (a2dCanvasObject*) parent;
69  a2dCanvasObject* canobj = ( a2dCanvasObject* ) object;
70  if ( canobj->GetChildObjectList() != wxNullCanvasObjectList )
71  {
73  {
74  //a2dCanvasObject *obj = (*iter);
75 
76  }
77  }
78  }
79 
80  if ( event == a2dWalker_a2dPropertyStart )
81  {
82  if ( wxDynamicCast( object, a2dObject ) )
83  wxLogDebug( _T( "%s" ), wxDynamicCast( object, a2dObject )->GetName().c_str() );
84  }
85 
86  if ( event == a2dWalker_a2dNamedPropertyStart )
87  {
88  if ( wxDynamicCast( object, a2dNamedProperty ) )
89  wxLogDebug( _T( "%s" ), wxDynamicCast( object, a2dNamedProperty )->GetName().c_str() );
90 
91  }
92 
94  return false; //do not go here
95 
96  return true;
97 }
98 
99 //----------------------------------------------------------------------------
100 // a2dWalker_CallMemberFunc
101 //----------------------------------------------------------------------------
102 
103 
104 a2dWalker_CallMemberFunc::a2dWalker_CallMemberFunc()
105 {
106  SetDepthFirst( true );
107  Initialize();
108 }
109 
110 a2dWalker_CallMemberFunc::~a2dWalker_CallMemberFunc()
111 {
112 }
113 
114 bool a2dWalker_CallMemberFunc::Start( a2dObject* object, a2dCanvasObjectFunc func )
115 {
116  m_func = func;
117  object->Walker( NULL, *this );
118  return true;
119 }
120 
121 bool a2dWalker_CallMemberFunc::WalkTask( wxObject* parent, wxObject* object, a2dWalkEvent event )
122 {
123  if ( event == a2dWalker_a2dCanvasObjectStart )
124  {
125  a2dCanvasObject* canobj = ( a2dCanvasObject* ) object;
126  ( canobj->*( ( a2dCanvasObjectFunc ) ( m_func ) ) )();
127  }
128 
129  if ( event == a2dWalker_a2dCanvasObjectPostChild )
130  return false; //do not go here
131 
132  return true;
133 }
134 
135 //----------------------------------------------------------------------------
136 // a2dWalker_CallMemberFuncW
137 //----------------------------------------------------------------------------
138 
139 a2dWalker_CallMemberFuncW::a2dWalker_CallMemberFuncW()
140 {
141  Initialize();
142 }
143 
144 a2dWalker_CallMemberFuncW::~a2dWalker_CallMemberFuncW()
145 {
146 }
147 
148 bool a2dWalker_CallMemberFuncW::Start( a2dObject* object, a2dCanvasObjectFuncW func )
149 {
150  m_func = func;
151  object->Walker( NULL, *this );
152  return true;
153 }
154 
155 bool a2dWalker_CallMemberFuncW::WalkTask( wxObject* parent, wxObject* object, a2dWalkEvent event )
156 {
157  m_currentParent = parent;
158 
159  if ( event == a2dWalker_a2dCanvasObjectStart )
160  {
161  a2dCanvasObject* canobj = ( a2dCanvasObject* ) object;
162  ( canobj->*( ( a2dCanvasObjectFuncW ) ( m_func ) ) )( this );
163  }
164 
165  if ( event == a2dWalker_a2dCanvasObjectPostChild )
166  return false; //do not go here
167 
168  return true;
169 }
170 
171 //----------------------------------------------------------------------------
172 // a2dWalker_SetAvailable
173 //----------------------------------------------------------------------------
174 
175 a2dWalker_SetAvailable::a2dWalker_SetAvailable( a2dLayers* layerSetup )
176 {
177  Initialize();
178  m_layerSetup = layerSetup;
179  m_drawingPart = NULL;
180 }
181 
182 a2dWalker_SetAvailable::a2dWalker_SetAvailable( a2dDrawingPart* drawingPart )
183 {
184  Initialize();
185  m_layerSetup = NULL;
186  m_drawingPart = drawingPart;
187 }
188 
189 a2dWalker_SetAvailable::~a2dWalker_SetAvailable()
190 {
191 }
192 
194 {
195  object->Walker( NULL, *this );
196  return true;
197 }
198 
199 bool a2dWalker_SetAvailable::WalkTask( wxObject* parent, wxObject* object, a2dWalkEvent event )
200 {
201  bool foundfirst = false;
202 
203  if ( event == a2dWalker_a2dCanvasObjectStart )
204  {
205  a2dCanvasObject* canobj = ( a2dCanvasObject* ) object;
206  if ( m_drawingPart )
207  m_drawingPart->GetLayerRenderArray()[ canobj->GetLayer() ].SetAvailable( true );
208  if ( m_layerSetup )
209  m_layerSetup->GetLayerIndex()[ canobj->GetLayer() ]->SetAvailable( true );
210  // wxLogDebug( "available layer %d", obj->GetLayer() );
211  }
212 
213  if ( event == a2dWalker_a2dCanvasObjectPostChild )
214  return false; //do not go here
215 
216  return true;
217 }
218 
219 //----------------------------------------------------------------------------
220 // a2dWalker_RemoveProperty
221 //----------------------------------------------------------------------------
222 
224 {
225  m_all = all;
226 }
227 
229 {
230  m_propertyList.push_back( ( a2dPropertyId* ) &id );
231  m_all = all;
232 }
233 
235 {
236  m_propertyList = idList;
237  m_all = all;
238 }
239 
240 a2dWalker_RemoveProperty::~a2dWalker_RemoveProperty()
241 {
242 }
243 
245 {
246  m_propertyList.push_back( id );
247 }
248 
249 
251 {
252  object->Walker( NULL, *this );
253  return m_result;
254 }
255 
256 bool a2dWalker_RemoveProperty::WalkTask( wxObject* parent, wxObject* object, a2dWalkEvent event )
257 {
258  if ( event == a2dWalker_a2dPropertyStart )
259  {
260  SetStopWalking( true );
261  if ( wxDynamicCast( object, a2dObject ) )
262  {
263  a2dObject* propobj = wxDynamicCast( object, a2dObject );
265  {
266  a2dPropertyId* id = *iter;
267  m_result |= propobj->RemoveProperty( id, m_all );
268  }
269  }
270  }
271  if ( event == a2dWalker_a2dPropertyEnd )
272  SetStopWalking( false );
273 
274  if ( event == a2dWalker_a2dCanvasObjectPostChild )
275  return false; //do not go here
276 
277  return true;
278 }
279 
280 
281 //----------------------------------------------------------------------------
282 // a2dWalker_RemovePropertyCandoc
283 //----------------------------------------------------------------------------
284 
286 {
287  m_all = all;
288  m_mask = mask;
289  m_makePending = false;
290 }
291 
293 {
294  m_propertyList.push_back( id );
295  m_all = all;
296  m_mask = mask;
297  m_makePending = false;
298 }
299 
301 {
302  m_propertyList = idList;
303  m_all = all;
304  m_mask = mask;
305  m_makePending = false;
306 }
307 
308 a2dWalker_RemovePropertyCandoc::~a2dWalker_RemovePropertyCandoc()
309 {
310 }
311 
313 {
314  m_propertyList.push_back( id );
315 }
316 
317 
319 {
320  object->Walker( NULL, *this );
321  return m_result;
322 }
323 
324 bool a2dWalker_RemovePropertyCandoc::WalkTask( wxObject* parent, wxObject* object, a2dWalkEvent event )
325 {
326  if ( event == a2dWalker_a2dPropertyStart )
327  SetStopWalking( true );
328 
329  if ( event == a2dWalker_a2dCanvasObjectStart )
330  {
331  a2dCanvasObject* propobj = wxDynamicCast( object, a2dCanvasObject );
332  if ( propobj && propobj->CheckMask( m_mask ) )
333  {
335  {
336  a2dPropertyId* id = *iter;
337  //propobj->RemoveProperty( *id, m_all );
338  bool res = propobj->RemoveProperty( id, m_all );
339  m_result |= res;
340  if ( res && m_makePending )
341  propobj->SetPending( true );
342  }
343  }
344  }
345  if ( event == a2dWalker_a2dPropertyEnd )
346  SetStopWalking( false );
347 
348  if ( event == a2dWalker_a2dCanvasObjectPostChild )
349  return false; //do not go here
350 
351  return true;
352 }
353 
354 //----------------------------------------------------------------------------
355 // a2dWalker_FilterCanvasObjects
356 //----------------------------------------------------------------------------
357 
359 {
360  Initialize();
361 
362  m_mask = mask;
363 }
364 
366 {
367  Initialize();
368 
369  m_propertyList.push_back( ( a2dPropertyId* ) &id );
370  m_mask = mask;
371 }
372 
374 {
375  Initialize();
376 
377  m_propertyList = idList;
378  m_mask = mask;
379  m_result = false;
380 }
381 
382 a2dWalker_FilterCanvasObjects::~a2dWalker_FilterCanvasObjects()
383 {
384 }
385 
387 {
390  m_skipStartObject = false;
391  m_depth = INT_MAX;
394  m_allowClassList = true;
395  m_classnameMap.clear();
396  m_objectname = wxT( "" );
397  m_id = -1;
398  m_layervisible = false;
399  m_layerselectable = false;
400  m_propertyList.clear();
401 }
402 
404 {
405  m_propertyList.push_back( ( a2dPropertyId* ) &id );
406 }
407 
408 
410 {
411  object->Walker( NULL, *this );
412  return m_result;
413 }
414 
416 {
417  if ( m_classnameMap.find( className ) == m_classnameMap.end() )
418  m_classnameMap.insert( className );
419 }
420 
422 {
423  if ( m_classnameMap.find( className ) != m_classnameMap.end() )
424  m_classnameMap.erase( m_classnameMap.find( className ) );
425 }
426 
428 {
429  if ( obj &&
430  ( m_objectname.IsEmpty() || m_objectname.Matches( obj->GetName() ) ) &&
431  ( m_id == -1 || obj->GetUniqueSerializationId() == m_id ) &&
432  obj->CheckMask( m_mask )
433  )
434  {
435  if ( m_layervisible && m_layerselectable && obj->GetRoot() && obj->GetRoot()->GetLayerSetup() )
436  {
437  if ( m_layervisible && !obj->GetRoot()->GetLayerSetup()->GetVisible( obj->GetLayer() ) )
438  return false;
439  if ( m_layerselectable && !obj->GetRoot()->GetLayerSetup()->GetSelectable( obj->GetLayer() ) )
440  return false;
441  }
442 
443  if ( m_bbox.GetValid() && ( m_bbox.Intersect( obj->GetBbox() ) & m_intersectionCondition ) == 0 )
444  return false;
445 
446  if ( m_propertyList.size() )
447  {
449  {
450  a2dPropertyId* id = *iter;
451  if ( !obj->HasProperty( id ) )
452  return false;
453  }
454  }
455  return true;
456  }
457  return false;
458 }
459 
461 {
462  if ( ! m_classnameMap.empty() )
463  {
464  if ( !m_allowClassList )
465  {
466  // if class is in list, that is a non wanted object
467  if ( m_classnameMap.find( obj->GetClassInfo()->GetClassName() ) != m_classnameMap.end() )
468  return false;
469  else
470  return true;
471  }
472  else
473  {
474  // if class is NOT in list, that is a non wanted object
475  if ( m_classnameMap.find( obj->GetClassInfo()->GetClassName() ) == m_classnameMap.end() )
476  return false;
477  else
478  return true;
479  }
480  }
481  return true;
482 }
483 
485 {
486  a2dCanvasObjectList* ret = canvasobject->GetAsPolygons( true );
487  if ( ret != wxNullCanvasObjectList )
488  return ret;
489  return NULL;
490 }
491 
493 {
495 
496  if ( wxDynamicCast( canvasobject, a2dRect ) ||
497  wxDynamicCast( canvasobject, a2dRectC ) ||
498  wxDynamicCast( canvasobject, a2dArrow ) ||
499  wxDynamicCast( canvasobject, a2dCircle ) ||
500  wxDynamicCast( canvasobject, a2dEllipse ) ||
501  wxDynamicCast( canvasobject, a2dEllipticArc ) ||
502  wxDynamicCast( canvasobject, a2dArc ) ||
503  wxDynamicCast( canvasobject, a2dPolygonL ) ||
504  wxDynamicCast( canvasobject, a2dVectorPath ) ||
505  wxDynamicCast( canvasobject, a2dText ) ||
506  wxDynamicCast( canvasobject, a2dEndsLine ) ||
507  wxDynamicCast( canvasobject, a2dSLine ) ||
508  wxDynamicCast( canvasobject, a2dPolylineL )
509  )
510  {
511  vpath = canvasobject->GetAsCanvasVpaths( transform );
512  }
513  return vpath;
514 }
515 
516 
517 //----------------------------------------------------------------------------
518 // a2dWalker_CollectCanvasObjects
519 //----------------------------------------------------------------------------
520 
523 {
524  Initialize();
525 
526  m_mask = mask;
527 }
528 
530  : a2dWalker_FilterCanvasObjects( id, mask )
531 {
532  Initialize();
533 
534  m_mask = mask;
535 }
536 
538  : a2dWalker_FilterCanvasObjects( idList, mask )
539 {
540  Initialize();
541 
542  m_propertyList = idList;
543  m_mask = mask;
544 }
545 
546 a2dWalker_CollectCanvasObjects::~a2dWalker_CollectCanvasObjects()
547 {
548 }
549 
551 {
553  m_found.clear();
554 }
555 
556 bool a2dWalker_CollectCanvasObjects::WalkTask( wxObject* parent, wxObject* object, a2dWalkEvent event )
557 {
558 
560  SetStopWalking( true );
561 
562  if ( event == a2dWalker_a2dCanvasObjectStart )
563  {
565  if ( obj && ObjectOke( obj ) && ClassOfObjectOke( obj ) )
566  {
567  m_found.push_back( obj );
568  m_result = true;
569  }
570  }
571 
572  if ( m_currentDepth < m_depth && event == a2dWalker_a2dPropertyEnd )
573  SetStopWalking( false );
574 
575  if ( event == a2dWalker_a2dCanvasObjectPostChild )
576  return false; //do not go here
577 
578  return true;
579 }
580 
581 //----------------------------------------------------------------------------
582 // a2dWalker_CollectCanvasObjectsSet
583 //----------------------------------------------------------------------------
584 
586 {
587  a2dCanvasObject* firstc = wxStaticCast( x.Get(), a2dCanvasObject );
588  a2dCanvasObject* secondc = wxStaticCast( y.Get(), a2dCanvasObject );
589 
590  if ( firstc->GetName() < secondc->GetName() )
591  return true;
592  return false;
593 }
594 
596 {
597  a2dCanvasObject* firstc = wxStaticCast( x.Get(), a2dCanvasObject );
598  a2dCanvasObject* secondc = wxStaticCast( y.Get(), a2dCanvasObject );
599 
600  if ( firstc->GetName() > secondc->GetName() )
601  return true;
602  return false;
603 }
604 
606 {
607  a2dCanvasObject* firstc = wxStaticCast( x.Get(), a2dCanvasObject );
608  a2dCanvasObject* secondc = wxStaticCast( y.Get(), a2dCanvasObject );
609 
610  if ( firstc->GetChildObjectsCount() > secondc->GetChildObjectsCount() )
611  return true;
612  else if ( firstc->GetChildObjectsCount() == secondc->GetChildObjectsCount() )
613  return NameSorter( x, y );
614  return false;
615 }
616 
618 {
619  a2dCanvasObject* firstc = wxStaticCast( x.Get(), a2dCanvasObject );
620  a2dCanvasObject* secondc = wxStaticCast( y.Get(), a2dCanvasObject );
621 
622  if ( firstc->GetChildObjectsCount() < secondc->GetChildObjectsCount() )
623  return true;
624  else if ( firstc->GetChildObjectsCount() == secondc->GetChildObjectsCount() )
625  return NameSorter( x, y );
626  return false;
627 }
628 
631 {
632  Initialize();
633 
634  m_mask = mask;
635 }
636 
638  : a2dWalker_FilterCanvasObjects( id, mask )
639 {
640  Initialize();
641 
642  m_mask = mask;
643 }
644 
646  : a2dWalker_FilterCanvasObjects( idList, mask )
647 {
648  Initialize();
649 
650  m_propertyList = idList;
651  m_mask = mask;
652 }
653 
654 a2dWalker_CollectCanvasObjectsSet::~a2dWalker_CollectCanvasObjectsSet()
655 {
656 }
657 
659 {
661  m_found.clear();
662  m_childs = false;
663  m_sortOn = onName;
664 }
665 
666 bool a2dWalker_CollectCanvasObjectsSet::Start( a2dCanvasObject* object )
667 {
668  switch ( m_sortOn )
669  {
670  case onName: s_a2dCanvasObjectSorter = &NameSorter; break;
671  case onNameReverse: s_a2dCanvasObjectSorter = &NameSorterReverse; break;
672  case onNrChilds: s_a2dCanvasObjectSorter = &OnNrChilds; break;
673  case onNrChildsReverse: s_a2dCanvasObjectSorter = &OnNrChildsReverse; break;
674  }
675 
676  object->Walker( NULL, *this );
677  return m_result;
678 }
679 
680 bool a2dWalker_CollectCanvasObjectsSet::WalkTask( wxObject* parent, wxObject* object, a2dWalkEvent event )
681 {
682 
684  SetStopWalking( true );
685 
686  if ( event == a2dWalker_a2dCanvasObjectStart )
687  {
689  if ( obj && ObjectOke( obj ) && ClassOfObjectOke( obj ) &&
690  ( !m_childs || ( m_childs && ( obj->GetChildObjectList() != wxNullCanvasObjectList ) ) ) )
691  {
692  if ( m_found.find( obj ) == m_found.end() )
693  m_found.insert( obj );
694  m_result = true;
695  }
696  }
697 
698  if ( m_currentDepth < m_depth && event == a2dWalker_a2dPropertyEnd )
699  SetStopWalking( false );
700 
701  if ( event == a2dWalker_a2dCanvasObjectPostChild )
702  return false; //do not go here
703 
704  return true;
705 }
706 
707 //----------------------------------------------------------------------------
708 // a2dWalker_FindCanvasObject
709 //----------------------------------------------------------------------------
710 
713 {
714  Initialize();
715  m_search = search;
716 }
717 
718 
719 a2dWalker_FindCanvasObject::~a2dWalker_FindCanvasObject()
720 {
721 }
722 
724 {
726  m_search = 0;
727 }
728 
729 bool a2dWalker_FindCanvasObject::WalkTask( wxObject* parent, wxObject* object, a2dWalkEvent event )
730 {
731  if ( event == a2dWalker_a2dCanvasObjectStart )
732  {
734  if ( obj == m_search )
735  {
736  SetStopWalking( true );
737  m_result = true;
738  }
739  }
740 
741  if ( event == a2dWalker_a2dCanvasObjectPostChild )
742  return false; //do not go here
743 
744  return true;
745 }
746 
747 bool a2dWalker_FindCanvasObject::Start( a2dCanvasObject* object )
748 {
749  m_result = false;
750  object->Walker( NULL, *this );
751  return m_result;
752 }
753 
754 
755 //----------------------------------------------------------------------------
756 // a2dWalker_SetSpecificFlagsCanvasObjects
757 //----------------------------------------------------------------------------
758 
761 {
762  m_which = which;
763  Initialize();
764 }
765 
767  : a2dWalker_FilterCanvasObjects( id, mask )
768 {
769  m_which = which;
770  Initialize();
771 }
772 
774  : a2dWalker_FilterCanvasObjects( idList, mask )
775 {
776  m_which = which;
777  Initialize();
778 }
779 
780 a2dWalker_SetSpecificFlagsCanvasObjects::~a2dWalker_SetSpecificFlagsCanvasObjects()
781 {
782 }
783 
785 {
786  if ( !object )
787  return false;
788  m_setOrClear = setTo;
789  object->Walker( NULL, *this );
790  return m_result;
791 }
792 
794 {
796 }
797 
798 bool a2dWalker_SetSpecificFlagsCanvasObjects::WalkTask( wxObject* parent, wxObject* object, a2dWalkEvent event )
799 {
800 
802  SetStopWalking( true );
803 
804  if ( event == a2dWalker_a2dCanvasObjectStart )
805  {
808  if ( obj && ObjectOke( obj ) && ClassOfObjectOke( obj ) )
809  {
811  m_result = true;
812  }
813  }
814 
815  if ( m_currentDepth < m_depth && event == a2dWalker_a2dPropertyEnd )
816  SetStopWalking( false );
817 
818  if ( event == a2dWalker_a2dCanvasObjectPostChild )
819  return false; //do not go here
820 
821  return true;
822 }
823 
824 
826 {
827  m_property = prop;
828  Initialize();
829 }
830 
831 a2dWalker_SetPropertyToObject::~a2dWalker_SetPropertyToObject()
832 {
833 }
834 
836 {
838 }
839 
840 bool a2dWalker_SetPropertyToObject::WalkTask( wxObject* parent, wxObject* object, a2dWalkEvent event )
841 {
842  if ( event == a2dWalker_a2dCanvasObjectStart )
843  {
846  }
847 
848  if ( event == a2dWalker_a2dCanvasObjectPostChild )
849  return false; //do not go here
850 
851  return true;
852 }
853 
854 
855 //----------------------------------------------------------------------------
856 // a2dWalker_SetViewDependent
857 //----------------------------------------------------------------------------
858 
859 a2dWalker_SetViewDependent::a2dWalker_SetViewDependent( a2dDrawingPart* aView, bool viewdependent, bool viewspecific, bool onlyinternalarea )
860 {
861  m_drawingPart = aView;
862  m_viewdependent = viewdependent;
863  m_viewspecific = viewspecific;
864  m_onlyinternalarea = onlyinternalarea;
865 }
866 
868 {
869 }
870 
872 {
874 }
875 
876 bool a2dWalker_SetViewDependent::WalkTask( wxObject* parent, wxObject* object, a2dWalkEvent event )
877 {
878  if ( event == a2dWalker_a2dCanvasObjectStart )
879  {
882  }
883 
884  if ( event == a2dWalker_a2dCanvasObjectPostChild )
885  return false; //do not go here
886 
887  return true;
888 }
889 
890 bool a2dWalker_SetViewDependent::Start( a2dCanvasObject* object )
891 {
892  object->Walker( NULL, *this );
893  return true;
894 }
895 
896 
897 //----------------------------------------------------------------------------
898 // a2dWalker_SetRoot
899 //----------------------------------------------------------------------------
900 IMPLEMENT_CLASS( a2dWalker_SetRoot, a2dWalkerIOHandler )
901 
903 {
904  m_root = root;
905  m_skipNotRenderedInDrawing = true;
906 }
907 
908 a2dWalker_SetRoot::~a2dWalker_SetRoot()
909 {
910 }
911 
912 bool a2dWalker_SetRoot::WalkTask( wxObject* parent, wxObject* object, a2dWalkEvent event )
913 {
914  if ( event == a2dWalker_a2dCanvasObjectStart )
915  {
917  a2dDrawing* drawingInDrawing = wxDynamicCast( object, a2dDrawing );
918  if ( drawingInDrawing && drawingInDrawing != m_root )
919  //here we start a new walker, with the root of the found drawing.
920  drawingInDrawing->SetRootRecursive();
921  else
922  obj->SetRoot( m_root, false );
923  }
924 
925  if ( event == a2dWalker_a2dCanvasObjectPostChild )
926  return false; //do not go here
927 
928  return true;
929 }
930 
932 {
933  object->Walker( NULL, *this );
934  return true;
935 }
936 
937 //----------------------------------------------------------------------------
938 // a2dWalker_MakeTree
939 //----------------------------------------------------------------------------
940 
943 {
944  Initialize();
945  m_mask = mask;
946 }
947 
949  : a2dWalker_FilterCanvasObjects( id, mask )
950 {
951  Initialize();
952  m_mask = mask;
953 }
954 
956  : a2dWalker_FilterCanvasObjects( idList, mask )
957 {
958  Initialize();
959 }
960 
961 a2dWalker_MakeTree::~a2dWalker_MakeTree()
962 {
963 }
964 
966 {
967  a2dWalker_SetCheck setp( false );
968  setp.Start( object );
969 
970  object->Walker( NULL, *this );
971  return true;
972 }
973 
975 {
977  m_useCheck = true;
978  m_depthFirst = true;
979  m_firstLevelChild = false;
980 }
981 
982 bool a2dWalker_MakeTree::WalkTask( wxObject* parent, wxObject* object, a2dWalkEvent event )
983 {
984  if ( m_currentDepth > m_depth )
985  SetStopWalking( true );
986  else
987  SetStopWalking( false );
988 
989  if ( event == a2dWalker_a2dObjectStart )
990  {
991  //wxLogDebug(_T("a2dobj start %s"), wxDynamicCast( object, a2dObject )->GetName() );
993  if ( obj && m_currentDepth == 2 && ObjectOke( obj ) && ClassOfObjectOke( obj ) && !obj->GetCheck() )
994  {
995  m_firstLevelChild = true;
996  obj->SetCheck( true );
997  }
998  }
999 
1000  if ( event == a2dWalker_a2dCanvasObjectEnd )
1001  {
1002  a2dCanvasObject* obj = wxDynamicCast( object, a2dCanvasObject );
1003  //wxLogDebug( wxT( "classname = %s" ), obj->GetClassInfo()->GetClassName().c_str() );
1004  //wxLogDebug( wxT( "name = %s" ), obj->GetName().c_str() );
1005 
1006  if ( obj && m_firstLevelChild )
1007  {
1009  {
1011  if ( arrayref->GetCanvasObject() )
1012  {
1013  a2dAffineMatrix offsetXY;
1014  int i, j;
1015  for ( i = 0 ; i < arrayref->GetRows(); i++ )
1016  {
1017  for ( j = 0 ; j < arrayref->GetColumns(); j++ )
1018  {
1019  a2dCanvasObjectPtr cobj = ( a2dCanvasObject* ) arrayref->GetCanvasObject()->Clone( clone_deep );
1020  cobj->SetRelease( false );
1021 
1022  obj->CreateChildObjectList()->push_back( cobj );
1023  cobj->Transform( offsetXY );
1024 
1025  offsetXY.Translate( arrayref->GetHorzSpace(), 0 );
1026  }
1027  //translate back (one row of columns) and add one row
1028  offsetXY.Translate( -arrayref->GetHorzSpace()*arrayref->GetColumns(), arrayref->GetVertSpace() );
1029  }
1030  arrayref->SetCanvasObject( NULL );
1031  }
1032  }
1033  else if ( wxDynamicCast( object, a2dCanvasObjectReference ) )
1034  {
1036 
1037  if ( ref->GetCanvasObject() )
1038  {
1039  obj->CreateChildObjectList()->push_back( ref->GetCanvasObject() );
1040  ref->SetCanvasObject( NULL );
1041  }
1042  }
1043 
1044  // references are now (must be) gone in derived objects.
1045  // There for the obj has only children at this stage.
1046  obj->MakeReferencesUnique();
1047  obj->SetCheck( true );
1048 
1049  }
1050  }
1051 
1052  if ( event == a2dWalker_a2dObjectEnd )
1053  {
1054  //wxLogDebug(_T("a2dobj end %s"), wxDynamicCast( object, a2dObject )->GetName().c_str() );
1055  if ( m_currentDepth <= 2 )
1056  {
1057  m_firstLevelChild = false;
1058  }
1059  }
1060 
1061  if ( m_currentDepth <= m_depth )
1062  SetStopWalking( false );
1063 
1064  if ( event == a2dWalker_a2dCanvasObjectPostChild )
1065  return false; //do not go here
1066 
1067  return true;
1068 }
1069 
1070 //----------------------------------------------------------------------------
1071 // a2dWalker_RemoveHierarchy
1072 //----------------------------------------------------------------------------
1073 
1076 {
1077  Initialize();
1078  m_mask = mask;
1079 }
1080 
1082  : a2dWalker_FilterCanvasObjects( id, mask )
1083 {
1084  Initialize();
1085  m_mask = mask;
1086 }
1087 
1089  : a2dWalker_FilterCanvasObjects( idList, mask )
1090 {
1091  Initialize();
1092 }
1093 
1094 a2dWalker_RemoveHierarchy::~a2dWalker_RemoveHierarchy()
1095 {
1096 }
1097 
1099 {
1100  a2dWalker_MakeTree unify( m_mask );
1101  unify.Start( object );
1102 
1103  a2dWalker_SetCheck setp( false );
1104  setp.Start( object );
1106  setflags.SetSkipNotRenderedInDrawing( true );
1107  setflags.Start( object, false );
1108 
1109  object->Walker( NULL, *this );
1110  return true;
1111 }
1112 
1114 {
1116  m_selected = true;
1117  m_useCheck = true;
1118  m_depthFirst = true;
1119  m_firstLevelChild = false;
1120 }
1121 
1122 bool a2dWalker_RemoveHierarchy::WalkTask( wxObject* parent, wxObject* object, a2dWalkEvent event )
1123 {
1124  if ( m_currentDepth > m_depth )
1125  SetStopWalking( true );
1126  else
1127  SetStopWalking( false );
1128 
1129  if ( event == a2dWalker_a2dObjectStart )
1130  {
1131  m_parentList.push_front( wxDynamicCast( object, a2dObject ) );
1132 
1133  //wxLogDebug(_T("a2dobj start %s"), wxDynamicCast( object, a2dObject )->GetName().c_str() );
1134 
1135  a2dCanvasObject* obj = wxDynamicCast( object, a2dCanvasObject );
1136  if ( obj && m_parentList.size() == 2 && ObjectOke( obj ) && ClassOfObjectOke( obj ) && !obj->GetCheck() )
1137  {
1138  m_firstLevelChild = true;
1139  obj->SetCheck( true );
1140  }
1141  }
1142 
1143  if ( event == a2dWalker_a2dCanvasObjectEnd )
1144  {
1145  a2dCanvasObject* parentobj = wxDynamicCast( parent, a2dCanvasObject );
1146  a2dCanvasObject* obj = wxDynamicCast( object, a2dCanvasObject );
1147 
1148  //wxLogDebug( wxT( "classname = %s" ), obj->GetClassInfo()->GetClassName().c_str() );
1149  //wxLogDebug( wxT( "name = %s" ), obj->GetName().c_str() );
1150 
1151  if ( obj && !obj->GetBin() && parentobj && m_firstLevelChild )
1152  {
1153  if ( wxDynamicCast( object, a2dCanvasObjectReference ) )
1154  {
1156  wxASSERT_MSG( ref->GetCanvasObject() == NULL, wxT( "No references allowed at this stage" ) );
1157  }
1158 
1160  {
1161  // release later on, since there is an iterator more on it in a2dCanvasObject::DoWalker()
1162  obj->SetRelease( true );
1163 
1164  a2dCanvasObjectList::iterator iter = obj->GetChildObjectList()->begin();
1165  while( iter != obj->GetChildObjectList()->end() )
1166  {
1167  a2dCanvasObjectList::value_type objchild = *iter;
1168  //iter++;
1169  iter = obj->GetChildObjectList()->erase( iter );
1170 
1171  if ( !objchild->GetRelease() )
1172  {
1173  a2dPin* pin = wxDynamicCast( objchild.Get(), a2dPin );
1174  if ( pin )
1175  pin->Disconnect( NULL );
1176 
1177  //parentobj->CreateChildObjectList()->insert( iterinserthere, obj );
1178  parentobj->CreateChildObjectList()->push_back( objchild );
1179  objchild->SetBin( true );
1180  objchild->SetParent( parentobj );
1181  objchild->Transform( obj->GetTransformMatrix() );
1182  objchild->SetSelected( m_selected );
1183  }
1184  }
1185  }
1186  }
1187  }
1188 
1189  if ( event == a2dWalker_a2dObjectEnd )
1190  {
1191  //wxLogDebug(_T("a2dobj end %s"), wxDynamicCast( object, a2dObject )->GetName().c_str() );
1192 
1193  m_parentList.pop_front();
1194  if ( m_parentList.size() < 2 )
1195  {
1196  m_firstLevelChild = false;
1197  }
1198  }
1199 
1200  if ( m_currentDepth <= m_depth )
1201  SetStopWalking( false );
1202 
1203  if ( event == a2dWalker_a2dCanvasObjectPostChild )
1204  return false; //do not go here
1205 
1206  return true;
1207 }
1208 
1209 //----------------------------------------------------------------------------
1210 // a2dWalker_LayerGroup
1211 //----------------------------------------------------------------------------
1212 
1215 {
1216  Initialize();
1217 }
1218 
1220  : a2dWalker_FilterCanvasObjects( id, mask )
1221 {
1222  Initialize();
1223 }
1224 
1226  : a2dWalker_FilterCanvasObjects( idList, mask )
1227 {
1228  Initialize();
1229 }
1230 
1232 {
1233 }
1234 
1236 {
1239  m_selectedOnlyA = false;
1240  m_selectedOnlyB = false;
1241 }
1242 
1243 void a2dWalker_LayerGroup::SetTarget( wxUint16 targetlayer )
1244 {
1245  wxASSERT_MSG( wxMAXLAYER > targetlayer , wxT( " targetlayer > wxMAXLAYER, index to high" ) );
1246  m_target = targetlayer;
1247 };
1248 
1250 {
1252  setflags.SetSkipNotRenderedInDrawing( true );
1253  setflags.Start( object, false );
1254 
1255  object->Walker( NULL, *this );
1256  return m_result;
1257 }
1258 
1259 //----------------------------------------------------------------------------
1260 // a2dWalker_LayerCanvasObjects
1261 //----------------------------------------------------------------------------
1262 
1276 
1278  : a2dWalker_LayerGroup( mask )
1279 {
1280  Initialize();
1281 }
1282 
1284  : a2dWalker_LayerGroup( id, mask )
1285 {
1286  Initialize();
1287 }
1288 
1289 
1291  : a2dWalker_LayerGroup( idList, mask )
1292 {
1293  Initialize();
1294 }
1295 
1297 {
1298 }
1299 
1301 {
1304  m_radiusMin = 0;
1305  m_radiusMax = DBL_MAX;
1306  m_detectCircle = false;
1307  m_calculatedArea = 0.0;
1308  m_AberPolyToArc = a2dCanvasGlobals->GetHabitat()->ACCUR();
1309 }
1310 
1311 bool a2dWalker_LayerCanvasObjects::WalkTask( wxObject* parent, wxObject* object, a2dWalkEvent event )
1312 {
1313  if ( m_currentDepth > m_depth )
1314  SetStopWalking( true );
1315  else
1316  SetStopWalking( false );
1317 
1318  if ( event == a2dWalker_a2dCanvasObjectStart )
1319  {
1320  a2dCanvasObject* parentobj = wxDynamicCast( parent, a2dCanvasObject );
1321  a2dCanvasObject* obj = wxDynamicCast( object, a2dCanvasObject );
1322  if ( obj && parentobj && !obj->GetIgnoreLayer() && !obj->GetBin() && ObjectOke( obj ) && ClassOfObjectOke( obj ) )
1323 
1324  {
1325  bool hasLayer = m_groupA.InGroup( obj->GetLayer() );
1326  if ( hasLayer && ( !m_selectedOnlyA || ( m_selectedOnlyA && obj->GetSelected() ) ) )
1327  {
1328  if ( m_operation == moveLayers )
1329  {
1330  obj->SetLayer( m_target );
1331  }
1332  else if ( m_operation == copyLayers )
1333  {
1334  a2dCanvasObject* cobj = obj->TClone( a2dObject::clone_deep );
1335  parentobj->Prepend( cobj );
1336  cobj->SetLayer( m_target );
1337  cobj->SetBin( true );
1338  }
1339  else if ( m_operation == deleteLayers )
1340  {
1341  parentobj->ReleaseChild( obj );
1342  }
1343  else if ( m_operation == ConvertToArcs )
1344  {
1345  if ( 0 != wxDynamicCast( obj, a2dPolylineL ) && obj->GetContourWidth() )
1346  {
1347  a2dPolylineL* objc = wxDynamicCast( obj, a2dPolylineL );
1348  bool returnIsPolygon;
1349  a2dPolygonL* contour = new a2dPolygonL( objc->GetAsVertexList( returnIsPolygon ) );
1350  contour->SetLayer( m_target );
1351  contour->SetBin( true );
1352  //contour->GetSegments()->ConvertPolylineToArc( m_AberPolyToArc, m_radiusMin, m_radiusMax );
1353  parentobj->Append( contour );
1354  }
1355  }
1357  {
1358  if ( 0 != wxDynamicCast( obj, a2dPolygonL ) )
1359  {
1360  a2dCanvasObject* cobj = obj->TClone( a2dObject::clone_deep );
1361  cobj->SetLayer( m_target );
1362  cobj->SetBin( true );
1363  a2dPolygonL* objc = wxDynamicCast( cobj, a2dPolygonL );
1364  objc->GetSegments()->ConvertPolygonToArc( m_AberPolyToArc, m_radiusMin, m_radiusMax );
1365  a2dPoint2D middle;
1366  double radius;
1367  if ( m_detectCircle && objc->GetSegments()->CheckForOneCircle( middle, radius ) )
1368  {
1369  a2dCircle* cir = new a2dCircle( middle.m_x, middle.m_y, radius );
1370  cir->Transform( obj->GetTransformMatrix() );
1371  cir->SetLayer( m_target );
1372  cir->SetBin( true );
1373  parentobj->Prepend( cir );
1374  delete cobj;
1375  }
1376  else
1377  parentobj->Prepend( cobj );
1378  }
1379  }
1380  else if ( m_operation == ConvertPolylineToArcs )
1381  {
1382  if ( 0 != wxDynamicCast( obj, a2dPolylineL ) && obj->GetContourWidth() )
1383  {
1384  a2dCanvasObject* cobj = obj->TClone( a2dObject::clone_deep );
1385  a2dPolylineL* objc = wxDynamicCast( cobj, a2dPolylineL );
1386  cobj->SetLayer( m_target );
1387  cobj->SetBin( true );
1388  parentobj->Prepend( cobj );
1390  }
1391  else if ( 0 != wxDynamicCast( obj, a2dPolylineL ) )
1392  {
1393  a2dCanvasObject* cobj = obj->TClone( a2dObject::clone_deep );
1394  cobj->SetLayer( m_target );
1395  cobj->SetBin( true );
1396  parentobj->Prepend( cobj );
1397  a2dPolylineL* objc = wxDynamicCast( cobj, a2dPolylineL );
1399  }
1400  }
1402  {
1403  a2dCanvasObjectList* polylist = ConvertToPolygons( obj, true );
1404  for( a2dCanvasObjectList::iterator iterp = polylist->begin(); iterp != polylist->end(); ++iterp )
1405  {
1406  a2dPolygonL* poly = wxDynamicCast( ( *iterp ).Get(), a2dPolygonL );
1407  a2dPolylineL* polyline = wxDynamicCast( ( *iterp ).Get(), a2dPolylineL );
1408  if ( poly && poly->GetNumberOfSegments() > 2 )
1409  {
1410  poly->SetLayer( m_target );
1411  poly->SetBin( true );
1412  parentobj->Prepend( poly );
1413  }
1414  else if ( polyline && polyline->GetNumberOfSegments() > 2 )
1415  {
1416  polyline->SetLayer( m_target );
1417  polyline->SetBin( true );
1418  parentobj->Prepend( polyline );
1419  }
1420  }
1421  delete polylist;
1422  }
1424  {
1425  a2dCanvasObjectList* polylist = ConvertToPolygons( obj, true );
1426  for( a2dCanvasObjectList::iterator iterp = polylist->begin(); iterp != polylist->end(); ++iterp )
1427  {
1428  a2dPolygonL* poly = wxDynamicCast( ( *iterp ).Get(), a2dPolygonL );
1429  a2dPolylineL* polyline = wxDynamicCast( ( *iterp ).Get(), a2dPolylineL );
1430  if ( poly && poly->GetNumberOfSegments() > 2 )
1431  {
1432  poly->SetLayer( m_target );
1433  poly->SetBin( true );
1434  poly->GetSegments()->ConvertToLines();
1435  parentobj->Prepend( poly );
1436  }
1437  else if ( polyline && polyline->GetNumberOfSegments() > 2 )
1438  {
1439  polyline->SetLayer( m_target );
1440  polyline->SetBin( true );
1441  polyline->GetSegments()->ConvertToLines();
1442  parentobj->Prepend( polyline );
1443  }
1444  }
1445  delete polylist;
1446  }
1447  else if ( m_operation == ConvertToVPaths )
1448  {
1449  a2dCanvasObjectList* vpath = ConvertToVpath( obj, true );
1450  for( a2dCanvasObjectList::iterator iterp = vpath->begin(); iterp != vpath->end(); ++iterp )
1451  {
1452  a2dVectorPath* path = wxDynamicCast( ( *iterp ).Get(), a2dVectorPath );
1453  path->SetLayer( m_target );
1454  path->SetBin( true );
1455  parentobj->Prepend( path );
1456  }
1457  delete vpath;
1458  }
1459  else if ( m_operation == ConvertToPolylines )
1460  {
1461  a2dCanvasObjectList* polylist = obj->GetAsPolylines( true );
1462  if ( polylist != wxNullCanvasObjectList )
1463  {
1464  int i, count = polylist->size();
1465  a2dCanvasObjectList::iterator iterp = polylist->begin();
1466  for( i = 0 ; i < count ; i++ )
1467  {
1468  a2dPolygonL* poly = wxDynamicCast( ( *iterp ).Get(), a2dPolygonL );
1469  a2dPolylineL* polyline = wxDynamicCast( ( *iterp ).Get(), a2dPolylineL );
1470  if ( poly && poly->GetNumberOfSegments() > 2 )
1471  {
1472  a2dPolylineL* conv = new a2dPolylineL( poly->GetSegments() );
1473 
1474  conv->SetLayer( m_target );
1475  conv->SetBin( true );
1476  parentobj->Prepend( conv );
1477  iterp = polylist->erase( iterp );
1478  }
1479  else if ( polyline && polyline->GetNumberOfSegments() > 2 )
1480  {
1481  polyline->SetLayer( m_target );
1482  polyline->SetBin( true );
1483  parentobj->Prepend( polyline );
1484  iterp++;
1485  }
1486  }
1487  delete polylist;
1488  }
1489  }
1490  else if ( m_operation == ConvertLinesArcs )
1491  {
1492  a2dCanvasObjectList* polylist = ConvertToPolygons( obj, true );
1493  int i, count = polylist->size();
1494  a2dCanvasObjectList::iterator iterp = polylist->begin();
1495  for( i = 0 ; i < count ; i++ )
1496  {
1497  a2dPolygonL* poly = wxDynamicCast( ( *iterp ).Get(), a2dPolygonL );
1498  poly->SetLayer( m_target );
1499  poly->SetBin( true );
1500  a2dCanvasObjectList* linesAndArcs = poly->GetAsLinesArcs();
1501  for( a2dCanvasObjectList::iterator iterl = linesAndArcs->begin(); iterl != linesAndArcs->end(); ++iterl )
1502  parentobj->Prepend( *iterl );
1503  iterp = polylist->erase( iterp );
1504  delete linesAndArcs;
1505  }
1506  delete polylist;
1507  }
1508  else if ( m_operation == RemoveRedundant )
1509  {
1510  if ( 0 != wxDynamicCast( obj, a2dPolylineL ) )
1511  {
1512  a2dPolylineL* cobj = wxDynamicCast( obj, a2dPolylineL );
1513  cobj->GetSegments()->RemoveRedundant( false );
1514  cobj->SetLayer( m_target );
1515  cobj->SetBin( true );
1516  }
1517  else if ( 0 != wxDynamicCast( obj, a2dPolygonL ) )
1518  {
1519  a2dPolygonL* cobj = wxDynamicCast( obj, a2dPolygonL );
1520  cobj->GetSegments()->RemoveRedundant( true );
1521  cobj->SetLayer( m_target );
1522  cobj->SetBin( true );
1523  }
1524  }
1525  else if ( m_operation == areaLayers )
1526  {
1527  AddArea( obj );
1528  }
1529  m_result = true;
1530  }
1531  }
1532  }
1533 
1534  if ( m_currentDepth <= m_depth )
1535  SetStopWalking( false );
1536 
1537  if ( event == a2dWalker_a2dCanvasObjectPostChild )
1538  return false; //do not go here
1539 
1540  return true;
1541 }
1542 
1543 void a2dWalker_LayerCanvasObjects::AddArea( a2dCanvasObject* getAsPolyObject )
1544 {
1546 
1547  if ( 0 != wxDynamicCast( getAsPolyObject, a2dRect ) )
1548  {
1549  a2dRect* obj = wxDynamicCast( getAsPolyObject, a2dRect );
1550  vpath = obj->GetAsCanvasVpaths();
1551  }
1552  else if ( 0 != wxDynamicCast( getAsPolyObject, a2dRectC ) )
1553  {
1554  a2dRectC* obj = wxDynamicCast( getAsPolyObject, a2dRectC );
1555  vpath = obj->GetAsCanvasVpaths();
1556  }
1557  else if ( 0 != wxDynamicCast( getAsPolyObject, a2dArrow ) )
1558  {
1559  a2dArrow* obj = wxDynamicCast( getAsPolyObject, a2dArrow );
1560  vpath = obj->GetAsCanvasVpaths();
1561  }
1562  else if ( 0 != wxDynamicCast( getAsPolyObject, a2dCircle ) )
1563  {
1564  a2dCircle* obj = wxDynamicCast( getAsPolyObject, a2dCircle );
1565  vpath = obj->GetAsCanvasVpaths();
1566  }
1567  else if ( 0 != wxDynamicCast( getAsPolyObject, a2dEllipse ) )
1568  {
1569  a2dEllipse* obj = wxDynamicCast( getAsPolyObject, a2dEllipse );
1570  vpath = obj->GetAsCanvasVpaths();
1571  }
1572  else if ( 0 != wxDynamicCast( getAsPolyObject, a2dEllipticArc ) )
1573  {
1574  a2dEllipticArc* obj = wxDynamicCast( getAsPolyObject, a2dEllipticArc );
1575  vpath = obj->GetAsCanvasVpaths();
1576  }
1577  else if ( 0 != wxDynamicCast( getAsPolyObject, a2dArc ) )
1578  {
1579  a2dArc* obj = wxDynamicCast( getAsPolyObject, a2dArc );
1580  vpath = obj->GetAsCanvasVpaths();
1581  }
1582  else if ( 0 != wxDynamicCast( getAsPolyObject, a2dEndsLine ) && getAsPolyObject->GetContourWidth() )
1583  {
1584  a2dEndsLine* obj = wxDynamicCast( getAsPolyObject, a2dEndsLine );
1585  vpath = obj->GetAsCanvasVpaths();
1586  }
1587  else if ( 0 != wxDynamicCast( getAsPolyObject, a2dSLine ) && getAsPolyObject->GetContourWidth() )
1588  {
1589  a2dSLine* obj = wxDynamicCast( getAsPolyObject, a2dSLine );
1590  vpath = obj->GetAsCanvasVpaths();
1591  }
1592  else if ( 0 != wxDynamicCast( getAsPolyObject, a2dPolylineL ) && getAsPolyObject->GetContourWidth() )
1593  {
1594  a2dPolylineL* obj = wxDynamicCast( getAsPolyObject, a2dPolylineL );
1595  vpath = obj->GetAsCanvasVpaths();
1596  }
1597  else if ( 0 != wxDynamicCast( getAsPolyObject, a2dPolygonL ) )
1598  {
1599  a2dPolygonL* obj = wxDynamicCast( getAsPolyObject, a2dPolygonL );
1600  vpath = obj->GetAsCanvasVpaths();
1601  }
1602  else if ( 0 != wxDynamicCast( getAsPolyObject, a2dVectorPath ) )
1603  {
1604  a2dVectorPath* obj = wxDynamicCast( getAsPolyObject, a2dVectorPath );
1605  vpath = obj->GetAsCanvasVpaths();
1606  }
1607  else if ( 0 != wxDynamicCast( getAsPolyObject, a2dText ) )
1608  {
1609  a2dText* obj = wxDynamicCast( getAsPolyObject, a2dText );
1610  vpath = obj->GetAsCanvasVpaths();
1611  }
1612 
1613  // now we have vector path, which we will convert to polygons and polylines.
1614  // Next only the polygons will be used for boolean operations.
1615  if ( vpath != wxNullCanvasObjectList )
1616  {
1617 
1618  a2dCanvasObjectList::iterator iter = vpath->begin();
1619  while ( iter != vpath->end() )
1620  {
1621  a2dCanvasObjectList* polylist = NULL;
1622  a2dVectorPath* obj = ( a2dVectorPath* ) ( *iter ).Get();
1623  polylist = obj->GetAsPolygons();
1624 
1625  for( a2dCanvasObjectList::iterator iterp = polylist->begin(); iterp != polylist->end(); ++iterp )
1626  {
1627  a2dPolygonL* poly = wxDynamicCast( ( *iterp ).Get(), a2dPolygonL );
1628  if ( poly && poly->GetNumberOfSegments() > 2 )
1629  {
1630  m_calculatedArea += poly->GetSegments()->CalcArea();
1631  }
1632  }
1633  delete polylist;
1634 
1635  iter = vpath->erase( iter );
1636  iter = vpath->begin();
1637  }
1638  delete vpath;
1639  }
1640 }
1641 
1642 //----------------------------------------------------------------------------
1643 // a2dWalker_DetectSmall
1644 //----------------------------------------------------------------------------
1645 
1647  : a2dWalker_LayerGroup( mask )
1648 {
1649  Initialize();
1650 }
1651 
1653  : a2dWalker_LayerGroup( id, mask )
1654 {
1655  Initialize();
1656 }
1657 
1659  : a2dWalker_LayerGroup( idList, mask )
1660 {
1661  Initialize();
1662 }
1663 
1665 {
1666 }
1667 
1669 {
1671  m_asString = false;
1672  /*
1673  #if wxUSE_STD_IOSTREAM
1674  m_strstream << _T("Contents of document \n");
1675  #else
1676  wxTextOutputStream text_stream( m_strstream );
1677  text_stream << _T("Contents of document \n");
1678  #endif
1679  */
1680 }
1681 
1682 bool a2dWalker_DetectSmall::Start( a2dCanvasObject* object )
1683 {
1685  setflags.Start( object, false );
1686 
1687  m_CVGwriter.WriteCvgStartDocument( m_strstream );
1688 
1689  m_CVGwriter.WriteStartElementAttributes( wxT( "o" ) );
1690  m_CVGwriter.WriteAttribute( wxT( "classname" ), wxT( "a2dCanvasObject" ) );
1691  m_CVGwriter.WriteEndAttributes();
1692 
1693  object->Walker( NULL, *this );
1694 
1695  m_CVGwriter.WriteEndElement();
1696 
1697  m_CVGwriter.WriteCvgEndDocument();
1698 
1699  return m_result;
1700 }
1701 
1702 bool a2dWalker_DetectSmall::WalkTask( wxObject* parent, wxObject* object, a2dWalkEvent event )
1703 {
1704  if ( m_currentDepth > m_depth )
1705  SetStopWalking( true );
1706  else
1707  SetStopWalking( false );
1708 
1709  if ( event == a2dWalker_a2dCanvasObjectStart )
1710  {
1711  a2dCanvasObject* parentobj = wxDynamicCast( parent, a2dCanvasObject );
1712  a2dCanvasObject* obj = wxDynamicCast( object, a2dCanvasObject );
1713  if ( obj && parentobj && !obj->GetIgnoreLayer() && !obj->GetBin() && ObjectOke( obj ) && ClassOfObjectOke( obj ) )
1714  {
1715  bool hasLayer = m_groupA.InGroup( obj->GetLayer() );
1716  if ( hasLayer && ( !m_selectedOnlyA || ( m_selectedOnlyA && obj->GetSelected() ) ) )
1717  {
1718  if ( obj->GetBboxWidth() < m_small && obj->GetBboxHeight() < m_small )
1719  {
1720  if ( m_asString )
1721  {
1722 #if wxART2D_USE_CVGIO
1723  m_CVGwriter.WriteObject( obj );
1724 #endif //wxART2D_USE_CVGIO
1725  }
1726  else
1727  {
1728  a2dCanvasObject* cobj = obj->TClone( a2dObject::clone_deep );
1729  cobj->SetLayer( m_target );
1730  cobj->SetBin( true );
1731  parentobj->Prepend( cobj );
1732  }
1733  m_result = true;
1734  }
1735  }
1736  }
1737  }
1738 
1739  if ( m_currentDepth <= m_depth )
1740  SetStopWalking( false );
1741 
1742  if ( event == a2dWalker_a2dCanvasObjectPostChild )
1743  return false; //do not go here
1744 
1745  return true;
1746 }
1747 
1748 //----------------------------------------------------------------------------
1749 // a2dWalker_DetectSmallSegments
1750 //----------------------------------------------------------------------------
1751 
1753  : a2dWalker_LayerGroup( mask )
1754 {
1755  Initialize();
1756 }
1757 
1759  : a2dWalker_LayerGroup( id, mask )
1760 {
1761  Initialize();
1762 }
1763 
1765  : a2dWalker_LayerGroup( idList, mask )
1766 {
1767  Initialize();
1768 }
1769 
1771 {
1772 }
1773 
1775 {
1777  m_asString = false;
1778  /*
1779  #if wxUSE_STD_IOSTREAM
1780  m_strstream << _T("Contents of document \n");
1781  #else
1782  wxTextOutputStream text_stream( m_strstream );
1783  text_stream << _T("Contents of document \n");
1784  #endif
1785  */
1786 }
1787 
1788 bool a2dWalker_DetectSmallSegments::Start( a2dCanvasObject* object )
1789 {
1791  setflags.Start( object, false );
1792 
1793  m_CVGwriter.WriteCvgStartDocument( m_strstream );
1794 
1795  m_CVGwriter.WriteStartElementAttributes( wxT( "o" ) );
1796  m_CVGwriter.WriteAttribute( wxT( "classname" ), wxT( "a2dCanvasObject" ) );
1797  m_CVGwriter.WriteEndAttributes();
1798 
1799  object->Walker( NULL, *this );
1800 
1801  m_CVGwriter.WriteEndElement();
1802 
1803  m_CVGwriter.WriteCvgEndDocument();
1804 
1805  return m_result;
1806 }
1807 
1808 bool a2dWalker_DetectSmallSegments::WalkTask( wxObject* parent, wxObject* object, a2dWalkEvent event )
1809 {
1810  if ( m_currentDepth > m_depth )
1811  SetStopWalking( true );
1812  else
1813  SetStopWalking( false );
1814 
1815  if ( event == a2dWalker_a2dCanvasObjectStart )
1816  {
1817  a2dCanvasObject* parentobj = wxDynamicCast( parent, a2dCanvasObject );
1818  a2dCanvasObject* obj = wxDynamicCast( object, a2dCanvasObject );
1819  if ( obj && parentobj && !obj->GetIgnoreLayer() && !obj->GetBin() && ObjectOke( obj ) && ClassOfObjectOke( obj ) )
1820  {
1821  bool hasLayer = m_groupA.InGroup( obj->GetLayer() );
1822  if ( hasLayer && ( !m_selectedOnlyA || ( m_selectedOnlyA && obj->GetSelected() ) ) )
1823  {
1824  a2dVertexListPtr redun;
1825  if ( 0 != wxDynamicCast( obj, a2dPolylineL ) )
1826  {
1827  a2dPolylineL* cobj = wxDynamicCast( obj, a2dPolylineL );
1828  redun = cobj->GetSegments()->GetRedundant( false, m_small );
1829  if ( redun )
1830  {
1831  m_result = true;
1832  a2dSmrtPtr<a2dPolylineL> p = new a2dPolylineL( redun, false );
1833  p->SetLayer( m_target );
1834  p->SetBin( true );
1835  if ( m_asString )
1836  {
1837 #if wxART2D_USE_CVGIO
1838  m_CVGwriter.WriteObject( p );
1839 #endif //wxART2D_USE_CVGIO
1840  }
1841  else
1842  parentobj->Append( p );
1843  }
1844  }
1845  else if ( 0 != wxDynamicCast( obj, a2dPolygonL ) )
1846  {
1847  a2dPolygonL* cobj = wxDynamicCast( obj, a2dPolygonL );
1848  redun = cobj->GetSegments()->GetRedundant( true, m_small );
1849  if ( redun )
1850  {
1851  m_result = true;
1852  a2dSmrtPtr<a2dPolygonL> p = new a2dPolygonL( redun, false );
1853  p->SetLayer( m_target );
1854  p->SetBin( true );
1855  if ( m_asString )
1856  {
1857 #if wxART2D_USE_CVGIO
1858  m_CVGwriter.WriteObject( p );
1859 #endif //wxART2D_USE_CVGIO
1860  }
1861  else
1862  parentobj->Append( p );
1863  }
1864  }
1865  }
1866  }
1867  }
1868 
1869  if ( m_currentDepth <= m_depth )
1870  SetStopWalking( false );
1871 
1872  if ( event == a2dWalker_a2dCanvasObjectPostChild )
1873  return false; //do not go here
1874 
1875  return true;
1876 }
1877 
1878 //----------------------------------------------------------------------------
1879 // a2dWalker_FindAndSetCorridorPath
1880 //----------------------------------------------------------------------------
1881 
1883  : a2dWalker_FindCanvasObject( search )
1884 {
1885 }
1886 
1887 
1889 {
1890 }
1891 
1892 bool a2dWalker_FindAndSetCorridorPath::WalkTask( wxObject* parent, wxObject* object, a2dWalkEvent event )
1893 {
1894  if ( event == a2dWalker_a2dPropertyStart )
1895  SetStopWalking( true );
1896 
1897  if ( event == a2dWalker_a2dCanvasObjectStart )
1898  {
1899  a2dCanvasObject* obj = wxDynamicCast( object, a2dCanvasObject );
1900  if ( !m_result )
1901  obj->SetIsOnCorridorPath( true );
1902  if ( obj == m_search )
1903  {
1904  m_result = true;
1905  SetStopWalking( true );
1906  return true;
1907  }
1908  }
1909 
1910  if ( event == a2dWalker_a2dCanvasObjectEnd )
1911  {
1912  a2dCanvasObject* obj = wxDynamicCast( object, a2dCanvasObject );
1913  if ( !m_result )
1914  {
1915  obj->SetIsOnCorridorPath( false );
1916  return true;
1917  }
1918  }
1919  if ( event == a2dWalker_a2dCanvasObjectPostChild )
1920  return false; //do not go here
1921 
1922  if ( !m_result && event == a2dWalker_a2dPropertyEnd )
1923  SetStopWalking( false );
1924 
1925 
1926  return true;
1927 }
1928 
1929 /* algorithm candidates, which or not in use currentl
1930 
1931  //! Mark multiple references.
1932  /! Search for objects that are multiple referenced from within the document.
1933  All such object get there m_bin2 flag set.
1934  /
1935 virtual bool MarkMultiReferences();
1936 
1937 
1938 bool a2dCanvasObject::MarkMultiReferences()
1939 {
1940  bool found = true;
1941 
1942  if ( GetBin() )
1943  {
1944  m_flags.m_bin2 = true;
1945  found = true;
1946  }
1947  m_flags.m_bin = true; //passed here
1948 
1949  if ( canobj->GetChildObjectList() == wxNullCanvasObjectList )
1950  return found;
1951 
1952  forEachIn( a2dCanvasObjectList, canobj->GetChildObjectList() )
1953  {
1954  a2dCanvasObject *obj = *iter;
1955  found = obj->MarkMultiReferences() && found;
1956  }
1957  return found;
1958 }
1959 
1960 
1961 
1962 
1963 
1964 
1965 
1966 
1967  //!can be used by the user to implement a function that affects all a2dCanvas derived objects
1968  /!
1969  The base implementation calls this function on its childs, so in a derived object always
1970  call the base class to keep recursing deeper.
1971 
1972  \param function id of the user function to be called
1973  \param data for the called function (type depends on id)
1974  \param depth recursion depth (0=this object, 1=this object+childs, ...)
1975  \param flags objects with this flag set ignore the depth limit
1976  /
1977  virtual bool UserBaseFunctionEx( int function, void *data, int depth, a2dCanvasObjectFlagsMask flags );
1978 
1979 
1980 
1981 bool a2dCanvasObject::UserBaseFunctionEx( int function, void *data, int depth, a2dCanvasObjectFlagsMask flags )
1982 {
1983  if( depth<=0 && !CheckMask( flags ) )
1984  return true;
1985 
1986  bool rslt = true;
1987  if( GetChildObjectsCount() )
1988  {
1989  forEachIn( a2dCanvasObjectList, canobj->GetChildObjectList() )
1990  {
1991  a2dCanvasObject *obj = *iter;
1992  rslt &= obj->UserBaseFunctionEx( function, data, depth-1, flags );
1993  }
1994  }
1995  return rslt;
1996 }
1997 
1998 
1999 
2000 
2001  //! to refresh controls after a rendering to a device did take place
2002  /!
2003  This brings the wxWindows controls back to the front.
2004  /
2005  void RefreshControls();
2006 
2007 
2008  void a2dCanvasObject::RefreshControls()
2009  {
2010  if ( canobj->GetChildObjectList() == wxNullCanvasObjectList )
2011  return;
2012 
2013  forEachIn( a2dCanvasObjectList, canobj->GetChildObjectList() )
2014  {
2015  a2dCanvasObject *obj = *iter;
2016  obj->RefreshControls();
2017  }
2018  }
2019 */
2020 
2021 
2022 //----------------------------------------------------------------------------
2023 // a2dWalker_AllowedObjects
2024 //----------------------------------------------------------------------------
2025 
2027  : a2dWalker_LayerGroup( mask )
2028 {
2029  Initialize();
2030 }
2031 
2033  : a2dWalker_LayerGroup( id, mask )
2034 {
2035  Initialize();
2036 }
2037 
2039  : a2dWalker_LayerGroup( idList, mask )
2040 {
2041  Initialize();
2042 }
2043 
2045 {
2046 }
2047 
2049 {
2051  m_asString = false;
2052 
2053  /*
2054  #if wxUSE_STD_IOSTREAM
2055  m_strstream << _T("Contents of document \n");
2056  #else
2057  wxTextOutputStream text_stream( m_strstream );
2058  text_stream << _T("Contents of document \n");
2059  #endif
2060  */
2061 }
2062 
2063 bool a2dWalker_AllowedObjects::Start( a2dCanvasObject* object )
2064 {
2066  setflags.Start( object, false );
2067 
2068  m_CVGwriter.WriteCvgStartDocument( m_strstream );
2069 
2070  m_CVGwriter.WriteStartElementAttributes( wxT( "o" ) );
2071  m_CVGwriter.WriteAttribute( wxT( "classname" ), wxT( "a2dCanvasObject" ) );
2072  m_CVGwriter.WriteEndAttributes();
2073 
2074  object->Walker( NULL, *this );
2075 
2076  m_CVGwriter.WriteEndElement();
2077 
2078  m_CVGwriter.WriteCvgEndDocument();
2079 
2080  return m_result;
2081 }
2082 
2083 bool a2dWalker_AllowedObjects::WalkTask( wxObject* parent, wxObject* object, a2dWalkEvent event )
2084 {
2085  if ( m_currentDepth > m_depth )
2086  SetStopWalking( true );
2087  else
2088  SetStopWalking( false );
2089 
2090  if ( event == a2dWalker_a2dCanvasObjectStart )
2091  {
2092  a2dCanvasObject* parentobj = wxDynamicCast( parent, a2dCanvasObject );
2093  a2dCanvasObject* obj = wxDynamicCast( object, a2dCanvasObject );
2094  if ( obj && parentobj && !obj->GetIgnoreLayer() && !obj->GetBin() && ObjectOke( obj ) )
2095  {
2096  bool hasLayer = m_groupA.InGroup( obj->GetLayer() );
2097  if ( hasLayer && ( !m_selectedOnlyA || ( m_selectedOnlyA && obj->GetSelected() ) ) )
2098  {
2099  // see also m_allowClassList
2100  if ( ClassOfObjectOke( obj ) )
2101  {
2102  m_result = true;
2103  if ( m_store )
2104  {
2105  if ( m_asString )
2106  {
2107 #if wxART2D_USE_CVGIO
2108  m_CVGwriter.WriteObject( obj );
2109 #endif //wxART2D_USE_CVGIO
2110  }
2111  else
2112  {
2113  a2dCanvasObject* cobj = obj->TClone( a2dObject::clone_deep );
2114  cobj->SetLayer( m_target );
2115  cobj->SetBin( true );
2116  parentobj->Prepend( cobj );
2117  }
2118  }
2119  }
2120  }
2121  }
2122  }
2123 
2124  if ( m_currentDepth <= m_depth )
2125  SetStopWalking( false );
2126 
2127  if ( event == a2dWalker_a2dCanvasObjectPostChild )
2128  return false; //do not go here
2129 
2130  return true;
2131 }
2132 
2133 //----------------------------------------------------------------------------
2134 // a2dWalkerIOHandlerWithContext
2135 //----------------------------------------------------------------------------
2136 
2138  : a2dWalkerIOHandler()
2139 {
2140  m_context = &ic;
2141  Initialize();
2142 }
2143 
2145 {
2146 }
2147 
2149 {
2150 }
2151 
2152 //! Start traversing at object, returns true.
2154 {
2155  a2dWalker_SetCheck setp( false );
2156  setp.SetSkipNotRenderedInDrawing( true );
2157  setp.Start( object );
2158 
2159  SetDepthFirst( false );
2160  m_result = true;
2161  m_context->SetClipStatus( _ON );
2162  m_context->SetRenderChildDerived( false );
2163  object->WalkerWithContext( *m_context, NULL, *this );
2164  return m_result;
2165 }
2166 
2167 //----------------------------------------------------------------------------
2168 // a2dWalker_RenderLayers
2169 //----------------------------------------------------------------------------
2170 
2173 {
2174 
2175 }
2176 
2178 {
2179 
2180 }
2181 
2182 bool a2dWalker_RenderLayers::WalkTask( a2dIterC& ic, wxObject* parent, wxObject* object, a2dWalkEvent event )
2183 {
2184  if ( event == a2dWalker_a2dCanvasObjectStart )
2185  {
2186  a2dCanvasObject* parentobj = ( a2dCanvasObject* ) parent;
2187  a2dCanvasObject* canobj = ( a2dCanvasObject* ) object;
2188  OVERLAP clipparent = ic.GetParentClipStatus();
2189  OVERLAP childclip = _IN;
2190  // if parent is checked it means, it is _ON or _IN
2191  childclip = canobj->GetClipStatus( ic, clipparent );
2192  ic.SetClipStatus( childclip );
2193  //if ( childclip != _OUT ) //if a child is _OUT, no need to render it.
2194  {
2195  Render( ic, canobj, childclip );
2196  }
2197  }
2198  if ( event == a2dWalker_a2dCanvasObjectPostChild )
2199  return false;
2200 
2201  return true;
2202 }
2203 
2204 void a2dWalker_RenderLayers::Render( a2dIterC& ic, a2dCanvasObject* canobj, OVERLAP clipparent )
2205 {
2206  wxUint16 layer = canobj->GetLayer();
2207  // Check if the object is not about to be deleted
2208  if ( canobj->GetRelease( ) )
2209  return;
2210 
2211  if ( !ic.FilterObject( canobj ) )
2212  {
2213  ic.EndFilterObject( canobj );
2214  return;
2215  }
2216 
2217  //Now we will either render the object or children or both on the given layer.
2218  //OR in case layer == wxLAYER_ALL, everything will be rendered at once.
2219  //Style of objects will be according to their own style properties of using the object
2220  //m_layer id.
2221 
2222 
2223  //get bbox at the absolute position
2224  //first map without pen width which is not included in the boundingbox
2225 
2226  // if 0 in width or height, nothing will be rendered in principle.
2227  // But the stroke width is not included in bbox, so it might still be visible.
2228  if ( !canobj->GetFlag( a2dCanvasOFlags::NoRenderCanvasObject ) && canobj->GetBbox().GetWidth() && canobj->GetBbox().GetHeight() )
2229  {
2230  a2dBoundingBox absarea = canobj->GetBbox();
2231  if ( !ic.GetTransform().IsIdentity() )
2232  absarea.MapBbox( ic.GetTransform() );
2233 
2234  double size = wxMax( absarea.GetWidth(), absarea.GetHeight() );
2235  if ( ic.GetDrawer2D()->GetPrimitiveThreshold() != 0
2236  && size < ic.GetDrawer2D()->DeviceToWorldXRel( ic.GetDrawer2D()->GetPrimitiveThreshold() ) )
2237  {
2238  if ( ic.GetDrawer2D()->GetThresholdDrawRectangle() )
2239  {
2240  wxRect absareadev = canobj->GetAbsoluteArea( ic, 0 );
2241  ic.GetDrawer2D()->DrawRoundedRectangle( canobj->GetBbox().GetMinX(), canobj->GetBbox().GetMinY(),
2242  canobj->GetBbox().GetWidth(), canobj->GetBbox().GetHeight(), 0 );
2243 
2244  if ( canobj->GetHighLight() )
2245  canobj->DrawHighLighted( ic );
2246  }
2247  ic.EndFilterObject( canobj );
2248  return;
2249  }
2250  }
2251 
2252  // a2dIterCU scope ends for DrawHighLighted( ic )
2253  {
2254  //here the Drawer gets a new relative transform
2255  //Every call for drawing something on it, will use it from now on.
2256  // we go one level deeper in transform to the child level
2257  a2dIterCU cu( ic, canobj );
2258 
2259  //if ( m_flags.m_HighLight )
2260  // DrawHighLighted( ic );
2261 
2262 
2263  //if the propertylist NOT contains style properties,
2264  //we need to set the style according to the layer setting.
2265  bool fillset = false;
2266  bool strokeset = false;
2267  bool viewSpecific = false;
2268 
2269  a2dLayers* layers = canobj->GetRoot()->GetLayerSetup();
2270  //if style not set by the properties ,do it now using the layers.
2271  if ( layers )
2272  {
2273  if ( !fillset )
2274  ic.GetDrawer2D()->SetDrawerFill( layers->GetFill( layer ) );
2275  if ( !strokeset )
2276  ic.GetDrawer2D()->SetDrawerStroke( layers->GetStroke( layer ) );
2277  }
2278  else
2279  {
2280  if ( !fillset )
2282  if ( !strokeset )
2284  }
2285 
2286  //if the object has sub objects (apart from the childobjects which are handled here),
2287  //those subobjects must be rendered by iterating on layer when needed/wanted, simular to child objects.
2288  //We do not iterate here, since that is only needed if indeed there or subobjects.
2289  //This will be know in a "wxDerivedCanvasObject DoRender".
2290  //SO parent objects that call this function here, MUST:
2291  // 1- clip object against area to redraw.
2292  // 2- iterate on layers when needed.
2293  if ( ic.GetLayer() == layer || ic.GetLayer() == wxLAYER_ALL || canobj->GetIgnoreLayer() )
2294  {
2295 
2296  // DoRender() should not change the matrix of the drawing context, or at least restore it.
2297  // To prevent taking time for this.
2298  //a2dAffineMatrix tworld = ic.GetTransform();
2299 
2300  canobj->CallDoRender( ic, clipparent );
2301  }
2302  }
2303 
2304  if ( canobj->GetHighLight() )
2305  canobj->DrawHighLighted( ic );
2306 
2307  ic.EndFilterObject( canobj );
2308 }
2309 
2310 
2311 //----------------------------------------------------------------------------
2312 // a2dWalker_FindPinsToConnect
2313 //----------------------------------------------------------------------------
2314 
2315 a2dWalker_FindPinsToConnect::a2dWalker_FindPinsToConnect( a2dCanvasObjectFlagsMask mask, a2dPinClass* pinclassToConnectTo,
2316  a2dConnectTask connectTask, double xpin, double ypin, double margin )
2318 {
2319  Initialize();
2320 
2321  m_mask = mask;
2322  m_pinclassToConnectTo = pinclassToConnectTo;
2323  m_xpin = xpin;
2324  m_ypin = ypin;
2325  m_margin = margin;
2326  m_connectTask = connectTask;
2327  m_stopAtFirst = false;
2328 }
2329 
2330 a2dWalker_FindPinsToConnect::~a2dWalker_FindPinsToConnect()
2331 {
2332 }
2333 
2335 {
2337  m_found.clear();
2338 }
2339 
2341 {
2342  if( object->GetChildObjectsCount() )
2343  {
2344  object->GetChildObjectList()->SetSpecificFlags( false, a2dCanvasOFlags::BIN );
2345 
2346  a2dCanvasObjectList::iterator iter;
2347 
2348  for( iter = object->GetChildObjectList()->begin(); iter != object->GetChildObjectList()->end(); ++iter )
2349  {
2350  a2dCanvasObject* obj = *iter;
2351  if ( obj && !obj->GetAlgoSkip() && obj->DoConnect() && ObjectOke( obj ) && ClassOfObjectOke( obj ) && obj->HasPins() )
2352  {
2353  a2dCanvasObjectList::iterator iterpins; //iterate for pins
2354  for( iterpins = obj->GetChildObjectList()->begin(); iterpins != obj->GetChildObjectList()->end(); ++iterpins )
2355  {
2356  a2dCanvasObject* child = *iterpins;
2357  a2dPin* pin = wxDynamicCast( child, a2dPin );
2358  //if parent object has the right mask, the pin may be different (e.g. not visible), we take this into account.
2359  //This is to be able to disable pins.
2360  if ( pin && !pin->GetRelease() && pin->CheckMask( m_mask ) )
2361  {
2362  a2dPinClass* pinclass = pin->GetPinClass();
2363  //check if m_pinclassToConnectTo combines with this pin, if so set connectable.
2364  if ( 1 )
2365  {
2366  double dx = fabs( pin->GetAbsX() - m_xpin );
2367  double dy = fabs( pin->GetAbsY() - m_ypin );
2368  if ( pin->GetMode() != a2dPin::sm_PinUnConnected )
2370  if ( dx < m_margin && dy < m_margin //&&
2371  //pinclass->CanConnectTo( m_pinclassToConnectTo ) &&
2372  //m_pinclassToConnectTo->CanConnectTo( pinclass )
2373  )
2374  {
2375  //we have to pins of different objects on top of eachother, and they maybe can connect
2376  if ( m_connectTask == a2d_StartWire )
2377  {
2378  // wire start on a pin with pinclass, ask generator for pinclass of wire.
2379  if ( m_returnPinclass = pinclass->GetPinClassForTask( m_connectTask, obj, m_pinclassToConnectTo, pin ) )
2380  {
2381  m_found.push_back( pin );
2383  }
2384  else
2386  }
2387  else if ( m_connectTask == a2d_StartWire_BasedOnClassStartPin )
2388  {
2389  if ( m_returnPinclass = pinclass->GetPinClassForTask( m_connectTask, obj ) )
2390  m_found.push_back( pin );
2391  }
2392  else if ( m_connectTask == a2d_StartWire_BasedOnWireClassRequired )
2393  {
2394  if ( m_returnPinclass = pinclass->GetPinClassForTask( m_connectTask, obj ) )
2395  m_found.push_back( pin );
2396  }
2397  else if ( m_connectTask == a2d_StartWire_BasedOnObjectClassRequired )
2398  {
2399  if ( m_returnPinclass = pinclass->GetPinClassForTask( m_connectTask, obj ) )
2400  m_found.push_back( pin );
2401  }
2402  else if ( m_connectTask == a2d_SearchPinForFinishWire )
2403  {
2404  if ( m_pinclassToConnectTo == m_pinclassToConnectTo->GetPinClassForTask( m_connectTask, obj, pinclass ) )
2405  {
2406  m_found.push_back( pin );
2408  }
2409  else
2411  }
2412 /*
2413  else if ( m_connectTask == a2d_GeneratePinsForPinClass &&
2414  pinclass == pinclass->GetConnectionGenerator()->GetPinClassForTask( m_pinclassToConnectTo, m_connectTask, obj )
2415  )
2416  {
2417  m_found.push_back( pin );
2418  pin->SetMode( a2dPin::sm_PinCanConnectToPinClass );
2419  }
2420  else if ( m_connectTask == a2d_GeneratePinsForPinClass &&
2421  m_pinclassToConnectTo == pinclass->GetConnectionGenerator()->GetPinClassForTask( pinclass, m_connectTask, obj )
2422  )
2423  {
2424  m_found.push_back( pin );
2425  pin->SetMode( a2dPin::sm_PinCanConnectToPinClass );
2426  }
2427 */
2428  else
2430 
2431  if ( m_found.size() )
2432  {
2433  m_result = true;
2434  if ( m_stopAtFirst )
2435  return m_result;
2436  }
2437  }
2438  }
2439  else
2440  {
2441  if ( pin->GetMode() != a2dPin::sm_PinConnected )
2443  }
2444  }
2445  }
2446  }
2447  }
2448  }
2449 
2450  return m_result;
2451 }
2452 
2453 //----------------------------------------------------------------------------
2454 // a2dWalker_FindPinsToConnectToPin
2455 //----------------------------------------------------------------------------
2456 
2457 a2dWalker_FindPinsToConnectToPin::a2dWalker_FindPinsToConnectToPin( a2dCanvasObjectFlagsMask mask, a2dPin* pinToConnectTo,
2458  a2dConnectTask connectTask, double margin )
2460 {
2461  Initialize();
2462 
2463  m_mask = mask;
2464  m_pinToConnectTo = pinToConnectTo;
2465  m_margin = margin;
2466  m_connectTask = connectTask;
2467  m_stopAtFirst = false;
2468 }
2469 
2470 a2dWalker_FindPinsToConnectToPin::~a2dWalker_FindPinsToConnectToPin()
2471 {
2472 }
2473 
2475 {
2477  m_found.clear();
2478 }
2479 
2481 {
2482  if( object->GetChildObjectsCount() )
2483  {
2484  object->GetChildObjectList()->SetSpecificFlags( false, a2dCanvasOFlags::BIN );
2485 
2486  a2dCanvasObjectList::iterator iter;
2487 
2488  for( iter = object->GetChildObjectList()->begin(); iter != object->GetChildObjectList()->end(); ++iter )
2489  {
2490  a2dCanvasObject* obj = *iter;
2491  if ( obj && !obj->GetAlgoSkip() && obj->HasPins() && obj->DoConnect() && ObjectOke( obj ) && ClassOfObjectOke( obj ) )
2492  {
2493  a2dCanvasObjectList::iterator iterpins; //iterate for pins
2494  for( iterpins = obj->GetChildObjectList()->begin(); iterpins != obj->GetChildObjectList()->end(); ++iterpins )
2495  {
2496  a2dCanvasObject* child = *iterpins;
2497  a2dPin* pin = wxDynamicCast( child, a2dPin );
2498  if ( pin && !pin->GetRelease() && pin->CheckMask( m_mask ) )
2499  {
2500  a2dPinClass* pinclass = pin->GetPinClass();
2501  //check if m_pinclassToConnectTo combines with this pin, if so set connectable.
2502  if ( 1 )
2503  {
2504  double dx = fabs( pin->GetAbsX() - m_pinToConnectTo->GetAbsX() );
2505  double dy = fabs( pin->GetAbsY() - m_pinToConnectTo->GetAbsY() );
2506  if ( pin->GetMode() != a2dPin::sm_PinUnConnected )
2508  if ( dx < m_margin && dy < m_margin //&&
2509  //pinclass->CanConnectTo( m_pinclassToConnectTo ) &&
2510  //m_pinclassToConnectTo->CanConnectTo( pinclass )
2511  )
2512  {
2513  //we have to pins of different objects on top of eachother, and they maybe can connect
2514  if ( m_connectTask == a2d_PinToPin )
2515  {
2516  if ( m_pinToConnectTo->GetPinClass() == pinclass->GetPinClassForTask( m_connectTask, obj, m_pinToConnectTo->GetPinClass(), m_pinToConnectTo ) )
2517  {
2518  m_found.push_back( pin );
2520  }
2521  else
2523  }
2524  else if ( m_connectTask == a2d_FinishWire )
2525  {
2526  if ( m_pinToConnectTo->GetPinClass() == pinclass->GetPinClassForTask( m_connectTask, obj, m_pinToConnectTo->GetPinClass(), m_pinToConnectTo ) )
2527  {
2528  m_found.push_back( pin );
2530  }
2531  else
2533  }
2534  if ( m_found.size() )
2535  {
2536  m_result = true;
2537  if ( m_stopAtFirst )
2538  return m_result;
2539  } }
2540  }
2541  else
2542  {
2543  if ( pin->GetMode() != a2dPin::sm_PinConnected )
2545  }
2546  }
2547  }
2548  m_result = true;
2549  }
2550  }
2551  }
2552 
2553  return m_result;
2554 }
2555 
2556 //----------------------------------------------------------------------------
2557 // a2dWalker_GeneratePinsToConnect
2558 //----------------------------------------------------------------------------
2559 
2560 a2dWalker_GeneratePinsToConnect::a2dWalker_GeneratePinsToConnect( a2dCanvasObjectFlagsMask mask, a2dPinClass* pinclassToConnectTo,
2561  a2dConnectTask connectTask, double xpin, double ypin )
2563 {
2564  Initialize();
2565 
2566  m_mask = mask;
2567  m_pinclassToConnectTo = pinclassToConnectTo;
2568  m_xpin = xpin;
2569  m_ypin = ypin;
2570  m_connectTask = connectTask;
2571 }
2572 
2573 a2dWalker_GeneratePinsToConnect::~a2dWalker_GeneratePinsToConnect()
2574 {
2575 }
2576 
2578 {
2580 }
2581 
2583 {
2584  m_ic = &ic;
2585  double margin = m_ic->GetHitMarginWorld();
2586 
2587  if ( ItsChildren )
2588  {
2589  a2dIterCU cu( ic, object );
2590  if( object->GetChildObjectsCount() )
2591  {
2592  a2dCanvasObjectList::iterator iter;
2593 
2594  //the next will create dynamic pins when possible/wanted for required pinclass.
2595  //Those pins are specific to a x,y location.
2596  for( iter = object->GetChildObjectList()->begin(); iter != object->GetChildObjectList()->end(); ++iter )
2597  {
2598  a2dCanvasObject* obj = *iter;
2599 
2600  if ( obj && !obj->GetAlgoSkip() && obj->GetGeneratePins() &&
2601  obj->DoConnect() && ObjectOke( obj ) && ClassOfObjectOke( obj ) )
2602  {
2603  obj->RemovePins( true, true );
2604  // First test if canvas object is a hit, so TEMPORARY pins will only be created when hit on object.
2605  a2dHitEvent hitevent = a2dHitEvent( m_xpin, m_ypin );
2606  a2dCanvasObject* hit = obj->IsHitWorld( *m_ic, hitevent );
2607  if( hit )
2608  obj->GeneratePinsPossibleConnections( m_pinclassToConnectTo, m_connectTask, m_xpin, m_ypin, margin );
2609 
2610  m_result = true;
2611  }
2612  }
2613 
2614  }
2615  }
2616  else
2617  {
2618  a2dCanvasObject* obj = object;
2619  if ( obj && !obj->GetAlgoSkip() && obj->GetGeneratePins() &&
2620  obj->DoConnect() && ObjectOke( obj ) && ClassOfObjectOke( obj ) )
2621  {
2622  obj->RemovePins( true, true );
2623  // First test if canvas object is a hit, so TEMPORARY pins will only be created when hit on object.
2624  a2dHitEvent hitevent = a2dHitEvent( m_xpin, m_ypin );
2625  a2dCanvasObject* hit = obj->IsHitWorld( *m_ic, hitevent );
2626  if( hit )
2627  {
2628  obj->GeneratePinsPossibleConnections( m_pinclassToConnectTo, m_connectTask, m_xpin, m_ypin, margin );
2629  }
2630  m_result = true;
2631  }
2632  }
2633  return m_result;
2634 }
2635 
2636 //----------------------------------------------------------------------------
2637 // a2dWalker_SetPinsToEndState
2638 //----------------------------------------------------------------------------
2639 
2640 a2dWalker_SetPinsToEndState::a2dWalker_SetPinsToEndState( a2dCanvasObjectFlagsMask mask )
2642 {
2643  Initialize();
2644 
2645  m_mask = mask;
2646 }
2647 
2648 a2dWalker_SetPinsToEndState::~a2dWalker_SetPinsToEndState()
2649 {
2650 }
2651 
2653 {
2655 }
2656 
2658 {
2659  if( object->GetChildObjectsCount() )
2660  {
2661  a2dCanvasObjectList::iterator iter;
2662 
2663  for( iter = object->GetChildObjectList()->begin(); iter != object->GetChildObjectList()->end(); ++iter )
2664  {
2665  a2dCanvasObject* obj = *iter;
2666  if ( obj && !obj->GetAlgoSkip() && obj->HasPins() && obj->DoConnect() && ObjectOke( obj ) && ClassOfObjectOke( obj ) )
2667  {
2668  obj->RemovePins( true, true );
2669 
2670  a2dCanvasObjectList::iterator iterpins; //iterate for pins
2671  for( iterpins = obj->GetChildObjectList()->begin(); iterpins != obj->GetChildObjectList()->end(); ++iterpins )
2672  {
2673  a2dCanvasObject* child = *iterpins;
2674  a2dPin* pin = wxDynamicCast( child, a2dPin );
2675  if ( pin && !pin->GetRelease() )
2676  {
2677  a2dPinClass* pinclass = pin->GetPinClass();
2678  //check if m_pinclassToConnectTo combines with this pin, if so set connectable.
2679  if ( ! pin->IsConnectedTo() )
2680  {
2681  if ( pin->GetMode() != a2dPin::sm_PinUnConnected )
2683  }
2684  else
2685  {
2686  if ( pin->GetMode() != a2dPin::sm_PinConnected )
2688  }
2689  }
2690  }
2691 
2692  m_result = true;
2693  }
2694  }
2695 
2696  }
2697 
2698  return m_result;
2699 }
2700 
2701 //----------------------------------------------------------------------------
2702 // a2dWalker_SetPinsToBeginState
2703 //----------------------------------------------------------------------------
2704 
2705 a2dWalker_SetPinsToBeginState::a2dWalker_SetPinsToBeginState( a2dCanvasObjectFlagsMask mask )
2707 {
2708  Initialize();
2709 
2710  m_mask = mask;
2711 }
2712 
2713 a2dWalker_SetPinsToBeginState::~a2dWalker_SetPinsToBeginState()
2714 {
2715 }
2716 
2718 {
2720 }
2721 
2723 {
2724  if( object->GetChildObjectsCount() )
2725  {
2726  a2dCanvasObjectList::iterator iter;
2727 
2728  for( iter = object->GetChildObjectList()->begin(); iter != object->GetChildObjectList()->end(); ++iter )
2729  {
2730  a2dCanvasObject* obj = *iter;
2731  if ( obj && !obj->GetAlgoSkip() && obj->HasPins() && obj->DoConnect() && ObjectOke( obj ) && ClassOfObjectOke( obj )
2732  )
2733  {
2734  obj->RemovePins( true, true );
2735 
2736  a2dCanvasObjectList::iterator iterpins; //iterate for pins
2737  for( iterpins = obj->GetChildObjectList()->begin(); iterpins != obj->GetChildObjectList()->end(); ++iterpins )
2738  {
2739  a2dCanvasObject* child = *iterpins;
2740  a2dPin* pin = wxDynamicCast( child, a2dPin );
2741  if ( pin && !pin->GetRelease() )
2742  {
2743  a2dPinClass* pinclass = pin->GetPinClass();
2744  //check if m_pinclassToConnectTo combines with this pin, if so set connectable.
2745  if ( ! pin->IsConnectedTo() )
2746  {
2747  if ( pin->GetMode() != a2dPin::sm_PinUnConnected )
2749  }
2750  else
2751  {
2752  if ( pin->GetMode() != a2dPin::sm_PinConnected )
2754  }
2755  }
2756  }
2757 
2758  m_result = true;
2759  }
2760  }
2761 
2762  }
2763 
2764  return m_result;
2765 }
2766 
2767 
2768 
2769 //----------------------------------------------------------------------------
2770 // a2dWalker_GeneratePinsToConnectObject
2771 //----------------------------------------------------------------------------
2772 
2773 a2dWalker_GeneratePinsToConnectObject::a2dWalker_GeneratePinsToConnectObject( a2dCanvasObjectFlagsMask mask, a2dCanvasObject* connectObject,
2774  a2dConnectTask connectTask )
2776 {
2777  Initialize();
2778 
2779  m_mask = mask;
2780  m_connectTask = connectTask;
2781  m_connectObject = connectObject;
2782 }
2783 
2784 a2dWalker_GeneratePinsToConnectObject::~a2dWalker_GeneratePinsToConnectObject()
2785 {
2786 }
2787 
2789 {
2791 }
2792 
2793 bool a2dWalker_GeneratePinsToConnectObject::Start( a2dIterC& ic, a2dCanvasObject* top )
2794 {
2795  m_ic = &ic;
2796  a2dIterCU cu( ic, top );
2797 
2798  if( !top->GetChildObjectsCount() )
2799  return false;
2800 
2801  a2dCanvasObjectList::iterator iter;
2802 
2803  bool directChild = false;
2804  for( iter = top->GetChildObjectList()->begin(); iter != top->GetChildObjectList()->end(); ++iter )
2805  {
2806  a2dCanvasObject* obj = *iter;
2807  if ( obj )
2808  {
2809  if ( m_connectObject == obj )
2810  directChild = true;
2811  //obj->RemovePins( true, true );
2812  }
2813  }
2814  if ( !directChild )
2815  return false;
2816 
2817  if( m_connectObject->GetChildObjectsCount() &&
2818  m_connectObject->GetRoot() &&
2819  m_connectObject->HasPins() &&
2820  !m_connectObject->IsConnect() )
2821  {
2822  //the next part is to create dynamic pins, which are not a specific x,y but
2823  //which are on the same pins as m_connectObject. In other words: if another pin'ned objects
2824  //can deliver a pin at this objects its pins, set bin flag true.
2825 
2826  // are we on an object that is not itself wire like (IsConnect() ), and there are pins,
2827  // find if those pins can connect to others in object that have pins at the same location.
2828 
2829  // It depends on DoConnect() if the pins can be connected later on in ReWireConnected.
2830 
2831  a2dCanvasObjectList::iterator iter;
2832 
2833  //set all pins on m_connectObject object to bin flag false,
2834  //this to detect the pins which are able to connect.
2835  for( iter = m_connectObject->GetChildObjectList()->begin(); iter != m_connectObject->GetChildObjectList()->end(); ++iter )
2836  {
2837  a2dCanvasObject* obj = *iter;
2838  a2dPin* pinc = wxDynamicCast( obj, a2dPin );
2839  if ( pinc && !pinc->GetRelease() )
2840  {
2841  pinc->SetBin( false );
2842  if ( ! pinc->IsConnectedTo() )
2844  else
2846  }
2847  }
2848 
2849  m_bbox = m_connectObject->GetBbox();
2851 
2852  //flash if hit on pin of other object after modification
2853  a2dCanvasObjectList allpinobjects;
2854  for( iter = top->GetChildObjectList()->begin(); iter != top->GetChildObjectList()->end(); ++iter )
2855  {
2856  a2dCanvasObject* obj = *iter;
2857  if ( m_bbox.GetValid() && ( m_bbox.Intersect( obj->GetBbox() ) & m_intersectionCondition ) != 0 )
2858  {
2859  if ( obj->HasPins() || obj->GetGeneratePins() )
2860  allpinobjects.push_back( obj );
2861  }
2862  }
2863  //wxLogDebug( "How Many did intersect: %d",allpinobjects.size() );
2864 
2865  // ONLY object with pins or where pins will be generated upon in allpinobjects
2866  for( iter = allpinobjects.begin(); iter != allpinobjects.end(); ++iter )
2867  {
2868  a2dCanvasObject* obj = *iter;
2869  // if the other object is not a wire like objects, and allows connection,
2870  // we should generate feedback to the pins, by changing its render state.
2871  if (
2872  obj && obj != m_connectObject && !obj->IsConnect() && obj->DoConnect() &&
2873  !obj->GetAlgoSkip() && ObjectOke( obj ) && ClassOfObjectOke( obj )
2874  )
2875  {
2876  bool autocreatepins = obj->GetGeneratePins();
2877  if ( m_connectObject->GetEditingRender( ) )
2878  {
2879  //m_connectObject object is in editing mode, and is a copy of original.
2880  //We don't want to flash connection with that one.
2881  a2dCanvasObject* original = a2dCanvasObject::PROPID_Original->GetPropertyValue( m_connectObject );
2882  if ( original != obj )
2883  {
2884  //test connection of this object with the other is possible.
2885  //All pins which can connect will have the bin flag set
2886  m_connectObject->CanConnectWith( ic, obj, autocreatepins );
2887  }
2888  }
2889  else
2890  {
2891  //test connection of this object with the other is possible.
2892  //All pins which can connect will have the bin flag set
2893  m_connectObject->CanConnectWith( ic, obj, autocreatepins );
2894  }
2895  }
2896  }
2897 
2898  //all pins on m_connectObject object which are able to connect do have the bin flag set
2899  for( iter = m_connectObject->GetChildObjectList()->begin(); iter != m_connectObject->GetChildObjectList()->end(); ++iter )
2900  {
2901  a2dCanvasObject* obj = *iter;
2902  a2dPin* pinc = wxDynamicCast( obj, a2dPin );
2903  if ( pinc && !pinc->GetRelease() && pinc->GetBin() )
2904  {
2905  if( !pinc->IsConnectedTo() )
2906  {
2908  }
2909  pinc->SetBin( false );
2910  }
2911  }
2912  }
2913 
2914  return m_result;
2915 }
2916 
2917 
2918 //----------------------------------------------------------------------------
2919 // a2dWalker_ConnectToPinsObject
2920 //----------------------------------------------------------------------------
2921 
2922 a2dWalker_ConnectToPinsObject::a2dWalker_ConnectToPinsObject( a2dCanvasObjectFlagsMask mask, a2dCanvasObject* connectObject,
2923  a2dConnectTask connectTask, double margin )
2925 {
2926  Initialize();
2927 
2928  m_mask = mask;
2929  m_connectTask = connectTask;
2930  m_connectObject = connectObject;
2931  m_margin = margin;
2932 }
2933 
2934 a2dWalker_ConnectToPinsObject::~a2dWalker_ConnectToPinsObject()
2935 {
2936 }
2937 
2939 {
2941 }
2942 
2943 bool a2dWalker_ConnectToPinsObject::Start( a2dCanvasObject* top, bool alsoWires )
2944 {
2945  if( !top->GetChildObjectsCount() )
2946  return false;
2947 
2948  a2dCanvasObjectList::iterator iter;
2949 
2950  bool directChild = false;
2951  for( iter = top->GetChildObjectList()->begin(); iter != top->GetChildObjectList()->end(); ++iter )
2952  {
2953  a2dCanvasObject* obj = *iter;
2954  if ( obj )
2955  {
2956  if ( m_connectObject == obj )
2957  directChild = true;
2958  //obj->RemovePins( true, true );
2959  }
2960  }
2961  if ( !directChild )
2962  return false;
2963 
2964  if( m_connectObject->GetChildObjectsCount() &&
2965  m_connectObject->GetRoot() &&
2966  m_connectObject->HasPins() &&
2967  ( alsoWires || !m_connectObject->IsConnect() ) )
2968  {
2969  a2dCanvasObjectList::iterator iter; //iterate for pins
2970  for( iter = m_connectObject->GetChildObjectList()->begin(); iter != m_connectObject->GetChildObjectList()->end(); ++iter )
2971  {
2972  a2dCanvasObject* child = *iter;
2973  a2dPin* pin = wxDynamicCast( child, a2dPin );
2974  if ( pin && !pin->GetRelease() && pin->CheckMask( m_mask ) )
2975  {
2976  ConnectAtPin( top, pin );
2977  }
2978  }
2979  }
2980 
2981  return m_result;
2982 }
2983 
2984 bool a2dWalker_ConnectToPinsObject::ConnectAtPin( a2dCanvasObject* top, a2dPin* pintoconnect )
2985 {
2986  a2dCanvasObjectList::iterator iter;
2987 
2988  for( iter = top->GetChildObjectList()->begin(); iter != top->GetChildObjectList()->end(); ++iter )
2989  {
2990  a2dCanvasObject* obj = *iter;
2991  if ( obj && !obj->GetAlgoSkip() && obj->DoConnect() && ObjectOke( obj ) && ClassOfObjectOke( obj ) )
2992  {
2993  a2dCanvasObjectList::iterator iterpins; //iterate for pins
2994  for( iterpins = obj->GetChildObjectList()->begin(); iterpins != obj->GetChildObjectList()->end(); ++iterpins )
2995  {
2996  a2dCanvasObject* child = *iterpins;
2997  a2dPin* pin = wxDynamicCast( child, a2dPin );
2998  if ( pin && !pin->GetRelease() && pin->CheckMask( m_mask ) &&
2999  pin != pintoconnect //in case of pins on same object as pin, only allow connecting to other pins
3000  )
3001  {
3002  a2dPinClass* pinclass = pin->GetPinClass();
3003  if ( ! pin->IsConnectedTo( pintoconnect ) )
3004  {
3005  if ( pin->IsSameLocation( pintoconnect, m_margin ) &&
3006  pin->MayConnectTo( pintoconnect )
3007  )
3008  {
3010  // check if can connect connect the pins
3011  // pins did snap, but might not be at the exact same position
3012  // therefore create with wire.
3013  // multidrag tool does not create wires for pin to pin connections, it needs a wire
3014  // m_connectObject->ConnectPinsCreateConnect( top, pintoconnect, pin, true );
3015  // therefore use this until solved, since it always creates a wire.
3016 
3017  if ( pin->IsSameLocation( pintoconnect ) )
3018  m_connectObject->ConnectPins( top, pintoconnect, pin, true );
3019  else
3020  m_connectObject->CreateConnectObject( top, pintoconnect, pin, true );
3021 
3022  }
3023  }
3024  }
3025  }
3026  m_result = true;
3027  }
3028  }
3029  return m_result;
3030 }
Display Part of a a2dDrawing, in which a2dCanvasObjects are shown.
Definition: drawer.h:470
a2dCanvasObject * GetCanvasObject()
Definition: recur.cpp:104
set check on a2dObject flag false or true
Definition: algos.h:665
virtual void MakeReferencesUnique()
All direct a2dCanvasObject which are part of this one are made unique.
Definition: canobj.cpp:5440
a2dCircle at x,y, and with radius
Definition: canprim.h:554
bool IsSameLocation(a2dPin *other, double margin=0) const
Check if this pin is at same location.
Definition: canpin.cpp:1115
wxPoint2DDouble a2dPoint2D
this to define if coordinate numbers are integer or doubles
Definition: artglob.h:47
bool Start(a2dObject *object)
Start traversing at object, returns true.
Definition: algos.cpp:58
double GetHeight() const
returns height of the boundingbox
Definition: bbox.cpp:334
a2dWalker_RemoveProperty(bool all=true)
constructor with no a2dPropertyId added yet. For that use AddPropertyId()
Definition: algos.cpp:223
bool m_result
result of walk, set false at start, use at will.
Definition: gen.h:3984
virtual bool WalkTask(wxObject *parent, wxObject *object, a2dWalkEvent event)
called from within a2dCanvasDocument
Definition: algos.cpp:680
a2dNamedProperty * m_property
id of property to set
Definition: algos.h:550
void Initialize()
used from constructors
Definition: algos.cpp:2717
static const a2dCanvasObjectFlagsMask BIN
Definition: candefs.h:192
(In) Visible property that can be added to Docview Objects.
Definition: gen.h:1785
double GetAbsY() const
get absolute Y position of the pin ( after applying the parent&#39;s matrix and its own matrix ) ...
Definition: canpin.cpp:966
A2DGENERALDLLEXP long wxGenNewId()
This function is like wxNewId, but it has its own ID set.
Definition: gen.cpp:92
all basic primitives derived from a2dCanvasObject
#define wxDynamicCast(obj, className)
Define wxDynamicCast so that it will give a compiler error for unrelated types.
Definition: gen.h:75
void SetRoot(a2dDrawing *root, bool recurse=true)
Sets this object to a a2dCanvasDocument.
Definition: canobj.cpp:5933
virtual bool WalkTask(wxObject *parent, wxObject *object, a2dWalkEvent event)
called from within a2dCanvasDocument
Definition: algos.cpp:1122
bool GetGeneratePins() const
get the GeneratePins flag
Definition: canobj.h:2289
a2dCanvasObjectList * CreateChildObjectList()
create and get the list where the child objects are stored in.
Definition: canobj.cpp:2561
a2dCanvasObjectReference is a reference to any a2dCanvasObject derived class.
Definition: recur.h:53
a2dWalker_MakeTree(a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL)
constructor with no a2dPropertyId added yet. For that use AddPropertyId()
Definition: algos.cpp:941
virtual bool HasProperty(const a2dPropertyId *id, const wxString &stringvalue=wxEmptyString) const
Check if the object has a property with given id and string representation.
Definition: gen.cpp:1621
bool CanConnectWith(a2dIterC &ic, a2dCanvasObject *toConnect, bool autocreate)
check connect to other object
Definition: canobj.cpp:6790
bool Start(a2dObject *object)
Definition: algos.cpp:250
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const
when implemented the object without its children, is converted to
Definition: canprim.cpp:2075
a2dConnectTask
flags for searching a connecting a2dpinClass, for the connecting task at hand.
Definition: connectgen.h:40
a2dWalker_SetSpecificFlagsCanvasObjects(a2dCanvasObjectFlagsMask which, a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL)
constructor with no a2dPropertyId added yet. For that use AddPropertyId()
Definition: algos.cpp:759
virtual wxString GetName() const
Returns the name of this object, if no name is given the internal id will be returned.
Definition: gen.cpp:1310
const a2dStroke * a2dBLACK_STROKE
global a2dStroke stock object for BLACK stroking
void Initialize()
to initialize a walker class, default does nothing.
Definition: algos.cpp:54
const a2dAffineMatrix & GetTransformMatrix() const
get the matrix used to position the object
Definition: canobj.h:500
void SetRelease(bool value)
set release flag
Definition: gen.h:1346
void SetDepthFirst(bool depthFirst)
set if walker needs to go into recursive objects first.
Definition: gen.h:3946
bool m_viewdependent
on/off for view dependent updating
Definition: algos.h:712
void AddPropertyId(const a2dPropertyId *id)
add a a2dPropertyId to the list
Definition: algos.cpp:403
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const
when implemented the object without its children, is converted to
Definition: canprim.cpp:1211
bool Start(a2dCanvasObject *object)
start here
Definition: algos.cpp:1098
bool m_all
to remove all or only one property on each object found.
Definition: algos.h:217
void ConvertToLines(double aberation=0)
Convert complex segments to line segments.
Definition: polyver.cpp:1948
base algorithm class to work on a2dCanvasObjects in groups of layers
Definition: algos.h:838
unsigned int GetChildObjectsCount() const
get number of child objects
Definition: canobj.cpp:2570
~a2dWalker_LayerGroup()
destructor
Definition: algos.cpp:1231
bool m_viewspecific
set only visible for this view
Definition: algos.h:714
a2dCanvasObjectList m_found
pins found
Definition: algos.h:1317
static const long sm_PinCanConnectToPinClass
Pin can connect to supplied a2dPinClass.
Definition: canpin.h:505
void Initialize()
used from constructors
Definition: algos.cpp:1113
double m_AberPolyToArc
Polygon/polyline to Arc Maximum abberation.
Definition: algos.h:991
int GetMode() const
get current mode
Definition: canpin.h:313
OVERLAP Intersect(const a2dBoundingBox &, double Marge=0) const
Definition: bbox.cpp:205
bool m_all
to remove all or only one property on each object found.
Definition: algos.h:178
wxString m_objectname
name for object is not empty
Definition: algos.h:312
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const
when implemented the object without its children, is converted to
Definition: canprim.cpp:408
const a2dFill * a2dBLACK_FILL
global a2dFill stock object for BLACK filling
a2dPin is used in a2dCanvasObject to add pins to it.
Definition: canpin.h:233
This is a class/type description for a2dPin&#39;s.
Definition: canpin.h:628
void WriteStartElementAttributes(const wxString &name, bool newLine=true)
Writes start tag which has attributes.
Definition: genxmlpars.cpp:757
polygon defined with list of points.
Definition: polygon.h:45
Ref Counted base object.
Definition: gen.h:1045
~a2dWalker_FindAndSetCorridorPath()
destructor
Definition: algos.cpp:1888
a2dCanvasObjectList * GetAsPolygons()
convert to a list of a2dPolygonL and a2dPolylineL
Definition: vpath.cpp:116
void Initialize()
used from constructor
Definition: algos.cpp:1235
static const long moveLayers
move layers to target
Definition: algos.h:918
a2dDrawing * GetRoot() const
get a2dCanvasDocument of the object.
Definition: canobj.h:952
a2dLayerViewList & GetLayerRenderArray()
get the layer render array
Definition: drawer.h:564
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const
when implemented the object without its children, is converted to
Definition: vpath.cpp:67
a2dWalker_RemovePropertyCandoc(a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL, bool all=true)
constructor with no a2dPropertyId added yet. For that use AddPropertyId()
Definition: algos.cpp:285
a2dObject * Clone(CloneOptions options, a2dRefMap *refs=NULL) const
create an exact copy of this property
Definition: gen.cpp:1199
wxUint16 GetLayer()
get the layer that is to be rendered
Definition: canobj.h:3282
a2dWalker_CollectCanvasObjectsSet(a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL)
constructor with no a2dPropertyId added yet. For that use AddPropertyId()
Definition: algos.cpp:629
bool OnNrChilds(const a2dCanvasObjectPtr &x, const a2dCanvasObjectPtr &y)
used to canvas object on number of childs order and if same on name
Definition: algos.cpp:605
a2dPropertyIdList m_propertyList
properties to search for
Definition: algos.h:181
virtual bool GeneratePinsPossibleConnections(a2dPinClass *pinClass, a2dConnectTask task, double x, double y, double margin=0)
generates pins on all possible locations where the object can be connected.
Definition: canobj.cpp:3156
void SetDrawerStroke(const a2dStroke &stroke)
Used to set the current stroke.
Definition: drawer2d.cpp:565
bool IsIdentity(void) const
Is the matrix the identity matrix?
Definition: afmatrix.h:147
static const long ConvertToArcs
convert segments in polygon/polyline objects in group A to Arcs where possible
Definition: algos.h:924
~a2dWalker_DetectSmallSegments()
destructor
Definition: algos.cpp:1770
virtual void SetPending(bool pending)
set this object pending for update
Definition: canobj.cpp:2585
OVERLAP
Result of a a2dBoundingBox intersection or hittest.
Definition: bbox.h:24
static const long deleteLayers
delete layers
Definition: algos.h:922
wxUint16 m_intersectionCondition
test m_bbox against teh object in question for this condition
Definition: algos.h:324
bool GetThresholdDrawRectangle() const
underneath the threshold draw a rectangle instead of the real object.
Definition: drawer2d.h:217
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const
return the arrow converted to a vector path.
Definition: canprim.cpp:216
a2dRectC is a centered rectangle
Definition: canprim.h:99
static const long sm_PinConnected
Pin is connected rendering mode.
Definition: canpin.h:499
a2dPin * IsConnectedTo(a2dPin *pin=a2dAnyPin) const
Return the pin to which this pin is connected.
Definition: canpin.cpp:751
The base class for all drawable objects in a a2dCanvasDocument.
~a2dWalker_AllowedObjects()
destructor
Definition: algos.cpp:2044
void SetViewDependent(a2dDrawingPart *aView, bool viewdependent, bool viewspecific=false, bool onlyinternalarea=false, bool deep=false)
set the object view dependent and maybe process all children to set these flags
Definition: canobj.cpp:2816
static const long ConvertLinesArcs
convert shapes to seperate lines and arcs
Definition: algos.h:936
static const long ConvertToPolygonPolylinesWithArcs
convert to simple polygons and polylines preserve arcs
Definition: algos.h:926
wxUint16 GetPrimitiveThreshold() const
get drawing threshold
Definition: drawer2d.h:214
const long a2dWalkEvent
Definition: gen.h:3842
void Initialize()
used from constructors
Definition: algos.cpp:2938
bool GetFlag(const a2dCanvasObjectFlagsMask which) const
get specific bitflag value
Definition: canobj.cpp:2655
void Initialize()
used from constructors
Definition: algos.cpp:386
static const long ConvertToVPaths
convert shapes to vector paths
Definition: algos.h:934
OVERLAP GetClipStatus(a2dIterC &ic, OVERLAP clipparent)
used for deciding if the object needs to be rendered against the current clipping area of the active ...
Definition: canobj.cpp:3273
a2dCanvasObject is the base class for Canvas Objects.
Definition: canobj.h:371
std::vector< a2dLayerInfoPtr > & GetLayerIndex()
return array index on Layer
Definition: layerinf.cpp:555
a2dCanvasObjectList m_found
objects found
Definition: algos.h:384
virtual bool WalkTask(a2dIterC &ic, wxObject *parent, wxObject *object, a2dWalkEvent event)
called from within a2dCanvasDocument
Definition: algos.cpp:2182
a2dBoundingBox wxNonValidBbox
global non valid boundingbox to use as default argument etc.
Definition: bbox.cpp:23
void Initialize()
used from constructors
Definition: algos.cpp:793
bool WalkTask(wxObject *parent, wxObject *object, a2dWalkEvent event)
called from within a2dCanvasDocument
Definition: algos.cpp:121
bool m_depthFirst
Definition: gen.h:4000
a2dCanvasObjectList m_found
pins found
Definition: algos.h:1288
a2dCanvasObjectArrayReference is an array of a reference to any a2dCanvasObject derived class...
Definition: recur.h:131
a2dCanvasObjectPtr m_search
object found
Definition: algos.h:479
static const long ConvertPolylineToArcs
convert segments in polyline objects in group A to Arcs where possible
Definition: algos.h:932
void Initialize()
used from constructor
Definition: algos.cpp:2048
void ConvertPolylineToArc(double aber, double Rmin, double Rmax)
Definition: polyver.cpp:2369
a2dLayers * GetLayerSetup()
Get the layersettings for the canvas.
Definition: drawing.h:506
a2dCanvasObjectList * GetChildObjectList()
get the list where the child objects are stored in.
Definition: canobj.cpp:2551
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dNamedPropertyStart
id for a2dWalkEvent issued from within a2dWalkerIOHandler
void Initialize()
used from constructors
Definition: algos.cpp:550
void Initialize()
used from constructors
Definition: algos.cpp:2788
bool GetSelected() const
is the object selected flag set
Definition: canobj.h:1603
void WriteEndElement(bool newLine=true)
Writes correspondending end tag for the current start tag.
Definition: genxmlpars.cpp:862
double GetBboxWidth()
get width of the boundingbox in world coordinates relative to its parents
Definition: canobj.h:700
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const
when implemented the object without its children, is converted to
Definition: polygon.cpp:133
virtual a2dVertexList * GetAsVertexList(bool &returnIsPolygon) const
convert to a polygon.
Definition: polygon.cpp:1853
void RemoveClassName(wxString className)
remove this classname from set.
Definition: algos.cpp:421
void SetBin(bool bin)
general flag use at will.
Definition: canobj.h:2259
void Initialize()
used from constructors
Definition: algos.cpp:974
void EndFilterObject(a2dCanvasObject *canvasObject)
called when filter ends
Definition: canobj.cpp:817
bool Start(a2dCanvasObject *object)
Start traversing at object, returns true.
Definition: algos.cpp:2153
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
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dObjectStart
id for a2dWalkEvent issued from within a2dWalkerIOHandler
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dCanvasObjectPostChild
id for a2dWalkEvent issued from within a2dWalkerIOHandler
find wire/connect pinclass, given start pinclass of start pin
Definition: connectgen.h:43
wxUint64 a2dCanvasObjectFlagsMask
mask flags for a2dCanvasObject
Definition: candefs.h:152
void SetDrawerFill(const a2dFill &fill)
Used to set the current fill.
Definition: drawer2d.cpp:621
set a2dObjects property in a hierarchy of a a2dDocument
Definition: algos.h:563
void Initialize()
to initialize a walker class, default does nothing.
Definition: algos.cpp:835
Io handler to iterate through a a2dDocument.
Definition: gen.h:3911
void Initialize()
used from constructors
Definition: algos.cpp:2474
name of canvasobject reverse
Definition: algos.h:417
a2dWalker_DetectSmallSegments(a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL)
constructor with no a2dPropertyId added yet. For that use AddPropertyId()
Definition: algos.cpp:1752
bool GetCheck() const
general flag use at will.
Definition: gen.h:1342
void Transform(const a2dAffineMatrix &tworld, const wxString &type=wxT(""), a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL, const a2dPropertyId *id=NULL)
Transform objects fitting the given filter.
Definition: objlist.cpp:625
bool Disconnect(a2dPin *pin=a2dAnyPin, bool forceErase=false)
Definition: canpin.cpp:789
wxObject * m_currentParent
parent object of current object
Definition: gen.h:3987
bool Start(a2dCanvasObject *object)
start setting the root object from here
Definition: algos.cpp:931
void ConnectPins(a2dCanvasObject *parent, a2dPin *pinc, a2dPin *pinother, bool undo=false)
connect two pins which must be unconnected and at the same position
Definition: canobj.cpp:7037
void SetRootRecursive()
set a2dDrawing to its nested a2dCanvasObject&#39;s recursive for whole tree
Definition: drawing.cpp:913
a2dText is an abstract base class.
Definition: cantext.h:93
a2dCanvasObjectList * wxNullCanvasObjectList
define a NON a2dCanvasObjectList
Definition: objlist.cpp:53
bool Start(a2dObject *object)
object to start the algorithm
Definition: algos.cpp:193
virtual bool WalkTask(wxObject *parent, wxObject *object, a2dWalkEvent event)
called from within a2dCanvasDocument
Definition: algos.cpp:556
bool GetValid() const
returns true if boundingbox is calculated properly and therefore its valid flag is set...
Definition: bbox.cpp:299
double GetMinX() const
get minimum X of the boundingbox
Definition: bbox.cpp:304
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
bool m_allowClassList
to negate list of classnames to be filtered
Definition: algos.h:336
void Initialize()
used from constructor
Definition: algos.cpp:1774
a2dWalker_AllowedObjects(a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL)
constructor with no a2dPropertyId added yet. For that use AddPropertyId()
Definition: algos.cpp:2026
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const
when implemented the object without its children, is converted to
Definition: canprim.cpp:2390
bool NameSorterReverse(const a2dCanvasObjectPtr &x, const a2dCanvasObjectPtr &y)
used to canvas object on name in reverse order
Definition: algos.cpp:595
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
static const long ConvertToPolygonPolylinesWithoutArcs
convert to simple polygons and polylines
Definition: algos.h:928
a2dWalker_SetPropertyToObject(a2dNamedProperty *prop)
constructor with a2dPropertyId to set
Definition: algos.cpp:825
void SetCanvasObject(a2dCanvasObject *object)
set the object that is referenced
Definition: recur.cpp:109
Debug handler for output the hierarchy found in a a2dDocument.
Definition: algos.h:35
void SetMode(int mode)
default used to modify rendering
Definition: canpin.h:307
a2dEllipse centered at x,y.
Definition: canprim.h:635
polyline defined with list of points.
Definition: polygon.h:332
no special flags set
Definition: id.h:222
virtual bool WalkTask(wxObject *parent, wxObject *object, a2dWalkEvent event)
called from within a2dCanvasDocument
Definition: algos.cpp:2083
~a2dWalker_SetViewDependent()
destructor
Definition: algos.cpp:867
virtual a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const
when implemented the object without its children, is converted to
Definition: canobj.cpp:1505
void Initialize()
used from constructor
Definition: algos.cpp:1668
layer settings for a a2dCanvasDocument Holds layers settings classes
virtual bool WalkTask(wxObject *parent, wxObject *object, a2dWalkEvent event)
called from within a2dDocument
Definition: algos.cpp:840
Definition: bbox.h:26
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
bool Start(a2dCanvasObject *object)
Start traversing at object, returns true.
Definition: algos.cpp:2657
a2dWalkerIOHandlerWithContext(a2dIterC &ic)
constructor
Definition: algos.cpp:2137
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
a2dSLine
Definition: canprim.h:987
static const long ConvertToPolylines
convert shapes to polylines even if polygons
Definition: algos.h:938
Definition: bbox.h:27
Operation m_operation
id for operation
Definition: algos.h:998
a2dWalker_CollectCanvasObjects(a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL)
constructor with no a2dPropertyId added yet. For that use AddPropertyId()
Definition: algos.cpp:521
~a2dWalker_DetectSmall()
destructor
Definition: algos.cpp:1664
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const
return text as a vector path, where text outline is converted to polyline or polygons.
Definition: cantext.cpp:247
virtual bool WalkTask(wxObject *parent, wxObject *object, a2dWalkEvent event)
called from within a2dCanvasDocument
Definition: algos.cpp:982
wxUint16 GetLayer() const
Returns the layer index where this object is drawn upon.
Definition: canobj.h:2368
bool m_skipStartObject
the start object itself is not checked
Definition: algos.h:333
bool HasPins(bool realcheck=false)
are there a2dPin derived children
Definition: canobj.cpp:6414
void Prepend(a2dCanvasObject *obj)
prepend a a2dCanvasObject to the childobjects
Definition: canobj.cpp:6209
bool CheckMask(a2dCanvasObjectFlagsMask mask) const
Compares all flags in object to the given mask and return true is the same.
Definition: canobj.cpp:2665
bool InGroup(wxUint16 layer)
Definition: canglob.cpp:65
void Initialize()
used from constructors
Definition: algos.cpp:2334
bool GetBin() const
general flag use at will.
Definition: canobj.h:2262
bool Start(a2dObject *object, a2dCanvasObjectFuncW func)
object to start the algorithm
Definition: algos.cpp:148
static const long copyLayers
copy layers to target
Definition: algos.h:920
void RemovePins(bool NotConnected=false, bool onlyTemporary=false, bool now=false)
Remove all a2dPin children.
Definition: canobj.cpp:6504
virtual bool WalkTask(wxObject *parent, wxObject *object, a2dWalkEvent event)
called from within a2dDocument
Definition: algos.cpp:876
virtual bool WalkTask(wxObject *parent, wxObject *object, a2dWalkEvent event)
called from within a2dCanvasDocument
Definition: algos.cpp:1808
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dObjectEnd
id for a2dWalkEvent issued from within a2dWalkerIOHandler
static const long areaLayers
calculate area of objects
Definition: algos.h:942
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dPropertyStart
id for a2dWalkEvent issued from within a2dWalkerIOHandler
a2dArrow is used for having line begin and ends on specific objects.
Definition: canprim.h:198
set a2dCanvasObjects flags in a hierarchy of a a2dCanvasDocument
Definition: algos.h:486
a2dWalker_LayerGroup(a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL)
constructor with no a2dPropertyId added yet. For that use AddPropertyId()
Definition: algos.cpp:1213
void WriteEndAttributes(bool close=false)
&quot;Closes&quot; the start tag after writing all attributes (writes the &quot;&gt;&quot; or &quot;/&gt;&quot; bracket).
Definition: genxmlpars.cpp:837
virtual a2dCanvasObject * CreateConnectObject(a2dCanvasObject *parent, a2dPin *pinThis, a2dPin *pinOther, bool undo=false) const
generates a connection object with pins and all.
Definition: canobj.cpp:3169
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dCanvasObjectStart
id for a2dWalkEvent issued from within a2dWalkerIOHandler
void SetCheck(bool check)
general flag use at will.
Definition: gen.h:1339
virtual bool WalkTask(wxObject *parent, wxObject *object, a2dWalkEvent event)
called from within a2dDocument
Definition: algos.cpp:1892
bool RemoveRedundant(bool polygon)
line segments ( not arcs ) with same point are removed
Definition: polyver.cpp:2990
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const
when implemented the object without its children, is converted to
Definition: canprim.cpp:1762
virtual bool WalkTask(wxObject *parent, wxObject *object, a2dWalkEvent event)
called from within a2dCanvasDocument
Definition: algos.cpp:324
make the child which fit the mask/filter into a tree structure to a certain level ...
Definition: algos.h:755
A 2x3 affine matrix class for 2D transformations.
Definition: afmatrix.h:53
a2dLayers * m_layerSetup
availability set for this layer setup
Definition: algos.h:140
bool m_layervisible
if set, the layer must be visible
Definition: algos.h:327
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dCanvasObjectEnd
id for a2dWalkEvent issued from within a2dWalkerIOHandler
a2dPinClass * GetPinClass() const
return the pin class of this pin
Definition: canpin.h:356
bool Start(a2dCanvasObject *object)
Definition: algos.cpp:318
int m_currentDepth
contour to be used by algorithm, to decide on how deep recursing is to be.
Definition: gen.h:3996
bool DoConnect()
if return true, connection with other object on this object its pins is allowed.
Definition: canobj.h:1845
virtual bool WalkTask(wxObject *parent, wxObject *object, a2dWalkEvent event)
called from within a2dCanvasDocument
Definition: algos.cpp:798
a2dPropertyIdList m_propertyList
properties to search for
Definition: algos.h:220
void Initialize()
used from constructors
Definition: algos.cpp:2652
bool NameSorter(const a2dCanvasObjectPtr &x, const a2dCanvasObjectPtr &y)
used to canvas object on name
Definition: algos.cpp:585
void AddPropertyId(a2dPropertyId *id)
add a a2dPropertyId to the list
Definition: algos.cpp:312
virtual double GetContourWidth() const
get the Contour width of the shape
Definition: canobj.h:1411
while iterating a a2dCanvasDocument, this holds the context.
Definition: canobj.h:3212
Contains graphical drawing context specific classes. a2dDrawer2D and derived classes are used for dra...
a2dCanvasObjectFlagsMask m_mask
mask required in object
Definition: algos.h:223
void SetToObjectClone(a2dObject *obj, a2dPropertyId::SetFlags setflags=a2dPropertyId::set_none) const
Set this property to an object and clone it if neccessary.
Definition: gen.h:1855
bool Start(a2dCanvasObject *object)
Definition: algos.cpp:409
a2dWalker based algorithms
virtual bool WalkTask(wxObject *parent, wxObject *object, a2dWalkEvent event)
called from within a2dCanvasDocument
Definition: algos.cpp:256
bool WalkTask(wxObject *parent, wxObject *object, a2dWalkEvent event)
called from within a2dCanvasDocument
Definition: algos.cpp:64
a2dWalker_RenderLayers(a2dIterC &ic)
constructor
Definition: algos.cpp:2171
void MapBbox(const a2dAffineMatrix &matrix)
Definition: bbox.cpp:445
bool m_onlyinternalarea
transform without scale for children
Definition: algos.h:716
virtual void DrawHighLighted(a2dIterC &ic)
called by Render() if m_flags.m_HighLight is set
Definition: canobj.cpp:5020
double m_radiusMax
Polygon/polyline to Arc Maximum radius to test.
Definition: algos.h:989
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const
when implemented the object without its children, is converted to
Definition: polygon.cpp:1869
set< wxString > m_classnameMap
list of classnames to be filtered
Definition: algos.h:309
void Initialize()
to initialize a walker class, default does nothing.
Definition: algos.cpp:871
a2dWalker_LayerCanvasObjects(a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL)
constructor with no a2dPropertyId added yet. For that use AddPropertyId()
Definition: algos.cpp:1277
void Initialize()
used from constructors
Definition: algos.cpp:2577
virtual bool WalkTask(wxObject *parent, wxObject *object, a2dWalkEvent event)
called from within a2dDocument
Definition: algos.cpp:912
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dPropertyEnd
id for a2dWalkEvent issued from within a2dWalkerIOHandler
a2dCanvasObjectsSet m_found
objects found
Definition: algos.h:448
set pending flag in a drawing
Definition: algos.h:517
bool GetRelease() const
get release flag
Definition: gen.h:1350
double CalcArea() const
Definition: polyver.cpp:2151
bool Start(a2dObject *object, a2dCanvasObjectFunc func)
object to start the algorithm
Definition: algos.cpp:114
a2dWalker_RemoveHierarchy(a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL)
constructor with no a2dPropertyId added yet. For that use AddPropertyId()
Definition: algos.cpp:1074
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const
when implemented the object without its children, is converted to
Definition: canprim.cpp:3222
bool m_setOrClear
clear or set the flags
Definition: algos.h:513
a2dEndsLine with begin and/or end object.
Definition: canprim.h:1174
bool Start(a2dCanvasObject *object)
start at this object
Definition: algos.cpp:1249
double GetHitMarginWorld()
Get HitMargin in World units.
Definition: canobj.cpp:606
This is the base class for all kinds of property id&#39;s for a2dObject.
Definition: id.h:154
double GetWidth() const
returns width of the boundingbox
Definition: bbox.cpp:328
bool Start(a2dCanvasObject *object)
Start traversing at object, returns true.
Definition: algos.cpp:2722
An object of this class will update a a2dIterC with the required information.
Definition: canobj.h:3123
bool ClassOfObjectOke(a2dCanvasObject *obj)
return true of object fits the classname filter
Definition: algos.cpp:460
a2dWalker_DetectSmall(a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL)
constructor with no a2dPropertyId added yet. For that use AddPropertyId()
Definition: algos.cpp:1646
~a2dWalker_LayerCanvasObjects()
destructor
Definition: algos.cpp:1296
bool m_makePending
set object pending when property is removed.
Definition: algos.h:229
a2dVertexList * GetRedundant(bool polygon, double smallest=0)
line segments ( not arcs ) with same point are returned
Definition: polyver.cpp:3020
a2dLayerGroup m_groupA
group A layers operand
Definition: algos.h:884
bool m_layerselectable
if set, the layer must be selectable
Definition: algos.h:330
static const a2dCanvasObjectFlagsMask NoRenderCanvasObject
Definition: candefs.h:218
void SetClipStatus(OVERLAP status)
set the clipping withing the current view for the last added object in context
Definition: canobj.cpp:693
void SetTarget(wxUint16 targetlayer)
set the layer where the result will be placed
Definition: algos.cpp:1243
bool Start(a2dCanvasObject *object, bool setTo)
start removing properties from the object given, and down.
Definition: algos.cpp:784
bool Translate(double x, double y)
Translate by dx, dy:
Definition: afmatrix.cpp:420
bool Start(a2dCanvasObject *object)
start here
Definition: algos.cpp:965
bool m_useCheck
if set a2dObject are only walked if not m_check is set
Definition: gen.h:4003
double GetBboxHeight()
get height of the boundingbox in world coordinates relative to its parents
Definition: canobj.h:706
~a2dWalkerIOHandlerWithContext()
destructor
Definition: algos.cpp:2144
a2dCanvasObjectFlagsMask m_which
mask for which flags to set
Definition: algos.h:510
a2dBoundingBox m_bbox
object must be in this box if it the box is valid
Definition: algos.h:321
find normal object pinclass, given Connect/wire pinclass
Definition: connectgen.h:51
bool Start(a2dCanvasObject *object)
called from within a2dCanvasDocument
Definition: algos.cpp:2480
bool OnNrChildsReverse(const a2dCanvasObjectPtr &x, const a2dCanvasObjectPtr &y)
used to canvas object on number of childs reverse order and if same on name
Definition: algos.cpp:617
virtual bool WalkTask(wxObject *parent, wxObject *object, a2dWalkEvent event)
called from within a2dCanvasDocument
Definition: algos.cpp:1311
a2dWalker_FindCanvasObject(a2dCanvasObject *toSearch)
constructor with no a2dPropertyId added yet. For that use AddPropertyId()
Definition: algos.cpp:711
a2dRect
Definition: canprim.h:440
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 ObjectOke(a2dCanvasObject *obj)
return true if object fits the filter
Definition: algos.cpp:427
bool Start(a2dIterC &ic, a2dCanvasObject *object, bool ItsChildren=true)
Definition: algos.cpp:2582
~a2dWalker_RenderLayers()
destructor
Definition: algos.cpp:2177
void Initialize()
used from constructors
Definition: algos.cpp:658
virtual bool WalkTask(wxObject *parent, wxObject *object, a2dWalkEvent event)
called from within a2dCanvasDocument
Definition: algos.cpp:1702
virtual bool MayConnectTo(a2dPin *connectto)
Is given pin allowed to connect to this pin.
Definition: canpin.cpp:997
virtual bool RemoveProperty(const a2dPropertyId *id, bool all=true)
This function is called by a2dPropertyId to remove a property from the list.
Definition: gen.cpp:1573
virtual void Initialize()
to initialize a walker class, default does nothing.
Definition: gen.cpp:5257
static const long sm_PinUnConnected
Pin is not connected rendering mode.
Definition: canpin.h:497
a2dDrawingPart * m_drawingPart
visible on this drawingPart
Definition: algos.h:137
double GetMinY() const
get minimum Y of the boundingbox
Definition: bbox.cpp:310
affine matrix class
a2dArc centered at x,y
Definition: canprim.h:823
the a2dDrawingPart is a a2dView specially designed for displaying parts of a a2dDrawing. It uses a a2dDrawer2D to actually redraw things from the document, by giving that a2dDrawer2D as drawing context to the document, and telling the document to redraw a certain rectangular area. At that last is what this class is for. It optimizes the areas to be redrawn after object in the document were changed. To do that it combines redraw areas to a minimal set of redrawing areas. All the administration for this and the way things will be redrawn is from this view.
bool FilterObject(a2dCanvasObject *canvasObject)
apply object filter
Definition: canobj.cpp:809
bool Start(a2dCanvasObject *object)
called from within a2dCanvasDocument
Definition: algos.cpp:2340
int m_depth
wanted depth
Definition: algos.h:318
double m_radiusMin
Polygon/polyline to Arc Minimum radius to test.
Definition: algos.h:987
basetype GetPropertyValue(const a2dObject *obj) const
Get the property value in obj.
Definition: id.inl:325
static const long sm_PinCannotConnect
Pin can NOT be connected rendering mode.
Definition: canpin.h:503
a2dCanvasGlobal * a2dCanvasGlobals
global a2dCanvasGlobal to have easy access to global settings
Definition: canglob.cpp:1234
a2dCanvasObjectFlagsMask m_mask
object must fit this mask.
Definition: algos.h:306
a2dCanvasObject for a Vector Path
Definition: vpath.h:55
size_t GetNumberOfSegments()
get the number of points in the pointlist
Definition: polygon.h:229
set the a2dCanvasObject&#39;s a2dDrawing root recursive
Definition: algos.h:723
virtual a2dCanvasObjectList * GetAsPolygons(bool transform=true) const
convert to a list of polygons.
Definition: canobj.cpp:1510
a2dDrawingPart * m_drawingPart
which view to set view dependent
Definition: algos.h:710
a2dCanvasObjectList * ConvertToPolygons(a2dCanvasObject *canvasobject, bool transform)
Definition: algos.cpp:484
static const long ConvertPolygonToArcs
convert segments in polygon/polyline with width objects in group A to Arcs where possible ...
Definition: algos.h:930
Walker taking iterative context into account.
Definition: algos.h:1208
a2dWalker_FilterCanvasObjects(a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL)
constructor with no a2dPropertyId added yet. For that use AddPropertyId()
Definition: algos.cpp:358
virtual a2dCanvasObjectList * GetAsPolylines(bool transform=true) const
convert to a list of polylines.
Definition: canobj.cpp:1545
static const a2dCanvasObjectFlagsMask ALL
Definition: candefs.h:220
void AddClassName(wxString className)
add to classname to set of classes to be filtered.
Definition: algos.cpp:415
wxRect GetAbsoluteArea(a2dIterC &ic, int inflate=2)
Get absolute occupied area in the device coordinates.
Definition: canobj.cpp:3199
virtual bool WalkTask(wxObject *parent, wxObject *object, a2dWalkEvent event)
called from within a2dCanvasDocument
Definition: algos.cpp:729
a2dPropertyIdList m_propertyList
if not empty, object must have the properties in this list
Definition: algos.h:303
bool WalkTask(wxObject *parent, wxObject *object, a2dWalkEvent event)
called from within a2dCanvasDocument
Definition: algos.cpp:155
void Initialize()
used from constructor
Definition: algos.cpp:1300
double GetAbsX() const
get absolute X position of the pin ( after applying the parent&#39;s matrix and its own matrix ) ...
Definition: canpin.cpp:959
void Append(a2dCanvasObject *obj)
append a a2dCanvasObject to the childobjects
Definition: canobj.cpp:6224
const a2dAffineMatrix & GetTransform() const
Get the accumulated transform up to and including m_lworld of the current object. ...
Definition: canobj.cpp:663
a2dWalker_FindAndSetCorridorPath(a2dCanvasObject *findObject)
constructor
Definition: algos.cpp:1882
virtual void SetLayer(wxUint16 layer)
set layer index where this object is drawn upon.
Definition: canobj.cpp:5920
document walking to select a2dCanvasObject by filtering against several constraints.
Definition: algos.h:239
void AddPropertyId(a2dPropertyId *id)
add a a2dPropertyId to the list
Definition: algos.cpp:244
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const
when implemented the object without its children, is converted to
Definition: canprim.cpp:3950
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
void SetRenderChildDerived(bool value)
when set child object in derived a2dCanvasObject are rendered, else only the object itself...
Definition: canobj.h:3433
wxUint16 m_target
result into this layer
Definition: algos.h:890
A pointer class, that automatically calls SmrtPtrOwn/SmrtPtrRelease.
Definition: a2dlist.h:20
void Initialize()
to initialize a walker class, default does nothing.
Definition: algos.cpp:723
void SetStopWalking(bool stopWalking)
to further recursion, e.g. in a2dObject::Walker()
Definition: gen.h:3931
bool Start(a2dObject *object)
start removing properties from the object given, and down.
Definition: algos.h:634
OVERLAP GetParentClipStatus() const
what is the clipping withing the current view for the second last added object in context ...
Definition: canobj.cpp:679
bool WalkTask(wxObject *parent, wxObject *object, a2dWalkEvent event)
called from within a2dCanvasDocument
Definition: algos.cpp:199
double DeviceToWorldXRel(double x) const
convert x relative from device to world coordinates
Definition: drawer2d.h:444
find normal object pinclass, given Connect/wire pinclass
Definition: connectgen.h:52
structure to give as parameter to member functions of a2dCanvasObject
Definition: canobj.h:252
a2dBoundingBox & GetBbox()
get boundingbox in world coordinates exclusive stroke width relative to its parent ...
Definition: canobj.cpp:3175
Contain one drawing as hierarchical tree of a2dCanvasObject&#39;s.
Definition: drawing.h:434
bool m_selectedOnlyB
work only on selected object in group B
Definition: algos.h:895
a2dCanvasObjectList * ConvertToVpath(a2dCanvasObject *canvasobject, bool transform)
Definition: algos.cpp:492
bool m_selectedOnlyA
work only on selected object in group A
Definition: algos.h:893
static const long RemoveRedundant
remove redundant segment
Definition: algos.h:940
find a2dCanvasObjects in a hierarchy of a a2dCanvasDocument
Definition: algos.h:462
wxInt64 GetUniqueSerializationId() const
return a unique id for this object
Definition: gen.cpp:1450
wxInt64 m_id
wanted id
Definition: algos.h:315
a2dEllipticArc centered at x,y
Definition: canprim.h:697
a2dDrawing * m_root
document to set
Definition: algos.h:745
static const long sm_PinCanConnect
Pin can be connected rendering mode.
Definition: canpin.h:501
a2dWalker_SetViewDependent(a2dDrawingPart *drawingPart, bool viewdependent, bool viewspecific=false, bool onlyinternalarea=false)
constructor
Definition: algos.cpp:859
general canvas module declarations and classes
algos.cpp Source File -- Sun Oct 12 2014 17:04:12 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation