00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef __LAYERINF_H__
00015 #define __LAYERINF_H__
00016
00017 #ifndef WX_PRECOMP
00018 #include "wx/wx.h"
00019 #endif
00020
00021 #include "wx/txtstrm.h"
00022 #include "wx/geometry.h"
00023 #include "wx/artbase/afmatrix.h"
00024
00025 #include "wx/artbase/liner.h"
00026 #include "wx/artbase/bbox.h"
00027 #include "wx/canvas/canobj.h"
00028
00029
00030
00031
00032
00033 const double LAYERINFO_WIDTH = 100;
00034 const double LAYERINFO_HEIGHT = 100;
00035
00036
00037
00038
00039
00040
00041 class A2DCANVASDLLEXP a2dLayerInfo : public a2dCanvasObject
00042 {
00043 DECLARE_CLASS(a2dLayerInfo)
00044
00045 public:
00046
00047 a2dLayerInfo();
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 a2dLayerInfo( wxUint16 index, wxString name );
00061
00062
00063 a2dLayerInfo( const a2dLayerInfo& other, CloneOptions options = clone_deep );
00064
00065 ~a2dLayerInfo();
00066
00067
00068 virtual wxString GetName() const;
00069
00070
00071
00072
00073
00074
00075 virtual void SetName(const wxString& name);
00076
00077 virtual a2dObject *Clone( CloneOptions options ) const;
00078
00079
00080 bool GetVisible();
00081
00082
00083 bool GetSelectable();
00084
00085
00086
00087
00088 int GetOrder() const;
00089
00090
00091 bool GetRead();
00092
00093
00094 int GetInMapping();
00095
00096
00097 int GetOutMapping();
00098
00099
00100 bool GetPixelStroke();
00101
00102
00103 bool GetAvailable() { return m_layeravailable; }
00104
00105
00106 void SetAvailable( bool status ) { m_layeravailable = status; }
00107
00108
00109 a2dPinClass *GetPinClass() const { return m_pinclass; }
00110
00111
00112 void SetPinClass( a2dPinClass* pinClass ) { m_pinclass = pinClass; }
00113
00114
00115 void SetVisible( bool status );
00116
00117 void SetSelectable( bool status );
00118
00119 void SetOrder( wxUint16 order );
00120
00121 void SetRead( bool status );
00122
00123 void SetInMapping( wxUint16 layer );
00124
00125 void SetOutMapping( wxUint16 layer );
00126
00127
00128 void SetPixelStroke( bool pixel);
00129
00130
00131 const wxString& GetFeature() const { return m_feature; }
00132
00133
00134 void SetFeature( const wxString& feature ) { m_feature = feature; }
00135
00136
00137 const wxString& GetSubFeature() const { return m_subFeature; }
00138
00139
00140 void SetSubFeature( const wxString& subfeature ) { m_subFeature = subfeature; }
00141
00142
00143 const wxString& GetType() const { return m_type; }
00144
00145
00146 void SetType( const wxString& type ) { m_type = type; }
00147
00148
00149 const wxString& GetSide() const { return m_side; }
00150
00151
00152 void SetSide( const wxString& side ) { m_side = side; }
00153
00154
00155
00156
00157
00158 const wxString& GetSpan() const { return m_span; }
00159
00160
00161 void SetSpan( const wxString& span ) { m_span = span; }
00162
00163
00164 wxString& GetDescription() { return m_description; }
00165
00166 void SetDescription( const wxString& description ) { m_description = description; }
00167
00168
00169 double GetArea() { return m_area; }
00170
00171
00172 void SetArea( double area ) { m_area = area; }
00173
00174 bool GetPolarity() { return m_polarity; }
00175
00176 void SetPolarity( bool polarity ) { m_polarity = polarity; }
00177
00178
00179
00180 bool GetPlated() { return m_plated; }
00181
00182
00183
00184 void SetPlated( bool plated ) { m_plated = plated; }
00185
00186
00187 void OnPropertyChanged( const a2dPropertyId* id );
00188
00189 protected:
00190
00191 friend class a2dLayers;
00192
00193 #if wxART2D_USE_CVGIO
00194 void DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite );
00195
00196 void DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts );
00197 #endif //wxART2D_USE_CVGIO
00198
00199
00200
00201 void DoRender( a2dIterC& ic, OVERLAP clipparent );
00202
00203 bool DoIsHitWorld( a2dIterC& ic, a2dHitEvent& hitEvent );
00204
00205 a2dBoundingBox DoGetUnTransformedBbox( a2dBboxFlags flags = a2dCANOBJ_BBOX_NON ) const;
00206
00207
00208 bool m_layerselectable;
00209
00210
00211 bool m_layervisible;
00212
00213
00214 bool m_readlayer;
00215
00216
00217
00218 bool m_layeravailable;
00219
00220
00221 wxUint16 m_order;
00222
00223
00224 wxUint16 m_inmap;
00225
00226
00227 wxUint16 m_outmap;
00228
00229
00230 double m_width;
00231
00232
00233 double m_height;
00234
00235
00236 wxString m_layername;
00237
00238
00239 wxString m_feature;
00240
00241
00242 wxString m_subFeature;
00243
00244
00245 wxString m_type;
00246
00247
00248 wxString m_side;
00249
00250
00251 wxString m_span;
00252
00253
00254 wxString m_description;
00255
00256
00257 double m_area;
00258
00259
00260 bool m_polarity;
00261
00262
00263
00264 bool m_plated;
00265
00266
00267
00268
00269
00270 a2dPinClass* m_pinclass;
00271
00272 public:
00273
00274
00275 static a2dPropertyIdString* PROPID_layerName;
00276 static a2dPropertyIdBool* PROPID_layerSelectable;
00277 static a2dPropertyIdBool* PROPID_layerVisible;
00278 static a2dPropertyIdBool* PROPID_readlayer;
00279 static a2dPropertyIdUint16* PROPID_order;
00280 static a2dPropertyIdUint16* PROPID_inmap;
00281 static a2dPropertyIdUint16* PROPID_outmap;
00282
00283 DECLARE_PROPERTIES()
00284
00285 public:
00286
00287
00288 static const wxEventType sm_changedLayer;
00289
00290 private:
00291
00292
00293 };
00294
00295 #if defined(WXART2D_USINGDLL)
00296 template class A2DCANVASDLLEXP std::allocator< a2dSmrtPtr<a2dLayerInfo> >;
00297 template class A2DCANVASDLLEXP std::vector< a2dSmrtPtr<a2dLayerInfo> >;
00298 #endif
00299
00300 A2DCANVASDLLEXP_DATA(extern a2dSmrtPtr<a2dLayerInfo>) wxNullLayerInfo;
00301
00302 typedef a2dSmrtPtr<a2dLayerInfo> a2dLayerInfoPtr;
00303 typedef std::vector<a2dLayerInfoPtr> a2dLayerIndex;
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318 class A2DCANVASDLLEXP a2dLayers : public a2dCanvasObject
00319 {
00320 DECLARE_CLASS(a2dLayers)
00321
00322 public:
00323
00324 enum Index
00325 {
00326
00327 OnLayer,
00328
00329 OnOrder,
00330
00331 OnReverseOrder
00332 };
00333
00334 a2dLayers();
00335
00336 a2dLayers( const a2dLayers& other, CloneOptions options );
00337
00338 ~a2dLayers();
00339
00340
00341
00342
00343
00344 void SetFileName( const wxFileName& filename ) { m_filename = filename; }
00345
00346
00347 wxFileName& GetFileName() { return m_filename; }
00348
00349
00350 virtual a2dObject* Clone( CloneOptions options ) const;
00351
00352
00353 void SetPending(bool pending);
00354
00355
00356 a2dLayerInfo* operator[] (int indx)
00357 {
00358 assert(indx>=0 && indx<wxMAXLAYER); return m_layerArrayOnLayer[indx];
00359 }
00360
00361 const a2dLayerInfo* operator[] (int indx) const
00362 {
00363 assert(indx>=0 && indx<wxMAXLAYER); return m_layerArrayOnLayer[indx];
00364 }
00365
00366 a2dLayerInfo* GetLayerInfo( int index )
00367 {
00368 assert(index>=0 && index<wxMAXLAYER); return m_layerArrayOnLayer[index];
00369 }
00370
00371
00372 std::vector<a2dLayerInfoPtr>& GetLayerIndex();
00373
00374 std::vector<a2dLayerInfoPtr>& GetOrderIndex();
00375
00376 std::vector<a2dLayerInfoPtr>& GetReverseOrderIndex();
00377
00378
00379 bool LoadLayers( const wxString& filename );
00380
00381
00382 bool SaveLayers( const wxString& filename );
00383
00384 void InitWith( int highlayer, bool blackWhite );
00385
00386 wxString GetName( int layernumber );
00387 int GetNumber( wxString name );
00388 a2dStroke GetStroke( int layernumber );
00389 bool GetVisible( int layernumber );
00390 bool GetSelectable( int layernumber );
00391 a2dFill GetFill( int layernumber );
00392 int GetOrder( int layernumber );
00393 bool GetRead( int layernumber );
00394 int GetInMapping( int layernumber );
00395 int GetOutMapping( int layernumber );
00396
00397 bool GetPixelStroke( int layernumber );
00398
00399 void SetName( int layernumber, wxString name );
00400 void SetStroke( int layernumber, const a2dStroke& stroke );
00401 void SetVisible( int layernumber, bool = true );
00402 void SetAvailable( int layernumber, bool = true );
00403 void SetSelectable( int layernumber, bool = true );
00404 void SetFill( int layernumber, const a2dFill& fill );
00405 void SetOrder( int layernumber, int status );
00406 void SetRead( int layernumber, bool = true );
00407 void SetInMapping( int layernumber, wxUint16 layer );
00408 void SetOutMapping( int layernumber, wxUint16 layer );
00409
00410
00411 void SetPattern( int layernumber, const wxBitmap& stipple );
00412
00413 void SetPixelStroke( int layernumber, bool = true );
00414
00415
00416 void SetAll_Layers_Visible( bool onoff );
00417
00418
00419 void SetAll_Layers_Read( bool onoff );
00420
00421
00422 void SetAll_Layers_Selectable( bool onoff );
00423
00424
00425 void SetAll_Layers_Outline( bool onoff );
00426
00427 void SetAllLayersAvailable( bool onoff );
00428
00429
00430 void SetAvailable( a2dCanvasDocument* doc );
00431
00432
00433 void SetAvailable( a2dLayers* other );
00434
00435
00436
00437
00438
00439
00440
00441
00442 void UpdateIndexes();
00443
00444 protected:
00445
00446 #if wxART2D_USE_CVGIO
00447 void DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts );
00448
00449 void DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite );
00450 #endif //wxART2D_USE_CVGIO
00451
00452 bool DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox );
00453
00454 a2dLayerIndex m_layerArrayOnOrder;
00455 a2dLayerIndex m_layerArrayOnReverseOrder;
00456 a2dLayerIndex m_layerArrayOnLayer;
00457
00458
00459 bool m_indexed;
00460
00461 public:
00462 static a2dPropertyIdBool* PROPID_visibleAll;
00463 static a2dPropertyIdBool* PROPID_readAll;
00464 static a2dPropertyIdBool* PROPID_selectableAll;
00465
00466 DECLARE_PROPERTIES()
00467
00468 private:
00469
00470 wxFileName m_filename;
00471
00472
00473 a2dLayers( const a2dLayers &other );
00474 };
00475
00476 extern bool LayerSorter(const a2dCanvasObjectPtr& x, const a2dCanvasObjectPtr& y);
00477
00478 extern bool OrderSorter(const a2dCanvasObjectPtr& x, const a2dCanvasObjectPtr& y);
00479
00480
00481 extern bool ReverseOrderSorter(const a2dCanvasObjectPtr& x, const a2dCanvasObjectPtr& y);
00482
00483
00484 #if defined(WXART2D_USINGDLL)
00485 template class A2DCANVASDLLEXP a2dSmrtPtr<a2dLayers>;
00486 #endif
00487
00488 #endif
00489