wxArt2D
layerinf.cpp
Go to the documentation of this file.
1 /*! \file canvas/src/layerinf.cpp
2  \author Klaas Holwerda
3 
4  Copyright: 2000-2004 (c) Klaas Holwerda
5 
6  Licence: wxWidgets Licence
7 
8  RCS-ID: $Id: layerinf.cpp,v 1.106 2009/05/20 18:42:10 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/canglob.h"
22 #include "wx/canvas/algos.h"
23 #include "wx/canvas/layerinf.h"
24 #include "wx/canvas/canobj.h"
25 #include "wx/artbase/liner.h"
26 #include "wx/canvas/drawer.h"
27 
28 #include <algorithm>
29 #include <functional>
30 
31 struct SortLayerOrder : public std::binary_function< const a2dLayerInfoPtr&, const a2dLayerInfoPtr&, bool>
32 {
33  bool operator()( const a2dLayerInfoPtr& x, const a2dLayerInfoPtr& y )
34  {
35  if ( x == wxNullLayerInfo && y == wxNullLayerInfo )
36  return false;
37  if ( x != wxNullLayerInfo && y == wxNullLayerInfo )
38  return true;
39  if ( x == wxNullLayerInfo && y != wxNullLayerInfo )
40  return false;
41 
42  if ( x->GetOrder() < y->GetOrder() )
43  return true;
44  return false;
45  }
46 };
47 
48 struct SortLayerReverseOrder : public std::binary_function< const a2dLayerInfoPtr&, const a2dLayerInfoPtr&, bool>
49 {
50  bool operator()( const a2dLayerInfoPtr& x, const a2dLayerInfoPtr& y )
51  {
52  if ( x == wxNullLayerInfo && y == wxNullLayerInfo )
53  return false;
54  if ( x != wxNullLayerInfo && y == wxNullLayerInfo )
55  return true;
56  if ( x == wxNullLayerInfo && y != wxNullLayerInfo )
57  return false;
58 
59  if ( x->GetOrder() > y->GetOrder() )
60  return true;
61  return false;
62  }
63 };
64 
65 struct SortLayerNr : public std::binary_function< const a2dLayerInfoPtr&, const a2dLayerInfoPtr&, bool>
66 {
67  bool operator()( const a2dLayerInfoPtr& x, const a2dLayerInfoPtr& y )
68  {
69  if ( x == wxNullLayerInfo && y == wxNullLayerInfo )
70  return false;
71  if ( x != wxNullLayerInfo && y == wxNullLayerInfo )
72  return true;
73  if ( x == wxNullLayerInfo && y != wxNullLayerInfo )
74  return false;
75 
76  if ( x->GetLayer() < y->GetLayer() )
77  return true;
78  return false;
79  }
80 };
81 
82 
83 bool LayerSorter( const a2dCanvasObjectPtr& x, const a2dCanvasObjectPtr& y )
84 {
85  a2dLayerInfo* firstc = wxStaticCast( x.Get(), a2dLayerInfo );
86  a2dLayerInfo* secondc = wxStaticCast( y.Get(), a2dLayerInfo );
87 
88  if ( firstc->GetLayer() > secondc->GetLayer() )
89  return true;
90  return false;
91 }
92 
93 bool OrderSorter( const a2dCanvasObjectPtr& x, const a2dCanvasObjectPtr& y )
94 {
95  a2dLayerInfo* firstc = wxStaticCast( x.Get(), a2dLayerInfo );
96  a2dLayerInfo* secondc = wxStaticCast( y.Get(), a2dLayerInfo );
97 
98  if ( firstc->GetOrder() < secondc->GetOrder() )
99  return true;
100  return false;
101 }
102 
103 bool ReverseOrderSorter( const a2dCanvasObjectPtr& x, const a2dCanvasObjectPtr& y )
104 {
105  a2dLayerInfo* firstc = wxStaticCast( x.Get(), a2dLayerInfo );
106  a2dLayerInfo* secondc = wxStaticCast( y.Get(), a2dLayerInfo );
107 
108  if ( firstc->GetOrder() > secondc->GetOrder() )
109  return true;
110  return false;
111 }
112 
113 /**************************************************
114  a2dLayerInfo
115 **************************************************/
116 IMPLEMENT_DYNAMIC_CLASS( a2dLayerInfo, a2dCanvasObject )
117 IMPLEMENT_DYNAMIC_CLASS( a2dLayers, a2dCanvasObject )
118 
119 a2dPropertyIdString* a2dLayerInfo::PROPID_layerName = NULL;
120 a2dPropertyIdBool* a2dLayerInfo::PROPID_layerSelectable = NULL;
121 a2dPropertyIdBool* a2dLayerInfo::PROPID_layerVisible = NULL;
122 a2dPropertyIdBool* a2dLayerInfo::PROPID_readlayer = NULL;
123 a2dPropertyIdUint16* a2dLayerInfo::PROPID_order = NULL;
124 a2dPropertyIdUint16* a2dLayerInfo::PROPID_inmap = NULL;
125 a2dPropertyIdUint16* a2dLayerInfo::PROPID_outmap = NULL;
126 
127 INITIALIZE_PROPERTIES( a2dLayerInfo, a2dCanvasObject )
128 {
129  A2D_PROPID_M_F( a2dPropertyIdString, a2dLayerInfo, layerName, wxT( "" ), m_layername, a2dPropertyId::flag_notify );
130  A2D_PROPID_M_F( a2dPropertyIdBool, a2dLayerInfo, layerSelectable, false, m_layerselectable, a2dPropertyId::flag_notify );
131  A2D_PROPID_M_F( a2dPropertyIdBool, a2dLayerInfo, layerVisible, false, m_layervisible, a2dPropertyId::flag_notify );
132  A2D_PROPID_M_F( a2dPropertyIdBool, a2dLayerInfo, readlayer, false, m_readlayer, a2dPropertyId::flag_notify );
133  A2D_PROPID_M_F( a2dPropertyIdUint16, a2dLayerInfo, order, false, m_order, a2dPropertyId::flag_notify );
134  A2D_PROPID_M_F( a2dPropertyIdUint16, a2dLayerInfo, inmap, false, m_inmap, a2dPropertyId::flag_notify );
135  A2D_PROPID_M_F( a2dPropertyIdUint16, a2dLayerInfo, outmap, false, m_outmap, a2dPropertyId::flag_notify );
136  return true;
137 }
138 
139 const a2dSignal a2dLayerInfo::sig_changedLayerInfo = wxNewId();
140 
141 a2dSmrtPtr<a2dLayerInfo> wxNullLayerInfo = new a2dLayerInfo();
142 
143 BEGIN_EVENT_TABLE( a2dLayerInfo, a2dCanvasObject )
144  EVT_COM_EVENT( a2dLayerInfo::OnPropertyChanged )
145 END_EVENT_TABLE()
146 
147 a2dLayerInfo::a2dLayerInfo()
148 {
149  m_layer = 0;
150  m_layeravailable = false;
151  m_layervisible = true;
152  m_layerselectable = true;
153  m_readlayer = true;
154  m_order = 0;
155  m_polarity = true;
156  m_plated = false;
157  m_area = 0;
158 
159  m_inmap = 0;
160  m_outmap = 0;
161 
162  m_width = LAYERINFO_WIDTH;
163  m_height = LAYERINFO_HEIGHT;
164 
165  m_pinclass = a2dPinClass::Standard;
166 
167  m_type = wxT( "SIGNAL" );
168  m_side = wxT( "TOP" );
169 
170  m_canvasObjectCount = 0;
171  m_canvasPreviousObjectCount = 0;
172 }
173 
174 a2dLayerInfo::a2dLayerInfo( wxUint16 index, wxString name )
175 {
176  wxASSERT_MSG( GetHabitat()->GetMaxLayer() > index, wxT( " wxLAYER_ALL layer is reserved do not use" ) );
177 
178  m_layer = index;
179 
180  m_layeravailable = false;
181  m_layervisible = true;
182  m_layerselectable = true;
183  m_readlayer = true;
184  m_order = index;
185  m_polarity = true;
186  m_plated = false;
187  m_area = 0;
188 
189  m_inmap = index;
190  m_outmap = index;
191 
192  m_layername = name;
193 
194  MX_SetFill( a2dFill( wxColour( 0, 0, 0 ), a2dFILL_SOLID ) );
195  MX_SetStroke( a2dStroke( wxColour( 255, 0, 0 ), 0, a2dSTROKE_SOLID ) );
196 
197  m_width = LAYERINFO_WIDTH;
198  m_height = LAYERINFO_HEIGHT;
199 
201  m_type = wxT( "SIGNAL" );
202  m_side = wxT( "TOP" );
204  m_canvasPreviousObjectCount = 0;
205 }
206 
207 a2dLayerInfo::a2dLayerInfo( const a2dLayerInfo& other, CloneOptions options, a2dRefMap* refs )
208  : a2dCanvasObject( other, options, refs )
209 {
213 
214  m_order = other.m_order;
215  m_polarity = other.m_polarity;
216  m_plated = other.m_plated;
217  m_area = other.m_area;
218  m_readlayer = other.m_readlayer;
219  m_inmap = other.m_inmap;
220  m_outmap = other.m_outmap;
221 
222  m_type = other.m_type;
223  m_side = other.m_side;
224  m_span = other.m_span;
225  m_feature = other.m_feature;
226  m_subFeature = other.m_subFeature;
228 
229  m_width = other.m_width;
230  m_height = other.m_height;
231 
232  m_layername = other.m_layername;
233 
234  m_pinclass = other.m_pinclass;
236  m_canvasPreviousObjectCount = 0;
237 }
238 
239 a2dLayerInfo::~a2dLayerInfo()
240 {
241 }
242 
243 void a2dLayerInfo::SetPending( bool pending )
244 {
246 }
247 
248 wxString a2dLayerInfo::GetName() const
249 {
250  return m_layername;
251 }
252 
253 void a2dLayerInfo::SetName( const wxString& name )
254 {
255  m_layername = name;
256 }
257 
259 {
260  return new a2dLayerInfo( *this, options, refs );
261 }
262 
264 {
266  if ( m_root )
267  {
268  //wxASSERT_MSG(m_root->GetLayerSetup()->GetLayerIndex()[m_layer] != wxNullLayerInfo,
269  // wxT("layer not defined in layer table"));
270 
271  a2dComEvent changedlayer( this, event.GetPropertyId(), sig_changedLayerInfo );
272  m_root->ProcessEvent( changedlayer );
273  }
274 }
275 
276 #if wxART2D_USE_CVGIO
277 void a2dLayerInfo::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
278 {
279  a2dCanvasObject::DoSave( parent, out, xmlparts, towrite );
280  if ( xmlparts == a2dXmlSer_attrib )
281  {
282  //out.WriteAttribute( wxT("layername"), m_layername ); //is written in base class
283  out.WriteAttribute( wxT( "layervisible" ), m_layervisible );
284  out.WriteAttribute( wxT( "layerselectable" ), m_layerselectable );
285  out.WriteAttribute( wxT( "readlayer" ), m_readlayer );
286  out.WriteAttribute( wxT( "inmap" ), m_inmap );
287  out.WriteAttribute( wxT( "outmap" ), m_outmap );
288  out.WriteAttribute( wxT( "order" ), m_order );
289  if ( m_width != LAYERINFO_WIDTH )
290  {
291  out.WriteNewLine();
292  out.WriteAttribute( wxT( "width" ), m_width );
293  }
294  if ( m_height != LAYERINFO_HEIGHT )
295  {
296  out.WriteNewLine();
297  out.WriteAttribute( wxT( "height" ), m_height );
298  }
299 
300  out.WriteAttribute( wxT( "description" ), m_description );
301  out.WriteAttribute( wxT( "feature" ), m_feature );
302  out.WriteAttribute( wxT( "subfeature" ), m_subFeature );
303  out.WriteAttribute( wxT( "type" ), m_type );
304  out.WriteAttribute( wxT( "polarity" ), m_polarity );
305  out.WriteAttribute( wxT( "span" ), m_span );
306  out.WriteAttribute( wxT( "area" ), m_area );
307  }
308  else
309  {
310  }
311 }
312 
313 void a2dLayerInfo::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
314 {
315  a2dCanvasObject::DoLoad( parent, parser, xmlparts );
316  if ( xmlparts == a2dXmlSer_attrib )
317  {
318  m_width = parser.GetAttributeValueDouble( wxT( "width" ), LAYERINFO_WIDTH );
319  m_height = parser.GetAttributeValueDouble( wxT( "height" ), LAYERINFO_HEIGHT );
320 
321  m_layername = parser.GetAttributeValue( wxT( "name" ), m_layername );
322  m_inmap = parser.GetAttributeValueUint16( wxT( "inmap" ), m_layer );
323  m_outmap = parser.GetAttributeValueUint16( wxT( "outmap" ), m_layer );
324  m_order = parser.GetAttributeValueUint16( wxT( "order" ), m_layer );
325  m_readlayer = parser.GetAttributeValueBool( wxT( "readlayer" ), m_readlayer );
326 
327  m_description = parser.GetAttributeValue( wxT( "description" ), m_description );
328  m_feature = parser.GetAttributeValue( wxT( "feature" ), m_feature );
329  m_subFeature = parser.GetAttributeValue( wxT( "subfeature" ), m_subFeature );
330  m_type = parser.GetAttributeValue( wxT( "type" ), m_type );
331  m_polarity = parser.GetAttributeValueBool( wxT( "polarity" ), m_polarity );
332  m_span = parser.GetAttributeValue( wxT( "span" ), m_span );
333  m_area = parser.GetAttributeValueDouble( wxT( "area" ), m_area );
334  }
335  else
336  {
337  }
338 }
339 #endif //wxART2D_USE_CVGIO
340 
342 {
343  return m_layervisible;
344 }
345 
347 {
348  return m_layerselectable;
349 }
350 
352 {
353  return m_order;
354 }
355 
357 {
358  return m_readlayer;
359 }
360 
361 void a2dLayerInfo::SetVisible( bool status )
362 {
363  m_layervisible = status;
364 }
365 
366 void a2dLayerInfo::SetSelectable( bool status )
367 {
368  m_layerselectable = status;
369 }
370 
371 void a2dLayerInfo::SetOrder( wxUint16 order )
372 {
373  m_order = order;
374 }
375 
376 void a2dLayerInfo::SetRead( bool status )
377 {
378  m_readlayer = status;
379 }
380 
382 {
383  return m_inmap;
384 }
385 
387 {
388  return m_outmap;
389 }
390 
391 void a2dLayerInfo::SetInMapping( wxUint16 layer )
392 {
393  m_inmap = layer;
394 }
395 void a2dLayerInfo::SetOutMapping( wxUint16 layer )
396 {
397  m_outmap = layer;
398 }
399 
401 {
402  return GetStroke().GetPixelStroke();
403 }
404 
406 {
407  GetStroke().SetPixelStroke( pixel );
408 }
409 
410 a2dBoundingBox a2dLayerInfo::DoGetUnTransformedBbox( a2dBboxFlags WXUNUSED( flags ) ) const
411 {
412  a2dBoundingBox bbox;
413  bbox.Expand( 0, 0 );
414  bbox.Expand( m_width , m_height );
415  return bbox;
416 }
417 
418 void a2dLayerInfo::DoRender( a2dIterC& ic, OVERLAP WXUNUSED( clipparent ) )
419 {
421 }
422 
424 {
425  double margin = ic.GetTransformedHitMargin();
426 
427  double xmin = wxMin( 0 , m_width );
428  double ymin = wxMin( 0 , m_height );
429  double xmax = wxMax( 0 , m_width );
430  double ymax = wxMax( 0 , m_height );
431 
432  hitEvent.m_how = HitTestRectangle( hitEvent.m_relx, hitEvent.m_rely, xmin, ymin, xmax, ymax, ic.GetTransformedHitMargin() + margin );
433 
434  return hitEvent.m_how.IsHit();
435 }
436 
438 {
439  if ( m_root )
440  {
441  a2dComEvent changed( this, sig_changedLayerInfo );
442  m_root->ProcessEvent( changed );
443  }
444 }
445 
446 
447 /******************************************************************************
448  Layers settings
449 *******************************************************************************/
450 
451 a2dPropertyIdBool* a2dLayers::PROPID_visibleAll = NULL;
452 a2dPropertyIdBool* a2dLayers::PROPID_readAll = NULL;
453 a2dPropertyIdBool* a2dLayers::PROPID_selectableAll = NULL;
454 
455 
456 const a2dSignal a2dLayers::sig_visibleAll = wxNewId();
457 const a2dSignal a2dLayers::sig_selectAll = wxNewId();
458 const a2dSignal a2dLayers::sig_outlineAll = wxNewId();
459 const a2dSignal a2dLayers::sig_readAll = wxNewId();
460 const a2dSignal a2dLayers::sig_availableAll = wxNewId();
461 
462 INITIALIZE_PROPERTIES( a2dLayers, a2dCanvasObject )
463 {
464  A2D_PROPID_D( a2dPropertyIdBool, visibleAll, false );
465  A2D_PROPID_D( a2dPropertyIdBool, readAll, false );
466  A2D_PROPID_D( a2dPropertyIdBool, selectableAll, false );
467  return true;
468 }
469 
470 /*
471 #include <functional>
472 
473 template<class _Ty>
474 struct greater2 : std::binary_function<_Ty, _Ty, bool> {
475  bool operator()(const _Ty& _X, const _Ty& _Y) const
476  {return (_X > _Y); }
477  };
478 
479 
480 bool operator < (const a2dCanvasObjectPtr& x, const a2dCanvasObjectPtr& y)
481 {
482  a2dLayerInfo* firstc = wxStaticCast( x.Get(), a2dLayerInfo );
483  a2dLayerInfo* secondc = wxStaticCast( y.Get(), a2dLayerInfo );
484 
485  switch ( a2dLayers::m_sortOn )
486  {
487  default:
488  case 0:
489  if ( firstc->GetOrder() < secondc->GetOrder() )
490  return true;
491  case 1:
492  if ( firstc->GetOrder() > secondc->GetOrder() )
493  return true;
494  case 2:
495  if ( firstc->GetLayer() < secondc->GetLayer() )
496  return true;
497  }
498  return false;
499 }
500 
501 
502 namespace std{
503 struct sortgreater : public binary_function< a2dCanvasObjectPtr, a2dCanvasObjectPtr, bool>
504  {
505  bool operator()(const a2dCanvasObjectPtr& x, const a2dCanvasObjectPtr& y) const
506  {
507  a2dLayerInfo* firstc = wxStaticCast( x.Get(), a2dLayerInfo );
508  a2dLayerInfo* secondc = wxStaticCast( y.Get(), a2dLayerInfo );
509 
510  if ( firstc->GetOrder() < secondc->GetOrder() )
511  return true;
512  return false;
513  }
514  };
515 
516 }
517 */
518 
519 a2dLayers::a2dLayers(): a2dCanvasObject()
520 {
521  m_indexed = false;
522  UpdateIndexes();
523 }
524 
525 a2dLayers::a2dLayers( const a2dLayers& other, CloneOptions options, a2dRefMap* refs )
526  : a2dCanvasObject( other, options, refs )
527 {
528  wxASSERT( ( options & clone_deep ) == clone_deep );
529  m_flags.m_pending = true;
530  m_indexed = false;
531  m_filename = other.m_filename;
532 
533  UpdateIndexes();
534 }
535 
536 a2dLayers::~a2dLayers()
537 {
538 }
539 
541 {
542  return new a2dLayers( *this, options, refs );
543 }
544 
545 void a2dLayers::SetPending( bool pending )
546 {
547  a2dCanvasObject::SetPending( pending );
548 
549  if ( m_root )
550  {
551  m_indexed = false;
552  }
553 }
554 
555 a2dLayerIndex& a2dLayers::GetLayerIndex()
556 {
557  if ( !m_indexed )
558  UpdateIndexes();
559  return m_layerArrayOnLayer;
560 }
561 
562 a2dLayerIndex& a2dLayers::GetOrderIndex()
563 {
564  if ( !m_indexed )
565  UpdateIndexes();
566  return m_layerArrayOnOrder;
567 }
568 
570 {
571  if ( !m_indexed )
572  UpdateIndexes();
573  return m_layerArrayOnReverseOrder;
574 }
575 
576 bool a2dLayers::LoadLayers( const wxString& filename )
577 {
578  wxString foundfile = filename;
579 #if wxART2D_USE_CVGIO
580 
582  m_indexed = false;
583 
584 #if wxUSE_STD_IOSTREAM
585  a2dDocumentFileInputStream stream( foundfile.mb_str() );
586  if ( stream.fail() || stream.bad() )
587 #else
588  wxFileInputStream stream( foundfile );
589  if ( !stream.Ok() )
590 #endif
591  {
592  a2dGeneralGlobals->ReportErrorF( a2dError_FileCouldNotOpen, _( "Could not open layers settings file %s" ), foundfile.c_str() );
593  return false;
594  }
595 
596  a2dIOHandlerCVGIn cvgparser;
597  if ( cvgparser.CanLoad( stream, this ) )
598  {
599  bool result = cvgparser.LoadLayers( stream, this );
600  SetPending( true );
601  if ( !result )
602  a2dGeneralGlobals->ReportErrorF( a2dError_LoadLayers, _( "Cannot load layers from this file %s" ), foundfile.c_str() );
603  return result;
604  }
605  else
606  a2dGeneralGlobals->ReportErrorF( a2dError_LoadLayers, _( "Cannot load layers from this file %s" ), foundfile.c_str() );
607  return false;
608 #else
609  wxFAIL_MSG( wxT( "wxART2D_USE_CVGIO is needed to load layers from a CVG file" ) );
610  return false;
611 #endif //wxART2D_USE_CVGIO
612 }
613 
614 
615 bool a2dLayers::SaveLayers( const wxString& filename )
616 {
617 #if wxUSE_STD_IOSTREAM
618  a2dDocumentFileOutputStream store( filename.mb_str() );
619  if ( store.fail() || store.bad() )
620 #else
621  wxFileOutputStream storeUnbuf( filename );
622  wxBufferedOutputStream store( storeUnbuf );
623  if ( store.GetLastError() != wxSTREAM_NO_ERROR )
624 #endif
625  {
626  a2dGeneralGlobals->ReportErrorF( a2dError_FileCouldNotOpen, _( "Sorry, could not open file %s for saving" ), filename.c_str() );
627  return false;
628  }
631 
632 #if wxART2D_USE_CVGIO
633  //assume it is the default CVG format.
634  a2dIOHandlerCVGOut* handler = new a2dIOHandlerCVGOut();
635  bool res = handler->SaveLayers( store, this );
636  delete handler;
637 #else
638  wxFAIL_MSG( wxT( "wxART2D_USE_CVGIO is needed to save object to a CVG file" ) );
639  return false;
640 #endif //wxART2D_USE_CVGIO
641  return res;
642 }
643 
644 void a2dLayers::InitWith( int highlayer, bool blackWhite )
645 {
646  CreateChildObjectList()->clear();
647 
648  if ( highlayer > GetHabitat()->GetMaxLayer() )
649  highlayer = GetHabitat()->GetMaxLayer();
650 
651  int j;
652  for ( j = 0; j < highlayer; j++ )
653  {
654  wxString namelay;
655  namelay.Printf( wxT( "Layer %d" ), j );
656  a2dLayerInfo* defLayer = new a2dLayerInfo( j, namelay );
657  if ( !blackWhite )
658  {
659  a2dFill fill = a2dFill( wxColour( wxColour( rand() % 254, rand() % 254, rand() % 254 ) ) );
660  a2dStroke stroke = a2dStroke( wxColour( wxColour( rand() % 254, rand() % 254, rand() % 254 ) ) );
661  defLayer->SetFill( fill );
662  defLayer->SetStroke( stroke );
663  }
664  else
665  {
666  int graycol = rand() % 254;
667  wxColour gray( graycol, graycol, graycol );
668  a2dFill fill = a2dFill( gray );
669  graycol = rand() % 254;
670  wxColour grays( graycol, graycol, graycol );
671  a2dStroke stroke = a2dStroke( grays );
672  defLayer->SetFill( fill );
673  defLayer->SetStroke( stroke );
674  }
675  Append( defLayer );
676  m_indexed = false;
677  }
678  UpdateIndexes();
679 }
680 
681 a2dLayerInfo* a2dLayers::operator[] ( int indx )
682 {
683  assert( indx >= 0 && indx < GetHabitat()->GetMaxLayer() ); return m_layerArrayOnLayer[indx];
684 }
685 const a2dLayerInfo* a2dLayers::operator[] ( int indx ) const
686 {
687  assert( indx >= 0 && indx < GetHabitat()->GetMaxLayer() ); return m_layerArrayOnLayer[indx];
688 }
689 
690 a2dLayerInfo* a2dLayers::GetLayerInfo( int index )
691 {
692  assert( index >= 0 && index < GetHabitat()->GetMaxLayer() ); return m_layerArrayOnLayer[index];
693 }
694 
696 {
697  if ( m_layerArrayOnOrder.size() != GetHabitat()->GetMaxLayer() )
698  {
699  m_layerArrayOnOrder.resize( GetHabitat()->GetMaxLayer() );
700  m_layerArrayOnReverseOrder.resize( GetHabitat()->GetMaxLayer() );
701  m_layerArrayOnLayer.resize( GetHabitat()->GetMaxLayer() );
702  m_indexed = false;
703  }
704 
705  if ( !m_indexed )
706  {
707  m_indexed = true;
708  unsigned int j;
709 
710  //! fill them with the non defined layer objects
711  for ( j = 0; j < GetHabitat()->GetMaxLayer(); j++ )
712  {
713  m_layerArrayOnOrder[j] = wxNullLayerInfo;
714  m_layerArrayOnReverseOrder[j] = wxNullLayerInfo;
715  m_layerArrayOnLayer[j] = wxNullLayerInfo;
716  }
717 
719  {
720  wxUint16 maxorder = 0;
722  {
723  a2dLayerInfo* lobj = ( a2dLayerInfo* ) ( *iter ).Get();
724  wxUint16 layer = lobj->m_layer;
725 
726  maxorder = wxMax( lobj->m_order, maxorder );
727 
728  wxASSERT_MSG( layer < GetHabitat()->GetMaxLayer(), wxT( "layer index must be > 0 and < GetHabitat()->GetMaxLayer()" ) );
729 
730  if ( m_layerArrayOnLayer[ layer ] != wxNullLayerInfo )
731  {
732  wxString warn;
733  warn.Printf( wxT( "layer index %d defined twice" ), layer );
734  wxLogWarning( warn );
735  }
736 
737  m_layerArrayOnLayer[ layer ] = lobj;
738  m_layerArrayOnOrder[ layer ] = lobj;
739  m_layerArrayOnReverseOrder[ layer ] = lobj;
740  //wxLogDebug( wxT(" found layer %d with name %s"), layer, lobj->GetName() );
741  }
742 
743  // non existing layers will be added.
744  int j;
745  for ( j = 0; j < GetHabitat()->GetMaxLayer(); j++ )
746  {
747  if ( m_layerArrayOnLayer[j] == wxNullLayerInfo )
748  {
749  wxString namelay;
750  namelay.Printf( wxT( "Layer %d" ), j );
751  a2dLayerInfo* defLayer = new a2dLayerInfo( j, namelay );
752  maxorder += 10;
753  defLayer->SetOrder( maxorder );
754  PROPID_TemporaryObject->SetPropertyToObject( defLayer, true );
755 
756  Append( defLayer );
757  m_layerArrayOnLayer[j] = defLayer;
758  m_layerArrayOnOrder[j] = defLayer;
759  m_layerArrayOnReverseOrder[j] = defLayer;
760  }
761  }
762 
763  std::sort( m_layerArrayOnLayer.begin(), m_layerArrayOnLayer.end(), SortLayerNr() );
764  std::sort( m_layerArrayOnOrder.begin(), m_layerArrayOnOrder.end(), SortLayerOrder() );
765  std::sort( m_layerArrayOnReverseOrder.begin(), m_layerArrayOnReverseOrder.end(), SortLayerReverseOrder() );
766 
767  /* if you need to check it.
768  for ( j=0; j < GetHabitat()->GetMaxLayer(); j++ )
769  {
770  if ( m_layerArrayOnLayer[j] != wxNullLayerInfo )
771  {
772  wxString namelay;
773  namelay.Printf( wxT("index %d Layer %d %s"), j, m_layerArrayOnLayer[j]->GetLayer(), m_layerArrayOnLayer[j]->GetName() );
774  wxLogDebug( namelay );
775  }
776  else
777  wxLogDebug( wxT("NULL") );
778  if ( m_layerArrayOnOrder[j] != wxNullLayerInfo )
779  {
780  wxString namelay;
781  namelay.Printf( wxT("index %d Order %d"), j, m_layerArrayOnOrder[j]->GetOrder() );
782  wxLogDebug( namelay );
783  }
784  else
785  wxLogDebug( wxT("NULL") );
786  if ( m_layerArrayOnReverseOrder[j] != wxNullLayerInfo )
787  {
788  wxString namelay;
789  namelay.Printf( wxT("index %d reverse %d"), j, m_layerArrayOnReverseOrder[j]->GetOrder() );
790  wxLogDebug( namelay );
791  }
792  else
793  wxLogDebug( wxT("NULL") );
794  }
795  */
796 
797  }
798  }
799 }
800 
801 void a2dLayers::SetAvailable( a2dDrawing* drawing )
802 {
803  SetAllLayersAvailable( false );
804  //this one always available because editing handles are on it.
805  m_layerArrayOnLayer[wxLAYER_DEFAULT]->SetAvailable( true );
806 
807  a2dWalker_SetAvailable set( this );
808  set.SetSkipNotRenderedInDrawing( true );
809  set.Start( drawing );
810 }
811 
812 void a2dLayers::SetAvailable( a2dLayers* other )
813 {
814  unsigned int j;
815  for ( j = 0; j < GetHabitat()->GetMaxLayer(); j++ )
816  {
817  m_layerArrayOnLayer[j]->SetAvailable( other->m_layerArrayOnLayer[j]->GetAvailable() );
818  }
819 
820  //this one always available because editing handles are on it.
821  m_layerArrayOnLayer[wxLAYER_DEFAULT]->SetAvailable( true );
822 }
823 
824 bool a2dLayers::DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox )
825 {
826  if ( !m_indexed )
827  {
828  UpdateIndexes();
829 
830  return true;
831  }
832  return false;
833 }
834 
835 #if wxART2D_USE_CVGIO
836 void a2dLayers::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
837 {
838  if ( xmlparts == a2dXmlSer_attrib )
839  {
840  // all layers that are added temporarely into the setup, are now checked,
841  // and those available ( has objects on it in the document(s) ), will be set non temporary, and therefore saved.
843  {
845  {
846  a2dLayerInfo* lobj = ( a2dLayerInfo* ) ( *iter ).Get();
847  if ( lobj->GetAvailable() )
849  }
850  }
851  }
852 
853  a2dCanvasObject::DoSave( parent, out, xmlparts, towrite );
854  if ( xmlparts == a2dXmlSer_attrib )
855  {
856  }
857  else
858  {
859  }
860 }
861 
862 void a2dLayers::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
863 {
864  a2dCanvasObject::DoLoad( parent, parser, xmlparts );
865  if ( xmlparts == a2dXmlSer_attrib )
866  {
867  }
868  else
869  {
870  a2dCanvasObjectList::iterator iter = m_childobjects->begin();
871  while ( iter != m_childobjects->end() )
872  {
873  a2dLayerInfo* lobj = wxDynamicCast( ( *iter ).Get(), a2dLayerInfo ) ;
874  if ( lobj->GetLayer() && (lobj->GetLayer() < 0 || lobj->GetLayer() >= GetHabitat()->GetMaxLayer() ) )
875  {
876  //lobj->SetRelease( true );
877  wxLogWarning( wxT( "%s %d" ), _T( "Layer definition not in Range is removed: " ), lobj->GetLayer() );
878  iter = m_childobjects->erase( iter );
879  }
880  else
881  {
882  lobj->SetParent( this );
883  iter++;
884  }
885  }
886  }
887  m_indexed = false;
888 }
889 #endif //wxART2D_USE_CVGIO
890 
891 wxString a2dLayers::GetName( int layernumber )
892 {
893  return m_layerArrayOnLayer[layernumber]->GetName();
894 }
895 
896 int a2dLayers::GetNumber( wxString name )
897 {
898  unsigned int j;
899 
900  for ( j = 0; j < GetHabitat()->GetMaxLayer(); j++ )
901  {
902  if ( m_layerArrayOnLayer[j]->GetName() == name )
903  return j;
904  }
905  wxFAIL_MSG( wxT( "layer not defined in layerlist" ) );
906  return -1;
907 }
908 
909 a2dStroke a2dLayers::GetStroke( int layernumber )
910 {
911  return m_layerArrayOnLayer[layernumber]->GetStroke();
912 }
913 
914 bool a2dLayers::GetVisible( int layernumber )
915 {
916  return m_layerArrayOnLayer[layernumber]->GetVisible();
917 }
918 
919 bool a2dLayers::GetSelectable( int layernumber )
920 {
921  return m_layerArrayOnLayer[layernumber]->GetSelectable();
922 }
923 
924 a2dFill a2dLayers::GetFill( int layernumber )
925 {
926  return m_layerArrayOnLayer[layernumber]->GetFill();
927 }
928 
929 int a2dLayers::GetOrder( int layernumber )
930 {
931  return m_layerArrayOnLayer[layernumber]->GetOrder();
932 }
933 
934 bool a2dLayers::GetRead( int layernumber )
935 {
936  return m_layerArrayOnLayer[layernumber]->GetRead();
937 }
938 
939 bool a2dLayers::GetPixelStroke( int layernumber )
940 {
941  return m_layerArrayOnLayer[layernumber]->GetPixelStroke();
942 }
943 
944 
945 void a2dLayers::SetName( int layernumber, wxString name )
946 {
947  m_layerArrayOnLayer[layernumber]->SetName( name );
948 }
949 
950 void a2dLayers::SetVisible( int layernumber, bool status )
951 {
952  m_layerArrayOnLayer[layernumber]->SetVisible( status );
953 }
954 
955 void a2dLayers::SetAvailable( int layernumber, bool status )
956 {
957  m_layerArrayOnLayer[layernumber]->SetAvailable( status );
958 }
959 
960 void a2dLayers::SetSelectable( int layernumber, bool status )
961 {
962  m_layerArrayOnLayer[layernumber]->SetSelectable( status );
963 }
964 
965 void a2dLayers::SetFill( int layernumber, const a2dFill& fill )
966 {
967  m_layerArrayOnLayer[layernumber]->SetFill( fill );
968 }
969 
970 void a2dLayers::SetStroke( int layernumber, const a2dStroke& stroke )
971 {
972  m_layerArrayOnLayer[layernumber]->SetStroke( stroke );
973 }
974 
975 void a2dLayers::SetPattern( int layernumber, const wxBitmap& stipple )
976 {
977  a2dFill fill = m_layerArrayOnLayer[layernumber]->GetFill();
978  a2dFill pfill = a2dFill( stipple );
979  pfill.SetColour( fill.GetColour() );
980  pfill.SetColour2( fill.GetColour2() );
981  m_layerArrayOnLayer[layernumber]->SetFill( pfill );
982 }
983 
984 void a2dLayers::SetOrder( int layernumber, int status )
985 {
986  m_layerArrayOnLayer[layernumber]->SetOrder( status );
987 }
988 
989 void a2dLayers::SetRead( int layernumber, bool status )
990 {
991  m_layerArrayOnLayer[layernumber]->SetRead( status );
992 }
993 
995 {
996  unsigned int j;
997  for ( j = 0; j < GetHabitat()->GetMaxLayer(); j++ )
998  {
999  m_layerArrayOnLayer[j]->SetVisible( onoff );
1000  }
1001  if ( m_root )
1002  {
1003  a2dComEvent changed( this, sig_visibleAll );
1004  m_root->ProcessEvent( changed );
1005  }
1006 }
1007 
1009 {
1010  unsigned int j;
1011 
1012  for ( j = 0; j < GetHabitat()->GetMaxLayer(); j++ )
1013  {
1014  m_layerArrayOnLayer[j]->SetRead( onoff );
1015  }
1016  if ( m_root )
1017  {
1018  a2dComEvent changed( this, sig_readAll );
1019  m_root->ProcessEvent( changed );
1020  }
1021 }
1022 
1024 {
1025  unsigned int j;
1026 
1027  for ( j = 0; j < GetHabitat()->GetMaxLayer(); j++ )
1028  {
1029  m_layerArrayOnLayer[j]->SetSelectable( onoff );
1030  }
1031  if ( m_root )
1032  {
1033  a2dComEvent changed( this, sig_selectAll );
1034  m_root->ProcessEvent( changed );
1035  }
1036 }
1037 
1039 {
1040  unsigned int j;
1041 
1042  for ( j = 0; j < GetHabitat()->GetMaxLayer(); j++ )
1043  {
1044  a2dFill fill = m_layerArrayOnLayer[j]->GetFill();
1045  fill.SetFilling( onoff );
1046  m_layerArrayOnLayer[j]->SetFill( fill );
1047  }
1048  if ( m_root )
1049  {
1050  a2dComEvent changed( this, sig_outlineAll );
1051  m_root->ProcessEvent( changed );
1052  }
1053 }
1054 
1055 void a2dLayers::SetAllLayersAvailable( bool onoff )
1056 {
1057  unsigned int j;
1058 
1059  for ( j = 0; j < GetHabitat()->GetMaxLayer(); j++ )
1060  {
1061  m_layerArrayOnLayer[j]->SetAvailable( onoff );
1062  }
1063  if ( m_root )
1064  {
1065  a2dComEvent changed( this, sig_availableAll );
1066  m_root->ProcessEvent( changed );
1067  }
1068 }
1069 
1070 int a2dLayers::GetInMapping( int layernumber )
1071 {
1072  return m_layerArrayOnLayer[layernumber]->GetInMapping();
1073 }
1074 
1075 int a2dLayers::GetOutMapping( int layernumber )
1076 {
1077  return m_layerArrayOnLayer[layernumber]->GetOutMapping();
1078 }
1079 
1080 void a2dLayers::SetInMapping( int layernumber, wxUint16 layer )
1081 {
1082  m_layerArrayOnLayer[layernumber]->SetInMapping( layer );
1083 }
1084 
1085 void a2dLayers::SetOutMapping( int layernumber, wxUint16 layer )
1086 {
1087  m_layerArrayOnLayer[layernumber]->SetOutMapping( layer );
1088 }
1089 
1090 void a2dLayers::SetPixelStroke( int layernumber, bool status )
1091 {
1092  m_layerArrayOnLayer[layernumber]->SetPixelStroke( status );
1093 }
1094 
a2dHit m_how
return in which way the object was hit (stroke, fill, ...)
Definition: canobj.h:301
bool GetAttributeValueBool(const wxString &attrib, bool defaultv=false)
Returns the boolean value of an attribute.
Definition: genxmlpars.cpp:537
double m_relx
(world coordinates) hit point x relative to the canvas object its parent object(s) ...
Definition: canobj.h:289
#define wxDynamicCast(obj, className)
Define wxDynamicCast so that it will give a compiler error for unrelated types.
Definition: gen.h:75
Base class for all types of strokes, understood by a2dDrawer2D classes.
Definition: stylebase.h:378
a2dCanvasObjectList * CreateChildObjectList()
create and get the list where the child objects are stored in.
Definition: canobj.cpp:2561
wxString m_layername
name of the layer
Definition: layerinf.h:273
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: layerinf.cpp:862
virtual void SetParent(a2dCanvasObject *parent)
set parent object of the pin or some other objects that needs a parent
Definition: canobj.h:2122
void SetSelectable(bool status)
set layer selectable
Definition: layerinf.cpp:366
a2dLayerInfo * operator[](int indx)
element operator
Definition: layerinf.cpp:681
void SetAll_Layers_Selectable(bool onoff)
set all visible layers selectable
Definition: layerinf.cpp:1023
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
class to map references to objects stored in XML, in order to make the connection later on...
Definition: gen.h:3462
wxColour GetColour2() const
return colour 2
Definition: stylebase.cpp:4969
a2dDrawing * m_root
root group for rendering and accessing the canvas&#39;s also contains layer settings
Definition: canobj.h:2525
a2dCanvasOFlags m_flags
holds flags for objects
Definition: canobj.h:2528
bool GetAvailable()
are there objects on this layer
Definition: layerinf.h:108
void SignalChange()
sent a sig_changedLayerInfo to a2dDrawing
Definition: layerinf.cpp:437
bool m_readlayer
will the layer be read from a file
Definition: layerinf.h:251
void SetAll_Layers_Outline(bool onoff)
set all visible layers outline
Definition: layerinf.cpp:1038
void SetPixelStroke(bool pixelstroke)
set pixelstoke flag, stroke width is defined in pixels else in worldcoordinates
Definition: stylebase.cpp:6316
wxUint16 m_outmap
mapping to this layer from the file layer in the output file
Definition: layerinf.h:264
Ref Counted base object.
Definition: gen.h:1045
void SetPixelStroke(bool pixel)
make stroke of layer a pixelstroke
Definition: layerinf.cpp:405
void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: layerinf.cpp:277
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: layerinf.cpp:313
bool m_pending
set when a2dCanvasObject needs an update (redraw).
Definition: candefs.h:277
double m_height
height of rectangle
Definition: layerinf.h:270
bool IsHit() const
true if this is a hit
Definition: polyver.h:107
a2dPinClass * m_pinclass
The class defines to which other pins a pin on this layer can connect.
Definition: layerinf.h:307
virtual void SetName(const wxString &name)
Set name for layer.
Definition: layerinf.cpp:253
const a2dError a2dError_FileCouldNotOpen
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:819
UpdateMode
Various mode flags for Update.
Definition: canobj.h:1091
bool GetPixelStroke() const
if the width is pixels or not.
Definition: stylebase.cpp:6335
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
bool m_polarity
negative or positive
Definition: layerinf.h:297
wxString m_subFeature
extra as part of a feature.
Definition: layerinf.h:279
The base class for all drawable objects in a a2dCanvasDocument.
double GetTransformedHitMargin()
transformed to object its coordinate system
Definition: canobj.cpp:616
#define A2D_PROPID_M_F(type, classname, propname, defaultval, mptr, flags)
to define a get set property more easily
Definition: id.h:723
wxUint16 m_layer
layer of object, default wxLAYER_DEFAULT
Definition: canobj.h:2556
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: canobj.cpp:5728
a2dCanvasObject is the base class for Canvas Objects.
Definition: canobj.h:371
std::vector< a2dLayerInfoPtr > & GetLayerIndex()
return array index on Layer
Definition: layerinf.cpp:555
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: layerinf.cpp:258
wxString m_span
Used to tell for layers of type hole, in between which other two layers this hole starts and ends...
Definition: layerinf.h:288
output handler for the CVG format.
Definition: xmlpars.h:103
bool SaveLayers(const wxString &filename)
save layer object to CVG file
Definition: layerinf.cpp:615
bool GetVisible()
is the layer visible
Definition: layerinf.cpp:341
int GetOutMapping()
mapping of internal layer index to external layer index
Definition: layerinf.cpp:386
bool m_layervisible
is the layer visible
Definition: layerinf.h:248
void OnPropertyChanged(a2dComEvent &event)
Definition: canobj.cpp:2762
virtual bool CanLoad(a2dDocumentInputStream &stream, const wxObject *obj=NULL, wxClassInfo *docClassInfo=NULL)
test header of the file to see if its CVG format
Definition: xmlpars.cpp:52
bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
Definition: layerinf.cpp:824
void SetPattern(int layernumber, const wxBitmap &stipple)
sets a a2dPatternFill to this stipple, if not a a2dPatternFill, it will be changed.
Definition: layerinf.cpp:975
void WriteNewLine()
Writes a new line and takes care of indentation.
Definition: genxmlpars.cpp:890
bool m_layerselectable
is the layer selectable
Definition: layerinf.h:245
void SetVisible(bool status)
set layer visible
Definition: layerinf.cpp:361
double m_area
used to save area occupied by all primitives on the layer
Definition: layerinf.h:294
wxUint32 m_canvasObjectCount
Definition: layerinf.h:311
void SetRead(bool status)
read this layer from input files
Definition: layerinf.cpp:376
a2dCanvasObjectList * wxNullCanvasObjectList
define a NON a2dCanvasObjectList
Definition: objlist.cpp:53
bool Start(a2dObject *object)
object to start the algorithm
Definition: algos.cpp:193
bool GetSelectable()
can objects on this layer be selected
Definition: layerinf.cpp:346
virtual wxString GetName() const
Get name for layer.
Definition: layerinf.cpp:248
void Expand(const a2dPoint2D &, const a2dPoint2D &)
expand boundingbox width two points
Definition: bbox.cpp:155
void SetPending(bool pending)
setpending to also set a2dLayers pending
Definition: layerinf.cpp:243
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: layerinf.cpp:540
int GetInMapping()
mapping of external file layer to internal layer index
Definition: layerinf.cpp:381
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
a2dCanvasObjectList * m_childobjects
holds child objects
Definition: canobj.h:2562
bool m_layeravailable
Definition: layerinf.h:255
#define forEachIn(listtype, list)
easy iteration for a2dlist
Definition: a2dlist.h:111
void SetPropertyToObject(a2dObject *obj, const basetype &value, SetFlags setflags=set_none) const
Set the property in obj to value.
Definition: id.inl:238
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: layerinf.cpp:410
wxString m_feature
this layer is part of a group of layers to present a feature ( metalized via etc. )...
Definition: layerinf.h:276
#define EVT_COM_EVENT(func)
static wxEvtHandler for communication event
Definition: gen.h:564
layer settings for a a2dCanvasDocument Holds layers settings classes
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
static a2dPropertyIdBool * PROPID_TemporaryObject
set for objects that do not have to be saved
Definition: canobj.h:2681
void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: layerinf.cpp:836
void SetPending(bool pending)
next to base sets m_indexed false
Definition: layerinf.cpp:545
static const a2dSignal sig_changedLayerInfo
when one layer its a2dLayerInfo has changed ( e.g. visible or order of rendering ) ...
Definition: layerinf.h:322
bool SaveLayers(a2dDocumentOutputStream &stream, a2dLayers *layers)
save a layer definition to a CVG file.
Definition: xmlpars.cpp:304
A2DGENERALDLLEXP a2dSmrtPtr< a2dGeneralGlobal > a2dGeneralGlobals
a global pointer to get to global instance of important classes.
Definition: comevt.cpp:1148
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: canobj.cpp:5569
wxString m_side
which side of board
Definition: layerinf.h:285
wxUint16 GetLayer() const
Returns the layer index where this object is drawn upon.
Definition: canobj.h:2368
bool GetPixelStroke()
stroke defined in pixels?
Definition: layerinf.cpp:400
void SetColour(const wxColour &col)
set colour used for gradient and wxSTIPPLE_MASK_OPAQUE filling.
Definition: stylebase.cpp:4988
contains the layer properties for one layer,
Definition: layerinf.h:41
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:862
void SetInMapping(wxUint16 layer)
read this layer from the given layer in input files
Definition: layerinf.cpp:391
void UpdateIndexes()
all non defined layers until wxMAXLAYER will be added a new childs.
Definition: layerinf.cpp:695
void SetAll_Layers_Read(bool onoff)
set all layers read
Definition: layerinf.cpp:1008
bool LoadLayers(a2dDocumentInputStream &stream, a2dLayers *layers)
load a layer definition from a CVG file.
Definition: xmlpars.cpp:93
wxString m_description
what is this layer for.
Definition: layerinf.h:291
void SetAll_Layers_Visible(bool onoff)
set all layers visible
Definition: layerinf.cpp:994
bool m_indexed
to test if index array are valid
Definition: layerinf.h:496
bool LoadLayers(const wxString &filename)
save layers to a file
Definition: layerinf.cpp:576
void MakeUnique()
all with reference count &gt; 1 are cloned.
Definition: objlist.cpp:143
double GetAttributeValueDouble(const wxString &attrib, double defaultv=0)
Returns the double value of an attribute.
Definition: genxmlpars.cpp:474
wxUint16 GetAttributeValueUint16(const wxString &attrib, wxUint16 defaultv=0)
cast to wxUint16 of GetAttributeValueInt()
Definition: genxmlpars.h:462
while iterating a a2dCanvasDocument, this holds the context.
Definition: canobj.h:3212
a2dWalker based algorithms
set layers available in a2dCanvasView as found in document
Definition: algos.h:114
bool ReleaseChildObjects(a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL)
removes and release only from the childobjects the objects with the given mask
Definition: canobj.cpp:6296
void SetStroke(const wxColour &strokecolor, double width=0, a2dStrokeStyle style=a2dSTROKE_SOLID)
Set a stroke for the object which will be used instead of the layer stroke.
Definition: canobj.cpp:2924
void SetOutMapping(wxUint16 layer)
write this layer from the given layer to output files
Definition: layerinf.cpp:395
std::vector< a2dLayerInfoPtr > & GetReverseOrderIndex()
return array index on ReverseOrder
Definition: layerinf.cpp:569
wxString GetAttributeValue(const wxString &attrib, const wxString &defaultv=wxT(""))
Returns the value of an attribute.
Definition: genxmlpars.cpp:450
void OnPropertyChanged(a2dComEvent &event)
called via a2dPropertyId SetPropertyToObject() etc.
Definition: layerinf.cpp:263
void SetOrder(wxUint16 order)
set drawing order for layer
Definition: layerinf.cpp:371
wxUint16 m_order
drawing order number
Definition: layerinf.h:258
const a2dError a2dError_LoadLayers
bool DoIsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent)
Does hit test on the object (exclusif child objects)
Definition: layerinf.cpp:423
static a2dPinClass * Standard
Pins of this class can only connect to pins of the same class.
Definition: canpin.h:766
wxColour GetColour() const
return colour
Definition: stylebase.cpp:5012
double m_width
width of rectangle
Definition: layerinf.h:267
see a2dComEvent
Definition: gen.h:371
bool GetVisible() const
get visibility (rendering depends on layer settings also)
Definition: canobj.h:1309
bool GetSelectable() const
is the object selectable flag set
Definition: canobj.h:1648
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
Definition: bbox.h:39
std::vector< a2dLayerInfoPtr > & GetOrderIndex()
return array index on Order
Definition: layerinf.cpp:562
void SetFilling(bool OnOff)
Definition: stylebase.cpp:5060
the a2dDrawingPart is a a2dView specially designed for displaying parts of a a2dDrawing. It uses a a2dDrawer2D to actually redraw things from the document, by giving that a2dDrawer2D as drawing context to the document, and telling the document to redraw a certain rectangular area. At that last is what this class is for. It optimizes the areas to be redrawn after object in the document were changed. To do that it combines redraw areas to a minimal set of redrawing areas. All the administration for this and the way things will be redrawn is from this view.
Input handler for the CVG format.
Definition: xmlpars.h:59
void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
Definition: layerinf.cpp:418
int GetOrder() const
Definition: layerinf.cpp:351
This template class is for property ids with a known data type.
Definition: id.h:477
bool m_plated
Definition: layerinf.h:301
wxUint16 m_inmap
mapping to this layer from the file layer in the input file
Definition: layerinf.h:261
If a property with this id has changed its parent/holder will be notified.
Definition: id.h:213
void Append(a2dCanvasObject *obj)
append a a2dCanvasObject to the childobjects
Definition: canobj.cpp:6224
list of a2dObject&#39;s
Definition: gen.h:3157
double m_rely
(world coordinates) hit point y relative to the canvas object its parent object(s) ...
Definition: canobj.h:291
A pointer class, that automatically calls SmrtPtrOwn/SmrtPtrRelease.
Definition: a2dlist.h:20
void SetColour2(const wxColour &col)
set colour 2 used for gradient and wxSTIPPLE_MASK_OPAQUE filling.
Definition: stylebase.cpp:4949
CloneOptions
options for cloning
Definition: gen.h:1200
wxString m_type
type of layer (mask, holes etc.)
Definition: layerinf.h:282
a2dLayerInfo()
constructor
Definition: layerinf.cpp:147
basic 2 point line class for intersection and contouring routines.
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
void SetFill(const a2dFill &fill)
Set a fill for the object which will be used instead of the layer fill.
Definition: canobj.cpp:2874
general canvas module declarations and classes
bool GetRead()
does this layer need to be read in from a file.
Definition: layerinf.cpp:356
layerinf.cpp Source File -- Sun Oct 12 2014 17:04:21 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation