00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "a2dprec.h"
00012
00013 #ifdef __BORLANDC__
00014 #pragma hdrstop
00015 #endif
00016
00017 #ifndef WX_PRECOMP
00018 #include "wx/wx.h"
00019 #endif
00020
00021 #include <math.h>
00022 #include <limits.h>
00023 #include <float.h>
00024 #include "wx/canvas/canglob.h"
00025 #include "wx/canvas/layerinf.h"
00026 #include "wx/canvas/canobj.h"
00027 #include "wx/canvas/canprim.h"
00028 #include "wx/canvas/candoc.h"
00029 #include "wx/canvas/cancom.h"
00030 #include "wx/artbase/afmatrix.h"
00031 #include "wx/artbase/drawer2d.h"
00032
00033 #include <wx/wfstream.h>
00034
00035 #include "wx/canvas/canprop.h"
00036 #include "wx/canvas/wire.h"
00037
00038
00039
00040
00041
00042
00043 #define PINWIDTH 9
00044
00045 #define HANDLEWIDTH 7
00046
00047 IMPLEMENT_CLASS( a2dCanvasGlobal, a2dGlobal )
00048 IMPLEMENT_CLASS( a2dCanvasObjectEvent, wxEvent )
00049 IMPLEMENT_CLASS( a2dHandleMouseEvent, wxEvent )
00050 IMPLEMENT_CLASS( a2dCanvasObjectMouseEvent, wxEvent )
00051
00052 DEFINE_EVENT_TYPE( wxEVT_CANVASOBJECT_MOUSE_EVENT )
00053 DEFINE_EVENT_TYPE( wxEVT_CANVASOBJECT_ENTER_EVENT )
00054 DEFINE_EVENT_TYPE( wxEVT_CANVASOBJECT_LEAVE_EVENT )
00055 DEFINE_EVENT_TYPE( wxEVT_CANVASHANDLE_MOUSE_EVENT )
00056 DEFINE_EVENT_TYPE( wxEVT_CANVASOBJECT_RESIZE_EVENT )
00057 DEFINE_EVENT_TYPE( wxEVT_CANVASOBJECT_POPUPMENU_EVENT )
00058
00059
00060
00061
00062
00063 bool a2dLayerGroup::InGroup( wxUint16 layer )
00064 {
00065 bool hasLayer = false;
00066 forEachIn( a2dLayerGroup, this )
00067 {
00068 wxUint16 layerOfGroup = *iter;
00069
00070 if ( wxLAYER_ALL == layerOfGroup )
00071 {
00072 hasLayer = true;
00073 break;
00074 }
00075 if ( layer == layerOfGroup )
00076 hasLayer = true;
00077 }
00078 return hasLayer;
00079 }
00080
00081
00082
00083
00084
00085 a2dCanvasObjectEvent::a2dCanvasObjectEvent( a2dIterC* ic, wxEventType type, a2dCanvasObject* object, double x, double y, int id )
00086 : wxEvent( id, type )
00087 {
00088 SetEventObject( (wxObject*) object );
00089 m_x = x;
00090 m_y = y;
00091 m_ic = ic;
00092 }
00093
00094 a2dCanvasObjectEvent::a2dCanvasObjectEvent( a2dCanvasObject* object, const a2dBoundingBox& box, int id )
00095 : wxEvent( id, wxEVT_CANVASOBJECT_RESIZE_EVENT )
00096 {
00097 SetEventObject( (wxObject*) object );
00098 m_box = box;
00099 m_ic = NULL;
00100 }
00101
00102 a2dCanvasObjectEvent::a2dCanvasObjectEvent( const a2dCanvasObjectEvent& other )
00103 : wxEvent( other )
00104 {
00105 m_x = other.m_x;
00106 m_y = other.m_y;
00107 m_ic = other.m_ic;
00108 m_box = other.m_box;
00109 }
00110
00111
00112
00113
00114
00115 a2dCanvasObjectMouseEvent::a2dCanvasObjectMouseEvent( a2dIterC* ic, a2dCanvasObject* object, a2dHit& how, double x, double y, const wxMouseEvent& event )
00116 : a2dCanvasObjectEvent( ic, wxEVT_CANVASOBJECT_MOUSE_EVENT, object, x, y )
00117 {
00118 m_mouseevent = event;
00119 m_how = how;
00120 }
00121
00122 a2dCanvasObjectMouseEvent::a2dCanvasObjectMouseEvent( a2dIterC* ic, a2dCanvasObject* object, wxEventType type, double x, double y, const wxMouseEvent& event )
00123 : a2dCanvasObjectEvent( ic, type, object, x, y )
00124 {
00125 m_mouseevent = event;
00126 }
00127
00128
00129 a2dCanvasObjectMouseEvent::a2dCanvasObjectMouseEvent( const a2dCanvasObjectMouseEvent& other )
00130 : a2dCanvasObjectEvent( other )
00131 {
00132 m_mouseevent = other.m_mouseevent;
00133 m_how = other.m_how;
00134 }
00135
00136
00137
00138
00139
00140 a2dHandleMouseEvent::a2dHandleMouseEvent( a2dIterC* ic, a2dHandle* handle, double x, double y, const wxMouseEvent& event )
00141 : a2dCanvasObjectEvent( ic, wxEVT_CANVASHANDLE_MOUSE_EVENT, (a2dCanvasObject*) handle, x, y )
00142 {
00143 m_mouseevent = event;
00144 }
00145
00146 a2dHandleMouseEvent::a2dHandleMouseEvent( const a2dHandleMouseEvent& other )
00147 : a2dCanvasObjectEvent( other )
00148 {
00149 m_mouseevent = other.m_mouseevent;
00150 }
00151
00152
00153
00154
00155
00156 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_NONE = wxGenNewId();
00157 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_ARROW = wxGenNewId();
00158 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_RIGHT_ARROW = wxGenNewId();
00159 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_BULLSEYE = wxGenNewId();
00160 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_CHAR = wxGenNewId();
00161 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_CROSS = wxGenNewId();
00162 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_HAND = wxGenNewId();
00163 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_IBEAM = wxGenNewId();
00164 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_LEFT_BUTTON = wxGenNewId();
00165 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_MAGNIFIER = wxGenNewId();
00166 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_MIDDLE_BUTTON = wxGenNewId();
00167 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_NO_ENTRY = wxGenNewId();
00168 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_PAINT_BRUSH = wxGenNewId();
00169 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_PENCIL = wxGenNewId();
00170 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_POINT_LEFT = wxGenNewId();
00171 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_POINT_RIGHT = wxGenNewId();
00172 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_QUESTION_ARROW = wxGenNewId();
00173 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_RIGHT_BUTTON = wxGenNewId();
00174 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_SIZENESW = wxGenNewId();
00175 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_SIZENS = wxGenNewId();
00176 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_SIZENWSE = wxGenNewId();
00177 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_SIZEWE = wxGenNewId();
00178 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_SIZING = wxGenNewId();
00179 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_SPRAYCAN = wxGenNewId();
00180 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_WAIT = wxGenNewId();
00181 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_WATCH = wxGenNewId();
00182 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_BLANK = wxGenNewId();
00183 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_ARROWWAIT = wxGenNewId();
00184
00185 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_Select = wxGenNewId();
00186 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_Zoom = wxGenNewId();
00187 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_Drag = wxGenNewId();
00188 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_Move = wxGenNewId();
00189 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_Copy = wxGenNewId();
00190 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_DrawWire = wxGenNewId();
00191 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_EditWire = wxGenNewId();
00192 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_EditWireVertex = wxGenNewId();
00193 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_EditWireSegment = wxGenNewId();
00194 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_EditWireSegmentHorizontal = wxGenNewId();
00195 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_EditWireSegmentVertical = wxGenNewId();
00196 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_WireSegmentInsert = wxGenNewId();
00197 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_Edit = wxGenNewId();
00198 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_EditVertex = wxGenNewId();
00199 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_EditSegment = wxGenNewId();
00200 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_EditSegmentHorizontal = wxGenNewId();
00201 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_EditSegmentVertical = wxGenNewId();
00202 A2DCANVASDLLEXP extern const a2dCursorId a2dCURSOR_SegmentInsert = wxGenNewId();
00203
00204 A2DCANVASDLLEXP extern const a2dImageId a2dBitmap_EditRectangleFill = wxGenNewId();
00205
00206 a2dArtProvider::a2dArtProvider()
00207 {
00208 }
00209
00210 a2dArtProvider::~a2dArtProvider()
00211 {
00212 }
00213
00214 wxCursor LoadCursorFile( const wxString& filename )
00215 {
00216 wxImage im;
00217 if ( im.LoadFile( filename ))
00218 {
00219 im.LoadFile( filename );
00220 im.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X, 16);
00221 im.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y, 16);
00222 return wxCursor( im );
00223 }
00224 else
00225 {
00226 wxString error;
00227 error.Printf( _T("could not load cursor from file:"), filename.c_str() );
00228 wxMessageBox( error,_T("environment error"), wxOK);
00229 return wxCURSOR_ARROW;
00230 }
00231 }
00232
00233 wxCursor& a2dArtProvider::GetCursor( a2dCursorId id )
00234 {
00235 if ( m_cursorsLoaded.find(id) != m_cursorsLoaded.end() )
00236 return m_cursorsLoaded[id];
00237
00238 static wxCursor cursor;
00239
00240 if ( id == a2dCURSOR_NONE )
00241 cursor = wxCursor(wxCURSOR_NONE);
00242 if ( id == a2dCURSOR_ARROW )
00243 cursor = wxCursor(wxCURSOR_ARROW);
00244 if ( id == a2dCURSOR_RIGHT_ARROW )
00245 cursor = wxCursor(wxCURSOR_RIGHT_ARROW);
00246 if ( id == a2dCURSOR_BULLSEYE )
00247 cursor = wxCursor(wxCURSOR_BULLSEYE);
00248 if ( id == a2dCURSOR_CHAR )
00249 cursor = wxCursor(wxCURSOR_CHAR);
00250 if ( id == a2dCURSOR_CROSS )
00251 cursor = wxCursor(wxCURSOR_CROSS);
00252 if ( id == a2dCURSOR_HAND )
00253 cursor = wxCursor(wxCURSOR_HAND);
00254 if ( id == a2dCURSOR_IBEAM )
00255 cursor = wxCursor(wxCURSOR_IBEAM);
00256 if ( id == a2dCURSOR_LEFT_BUTTON )
00257 cursor = wxCursor(wxCURSOR_LEFT_BUTTON);
00258 if ( id == a2dCURSOR_MAGNIFIER )
00259 cursor = wxCursor(wxCURSOR_MAGNIFIER);
00260 if ( id == a2dCURSOR_MIDDLE_BUTTON )
00261 cursor = wxCursor(wxCURSOR_MIDDLE_BUTTON);
00262 if ( id == a2dCURSOR_NO_ENTRY )
00263 cursor = wxCursor(wxCURSOR_NO_ENTRY);
00264 if ( id == a2dCURSOR_PAINT_BRUSH )
00265 cursor = wxCursor(wxCURSOR_PAINT_BRUSH);
00266 if ( id == a2dCURSOR_PENCIL )
00267 cursor = wxCursor(wxCURSOR_PENCIL);
00268 if ( id == a2dCURSOR_POINT_LEFT )
00269 cursor = wxCursor(wxCURSOR_POINT_LEFT);
00270 if ( id == a2dCURSOR_POINT_RIGHT )
00271 cursor = wxCursor(wxCURSOR_POINT_RIGHT);
00272 if ( id == a2dCURSOR_QUESTION_ARROW )
00273 cursor = wxCursor(wxCURSOR_QUESTION_ARROW);
00274 if ( id == a2dCURSOR_RIGHT_BUTTON )
00275 cursor = wxCursor(wxCURSOR_RIGHT_BUTTON);
00276 if ( id == a2dCURSOR_SIZENESW )
00277 cursor = wxCursor(wxCURSOR_SIZENESW);
00278 if ( id == a2dCURSOR_SIZENS )
00279 cursor = wxCursor(wxCURSOR_SIZENS);
00280 if ( id == a2dCURSOR_SIZENWSE )
00281 cursor = wxCursor(wxCURSOR_SIZENWSE);
00282 if ( id == a2dCURSOR_SIZEWE )
00283 cursor = wxCursor(wxCURSOR_SIZEWE);
00284 if ( id == a2dCURSOR_SIZING )
00285 cursor = wxCursor(wxCURSOR_SIZING);
00286 if ( id == a2dCURSOR_SPRAYCAN )
00287 cursor = wxCursor(wxCURSOR_SPRAYCAN);
00288 if ( id == a2dCURSOR_WAIT )
00289 cursor = wxCursor(wxCURSOR_WAIT);
00290 if ( id == a2dCURSOR_WATCH )
00291 cursor = wxCursor(wxCURSOR_WATCH);
00292 if ( id == a2dCURSOR_BLANK )
00293 cursor = wxCursor(wxCURSOR_BLANK);
00294 if ( id == a2dCURSOR_ARROWWAIT )
00295 cursor = wxCursor(wxCURSOR_ARROWWAIT);
00296
00297 if ( id == a2dCURSOR_Select )
00298 cursor = wxCursor(wxCURSOR_CROSS);
00299 if ( id == a2dCURSOR_Zoom )
00300 cursor = wxCursor(wxCURSOR_MAGNIFIER);
00301 if ( id == a2dCURSOR_Drag )
00302 cursor = wxCursor(wxCURSOR_HAND);
00303 if ( id == a2dCURSOR_Move )
00304 cursor = wxCursor(wxCURSOR_HAND);
00305 if ( id == a2dCURSOR_Copy )
00306 cursor = wxCursor(wxCURSOR_HAND);
00307 if ( id == a2dCURSOR_DrawWire )
00308 cursor = wxCursor(wxCURSOR_PENCIL);
00309 if ( id == a2dCURSOR_EditWire )
00310 cursor = wxCursor(wxCURSOR_HAND);
00311 if ( id == a2dCURSOR_EditWireVertex )
00312 cursor = wxCursor(wxCURSOR_HAND);
00313 if ( id == a2dCURSOR_EditWireSegment )
00314 cursor = wxCursor(wxCURSOR_HAND);
00315 if ( id == a2dCURSOR_EditWireSegmentHorizontal )
00316 cursor = wxCursor(wxCURSOR_SIZENS);
00317 if ( id == a2dCURSOR_EditWireSegmentVertical )
00318 cursor = wxCursor(wxCURSOR_SIZEWE);
00319 if ( id == a2dCURSOR_WireSegmentInsert )
00320 cursor = wxCursor(wxCURSOR_SIZENESW);
00321 if ( id == a2dCURSOR_Edit )
00322 cursor = wxCursor(wxCURSOR_SIZEWE);
00323 if ( id == a2dCURSOR_EditVertex )
00324 cursor = wxCursor(wxCURSOR_HAND);
00325 if ( id == a2dCURSOR_EditSegment )
00326 cursor = wxCursor(wxCURSOR_SIZENS);
00327 if ( id == a2dCURSOR_EditSegmentHorizontal )
00328 cursor = wxCursor(wxCURSOR_HAND);
00329 if ( id == a2dCURSOR_EditSegmentVertical )
00330 cursor = wxCursor(wxCURSOR_HAND);
00331 if ( id == a2dCURSOR_SegmentInsert )
00332 cursor = wxCursor(wxCURSOR_HAND);
00333
00334 wxString artroot = a2dGeneralGlobals->GetWxArt2DArtVar();
00335 if ( artroot.IsEmpty() )
00336 return cursor;
00337 else
00338 artroot += wxT("cursors/");
00339
00340 if ( id == a2dCURSOR_Select )
00341 cursor = wxCursor(wxCURSOR_CROSS);
00342 if ( id == a2dCURSOR_Zoom )
00343 cursor = wxCursor(wxCURSOR_MAGNIFIER);
00344 if ( id == a2dCURSOR_Drag )
00345 cursor = LoadCursorFile( artroot + wxT("drag_cur.cur") );
00346 if ( id == a2dCURSOR_Move )
00347 cursor = LoadCursorFile( artroot + wxT("move_cur.cur") );
00348 if ( id == a2dCURSOR_Copy )
00349 cursor = LoadCursorFile( artroot + wxT("copy_cur.cur") );
00350 if ( id == a2dCURSOR_DrawWire )
00351 cursor = wxCursor(wxCURSOR_PENCIL);
00352 if ( id == a2dCURSOR_EditWire )
00353 cursor = wxCursor(wxCURSOR_HAND);
00354 if ( id == a2dCURSOR_EditWireVertex )
00355 cursor = wxCursor(wxCURSOR_HAND);
00356 if ( id == a2dCURSOR_EditWireSegment )
00357 cursor = wxCursor(wxCURSOR_HAND);
00358 if ( id == a2dCURSOR_EditWireSegmentHorizontal )
00359 cursor = wxCursor(wxCURSOR_SIZENS);
00360 if ( id == a2dCURSOR_EditWireSegmentVertical )
00361 cursor = wxCursor(wxCURSOR_SIZEWE);
00362 if ( id == a2dCURSOR_WireSegmentInsert )
00363 cursor = wxCursor(wxCURSOR_SIZENESW);
00364 if ( id == a2dCURSOR_Edit )
00365 cursor = LoadCursorFile( artroot + wxT("edit_cur.cur") );
00366 if ( id == a2dCURSOR_EditVertex )
00367 cursor = LoadCursorFile( artroot + wxT("edit_cur.cur") );
00368 if ( id == a2dCURSOR_EditSegment )
00369 cursor = wxCursor(wxCURSOR_SIZENS);
00370 if ( id == a2dCURSOR_EditSegmentHorizontal )
00371 cursor = wxCursor(wxCURSOR_HAND);
00372 if ( id == a2dCURSOR_EditSegmentVertical )
00373 cursor = wxCursor(wxCURSOR_HAND);
00374 if ( id == a2dCURSOR_SegmentInsert )
00375 cursor = wxCursor(wxCURSOR_HAND);
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415 m_cursorsLoaded[id] = cursor;
00416 return cursor;
00417 }
00418
00419 wxBitmap& a2dArtProvider::GetImage( a2dImageId id )
00420 {
00421 if ( m_imageLoaded.find(id) != m_imageLoaded.end() )
00422 return m_imageLoaded[id];
00423
00424 static wxBitmap bitmap;
00425
00426 if ( id == a2dBitmap_EditRectangleFill )
00427 {
00428 static const char *bits[] = {
00429 "8 8 3 1 0 0",
00430 " c #000000",
00431 "! c #FFFFFF",
00432 "# c #FFFFFF",
00433
00434 " # # # #",
00435 "# # # # ",
00436 " # # # #",
00437 "# # # # ",
00438 " # # # #",
00439 "# # # # ",
00440 " # # # #",
00441 "# # # # "
00442 };
00443
00444 bitmap = wxBitmap( bits);
00445 static char mask_bits[] = {
00446 0x13, 0x00, 0x15, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x80,
00447 0x00, 0x60 };
00448 wxBitmap mask_bitmap( mask_bits,8,8,1 );
00449 bitmap.SetMask( new wxMask( mask_bitmap ));
00450 }
00451
00452
00453 m_imageLoaded[id] = bitmap;
00454 return bitmap;
00455 }
00456
00457
00458
00459
00460
00461 const a2dPropertyIdPathList a2dCanvasGlobal::PROPID_layerPathList( wxT("layerPathList"), a2dPropertyId::flag_none, a2dPathList() );
00462
00463 a2dPathList a2dCanvasGlobal::m_layersPath = a2dPathList();
00464
00465 a2dCanvasGlobal::a2dCanvasGlobal()
00466
00467 {
00468 m_a2dDocviewGlobal = a2dDocviewGlobals;
00469
00470 m_layersPath.Add( wxT(".") );
00471 m_layersPath.Add( wxT("..") );
00472 m_layersPath.Add( wxT("./config") );
00473
00474 m_initialDocChildFramePos = wxPoint(20,20);
00475 m_initialDocChildFrameSize = wxSize(600,300);
00476 m_initialDocChildFrameStyle = wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE;
00477
00478
00479 m_initialWorldCanvasStyle = wxHSCROLL|wxVSCROLL;
00480
00481 m_default_acc = 1e-6;
00482
00483 m_propertytext = (a2dText*) NULL;
00484
00485 m_layersetup = new a2dLayers();
00486
00487 SetupReservedLayers();
00488
00489 a2dLayerInfo* n;
00490 n=new a2dLayerInfo(wxLAYER_DEFAULT, wxT("layer default"));
00491 m_layersetup->Append(n);
00492 n->SetStroke( a2dStroke(wxColour(0,255,255), 2,a2dSTROKE_SOLID));
00493 n->SetFill( a2dFill(wxColour(0,0,0),a2dFILL_SOLID));
00494
00495 for ( wxUint16 i = 1; i < 30; i++)
00496 {
00497 wxString buf;
00498 buf.Printf( wxT("layer %d"),i );
00499 a2dLayerInfo* n = new a2dLayerInfo(i,buf);
00500 m_layersetup->Append(n);
00501 n->SetOrder(i);
00502 n->SetInMapping(i);
00503 n->SetOutMapping(i);
00504 }
00505 m_layersetup->SetPending(true);
00506
00507 m_SelectStroke = a2dStroke(wxColour(255,255,0), 2, a2dSTROKE_SOLID );
00508 m_SelectFill = *a2dTRANSPARENT_FILL;
00509
00510 m_HighLightStroke = m_SelectStroke;
00511 m_HighLightFill = m_SelectFill;
00512
00513 m_SelectDrawStyle = RenderWIREFRAME_SELECT_INVERT;
00514
00515 m_hitmargin_device = 2;
00516 m_hitmargin_world = 2;
00517 m_copymindistance = 5;
00518 m_coordinateepsilon = 1e-8;
00519 m_reverse_order = false;
00520 m_oneLine = false;
00521 m_connectionGenerator = new a2dConnectionGenerator();
00522
00523 }
00524
00525 void a2dCanvasGlobal::SetupReservedLayers()
00526 {
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543 }
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598 a2dCanvasGlobal::~a2dCanvasGlobal()
00599 {
00600 }
00601
00602 void a2dCanvasGlobal::SetLayerSetup( a2dLayers* layersetup )
00603 {
00604 m_layersetup = layersetup;
00605
00606 SetupReservedLayers();
00607 };
00608
00609 bool a2dCanvasGlobal::LoadLayers( const wxString& filename )
00610 {
00611 wxString foundfile = filename;
00612
00613 if (m_layersetup)
00614 m_layersetup->ReleaseChildObjects();
00615 else
00616 {
00617 m_layersetup = new a2dLayers();
00618 }
00619 SetupReservedLayers();
00620
00621 foundfile = m_layersPath.FindValidPath( foundfile );
00622 if ( foundfile.IsEmpty() )
00623 {
00624 a2dDocviewGlobals->ReportErrorF( a2dError_NotSpecified, _("Path to layers settings file %s not found in path %s"), filename.c_str(), m_layersPath.GetAsString().c_str() );
00625 return false;
00626 }
00627
00628 return m_layersetup->LoadLayers( foundfile );
00629 }
00630
00631
00632 void a2dCanvasGlobal::SetPin( a2dPin* newpin )
00633 {
00634 m_defPin = newpin;
00635 }
00636
00637 a2dPin* a2dCanvasGlobal::GetPin()
00638 {
00639 if ( !m_defPin )
00640 {
00641 m_defPin = new a2dPin( NULL, wxT("global"), a2dPinClass::Standard, 0, 0, 0, PINWIDTH, PINWIDTH );
00642 m_defPin->SetFill( *wxGREEN );
00643 m_defPin->SetStroke( wxColour( 66, 159, 235 ), 0 );
00644 }
00645 return m_defPin;
00646 }
00647
00648 void a2dCanvasGlobal::SetPinCannotConnect( a2dPin* newpin )
00649 {
00650 m_defCannotConnectPin = newpin;
00651 }
00652
00653 a2dPin* a2dCanvasGlobal::GetPinCannotConnect()
00654 {
00655 if ( !m_defCannotConnectPin )
00656 {
00657 m_defCannotConnectPin = new a2dPin( NULL, wxT("global"), a2dPinClass::Standard, 0, 0, 0, PINWIDTH/2+1, PINWIDTH/2+1 );
00658 m_defCannotConnectPin->SetFill( wxColour( 255, 128, 128 ) );
00659 m_defCannotConnectPin->SetStroke( *wxRED, 0 );
00660 }
00661 return m_defCannotConnectPin;
00662 }
00663
00664 void a2dCanvasGlobal::SetPinCanConnect( a2dPin* newpin )
00665 {
00666 m_defCanConnectPin = newpin;
00667 }
00668
00669 a2dPin* a2dCanvasGlobal::GetPinCanConnect()
00670 {
00671 if ( !m_defCanConnectPin )
00672 {
00673 m_defCanConnectPin = new a2dPin( NULL, wxT("global"), a2dPinClass::Standard, 0, 0, 0, 2*PINWIDTH+1, 2*PINWIDTH+1 );
00674 m_defCanConnectPin->SetFill( wxColour( 128, 255, 128 ) );
00675 m_defCanConnectPin->SetStroke( *wxGREEN, 0 );
00676 }
00677 return m_defCanConnectPin;
00678 }
00679
00680 void a2dCanvasGlobal::SetHandle( a2dHandle* newhandle )
00681 {
00682 m_defHandle = newhandle;
00683 }
00684
00685 a2dHandle* a2dCanvasGlobal::GetHandle()
00686 {
00687
00688 if ( !m_defHandle )
00689 {
00690 m_defHandle = new a2dHandle( NULL, 0,0, wxT("global"), HANDLEWIDTH, HANDLEWIDTH );
00691 m_defHandle->SetFill( *wxCYAN );
00692 m_defHandle->SetStroke( wxColour( 66, 159, 235 ), 0 );
00693 }
00694 return m_defHandle;
00695 }
00696
00697 a2dText* a2dCanvasGlobal::GetPropertyText()
00698 {
00699 if ( !m_propertytext )
00700 {
00701 m_propertytext = new a2dText( wxT("dummy"), 0, 0, a2dFont( 80.0, wxSWISS ) );
00702 m_propertytext->SetFill( *wxCYAN );
00703 m_propertytext->SetStroke( wxColour( 66, 159, 235 ), 0.0 );
00704 }
00705 return m_propertytext;
00706 }
00707
00708
00709 void a2dCanvasGlobal::USERUNITS(double userunit)
00710 {
00711 m_userunits=userunit;
00712 }
00713
00714 void a2dCanvasGlobal::PHYSUNITS(double physicalunit)
00715 {
00716 m_physicalunits=physicalunit;
00717 }
00718
00719 double a2dCanvasGlobal::USERUNITS()
00720 {
00721 return m_userunits;
00722 }
00723
00724 double a2dCanvasGlobal::PHYSUNITS()
00725 {
00726 return m_physicalunits;
00727 }
00728
00729
00730 double a2dCanvasGlobal::ENTRYUNITS()
00731 {
00732 return m_default_acc;
00733 }
00734
00735 double a2dCanvasGlobal::ACCUR()
00736 {
00737 return m_default_acc/10000;
00738 }
00739
00740 double a2dCanvasGlobal::ARCTOPOLYABER()
00741 {
00742 return m_arc2polyaber/m_physicalunits;
00743 }
00744
00745 double a2dCanvasGlobal::POLYTOARCRMIN()
00746 {
00747 return m_poly2arcMin/m_physicalunits;
00748 }
00749
00750 double a2dCanvasGlobal::POLYTOARCRMAX()
00751 {
00752 return m_poly2arcMax/m_physicalunits;
00753 }
00754
00755 double a2dCanvasGlobal::POLYTOARCABER()
00756 {
00757 return m_poly2arcAber/m_physicalunits;
00758 }
00759
00760 a2dStroke& a2dCanvasGlobal::GetHighLightStroke()
00761 {
00762 return m_HighLightStroke;
00763 }
00764
00765 a2dFill& a2dCanvasGlobal::GetHighLightFill()
00766 {
00767 return m_HighLightFill;
00768 }
00769
00770 void a2dCanvasGlobal::SetHighLightStroke( const a2dStroke& stroke )
00771 {
00772 m_HighLightStroke = stroke;
00773 }
00774
00775 void a2dCanvasGlobal::SetHighLightFill( const a2dFill& fill )
00776 {
00777 m_HighLightFill = fill;
00778 }
00779
00780 a2dStroke& a2dCanvasGlobal::GetSelectStroke()
00781 {
00782 return m_SelectStroke;
00783 }
00784
00785 a2dFill& a2dCanvasGlobal::GetSelectFill()
00786 {
00787 return m_SelectFill;
00788 }
00789
00790 void a2dCanvasGlobal::SetSelectStroke( const a2dStroke& stroke )
00791 {
00792 m_SelectStroke = stroke;
00793 }
00794
00795 void a2dCanvasGlobal::SetSelectFill( const a2dFill& fill )
00796 {
00797 m_SelectFill = fill;
00798 }
00799
00800 a2dRestrictionEngine *a2dCanvasGlobal::GetRestrictionEngine()
00801 {
00802 return m_restrictionEngine;
00803 }
00804
00805
00806 a2dCanvasGlobal* a2dCanvasGlobals;
00807
00808
00809 IMPLEMENT_DYNAMIC_CLASS(a2dCanvasModule, wxModule)
00810
00811 a2dCanvasModule::a2dCanvasModule()
00812 {
00813 m_currentCmdProc = NULL;
00814 AddDependency( CLASSINFO(a2dFreetypeModule) );
00815 AddDependency( CLASSINFO(a2dDocviewModule) );
00816 AddDependency( CLASSINFO(a2dArtBaseModule) );
00817 AddDependency( CLASSINFO(a2dGeneralModule) );
00818 }
00819
00820 bool a2dCanvasModule::OnInit()
00821 {
00822 wxNullCanvasObjectList = new a2dCanvasObjectList();
00823 a2dCanvasGlobals = new a2dCanvasGlobal();
00824 wxNullLayerInfo = new a2dLayerInfo( 0, wxT("not defined") );
00825
00826 a2dCanvasGlobals->SetupReservedLayers();
00827
00828 a2dPinClass::InitializeStockPinClasses();
00829 a2dCanvasGlobals->GetConnectionGenerator()->SetAnyPinClass( a2dPinClass::Standard );
00830
00831
00832 m_prevCmdProc = a2dDocviewGlobals->GetDocviewCommandProcessor();
00833 m_currentCmdProc = new a2dCentralCanvasCommandProcessor(m_prevCmdProc);
00834 a2dDocviewGlobals->SetDocviewCommandProcessor( m_currentCmdProc );
00835
00836 return true;
00837 }
00838
00839 void a2dCanvasModule::OnExit()
00840 {
00841
00842
00843 a2dPinClass::DeleteStockPinClasses();
00844
00845
00846 a2dCentralCanvasCommandProcessor* aCurrentCmdProc = wxDynamicCast(a2dDocviewGlobals->GetDocviewCommandProcessor(),a2dCentralCanvasCommandProcessor);
00847 a2dDocviewGlobals->SetDocviewCommandProcessor( m_prevCmdProc );
00848 m_prevCmdProc = NULL;
00849 m_currentCmdProc = NULL;
00850
00851 delete wxNullCanvasObjectList;
00852
00853 delete a2dCanvasGlobals;
00854
00855
00856 a2dCanvasGlobals = NULL;
00857 }
00858
00859
00860