wxArt2D
cameleon.cpp
1 /*! \ file canvas/src/recur.cpp
2  \author Klaas Holwerda
3 
4  Copyright: 2001-2004 (c) Klaas Holwerda
5 
6  Licence: wxWidgets Licence
7 
8  RCS-ID: $Id: recur.cpp,v 1.107 2009/09/26 20:40:32 titato Exp $
9 */
10 
11 #include "a2dprec.h"
12 
13 #ifdef __BORLANDC__
14 #pragma hdrstop
15 #endif
16 
17 #ifndef WX_PRECOMP
18 #include "wx/wx.h"
19 #endif
20 
21 #include "wx/canvas/cameleon.h"
22 #include "wx/canvas/objlist.h"
23 #include "wx/canvas/canglob.h"
24 #include "wx/canvas/drawing.h"
25 #include "wx/canvas/algos.h"
26 
27 #include <wx/wfstream.h>
28 #include <math.h>
29 #include <float.h>
30 
31 
32 //----------------------------------------------------------------------------
33 // a2dHasParameters
34 //----------------------------------------------------------------------------
35 IMPLEMENT_DYNAMIC_CLASS( a2dHasParameters, a2dCanvasObject )
36 
37 a2dHasParameters::a2dHasParameters( double x, double y )
38  : a2dCanvasObject( x, y )
39 {
40 }
41 
42 a2dHasParameters::~a2dHasParameters()
43 {
44 }
45 
47  : a2dCanvasObject( other, options, refs )
48 {
49 }
50 
52 {
53  a2dHasParameters* a = new a2dHasParameters( *this, options, refs );
54  return a;
55 }
56 
57 void a2dHasParameters::AddStringParameter( const wxString& name, const wxString& value )
58 {
59  a2dPropertyId* propid = GetParameterId( name );
60  if ( !propid )
61  propid = new a2dPropertyIdString( name, wxT( "" ), a2dPropertyId::flag_userDefined );
62  a2dPropertyIdString* strprop = NULL;
63  strprop = dynamic_cast<a2dPropertyIdString*>( propid );
64  if ( !strprop )
65  wxLogWarning( _T( "property with this name already exists, but with different type, skipped" ) );
66  else
67  {
68  a2dStringProperty* nprop = new a2dStringProperty( strprop, value );
69  m_parametermap[ propid ] = nprop;
70  }
71 }
72 
73 void a2dHasParameters::AddIntegerParameter( const wxString& name, wxInt32 value )
74 {
75  a2dPropertyId* propid = GetParameterId( name );
76  if ( !propid )
77  propid = new a2dPropertyIdInt32( name, 0, a2dPropertyId::flag_userDefined );
78  a2dPropertyIdInt32* intprop = NULL;
79  intprop = dynamic_cast<a2dPropertyIdInt32*>( propid );
80  if ( !intprop )
81  wxLogWarning( _T( "property with this name already exists, but with different type, skipped" ) );
82  else
83  {
84  a2dInt32Property* nprop = new a2dInt32Property( intprop, value );
85  m_parametermap[ propid ] = nprop;
86  }
87 }
88 
89 void a2dHasParameters::AddBoolParameter( const wxString& name, bool value )
90 {
91  a2dPropertyId* propid = GetParameterId( name );
92  if ( !propid )
93  propid = new a2dPropertyIdBool( name, false, a2dPropertyId::flag_userDefined );
94  a2dPropertyIdBool* boolprop = NULL;
95  boolprop = dynamic_cast<a2dPropertyIdBool*>( propid );
96  if ( !boolprop )
97  wxLogWarning( _T( "property with this name already exists, but with different type, skipped" ) );
98  else
99  {
100  a2dBoolProperty* nprop = new a2dBoolProperty( boolprop, value );
101  m_parametermap[ propid ] = nprop;
102  }
103 }
104 
105 void a2dHasParameters::AddDoubleParameter( const wxString& name, double value )
106 {
107  a2dPropertyId* propid = GetParameterId( name );
108  if ( !propid )
109  propid = new a2dPropertyIdDouble( name, false, a2dPropertyId::flag_userDefined );
110  a2dPropertyIdDouble* doubleprop = NULL;
111  doubleprop = dynamic_cast<a2dPropertyIdDouble*>( propid );
112  if ( !doubleprop )
113  wxLogWarning( _T( "property with this name already exists, but with different type, skipped" ) );
114  else
115  {
116  a2dDoubleProperty* nprop = new a2dDoubleProperty( doubleprop, value );
117  m_parametermap[ propid ] = nprop;
118  }
119 }
120 
121 void a2dHasParameters::TakeParameters( a2dHasParameters* parInst ) const
122 {
123  for ( a2dParameterMap::const_iterator i = m_parametermap.begin(); i != m_parametermap.end(); i++ )
124  {
125  a2dPropertyIdPtr propId = (*i).first;
126  if ( propId->IsUserDefined() )
127  {
128  a2dNamedPropertyPtr namedprop = (*i).second;
129  namedprop = namedprop->Clone( clone_deep );
130  parInst->GetParameters().operator[](propId) = namedprop;
131  }
132  }
133 }
134 
135 void a2dHasParameters::SetParameter( a2dPropertyId *dynproperty, a2dNamedProperty* namedproperty )
136 {
137  m_parametermap[ dynproperty ] = namedproperty;
138 }
139 
140 a2dNamedProperty* a2dHasParameters::GetParameter( const a2dPropertyIdPtr id ) const
141 {
142  m_parametermap.find( id );
143  return (* m_parametermap.find( id )).second;
144 }
145 
146 a2dPropertyId* a2dHasParameters::GetParameterId( const wxString &idName ) const
147 {
148  for ( a2dParameterMap::const_iterator i = m_parametermap.begin(); i != m_parametermap.end(); i++ )
149  {
150  a2dPropertyIdPtr propId = (*i).first;
151  if ( propId->GetName() == idName )
152  return propId;
153  }
154  return 0;
155 }
156 
157 a2dNamedProperty* a2dHasParameters::GetParameter( const wxString &idName ) const
158 {
159  for ( a2dParameterMap::const_iterator i = m_parametermap.begin(); i != m_parametermap.end(); i++ )
160  {
161  a2dPropertyIdPtr propId = (*i).first;
162  if ( propId->GetName() == idName )
163  {
164  return (*i).second;
165  }
166  }
167  return 0;
168 }
169 
170 //----------------------------------------------------------------------------
171 // a2dPort
172 //----------------------------------------------------------------------------
173 IMPLEMENT_DYNAMIC_CLASS( a2dPort, a2dCanvasObject )
174 
175 double a2dPort::m_l1 = 1;
176 double a2dPort::m_l2 = 2;
177 double a2dPort::m_l3 = 3;
178 double a2dPort::m_b = 2;
179 bool a2dPort::m_doRender = true;
180 
182  :
184 {
185  m_parPinClass = a2dPinClass::Standard;
186 }
187 
188 a2dPort::a2dPort( double x, double y, const wxString& name, a2dPinClass* pinclass, a2dPinClass* parPinClass )
189  :
191 {
192  SetPosXY( x, y );
193  SetName( name );
194 
195  a2dPin* pin = new a2dPin( this, wxT( "1" ), pinclass, 0.0, 0.0 );
196  Append( pin );
197  m_parPinClass = parPinClass;
198 }
199 
200 a2dPort::~a2dPort()
201 {
202 }
203 
204 a2dPort::a2dPort( const a2dPort& other, CloneOptions options, a2dRefMap* refs )
205  : a2dCanvasObject( other, options, refs )
206 {
207  static int nr = 1;
208  nr++;
209 
210  wxString strNr = wxString::Format("%d", nr);
211  m_name = other.m_name + strNr;
212  m_parPinClass = other.m_parPinClass;
213 }
214 
216 {
217  a2dPort* a = new a2dPort( *this, options, refs );
218  return a;
219 }
220 
221 a2dPin* a2dPort::GetPin() const
222 {
223  a2dPin* find = NULL;
224  a2dCanvasObjectList::const_iterator iter = m_childobjects->begin();
225  while ( iter != m_childobjects->end() )
226  {
227  find = wxDynamicCast( ( *iter ).Get(), a2dPin );
228  if ( find )
229  {
230  return find;
231  }
232  iter++;
233  }
234  return NULL;
235 }
236 
237 void a2dPort::Set( double l1, double l2, double l3, double b )
238 {
239  m_l1 = l1;
240  m_l2 = l2;
241  m_l3 = l3;
242  m_b = b;
243 }
244 
245 a2dBoundingBox a2dPort::DoGetUnTransformedBbox( a2dBboxFlags WXUNUSED( flags ) ) const
246 {
247  double grid = GetHabitat()->GetObjectGridSize();
248  a2dBoundingBox bbox;
249  bbox.Expand( 0 , grid * - m_b / 2 );
250  bbox.Expand( grid * m_l3 , grid * m_b / 2 );
251  return bbox;
252 }
253 
254 void a2dPort::DoRender( a2dIterC& ic, OVERLAP WXUNUSED( clipparent ) )
255 {
256  if ( !m_doRender )
257  return;
258 
259  double grid = GetHabitat()->GetObjectGridSize();
260 
261  a2dVertexArray points;
262  points.push_back( new a2dLineSegment( 0, 0 ) );
263  points.push_back( new a2dLineSegment( grid * m_l1, grid * m_b / 2.0 ) );
264  points.push_back( new a2dLineSegment( grid * m_l3, grid * m_b / 2.0 ) );
265  points.push_back( new a2dLineSegment( grid * m_l2, 0 ) );
266  points.push_back( new a2dLineSegment( grid * m_l3, grid * -m_b / 2.0 ) );
267  points.push_back( new a2dLineSegment( grid * m_l1, grid * -m_b / 2.0 ) );
268 
269  ic.GetDrawer2D()->DrawPolygon( &points, false, wxWINDING_RULE );
270 }
271 
273 {
274  double grid = GetHabitat()->GetObjectGridSize();
275  a2dVertexArray points;
276  points.push_back( new a2dLineSegment( 0, 0 ) );
277  points.push_back( new a2dLineSegment( grid * m_l1, grid * m_b / 2.0 ) );
278  points.push_back( new a2dLineSegment( grid * m_l3, grid * m_b / 2.0 ) );
279  points.push_back( new a2dLineSegment( grid * m_l2, 0 ) );
280  points.push_back( new a2dLineSegment( grid * m_l3, grid * -m_b / 2.0 ) );
281  points.push_back( new a2dLineSegment( grid * m_l1, grid * -m_b / 2.0 ) );
282 
283  a2dPoint2D P = a2dPoint2D( hitEvent.m_relx, hitEvent.m_rely );
284  hitEvent.m_how = points.HitTestPolygon( P, ic.GetWorldStrokeExtend() + ic.GetTransformedHitMargin() );
285 
286  return hitEvent.m_how.IsHit();
287 }
288 
289 //----------------------------------------------------------------------------
290 // a2dParPin
291 //----------------------------------------------------------------------------
292 IMPLEMENT_DYNAMIC_CLASS( a2dParPin, a2dPin )
293 
295  : a2dPin()
296 {
297  SetVisible( true );
298 }
299 
300 a2dParPin::a2dParPin( a2dCameleonInst* parent, a2dPort* portPin, a2dPinClass* parPinClass )
301  : a2dPin( parent,
302  portPin->GetName(),
303  parPinClass,
304  portPin->GetPosX(), portPin->GetPosY(),
305  portPin->GetPin()->GetAbsAngle(),
306  parPinClass->GetParPin()->GetWidth(),
307  parPinClass->GetParPin()->GetHeight(),
308  parPinClass->GetParPin()->GetRadius() )
309 {
310  SetVisible( true );
311  m_port = portPin;
312 }
313 
314 a2dParPin::a2dParPin( a2dPinClass* parPinClass, double w, double h )
315  : a2dPin( NULL,
316  "unDefined",
317  parPinClass,
318  0,0,
319  0,
320  w,
321  h,
322  0 )
323 {
324  SetVisible( true );
325  m_port = NULL;
326 }
327 
328 a2dParPin::~a2dParPin()
329 {
330 }
331 
332 a2dParPin::a2dParPin( const a2dParPin& other, CloneOptions options, a2dRefMap* refs )
333  : a2dPin( other, options, refs )
334 {
335  m_port = other.m_port;
336 }
337 
339 {
340  a2dParPin* a = new a2dParPin( *this, options, refs );
341  return a;
342 }
343 
345 {
346  if( !other )
347  return false;
348 
349 
350  if ( m_port.Get() )
351  return false;
352 
353  a2dPort* port = wxDynamicCast( other, a2dPort );
354 
355  if ( !port )
356  {
357  wxString reference_name = GetName();
358  //a2dGeneralGlobals->ReportErrorF( a2dError_LinkPin, _( "a2dParPin with name %s \n Linked to wrong object type" ), reference_name.c_str() );
359  return false;
360  }
361  port->SetCheck( true );
362  m_port = port;
363  return true;
364 }
365 
366 #if wxART2D_USE_CVGIO
367 void a2dParPin::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
368 {
369  a2dPin::DoSave( parent, out, xmlparts, towrite );
370  if ( xmlparts == a2dXmlSer_attrib )
371  {
372  out.WriteAttribute( wxT( "portid" ), m_port->GetUniqueSerializationId() );
373  }
374  else
375  {
376  }
377 }
378 
379 void a2dParPin::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
380 {
381  a2dPin::DoLoad( parent, parser, xmlparts );
382 
383  if ( xmlparts == a2dXmlSer_attrib )
384  {
385  if ( parser.HasAttribute( wxT( "portid" ) ) )
386  {
387  wxString portid = parser.GetAttributeValue( wxT( "portid" ) );
388  parser.ResolveOrAddLink( this, portid );
389  }
390  }
391  else
392  {
393  }
394 }
395 #endif //wxART2D_USE_CVGIO
396 
397 //----------------------------------------------------------------------------
398 // a2dAppear
399 //----------------------------------------------------------------------------
400 
401 bool a2dAppear::m_nextLine = false;
402 
403 IMPLEMENT_CLASS( a2dAppear, a2dCanvasObject )
404 
405 a2dAppear::a2dAppear( a2dCameleon* cameleon, double x, double y )
406  : a2dCanvasObject( x, y )
407 {
408  m_cameleon = cameleon;
409 }
410 
411 a2dAppear::a2dAppear( const a2dAppear& other, CloneOptions options, a2dRefMap* refs )
412  : a2dCanvasObject( other, options, refs )
413 {
414  m_cameleon = other.m_cameleon;
415 }
416 
417 a2dAppear::~a2dAppear()
418 {
419 }
420 
422 {
423  return new a2dAppear( *this, options, refs );
424 }
425 
426 #if wxART2D_USE_CVGIO
427 void a2dAppear::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
428 {
429  a2dCanvasObject::DoSave( parent, out, xmlparts, towrite );
430 }
431 
432 void a2dAppear::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
433 {
434  a2dCanvasObject::DoLoad( parent, parser, xmlparts );
435 }
436 #endif //wxART2D_USE_CVGIO
437 
438 //----------------------------------------------------------------------------
439 // a2dDiagram
440 //----------------------------------------------------------------------------
441 
442 IMPLEMENT_DYNAMIC_CLASS( a2dDiagram, a2dAppear )
443 
444 BEGIN_EVENT_TABLE( a2dDiagram, a2dAppear )
445  EVT_UPDATE_DRAWING( a2dDiagram::OnUpdateFromDrawing )
446 END_EVENT_TABLE()
447 
448 a2dDiagram::a2dDiagram()
449  :
450  m_diagramDrawing( NULL ),
451  a2dAppear( NULL, 0, 0 )
452 {
453 }
454 
455 a2dDiagram::a2dDiagram( a2dCameleon* cameleon, double x, double y )
456  :
457  a2dAppear( cameleon, x, y )
458 {
459  wxASSERT_MSG( m_cameleon, wxT( "a2dCamelon not set in a2dDiagram" ) );
460  if ( m_cameleon->GetHabitat() )
461  {
462  m_diagramDrawing = (a2dDrawing*) m_cameleon->GetHabitat()->GetDiagramDrawingTemplate()->Clone( clone_deep );
463  }
464  else
465  m_diagramDrawing = new a2dDrawing( wxEmptyString, NULL );
466  m_diagramDrawing->SetHabitat( m_cameleon->GetHabitat() );
467  m_diagramDrawing->SetParent( this );
468  //m_diagramDrawing->ConnectEvent( wxEVT_UPDATE_DRAWING, this );
469 }
470 
471 a2dDiagram::a2dDiagram( const a2dDiagram& other, CloneOptions options, a2dRefMap* refs )
472  : a2dAppear( other, options, refs )
473 {
474  if ( ! (options & clone_members) )
475  {
476  m_diagramDrawing = other.m_diagramDrawing;
477  }
478  else if ( options & clone_members && other.m_diagramDrawing )
479  {
480  m_diagramDrawing = other.m_diagramDrawing->TClone( CloneOptions( options | clone_noCameleonRef ) );
481  m_diagramDrawing->SetParent( this );
482  //m_diagramDrawing->ConnectEvent( wxEVT_UPDATE_DRAWING, this );
483  }
484  else
485  {
486  m_diagramDrawing = other.m_diagramDrawing;
487  }
488 }
489 
491 {
492  return new a2dDiagram( *this, options, refs );
493 }
494 
495 a2dDiagram::~a2dDiagram()
496 {
497  //if ( m_diagramDrawing )
498  //m_diagramDrawing->DisconnectEvent( wxEVT_UPDATE_DRAWING, this );
499 }
500 
501 a2dBoundingBox a2dDiagram::GetUnTransformedBboxNoPorts() const
502 {
503  a2dBoundingBox childbox;
504 
505  a2dBoundingBox bbox;
506  a2dPort* find = NULL;
507  a2dCanvasObjectList::iterator iter = m_diagramDrawing->GetRootObject()->CreateChildObjectList()->begin();
508  while ( iter != m_diagramDrawing->GetRootObject()->CreateChildObjectList()->end() )
509  {
510  find = wxDynamicCast( ( *iter ).Get(), a2dPort );
511  if ( !find )
512  {
513  childbox.Expand( ( *iter )->GetBbox() );
514  }
515  else
516  childbox.Expand( ( *iter )->GetPosXY() );
517  iter++;
518  }
519  if ( !childbox.GetValid() )
520  childbox.Expand( 0, 0 );
521  //childbox.MapBbox( m_lworld );
522  bbox.Expand( childbox );
523  return bbox;
524 }
525 
526 void a2dDiagram::OnUpdateFromDrawing( a2dDrawingEvent& event )
527 {
528  if (event.GetUpdateHint() & a2dCANVIEW_UPDATE_PENDING_POSTUPDATE)
529  {
530  a2dPort* find = NULL;
531  a2dCanvasObjectList::iterator iter = m_diagramDrawing->GetRootObject()->CreateChildObjectList()->begin();
532  while ( iter != m_diagramDrawing->GetRootObject()->GetChildObjectList()->end() )
533  {
534  find = wxDynamicCast( ( *iter ).Get(), a2dPort );
535  if ( find && find->GetPending() )
536  {
538  }
539  iter++;
540  }
541  }
542  event.Skip();
543 }
544 
546 {
547  return m_diagramDrawing->PushInto( parent );
548 }
549 
551 {
552  a2dPort* find = NULL;
553  a2dCanvasObjectList::iterator iter = m_diagramDrawing->GetRootObject()->CreateChildObjectList()->begin();
554  while ( iter != m_diagramDrawing->GetRootObject()->GetChildObjectList()->end() )
555  {
556  find = wxDynamicCast( ( *iter ).Get(), a2dPort );
557  if ( find )
558  {
559  a2dParPin* parPin = NULL;
560  if ( find->GetParPinClass() && find->GetParPinClass()->GetParPin() )
561  {
562  parPin = (a2dParPin*) ( find->GetParPinClass()->GetParPin()->Clone( clone_deep ) );
563  parPin->SetPort( find );
564  parPin->Set( find->GetPosX(), find->GetPosY(), find->GetAngle(), find->GetName() );
565  }
566  else
567  parPin = new a2dParPin( parInst, find, find->GetParPinClass() );
568  parInst->Append( parPin );
569  }
570  iter++;
571  }
572 }
573 
574 
575 void a2dDiagram::TranslateTo( double dx, double dy )
576 {
577  a2dCanvasObjectList::iterator iter = m_diagramDrawing->GetRootObject()->CreateChildObjectList()->begin();
578  while ( iter != m_diagramDrawing->GetRootObject()->GetChildObjectList()->end() )
579  {
580  a2dCanvasObject* obj = ( *iter );
581  if ( obj )
582  {
583  obj->Translate( dx, dy );
584  }
585  iter++;
586  }
587 }
588 
590 {
591  double xmin = DBL_MAX;
592  double ymax = -DBL_MAX;
593 
594  a2dPort* find = NULL;
595  a2dPort* best = NULL;
596  a2dCanvasObjectList::iterator iter = m_diagramDrawing->GetRootObject()->CreateChildObjectList()->begin();
597  while ( iter != m_diagramDrawing->GetRootObject()->GetChildObjectList()->end() )
598  {
599  find = wxDynamicCast( ( *iter ).Get(), a2dPort );
600  if ( find )
601  {
602  if ( xmin > find->GetPosX() )
603  {
604  best = find;
605  xmin = best->GetPosX();
606  }
607  else if ( xmin == find->GetPosX() )
608  {
609  best = find;
610  ymax = find->GetPosY();
611  }
612  return find;
613  }
614  iter++;
615  }
616  return best;
617 }
618 
619 
621 {
622  a2dPort* find = NULL;
623  a2dCanvasObjectList::iterator iter = m_diagramDrawing->GetRootObject()->CreateChildObjectList()->begin();
624  while ( iter != m_diagramDrawing->GetRootObject()->GetChildObjectList()->end() )
625  {
626  find = wxDynamicCast( ( *iter ).Get(), a2dPort );
627  if ( find && find->GetName() == symPin->GetName() )
628  return find;
629  iter++;
630  }
631  return NULL;
632 }
633 
635 {
636  a2dPort* find = NULL;
637  a2dCanvasObjectList::iterator iter = m_diagramDrawing->GetRootObject()->CreateChildObjectList()->begin();
638  while ( iter != m_diagramDrawing->GetRootObject()->GetChildObjectList()->end() )
639  {
640  find = wxDynamicCast( ( *iter ).Get(), a2dPort );
641  if ( find && find->GetName() == parPin->GetName() )
642  return find;
643  iter++;
644  }
645  return NULL;
646 }
647 
648 a2dPort* a2dDiagram::FindPortByName( const wxString& parPinName ) const
649 {
650  a2dPort* find = NULL;
651  a2dCanvasObjectList::iterator iter = m_diagramDrawing->GetRootObject()->CreateChildObjectList()->begin();
652  while ( iter != m_diagramDrawing->GetRootObject()->GetChildObjectList()->end() )
653  {
654  find = wxDynamicCast( ( *iter ).Get(), a2dPort );
655  if ( find && find->GetName() == parPinName )
656  return find;
657  iter++;
658  }
659  return NULL;
660 }
661 
663 {
664  a2dVisibleParameter* find = NULL;
665  a2dCanvasObjectList::iterator iter = m_diagramDrawing->GetRootObject()->CreateChildObjectList()->begin();
666  while ( iter != m_diagramDrawing->GetRootObject()->CreateChildObjectList()->end() )
667  {
668  find = wxDynamicCast( ( *iter ).Get(), a2dVisibleParameter );
669  if ( find )
670  {
671  a2dVisibleParameter* visPar = wxDynamicCast( find->Clone( a2dObject::clone_deep ), a2dVisibleParameter );
672  visPar->SetParent( parInst );
673  parInst->Append( visPar );
674  }
675  iter++;
676  }
677 }
678 
680 {
681  a2dCanvasObject* parent = wxDynamicCast( handler->GetParent(), a2dCanvasObject );
682  if ( parent && parent->GetHighLight() && !parent->GetPending() && GetPending() )
683  {
684  parent->SetPending( true );
685  }
686 }
687 
688 void a2dDiagram::DoWalker( wxObject* parent, a2dWalkerIOHandler& handler )
689 {
690  a2dCanvasObject::DoWalker( parent, handler );
691 
692  if ( m_diagramDrawing )
693  m_diagramDrawing->Walker( this, handler );
694 }
695 
696 #if wxART2D_USE_CVGIO
697 void a2dDiagram::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
698 {
699  a2dAppear::DoSave( parent, out, xmlparts, towrite );
700  if ( xmlparts == a2dXmlSer_attrib )
701  {
702  if ( m_diagramDrawing )
703  out.WriteAttribute( wxT( "drawing" ), m_diagramDrawing->GetUniqueSerializationId() );
704  }
705  else
706  {
707  if ( m_diagramDrawing && !m_diagramDrawing->GetCheck() )
708  {
709  a2dObjectPtr multiRef = m_diagramDrawing.Get();
710 
711  out.WriteStartElement( wxT( "drawing" ) );
712  m_diagramDrawing->Save( this, out, towrite, NULL );
713  out.WriteEndElement();
714  }
715  }
716 }
717 
718 void a2dDiagram::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
719 {
720  a2dAppear::DoLoad( parent, parser, xmlparts );
721  if ( xmlparts == a2dXmlSer_attrib )
722  {
723  if ( parser.HasAttribute( wxT( "drawing" ) ) )
724  {
725  parser.ResolveOrAdd( ( a2dSmrtPtr<class a2dObject>* ) &m_diagramDrawing, parser.GetAttributeValue( wxT( "drawing" ) ) );
726  }
727  }
728  else
729  {
730  if ( parser.GetTagName() != wxT( "drawing" ) )
731  return;
732 
733  parser.Require( START_TAG, wxT( "drawing" ) );
734  parser.Next();
735 
736  m_diagramDrawing = (a2dDrawing*) parser.LoadOneObject( this );
737  m_diagramDrawing->SetParent( this );
738  //m_diagramDrawing->ConnectEvent( wxEVT_UPDATE_DRAWING, this );
739 
740  parser.Require( END_TAG, wxT( "drawing" ) );
741  parser.Next();
742  }
743 }
744 #endif //wxART2D_USE_CVGIO
745 
747 {
748  double grid = GetHabitat()->GetObjectGridSize();
749 
750  a2dBoundingBox bbox;
751  bbox.Expand( 0, 0 );
752  bbox.Expand( 30*grid, m_nextLine ? 4*grid: -4*grid );
753  return bbox;
754 }
755 
756 void a2dDiagram::DoRender( a2dIterC& ic, OVERLAP clipparent )
757 {
758  double grid = GetHabitat()->GetObjectGridSize();
759  a2dDrawer2D *d(ic.GetDrawer2D());
760 
761  int align = m_nextLine ? wxMINX|wxMAXY: wxMINX|wxMINY;
762 
763  d->DrawRoundedRectangle( 0, 0, 30*grid, m_nextLine ? 4*grid: -4*grid , 1*grid );
764  d->SetFont( a2dCanvasModule::GetFontMedBold() );
765  d->DrawText( " diagram : " + GetName(), 0, m_nextLine ? 1.5*grid: -1.5*grid, align, false);
766  d->SetFont( a2dCanvasModule::GetFontSmall() );
767  wxString classn = GetClassInfo()->GetClassName();
768  classn = "type: " + classn;
769  d->DrawText( classn, 2, m_nextLine ? 2.6*grid: -2.6*grid, align, false);
770 }
771 
773 {
774  double grid = GetHabitat()->GetObjectGridSize();
775  double margin = ic.GetTransformedHitMargin();
776 
777  hitEvent.m_how = HitTestRectangle( hitEvent.m_relx, hitEvent.m_rely, 0, 0, 30*grid, m_nextLine ? 4*grid: -4*grid, ic.GetWorldStrokeExtend() + margin );
778 
779  return hitEvent.m_how.IsHit();
780 }
781 
782 
783 
784 //----------------------------------------------------------------------------
785 // a2dSymbol
786 //----------------------------------------------------------------------------
787 IMPLEMENT_DYNAMIC_CLASS( a2dSymbol, a2dDiagram )
788 
790  : a2dDiagram()
791 {
792 }
793 
794 a2dSymbol::a2dSymbol( a2dCameleon* cameleon, double x, double y )
795  : a2dDiagram( cameleon, x, y )
796 {
797  wxASSERT_MSG( m_cameleon, wxT( "a2dCamelon not set in a2dDiagram" ) );
798  if ( m_cameleon->GetHabitat() )
799  {
800  m_diagramDrawing = (a2dDrawing*) m_cameleon->GetHabitat()->GetSymbolDrawingTemplate()->Clone( clone_deep );
801  }
802  else
803  m_diagramDrawing = new a2dDrawing( wxEmptyString, NULL );
804  m_diagramDrawing->SetHabitat( m_cameleon->GetHabitat() );
805  m_diagramDrawing->SetParent( this );
806  //m_diagramDrawing->ConnectEvent( wxEVT_UPDATE_DRAWING, this );
807 }
808 
809 a2dSymbol::a2dSymbol( const a2dSymbol& other, CloneOptions options, a2dRefMap* refs )
810  : a2dDiagram( other, options, refs )
811 {
812 }
813 
815 {
816  return new a2dSymbol( *this, options, refs );
817 }
818 
819 a2dSymbol::~a2dSymbol()
820 {
821 }
822 
823 void a2dSymbol::DoRender( a2dIterC& ic, OVERLAP clipparent )
824 {
825  double grid = GetHabitat()->GetObjectGridSize();
826  a2dDrawer2D *d(ic.GetDrawer2D());
827 
828  int align = m_nextLine ? wxMINX|wxMAXY: wxMINX|wxMINY;
829 
830  d->DrawRoundedRectangle( 0, 0, 30*grid, m_nextLine ? 4*grid: -4*grid , 1 );
831  d->SetFont( a2dCanvasModule::GetFontMedBold() );
832  d->DrawText( " symbol : " + GetName(), 0, m_nextLine ? 1.5*grid: -1.5*grid, align, false);
833  d->SetFont( a2dCanvasModule::GetFontSmall() );
834  wxString classn = GetClassInfo()->GetClassName();
835  classn = "type: " + classn;
836  d->DrawText( classn, 2*grid, m_nextLine ? 2.6*grid: -2.6*grid, align, false);
837 }
838 
839 //----------------------------------------------------------------------------
840 // a2dBuildIn
841 //----------------------------------------------------------------------------
842 
843 IMPLEMENT_DYNAMIC_CLASS( a2dBuildIn, a2dAppear )
844 
845 BEGIN_EVENT_TABLE( a2dBuildIn, a2dAppear )
846  EVT_UPDATE_DRAWING( a2dBuildIn::OnUpdateFromDrawing )
847 END_EVENT_TABLE()
848 
849 a2dBuildIn::a2dBuildIn()
850  :
851  m_drawing( NULL ),
852  a2dAppear( NULL, 0, 0 )
853 {
854 }
855 
856 a2dBuildIn::a2dBuildIn( a2dCameleon* cameleon, double x, double y, a2dCanvasObject* buildIn )
857  :
858  a2dAppear( cameleon, x, y )
859 {
860  wxASSERT_MSG( m_cameleon, wxT( "a2dCamelon not set in a2dDiagram" ) );
861  if ( m_cameleon->GetHabitat() )
862  {
863  m_drawing = (a2dDrawing*) m_cameleon->GetHabitat()->GetBuildInDrawingTemplate()->Clone( clone_deep );
864  }
865  else
866  m_drawing = new a2dDrawing( wxEmptyString, NULL );
867  m_drawing->SetHabitat( m_cameleon->GetHabitat() );
868  m_drawing->GetRootObject()->Append( buildIn );
869  m_drawing->ConnectEvent( wxEVT_UPDATE_DRAWING, this );
870  m_drawing->SetMayEdit( false );
871 }
872 
873 a2dBuildIn::a2dBuildIn( const a2dBuildIn& other, CloneOptions options, a2dRefMap* refs )
874  : a2dAppear( other, options, refs )
875 {
876  if ( ! (options & clone_members) )
877  {
878  m_drawing = other.m_drawing;
879  }
880  else if ( options & clone_members && other.m_drawing )
881  {
882  m_drawing = other.m_drawing->TClone( CloneOptions( options | clone_noCameleonRef ) );
883  m_drawing->ConnectEvent( wxEVT_UPDATE_DRAWING, this );
884  }
885  else
886  {
887  m_drawing = other.m_drawing;
888  }
889 }
890 
892 {
893  return new a2dBuildIn( *this, options, refs );
894 }
895 
896 a2dBuildIn::~a2dBuildIn()
897 {
898  if ( m_drawing )
899  m_drawing->DisconnectEvent( wxEVT_UPDATE_DRAWING, this );
900 }
901 
902 a2dCanvasObject* a2dBuildIn::GetBuildIn() const
903 {
904  return *(m_drawing->GetRootObject()->GetChildObjectList()->begin());
905 }
906 
907 void a2dBuildIn::SetBuildIn( a2dCanvasObject* buildIn )
908 {
909  m_drawing->GetRootObject()->ReleaseChildObjects();
910  m_drawing->GetRootObject()->Append( buildIn );
911 }
912 
913 void a2dBuildIn::OnUpdateFromDrawing( a2dDrawingEvent& event )
914 {
915  if (event.GetUpdateHint() & a2dCANVIEW_UPDATE_PENDING_POSTUPDATE)
916  {
917  a2dPort* find = NULL;
918  a2dCanvasObjectList::iterator iter = m_drawing->GetRootObject()->CreateChildObjectList()->begin();
919  while ( iter != m_drawing->GetRootObject()->GetChildObjectList()->end() )
920  {
921  find = wxDynamicCast( ( *iter ).Get(), a2dPort );
922  if ( find && find->GetPending() )
923  {
925  }
926  iter++;
927  }
928  event.Skip();
929  }
930 }
931 
932 #if wxART2D_USE_CVGIO
933 void a2dBuildIn::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
934 {
935  a2dAppear::DoSave( parent, out, xmlparts, towrite );
936  if ( xmlparts == a2dXmlSer_attrib )
937  {
938  if ( GetBuildIn() )
939  out.WriteAttribute( "buildin", GetBuildIn()->GetClassInfo()->GetClassName() );
940  }
941  else
942  {
943  /*
944  if ( m_drawing && !m_drawing->GetCheck() )
945  {
946  a2dObjectPtr multiRef = m_drawing.Get();
947 
948  out.WriteStartElement( "drawing" );
949  m_drawing->Save( this, out, towrite, NULL );
950  out.WriteEndElement();
951  }
952  */
953 
954  }
955 }
956 
957 void a2dBuildIn::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
958 {
959  static wxString lastBuildIn;
960 
961  a2dAppear::DoLoad( parent, parser, xmlparts );
962  if ( xmlparts == a2dXmlSer_attrib )
963  {
964  lastBuildIn = parser.GetAttributeValue( "buildin" );
965  if ( parser.HasAttribute( "drawing" ) )
966  {
967  parser.ResolveOrAdd( ( a2dSmrtPtr<class a2dObject>* ) &m_drawing, parser.GetAttributeValue( "drawing" ) );
968  }
969  }
970  else
971  {
972  if ( parser.GetTagName() != "drawing" )
973  {
974  m_drawing = new a2dDrawing();
975  a2dCanvasObject* obj = wxStaticCast( parser.CreateObject( lastBuildIn ), a2dCanvasObject );
976  obj->Initialize();
977  m_drawing->GetRootObject()->Append( obj );
978  m_drawing->ConnectEvent( wxEVT_UPDATE_DRAWING, this );
979  m_drawing->SetMayEdit( false );
980  return;
981  }
982  else
983  {
984  parser.Require( START_TAG, "drawing" );
985  parser.Next();
986 
987  m_drawing = (a2dDrawing*) parser.LoadOneObject( this );
988  m_drawing->SetParent( this );
989 
990  parser.Require( END_TAG, "drawing" );
991  parser.Next();
992  }
993  }
994 }
995 #endif //wxART2D_USE_CVGIO
996 
998 {
999  double grid = GetHabitat()->GetObjectGridSize();
1000 
1001  a2dBoundingBox bbox;
1002  bbox.Expand( 0, 0 );
1003  bbox.Expand( 30*grid, -4*grid );
1004  return bbox;
1005 }
1006 
1007 void a2dBuildIn::DoWalker( wxObject* parent, a2dWalkerIOHandler& handler )
1008 {
1009  a2dCanvasObject::DoWalker( parent, handler );
1010 
1011  if ( m_drawing )
1012  m_drawing->Walker( this, handler );
1013 }
1014 
1015 void a2dBuildIn::DoRender( a2dIterC& ic, OVERLAP clipparent )
1016 {
1017  double grid = GetHabitat()->GetObjectGridSize();
1018  a2dDrawer2D *d(ic.GetDrawer2D());
1019 
1020  d->DrawRoundedRectangle( 0, 0, 30*grid, -4*grid , 1*grid );
1021 
1022  int align = m_nextLine ? wxMINX|wxMAXY: wxMINX|wxMINY;
1023 
1024  d->SetFont( a2dCanvasModule::GetFontMedBold() );
1025  wxString nameBuildIn = "Not Defined";
1026  if ( GetBuildIn() )
1027  nameBuildIn = GetBuildIn()->GetClassInfo()->GetClassName();
1028  d->DrawText( " buildin : " + GetName() + " : "+ nameBuildIn, 0, -2*grid, align, false);
1029  d->SetFont( a2dCanvasModule::GetFontSmall() );
1030  wxString classn = GetClassInfo()->GetClassName();
1031  classn = "type: " + classn;
1032  d->DrawText( classn, 2*grid, -3.1*grid, align, false);
1033 }
1034 
1036 {
1037  double grid = GetHabitat()->GetObjectGridSize();
1038  double margin = ic.GetTransformedHitMargin();
1039 
1040  hitEvent.m_how = HitTestRectangle( hitEvent.m_relx, hitEvent.m_rely, 0, 0, 30*grid, -4*grid, ic.GetWorldStrokeExtend() + margin );
1041 
1042  return hitEvent.m_how.IsHit();
1043 }
1044 
1046 {
1047  return m_drawing->PushInto( parent );
1048 }
1049 
1050 
1051 //----------------------------------------------------------------------------
1052 // a2dParameters
1053 //----------------------------------------------------------------------------
1054 IMPLEMENT_DYNAMIC_CLASS( a2dParameters, a2dAppear )
1055 
1056 a2dParameters::a2dParameters( a2dCameleon* cameleon, double x, double y )
1057  : a2dAppear( cameleon, x, y )
1058 {
1059 }
1060 
1062  : a2dAppear( other, options, refs )
1063 {
1064 }
1065 
1067 {
1068  return new a2dParameters( *this, options,refs );
1069 }
1070 
1071 
1072 #if wxART2D_USE_CVGIO
1073 void a2dParameters::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
1074 {
1075  a2dAppear::DoSave( parent, out, xmlparts, towrite );
1076 }
1077 
1078 void a2dParameters::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
1079 {
1080  a2dAppear::DoLoad( parent, parser, xmlparts );
1081 }
1082 #endif //wxART2D_USE_CVGIO
1083 
1084 //----------------------------------------------------------------------------
1085 // a2dGui
1086 //----------------------------------------------------------------------------
1087 IMPLEMENT_DYNAMIC_CLASS( a2dGui, a2dAppear )
1088 
1089 a2dGui::a2dGui( a2dCameleon* cameleon, double x, double y )
1090  : a2dAppear( cameleon, x, y )
1091 {
1092 }
1093 
1094 a2dGui::a2dGui( const a2dGui& other, CloneOptions options, a2dRefMap* refs )
1095  : a2dAppear( other, options, refs )
1096 {
1097 }
1098 
1100 {
1101  return new a2dGui( *this, options, refs );
1102 }
1103 
1104 #if wxART2D_USE_CVGIO
1105 void a2dGui::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
1106 {
1107  a2dAppear::DoSave( parent, out, xmlparts, towrite );
1108 }
1109 
1110 void a2dGui::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
1111 {
1112  a2dAppear::DoLoad( parent, parser, xmlparts );
1113 }
1114 #endif //wxART2D_USE_CVGIO
1115 
1116 //----------------------------------------------------------------------------
1117 // a2dCameleon
1118 //----------------------------------------------------------------------------
1119 
1120 bool a2dCameleon::m_nextLine = false;
1121 
1122 
1123 DEFINE_EVENT_TYPE( wxEVT_NEW_CAMELEON )
1124 
1125 a2dCanvasObject* a2dCameleon::ms_centralCameleonRoot = NULL;
1126 double a2dCameleon::ms_dx = 1;
1127 double a2dCameleon::ms_dy = -1;
1128 
1129 IMPLEMENT_DYNAMIC_CLASS( a2dCameleon, a2dHasParameters )
1130 
1131 INITIALIZE_PROPERTIES( a2dCameleon, a2dHasParameters )
1132 {
1133  return true;
1134 }
1135 
1136 BEGIN_EVENT_TABLE( a2dCameleon, a2dHasParameters )
1137 END_EVENT_TABLE()
1138 
1139 a2dCameleon::a2dCameleon( const wxString& name, double x, double y, a2dHabitat* habitat )
1140  : a2dHasParameters( x, y ),
1141  m_habitat( habitat )
1142 {
1143  if ( m_habitat )
1144  {
1145  m_appearances = (a2dDrawing*) m_habitat->GetDrawingTemplate()->Clone( clone_deep );
1146  m_appearances->SetName( name );
1147  }
1148  else
1149  {
1150  m_appearances = new a2dDrawing( wxEmptyString );
1151  m_habitat = a2dCanvasObject::GetHabitat();
1152  }
1153  m_appearances->SetHabitat( m_habitat );
1154  m_appearances->SetParent( this );
1155  m_appearances->SetDrawingId( a2dDrawing::sm_appearances );
1156  m_changedInternalAccesstime = wxDateTime::Now();
1157  SetName( name );
1158 }
1159 
1160 a2dCameleon::a2dCameleon( const a2dCameleon& other, CloneOptions options, a2dRefMap* refs )
1161  : a2dHasParameters( other, options, refs )
1162 {
1163  wxInt64 id = GetUniqueSerializationId();
1164  //wxString camNr = wxString::Format("%s_%lld", other.GetName(), id );
1165  //SetName( camNr );
1166 
1167  m_habitat = other.m_habitat;
1168 
1169  if ( options & clone_toDrag )
1170  {
1171  SetName( wxString::Format( wxT( "drag" ) ) );
1172  m_appearances = other.m_appearances;
1173  }
1174  else
1175  {
1176  SetName( wxString::Format( wxT( "%lld" ), GetUniqueSerializationId() ) );
1177  //cloning is always clone_members, because cameleon is set to the a2dAppear as parent, which can be only one.
1178  if ( ! (options & clone_members) )
1179  {
1180  m_appearances = other.m_appearances;
1181  }
1182  else if ( options & clone_members && other.m_appearances )
1183  {
1184  m_appearances = other.m_appearances->TClone( CloneOptions( options | clone_noCameleonRef ) );
1185  a2dCanvasObjectList::const_iterator iter = m_appearances->GetRootObject()->GetChildObjectList()->begin();
1186  while ( iter != m_appearances->GetRootObject()->GetChildObjectList()->end() )
1187  {
1188  a2dAppear* appear = wxDynamicCast( ( *iter ).Get(), a2dAppear );
1189  if ( appear && !appear->GetRelease() )
1190  appear->SetCameleon( this );
1191  iter++;
1192  }
1193  }
1194  else
1195  {
1196  m_appearances = other.m_appearances;
1197  }
1198  m_appearances->SetParent( this );
1199  }
1200 
1201  /*
1202  m_appearances.clear();
1203  a2dCanvasObjectList::const_iterator iter = other.m_appearances.begin();
1204  while ( iter != other.m_appearances.end() )
1205  {
1206  a2dAppear* appear = wxDynamicCast( ( *iter ).Get(), a2dAppear );
1207  if ( appear && !appear->GetRelease() )
1208  {
1209  a2dObject* objn = appear->Clone( CloneOptions( options & ~ clone_seteditcopy ) );
1210  a2dAppear* appearn = wxStaticCast( objn, a2dAppear );
1211  appearn->SetCameleon( this );
1212  m_appearances.push_back( appearn );
1213  }
1214  iter++;
1215  }
1216  */
1217 /*
1218  a2dSymbol* sym = GetAppearance<a2dSymbol>();
1219  a2dGui* gui = GetAppearance<a2dGui>();
1220  a2dParameters* pars = GetAppearance<a2dP
1221  arameters>();
1222  a2dDiagram* gram = GetAppearance<a2dDiagram>();
1223 */
1224  m_changedInternalAccesstime = wxDateTime::Now();
1225 }
1226 
1227 a2dCameleon::~a2dCameleon()
1228 {
1229 }
1230 
1232 {
1233  return new a2dCameleon( *this, options, refs );
1234 }
1235 
1237 {
1238  if ( ms_centralCameleonRoot )
1239  ms_centralCameleonRoot->ProcessEvent( event );
1240 }
1241 
1243 {
1244  if ( ms_centralCameleonRoot )
1245  ms_centralCameleonRoot->ProcessEvent( event );
1246 }
1247 
1249 {
1250  if ( ms_centralCameleonRoot )
1251  ms_centralCameleonRoot->ProcessEvent( event );
1252 }
1253 
1255 {
1256  if ( ms_centralCameleonRoot )
1257  ms_centralCameleonRoot->ProcessEvent( event );
1258 }
1259 
1260 void a2dCameleon::AddToRoot( bool autoPlace )
1261 {
1262  a2dCameleonEvent eventNewCameleon( this );
1263  ProcessEvent( eventNewCameleon );
1264 
1265  if ( autoPlace )
1266  {
1268  SetPosXyPoint( pos );
1269  }
1270  if ( GetCameleonRoot() )
1271  GetCameleonRoot()->Append( this );
1272 }
1273 
1275 {
1276  if ( GetCameleonRoot() )
1277  {
1278  //calculate/get boundingbox and place at upper left.
1281  return a2dPoint2D( bbox.GetMinX(), bbox.GetMinY() + ms_dy );
1282  }
1283  return a2dPoint2D( 0,0 );
1284 }
1285 
1286 a2dPoint2D a2dCameleon::GetSuitblePointForNewAppearance() const
1287 {
1288  a2dBoundingBox bbox = m_appearances->GetRootObject()->GetBbox();
1289  return a2dPoint2D( bbox.GetMinX(), bbox.GetMinY() + ms_dy );
1290 }
1291 
1292 a2dAppear* a2dCameleon::GetAppearanceByName( const wxString& name ) const
1293 {
1294  a2dCanvasObjectList::iterator iter = m_appearances->GetRootObject()->GetChildObjectList()->begin();
1295  while ( iter != m_appearances->GetRootObject()->GetChildObjectList()->end() )
1296  {
1297  a2dAppear* appear = wxDynamicCast( ( *iter ).Get(), a2dAppear );
1298  if ( appear && appear->GetName() == name )
1299  return appear;
1300  iter++;
1301  }
1302  return NULL;
1303 }
1304 
1305 a2dAppear* a2dCameleon::GetAppearanceByClassName( const wxString& appearranceClassName ) const
1306 {
1307  a2dCanvasObjectList::iterator iter = m_appearances->GetRootObject()->GetChildObjectList()->begin();
1308  while ( iter != m_appearances->GetRootObject()->GetChildObjectList()->end() )
1309  {
1310  a2dAppear* appear = wxDynamicCast( ( *iter ).Get(), a2dAppear );
1311  if ( appear && appear->GetClassInfo()->GetClassName() == appearranceClassName )
1312  return appear;
1313  iter++;
1314  }
1315  return NULL;
1316 }
1317 
1318 a2dDiagram* a2dCameleon::GetDiagram( bool autoCreate )
1319 {
1320  a2dDiagram* ret = wxStaticCastNull( GetAppearanceByClassName( "a2dDiagram" ), a2dDiagram );
1321  if ( !ret && autoCreate )
1322  {
1323  ret = new a2dDiagram( this );
1324  ret->SetPosXyPoint( GetSuitblePointForNewAppearance() );
1325  m_appearances->GetRootObject()->Append( ret );
1326  }
1327  return ret;
1328 }
1329 
1330 a2dSymbol* a2dCameleon::GetSymbol( bool autoCreate )
1331 {
1332  a2dSymbol* ret = wxStaticCastNull( GetAppearanceByClassName( "a2dSymbol" ), a2dSymbol );
1333  if ( !ret && autoCreate )
1334  {
1335  ret = new a2dSymbol( this );
1336  ret->SetPosXyPoint( GetSuitblePointForNewAppearance() );
1337  m_appearances->GetRootObject()->Append( ret );
1338  }
1339  return ret;
1340 }
1341 
1342 a2dBuildIn* a2dCameleon::GetBuildIn( bool autoCreate )
1343 {
1344  a2dBuildIn* ret = wxStaticCastNull( GetAppearanceByClassName( "a2dBuildIn" ), a2dBuildIn );
1345  if ( !ret && autoCreate )
1346  {
1347  ret = new a2dBuildIn( this );
1348  ret->SetPosXyPoint( GetSuitblePointForNewAppearance() );
1349  m_appearances->GetRootObject()->Append( ret );
1350  }
1351  return ret;
1352 }
1353 
1354 a2dGui* a2dCameleon::GetGui( bool autoCreate )
1355 {
1356  a2dGui* ret = wxStaticCast( GetAppearanceByClassName( "a2dGui" ), a2dGui );
1357  if ( !ret && autoCreate )
1358  {
1359  ret = new a2dGui( this );
1360  ret->SetPosXyPoint( GetSuitblePointForNewAppearance() );
1361  m_appearances->GetRootObject()->Append( ret );
1362  }
1363  return ret;
1364 }
1365 
1366 void a2dCameleon::AddAppearance( a2dAppear* appearance )
1367 {
1368  m_appearances->GetRootObject()->Append( appearance );
1369  appearance->SetCameleon( this );
1370 }
1371 
1373 {
1374  a2dCameleonInst* inst = wxDynamicCast( parent, a2dCameleonInst );
1375  if ( inst )
1376  {
1377  //thinking in subcircuits, the diagram is the one to show, one can change the view to the symbol
1378  if ( inst->GetAppearance() == GetDiagram() )
1379  {
1380  return GetDiagram()->PushInto( parent );
1381  }
1382  if ( inst->GetAppearance() == GetSymbol() )
1383  {
1384  if ( GetDiagram() )
1385  return GetDiagram()->PushInto( parent );
1386  return GetSymbol()->PushInto( parent );
1387  }
1388  }
1389  return m_appearances->PushInto( parent );
1390 }
1391 
1392 void a2dCameleon::DoWalker( wxObject* parent, a2dWalkerIOHandler& handler )
1393 {
1394  a2dCanvasObject::DoWalker( parent, handler );
1395 
1396  if ( handler.GetSkipNotRenderedInDrawing() )
1397  {
1398  int b = 1;
1399  //cameleon has subdrawings, not part of rendering the drawing containing this objects.
1400  }
1401  else if ( wxDynamicCast( &handler, a2dWalker_SetCheck ) )
1402  m_appearances->Walker( parent, handler );
1403  else
1404  m_appearances->Walker( parent, handler );
1405 }
1406 
1408 {
1409  double grid = m_habitat->GetObjectGridSize();
1410  a2dBoundingBox bbox;
1411  bbox.Expand( 0, 0 );
1412  bbox.Expand( 30*grid, m_nextLine ? 10*grid: -10*grid );
1413  return bbox;
1414 }
1415 
1416 #define BBOX2XYWH(bbox) (bbox).GetMinX(), (bbox).GetMinY(), (bbox).GetWidth(), (bbox).GetHeight()
1417 
1418 void a2dCameleon::DoRender( a2dIterC& ic, OVERLAP clipparent )
1419 {
1420  double grid = m_habitat->GetObjectGridSize();
1421  a2dDrawer2D *d(ic.GetDrawer2D());
1422 
1423  // For debugging
1424  //d->SetDrawerFill(*a2dBLACK_FILL);
1425  //d->DrawRoundedRectangle(BBOX2XYWH(GetUnTransformedBbox() ), 0);
1426 
1427  int align = m_nextLine ? wxMINX|wxMAXY: wxMINX|wxMINY;
1428 
1429  d->DrawRoundedRectangle( 0, 0, 30*grid, m_nextLine ? 10*grid: -10*grid , 1*grid );
1430  d->SetFont( a2dCanvasModule::GetFontMedBold() );
1431  d->DrawText( " cam : " + GetName(), 0, m_nextLine ? 2*grid: -2*grid, align, false);
1432  d->SetFont( a2dCanvasModule::GetFontSmall() );
1433 
1434  double y = m_nextLine ? 3.1*grid: -3.1*grid;
1435  a2dCanvasObjectList::iterator iter = m_appearances->GetRootObject()->GetChildObjectList()->begin();
1436  while ( iter != m_appearances->GetRootObject()->GetChildObjectList()->end() )
1437  {
1438  a2dCanvasObjectPtr obj = *iter;
1439  a2dAppear* appearance = wxDynamicCast( obj.Get(), a2dAppear );
1440  //if object is not saved yet, we need to save it here.
1441  if ( appearance && !appearance->GetRelease() )
1442  {
1443  wxString classn = appearance->GetClassInfo()->GetClassName();
1444  classn = "type: " + classn;
1445  d->DrawText( classn, 2*grid, y, align, false);
1446  d->SetFont( a2dCanvasModule::GetFontSmall() );
1447  y += m_nextLine ? 1.2*grid: -1.2*grid;
1448  d->DrawText( "name: " + appearance->GetName(), 2*grid, y, align, false);
1449  y += m_nextLine ? 1.2*grid: -1.2*grid;
1450  }
1451  iter++;
1452  }
1453 
1454 }
1455 
1457 {
1458  double grid = m_habitat->GetObjectGridSize();
1459  double margin = ic.GetTransformedHitMargin();
1460 
1461  hitEvent.m_how = HitTestRectangle( hitEvent.m_relx, hitEvent.m_rely, 0, 0, 30*grid, m_nextLine ? 10*grid: -10*grid, ic.GetWorldStrokeExtend() + margin );
1462 
1463  return hitEvent.m_how.IsHit();
1464 }
1465 
1466 #if wxART2D_USE_CVGIO
1467 void a2dCameleon::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
1468 {
1469  a2dCanvasObject::DoSave( parent, out, xmlparts, towrite );
1470  if ( xmlparts == a2dXmlSer_attrib )
1471  {
1472  if ( m_appearances )
1473  out.WriteAttribute( wxT( "appearances" ), m_appearances->GetUniqueSerializationId() );
1474  }
1475  else
1476  {
1477  if ( m_appearances && !m_appearances->GetCheck() )
1478  {
1479  a2dObjectPtr multiRef = m_appearances.Get();
1480 
1481  out.WriteStartElement( wxT( "appearances" ) );
1482  m_appearances->Save( this, out, towrite, NULL );
1483  out.WriteEndElement();
1484  }
1485  }
1486 
1487 }
1488 
1489 void a2dCameleon::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
1490 {
1491  a2dCanvasObject::DoLoad( parent, parser, xmlparts );
1492  if ( xmlparts == a2dXmlSer_attrib )
1493  {
1494  if ( parser.HasAttribute( wxT( "appearances" ) ) )
1495  {
1496  parser.ResolveOrAdd( ( a2dSmrtPtr<class a2dObject>* ) &m_appearances, parser.GetAttributeValue( wxT( "appearances" ) ) );
1497  }
1498  }
1499  else
1500  {
1501  if ( parser.GetTagName() != wxT( "appearances" ) )
1502  return;
1503 
1504  parser.Require( START_TAG, wxT( "appearances" ) );
1505  parser.Next();
1506 
1507  m_appearances = (a2dDrawing*) parser.LoadOneObject( this );
1508 
1509  a2dCanvasObjectList::iterator iter = m_appearances->GetRootObject()->GetChildObjectList()->begin();
1510  while ( iter != m_appearances->GetRootObject()->GetChildObjectList()->end() )
1511  {
1512  a2dCanvasObjectPtr obj = *iter;
1513  a2dAppear* appearance = wxDynamicCast( obj.Get(), a2dAppear );
1514  //if object is not saved yet, we need to save it here.
1515  if ( appearance )
1516  {
1517  appearance->SetCameleon( this );
1518  }
1519  iter++;
1520  }
1521 
1522 
1523  parser.Require( END_TAG, wxT( "appearances" ) );
1524  parser.Next();
1525  }
1526 }
1527 #endif //wxART2D_USE_CVGIO
1528 
1529 OVERLAP a2dCameleon::GetClipStatusData( a2dAppear* appearance, a2dIterC& ic, OVERLAP clipparent ) const
1530 {
1531  if ( appearance )
1532  {
1533  if ( wxDynamicCast( appearance, a2dSymbol ) )
1534  {
1535  a2dSymbol* draw = wxDynamicCast( appearance, a2dSymbol );
1536  return draw->GetDrawing()->GetRootObject()->GetClipStatus( ic, clipparent );
1537  }
1538  else if ( wxDynamicCast( appearance, a2dDiagram ) )
1539  {
1540  a2dDiagram* draw = wxDynamicCast( appearance, a2dDiagram );
1541  return draw->GetDrawing()->GetRootObject()->GetClipStatus( ic, clipparent );
1542  }
1543  }
1544  return _OUT;
1545 }
1546 
1547 a2dBoundingBox a2dCameleon::GetUnTransformedBboxData( a2dAppear* appearance, a2dBboxFlags WXUNUSED( flags ) ) const
1548 {
1549  a2dBoundingBox bbox;
1550  if ( appearance )
1551  {
1552  if ( wxDynamicCast( appearance, a2dSymbol ) )
1553  {
1554  a2dSymbol* draw = wxDynamicCast( appearance, a2dSymbol );
1555  bbox.Expand( draw->GetBbox() );
1556  }
1557  else if ( wxDynamicCast( appearance, a2dDiagram ) )
1558  {
1559  a2dDiagram* draw = wxDynamicCast( appearance, a2dDiagram );
1560  bbox.Expand( draw->GetBbox() );
1561  }
1562  }
1563  else
1564  bbox.Expand( 0, 0 );
1565  return bbox;
1566 }
1567 
1568 bool a2dCameleon::UpdateData( a2dAppear* appearance, UpdateMode mode )
1569 {
1570  bool calc = false;
1571  if ( appearance )
1572  {
1573  if ( wxDynamicCast( appearance, a2dSymbol ) )
1574  {
1575  a2dSymbol* draw = wxDynamicCast( appearance, a2dSymbol );
1576  calc = draw->GetDrawing()->GetRootObject()->Update( mode );
1577  }
1578  else if ( wxDynamicCast( appearance, a2dDiagram ) )
1579  {
1580  a2dDiagram* draw = wxDynamicCast( appearance, a2dDiagram );
1581  calc = draw->GetDrawing()->GetRootObject()->Update( mode );
1582  }
1583  }
1584 
1585  if ( !m_bbox.GetValid() || calc )
1586  {
1587  m_bbox = GetUnTransformedBboxData( appearance );
1588  m_bbox.MapBbox( m_lworld );
1589  return true;
1590  }
1591  return false;
1592 }
1593 
1594 void a2dCameleon::RenderData( a2dAppear* appearance, a2dIterC& ic, OVERLAP clipparent )
1595 {
1596  // For debugging
1597  //ic.GetDrawer2D()->SetDrawerFill(*a2dWHITE_FILL);
1598  //ic.GetDrawer2D()->DrawRoundedRectangle(BBOX2XYWH( DoGetUnTransformedBbox() ), 0);
1599 
1600  if ( !ic.GetRenderChildDerived() )
1601  return;
1602 
1603  OVERLAP childclip = _IN;
1604  if ( clipparent != _IN )
1605  {
1606  if ( wxDynamicCast( appearance, a2dSymbol ) )
1607  {
1608  a2dSymbol* draw = wxDynamicCast( appearance, a2dSymbol );
1609  childclip = draw->GetDrawing()->GetRootObject()->GetClipStatus( ic, clipparent );
1610  }
1611  else if ( wxDynamicCast( appearance, a2dDiagram ) )
1612  {
1613  a2dDiagram* draw = wxDynamicCast( appearance, a2dDiagram );
1614  childclip = draw->GetDrawing()->GetRootObject()->GetClipStatus( ic, clipparent );
1615  }
1616  }
1617 
1618  if ( childclip != _OUT ) //if a child is _OUT, no need to render it.
1619  {
1620  bool skip = a2dPin::GetDoRender();
1621  if ( skip )
1622  {
1623  a2dPin::SetDoRender( false );
1624  a2dPort::SetDoRender( false );
1625  }
1626  if ( wxDynamicCast( appearance, a2dSymbol ) )
1627  {
1628  a2dSymbol* draw = wxDynamicCast( appearance, a2dSymbol );
1629  draw->GetDrawing()->GetRootObject()->Render( ic, childclip );
1630  }
1631  else if ( wxDynamicCast( appearance, a2dDiagram ) )
1632  {
1633  a2dDiagram* draw = wxDynamicCast( appearance, a2dDiagram );
1634  draw->GetDrawing()->GetRootObject()->Render( ic, childclip );
1635  }
1636  if ( skip )
1637  {
1638  a2dPin::SetDoRender( true );
1639  a2dPort::SetDoRender( true );
1640  skip = false;
1641  }
1642  }
1643 }
1644 
1645 bool a2dCameleon::IsHitWorldData( a2dAppear* appearance, a2dIterC& ic, a2dHitEvent& hitEvent )
1646 {
1647  if ( appearance )
1648  {
1649  if ( wxDynamicCast( appearance, a2dSymbol ) )
1650  {
1651  a2dSymbol* draw = wxDynamicCast( appearance, a2dSymbol );
1652  return draw->GetDrawing()->GetRootObject()->IsHitWorld( ic, hitEvent ) != 0;
1653  }
1654  else if ( wxDynamicCast( appearance, a2dDiagram ) )
1655  {
1656  a2dDiagram* draw = wxDynamicCast( appearance, a2dDiagram );
1657  return draw->GetDrawing()->GetRootObject()->IsHitWorld( ic, hitEvent ) != 0;
1658  }
1659  }
1660 
1661  return false;
1662 }
1663 
1664 //----------------------------------------------------------------------------
1665 // a2dVisibleParameter
1666 //----------------------------------------------------------------------------
1667 BEGIN_EVENT_TABLE( a2dVisibleParameter, a2dText )
1669  EVT_CHAR( a2dVisibleParameter::OnChar )
1670 END_EVENT_TABLE()
1671 
1672 IMPLEMENT_DYNAMIC_CLASS( a2dVisibleParameter, a2dText );
1673 
1674 void a2dVisibleParameter::OnPropertyChanged( a2dComEvent& event )
1675 {
1676  if ( event.GetPropertyId() == m_propId )
1677  {
1678  SetPending( true );
1679  }
1680 }
1681 
1683  : a2dText()
1684 {
1685  m_flags.m_visible = true;
1686  m_flags.m_prerenderaschild = false;
1687  m_flags.m_subEditAsChild = true;
1688  m_propId = NULL;
1689  m_showname = true;
1690  m_parent = NULL;
1691 }
1692 
1693 a2dVisibleParameter::a2dVisibleParameter( a2dHasParameters* parent, a2dPropertyIdPtr propertyId, double x, double y, double angle )
1694  : a2dText( wxT( "" ), x, y, *a2dDEFAULT_CANVASFONT, angle )
1695 {
1696  m_flags.m_visible = true;
1697  m_flags.m_prerenderaschild = false;
1698  m_flags.m_subEditAsChild = true;
1699  m_parent = parent;
1700  m_propId = propertyId;
1701 
1702  Connect( wxID_ANY, wxID_ANY, a2dEVT_COM_EVENT, wxObjectEventFunction( &a2dVisibleParameter::OnPropertyChanged ), 0, this );
1703  m_showname = true;
1704 }
1705 
1706 a2dVisibleParameter::a2dVisibleParameter( a2dHasParameters* parent, a2dPropertyIdPtr propertyId, double x, double y, bool visible, const a2dFont& font, double angle )
1707  : a2dText( wxT( "" ), x, y, font, angle )
1708 {
1709  m_flags.m_visible = visible;
1710  m_flags.m_prerenderaschild = false;
1711  m_flags.m_subEditAsChild = true;
1712  m_parent = parent;
1713  m_propId = propertyId;
1714  Connect( wxID_ANY, wxID_ANY, a2dEVT_COM_EVENT, wxObjectEventFunction( &a2dVisibleParameter::OnPropertyChanged ), 0, this );
1715  m_showname = true;
1716 }
1717 
1718 a2dVisibleParameter::~a2dVisibleParameter()
1719 {
1720  Disconnect( wxID_ANY, wxID_ANY, a2dEVT_COM_EVENT, wxObjectEventFunction( &a2dVisibleParameter::OnPropertyChanged ), 0, this );
1721 }
1722 
1723 a2dVisibleParameter::a2dVisibleParameter( const a2dVisibleParameter& other, CloneOptions options, a2dRefMap* refs )
1724  : a2dText( other, options, refs )
1725 {
1726  m_propId = other.m_propId;
1727  m_parent = other.m_parent;
1728  m_showname = other.m_showname;
1729 }
1730 
1732 {
1733  m_showname = show;
1734  SetPending( true );
1735 }
1736 
1738 {
1739  m_parent = parent;
1740  SetPending( true );
1741 }
1742 
1744 {
1745  return new a2dVisibleParameter( *this, options, refs );
1746 };
1747 
1748 void a2dVisibleParameter::OnMouseEvent( a2dCanvasObjectMouseEvent& event )
1749 {
1750  event.Skip();
1751 }
1752 
1754 {
1756  //m_root->GetCommandProcessor()->Submit( new a2dCommand_SetCanvasProperty( m_parent, property ) );
1757 
1759 }
1760 
1761 void a2dVisibleParameter::OnChar( wxKeyEvent& event )
1762 {
1763  wxString text = m_text;
1764 
1765  a2dText::OnChar( event );
1766  if ( m_flags.m_editingCopy )
1767  {
1768  //m_propId->ValidateString( m_text )
1769  }
1770 }
1771 
1772 bool a2dVisibleParameter::DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox )
1773 {
1774  if ( !m_bbox.GetValid() )
1775  {
1776  if ( m_showname )
1777  m_text = m_propId->GetName() + wxT( " = " );
1778  else
1779  m_text = wxEmptyString;
1780  m_firsteditable = m_text.Length();
1781  if ( m_caret < m_firsteditable )
1783  a2dNamedPropertyPtr property = m_parent->GetParameter( m_propId );
1784  if ( property )
1785  m_text = m_text + property->StringValueRepresentation();
1786  m_utbbox_changed = true;
1787  }
1788 
1789  return a2dText::DoUpdate( mode, childbox, clipbox, propbox );
1790 }
1791 
1792 #if wxART2D_USE_CVGIO
1793 void a2dVisibleParameter::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
1794 {
1795  a2dText::DoSave( parent, out, xmlparts, towrite );
1796 
1797  if ( xmlparts == a2dXmlSer_attrib )
1798  {
1799  out.WriteAttribute( wxT( "showname" ), m_showname, true );
1800  out.WriteAttribute( wxT( "propertyId" ), m_propId->GetName() );
1801  }
1802  else
1803  {
1804 
1805  }
1806 }
1807 
1808 void a2dVisibleParameter::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
1809 {
1810  a2dText::DoLoad( parent, parser, xmlparts );
1811 
1812  if ( xmlparts == a2dXmlSer_attrib )
1813  {
1814  wxString resolveKey;
1815  if ( parser.HasAttribute( wxT( "propertyId" ) ) )
1816  {
1817  m_propId = wxStaticCast( parent, a2dObject )->HasPropertyId( parser.GetAttributeValue( wxT( "propertyId" ) ) );
1818  }
1819  m_showname = parser.GetAttributeValueBool( wxT( "showname" ) );
1820  }
1821  else
1822  {
1823  }
1824 }
1825 #endif //wxART2D_USE_CVGIO
1826 
1827 
1828 //----------------------------------------------------------------------------
1829 // a2dCameleonSymbolicRef
1830 //----------------------------------------------------------------------------
1831 IMPLEMENT_DYNAMIC_CLASS( a2dCameleonSymbolicRef, a2dHasParameters )
1832 
1833 bool a2dCameleonSymbolicRef::m_nextLine = false;
1834 
1835 a2dCameleonSymbolicRef::a2dCameleonSymbolicRef( double x, double y, a2dCameleon* cameleon )
1836  : a2dCanvasObject( x, y )
1837 {
1838  m_appearance = NULL;
1839  m_cameleon = cameleon;
1840 }
1841 
1842 a2dCameleonSymbolicRef::a2dCameleonSymbolicRef( double x, double y, a2dSymbol* symbol )
1843  : a2dCanvasObject( x, y )
1844 {
1845  m_appearance = symbol;
1846  m_cameleon = symbol->GetCameleon();
1847  wxASSERT_MSG( m_cameleon, wxT( "a2dCamelon not set in a2dSymbol" ) );
1848 }
1849 
1850 a2dCameleonSymbolicRef::a2dCameleonSymbolicRef( double x, double y, a2dDiagram* diagram )
1851  : a2dCanvasObject( x, y )
1852 {
1853  m_appearance = diagram;
1854  m_cameleon = diagram->GetCameleon();
1855  wxASSERT_MSG( m_cameleon, wxT( "a2dCamelon not set in a2dDiagram" ) );
1856 }
1857 
1858 a2dCameleonSymbolicRef::a2dCameleonSymbolicRef( double x, double y, const wxString& appearanceName )
1859  : a2dCanvasObject( x, y )
1860 {
1861  m_appearanceName = appearanceName;
1862  m_appearance = 0;
1863 }
1864 
1865 a2dCameleonSymbolicRef::~a2dCameleonSymbolicRef()
1866 {
1867 }
1868 
1869 a2dCameleonSymbolicRef::a2dCameleonSymbolicRef( const a2dCameleonSymbolicRef& other, CloneOptions options, a2dRefMap* refs )
1870  : a2dCanvasObject( other, options, refs )
1871 {
1872  m_appearance = other.m_appearance;
1873  m_cameleon = other.m_cameleon;
1874 }
1875 
1877 {
1878  a2dCameleonSymbolicRef* a = new a2dCameleonSymbolicRef( *this, options, refs );
1879  return a;
1880 }
1881 
1882 void a2dCameleonSymbolicRef::SetAppearanceName( const wxString& appearanceName )
1883 {
1884  m_appearanceName = appearanceName;
1885  m_appearance = 0;
1886 }
1887 
1889 {
1890  wxASSERT_MSG( m_cameleon == m_appearance->GetCameleon(), wxT( "a2dCamelon not same in m_appearance" ) );
1891 
1892  if ( m_cameleon )
1893  return m_cameleon;
1894  return NULL;
1895 }
1896 
1898 {
1899  double grid = GetHabitat()->GetObjectGridSize();
1900  a2dBoundingBox bbox;
1901  bbox.Expand( 0, 0 );
1902  bbox.Expand( 30*grid, -3*grid );
1903  return bbox;
1904 }
1905 
1906 bool a2dCameleonSymbolicRef::DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox )
1907 {
1908  bool calc = false;
1909  if ( !m_bbox.GetValid() || !m_appearance )
1910  {
1911  calc = a2dCanvasObject::DoUpdate( mode, childbox, clipbox, propbox );
1912  //m_appearance = m_cameleon->GetAppearanceByName( m_appearanceName );
1913  }
1914  return calc;
1915 }
1916 
1918 {
1919  if( !linkto )
1920  return false;
1921 
1922  if ( wxDynamicCast( linkto, a2dCameleon ) )
1923  {
1924  a2dCameleon* cam = wxStaticCast( linkto, a2dCameleon );
1925  m_cameleon = cam;
1926  wxASSERT_MSG( m_cameleon, wxT( "a2dCamelon not set" ) );
1927  if ( !m_appearanceName.IsEmpty() )
1928  {
1930  if ( m_appearance )
1931  m_appearance->SetCheck( true );
1932  else
1933  {
1934  wxString error;
1935  error.Printf( wxT( "Appearance with name: %s not found in a2dCameleonSymbolicRef" ), m_appearanceName.c_str() );
1936  a2dGeneralGlobals->ReportErrorF( a2dError_LinkRef, error );
1937  }
1938  }
1939  }
1940  else if ( wxDynamicCast( linkto, a2dAppear ) )
1941  {
1942  m_appearance = wxStaticCast( linkto, a2dAppear );
1943  m_appearance->SetCheck( true );
1944  m_cameleon = m_appearance->GetCameleon();;
1945  }
1946  else
1947  {
1948  wxString name = linkto->GetName();
1949  wxString error;
1950  error.Printf( wxT( "cannot Link To: %s with name %s" ), linkto->GetClassInfo()->GetClassName(), name.c_str() );
1951  a2dGeneralGlobals->ReportErrorF( a2dError_LinkRef, error );
1952  }
1953  return true;
1954 }
1955 
1957 {
1958  if ( m_appearance )
1959  {
1960  if ( wxDynamicCast( m_appearance.Get(), a2dSymbol ) )
1961  {
1962  a2dSymbol* draw = wxDynamicCast( m_appearance.Get(), a2dSymbol );
1963  return draw->GetDrawing()->GetRootObject();
1964  }
1965  else if ( wxDynamicCast( m_appearance.Get(), a2dDiagram ) )
1966  {
1967  a2dDiagram* draw = wxDynamicCast( m_appearance.Get(), a2dDiagram );
1968  return draw->GetDrawing()->GetRootObject();
1969  }
1970  }
1971  else if ( m_cameleon )
1972  return m_cameleon->GetAppearances()->GetRootObject();
1973 
1974  return this;
1975 }
1976 
1977 void a2dCameleonSymbolicRef::DoWalker( wxObject* parent, a2dWalkerIOHandler& handler )
1978 {
1979  if ( m_appearance.Get() && m_cameleon )
1980  m_cameleon->Walker( this, handler );
1981 
1982  a2dCanvasObject::DoWalker( parent, handler );
1983 }
1984 
1986 {
1987  double grid = GetHabitat()->GetObjectGridSize();
1988  a2dDrawer2D *d(ic.GetDrawer2D());
1989 
1990  int align = m_nextLine ? wxMINX|wxMAXY: wxMINX|wxMINY;
1991 
1992  d->DrawRoundedRectangle( 0, 0, 30*grid, -3*grid, 0.2*grid);
1993  d->SetFont( a2dCanvasModule::GetFontMedBold() );
1994  d->DrawText( " cam : " + m_cameleon->GetName(), 0, -1*grid, align, false);
1995  d->SetFont( a2dCanvasModule::GetFontSmall() );
1996  if ( !m_appearance )
1997  return;
1998  wxString classn = m_appearance->GetClassInfo()->GetClassName();
1999  classn = " type: " + classn;
2000  d->DrawText( classn, 0, -2.1*grid, align, false);
2001  d->SetFont( a2dCanvasModule::GetFontSmall() );
2002  d->DrawText( " name: " + m_appearance->GetName(), 0, -3.2*grid, align, false);
2003 }
2004 
2005 #if wxART2D_USE_CVGIO
2006 void a2dCameleonSymbolicRef::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
2007 {
2008  a2dCanvasObject::DoSave( parent, out, xmlparts, towrite );
2009  if ( xmlparts == a2dXmlSer_attrib )
2010  {
2011  if ( m_appearance )
2012  {
2013  out.WriteAttribute( wxT( "cameleon" ), m_cameleon->GetUniqueSerializationId() );
2014  out.WriteAttribute( wxT( "appearance" ), m_appearance->GetUniqueSerializationId() );
2015  out.WriteAttribute( wxT( "appearanceClassName" ), m_appearance->GetClassInfo()->GetClassName() );
2016  out.WriteAttribute( wxT( "appearanceName" ), m_appearanceName );
2017  }
2018  }
2019  else
2020  {
2021  //if object is not saved yet, we need to save it here.
2022  if ( m_cameleon && !m_cameleon->GetCheck() )
2023  {
2024  //trick the system to have multiple refs on those objects, else we will not get an id attribute
2025  a2dCanvasObjectPtr multiRef = m_cameleon.Get();
2026 
2027  out.WriteStartElement( wxT( "cameleon" ) );
2028  m_cameleon->Save( this, out, towrite );
2029  out.WriteEndElement();
2030  }
2031  }
2032 }
2033 
2034 void a2dCameleonSymbolicRef::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
2035 {
2036  a2dCanvasObject::DoLoad( parent, parser, xmlparts );
2037  if ( xmlparts == a2dXmlSer_attrib )
2038  {
2039  m_appearanceName = parser.GetAttributeValue( wxT( "appearanceName" ) );
2040  if ( parser.HasAttribute( wxT( "appearance" ) ) )
2041  {
2042  parser.ResolveOrAddLink( this, parser.GetAttributeValue( wxT( "appearance" ) ) );
2043  //parser.ResolveOrAdd( ( a2dSmrtPtr<class a2dObject>* ) &m_appearance, parser.GetAttributeValue( wxT( "appearance" ) ) );
2044  }
2045  if ( parser.HasAttribute( wxT( "cameleon" ) ) )
2046  {
2047  parser.ResolveOrAddLink( this, parser.GetAttributeValue( wxT( "cameleon" ) ) );
2048  //parser.ResolveOrAdd( ( a2dSmrtPtr<class a2dObject>* ) &m_cameleon, parser.GetAttributeValue( wxT( "cameleon" ) ) );
2049  }
2050  }
2051  else
2052  {
2053  if ( parser.GetTagName() != wxT( "cameleon" ) )
2054  return;
2055 
2056  parser.Require( START_TAG, wxT( "cameleon" ) );
2057  parser.Next();
2058 
2059  m_cameleon = (a2dCameleon*) parser.LoadOneObject( this );
2060 
2061  parser.Require( END_TAG, wxT( "cameleon" ) );
2062  parser.Next();
2063  }
2064 }
2065 #endif //wxART2D_USE_CVGIO
2066 
2068 {
2069  double grid = GetHabitat()->GetObjectGridSize();
2070  double margin = ic.GetTransformedHitMargin();
2071 
2072  hitEvent.m_how = HitTestRectangle( hitEvent.m_relx, hitEvent.m_rely, 0, 0, 30*grid, -3*grid, ic.GetWorldStrokeExtend() + margin );
2073 
2074  return hitEvent.m_how.IsHit();
2075 }
2076 
2077 
2078 //----------------------------------------------------------------------------
2079 // a2dCameleonInst
2080 //----------------------------------------------------------------------------
2081 IMPLEMENT_DYNAMIC_CLASS( a2dCameleonInst, a2dHasParameters )
2082 
2083 a2dCameleonInst::a2dCameleonInst( double x, double y, a2dSymbol* symbol )
2084  : a2dHasParameters( x, y )
2085 {
2086  TriggerCameleonUpdateTime();
2087 
2088  m_appearance = symbol;
2089  m_appearanceName = "a2dSymbol";
2090  if ( symbol )
2091  {
2092  m_cameleon = symbol->GetCameleon();
2093  wxASSERT_MSG( m_cameleon, wxT( "a2dCameleon not set in a2dSymbol" ) );
2094  }
2095  if ( symbol )
2096  {
2097  symbol->TakePortsTo( this );
2098  symbol->TakeVisibleParameters( this );
2099  symbol->GetCameleon()->TakeParameters( this );
2100  }
2101 }
2102 
2103 a2dCameleonInst::a2dCameleonInst( double x, double y, a2dDiagram* diagram )
2104  : a2dHasParameters( x, y )
2105 {
2107  m_appearance = diagram;
2108  m_appearanceName = "a2dDiagram";
2109  if (diagram )
2110  {
2111  m_cameleon = diagram->GetCameleon();
2112  wxASSERT_MSG( m_cameleon, wxT( "a2dCameleon not set in a2dDiagram" ) );
2113  }
2114  if ( diagram )
2115  diagram->TakePortsTo( this );
2116  //m_diagram->TakeVisibleParameters( this );
2117  //m_diagram->GetCameleon()->TakeParameters( this );
2118 }
2119 
2120 a2dCameleonInst::a2dCameleonInst( double x, double y, const wxString& appearanceName )
2121  : a2dHasParameters( x, y )
2122 {
2124  m_appearanceName = appearanceName;
2125  m_cameleon = 0;
2126  m_appearance = 0;
2127 }
2128 
2129 a2dCameleonInst::~a2dCameleonInst()
2130 {
2131 }
2132 
2133 a2dCameleonInst::a2dCameleonInst( const a2dCameleonInst& other, CloneOptions options, a2dRefMap* refs )
2134  : a2dHasParameters( other, options, refs )
2135 {
2137 
2138  if ( !(options & clone_noCameleonRef) && (options & clone_members) && other.m_cameleon )
2139  {
2140  m_cameleon = wxStaticCast( other.m_cameleon->Clone( CloneOptions( options & ~ clone_seteditcopy ) ), a2dCameleon );
2141  m_cameleon->AddToRoot();
2143  a2dAppear* appear = m_cameleon->GetAppearanceByClassName( m_appearanceName );
2144  a2dDiagram* diagram = wxDynamicCast( appear, a2dDiagram );
2145  if ( diagram )
2146  {
2147  m_appearance = appear;
2148  SyncPinsTo( diagram->GetDrawing() );
2149  }
2150  }
2151  else
2152  {
2154  m_appearance = other.m_appearance;
2155  m_cameleon = other.m_cameleon;
2156  a2dAppear* appear = m_cameleon->GetAppearanceByClassName( m_appearanceName );
2157  a2dDiagram* diagram = wxDynamicCast( appear, a2dDiagram );
2158  if ( diagram )
2159  {
2160  wxASSERT_MSG( m_appearance == appear, wxT( "Appearance with name different from pointer" ) );
2161  SyncPinsTo( diagram->GetDrawing() );
2162  }
2163  }
2164 }
2165 
2167 {
2168  a2dCameleonInst* a = new a2dCameleonInst( *this, options, refs );
2169  return a;
2170 }
2171 
2172 void a2dCameleonInst::SetAppearanceName( const wxString& appearanceName )
2173 {
2174  m_appearanceName = appearanceName;
2175  m_cameleon = 0;
2176  m_appearance = 0;
2177 }
2178 
2179 void a2dCameleonInst::SetAppearance( a2dAppear* appearance )
2180 {
2181  m_appearance = appearance;
2182  m_cameleon = appearance->GetCameleon();
2183 }
2184 
2186 {
2187  if ( m_appearance )
2188  return m_appearance->GetCameleon();
2189  return NULL;
2190 }
2191 
2193 {
2194  if ( m_appearance )
2195  {
2196  a2dDrawing* drawing = NULL;
2197  if ( wxDynamicCast( m_appearance.Get(), a2dDiagram ) )
2198  {
2199  a2dDiagram* diagram = wxDynamicCast( m_appearance.Get(), a2dDiagram );
2200  drawing = diagram->GetDrawing();
2201  }
2202  a2dRefMap refs;
2203  a2dCanvasObjectList::iterator iterchilds = drawing->GetRootObject()->CreateChildObjectList()->begin();
2204  while ( iterchilds != drawing->GetRootObject()->CreateChildObjectList()->end() )
2205  {
2206  a2dCanvasObject* obj = *iterchilds;
2207  if ( obj && !obj->GetRelease() )
2208  {
2209  a2dCanvasObject* cloned = obj->TClone( CloneOptions( clone_deep & ~ clone_seteditcopy ), &refs );
2210  double x = GetPosX();
2211  double y = GetPosY();
2212  cloned->Translate( x, y );
2213  parent->Append( cloned );
2214  }
2215  iterchilds++;
2216  }
2217  refs.LinkReferences();
2218  }
2219 }
2220 
2221 #define BBOX2XYWH(bbox) (bbox).GetMinX(), (bbox).GetMinY(), (bbox).GetWidth(), (bbox).GetHeight()
2222 
2224 {
2225  if( !linkto )
2226  return false;
2227 
2228  if ( m_appearance.Get() )
2229  return false;
2230 
2231  if ( wxDynamicCast( linkto, a2dCameleon ) )
2232  {
2233  a2dCameleon* cam = wxStaticCast( linkto, a2dCameleon );
2235  m_cameleon = cam;
2236  wxASSERT_MSG( m_cameleon, wxT( "a2dCamelon not set in a2dDiagram" ) );
2237  if ( m_appearance )
2238  m_appearance->SetCheck( true );
2239  else
2240  {
2241  wxString error;
2242  error.Printf( wxT( "Appearance with name: %s not found in a2dCameleonInst" ), m_appearanceName.c_str() );
2243  a2dGeneralGlobals->ReportErrorF( a2dError_LinkRef, error );
2244  }
2245  }
2246  else if ( wxDynamicCast( linkto, a2dAppear ) )
2247  {
2248  m_appearance = wxStaticCast( linkto, a2dAppear );
2249  m_appearance->SetCheck( true );
2250  m_cameleon = m_appearance->GetCameleon();;
2251  }
2252  else
2253  {
2254  wxString name = linkto->GetName();
2255  wxString error;
2256  error.Printf( wxT( "cannot Link To: %s with name %s" ), linkto->GetClassInfo()->GetClassName(), name.c_str() );
2257  a2dGeneralGlobals->ReportErrorF( a2dError_LinkRef, error );
2258  }
2259  return true;
2260 }
2261 
2263 {
2264  if ( m_cameleon ) //&& m_cameleon->GetOwnedBy() > 1 )
2265  {
2266  m_cameleon = wxStaticCast( m_cameleon->Clone( a2dObject::clone_deep ), a2dCameleon );
2267  }
2269 }
2270 
2272 {
2274  {
2275  return m_appearance->GetCameleon()->PushInto( this );
2276  //stick to the appearance.
2277  //return m_appearance->PushInto( parent );
2278  }
2279  return this;
2280 }
2281 
2282 void a2dCameleonInst::DoWalker( wxObject* parent, a2dWalkerIOHandler& handler )
2283 {
2284  wxString handlername = handler.GetClassInfo()->GetClassName();
2285  if ( m_cameleon.Get() && handlername != wxT("a2dWalker_SetRoot") )
2286  m_cameleon->Walker( this, handler );
2287 
2288  a2dCanvasObject::DoWalker( parent, handler );
2289 }
2290 
2292 {
2293  a2dBoundingBox bbox;
2294  if ( m_appearance )
2295  {
2296  a2dDiagram* diagram = wxDynamicCast( m_appearance.Get(), a2dDiagram );
2297  if ( diagram )
2298  {
2299  bbox.Expand( diagram->GetUnTransformedBboxNoPorts() );
2300  }
2301  }
2302  else
2303  bbox.Expand( 0, 0 );
2304  return bbox;
2305 }
2306 
2307 a2dPort* a2dCameleonInst::HasPort( a2dDrawing* drawing, a2dParPin* parPin )
2308 {
2309  a2dPort* find = NULL;
2310  a2dCanvasObjectList::iterator iter = drawing->GetRootObject()->CreateChildObjectList()->begin();
2311  while ( iter != drawing->GetRootObject()->GetChildObjectList()->end() )
2312  {
2313  find = wxDynamicCast( ( *iter ).Get(), a2dPort );
2314  //if ( find && find->GetName() == parPin->GetName() )
2315  if ( find && find == parPin->GetPort() )
2316  return find;
2317  iter++;
2318  }
2319  return NULL;
2320 }
2321 
2323 {
2324  a2dCanvasObjectList::iterator iterparInst = CreateChildObjectList()->begin();
2325  while ( iterparInst != CreateChildObjectList()->end() )
2326  {
2327  a2dParPin* pin = wxDynamicCast( ( *iterparInst ).Get(), a2dParPin );
2328  if ( pin && port == pin->GetPort() )
2329  {
2330  wxASSERT_MSG( port == pin->GetPort(), wxT( "pin must be same in both" ) );
2331  return pin;
2332  }
2333  iterparInst++;
2334  }
2335  return NULL;
2336 }
2337 
2339 {
2340  // first make sure all ports in the drawing of the diagram are available here as a2dParPin
2341  // If not add a new one.
2342  a2dPort* port = NULL;
2343  a2dCanvasObjectList::iterator iter = drawing->GetRootObject()->CreateChildObjectList()->begin();
2344  while ( iter != drawing->GetRootObject()->CreateChildObjectList()->end() )
2345  {
2346  port = wxDynamicCast( ( *iter ).Get(), a2dPort );
2347  if ( port )
2348  {
2349  bool found = false;
2350  if ( !HasParPinForPort( port ) )
2351  {
2352  a2dParPin* parPin = NULL;
2353  if ( port->GetParPinClass() && port->GetParPinClass()->GetParPin() )
2354  {
2355  parPin = (a2dParPin*) ( port->GetParPinClass()->GetParPin()->Clone( clone_deep ) );
2356  parPin->SetPort( port );
2357  parPin->Set( port->GetPosX(), port->GetPosY(), port->GetAngle(), port->GetName() );
2358  }
2359  else
2360  parPin = new a2dParPin( this, port, port->GetParPinClass() );
2361  Append( parPin );
2362  }
2363  }
2364  iter++;
2365  }
2366 
2367  // test all parInst a2dParPins for having an equivalent in the drawing ( symbol/diagram )
2368  a2dCanvasObjectList::iterator iterparInst = CreateChildObjectList()->begin();
2369  while ( iterparInst != CreateChildObjectList()->end() )
2370  {
2371  a2dParPin* pin = wxDynamicCast( ( *iterparInst ).Get(), a2dParPin );
2372  if ( pin )
2373  {
2374  // if there is a pin in the cameleon reference which is not in the drawing
2375  // we remove it.
2376  a2dPort* portInDrawing = HasPort(drawing, pin );
2377  if ( !portInDrawing )
2378  {
2379  // disconnect the pin from others
2380  a2dPinList::const_iterator iterconp;
2381  for ( iterconp = pin->GetConnectedPins().begin( ) ; iterconp != pin->GetConnectedPins().end( ) ; iterconp++ )
2382  {
2383  a2dPin* other = *iterconp;
2384  if ( !other || other->GetRelease() )
2385  continue;
2386  pin->Disconnect( other );
2387  }
2388  //release it in idle time (redraw oke ).
2389  pin->SetRelease( true );
2390  iterparInst++;
2391  //parInst->CreateChildObjectList()->erase( iterparInst );
2392  }
2393  else
2394  {
2395  // the pin is in the drawing, now check its position.
2396  pin->SetPosXY( portInDrawing->GetPosX(), portInDrawing->GetPosY() );
2397  iterparInst++;
2398  }
2399  }
2400  else
2401  iterparInst++;
2402  }
2403 }
2404 
2406 {
2407  if ( m_CameleonUpdateTime < m_cameleon->GetInternalChangedTime() )
2408  {
2410  if ( wxDynamicCast( m_appearance.Get(), a2dDiagram ) )
2411  {
2412  a2dDiagram* diagram = wxDynamicCast( m_appearance.Get(), a2dDiagram );
2413  // need a flag or a check for this, else existing connection at this level
2414  // will get lost.
2415  // Preserve existing pins, and add others.
2416  SyncPinsTo( diagram->GetDrawing() );
2417  }
2418  if ( GetPending() )
2419  SetPending( true );
2420  }
2421  a2dCanvasObject* parent = wxDynamicCast( handler->GetParent(), a2dCanvasObject );
2422  if ( parent && parent->GetHighLight() && !parent->GetPending() && GetPending() )
2423  {
2424  parent->SetPending( true );
2425  }
2426 }
2427 
2428 bool a2dCameleonInst::DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox )
2429 {
2430  bool calc = false;
2431  if ( m_appearance )
2432  {
2433  calc = m_cameleon->UpdateData( m_appearance, mode );
2434  }
2435 
2436  if ( !m_bbox.GetValid() || calc )
2437  {
2439  m_bbox.MapBbox( m_lworld );
2440  return true;
2441  }
2442  return false;
2443 }
2444 
2446 {
2447  if ( !m_appearance )
2448  {
2449  double x1;
2450  double y1;
2451  ic.GetTransform().TransformPoint( 0, 0, x1, y1 );
2452  int dx = ic.GetDrawer2D()->WorldToDeviceX( x1 );
2453  int dy = ic.GetDrawer2D()->WorldToDeviceY( y1 );
2454 
2456  ic.GetDrawer2D()->DrawLine( dx - 3, dy, dx + 4, dy );
2457  ic.GetDrawer2D()->DrawLine( dx, dy + 3, dx, dy - 4 );
2458  ic.GetDrawer2D()->PopTransform();
2459  return;
2460  }
2461 
2462  if ( !ic.GetRenderChildDerived() )
2463  return;
2464 
2465 
2466  OVERLAP childclip = _IN;
2467  if ( clipparent != _IN )
2468  {
2469  m_cameleon->GetClipStatusData( m_appearance, ic, clipparent );
2470  }
2471 
2472  if ( childclip != _OUT ) //if a child is _OUT, no need to render it.
2473  {
2474  m_cameleon->RenderData( m_appearance, ic, childclip );
2475  }
2476 
2477  // For debugging
2478  //ic.GetDrawer2D()->SetDrawerStroke( a2dStroke( wxColour( 255, 0, 0 ) ) );
2479  //ic.GetDrawer2D()->DrawRoundedRectangle(BBOX2XYWH( DoGetUnTransformedBbox() ), 0);
2480 
2481 }
2482 
2484 {
2485  if ( !m_appearance )
2486  return false;
2487 
2488 
2489  if ( m_appearance )
2490  {
2491  return m_cameleon->IsHitWorldData( m_appearance, ic, hitEvent ) != 0;
2492  }
2493  return false;
2494 }
2495 
2496 
2497 
2498 #if wxART2D_USE_CVGIO
2499 void a2dCameleonInst::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
2500 {
2501  a2dCanvasObject::DoSave( parent, out, xmlparts, towrite );
2502  if ( xmlparts == a2dXmlSer_attrib )
2503  {
2504  if ( m_cameleon )
2505  out.WriteAttribute( wxT( "cameleon" ), m_cameleon->GetUniqueSerializationId() );
2506  if ( m_appearance )
2507  out.WriteAttribute( wxT( "appearance" ), m_appearance->GetUniqueSerializationId() );
2508  }
2509  else
2510  {
2511  //if object is not saved yet, we need to save it here.
2512  //Normally it will be save from the top of the document, but if reference is the only one, save it here.
2513  if ( m_cameleon && !m_cameleon->GetCheck() && m_cameleon->GetOwnedBy() == 1 )
2514  {
2515  //trick the system to have multiple refs on those objects, else we will not get an id attribute
2516  a2dCanvasObjectPtr multiRef = m_cameleon.Get();
2517 
2518  out.WriteStartElement( wxT( "cameleon" ) );
2519  m_cameleon->Save( this, out, towrite );
2520  out.WriteEndElement();
2521  }
2522  }
2523 }
2524 
2525 void a2dCameleonInst::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
2526 {
2527  a2dCanvasObject::DoLoad( parent, parser, xmlparts );
2528  if ( xmlparts == a2dXmlSer_attrib )
2529  {
2530  if ( parser.HasAttribute( wxT( "cameleon" ) ) )
2531  {
2532  parser.ResolveOrAdd( ( a2dSmrtPtr<class a2dObject>* ) &m_cameleon, parser.GetAttributeValue( wxT( "cameleon" ) ) );
2533  }
2534  if ( parser.HasAttribute( wxT( "appearance" ) ) )
2535  {
2536  parser.ResolveOrAdd( ( a2dSmrtPtr<class a2dObject>* ) &m_appearance, parser.GetAttributeValue( wxT( "appearance" ) ) );
2537  }
2538  }
2539  else
2540  {
2541  if ( parser.GetTagName() != wxT( "cameleon" ) )
2542  return;
2543 
2544  parser.Require( START_TAG, wxT( "cameleon" ) );
2545  parser.Next();
2546 
2547  m_cameleon = (a2dCameleon*) parser.LoadOneObject( this );
2548  if ( m_cameleon )
2549  m_appearance = m_cameleon->GetAppearance<a2dDiagram>();
2550 
2551  parser.Require( END_TAG, wxT( "cameleon" ) );
2552  parser.Next();
2553  }
2554 }
2555 #endif //wxART2D_USE_CVGIO
2556 
2557 
2558 //----------------------------------------------------------------------------
2559 // a2dCommand_CreateCameleonMask
2560 //----------------------------------------------------------------------------
2561 
2563 {
2564  static int nr = 0;
2565  nr++;
2566  wxString portNr = wxString::Format("port_%ld", nr);
2567 
2568  static int camnr = 0;
2569  camnr++;
2570  wxString camNr = wxString::Format("cam_%ld", camnr);
2571 
2572 
2573  a2dCanvasObjectList* objects = m_parent->GetChildObjectList();
2574  m_objects = objects->Clone( m_mask, a2dObject::clone_flat, &m_objectsIndex );
2575  if ( m_objects != wxNullCanvasObjectList )
2576  {
2577  //check for connection to non selected, and disconnect them.
2578  a2dCanvasObjectList result;
2579  a2dCanvasObjectList::iterator iterp = objects->begin();
2580  while ( iterp != objects->end() )
2581  {
2582  a2dCanvasObject* obj = *iterp;
2583  if ( obj && obj->CheckMask( m_mask ) )
2584  {
2586  {
2587  a2dCanvasObject* objchild = *iter;
2588  a2dPin* pin = wxDynamicCast( objchild, a2dPin );
2589  if ( !pin || pin->GetRelease( ) )
2590  continue;
2591 
2592  a2dPinList::iterator iterpins;
2593  for ( iterpins = pin->GetConnectedPins().begin( ) ; iterpins != pin->GetConnectedPins().end( ) ; iterpins++ )
2594  {
2595  a2dPin* pincother = wxDynamicCast( iterpins->Get(), a2dPin );
2596  if ( !pincother || pincother->GetRelease() )
2597  continue;
2598 
2599  if ( pincother && ! pincother->GetParent()->IsSelected() )
2600  {
2601  pincother->Disconnect( pin );
2602  }
2603  }
2604  }
2605  }
2606  iterp++;
2607  }
2608 
2609  wxString camName = wxGetTextFromUser( _T( "Give Name For Created Cameleon:" ), _T( "Create Cameleon" ) , camNr );
2610  m_groupobject = new a2dCameleon( camName, 0, 0, a2dCanvasGlobals->GetHabitat() );
2611  m_groupobject->AddToRoot();
2612 
2613  a2dCanvasObject* drawingroot = NULL;
2614  a2dDiagram* diagram = NULL;
2615  if ( m_symbol )
2616  {
2617  diagram = new a2dSymbol( m_groupobject );
2618  a2dDrawing* currentDrawing = wxDynamicCast( m_parent->GetRoot(), a2dDrawing );
2619  if ( currentDrawing )
2620  diagram->GetDrawing()->SetDrawingId( currentDrawing->GetDrawingId() );
2621  drawingroot = diagram->GetDrawing()->GetRootObject();
2622  m_groupobject->AddAppearance( diagram );
2623  }
2624  else
2625  {
2626  diagram = new a2dDiagram( m_groupobject );
2627  a2dDrawing* currentDrawing = wxDynamicCast( m_parent->GetRoot(), a2dDrawing );
2628  if ( currentDrawing )
2629  diagram->GetDrawing()->SetDrawingId( currentDrawing->GetDrawingId() );
2630  drawingroot = diagram->GetDrawing()->GetRootObject();
2631  m_groupobject->AddAppearance( diagram );
2632  }
2633  m_groupobject->SetIgnoreLayer( true );
2634 
2635  a2dCanvasObjectList::iterator iter = objects->begin();
2636  while ( iter != objects->end() )
2637  {
2638  a2dCanvasObject* obj = *iter;
2639  if ( obj && obj->CheckMask( m_mask ) )
2640  {
2641  a2dPort* port = wxDynamicCast( obj, a2dPort );
2642  /*
2643  a2dPort* pin = wxDynamicCast( obj, a2dPort );
2644  if ( pin )
2645  {
2646  a2dPinClass* pclass = pin->GetPin()->GetPinClass();
2647  obj->Translate( -dx, -dy );
2648  diagram->AppendToDrawing( new a2dPort( obj->GetPosX(), obj->GetPosY(), portNr, pclass ) );
2649  }
2650  else
2651  */
2652  {
2653  //translate the objects within the group in opposite direction
2654  drawingroot->Append( obj );
2655  }
2656  iter = objects->erase( iter );
2657  }
2658  else
2659  iter++;
2660  }
2661 
2662  //parent boxes don't change
2663  drawingroot->Update( a2dCanvasObject::updatemask_force );
2664 
2665  //let the bounding be the position
2666  double dx, dy;
2667  dx = drawingroot->GetBbox().GetMinX();
2668  dy = drawingroot->GetBbox().GetMinY();
2669 
2670  a2dPort* leftUp = diagram->FindLeftUp();
2671 
2672  if ( leftUp )
2673  {
2674  dx = leftUp->GetPosX();
2675  dy = leftUp->GetPosY();
2676  }
2677  diagram->TranslateTo( -dx, -dy );
2678 
2679  if ( !m_name.IsEmpty() )
2680  m_groupobject->SetName( m_name );
2681 
2682  if ( m_symbol )
2683  m_camref = new a2dCameleonInst( dx, dy, (a2dSymbol*) diagram );
2684  else
2685  m_camref = new a2dCameleonInst( dx, dy, diagram );
2686  m_camref->SetName( "ref1" );
2687  m_camref->SetRoot( m_parent->GetRoot() );
2688  m_parent->Append( m_camref );
2689 
2691 
2692  a2dWalker_SetSpecificFlagsCanvasObjects setflags( m_mask );
2693  setflags.Start( m_parent, false );
2694  m_parent->SetPending( true );
2695  }
2696  return true;
2697 }
2698 
2700 {
2701  a2dCanvasObjectList* objects = m_parent->GetChildObjectList();
2702  if ( m_objects != wxNullCanvasObjectList )
2703  {
2704  objects->Release( m_groupobject, false, false, true );
2705  double x = m_groupobject->GetPosX();
2706  double y = m_groupobject->GetPosY();
2707 
2708  a2dlist< long >::iterator index = m_objectsIndex.begin();
2709  while ( index != m_objectsIndex.end() )
2710  {
2711  forEachIn( a2dCanvasObjectList, m_objects )
2712  {
2713  a2dCanvasObject* obj = *iter;
2714  obj->Translate( x, y );
2715  objects->Insert( *index, obj, true );
2716  index++;
2717  }
2718  }
2719  }
2720  m_objects->clear();
2721  return true;
2722 }
2723 
2724 //----------------------------------------------------------------------------
2725 // a2dCommand_FlattenCameleonMask
2726 //----------------------------------------------------------------------------
2727 
2729 {
2730  a2dCanvasObjectList* objects = m_parent->GetChildObjectList();
2731  m_objects = objects->Clone( m_mask, a2dObject::clone_flat, &m_objectsIndex );
2732  if ( m_objects != wxNullCanvasObjectList )
2733  {
2734  forEachIn( a2dCanvasObjectList, m_objects )
2735  {
2736  a2dCameleonInst* group = wxDynamicCast( iter->Get(), a2dCameleonInst );
2737  if ( group && group->CheckMask( m_mask ) )
2738  {
2739  group->Flatten( m_parent );
2740  group->SetRelease( true );
2741  }
2742  }
2743  }
2744  return true;
2745 }
2746 
2748 {
2749  a2dCanvasObjectList* objects = m_parent->GetChildObjectList();
2750  if ( m_objects != wxNullCanvasObjectList )
2751  {
2752  a2dlist< long >::iterator index = m_objectsIndex.begin();
2753  while ( index != m_objectsIndex.end() )
2754  {
2755  forEachIn( a2dCanvasObjectList, m_objects )
2756  {
2757  a2dCanvasObject* obj = *iter;
2758  objects->Insert( *index, obj, true );
2759  index++;
2760  }
2761  }
2762  }
2763  m_objects->clear();
2764  return true;
2765 }
2766 
2767 
2768 //----------------------------------------------------------------------------
2769 // a2dCommand_CloneCameleonFromInstMask
2770 //----------------------------------------------------------------------------
2771 
2773 {
2774  static int nr = 1;
2775  nr++;
2776  wxString camNr = wxString::Format("ref_%ld", nr);
2777  m_newobjects = new a2dCanvasObjectList();
2778 
2779  a2dCanvasObjectList* objects = m_parent->GetChildObjectList();
2780  m_objects = objects->Clone( m_mask, a2dObject::clone_flat );
2781  if ( m_objects != wxNullCanvasObjectList )
2782  {
2783  a2dCanvasObjectList::iterator iter = m_objects->begin();
2784  while ( iter != m_objects->end() )
2785  {
2786  a2dCanvasObject* obj = *iter;
2787  if ( obj && obj->CheckMask( m_mask ) )
2788  {
2790  if ( ref )
2791  {
2792  ref->SetSelected( false );
2793  double dx, dy;
2794  dx = ref->GetBbox().GetWidth()/10;
2795  dy = dx;
2796  //a2dCameleon* cloned = wxStaticCast( ref->GetCameleon()->Clone( a2dObject::clone_deep ), a2dCameleon );
2797  a2dCameleonInst* camref = wxStaticCast( ref->Clone( a2dObject::clone_deep ), a2dCameleonInst );
2798  camref->Translate( dx, dy );
2799  camref->SetName( camNr );
2800  camref->SetSelected( true );
2801  a2dCameleon* cam = camref->GetCameleon();
2802  m_parent->Append( camref );
2803  m_newobjects->push_back( camref );
2804  }
2805  iter++;
2806  }
2807  else
2808  iter = m_objects->erase( iter );
2809  }
2811  }
2812  return true;
2813 }
2814 
2816 {
2817  a2dCanvasObjectList* objects = m_parent->GetChildObjectList();
2818  if ( m_newobjects != wxNullCanvasObjectList )
2819  {
2820  forEachIn( a2dCanvasObjectList, m_newobjects )
2821  {
2822  a2dCanvasObject* obj = *iter;
2823  obj->SetRelease( true );
2824  }
2825  }
2826  m_objects->clear();
2827  return true;
2828 }
2829 
2830 const a2dCommandId a2dCommand_CreateCameleonMask::Id( wxT( "Create Cameleon Selected" ) );
2831 const a2dCommandId a2dCommand_FlattenCameleonMask::Id( wxT( "Flatten Cameleon" ) );
2832 const a2dCommandId a2dCommand_CloneCameleonFromInstMask::Id( wxT( "CloneCameleonFromInstMask" ) );
2833 
Prevent cloning a a2dCameleon reference at a deeper level.
Definition: gen.h:1219
a2dHit m_how
return in which way the object was hit (stroke, fill, ...)
Definition: canobj.h:301
bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
Definition: cantext.cpp:822
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
double GetObjectGridSize()
used for objects which depend in size on this grid
Definition: canglob.h:939
a2dParameters(a2dCameleon *cameleon=NULL, double x=0, double y=0)
Constructor.
Definition: cameleon.cpp:1056
bool GetAttributeValueBool(const wxString &attrib, bool defaultv=false)
Returns the boolean value of an attribute.
Definition: genxmlpars.cpp:537
wxPoint2DDouble a2dPoint2D
this to define if coordinate numbers are integer or doubles
Definition: artglob.h:47
double m_relx
(world coordinates) hit point x relative to the canvas object its parent object(s) ...
Definition: canobj.h:289
see a2dCameleonEvent
Definition: cameleon.h:1098
const a2dError a2dError_LinkRef
user interface appearance for a2dCameleon
Definition: cameleon.h:585
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: cameleon.cpp:51
virtual void Render(a2dIterC &ic, OVERLAP clipparent)
Render this object to the active a2dDrawingPart.
Definition: canobj.cpp:4712
parameters appearance for a2dCameleon
Definition: cameleon.h:556
(In) Visible property that can be added to Docview Objects.
Definition: gen.h:1785
a2dGui(a2dCameleon *cameleon=NULL, double x=0, double y=0)
Constructor.
Definition: cameleon.cpp:1089
#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 void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: cameleon.cpp:697
a2dCanvasObjectList * CreateChildObjectList()
create and get the list where the child objects are stored in.
Definition: canobj.cpp:2561
a2dObject * LoadOneObject(wxObject *parent)
load one object from a CVG file.
bool HasAttribute(const wxString &attrib)
Does the current tag have this attribute?
Definition: genxmlpars.cpp:560
bool Undo(void)
Override this to undo a command.
Definition: cameleon.cpp:2815
virtual void DoWalker(wxObject *parent, a2dWalkerIOHandler &handler)
iterate over this object and its children
Definition: cameleon.cpp:2282
diagram is an appearance for a2dCameleon
Definition: cameleon.h:382
see a2dDrawingEvent
Definition: drawing.h:933
mouse event sent from a2dCanvasObject to itself
Definition: canglob.h:223
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: cameleon.cpp:1808
Port to be used in a diagram for connecting to symbol.
Definition: cameleon.h:54
int WorldToDeviceY(double y) const
convert y from world to device coordinates
Definition: drawer2d.h:455
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
void Flatten(a2dCanvasObject *parent)
bring the contents in a2dSymbol or a2dDiagram to parent.
Definition: cameleon.cpp:2192
virtual void PopTransform(void)
Recall the previously saved user-to-world transform off the matrix stack.
Definition: drawer2d.cpp:480
void SetRelease(bool value)
set release flag
Definition: gen.h:1346
a2dDrawingId GetDrawingId()
set special id to differentiate drawings
Definition: drawing.h:721
XMLeventType Next()
Walks to next element and returns event type.
Definition: genxmlpars.cpp:422
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: cameleon.cpp:432
a2dPort * FindPortByName(const wxString &parPinName) const
find a2dPort with given name.
Definition: cameleon.cpp:648
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: cameleon.cpp:814
bool ResolveOrAdd(a2dSmrtPtr< a2dObject > *storedHere, const wxString &id=wxT(""))
try to resolve the object that is in storedHere when it is a reference.
Definition: gen.cpp:4760
class to map references to objects stored in XML, in order to make the connection later on...
Definition: gen.h:3462
a2dCameleon * GetCameleon()
get referenced a2dCameleon
Definition: cameleon.cpp:2185
virtual wxString GetName() const
Get the ids print and serialization name.
Definition: id.h:245
a2dPropertyIdTyped< wxString, a2dStringProperty > a2dPropertyIdString
property of this type
Definition: id.h:665
bool m_showname
Indicates if both name and value of the property are visible, or just the value.
Definition: cameleon.h:864
bool Do(void)
Override this to perform a command.
Definition: cameleon.cpp:2772
#define EVT_UPDATE_DRAWING(func)
event from a drawing when updated
Definition: drawing.h:988
a2dCanvasOFlags m_flags
holds flags for objects
Definition: canobj.h:2528
a2dCanvasObject * GetRootObject() const
get the root object, which holds the objects in the document
Definition: drawing.h:521
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: cameleon.cpp:367
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
a2dPort * FindPort(a2dPort *symPin) const
search a2dPort in this a2dDiagram with same name as input a2dPort (coming from e.g a a2dSymbol) ...
Definition: cameleon.cpp:620
a2dVisibleParameter()
constructor
Definition: cameleon.cpp:1682
Ref Counted base object.
Definition: gen.h:1045
bool GetPending() const
is this object pending for update?
Definition: canobj.h:1162
a2dDrawing * GetRoot() const
get a2dCanvasDocument of the object.
Definition: canobj.h:952
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: cameleon.cpp:891
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Load object specific CVG data.
Definition: cantext.cpp:536
a2dObject * Clone(CloneOptions options, a2dRefMap *refs=NULL) const
create an exact copy of this property
Definition: gen.cpp:1199
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: cameleon.cpp:490
bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
Definition: cameleon.cpp:2428
bool IsHit() const
true if this is a hit
Definition: polyver.h:107
virtual bool Update(UpdateMode mode)
Update the state of the object according to its current position etc.
Definition: canobj.cpp:5149
Base class for adding to the list of appearances in a a2dCameleon.
Definition: cameleon.h:217
property to hold a double type variable to be associated with a a2dObject
Definition: gen.h:2503
void ConnectEvent(wxEventType type, wxEvtHandler *eventSink)
Definition: gen.cpp:876
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: cameleon.cpp:1743
int m_caret
position of caret within text string
Definition: cantext.h:387
a2dPropertyIdTyped< wxInt32, a2dInt32Property > a2dPropertyIdInt32
property of this type
Definition: id.h:649
property to hold a bool type variable to be associated with a a2dObject
Definition: gen.h:2004
Defines a font to be set to a2dDrawer2D or stored in a2dCanvsObject etc.
Definition: stylebase.h:779
void OnDoEvent(a2dCommandProcessorEvent &event)
track modification of document
Definition: cameleon.cpp:1236
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:819
virtual void DrawPolygon(a2dVertexArray *points, bool spline=false, wxPolygonFillMode fillStyle=wxODDEVEN_RULE)
Draw polygon in world coordinates using pointarray.
Definition: drawer2d.cpp:1889
UpdateMode
Various mode flags for Update.
Definition: canobj.h:1091
virtual bool LinkReference(a2dObject *other)
when resolving this refrence via a a2dIOHandler, this is used.
Definition: cameleon.cpp:2223
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
a2dParPin points to a2dPort
Definition: cameleon.h:172
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: cameleon.cpp:1467
a2dPropertyIdTyped< bool, a2dBoolProperty > a2dPropertyIdBool
property of this type
Definition: id.h:655
a2dCameleon * m_cameleon
point to the a2dCameleon of which this appearance is a part.
Definition: cameleon.h:254
(In)Visible parameters that can be added to Canvas Objects.
Definition: cameleon.h:802
void OnChangeDrawings(a2dDrawingEvent &event)
called when a drawing in a document did change.
Definition: cameleon.cpp:1254
double GetTransformedHitMargin()
transformed to object its coordinate system
Definition: canobj.cpp:616
void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
Definition: cameleon.cpp:1418
a2dCameleonSymbolicRef
Definition: cameleon.h:874
void OnRedoEvent(a2dCommandProcessorEvent &event)
track modification of document
Definition: cameleon.cpp:1242
a2dCanvasObject * PushInto(a2dCanvasObject *parent)
when wanting to traverse hierarchy what level is down here.
Definition: cameleon.cpp:1372
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: canobj.cpp:5728
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: cameleon.cpp:1876
static double m_l2
length from top of arrow to inside point in X
Definition: cameleon.h:106
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
vertex array of line and arc segments.
Definition: polyver.h:494
a2dParPin()
Constructor.
Definition: cameleon.cpp:294
object to show several appearance views on what it contains
Definition: cameleon.h:630
void SetDrawingId(a2dDrawingId id)
get special id to differentiate drawings
Definition: drawing.h:723
a2dCanvasObject is the base class for Canvas Objects.
Definition: canobj.h:371
virtual bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
Definition: cameleon.cpp:1772
virtual void DoWalker(wxObject *parent, a2dWalkerIOHandler &handler)
iterate over this object and its children
Definition: cameleon.cpp:1007
void DoWalker(wxObject *parent, a2dWalkerIOHandler &handler)
iterate over this object and its children
Definition: cameleon.cpp:1392
a2dParPin * GetParPin()
Pin to use in a2dCameleonInst when creating a2dParPin from an a2dPort.
Definition: canpin.cpp:576
void SetMayEdit(bool mayEdit)
if true, editing drawing is allowed
Definition: drawing.h:726
a2dPort * FindLeftUp() const
find the port in the diagram that is most left up.
Definition: cameleon.cpp:589
wxString m_appearanceName
if m_appearance is not set, this is used to establish link
Definition: cameleon.h:356
void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
Definition: cameleon.cpp:756
a2dBoundingBox DoGetUnTransformedBbox(a2dBboxFlags flags=a2dCANOBJ_BBOX_NON) const
In derived object this should be overriden to calculate the boundingbox of the object without its chi...
Definition: cameleon.cpp:997
a2dCanvasObjectList * GetChildObjectList()
get the list where the child objects are stored in.
Definition: canobj.cpp:2551
virtual wxObject * CreateObject(const wxString &symbolicName)
Creates an specific object by name.
Definition: gen.cpp:4937
void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
Definition: cameleon.cpp:254
void TransformPoint(double x, double y, double &tx, double &ty) const
Transform a point.
Definition: afmatrix.cpp:559
a2dAppear(a2dCameleon *cameleon, double x=0, double y=0)
Constructor.
Definition: cameleon.cpp:405
void SetSelected(bool selected)
Set the object selected flag if allowed.
Definition: canobj.h:1620
virtual void SetName(const wxString &name)
Creates the a2dStringProperty PROPID_Name.
Definition: gen.cpp:1305
void WriteEndElement(bool newLine=true)
Writes correspondending end tag for the current start tag.
Definition: genxmlpars.cpp:862
a2dAppear * GetAppearanceByName(const wxString &name) const
get appearance by its name
Definition: cameleon.cpp:1292
static double m_l1
length from top of arrow to outside points in X
Definition: cameleon.h:103
bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
Definition: cameleon.cpp:1906
a2dBoundingBox DoGetUnTransformedBbox(a2dBboxFlags flags=a2dCANOBJ_BBOX_NON) const
In derived object this should be overriden to calculate the boundingbox of the object without its chi...
Definition: cameleon.cpp:1407
void OnUndoEvent(a2dCommandProcessorEvent &event)
track modification of document
Definition: cameleon.cpp:1248
a2dPinClass * GetParPinClass() const
get pinclass to be used for a2dParPin to generate when making instances from a2dCameleons using this ...
Definition: cameleon.h:87
void AddToRoot(bool autoPlace=true)
add this to ms_centralCameleonRoot at a suitable position
Definition: cameleon.cpp:1260
a2dAffineMatrix m_lworld
used for positioning the object (x,y,ang,scale etc.)
Definition: canobj.h:2559
size_t m_firsteditable
The first editable character, usually 0, but may be different for a2dVisibleProperty.
Definition: cantext.h:407
a2dBoundingBox DoGetUnTransformedBbox(a2dBboxFlags flags=a2dCANOBJ_BBOX_NON) const
In derived object this should be overriden to calculate the boundingbox of the object without its chi...
Definition: cameleon.cpp:245
Io handler to iterate through a a2dDocument.
Definition: gen.h:3911
property to hold a 2 byte integer type variable to be associated with a a2dObject ...
Definition: gen.h:2401
bool GetCheck() const
general flag use at will.
Definition: gen.h:1342
a2dBoundingBox DoGetUnTransformedBbox(a2dBboxFlags flags=a2dCANOBJ_BBOX_NON) const
In derived object this should be overriden to calculate the boundingbox of the object without its chi...
Definition: cameleon.cpp:2291
bool Disconnect(a2dPin *pin=a2dAnyPin, bool forceErase=false)
Definition: canpin.cpp:789
bool Undo(void)
Override this to undo a command.
Definition: cameleon.cpp:2699
a2dText is an abstract base class.
Definition: cantext.h:93
a2dCanvasObjectList * wxNullCanvasObjectList
define a NON a2dCanvasObjectList
Definition: objlist.cpp:53
std list compatible list
Definition: a2dlist.h:42
static a2dCanvasObject * GetCameleonRoot()
return the root where all a2dCameleon&#39;s are stored
Definition: cameleon.h:711
static double ms_dy
dy position for next a2dCameleon;
Definition: cameleon.h:783
bool GetValid() const
returns true if boundingbox is calculated properly and therefore its valid flag is set...
Definition: bbox.cpp:299
void Expand(const a2dPoint2D &, const a2dPoint2D &)
expand boundingbox width two points
Definition: bbox.cpp:155
double GetMinX() const
get minimum X of the boundingbox
Definition: bbox.cpp:304
a2dBoundingBox DoGetUnTransformedBbox(a2dBboxFlags flags=a2dCANOBJ_BBOX_NON) const
In derived object this should be overriden to calculate the boundingbox of the object without its chi...
Definition: cameleon.cpp:1897
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
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: cameleon.cpp:421
a2dCanvasObjectList * m_childobjects
holds child objects
Definition: canobj.h:2562
void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: cameleon.cpp:2499
a2dCameleon * GetCameleon()
this appearance is for the returned a2dCameleon here.
Definition: cameleon.h:229
bool m_visible
is the object visible (overruled by paranet object in some cases during rendering ...
Definition: candefs.h:250
#define forEachIn(listtype, list)
easy iteration for a2dlist
Definition: a2dlist.h:111
bool IsUserDefined() const
true if this property is user defined
Definition: id.h:277
a2dSmrtPtr< a2dAppear > m_appearance
points to an appearance in a2dCameleon
Definition: cameleon.h:351
void Set(double xc, double yc, double angle=0, const wxString &name=wxT(""), bool dynamic=false)
set postion angle and name of the pin
Definition: canpin.cpp:663
void SetParent(a2dObject *parent)
set parent object of the drawing ( in case there is always only one )
Definition: drawing.h:461
bool DoIsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent)
Does hit test on the object (exclusif child objects)
Definition: cameleon.cpp:1035
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: cameleon.cpp:1110
a2dCameleonInst to show one appearance of an a2dCameleon.
Definition: cameleon.h:272
void Walker(wxObject *parent, a2dWalkerIOHandler &handler)
This is used to recursively walk through an object tree.
Definition: gen.cpp:1473
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: cameleon.cpp:1105
double GetPosX() const
get x position from affine matrix
Definition: canobj.h:527
void Insert(size_t before, a2dCanvasObject *obj, bool ignoreReleased)
insert at index, taking into account released objects if needed.
Definition: objlist.cpp:742
a2dSmrtPtr< a2dAppear > m_appearance
points to an appearance in a2dCameleon
Definition: cameleon.h:931
void DependencyPending(a2dWalkerIOHandler *handler)
called by to check if this object becomes pending as a result of other objects
Definition: cameleon.cpp:2405
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: canpin.cpp:1526
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
Drawing context abstraction.
Definition: drawer2d.h:177
Normal straight line segment in a2dVertexList and a2dVertexArray.
Definition: polyver.h:163
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: cameleon.cpp:2166
#define EVT_CANVASOBJECT_MOUSE_EVENT(func)
static event table macro for a2dCanvasObject mouse event
Definition: canglob.h:312
a2dCameleon * GetCameleon()
get referenced a2dCameleon
Definition: cameleon.cpp:1888
A2DGENERALDLLEXP a2dSmrtPtr< a2dGeneralGlobal > a2dGeneralGlobals
a global pointer to get to global instance of important classes.
Definition: comevt.cpp:1148
void TriggerChangedTime()
make the changed time Now
Definition: cameleon.h:708
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: canobj.cpp:5569
void Translate(double x, double y)
relative translate the object to position x,y in world coordinates
Definition: canobj.h:569
a2dNamedProperty * Clone(a2dObject::CloneOptions options, a2dRefMap *refs=NULL) const
Virtual copy constructor.
Definition: gen.cpp:1820
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: cameleon.cpp:718
virtual void Initialize()
Definition: canobj.h:420
int Release(a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL, const wxString &classname=wxT(""), const a2dPropertyId *id=NULL, const wxString &name=wxT(""), bool now=true)
release only objects with the given mask and classname and has property named propertyname and object...
Definition: objlist.cpp:306
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: canpin.cpp:1476
void TranslateTo(double dx, double dy)
origin of drawing is shifted to the pos given.
Definition: cameleon.cpp:575
static a2dPoint2D GetSuitblePoint()
Get a suitable location for a new a2dCameleon();.
Definition: cameleon.cpp:1274
int WorldToDeviceX(double x) const
convert x from world to device coordinates
Definition: drawer2d.h:453
Hint to clone enough of the object to do proper dragging in graphics.
Definition: gen.h:1221
a2dCanvasObject * PushInto(a2dCanvasObject *parent)
when wanting to traverse hierarchy what level is down here.
Definition: cameleon.cpp:1045
virtual void DrawLine(double x1, double y1, double x2, double y2)
Draw line in world coordinates.
Definition: drawer2d.cpp:2167
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Write object specific CVG data.
Definition: cameleon.cpp:1793
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:862
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 DoIsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent)
Does hit test on the object (exclusif child objects)
Definition: cameleon.cpp:772
bool IsSelected() const
Is the object selected flag set.
Definition: canobj.h:1610
void TriggerCameleonUpdateTime()
make the update time Now
Definition: cameleon.h:317
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: cameleon.cpp:379
Tappear * GetAppearance(bool autoCreate=false)
Get a specific a2dAppear derived class instance from here.
Definition: cameleon.h:666
bool m_subEditAsChild
allow subedit on this object when child of other object
Definition: candefs.h:247
a2dCanvasObject(double x=0, double y=0)
constructor called by derived objects
Definition: canobj.cpp:1391
Symbolic appearance for a2dCameleon.
Definition: cameleon.h:470
Contains a2dDrawing Class to hold a drawing.
a2dPort()
Constructor.
Definition: cameleon.cpp:181
set a2dCanvasObjects flags in a hierarchy of a a2dCanvasDocument
Definition: algos.h:486
a2dBoundingBox DoGetUnTransformedBbox(a2dBboxFlags flags=a2dCANOBJ_BBOX_NON) const
In derived object this should be overriden to calculate the boundingbox of the object without its chi...
Definition: cameleon.cpp:746
Each a2dCommand is given a command id at construction.
Definition: comevt.h:99
bool DoIsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent)
Does hit test on the object (exclusif child objects)
Definition: cameleon.cpp:2483
void SetCheck(bool check)
general flag use at will.
Definition: gen.h:1339
property to hold a wxString type variable to be associated with a a2dObject
Definition: gen.h:2066
defines common settinsg for a habitat for a set of a2dCameleons.
Definition: canglob.h:439
void SetVisible(bool visible)
set if this object will visible (be rendered or not)
Definition: canobj.h:1303
void DoEndEdit()
only used for editable objects and under control of a editing tool.
Definition: cameleon.cpp:1753
bool LinkReference(a2dObject *other)
link a reference in the object to the given value
Definition: cameleon.cpp:344
a2dPropertyIdPtr m_propId
the property id for which the value needs to be displayed.
Definition: cameleon.h:861
a2dParPin * HasParPinForPort(a2dPort *pin)
find equivalent a2dParPin voor the given a2dPort.
Definition: cameleon.cpp:2322
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: cameleon.cpp:1073
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: cameleon.cpp:1066
if set, set in the clone the PROPID_editcopy property to the original object
Definition: gen.h:1215
double GetPosY() const
get y position from affine matrix
Definition: canobj.h:530
bool Do(void)
Override this to perform a command.
Definition: cameleon.cpp:2562
double GetWorldStrokeExtend()
Definition: canobj.h:3403
while iterating a a2dCanvasDocument, this holds the context.
Definition: canobj.h:3212
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: cameleon.cpp:2525
virtual a2dCanvasObject * PushInto(a2dCanvasObject *parent)
when wanting to traverse hierarchy what level is down here.
Definition: cameleon.cpp:1956
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: cameleon.cpp:2034
a2dWalker based algorithms
All updates of these modes force an update (e.g. update non-pending valid bounding boxes) ...
Definition: canobj.h:1107
a2dSymbol()
Constructor.
Definition: cameleon.cpp:789
void MapBbox(const a2dAffineMatrix &matrix)
Definition: bbox.cpp:445
Definition: bbox.h:28
a2dlist< a2dDumbPtr< a2dPin > > & GetConnectedPins()
Return list fo connected pins.
Definition: canpin.h:462
bool ReleaseChildObjects(a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL)
removes and release only from the childobjects the objects with the given mask
Definition: canobj.cpp:6296
special a2dCanvasObject to make a multi view hierachy.
const a2dFont * a2dDEFAULT_CANVASFONT
global a2dFont stock object for default font
a2dHasParameters * m_parent
object which contains m_propId
Definition: cameleon.h:858
static double m_l3
length from top of arrow to inside point in X
Definition: cameleon.h:109
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Write object specific CVG data.
Definition: cantext.cpp:568
void DoWalker(wxObject *parent, a2dWalkerIOHandler &handler)
iterate over this object and its children
Definition: cameleon.cpp:688
a2dHit HitTestPolygon(const a2dPoint2D &ptest, double margin)
extensive hittesting on vertex list seen as polygon.
Definition: polyver.cpp:1254
wxString GetAttributeValue(const wxString &attrib, const wxString &defaultv=wxT(""))
Returns the value of an attribute.
Definition: genxmlpars.cpp:450
wxString GetName() const
get the name given to the pin.
Definition: canpin.h:322
void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: cameleon.cpp:2006
bool LinkReference(a2dObject *linkto)
link a reference in the object to the given value
Definition: cameleon.cpp:1917
int GetOwnedBy()
like it to be protected, but this does not work with wxList macros
Definition: gen.h:1173
void TakePortsTo(a2dCameleonInst *parInst)
a2dPort objects result in pins for the instance
Definition: cameleon.cpp:550
wxObject * GetParent()
Definition: gen.h:3972
bool GetRelease() const
get release flag
Definition: gen.h:1350
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: cameleon.cpp:1099
virtual a2dCanvasObject * PushInto(a2dCanvasObject *parent)
when wanting to traverse hierarchy what level is down here.
Definition: cameleon.cpp:2271
bool GetRenderChildDerived()
when set child object in derived a2dCanvasObject are rendered, else only the object itself...
Definition: canobj.h:3436
bool DoIsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent)
Does hit test on the object (exclusif child objects)
Definition: cameleon.cpp:272
virtual void DoWalker(wxObject *parent, a2dWalkerIOHandler &handler)
iterate over this object and its children
Definition: cameleon.cpp:1977
This is the base class for all kinds of property id&#39;s for a2dObject.
Definition: id.h:154
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: cameleon.cpp:957
double GetWidth() const
returns width of the boundingbox
Definition: bbox.cpp:328
void Require(const XMLeventType &type, wxString name)
Forces a special tag.
Definition: genxmlpars.cpp:390
list for a2dCanvasObject
wxString GetTagName()
Returns name of the current XML tag.
Definition: genxmlpars.cpp:565
static a2dPinClass * Standard
Pins of this class can only connect to pins of the same class.
Definition: canpin.h:766
bool DoIsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent)
Does hit test on the object (exclusif child objects)
Definition: cameleon.cpp:1456
void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
Definition: cameleon.cpp:1015
a2dAppear * GetAppearance()
get referenced a2dCameleon
Definition: cameleon.h:293
void SetPosXY(double x, double y, bool restrict=false)
set position to x,y
Definition: canobj.cpp:1624
a2dHasParameters(double x=0, double y=0)
Constructor.
Definition: cameleon.cpp:37
bool Start(a2dCanvasObject *object, bool setTo)
start removing properties from the object given, and down.
Definition: algos.cpp:784
virtual void DependencyPending(a2dWalkerIOHandler *handler)
called by to check if this object becomes pending as a result of other objects
Definition: cameleon.cpp:679
void ShowName(bool show=false)
Show both name and value of the property or just the value.
Definition: cameleon.cpp:1731
bool m_editingCopy
true if the object needs to be rendered in edit mode.
Definition: candefs.h:304
Event sent to a2dCommandProcessor.
Definition: comevt.h:701
void SetName(const wxString &name)
Creates the a2dStringProperty PROPID_Name.
Definition: cameleon.h:76
bool m_utbbox_changed
Untransformed bounding box changed.
Definition: cantext.h:399
if set, clone members (e.g. line end styles), otherwise ref-copy them
Definition: gen.h:1203
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: cameleon.cpp:215
class to define a set of properties/parameters on derived classes.
Definition: cameleon.h:123
see a2dComEvent
Definition: gen.h:371
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: cameleon.cpp:1078
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: cameleon.cpp:1231
a2dCanvasObject * IsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent)
If the position (x,y) is within the object return this.
Definition: canobj.cpp:3415
void TakeVisibleParameters(a2dCameleonInst *parInst)
take visible parameters instances into a pameterized instance, to make them unique per instance...
Definition: cameleon.cpp:662
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
Definition: bbox.h:39
void SyncPinsTo(a2dDrawing *drawing)
synchronize pins here to the a2dPorts in the drawing.
Definition: cameleon.cpp:2338
a2dCanvasObjectList * Clone(a2dObject::CloneOptions options) const
Clone everything ( Clones objects also) in a new created list.
Definition: objlist.cpp:173
A property id defined by user.
Definition: id.h:207
double GetMinY() const
get minimum Y of the boundingbox
Definition: bbox.cpp:310
bool Undo(void)
Override this to undo a command.
Definition: cameleon.cpp:2747
double GetAngle() const
get absolute angle of the pin ( after applying the parent its matrix and it own matrix ) ...
Definition: cameleon.h:70
void SetPosXyPoint(const a2dPoint2D &pos)
set position to x,y
Definition: canobj.h:547
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: cameleon.cpp:1489
a2dCanvasGlobal * a2dCanvasGlobals
global a2dCanvasGlobal to have easy access to global settings
Definition: canglob.cpp:1234
virtual void Save(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dObjectList *towrite)
write all needed to an XML type of file called the CVG format
Definition: gen.cpp:1343
virtual bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
Definition: canobj.cpp:5098
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: cameleon.cpp:427
bool m_prerenderaschild
as child this object will be rendered before the parent object itself when true (default) ...
Definition: candefs.h:289
This template class is for property ids with a known data type.
Definition: id.h:477
a2dBoundingBox m_bbox
boundingbox in world coordinates
Definition: canobj.h:2539
void MakeReferencesUnique()
All direct a2dCanvasObject which are part of this one are made unique.
Definition: cameleon.cpp:2262
void Append(a2dCanvasObject *obj)
append a a2dCanvasObject to the childobjects
Definition: canobj.cpp:6224
wxString m_text
the text to display
Definition: cantext.h:381
a2dCanvasObject * PushInto(a2dCanvasObject *parent)
when wanting to traverse hierarchy what level is down here.
Definition: cameleon.cpp:545
static double m_b
base of arrow
Definition: cameleon.h:112
a2dCanvasObject * GetParent() const
get parent object of the pin
Definition: canpin.h:295
const a2dAffineMatrix & GetTransform() const
Get the accumulated transform up to and including m_lworld of the current object. ...
Definition: canobj.cpp:663
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: cameleon.cpp:933
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Definition: cameleon.cpp:338
bool DoIsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent)
Does hit test on the object (exclusif child objects)
Definition: cameleon.cpp:2067
void SetCameleon(a2dCameleon *cam)
this appearance is from this a2dCameleon
Definition: cameleon.h:232
list of a2dObject&#39;s
Definition: gen.h:3157
virtual bool LinkReferences(bool ignoreNonResolved=false)
link references to their destination
Definition: gen.cpp:4862
double m_rely
(world coordinates) hit point y relative to the canvas object its parent object(s) ...
Definition: canobj.h:291
void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
Definition: cameleon.cpp:2445
wxString m_appearanceName
if m_appearance is not set, this is used to establish link
Definition: cameleon.h:936
void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
Definition: cameleon.cpp:1985
CloneOptions
options for cloning
Definition: gen.h:1200
bool DisconnectEvent(wxEventType type, wxEvtHandler *eventSink)
Definition: gen.cpp:902
bool ResolveOrAddLink(a2dObject *obj, const wxString &id=wxT(""))
try to resolve an object referenced by obj using the LinkReference function
Definition: gen.cpp:4808
void SetParent(a2dHasParameters *parent)
to set the parent where the m_propId is searched for.
Definition: cameleon.cpp:1737
virtual void DoEndEdit()
only used for editable objects and under control of a editing tool.
Definition: cantext.cpp:1026
a2dAppear * GetAppearanceByClassName(const wxString &appearranceClassName) const
get appearance by its Classname
Definition: cameleon.cpp:1305
a2dBoundingBox & GetBbox()
get boundingbox in world coordinates exclusive stroke width relative to its parent ...
Definition: canobj.cpp:3175
structure to give as parameter to member functions of a2dCanvasObject
Definition: canobj.h:252
Contain one drawing as hierarchical tree of a2dCanvasObject&#39;s.
Definition: drawing.h:434
virtual a2dNamedProperty * CreatePropertyFromString(const wxString &value) const
Create a new property object from a value string.
Definition: id.h:255
void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
Definition: cameleon.cpp:823
wxInt64 GetUniqueSerializationId() const
return a unique id for this object
Definition: gen.cpp:1450
virtual void PushIdentityTransform()
push no transform, to draw directly in device coordinates
Definition: drawer2d.cpp:469
a2dPropertyIdTyped< double, a2dDoubleProperty > a2dPropertyIdDouble
property of this type
Definition: id.h:657
static a2dCanvasObject * ms_centralCameleonRoot
Definition: cameleon.h:777
virtual void DoWalker(wxObject *parent, a2dWalkerIOHandler &handler)
iterate over this object and its children
Definition: canobj.cpp:5504
general canvas module declarations and classes
void WriteStartElement(const wxString &name, bool newLine=true)
Writes start tag which has no attributes.
Definition: genxmlpars.cpp:738
bool Do(void)
Override this to perform a command.
Definition: cameleon.cpp:2728
cameleon.cpp Source File -- Sun Oct 12 2014 17:04:13 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation