wxArt2D
cancom.cpp
1 /*! \file canvas/src/cancom.cpp
2  \brief see wx/canvas/cancom.h
3 
4  \author Klaas Holwerda
5 
6  Copyright: 2001-2004 (c) Klaas Holwerda
7 
8  Licence: wxWidgets Licence
9 
10  RCS-ID: $Id: cancom.cpp,v 1.236 2009/10/01 19:22:35 titato Exp $
11 */
12 
13 #include "a2dprec.h"
14 
15 #ifdef __BORLANDC__
16 #pragma hdrstop
17 #endif
18 
19 #ifndef WX_PRECOMP
20 #include "wx/wx.h"
21 #endif
22 
23 #if defined(__WXMSW__) && defined(__MEMDEBUG__)
24 #include <wx/msw/msvcrt.h>
25 #endif
26 
27 #include <float.h>
28 
29 #include "wx/canvas/drawer.h"
30 #include "wx/canvas/polygon.h"
31 #include "wx/canvas/canglob.h"
32 #include "wx/canvas/algos.h"
33 #include "wx/canvas/canorderdlg.h"
34 #include "wx/editor/cancom.h"
35 #include "wx/editor/edsttool.h"
36 #include "wx/editor/editmod.h"
37 
38 #include <wx/numdlg.h>
39 
40 
41 //----------------------------------------------------------------------------
42 // globals
43 //----------------------------------------------------------------------------
44 
45 //! used application broad to get the central command processor, when using Canvas module
46 //! Essential this a2dDocviewGlobals->GetDocviewCommandProcessor()
48 {
50 }
51 
52 //! get drawing context of current a2dCanvasView
53 a2dDrawer2D* a2dGetDrawer2D()
54 {
56  if ( !drawer )
57  return NULL;
58  return drawer->GetDrawer2D();
59 }
60 
61 IMPLEMENT_DYNAMIC_CLASS( a2dCommand_GdsIoSaveTextAsPolygon, a2dCommand )
62 IMPLEMENT_DYNAMIC_CLASS( a2dCommand_KeyIoSaveTextAsPolygon, a2dCommand )
63 IMPLEMENT_DYNAMIC_CLASS( a2dCommand_ViewAsImage, a2dCommand )
64 IMPLEMENT_DYNAMIC_CLASS( a2dCommand_ViewAsSvg, a2dCommand )
65 IMPLEMENT_DYNAMIC_CLASS( a2dCommand_GdsIoSaveFromView, a2dCommand )
66 IMPLEMENT_DYNAMIC_CLASS( a2dCommand_KeyIoSaveFromView, a2dCommand )
67 
68 //!@{ \ingroup commandid
69 
70 const a2dCommandId a2dCommand_GdsIoSaveTextAsPolygon::Id( wxT( "GdsIoSaveTextAsPolygon" ) );
71 const a2dCommandId a2dCommand_KeyIoSaveTextAsPolygon::Id( wxT( "KeyIoSaveTextAsPolygon" ) );
72 
73 const a2dCommandId a2dCommand_ViewAsImage::Id( wxT( "ViewAsImage" ) );
74 const a2dCommandId a2dCommand_ViewAsSvg::Id( wxT( "ViewAsSvg" ) );
75 
76 const a2dCommandId a2dCommand_GdsIoSaveFromView::Id( wxT( "GdsIoSaveFromView" ) );
77 const a2dCommandId a2dCommand_KeyIoSaveFromView::Id( wxT( "KeyIoSaveFromView" ) );
78 
79 const a2dCommandId a2dCommand_ShowDlg::Id( wxT( "ShowDlg" ) );
80 
81 //!@}
82 
83 
84 
85 //!@{ \ingroup menus
86 //----------------------------------------------------------------------------
87 // globals a2dMenuIdItem's
88 //----------------------------------------------------------------------------
89 
90 DEFINE_MENU_ITEMID_KIND( CmdMenu_GdsIoSaveTextAsPolygon, wxTRANSLATE("Gdsii Save text as Polgyon"), wxTRANSLATE("When possible/implemented, save text as polygon in GdsII format") , wxITEM_CHECK )
91 DEFINE_MENU_ITEMID_KIND( CmdMenu_KeyIoSaveTextAsPolygon, wxTRANSLATE("Key Save text as Polgyon"), wxTRANSLATE("When possible/implemented, save text as polygon in KEY format") , wxITEM_CHECK )
92 DEFINE_MENU_ITEMID_KIND( CmdMenu_SetGdsIoSaveFromView, wxTRANSLATE("Gdsii Save from View down"), wxTRANSLATE("Structure visible and all down will be saved") , wxITEM_CHECK )
93 DEFINE_MENU_ITEMID_KIND( CmdMenu_SetKeyIoSaveFromView, wxTRANSLATE("Key Save from View down"), wxTRANSLATE("Structure visible and all down will be saved") , wxITEM_CHECK )
94 
95 DEFINE_MENU_ITEMID( CmdMenu_SaveLayers, wxTRANSLATE("SaveLayers"), wxTRANSLATE("Save layers to a layer file") )
96 DEFINE_MENU_ITEMID( CmdMenu_SaveLayersHome, wxTRANSLATE("SaveLayers Home"), wxTRANSLATE("Save layers to a layer file") )
97 DEFINE_MENU_ITEMID( CmdMenu_SaveLayersLastDir, wxTRANSLATE("SaveLayers LastDir"), wxTRANSLATE("Save layers to a layer file") )
98 DEFINE_MENU_ITEMID( CmdMenu_SaveLayersCurrentDir, wxTRANSLATE("SaveLayers Current Dir"), wxTRANSLATE("Save layers to a layer file") )
99 
100 DEFINE_MENU_ITEMID( CmdMenu_LoadLayers, wxTRANSLATE("LoadLayers"), wxTRANSLATE("Load layers to a layer file") )
101 DEFINE_MENU_ITEMID( CmdMenu_LoadLayersHome, wxTRANSLATE("LoadLayers Home"), wxTRANSLATE("Load layers to a layer file") )
102 DEFINE_MENU_ITEMID( CmdMenu_LoadLayersLastDir, wxTRANSLATE("LoadLayers LastDir"), wxTRANSLATE("Load layers to a layer file") )
103 DEFINE_MENU_ITEMID( CmdMenu_LoadLayersCurrentDir, wxTRANSLATE("LoadLayers Current Dir"), wxTRANSLATE("Load layers to a layer file") )
104 
105 DEFINE_MENU_ITEMID_KIND( CmdMenu_GdsIoSaveFromView, wxTRANSLATE("Gdsii Save from View down"), wxTRANSLATE("Structure visible and all down will be saved") , wxITEM_CHECK )
106 DEFINE_MENU_ITEMID_KIND( CmdMenu_KeyIoSaveFromView, wxTRANSLATE("Key Save from View down"), wxTRANSLATE("Structure visible and all down will be saved") , wxITEM_CHECK )
107 DEFINE_MENU_ITEMID( CmdMenu_SetLayersProperty, wxTRANSLATE("Set layer property"), wxTRANSLATE("Set property like colour on a layer") )
108 
109 DEFINE_MENU_ITEMID_KIND( CmdMenu_ShowDlgLayers, wxTRANSLATE("&Init Layers Document"), wxTRANSLATE("layer dialog initialized for editing layers document") , wxITEM_CHECK )
110 DEFINE_MENU_ITEMID_KIND( CmdMenu_ShowDlgLayersDocument, wxTRANSLATE("&Init Layers Document"), wxTRANSLATE("layer dialog initialized for editing layers document") , wxITEM_CHECK )
111 DEFINE_MENU_ITEMID_KIND( CmdMenu_ShowDlgLayerOrderDocument, wxTRANSLATE("&Order Layers Document"), wxTRANSLATE("order layer dialog initialized for layers document") , wxITEM_CHECK )
112 
113 DEFINE_MENU_ITEMID_KIND( CmdMenu_ShowDlgStructureDocument, wxTRANSLATE("&Structure Dialog"), wxTRANSLATE("shows structure dialog") , wxITEM_CHECK )
114 DEFINE_MENU_ITEMID_KIND( CmdMenu_ShowDlgStructureDocumentModal, wxTRANSLATE("&Structure Dialog"), wxTRANSLATE("shows structure dialog modal") , wxITEM_CHECK )
115 
116 DEFINE_MENU_ITEMID( CmdMenu_ViewAsImage, wxTRANSLATE("n"), wxTRANSLATE("n") )
117 DEFINE_MENU_ITEMID( CmdMenu_ViewAsImage_Png, wxTRANSLATE("PNG bitmap"), wxTRANSLATE("Save as PNG bitmap file") )
118 DEFINE_MENU_ITEMID( CmdMenu_ViewAsImage_Bmp, wxTRANSLATE("BMP bitmap"), wxTRANSLATE("Save as BMP bitmap file") )
119 DEFINE_MENU_ITEMID( CmdMenu_DocumentAsImage_Png, wxTRANSLATE("Document PNG bitmap"), wxTRANSLATE("Save as PNG bitmap file") )
120 DEFINE_MENU_ITEMID( CmdMenu_DocumentAsImage_Bmp, wxTRANSLATE("Document BMP bitmap"), wxTRANSLATE("Save as BMP bitmap file") )
121 DEFINE_MENU_ITEMID( CmdMenu_DocumentAsOdbXml, wxTRANSLATE("Document As OdbXml"), wxTRANSLATE("Save Document As Odb Xml") )
122 DEFINE_MENU_ITEMID( CmdMenu_ViewAsSvg, wxTRANSLATE("SVG file"), wxTRANSLATE("Save view as SVG file") )
123 
124 DEFINE_MENU_ITEMID( CmdMenu_PushTool_Link, wxTRANSLATE("Insert Link"), wxTRANSLATE("insert a2dText in dragged rectangle having a link to a file") )
125 DEFINE_MENU_ITEMID( CmdMenu_PushTool_Link_OneShot, wxTRANSLATE("Insert Link"), wxTRANSLATE("insert a2dText in dragged rectangle having a link to a file") )
126 DEFINE_MENU_ITEMID( CmdMenu_PushTool_FollowLinkDocDrawCam, wxTRANSLATE("Follow Link"), wxTRANSLATE("follow link to a file or drawing or a2dCameleon") )
127 DEFINE_MENU_ITEMID_KIND( CmdMenu_PushTool_Master3Link, wxTRANSLATE("Edit Master tool and link"), wxTRANSLATE("Edit Master tool and link"), wxITEM_CHECK )
128 
129 
130 //!@}
131 
132 
133 /*
134 * a2dCentralCanvasCommandProcessor
135 */
136 
137 /*
138 a2dPropertyIdBool* a2dCentralCanvasCommandProcessor::PROPID_PopBeforePush = NULL;
139 a2dPropertyIdBool* a2dCentralCanvasCommandProcessor::PROPID_OneShotTools = NULL;
140 a2dPropertyIdBool* a2dCentralCanvasCommandProcessor::PROPID_EditAtEndTools = NULL;
141 a2dPropertyIdBool* a2dCentralCanvasCommandProcessor::PROPID_Spline = NULL;
142 a2dPropertyIdUint16* a2dCentralCanvasCommandProcessor::PROPID_Layer = NULL;
143 a2dPropertyIdFill* a2dCentralCanvasCommandProcessor::PROPID_Fill = NULL;
144 a2dPropertyIdStroke* a2dCentralCanvasCommandProcessor::PROPID_Stroke = NULL;
145 a2dPropertyIdFont* a2dCentralCanvasCommandProcessor::PROPID_Font = NULL;
146 a2dPropertyIdCanvasObject* a2dCentralCanvasCommandProcessor::PROPID_Begin = NULL;
147 a2dPropertyIdCanvasObject* a2dCentralCanvasCommandProcessor::PROPID_End = NULL;
148 a2dPropertyIdDouble* a2dCentralCanvasCommandProcessor::PROPID_EndScaleX = NULL;
149 a2dPropertyIdDouble* a2dCentralCanvasCommandProcessor::PROPID_EndScaleY = NULL;
150 a2dPropertyIdBool* a2dCentralCanvasCommandProcessor::PROPID_Snap = NULL;
151 */
152 
154 {
155 /*
156  PROPID_Fill = new a2dPropertyIdFill( wxT( "Fill" ),
157  a2dPropertyId::flag_transfer | a2dPropertyId::flag_listfirst | a2dPropertyId::flag_clonedeep,
158  *a2dNullFILL,
159  static_cast < a2dPropertyIdFill::ConstGet >( &a2dCentralCanvasCommandProcessor::MX_GetFill ),
160  static_cast < a2dPropertyIdFill::ConstSet >( &a2dCentralCanvasCommandProcessor::MX_SetFill ) );
161  AddPropertyId( PROPID_Fill );
162 
163  PROPID_Stroke = new a2dPropertyIdStroke( wxT( "Stroke" ),
164  a2dPropertyId::flag_transfer | a2dPropertyId::flag_listfirst | a2dPropertyId::flag_clonedeep,
165  *a2dNullSTROKE,
166  static_cast < a2dPropertyIdStroke::ConstGet >( &a2dCentralCanvasCommandProcessor::MX_GetStroke ),
167  static_cast < a2dPropertyIdStroke::ConstSet >( &a2dCentralCanvasCommandProcessor::MX_SetStroke ) );
168  AddPropertyId( PROPID_Stroke );
169 
170  PROPID_Font = new a2dPropertyIdFont( wxT( "Font" ),
171  a2dPropertyId::flag_transfer | a2dPropertyId::flag_clonedeep,
172  *a2dNullFONT,
173  static_cast < a2dPropertyIdFont::ConstGet >( &a2dCentralCanvasCommandProcessor::MX_GetFont ),
174  static_cast < a2dPropertyIdFont::ConstSet >( &a2dCentralCanvasCommandProcessor::MX_SetFont ) );
175  AddPropertyId( PROPID_Font );
176 
177  A2D_PROPID_M( a2dPropertyIdCanvasObject, a2dCentralCanvasCommandProcessor, Begin, 0, m_currentBegin );
178  A2D_PROPID_M( a2dPropertyIdCanvasObject, a2dCentralCanvasCommandProcessor, End, 0, m_currentEnd );
179  A2D_PROPID_M( a2dPropertyIdDouble, a2dCentralCanvasCommandProcessor, EndScaleX, 0, m_currentXscale );
180  A2D_PROPID_M( a2dPropertyIdDouble, a2dCentralCanvasCommandProcessor, EndScaleY, 0, m_currentYscale );
181  A2D_PROPID_M( a2dPropertyIdBool, a2dCentralCanvasCommandProcessor, PopBeforePush, false, m_popBeforePush );
182  A2D_PROPID_M( a2dPropertyIdBool, a2dCentralCanvasCommandProcessor, OneShotTools, false, m_oneShotTools );
183  A2D_PROPID_M( a2dPropertyIdBool, a2dCentralCanvasCommandProcessor, EditAtEndTools, false, m_editAtEndTools );
184  A2D_PROPID_M( a2dPropertyIdBool, a2dCentralCanvasCommandProcessor, Spline, false, m_spline );
185  A2D_PROPID_D( a2dPropertyIdBool, Snap, false );
186  A2D_PROPID_M( a2dPropertyIdUint16, a2dCentralCanvasCommandProcessor, Layer, false, m_layer );
187 */
188  return true;
189 }
190 
192 
194  EVT_BEGINBUSY( a2dCentralCanvasCommandProcessor::OnBusyBegin )
195  EVT_ENDBUSY( a2dCentralCanvasCommandProcessor::OnBusyEnd )
196  EVT_CHANGED_DOCUMENT( a2dCentralCanvasCommandProcessor::OnChangedDocument )
197 
198  EVT_MENU( CmdMenu_ChangeCentralStyle().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
199 
200  EVT_MENU( CmdMenu_GdsIoSaveTextAsPolygon().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
201  EVT_MENU( CmdMenu_KeyIoSaveTextAsPolygon().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
202  EVT_MENU( CmdMenu_SetGdsIoSaveFromView().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
203  EVT_MENU( CmdMenu_SetKeyIoSaveFromView().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
204 
205  EVT_MENU( CmdMenu_SaveLayers().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
206  EVT_MENU( CmdMenu_SaveLayersHome().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
207  EVT_MENU( CmdMenu_SaveLayersLastDir().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
208  EVT_MENU( CmdMenu_SaveLayersCurrentDir().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
209  EVT_MENU( CmdMenu_LoadLayers().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
210  EVT_MENU( CmdMenu_LoadLayersHome().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
211  EVT_MENU( CmdMenu_LoadLayersLastDir().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
212  EVT_MENU( CmdMenu_LoadLayersCurrentDir().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
213 
214  EVT_MENU( CmdMenu_GdsIoSaveFromView().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
215  EVT_MENU( CmdMenu_KeyIoSaveFromView().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
216  EVT_MENU( CmdMenu_SetLayersProperty().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
217 
218  EVT_UPDATE_UI( CmdMenu_GdsIoSaveTextAsPolygon().GetId(), a2dCentralCanvasCommandProcessor::OnUpdateMenu )
219  EVT_UPDATE_UI( CmdMenu_KeyIoSaveTextAsPolygon().GetId(), a2dCentralCanvasCommandProcessor::OnUpdateMenu )
220  EVT_UPDATE_UI( CmdMenu_SetGdsIoSaveFromView().GetId(), a2dCentralCanvasCommandProcessor::OnUpdateMenu )
221  EVT_UPDATE_UI( CmdMenu_SetKeyIoSaveFromView().GetId(), a2dCentralCanvasCommandProcessor::OnUpdateMenu )
222 
223  EVT_UPDATE_UI( wxID_UNDO, a2dCentralCanvasCommandProcessor::OnUpdateUndo )
224  EVT_UPDATE_UI( wxID_REDO, a2dCentralCanvasCommandProcessor::OnUpdateRedo )
225 
226  EVT_MENU( CmdMenu_PushTool_RenderImageZoom().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
227 
228  EVT_MENU( CmdMenu_ShowDlgLayers().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
229  EVT_MENU( CmdMenu_ShowDlgLayersDocument().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
230  EVT_MENU( CmdMenu_ShowDlgLayersGlobal().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
231  EVT_MENU( CmdMenu_ShowDlgLayerOrderDocument().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
232  EVT_MENU( CmdMenu_ShowDlgLayerOrderGlobal().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
233  //EVT_MENU( CmdMenu_ShowDlgPropEdit().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
234 
235  EVT_MENU( CmdMenu_ShowDlgStructureDocument().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
236  EVT_MENU( CmdMenu_ShowDlgStructureDocumentModal().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
237  EVT_UPDATE_UI( CmdMenu_ShowDlgStructureDocument().GetId(), a2dCentralCanvasCommandProcessor::OnUpdateMenu )
238  EVT_UPDATE_UI( CmdMenu_ShowDlgStructureDocumentModal().GetId(), a2dCentralCanvasCommandProcessor::OnUpdateMenu )
239 
240  EVT_MENU( CmdMenu_SetFont().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
241 
242  EVT_UPDATE_UI( CmdMenu_ShowDlgLayers().GetId(), a2dCentralCanvasCommandProcessor::OnUpdateMenu )
243  EVT_UPDATE_UI( CmdMenu_ShowDlgLayersDocument().GetId(), a2dCentralCanvasCommandProcessor::OnUpdateMenu )
244  EVT_UPDATE_UI( CmdMenu_ShowDlgLayersGlobal().GetId(), a2dCentralCanvasCommandProcessor::OnUpdateMenu )
245  EVT_UPDATE_UI( CmdMenu_ShowDlgLayerOrderDocument().GetId(), a2dCentralCanvasCommandProcessor::OnUpdateMenu )
246  EVT_UPDATE_UI( CmdMenu_ShowDlgLayerOrderGlobal().GetId(), a2dCentralCanvasCommandProcessor::OnUpdateMenu )
247  //EVT_UPDATE_UI( CmdMenu_ShowDlgPropEdit().GetId(), a2dCentralCanvasCommandProcessor::OnUpdateMenu )
248 
249  EVT_UPDATE_UI( CmdMenu_SetLayerDlgModeless().GetId(), a2dCentralCanvasCommandProcessor::OnUpdateMenu )
250 
251  EVT_MENU( CmdMenu_ViewAsImage().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
252  EVT_MENU( CmdMenu_ViewAsImage_Png().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
253  EVT_MENU( CmdMenu_ViewAsImage_Bmp().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
254  EVT_MENU( CmdMenu_DocumentAsImage_Png().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
255  EVT_MENU( CmdMenu_DocumentAsImage_Bmp().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
256  EVT_MENU( CmdMenu_DocumentAsOdbXml().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
257  EVT_MENU( CmdMenu_ViewAsSvg().GetId(), a2dCentralCanvasCommandProcessor::OnMenu )
258 
259  EVT_MENU( CmdMenu_PushTool_Link_OneShot().GetId() , a2dCentralCanvasCommandProcessor::OnMenu )
260  EVT_MENU( CmdMenu_PushTool_Link().GetId() , a2dCentralCanvasCommandProcessor::OnMenu )
261  EVT_MENU( CmdMenu_PushTool_FollowLinkDocDrawCam().GetId() , a2dCentralCanvasCommandProcessor::OnMenu )
262  EVT_MENU( CmdMenu_PushTool_Master3Link().GetId() , a2dCentralCanvasCommandProcessor::OnMenu )
263 
264  EVT_MENU( CmdMenu_PrintDrawing().GetId(), a2dCanvasCommandProcessor::OnMenu )
265  EVT_MENU( CmdMenu_PreviewDrawing().GetId(), a2dCanvasCommandProcessor::OnMenu )
266 
267  EVT_UPDATE_UI( CmdMenu_ViewAsImage_Png().GetId(), a2dCentralCanvasCommandProcessor::OnUpdateMenu )
268  EVT_UPDATE_UI( CmdMenu_ViewAsImage_Bmp().GetId(), a2dCentralCanvasCommandProcessor::OnUpdateMenu )
269  EVT_UPDATE_UI( CmdMenu_DocumentAsImage_Png().GetId(), a2dCentralCanvasCommandProcessor::OnUpdateMenu )
270  EVT_UPDATE_UI( CmdMenu_DocumentAsImage_Bmp().GetId(), a2dCentralCanvasCommandProcessor::OnUpdateMenu )
271  EVT_UPDATE_UI( CmdMenu_ViewAsSvg().GetId(), a2dCentralCanvasCommandProcessor::OnUpdateMenu )
272  EVT_UPDATE_UI( CmdMenu_FileExport().GetId(), a2dCentralCanvasCommandProcessor::OnUpdateMenu )
273  EVT_UPDATE_UI( CmdMenu_FileImport().GetId(), a2dCentralCanvasCommandProcessor::OnUpdateMenu )
274 
275 END_EVENT_TABLE()
276 
277 a2dCentralCanvasCommandProcessor::a2dCentralCanvasCommandProcessor( long flags , bool initialize, int maxCommands )
278  : a2dDocumentCommandProcessor( flags, initialize, maxCommands )
279 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
280  , m_initCurrentSmartPointerOwner( this )
281 #endif
282 {
283  m_layersdlg = NULL;
284  m_layerOrderDlg = NULL;
285  m_structDlgDoc = NULL;
286 }
287 
289  : a2dDocumentCommandProcessor( other )
290 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
291  , m_initCurrentSmartPointerOwner( this )
292 #endif
293 {
294  m_layersdlg = NULL;
295  m_layerOrderDlg = NULL;
296  m_structDlgDoc = NULL;
297 }
298 
300 {
301  DeleteDlgs();
302 }
303 
304 void a2dCentralCanvasCommandProcessor::UpdateAllViews()
305 {
306  a2dDocumentList::iterator iter = m_docs.begin();
307  while( iter != m_docs.end() )
308  {
309  a2dDECLARE_LOCAL_ITEM( a2dDocumentList::value_type, doc, *iter );
310  iter++;
311  doc->UpdateAllViews( NULL, a2dCANVIEW_UPDATE_ALL );
312  }
313 }
314 
316 {
318  {
319  if ( event.GetEventType() == wxEVT_COMMAND_MENU_SELECTED )
320  {
322  if ( !drawingPart || !drawingPart->GetDrawing() || !drawingPart->GetDrawing()->GetCommandProcessor() )
323  return true;
324  return drawingPart->GetDrawing()->GetCommandProcessor()->ProcessEvent( event );
325  }
326  else if ( event.GetEventType() == wxEVT_UPDATE_UI
327  )
328  {
330  if ( !drawingPart || !drawingPart->GetDrawing() || !drawingPart->GetDrawing()->GetCommandProcessor() )
331  {
332  a2dCanvasCommandProcessor::StaticProcessEvent( (wxUpdateUIEvent&) event );
333  return true;
334  }
335  return drawingPart->GetDrawing()->GetCommandProcessor()->ProcessEvent( event );
336  }
337  return false;
338  }
339  return true;
340 }
341 
342 void a2dCentralCanvasCommandProcessor::OnUpdateUndo( wxUpdateUIEvent& event )
343 {
345  if ( doc )
346  {
347  // assume the current active commandprocessor is based on the active drawingpart its a2dDrawing.
349  if ( !drawer )
350  {
351  event.Skip();
352  return;
353  }
354  a2dDrawing* drawing = drawer->GetDrawing();
355  event.Enable( ( drawing->GetCommandProcessor() && drawing->GetCommandProcessor()->CanUndo() ));
356  }
357  else
358  event.Skip();
359 }
360 
361 void a2dCentralCanvasCommandProcessor::OnUpdateRedo( wxUpdateUIEvent& event )
362 {
364  if ( doc )
365  {
366  // assume the current active commandprocessor is based on the active drawingpart its a2dDrawing.
368  if ( !drawer )
369  {
370  event.Skip();
371  return;
372  }
373 
374  a2dDrawing* drawing = drawer->GetDrawing();
375  event.Enable( ( drawing->GetCommandProcessor() && drawing->GetCommandProcessor()->CanRedo() ));
376  }
377  else
378  event.Skip();
379 }
380 
381 void a2dCentralCanvasCommandProcessor::OnPushToolUpdateMenu( wxUpdateUIEvent& event )
382 {
384  if ( !drawingPart )
385  return;
386  if ( !drawingPart->GetDrawing() )
387  return;
388 
389  // a2dCanvasCommandProcessor will decide
390  event.Skip();
391 }
392 
393 void a2dCentralCanvasCommandProcessor::OnUpdateMenu( wxUpdateUIEvent& event )
394 {
395  if ( event.GetId() == CmdMenu_InsertGroupRef().GetId() )
396  {
397  }
398  else if ( event.GetId() == CmdMenu_GdsIoSaveTextAsPolygon().GetId() )
399  event.Check( a2dCanvasGlobals->GetHabitat()->m_gdsiiSaveTextAsPolygon );
400  else if ( event.GetId() == CmdMenu_KeyIoSaveTextAsPolygon().GetId() )
401  event.Check( a2dCanvasGlobals->GetHabitat()->m_keySaveTextAsPolygon );
402  else if ( event.GetId() == CmdMenu_SetGdsIoSaveFromView().GetId() )
403  event.Check( a2dCanvasGlobals->GetHabitat()->m_gdsiiSaveFromView );
404  else if ( event.GetId() == CmdMenu_SetKeyIoSaveFromView().GetId() )
405  event.Check( a2dCanvasGlobals->GetHabitat()->m_keySaveFromView );
406  else if ( event.GetId() == CmdMenu_ShowDlgStructureDocumentModal().GetId() )
407  {
408  event.Check( IsShownStructureDlg() );
409  }
410  else if ( event.GetId() == CmdMenu_ShowDlgStructure().GetId() )
411  {
412  }
413  else if (
414  event.GetId() == CmdMenu_FileExport().GetId() ||
415  event.GetId() == CmdMenu_FileImport().GetId() ||
416 
417  event.GetId() == CmdMenu_ViewAsImage_Png().GetId() ||
418  event.GetId() == CmdMenu_ViewAsImage_Bmp().GetId() ||
419  event.GetId() == CmdMenu_DocumentAsImage_Png().GetId() ||
420 #if wxART2D_USE_SVGIO
421  event.GetId() == CmdMenu_ViewAsSvg().GetId() ||
422 #endif // wxART2D_USE_SVGIO
423  event.GetId() == CmdMenu_DocumentAsImage_Bmp().GetId()
424  )
425  {
426  event.Enable( false );
428  if ( !doc )
429  return;
431  if ( !drawingPart )
432  return;
433  if ( !drawingPart->GetDrawing() )
434  return;
435  event.Enable( true );
436  }
437  else
438  {
439  event.Skip();
440  }
441 }
442 
443 
444 void a2dCentralCanvasCommandProcessor::OnMenu( wxCommandEvent& event )
445 {
446  bool onTop = true;
447  long style = wxDEFAULT_DIALOG_STYLE;
448  if ( !onTop )
449  style |= wxSTAY_ON_TOP;
450 
451  bool found = false;
452 
454  if ( !doc )
455  return;
456  a2dCanvasView* drawer = CheckDrawer();
457  if ( !drawer )
458  return;
459  if ( !drawer->GetDrawingPart()->GetDrawing() )
460  return;
461 
462  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
463 
464  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
465 
466  if ( event.GetId() == CmdMenu_ChangeCentralStyle().GetId() )
467  {
468  found = true;
469  }
470  else if ( event.GetId() == CmdMenu_SetLayer().GetId() )
471  {
472  found = true;
473  long w = wxGetNumberFromUser( _( "Give layer number:" ), _( "Layer:" ), _( "layer number" ), a2dCanvasGlobals->GetHabitat()->m_layer, 0, wxMAXLAYER );
474 
475  if ( w != -1 )
476  {
477  if ( w >= 0 && w < ( long ) wxMAXLAYER )
478  {
479  a2dCanvasGlobals->GetHabitat()->SetLayer( w, true );
480  }
481  else
482  ( void )wxMessageBox( _( "Layer is not available" ), _( "Layers" ), wxICON_INFORMATION | wxOK );
483  }
484  }
485  else if ( event.GetId() == CmdMenu_SetTarget().GetId() )
486  {
487  found = true;
488  long w = wxGetNumberFromUser( _( "Give layer number:" ), _( "Layer:" ), _( "Set Target Layer" ), a2dCanvasGlobals->GetHabitat()->m_target, 0, wxMAXLAYER );
489 
490  if ( w != -1 )
491  {
492  if ( w >= 0 && w < ( long ) wxMAXLAYER )
493  {
494  a2dCanvasGlobals->GetHabitat()->SetTarget( w );
495  }
496  else
497  ( void )wxMessageBox( _( "Layer is not available" ), _( "Layers" ), wxICON_INFORMATION | wxOK );
498  }
499  }
500  else if ( event.GetId() == CmdMenu_SetNormalizeFactor().GetId() )
501  {
502  found = true;
503  if ( !CheckCanvasDocument() )
504  return;
505 
506  double norm = wxGetDoubleNumberFromUser( _( "Give normalize factor:" ), _( "Normalize" ), _( "Normalize factor" ), 1, 0, 10000 );
507 
508  if ( norm != DBL_MAX )
509  {
510  if ( norm >= 0 && norm < 10000 )
511  {
513  a2dCanvasGlobals->GetHabitat()->SetTarget( norm );
514  }
515  else
516  ( void )wxMessageBox( _( "Normlaize factor must be > 0" ), _( "Normalize" ), wxICON_INFORMATION | wxOK );
517  }
518  }
519  else if ( event.GetId() == CmdMenu_GdsIoSaveTextAsPolygon().GetId() )
520  {
521  found = true;
522  a2dCanvasGlobals->GetHabitat()->GdsIoSaveTextAsPolygon( !a2dCanvasGlobals->GetHabitat()->m_gdsiiSaveTextAsPolygon );
524  {
525  a2dDocumentTemplateList::value_type temp = *iter;
526  if ( temp->IsVisible() && wxT( "GDS-II" ) == temp->GetDescription() )
527  {
528  #if wxART2D_USE_GDSIO
529  wxStaticCast( temp->GetDocumentIOHandlerStrOut(), a2dIOHandlerGDSOut )->SetSaveTextAsVpath( a2dCanvasGlobals->GetHabitat()->GetGdsIoSaveTextAsPolygon() );
530  #endif //wxART2D_USE_GDSIO
531  }
532  }
533  }
534  else if ( event.GetId() == CmdMenu_KeyIoSaveTextAsPolygon().GetId() )
535  {
536  found = true;
537  a2dCanvasGlobals->GetHabitat()->KeyIoSaveTextAsPolygon( !a2dCanvasGlobals->GetHabitat()->m_keySaveTextAsPolygon );
539  {
540  a2dDocumentTemplateList::value_type temp = *iter;
541  if ( temp->IsVisible() && wxT( "KEY" ) == temp->GetDescription() )
542  {
543  #if wxART2D_USE_KEYIO
544  wxStaticCast( temp->GetDocumentIOHandlerStrOut(), a2dIOHandlerKeyOut )->SetSaveTextAsVpath( a2dCanvasGlobals->GetHabitat()->GetKeyIoSaveTextAsPolygon() );
545  #endif //wxART2D_USE_KEYIO
546  }
547  }
548  }
549  else if ( event.GetId() == CmdMenu_SetGdsIoSaveFromView().GetId() )
550  {
551  found = true;
552  a2dCanvasGlobals->GetHabitat()->m_gdsiiSaveFromView = !a2dCanvasGlobals->GetHabitat()->m_gdsiiSaveFromView;
553  a2dCommand_GdsIoSaveFromView* command = new a2dCommand_GdsIoSaveFromView( a2dCanvasGlobals->GetHabitat()->m_gdsiiSaveFromView );
554  Submit( command );
555  }
556  else if ( event.GetId() == CmdMenu_SetKeyIoSaveFromView().GetId() )
557  {
558  found = true;
559  a2dCanvasGlobals->GetHabitat()->m_keySaveFromView = !a2dCanvasGlobals->GetHabitat()->m_keySaveFromView;
560  a2dCommand_KeyIoSaveFromView* command = new a2dCommand_KeyIoSaveFromView( a2dCanvasGlobals->GetHabitat()->m_keySaveFromView );
561  Submit( command );
562  }
563 
564  if ( found )
565  {}
566  else if ( event.GetId() == CmdMenu_SaveLayers().GetId() )
567  {
568  found = true;
569  wxString file = AskFile( _( "Give Name of output Layer file" ),
570  _T( "@{layerFileApplication}" ),
571  _T( "" ),
572  _T( "*.cvg" ),
573  _T( "*.cvg" ),
574  wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
575  SaveLayers( wxFileName( file ) );
576  }
577  else if ( event.GetId() == CmdMenu_SaveLayersLastDir().GetId() )
578  {
579  found = true;
580  wxString file = AskFile( _( "Give Name of output Layer file" ),
581  _T( "@{lastLayerFileSavePath}" ),
582  _T( "" ),
583  _T( "*.cvg" ),
584  _T( "*.cvg" ),
585  wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
586  SaveLayers( wxFileName( file ) );
587  }
588  else if ( event.GetId() == CmdMenu_SaveLayersHome().GetId() )
589  {
590  found = true;
591  wxString file = AskFile( _( "Give Name of output Layer file" ),
592  _T( "@{layerFileSavePath}" ),
593  _T( "" ),
594  _T( "*.cvg" ),
595  _T( "*.cvg" ),
596  wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
597  SaveLayers( wxFileName( file ) );
598  }
599  else if ( event.GetId() == CmdMenu_SaveLayersCurrentDir().GetId() )
600  {
601  found = true;
602  wxString file = AskFile( _( "Give Name of output Layer file" ),
603  _T( "./" ),
604  _T( "" ),
605  _T( "*.cvg" ),
606  _T( "*.cvg" ),
607  wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
608  SaveLayers( wxFileName( file ) );
609  }
610  else if ( event.GetId() == CmdMenu_LoadLayers().GetId() )
611  {
612  found = true;
613  wxString file = AskFile( _( "Give Name of input Layer file" ),
614  _T( "@{layerFileApplication}" ),
615  _T( "" ),
616  _T( "*.cvg" ),
617  _T( "*.cvg" ),
618  wxFD_OPEN | wxFD_FILE_MUST_EXIST );
619  LoadLayers( wxFileName( file ) );
620  }
621  else if ( event.GetId() == CmdMenu_LoadLayersHome().GetId() )
622  {
623  found = true;
624  wxString file = AskFile( _( "Give Name of input Layer file" ),
625  _T( "@{layerFileSavePath}" ),
626  _T( "" ),
627  _T( "*.cvg" ),
628  _T( "*.cvg" ),
629  wxFD_OPEN | wxFD_FILE_MUST_EXIST );
630  LoadLayers( wxFileName( file ) );
631  }
632  else if ( event.GetId() == CmdMenu_LoadLayersLastDir().GetId() )
633  {
634  found = true;
635  wxString file = AskFile( _( "Give Name of input Layer file" ),
636  _T( "@{lastLayerFileSavePath}" ),
637  _T( "" ),
638  _T( "*.cvg" ),
639  _T( "*.cvg" ),
640  wxFD_OPEN | wxFD_FILE_MUST_EXIST );
641  LoadLayers( wxFileName( file ) );
642  }
643  else if ( event.GetId() == CmdMenu_LoadLayersCurrentDir().GetId() )
644  {
645  found = true;
646  wxString file = AskFile( _( "Give Name of input Layer file" ),
647  _T( "./" ),
648  _T( "" ),
649  _T( "*.cvg" ),
650  _T( "*.cvg" ),
651  wxFD_OPEN | wxFD_FILE_MUST_EXIST );
652  LoadLayers( wxFileName( file ) );
653  }
654  else if ( event.GetId() == CmdMenu_SetCursor().GetId() )
655  {
656  found = true;
657  }
658  else if ( event.GetId() == CmdMenu_GdsIoSaveFromView().GetId() )
659  {
660  found = true;
661  a2dCanvasGlobals->GetHabitat()->m_gdsiiSaveFromView = !a2dCanvasGlobals->GetHabitat()->m_gdsiiSaveFromView;
662  a2dCommand_GdsIoSaveFromView* command = new a2dCommand_GdsIoSaveFromView( a2dCanvasGlobals->GetHabitat()->m_gdsiiSaveFromView );
663  Submit( command );
664  }
665  else if ( event.GetId() == CmdMenu_KeyIoSaveFromView().GetId() )
666  {
667  found = true;
668  a2dCanvasGlobals->GetHabitat()->m_keySaveFromView = !a2dCanvasGlobals->GetHabitat()->m_keySaveFromView;
669  a2dCommand_KeyIoSaveFromView* command = new a2dCommand_KeyIoSaveFromView( a2dCanvasGlobals->GetHabitat()->m_keySaveFromView );
670  Submit( command );
671  }
672  else if ( event.GetId() == CmdMenu_SetLayersProperty().GetId() )
673  {
674  found = true;
675  }
676 
677  if ( found )
678  {
679  }
680  else if ( event.GetId() == CmdMenu_ShowDlgLayers().GetId() ||
681  event.GetId() == CmdMenu_ShowDlgLayersDrawing().GetId() ||
682  event.GetId() == CmdMenu_ShowDlgLayersDocument().GetId() ||
683  event.GetId() == CmdMenu_ShowDlgLayersGlobal().GetId()
684  )
685  {
686  found = true;
688 
689  if ( !m_layersdlg )
690  {
691  m_layersdlg = new LayerPropertiesDialog( a2dCanvasGlobals->GetHabitat(), NULL, NULL, _( "Layer of Document" ), style | wxRESIZE_BORDER );
692  }
693 
694  if ( !m_layersdlg->IsShown() )
695  {
696  m_layersdlg->Show( true );
697  if ( event.GetId() == CmdMenu_ShowDlgLayersDocument().GetId() )
698  {
700  if ( !doc )
701  return;
702 
703  m_layersdlg->Init( doc->GetLayerSetup() );
704  }
705  else if ( event.GetId() == CmdMenu_ShowDlgLayersDrawing().GetId() || event.GetId() == CmdMenu_ShowDlgLayers().GetId() )
706  {
708  if ( !doc )
709  return;
710 
711  m_layersdlg->Init( doc->GetDrawing()->GetLayerSetup() );
712  }
713  else
714  m_layersdlg->Init( a2dCanvasGlobals->GetHabitat()->GetLayerSetup() );
715  }
716  else
717  {
718  m_layersdlg->Show( false );
719  }
720  }
721  else if ( event.GetId() == CmdMenu_ShowDlgLayerOrderDocument().GetId() ||
722  event.GetId() == CmdMenu_ShowDlgLayerOrderGlobal().GetId() )
723  {
724  found = true;
726 
727  if ( !m_layerOrderDlg )
728  {
729  m_layerOrderDlg = new a2dLayerOrderDialog( NULL, NULL, _( "Layer of Document" ), style | wxRESIZE_BORDER );
730  }
731 
732  if ( !m_layerOrderDlg->IsShown() )
733  {
734  if ( event.GetId() == CmdMenu_ShowDlgLayerOrderDocument().GetId() )
735  {
737  if ( !doc )
738  return;
739 
740  m_layerOrderDlg->Init( doc->GetLayerSetup() );
741  }
742  else
743  m_layerOrderDlg->Init( a2dCanvasGlobals->GetHabitat()->GetLayerSetup() );
744  m_layerOrderDlg->Show( true );
745  }
746  else
747  {
748  m_layerOrderDlg->Show( false );
749  }
750  }
751  else if ( event.GetId() == CmdMenu_ViewAsImage_Png().GetId() )
752  {
753  found = true;
754 
756  if ( !drawer )
757  return;
758 
760  if ( !doc )
761  return;
762 
763  wxString file = AskFile( _( "Give Name of output PNG file" ),
764  _T( "" ),
765  _T( "" ),
766  _T( "*.png" ),
767  _T( "*.png" ),
768  wxFD_SAVE );
769 
770  SaveViewAsImage( doc, file, wxBITMAP_TYPE_PNG, drawer->GetShowObject() );
771  }
772  else if ( event.GetId() == CmdMenu_ViewAsImage_Bmp().GetId() )
773  {
774  found = true;
775 
777  if ( !drawer )
778  return;
779 
781  if ( !doc )
782  return;
783 
784  wxString file = AskFile( _( "Give Name of output BMP file" ),
785  _T( "" ),
786  _T( "" ),
787  _T( "*.bmp" ),
788  _T( "*.bmp" ),
789  wxFD_SAVE );
790 
791  SaveViewAsImage( doc, file, wxBITMAP_TYPE_BMP, drawer->GetShowObject() );
792  }
793  else if ( event.GetId() == CmdMenu_DocumentAsImage_Png().GetId() )
794  {
795  found = true;
796 
798  if ( !doc )
799  return;
800 
801  wxString file = AskFile( _( "Give Name of output PNG file" ),
802  _T( "" ),
803  _T( "" ),
804  _T( "*.png" ),
805  _T( "*.png" ),
806  wxFD_SAVE );
807 
808  SaveViewAsImage( doc, file, wxBITMAP_TYPE_PNG, doc->GetDrawing()->GetRootObject() );
809  }
810  else if ( event.GetId() == CmdMenu_DocumentAsImage_Bmp().GetId() )
811  {
812  found = true;
813  wxString file = AskFile( _( "Give Name of output BMP file" ),
814  _T( "" ),
815  _T( "" ),
816  _T( "*.bmp" ),
817  _T( "*.bmp" ),
818  wxFD_SAVE );
819 
821  if ( !doc )
822  return;
823 
824  SaveViewAsImage( doc, file, wxBITMAP_TYPE_BMP, doc->GetDrawing()->GetRootObject() );
825  }
826 #if wxART2D_USE_SVGIO
827  else if ( event.GetId() == CmdMenu_ViewAsSvg().GetId() )
828  {
829  found = true;
830  wxString file = AskFile( _( "Give Name of output SVG file" ),
831  _T( "" ),
832  _T( "" ),
833  _T( "*.svg" ),
834  _T( "*.svg" ),
835  wxFD_SAVE );
836 
838  file( wxFileName( file ) ) );
839  Submit( command2 );
840  }
841 #endif //wxART2D_USE_SVGIO
842  else if ( event.GetId() == CmdMenu_DocumentAsOdbXml().GetId() )
843  {
844  found = true;
845  wxString file = AskFile( _( "Give Name of output ODB file" ),
846  _T( "" ),
847  _T( "" ),
848  _T( "*.xml" ),
849  _T( "*.xml" ),
850  wxFD_SAVE );
851 
852  if ( !FileExport( wxFileName( file ), _T( "ODB" ), a2dREFDOC_SILENT ) )
853  return;
854 
855  if ( a2dDocviewGlobals->GetLastError() != a2dError_CanceledFileDialog )
858  }
859  else if ( event.GetId() == CmdMenu_LineBegin().GetId() )
860  {
861  found = true;
862  a2dCanvasObjectList total;
863 
864  if ( !m_librarypoints )
865  {
866  wxMessageBox( _( "point library not loaded" ), _( "Points" ), wxICON_INFORMATION | wxOK );
867  return;
868  }
869  m_librarypoints->GetDrawing()->GetRootObject()->CollectObjects( &total, _T( "a2dLibraryReference" ), a2dCanvasOFlags::ALL );
870 
871  a2dCanvasObjectsDialog objects( NULL, &total, true, ( wxSTAY_ON_TOP | wxRESIZE_BORDER | wxCAPTION ) );
872  if ( objects.ShowModal() == wxID_OK )
873  {
874  a2dCanvasObject* begin = ( ( a2dLibraryReference* )objects.GetCanvasObject() )->GetCanvasObject();
875  begin->SetPosXY( 0, 0 );
876  a2dCanvasGlobals->GetHabitat()->SetLineBegin( begin );
877  }
878  }
879  else if ( event.GetId() == CmdMenu_LineEnd().GetId() )
880  {
881  found = true;
882  a2dCanvasObjectList total;
883 
884  if ( !m_librarypoints )
885  {
886  wxMessageBox( _( "point library not loaded" ), _( "Points" ), wxICON_INFORMATION | wxOK );
887  return;
888  }
889  m_librarypoints->GetDrawing()->GetRootObject()->CollectObjects( &total, _T( "a2dLibraryReference" ), a2dCanvasOFlags::ALL );
890 
891  a2dCanvasObjectsDialog objects( NULL, &total, true, ( wxSTAY_ON_TOP | wxRESIZE_BORDER | wxCAPTION ) );
892  if ( objects.ShowModal() == wxID_OK )
893  {
894  a2dCanvasObject* end = ( ( a2dLibraryReference* )objects.GetCanvasObject() )->GetCanvasObject();
895  end->SetPosXY( 0, 0 );
896  a2dCanvasGlobals->GetHabitat()->SetLineEnd( end );
897  }
898  }
899  else if ( event.GetId() == CmdMenu_ShowDlgStructureDocument().GetId() )
900  {
901  found = true;
902  a2dCanvasView* drawer = CheckDrawer();
903  if ( !drawer )
904  return;
906  if ( !doc )
907  return;
908  if ( !m_structDlgDoc )
909  {
910  m_structDlgDoc = new a2dCanvasObjectsDocDialog( NULL, doc, true, false, ( wxDEFAULT_DIALOG_STYLE | wxSTAY_ON_TOP | wxRESIZE_BORDER ) );
911  }
912  if ( m_structDlgDoc->IsShown() )
913  {
914  m_structDlgDoc->Show( false );
915  }
916  else
917  {
918  m_structDlgDoc->Show( true );
919  m_structDlgDoc->Init( doc );
920  }
921  }
922  else if ( event.GetId() == CmdMenu_ShowDlgStructureDocumentModal().GetId() )
923  {
924  found = true;
926  if ( !drawer )
927  return;
928 
929  a2dCanvasObjectsDocDialog groups( NULL, doc, true, true, ( wxDEFAULT_DIALOG_STYLE | wxSTAY_ON_TOP | wxRESIZE_BORDER ) );
930  if ( groups.ShowModal() == wxID_OK )
931  {
932  a2dCommand_SetShowObject* command = new a2dCommand_SetShowObject( drawer, a2dCommand_SetShowObject::Args().canvasobject( groups.GetCanvasObject() ) );
933  a2dGetCmdh()->Submit( command );
934  }
935  }
936  else if ( event.GetId() == CmdMenu_PushTool_Link().GetId() )
937  {
938  found = true;
940  if ( !part )
941  return;
942  a2dStToolContr* contr = ( a2dStToolContr* ) part->GetCanvasToolContr();
943 
944  a2dLinkTool* draw = new a2dLinkTool( contr );
945  contr->PushTool( draw );
946  }
947  else if ( event.GetId() == CmdMenu_PushTool_Link_OneShot().GetId() )
948  {
949  found = true;
951  if ( !part )
952  return;
953  a2dStToolContr* contr = ( a2dStToolContr* ) part->GetCanvasToolContr();
954 
955  a2dLinkTool* draw = new a2dLinkTool( contr );
956  draw->SetOneShot();
957  contr->PushTool( draw );
958  }
959  else if ( event.GetId() == CmdMenu_PushTool_FollowLinkDocDrawCam().GetId() )
960  {
961  found = true;
963  if ( !part )
964  return;
965  a2dStToolContr* contr = ( a2dStToolContr* ) part->GetCanvasToolContr();
966 
968  contr->PushTool( draw );
969  }
970  else if ( event.GetId() == CmdMenu_PushTool_DrawRectangleFast_OneShot().GetId() )
971  {
973  if ( !drawer )
974  return;
975 
976  found = true;
978  }
979  else if ( event.GetId() == CmdMenu_PushTool_Master3Link().GetId() )
980  {
981  found = true;
983  if ( !drawer )
984  return;
985 
986  a2dStToolContr* contr = wxDynamicCast( drawer->GetCanvasToolContr(), a2dStToolContr );
987  if ( contr )
988  {
990  //tool->SetWireMode( true );
991  tool->SetDlgOrEdit( true );
992  tool->SetDlgOrEditModal( true );
993  tool->SetAllowDoubleClickModifier( true );
994  contr->PushTool( tool );
995  }
996  }
997 
998  if ( !found )
999  event.Skip();
1000  else
1002 }
1003 
1005 {
1007  if ( !drawer )
1008  return false;
1009  if ( !drawer->GetDrawing() )
1010  return false;
1011 
1012  return drawer->GetDrawing()->GetCommandProcessor()->Submit( command, storeIt );
1013 }
1014 
1016 {
1018  if ( !doc )
1019  return;
1021  a2dCanvasView* drawer = CheckDrawer();
1022  if ( !drawer )
1023  return;
1024 
1026 }
1027 
1028 bool a2dCentralCanvasCommandProcessor::SaveViewAsImage( a2dCanvasDocument* doc, const wxString& file, wxBitmapType type, a2dCanvasObject* from )
1029 {
1030  a2dPathList path;
1031  path.Add( wxT( "." ) );
1032  wxString fileexp = file;
1033  if ( !path.ExpandPath( fileexp ) )
1034  {
1035  a2dDocviewGlobals->ReportErrorF( a2dError_CouldNotEvaluatePath, _( "Could not expand %s resulted in %s" ), fileexp.c_str(), fileexp.c_str() );
1036  return false;
1037  }
1038  if ( fileexp.IsEmpty() )
1039  {
1040  a2dDocviewGlobals->ReportErrorF( a2dError_NotSpecified, _( "file name %s not in %s" ), fileexp.c_str(), path.GetAsString().c_str() );
1041  return false;
1042  }
1043 
1044  a2dCanvasDocumentIOHandlerImageOut imagehout( type );
1045  imagehout.SetBorder( 10 );
1046  imagehout.SetShowObject( from );
1047 
1049  if ( !drawer )
1050  return false;
1051 
1052  imagehout.SetYaxis( drawer->GetDrawer2D()->GetYaxis() );
1053 
1054  if ( true )
1055  imagehout.SetViewRectangle( drawer->GetDrawer2D()->GetVisibleBbox() );
1056 
1057 #if wxUSE_STD_IOSTREAM
1058  a2dDocumentFileOutputStream store( fileexp.mb_str(), wxSTD ios_base::out | wxSTD ios_base::binary );
1059  if ( store.fail() || store.bad() )
1060  {
1061  a2dDocviewGlobals->ReportErrorF( a2dError_FileCouldNotOpen, _( "Sorry, could not open file %s for saving" ), fileexp.c_str() );
1062  return false;
1063  }
1064 #else
1065  wxFileOutputStream storeUnbuf( fileName );
1066  if ( storeUnbuf.GetLastError() != wxSTREAM_NO_ERROR )
1067  {
1068  a2dDocviewGlobals->ReportErrorF( a2dError_FileCouldNotOpen, _( "Sorry, could not open file %s for saving" ), fileexp.c_str() );
1069  return false;
1070  }
1071  wxBufferedOutputStream store( storeUnbuf );
1072 #endif
1073 
1074  if ( ! doc->SaveObject( store, &imagehout ) )
1075  {
1076  a2dDocviewGlobals->ReportErrorF( a2dError_SaveFile, _( "Sorry, could not save document to file %s" ), file.c_str() );
1077  return false;
1078  }
1079  return true;
1080 }
1081 
1082 void a2dCentralCanvasCommandProcessor::FillLibraryPoints()
1083 {
1084 #if wxART2D_USE_CANEXTOBJ
1085  //root group always at 0,0
1086  m_librarypoints = new a2dCanvasDocument();
1087 
1088  {
1089  a2dCircle* cire = new a2dCircle( 0, 0, 1 );
1090  cire->SetFill( wxColour( 219, 215, 6 ), a2dFILL_HORIZONTAL_HATCH );
1091  cire->SetStroke( wxColour( 1, 3, 205 ), 3.0 );
1093 
1094  a2dLibraryReference* libobject = new a2dLibraryReference( 0, 0, cire, _T( "circle" ), 100 );
1095  libobject->SetStroke( wxColour( 229, 5, 64 ), 0 );
1096  m_librarypoints->GetDrawing()->GetRootObject()->Append( libobject );
1097  }
1098 
1099  {
1100  a2dArrow* arrow = new a2dArrow( 0, 0, 1, 0.5, 0.5 );
1101  arrow->SetFill( wxColour( 219, 215, 6 ) );
1102  arrow->SetStroke( wxColour( 1, 3, 205 ), 1 );
1104 
1105  a2dLibraryReference* libobject = new a2dLibraryReference( 0, -200, arrow, _T( "arrow" ), 100 );
1106  libobject->SetStroke( wxColour( 229, 5, 64 ), 0 );
1107  m_librarypoints->GetDrawing()->GetRootObject()->Append( libobject );
1108  }
1109 
1110  {
1111  a2dArrow* arrow2 = new a2dArrow( 0, 0, 2, 1, 2 );
1112  arrow2->SetFill( wxColour( 219, 2, 6 ) );
1113  arrow2->SetStroke( wxColour( 255, 3, 205 ), 1.0 );
1115 
1116  a2dLibraryReference* libobject = new a2dLibraryReference( 0, -400, arrow2, _T( "arrow2" ), 100 );
1117  libobject->SetStroke( wxColour( 229, 5, 64 ), 0 );
1118  m_librarypoints->GetDrawing()->GetRootObject()->Append( libobject );
1119  }
1120 
1121  {
1122  a2dArrow* arrow3 = new a2dArrow( 0, 0, 2, 2, 2 );
1123  arrow3->SetFill( wxColour( 2, 233, 6 ) );
1124  arrow3->SetStroke( wxColour( 255, 3, 25 ), 1 );
1126 
1127  a2dLibraryReference* libobject = new a2dLibraryReference( 0, -400, arrow3, _T( "arrow3" ), 100 );
1128  libobject->SetStroke( wxColour( 229, 5, 64 ), 0 );
1129  m_librarypoints->GetDrawing()->GetRootObject()->Append( libobject );
1130  }
1131 
1132  {
1133  a2dArrow* arrow3 = new a2dArrow( 0, 0, 2, 0, 2 );
1134  arrow3->SetFill( wxColour( 2, 233, 6 ) );
1135  arrow3->SetStroke( wxColour( 255, 3, 25 ), 1 );
1137 
1138  a2dLibraryReference* libobject = new a2dLibraryReference( 0, -400, arrow3, _T( "arrow4" ), 100 );
1139  libobject->SetStroke( wxColour( 229, 5, 64 ), 0 );
1140  m_librarypoints->GetDrawing()->GetRootObject()->Append( libobject );
1141  }
1142  /*
1143  {
1144  wxBitmap bitmap( smile_xpm );
1145  a2dImage* i=new a2dImage( bitmap.ConvertToImage(), 0,0,1,1 );
1146  i->SetSpecificFlags( true, a2dCanvasOFlags::normalized );
1147 
1148  a2dLibraryReference* libobject = new a2dLibraryReference( 200, 0, i, _T("smilly"), 100);
1149  libobject->SetStroke(wxColour(229,5,64 ),0);
1150  m_librarypoints->Append( libobject );
1151  }
1152  */
1153  {
1154  a2dRect* rec3 = new a2dRect( -1, -1, 2, 2 );
1155  rec3->SetFill( wxColour( 0, 120, 240 ) );
1156  rec3->SetStroke( wxColour( 252, 54, 252 ), 3.0 );
1158 
1159  a2dLibraryReference* libobject = new a2dLibraryReference( 200, -200, rec3, _T( "rectangle" ), 100 );
1160  libobject->SetStroke( wxColour( 229, 5, 64 ), 0 );
1161  m_librarypoints->GetDrawing()->GetRootObject()->Append( libobject );
1162  }
1163 
1164 #endif
1165 }
1166 
1168 {
1170  if ( !drawer )
1171  return;
1172  drawer->SetCursor( a2dCanvasGlobals->GetCursor( a2dCURSOR_WAIT ) );
1173 }
1174 
1176 {
1178  if ( !drawer )
1179  return;
1180  drawer->SetCursor( a2dCanvasGlobals->GetCursor( a2dCURSOR_ARROW ) );
1181 }
1182 
1183 void a2dCentralCanvasCommandProcessor::OnChangedDocument( a2dCommandEvent& event )
1184 {
1185  event.Skip();
1187  if ( !doc )
1188  return;
1189 
1190  // this has to be set when document changes.
1191  a2dGlobals->SetAberPolyToArc( double( a2dCanvasGlobals->GetHabitat()->m_AberPolyToArc ) / doc->GetUnitsScale() );
1192  a2dGlobals->SetAberArcToPoly( double( a2dCanvasGlobals->GetHabitat()->m_AberArcToPoly ) / doc->GetUnitsScale() );
1193 }
1194 
1196 {
1198  if ( !doc )
1199  return 1;
1200 
1201  return doc->GetUnitsScale();
1202 }
1203 
1204 bool a2dCentralCanvasCommandProcessor::SaveLayers( const wxFileName& fileName )
1205 {
1207  if ( !doc )
1208  return false;
1209 
1210  a2dPathList path;
1211  path.Add( wxT( "." ) );
1212  wxString foundfile = fileName.GetFullPath();
1213  if ( !path.ExpandPath( foundfile ) )
1214  {
1215  a2dDocviewGlobals->ReportErrorF( a2dError_CouldNotEvaluatePath, _( "Could not expand %s resulted in %s" ), fileName.GetFullPath().c_str(), foundfile.c_str() );
1216  return false;
1217  }
1218  if ( foundfile.IsEmpty() )
1219  {
1220  a2dDocviewGlobals->ReportErrorF( a2dError_NotSpecified, _( "Filename %s not in %s" ), foundfile.c_str(), path.GetAsString().c_str() );
1221  return false;
1222  }
1223 
1224  if ( doc->GetLayerSetup() )
1225  doc->GetLayerSetup()->SaveLayers( foundfile );
1226  else
1227  a2dDocviewGlobals->ReportErrorF( a2dError_NotSpecified, _( "Document does not have layer setup" ) );
1228 
1229  return true;
1230 }
1231 
1232 bool a2dCentralCanvasCommandProcessor::LoadLayers( const wxFileName& fileName )
1233 {
1235  if ( !doc )
1236  return false;
1237 
1238  a2dPathList path;
1239  path.Add( wxT( "." ) );
1240  wxString foundfile = fileName.GetFullPath();
1241  if ( !path.ExpandPath( foundfile ) )
1242  {
1243  a2dDocviewGlobals->ReportErrorF( a2dError_CouldNotEvaluatePath, _( "Could not expand %s resulted in %s" ), fileName.GetFullPath().c_str(), foundfile.c_str() );
1244  return false;
1245  }
1246  if ( foundfile.IsEmpty() )
1247  {
1248  a2dDocviewGlobals->ReportErrorF( a2dError_NotSpecified, _( "Filename %s not in %s" ), foundfile.c_str(), path.GetAsString().c_str() );
1249  return false;
1250  }
1251 
1252 #if wxUSE_STD_IOSTREAM
1253  a2dDocumentFileInputStream store( foundfile.mb_str() );
1254  if ( store.fail() || store.bad() )
1255  {
1256  a2dDocviewGlobals->ReportErrorF( a2dError_FileCouldNotOpen, _( "Sorry, could not open file %s for import" ), foundfile.c_str() );
1257  return false;
1258  }
1259 #else
1260  wxFileInputStream storeUnbuf( foundfile );
1261  if ( !storeUnbuf.Ok() )
1262  {
1263  a2dDocviewGlobals->ReportErrorF( a2dError_FileCouldNotOpen, _( "Sorry, could not open file %s for import" ), foundfile.c_str() );
1264  return false;
1265  }
1266  wxBufferedInputStream store( storeUnbuf );
1267 #endif
1268 
1269 #if wxART2D_USE_CVGIO
1270  //assume it is the default CVG format.
1271  a2dIOHandlerCVGIn* handler = new a2dIOHandlerCVGIn();
1272  a2dLayers* layersetup = new a2dLayers();
1273  handler->LoadLayers( store, layersetup );
1274 
1275  delete handler;
1276 #else
1277  wxFAIL_MSG( wxT( "wxART2D_USE_CVGIO is needed to load object from a file CVG file" ) );
1278 #endif //wxART2D_USE_CVGIO
1279 
1280  doc->SetLayerSetup( layersetup );
1281  return true;
1282 }
1283 
1285 {
1287  if ( !drawer )
1288  return NULL;
1289  if ( !drawer->GetDrawing() )
1290  return NULL;
1291 
1292  a2dDrawing* drawing = drawer->GetDrawing();
1293  return drawing->GetCanvasCommandProcessor()->AddCurrent( objectToAdd, withUndo, setStyles, parentObject );
1294 }
1295 
1296 /*
1297 void a2dCentralCanvasCommandProcessor::SetStroke( const a2dStroke& stroke )
1298 {
1299  a2dCentralCanvasCommandProcessor::PROPID_Stroke->SetPropertyToObject( this, stroke );
1300 }
1301 
1302 void a2dCentralCanvasCommandProcessor::SetStroke( const unsigned char red, const unsigned char green, const unsigned char blue )
1303 {
1304  a2dCanvasObject* canobj = GetCurrentCanvasObject();
1305  a2dStroke col = GetStroke();
1306  col.SetColour( wxColour( red, green, blue ) );
1307  Submit( new a2dCommand_SetCanvasProperty( canobj, a2dCanvasObject::PROPID_Stroke, col ), m_withUndo );
1308 }
1309 
1310 void a2dCentralCanvasCommandProcessor::SetFill( const a2dFill& fill )
1311 {
1312  a2dCentralCanvasCommandProcessor::PROPID_Fill->SetPropertyToObject( this, fill );
1313 }
1314 
1315 void a2dCentralCanvasCommandProcessor::SetFill( const unsigned char red, const unsigned char green, const unsigned char blue )
1316 {
1317  a2dCanvasObject* canobj = GetCurrentCanvasObject();
1318  a2dFill col = GetFill();
1319  col.SetColour( wxColour( red, green, blue ) );
1320  Submit( new a2dCommand_SetCanvasProperty( canobj, a2dCanvasObject::PROPID_Fill, col ), m_withUndo );
1321 }
1322 
1323 void a2dCentralCanvasCommandProcessor::SetFont( const a2dFont& font )
1324 {
1325  a2dCentralCanvasCommandProcessor::PROPID_Font->SetPropertyToObject( this, font );
1326 
1327  a2dCanvasObject* canobj = GetCurrentCanvasObject();
1328  if ( wxDynamicCast( canobj, a2dText ) )
1329  {
1330  //! todo set text to object.
1331 // Submit(new a2dCommand_SetCanvasProperty( canobj, a2dCanvasObject::PROPID_Stroke, GetDrawingCmdProcessor()->GetStroke()->Clone( clone_flat ) ), m_withUndo );
1332  }
1333 }
1334 
1335 void a2dCentralCanvasCommandProcessor::SetContourWidthInDataBaseUnits( double width )
1336 {
1337  a2dCanvasDocument* doc = CheckCanvasDocument();
1338  if ( !doc )
1339  m_currentContourWidth = 0.0;
1340  m_currentContourWidth = width * doc->GetUnitsScale();
1341 }
1342 
1343 
1344 double a2dCentralCanvasCommandProcessor::GetContourWidthInDataBaseUnits() const
1345 {
1346  a2dCanvasDocument* doc = CheckCanvasDocument();
1347  if ( !doc )
1348  return 0;
1349  return m_currentContourWidth / doc->GetUnitsScale();
1350 }
1351 
1352 void a2dCentralCanvasCommandProcessor::SetContourWidth( const a2dDoMu& currentContourWidth )
1353 {
1354  m_currentContourWidth = currentContourWidth;
1355 }
1356 */
1357 
1358 /*
1359 void a2dCentralCanvasCommandProcessor::SetStyle( a2dPropertyIdList* setStyles )
1360 {
1361  if ( !m_currentobject )
1362  return;
1363 
1364  if ( !setStyles )
1365  return;
1366 
1367  if( setStyles->Find( &a2dCentralCanvasCommandProcessor::PROPID_Stroke ))
1368  m_currentobject->SetStroke( m_currentstroke );
1369 
1370  if( setStyles->Find( &a2dCentralCanvasCommandProcessor::PROPID_Fill ))
1371  m_currentobject->SetFill( m_currentfill );
1372 
1373  if( setStyles->Find( &a2dCentralCanvasCommandProcessor::PROPID_Layer ))
1374  m_currentobject->SetLayer( m_layer );
1375 
1376  if( setStyles->Find( &a2dCentralCanvasCommandProcessor::PROPID_Spline ))
1377  a2dCanvasObject::PROPID_spline->SetPropertyToObject( m_currentobject, m_spline );
1378 
1379  if( setStyles->Find( &a2dCentralCanvasCommandProcessor::PROPID_begin ))
1380  a2dCanvasObject::PROPID_begin->SetPropertyToObject( m_currentobject, m_currentBegin );
1381 
1382  if( setStyles->Find( &a2dCentralCanvasCommandProcessor::PROPID_end ))
1383  a2dCanvasObject::PROPID_end->SetPropertyToObject( m_currentobject, m_currentEnd );
1384 
1385  if( setStyles->Find( &a2dCentralCanvasCommandProcessor::PROPID_endScaleX ))
1386  a2dCanvasObject::PROPID_endScaleX->SetPropertyToObject( m_currentobject, m_currentXscale );
1387 
1388  if( setStyles->Find( &a2dCentralCanvasCommandProcessor::PROPID_endScaleY ))
1389  a2dCanvasObject::PROPID_endScaleY->SetPropertyToObject( m_currentobject, m_currentYscale );
1390 
1391 }
1392 */
1393 
1394 bool a2dCentralCanvasCommandProcessor::CvgString( const wxString& cvgString )
1395 {
1396  if ( !m_currentDocument )
1397  return false;
1398 
1399  wxString cvgStringtoExecute = cvgString;
1400 
1401 #if wxART2D_USE_CVGIO
1402  if ( cvgString.Contains( _T( "<?xml" ) ) && cvgString.Contains( _T( "<cvg" ) ) && cvgString.Contains( _T( "</cvg>" ) ) )
1403  {
1404  //almost certain the user meant to enter a complete valid CVG document
1405  }
1406  else
1407  {
1408  //only partly a valid CVG document, make it complete now
1409  cvgStringtoExecute = _T( "<?xml version=\"1.0\" standalone=\"yes\"?> <cvg classname=\"a2dCanvasDocument\"> " ) + cvgString + _T( " </cvg>" );
1410  }
1411 
1412 #if wxUSE_STD_IOSTREAM
1413 #if wxUSE_UNICODE
1414  a2dDocumentStringInputStream stream( cvgStringtoExecute.mb_str().data(), wxSTD ios_base::in );
1415 #else
1416  a2dDocumentStringInputStream stream( cvgStringtoExecute.mb_str(), wxSTD ios_base::in );
1417 #endif // wxUSE_UNICODE
1418 #else
1419  a2dDocumentStringInputStream stream( cvgStringtoExecute );
1420 #endif
1421  a2dIOHandlerCVGIn CvgString;
1422 
1423  return CvgString.Load( stream, ( a2dDrawing* ) m_currentDocument, GetCanvasDocument()->GetDrawing()->GetRootObject() );
1424 
1425 #else
1426  return false;
1427 #endif //wxART2D_USE_CVGIO
1428 }
1429 
1430 //--------------------- start tool commands ------------------
1431 
1432 bool a2dCentralCanvasCommandProcessor::SetPropertyToObject( const wxString& objectname, const wxString& propertyname, const wxString& value )
1433 {
1434  if ( objectname == _T( "a2dBaseTool" ) )
1435  {
1436  if ( !m_currentDocument )
1437  return false;
1438 
1439  a2dBaseTool* tool = GetActiveTool();
1440 
1441  if ( tool )
1442  return GetDrawingCmdProcessor()->SetOrAddPropertyToObject( tool, propertyname, value, m_withUndo );
1443 
1444  return false;
1445  }
1446  else if ( objectname == _T( "a2dToolContr" ) )
1447  {
1448  if ( !m_currentDocument )
1449  return false;
1450 
1452  if ( drawer )
1453  {
1454  a2dToolContr* contr = drawer->GetCanvasToolContr();
1455  return GetDrawingCmdProcessor()->SetOrAddPropertyToObject( contr, propertyname, value, m_withUndo );
1456  }
1457 
1458  return false;
1459  }
1460  else if ( objectname == _T( "a2dCanvasView" ) )
1461  {
1462  if ( !m_currentDocument )
1463  return false;
1464 
1465  a2dCanvasView* drawer = CheckDrawer();
1466 
1467  if ( drawer )
1468  return SetOrAddPropertyToObject( drawer, propertyname, value, m_withUndo );
1469  else
1470  a2dDocviewGlobals->ReportErrorF( a2dError_NoView, _( "No a2dCanvasView View available" ) );
1471 
1472  return false;
1473  }
1474  else if ( objectname == _T( "a2dCanvasCommandProcessor" ) )
1475  {
1476  if ( !m_currentDocument )
1477  return false;
1478 
1480  }
1481  else if ( objectname == _T( "a2dCentralCanvasCommandProcessor" ) )
1482  {
1483  if ( !m_currentDocument )
1484  return false;
1485 
1486  return SetOrAddPropertyToObject( this, propertyname, value, m_withUndo );
1487  }
1488  return false;
1489 }
1490 
1492 {
1493  //!todo HOW undo menu's work when commands endsup on this commandprocessor its commandstack.
1494 
1495  //for the moment command are submitted to the object which is related to the document.
1496  //e.g. a2dCanvasView is clearly showing a document.
1497 
1498  if ( objectname == _T( "a2dBaseTool" ) )
1499  {
1500  if ( !m_currentDocument )
1501  return false;
1502 
1503  a2dBaseTool* tool = GetActiveTool();
1504 
1505  if ( tool )
1506  return SetOrAddPropertyToObject( tool, property, m_withUndo );
1507 
1508  return false;
1509  }
1510  else if ( objectname == _T( "a2dToolContr" ) )
1511  {
1512  if ( !m_currentDocument )
1513  return false;
1514 
1516  if ( drawer )
1517  {
1518  a2dToolContr* contr = drawer->GetCanvasToolContr();
1519  return SetOrAddPropertyToObject( contr, property, m_withUndo );
1520  }
1521 
1522  return false;
1523  }
1524  else if ( objectname == _T( "a2dCanvasView" ) )
1525  {
1526  if ( !m_currentDocument )
1527  return false;
1528 
1529  a2dCanvasView* drawer = CheckDrawer();
1530 
1531  if ( drawer )
1532  return SetOrAddPropertyToObject( drawer, property, m_withUndo );
1533  else
1534  a2dDocviewGlobals->ReportErrorF( a2dError_NoView, _( "No a2dCanvasView View available" ) );
1535 
1536  return false;
1537  }
1538  else if ( objectname == _T( "a2dCanvasCommandProcessor" ) )
1539  {
1540  if ( !m_currentDocument )
1541  return false;
1542 
1544  }
1545  else if ( objectname == _T( "a2dCentralCanvasCommandProcessor" ) )
1546  {
1547  if ( !m_currentDocument )
1548  return false;
1549 
1550  return SetOrAddPropertyToObject( this, property, m_withUndo );
1551  }
1552  return false;
1553 }
1554 
1556  const wxString& propertyname,
1557  const wxString& value
1558  )
1559 {
1560  if ( !m_currentDocument )
1561  return false;
1562 
1563  a2dLayers* layers = ( ( a2dCanvasDocument* ) m_currentDocument )->GetLayerSetup();
1564  if ( !layers )
1565  return false;
1566 
1567  a2dLayerInfo* layerinfodoc = layers->GetLayerIndex()[ layer ];
1568 
1569  bool res = GetDrawingCmdProcessor()->SetOrAddPropertyToObject( layerinfodoc, propertyname, value, m_withUndo );
1570 
1571  return res;
1572 }
1573 
1575 {
1577  if ( drawer )
1578  {
1579  a2dToolContr* contr = drawer->GetCanvasToolContr();
1580  return contr->GetFirstTool();
1581  }
1582  return NULL;
1583 }
1584 
1586 {
1588  if ( drawer )
1589  {
1590  a2dToolContr* contr = drawer->GetCanvasToolContr();
1591  if ( contr )
1592  {
1594  contr->PopTool( tool );
1595  if ( ! tool )
1597  return ( a2dBaseTool* ) tool.Get();
1598  }
1600  return NULL;
1601  }
1603  return NULL;
1604 }
1605 
1606 //--------------------- drawer related commands ------------------
1607 
1609 {
1611  if ( drawer )
1612  {
1613  a2dCanvasObject* top = wxStaticCast( drawer->GetDrawing()->GetRootObject()->Find( _T( "" ), _T( "" ), index ), a2dCanvasObject );
1614  if ( !top )
1615  {
1616  a2dDocviewGlobals->ReportErrorF( a2dError_NotSpecified, _T( "No Object with id %d in a2dCentralCanvasCommandProcessor::SetShowObject()" ), index );
1617  return false;
1618  }
1619  drawer->SetShowObject( top );
1620  return true;
1621  }
1622 
1624  return false;
1625 }
1626 
1628 {
1630  if ( !doc )
1631  return;
1632 
1634  a2dCanvasGlobals->GetHabitat()->m_gridX = gridX;
1635  if ( drawer )
1636  {
1637  drawer->SetGridX( double( a2dCanvasGlobals->GetHabitat()->m_gridX ) / doc->GetUnitsScale() );
1638  }
1639 }
1640 
1642 {
1644  if ( !doc )
1645  return;
1646 
1647  a2dCanvasGlobals->GetHabitat()->m_gridY = gridY;
1649  if ( drawer )
1650  {
1651  drawer->SetGridY( double( a2dCanvasGlobals->GetHabitat()->m_gridY ) / doc->GetUnitsScale() );
1652  }
1653 }
1654 
1655 bool a2dCentralCanvasCommandProcessor::Zoom( double x1, double y1, double x2, double y2, bool upp )
1656 {
1658  if ( drawer )
1659  {
1660  drawer->GetDrawing()->GetCanvasCommandProcessor()->Zoom( x1, y1, x2, y2, upp );
1661  return true;
1662  }
1663 
1665  return false;
1666 }
1667 
1669 {
1670  a2dCanvasView* drawer = CheckDrawer();
1671  if ( drawer )
1672  {
1674  return true;
1675  }
1676 
1678  return false;
1679 }
1680 
1682 {
1683  //deactivate the current view if different from the new one.
1684  if ( m_currentView )
1685  {
1686  if ( m_currentView != view || m_currentView->IsClosed() )
1687  {
1688  m_currentView->DisconnectEvent( wxEVT_DO, this );
1689  m_currentView->DisconnectEvent( wxEVT_UNDO, this );
1690  m_currentView->DisconnectEvent( wxEVT_REDO, this );
1691  if ( view )
1692  {
1693  view->ConnectEvent( a2dEVT_COM_EVENT, this );
1694  view->ConnectEvent( wxEVT_DO, this );
1695  view->ConnectEvent( wxEVT_UNDO, this );
1696  view->ConnectEvent( wxEVT_REDO, this );
1697  }
1698  }
1699  // the base sets the new document of which this view is a part
1701 
1703  if ( candoc )
1705  else
1707  }
1708  else if ( view )
1709  {
1710  view->ConnectEvent( a2dEVT_COM_EVENT, this );
1711  view->ConnectEvent( wxEVT_DO, this );
1712  view->ConnectEvent( wxEVT_UNDO, this );
1713  view->ConnectEvent( wxEVT_REDO, this );
1714  // the base sets the new document of which this view is a part
1716 
1718  if ( candoc )
1720  else
1722  }
1723  //wxLogDebug( "view: %p camroot: %p ", view, a2dCameleon::GetCameleonRoot() );
1724 }
1725 
1727 {
1728  if ( !m_currentDocument )
1729  return NULL;
1730 
1731  if ( !GetCurrentView() )
1732  {
1733  return NULL;
1734  }
1735 
1737 }
1738 
1740 {
1741  if ( !m_currentDocument )
1742  return NULL;
1743 
1745 }
1746 
1747 bool a2dCentralCanvasCommandProcessor::IsShownStructureDlg() { return m_structDlgDoc != NULL && m_structDlgDoc->IsShown(); }
1748 
1749 void a2dCentralCanvasCommandProcessor::DeleteDlgs()
1750 {
1751  if ( m_layersdlg )
1752  m_layersdlg->Destroy();
1753 
1754  if ( m_layerOrderDlg )
1755  m_layerOrderDlg->Destroy();
1756 
1757  if ( m_structDlgDoc )
1758  m_structDlgDoc->Destroy();
1759 
1760  m_layersdlg = NULL;
1761  m_layerOrderDlg = NULL;
1762  m_structDlgDoc = NULL;
1763 }
1764 
1766 {
1768  DeleteDlgs();
1769 }
1770 
1771 bool a2dCentralCanvasCommandProcessor::ShowDlg( const a2dCommandId* comID, bool modal, bool onTop )
1772 {
1773  return false;
1774 }
1775 
1777  { a2dCanvasGlobals->GetHabitat()->SetBooleanEngineMarge( marge ); }
1779  { a2dCanvasGlobals->GetHabitat()->SetBooleanEngineGrid( grid ); }
1781  { a2dCanvasGlobals->GetHabitat()->SetBooleanEngineDGrid( dgrid ); }
1783  { a2dCanvasGlobals->GetHabitat()->SetBooleanEngineCorrectionAber( aber ); }
1785  { a2dCanvasGlobals->GetHabitat()->SetBooleanEngineCorrectionFactor( aber ); }
1787  { a2dCanvasGlobals->GetHabitat()->SetBooleanEngineMaxlinemerge( maxline ); }
1789  { a2dCanvasGlobals->GetHabitat()->SetBooleanEngineWindingRule( rule ); }
1791  { a2dCanvasGlobals->GetHabitat()->SetBooleanEngineRoundfactor( roundfac ) ; }
1792 void a2dCentralCanvasCommandProcessor::SetBooleanEngineSmoothAber( const a2dDoMu& aber )
1793  { a2dCanvasGlobals->GetHabitat()->SetBooleanEngineSmoothAber( aber ); }
1794 void a2dCentralCanvasCommandProcessor::SetBooleanEngineLinkHoles( bool doLinkHoles )
1795  { a2dCanvasGlobals->GetHabitat()->SetBooleanEngineLinkHoles( doLinkHoles ); }
1797  { a2dCanvasGlobals->GetHabitat()->SetRadiusMin( radiusMin ); }
1799  { a2dCanvasGlobals->GetHabitat()->SetRadiusMax( radiusMax ) ; }
1801  { a2dCanvasGlobals->GetHabitat()->SetAberPolyToArc( aber ); }
1803  { a2dCanvasGlobals->GetHabitat()->SetAberArcToPoly( aber ); }
1805  { a2dCanvasGlobals->GetHabitat()->SetSmall( smallest ); }
1806 
1807 bool a2dCentralCanvasCommandProcessor::GdsIoSaveTextAsPolygon( bool onOff )
1808  { return a2dCanvasGlobals->GetHabitat()->GdsIoSaveTextAsPolygon( onOff ); }
1809 bool a2dCentralCanvasCommandProcessor::KeyIoSaveTextAsPolygon( bool onOff )
1810  { return a2dCanvasGlobals->GetHabitat()->KeyIoSaveTextAsPolygon( onOff ); }
1811 
1813  { return a2dCanvasGlobals->GetHabitat()->GetRadiusMin(); }
1815  { return a2dCanvasGlobals->GetHabitat()->GetRadiusMax(); }
1817  { return a2dCanvasGlobals->GetHabitat()->GetAberPolyToArc(); }
1819  { return a2dCanvasGlobals->GetHabitat()->GetAberArcToPoly(); }
1821  { return a2dCanvasGlobals->GetHabitat()->GetSmall(); }
1822 
1824  { return a2dCanvasGlobals->GetHabitat()->GetBooleanEngineMarge(); }
1826  { return a2dCanvasGlobals->GetHabitat()->GetBooleanEngineGrid(); }
1828  { return a2dCanvasGlobals->GetHabitat()->GetBooleanEngineDGrid(); }
1830  { return a2dCanvasGlobals->GetHabitat()->GetBooleanEngineCorrectionAber(); }
1832  { return a2dCanvasGlobals->GetHabitat()->GetBooleanEngineCorrectionFactor(); }
1834  { return a2dCanvasGlobals->GetHabitat()->GetBooleanEngineMaxlinemerge(); }
1836  { return a2dCanvasGlobals->GetHabitat()->GetBooleanEngineWindingRule(); }
1838  { return a2dCanvasGlobals->GetHabitat()->GetBooleanEngineRoundfactor(); }
1840  { return a2dCanvasGlobals->GetHabitat()->GetBooleanEngineSmoothAber(); }
1842  { return a2dCanvasGlobals->GetHabitat()->GetBooleanEngineLinkHoles(); }
void SetAllowDoubleClickModifier(bool AllowDoubleClickModifier)
set if double click can be used to switch editingmode using shift key
Display Part of a a2dDrawing, in which a2dCanvasObjects are shown.
Definition: drawer.h:470
a2dBaseTool * GetActiveTool()
returns the current active tool in the current active view
Definition: cancom.cpp:1574
a2dBoundingBox GetVisibleBbox() const
get visible area as a boundingbox in world coordinates
Definition: drawer2d.cpp:433
a2dCircle at x,y, and with radius
Definition: canprim.h:554
wxString AskFile(const wxString &message, const wxString &default_path="", const wxString &default_filename="", const wxString &default_extension="", const wxString &wildcard="*.*", int flags=0, int x=-1, int y=-1)
ask for a file using a file selector.
Definition: doccom.h:294
(In) Visible property that can be added to Docview Objects.
Definition: gen.h:1785
bool GetBooleanEngineLinkHoles() const
boolean engine setting
Definition: cancom.cpp:1841
a2dDoMu m_AberPolyToArc
Polygon/polyline to Arc Maximum abberation.
Definition: canglob.h:1124
#define wxDynamicCast(obj, className)
Define wxDynamicCast so that it will give a compiler error for unrelated types.
Definition: gen.h:75
#define EVT_CHANGED_DOCUMENT(func)
event sent to a2dDocumentCommandProcessor when the current document has changed in the a2dDocumentCom...
Definition: doccom.h:179
bool PushTool(a2dBaseTool *tool)
specialize to keep first tool on the stack active
Definition: sttool.cpp:451
The a2dBaseTool is used to derive tools from that are controlled by.
Definition: tools.h:379
virtual bool CanUndo() const
Are there commands to undo and can they be undone ?
Definition: comevt.cpp:967
static void SetAberPolyToArc(double aber)
conversion from polygon/polyline into arc in database units
Definition: artglob.h:158
void SetLayer(wxUint16 layer, bool setStyleOfLayer=false)
Definition: canglob.cpp:1076
a2dCanvasCommandProcessor * GetDrawingCmdProcessor()
get commandprocessor of document
Definition: cancom.h:240
void SetLineEnd(a2dCanvasObject *end)
set current line end object for line and polyline.
Definition: canglob.h:838
bool Zoom(double x1, double y1, double x2, double y2, bool upp)
zoom into this area
Definition: cancom.cpp:1655
View on a a2dCanvasDocument.
Definition: candoc.h:212
a2dCanvasObject * GetCanvasObject()
Pointer to object selected.
Definition: strucdlg.cpp:373
const a2dDoMu & GetRadiusMin() const
Polygon/polyline to Arc Minimum radius to test.
Definition: cancom.cpp:1812
void SetBooleanEngineGrid(long grid)
boolean engine setting
Definition: cancom.cpp:1778
const a2dError a2dError_CouldNotEvaluatePath
virtual void SetCurrentView(a2dView *view)
To set the curent view.
Definition: doccom.cpp:2095
a2dCanvasObject * GetRootObject() const
get the root object, which holds the objects in the document
Definition: drawing.h:521
bool Zoom(double x1, double y1, double x2, double y2, bool upp)
Zoom to this rectangle, or Upp at x1, y1.
Definition: drawing.cpp:6123
void OnMenu(wxCommandEvent &event)
All menu&#39;s a2dMenuIdItem using can be intercepted here.
Definition: cancom.cpp:444
bool GetBooleanEngineWindingRule() const
boolean engine setting
Definition: cancom.cpp:1835
void SetBooleanEngineCorrectionFactor(const a2dDoMu &aber)
boolean engine setting
Definition: cancom.cpp:1784
void SetBooleanEngineCorrectionFactor(const a2dDoMu &aber)
boolean engine setting
Definition: canglob.h:696
double wxGetDoubleNumberFromUser(const wxString &message, const wxString &prompt, const wxString &caption, double value=0, double min=0, double max=100, wxWindow *parent=(wxWindow *) NULL, const wxPoint &pos=wxDefaultPosition)
get Double from user
Definition: drawing.cpp:11371
void SetOneShot()
Only one action of the tool, after that it will ask the controller to stop this tool.
Definition: tools.h:430
virtual bool Update(UpdateMode mode)
Update the state of the object according to its current position etc.
Definition: canobj.cpp:5149
void ConnectEvent(wxEventType type, wxEvtHandler *eventSink)
Definition: gen.cpp:876
double GetUnitsScale()
this is the number that defines the physical dimension in meters / inch/ etc.
Definition: candoc.h:601
see a2dCommandEvent
Definition: doccom.h:79
const a2dError a2dError_FileCouldNotOpen
const a2dDoMu & GetBooleanEngineMaxlinemerge() const
boolean engine setting
Definition: cancom.cpp:1833
bool SetPropertyToObject(const wxString &objectname, const wxString &propertyname, const wxString &value=wxT(""))
To set a property by to a certain object.
Definition: cancom.cpp:1432
a2dDoMu m_AberArcToPoly
Arc to Polygon/polyline Maximum abberation.
Definition: canglob.h:1126
Path searching.
Definition: gen.h:2926
a command processor specially designed to work with a a2dCanvasDocument
Definition: drawing.h:1046
void SetBooleanEngineMaxlinemerge(const a2dDoMu &maxline)
boolean engine setting
Definition: cancom.cpp:1786
bool GetYaxis() const
get y axis orientation
Definition: drawer2d.h:280
const a2dError a2dError_NoTool
a2dGlobal * a2dGlobals
global a2dCanvasGlobal to have easy access to global settings
Definition: artglob.cpp:34
a2dDrawing * GetDrawing() const
get the root object, which holds the objects in the document.
Definition: candoc.h:418
bool ProcessEvent(wxEvent &event)
reroutes events to the current active drawingPart when not handled here.
Definition: cancom.cpp:315
void SetSmall(const a2dDoMu &smallest)
detection of small object, smaller than this
Definition: cancom.cpp:1804
static const a2dCommandId COMID_PushTool_DrawRectangleFast
push this tool on the tools stack
Definition: sttool2.h:324
const a2dDocumentTemplateList & GetDocTemplates()
returns a reference to the a2dDocumentTemplateList, which contains all a2dDocumentTemplate&#39;s.
Definition: doccom.h:782
void SetBorder(wxUint16 border, bool percentual=true)
leafs a border of this amount of pixels around the drawing
Definition: imageioh.cpp:195
object to show several appearance views on what it contains
Definition: cameleon.h:630
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
a2dCanvasView * CheckDrawer() const
is a view with a2dCanvasView active
Definition: cancom.cpp:1726
a2dCanvasObject * GetCanvasObject()
Pointer to object selected.
wxUint16 m_target
target layer in operations
Definition: canglob.h:1088
a2dLayers * GetLayerSetup()
Get the layersettings for the canvas.
Definition: candoc.h:555
a2dLayers * GetLayerSetup()
Get the layersettings for the canvas.
Definition: drawing.h:506
void OnBusyBegin(a2dCommandProcessorEvent &event)
do this at command start
Definition: cancom.cpp:1167
bool SaveLayers(const wxString &filename)
save layer object to CVG file
Definition: layerinf.cpp:615
const a2dDoMu & GetSmall() const
detection of small object, smaller than this
Definition: cancom.cpp:1820
~a2dCentralCanvasCommandProcessor()
destructor
Definition: cancom.cpp:299
double GetBooleanEngineRoundfactor() const
boolean engine setting
Definition: canglob.h:753
store and convert number to number with unit and visa versa. e.g. 1.23e-6 =&gt; 1.23 * 1e-6 ...
Definition: artglob.h:208
a2dDocumentOutputStream & SaveObject(a2dDocumentOutputStream &stream, a2dIOHandlerStrOut *handler)
save as the a2dCanvas specific XML called CVG format
Definition: candoc.cpp:1068
a2dDrawingPart * GetActiveDrawingPart()
return the currently/last active drawing part.
Definition: canglob.h:1262
void SetGridY(const a2dDoMu &gridY)
grid setting Y
Definition: cancom.cpp:1641
const a2dError a2dError_CanceledFileDialog
const a2dDoMu & GetRadiusMin() const
Polygon/polyline to Arc Minimum radius to test.
Definition: canglob.h:723
virtual void Update(unsigned int hint=0, wxObject *hintObject=NULL)
force a2dDocumentEvent ::wxEVT_UPDATE_VIEWS event
void SetBooleanEngineDGrid(double dgrid)
boolean engine setting
Definition: cancom.cpp:1780
void SetAberArcToPoly(const a2dDoMu &aber)
Arc to Polygon/polyline Maximum abberation.
Definition: cancom.cpp:1802
bool IsClosed()
A closed flag is set when a view is closed.
Definition: docviewref.h:1829
const a2dDoMu & GetRadiusMax() const
Polygon/polyline to Arc Maximum radius to test.
Definition: cancom.cpp:1814
const a2dDoMu & GetAberArcToPoly() const
Arc to Polygon/polyline Maximum abberation.
Definition: cancom.cpp:1818
Holds a view on a a2dDocument.
Definition: docviewref.h:1804
const a2dDoMu & GetBooleanEngineCorrectionAber() const
boolean engine setting
Definition: canglob.h:745
void SetGridX(double gridx)
Set grid distance in X.
Definition: drawer.h:896
wxUint16 m_layer
layer to be set for new objects
Definition: canglob.h:1151
void SetBooleanEngineCorrectionAber(const a2dDoMu &aber)
boolean engine setting
Definition: canglob.h:694
void SetBooleanEngineMarge(const a2dDoMu &marge)
boolean engine setting
Definition: cancom.cpp:1776
static const a2dCanvasObjectFlagsMask normalized
Definition: candefs.h:217
a2dText is an abstract base class.
Definition: cantext.h:93
#define EVT_BEGINBUSY(func)
event sent from a2DocumentCommandProcessor when a command submit/execute is starting ...
Definition: comevt.h:806
a2dCanvasDocument * GetCanvasDocument()
return current document in the command processor
Definition: cancom.h:147
void SetYaxis(bool up)
set if the Yaxis goes up or down
Definition: imageioh.h:151
Export view as ViewAsSvg.
Definition: cancom.h:576
const a2dError a2dError_SaveFile
void SetRadiusMax(const a2dDoMu &radiusMax)
Polygon/polyline to Arc Maximum radius to test.
Definition: canglob.h:708
double GetUnitsScaleOfDocument()
Get UnitScale of current document if set else returns 1.
Definition: cancom.cpp:1195
virtual void ReportError(const a2dError &error, const wxString &errorstr=wxEmptyString)
concatenate to the the error report the given error.
Definition: comevt.cpp:1221
a2dCanvasDocument * CheckCanvasDocument() const
is a view with a2dCanvasView active and does it have a document
Definition: cancom.cpp:1739
virtual bool ProcessEvent(wxEvent &event)
Definition: doccom.cpp:2309
static void SetAberArcToPoly(double aber)
conversion from arc into lines in database units
Definition: artglob.h:164
The a2dStToolContr is a Tool Controller specialized for working with a2dCanvasView.
Definition: sttool.h:485
void OnBusyEnd(a2dCommandProcessorEvent &event)
do this at command end
Definition: cancom.cpp:1175
One object of this class may be created in an application, to manage all the templates and documents...
Definition: doccom.h:242
void SetCurrentView(a2dView *view)
besides calling the base class, its connect to Current view (active or not) for some events ...
Definition: cancom.cpp:1681
bool SubmitToDrawing(a2dCommand *command, bool storeIt=true)
Submit a command to the active drawing.
Definition: cancom.cpp:1004
Export view as image.
Definition: cancom.h:482
virtual bool CanRedo() const
Are there commands to redo and can they be redone ?
Definition: comevt.cpp:974
#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
a2dCanvasObject * GetShowObject() const
return pointer of then currently shown object on the drawer.
Definition: drawer.h:680
void SetSpecificFlags(bool setOrClear, a2dCanvasObjectFlagsMask which)
set all bit flags in object that or true in mask to true or false
Definition: canobj.cpp:2645
void SetDlgOrEditModal(bool dlgOrEditModal)
set style dlg as modal
Definition: mastertool.h:237
a2dDocument * GetCurrentDocument() const
Get the current Document, which is the document that was last accessed from a view.
Definition: doccom.cpp:1582
void SetActiveDrawingPart(a2dDrawingPart *part)
get the drawing part that has the focus/is active in a window.
Definition: canglob.cpp:1220
void SetTarget(wxUint16 target)
set target layer in operation
Definition: canglob.cpp:1088
wxStringInputStream a2dDocumentStringInputStream
string input stream based wxStreams
Definition: gen.h:3452
bool Load(a2dDocumentStringInputStream &stream, a2dDrawing *doc, a2dCanvasObject *parent)
reading a CVG document and add the contents as children to a given a2dCanvasObject parent...
Definition: xmlpars.cpp:146
a2dCentralCanvasCommandProcessor(long flags=a2dDEFAULT_DOCUMENT_FLAGS, bool initialize=true, int maxCommands=-1)
Input and output handler for a2dCanvasDocument to/from a wxImage.
Definition: imageioh.h:97
a2dBaseTool * PopTool()
pop a tool from the tool stack of the current active a2dCanvasView
Definition: cancom.cpp:1585
a2dDrawer2D * GetDrawer2D()
get the internal m_drawer2D that is used for rendering the document
Definition: drawer.h:1125
void SetBooleanEngineDGrid(double dgrid)
boolean engine setting
Definition: canglob.h:692
contains the layer properties for one layer,
Definition: layerinf.h:41
void SetBooleanEngineMaxlinemerge(const a2dDoMu &maxline)
boolean engine setting
Definition: canglob.h:698
void SetNormalizeScale(double scale)
see GetNormalizeScale()
Definition: candoc.h:621
void SetBooleanEngineRoundfactor(double roundfac)
boolean engine setting
Definition: canglob.h:702
bool LoadLayers(a2dDocumentInputStream &stream, a2dLayers *layers)
load a layer definition from a CVG file.
Definition: xmlpars.cpp:93
void SetShowObject(a2dCanvasObject *showObject)
document will be rendered as seen from this object, if NULL, the root of the document will be used...
Definition: imageioh.h:113
a2dArrow is used for having line begin and ends on specific objects.
Definition: canprim.h:198
void SetAberPolyToArc(const a2dDoMu &aber)
Polygon/polyline to Arc Maximum abberation.
Definition: cancom.cpp:1800
void Refresh()
refresh what is documents and shown on views
Definition: cancom.cpp:1015
Each a2dCommand is given a command id at construction.
Definition: comevt.h:99
void SetBooleanEngineRoundfactor(double roundfac)
boolean engine setting
Definition: cancom.cpp:1790
bool GetBooleanEngineWindingRule() const
boolean engine setting
Definition: canglob.h:751
virtual bool Submit(a2dCommand *command, bool storeIt=true)
next to the base class submit, it sets a2DocumentCommandProcessor for a2dCommand
Definition: comevt.cpp:842
a2dView * m_currentView
the current view (active or inactive)
Definition: doccom.h:977
a2dView * GetCurrentView() const
return the one that is active right now (e.g. has focus in case of a wxWindow), or NULL ...
Definition: doccom.cpp:1185
const a2dDoMu & GetBooleanEngineCorrectionAber() const
boolean engine setting
Definition: cancom.cpp:1829
a2dDoMu m_gridY
canvas default grid in Y
Definition: canglob.h:1133
bool SetLayerProperty(long layer, const wxString &propertyname, const wxString &value)
set a layer property via command &quot;setlayerproperty&quot;
Definition: cancom.cpp:1555
bool SetShowObject(int index)
set show object using index of child
Definition: cancom.cpp:1608
const a2dDoMu & GetBooleanEngineSmoothAber() const
boolean engine setting
Definition: cancom.cpp:1839
Dialog for displaying/editing layers and properties of layers.
Definition: layerdlg.h:30
a2dDocumentList m_docs
list of all that are open
Definition: doccom.h:968
Interactive Insertion of an text object with a wxURI Object.
Definition: edsttool.h:39
a2dWalker based algorithms
a2dCanvasObject * AddCurrent(a2dCanvasObject *objectToAdd, bool withUndo=false, a2dPropertyIdList *setStyles=NULL, a2dCanvasObject *parentObject=NULL)
add the current canvas object to parent as child
Definition: drawing.cpp:6290
All updates of these modes force an update (e.g. update non-pending valid bounding boxes) ...
Definition: canobj.h:1107
a2dCommandProcessor * GetCommandProcessor() const
Returns a pointer to the command processor associated with this document.
Definition: drawing.h:549
bool Update()
force an update of information on the currently active view
Definition: cancom.cpp:1668
void SetRadiusMin(const a2dDoMu &radiusMin)
Polygon/polyline to Arc Minimum radius to test.
Definition: canglob.h:706
a2dDocviewGlobal * a2dDocviewGlobals
a global pointer to get to global instance of important classes.
Definition: doccom.cpp:2348
Output driver for KEY files.
Definition: keyio.h:175
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
const a2dDoMu & GetBooleanEngineCorrectionFactor() const
boolean engine setting
Definition: canglob.h:747
void SetGridY(double gridy)
Set grid distance in Y.
Definition: drawer.h:902
void SetBooleanEngineGrid(long grid)
boolean engine setting
Definition: canglob.h:690
const a2dDoMu & GetAberPolyToArc() const
Polygon/polyline to Arc Maximum abberation.
Definition: cancom.cpp:1816
const a2dDoMu & GetSmall() const
detection of small object, smaller than this
Definition: canglob.h:731
const a2dDoMu & GetBooleanEngineMarge() const
boolean engine setting
Definition: canglob.h:739
bool FileExport(const wxFileName &file=wxFileName(wxT("")), const wxString &description=wxT(""), a2dDocumentFlagMask flags=a2dREFDOC_NON)
Calls a2dDocument::Export for the current document.
Definition: doccom.cpp:789
void Init(a2dLayers *layersetup)
initialize with this layer setup
Definition: orderdlg.cpp:117
const a2dError a2dError_NoView
virtual bool SetOrAddPropertyToObject(a2dObject *propRefObject, const wxString &name, const wxString &value=wxT(""), bool withUndo=true)
set a named property to the given object
Definition: comevt.cpp:1066
a2dCanvasObject * AddCurrent(a2dCanvasObject *objectToAdd, bool withUndo=false, a2dPropertyIdList *setStyles=NULL, a2dCanvasObject *parentObject=NULL)
add the current canvas object to parent as child
Definition: cancom.cpp:1284
void SetBooleanEngineCorrectionAber(const a2dDoMu &aber)
boolean engine setting
Definition: cancom.cpp:1782
void SetBooleanEngineWindingRule(bool rule)
boolean engine setting
Definition: cancom.cpp:1788
a2dLayers * GetLayerSetup()
Get the central layersettings for the canvas library.
Definition: canglob.h:478
Each a2dCanvasView needs to have a a2dCanvasDocument set in order to render data. ...
Definition: candoc.h:374
bool SaveViewAsImage(a2dCanvasDocument *doc, const wxString &file, wxBitmapType type, a2dCanvasObject *from)
Save current view as an image of the given type.
Definition: cancom.cpp:1028
virtual void OnExit()
cleaup modeless dialogs created from here
Definition: cancom.cpp:1765
double GetBooleanEngineDGrid() const
boolean engine setting
Definition: canglob.h:743
void SetAberPolyToArc(const a2dDoMu &aber)
Polygon/polyline to Arc Maximum abberation.
Definition: canglob.cpp:815
a2dCanvasCommandProcessor * GetCanvasCommandProcessor()
get a pointer to the command processor
Definition: drawing.cpp:375
void SetBooleanEngineMarge(const a2dDoMu &marge)
boolean engine setting
Definition: canglob.h:688
long GetBooleanEngineGrid() const
boolean engine setting
Definition: canglob.h:741
Output driver for GDSII files.
Definition: gdsio.h:347
a2dCanvasObject * SetShowObject(const wxString &name)
set object available in the a2dDrawing to be shown on the drawer
Definition: drawer.cpp:2947
void SetDlgOrEdit(bool dlgOrEdit)
set dlg at Double Left Down if dlgOrEdit == true
Definition: mastertool.h:231
const a2dDoMu & GetBooleanEngineCorrectionFactor() const
boolean engine setting
Definition: cancom.cpp:1831
a2dBaseTool * GetFirstTool() const
get currently used eventhandler (always the first in the list)
Definition: tools.cpp:91
void SetPosXY(double x, double y, bool restrict=false)
set position to x,y
Definition: canobj.cpp:1624
virtual void ReportErrorF(const a2dError &error, const wxChar *Format,...)
concatenate to the the error report the given error.
Definition: comevt.cpp:1312
#define EVT_ENDBUSY(func)
event sent from a2DocumentCommandProcessor when a command submit/execute is ending ...
Definition: comevt.h:808
void SetLineBegin(a2dCanvasObject *begin)
set current line begin object for line and polyline.
Definition: canglob.h:835
const a2dDoMu & GetBooleanEngineSmoothAber() const
boolean engine setting
Definition: canglob.h:755
const a2dDoMu & GetRadiusMax() const
Polygon/polyline to Arc Maximum radius to test.
Definition: canglob.h:725
void SetSmall(const a2dDoMu &smallest)
detection of small object, smaller than this
Definition: canglob.cpp:827
Event sent to a2dCommandProcessor.
Definition: comevt.h:701
bool m_withUndo
if set, for commands which can undo, will be submitted like that.
Definition: doccom.h:998
const a2dError a2dError_NotSpecified
command to show a dialog
Definition: cancom.h:762
a2dDocumentCommandProcessor * GetDocviewCommandProcessor() const
Gets a2dDocumentCommandProcessor pointer.
Definition: doccom.h:1034
const a2dDoMu & GetBooleanEngineMarge() const
boolean engine setting
Definition: cancom.cpp:1823
a2dRect
Definition: canprim.h:440
void SendToLogTarget()
all stored errors and warning are sent to log target using wxLogError()
Definition: comevt.cpp:1367
void Init(a2dCanvasObjectList *objects)
take over object to show from objects
stack based tools controller and tools for drawing and editing.
all polygon and polyline a2dCanvasObject are here.
a2dDrawing * GetDrawing() const
get drawing via top object
Definition: drawer.cpp:726
wxString GetAsString()
Get all search paths as one string.
Definition: gen.cpp:4470
#define const_forEachIn(listtype, list)
easy const iteration for a2dlist
Definition: a2dlist.h:118
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
a2dCanvasGlobal * a2dCanvasGlobals
global a2dCanvasGlobal to have easy access to global settings
Definition: canglob.cpp:1234
a2dLibraryReference is a symbol object, it holds a reference
Definition: recur.h:215
bool GetBooleanEngineLinkHoles() const
boolean engine setting
Definition: canglob.h:757
a command wrapper specially designed to work with wxArt2D docview classes and rest.
Definition: cancom.h:100
double GetBooleanEngineRoundfactor() const
boolean engine setting
Definition: cancom.cpp:1837
The a2dToolContr is the base class for Tool controller classes.
Definition: tools.h:87
long GetBooleanEngineGrid() const
boolean engine setting
Definition: cancom.cpp:1825
virtual void ResetErrors()
reset the error report to empty.
Definition: comevt.cpp:1206
a2dDoMu m_gridX
canvas default grid in X
Definition: canglob.h:1131
all headers in the editor module
static const a2dCanvasObjectFlagsMask ALL
Definition: candefs.h:220
void SetBooleanEngineWindingRule(bool rule)
boolean engine setting
Definition: canglob.h:700
const a2dDoMu & GetAberPolyToArc() const
Polygon/polyline to Arc Maximum abberation.
Definition: canglob.h:727
a2dCanvasObject * Find(const wxString &objectname, const wxString &classname=wxT(""), a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL, const a2dPropertyId *propid=NULL, const wxString &valueAsString=wxT(""), wxUint32 id=0) const
return the object which fits the filter.
Definition: canobj.cpp:4505
int CollectObjects(a2dCanvasObjectList *total, const wxString &classname=wxT(""), a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL, const a2dPropertyId *id=0, const a2dBoundingBox &bbox=wxNonValidBbox) const
Copy objects with the right conditions to the total list.
Definition: canobj.cpp:4495
const a2dError a2dError_NoController
static void SetCameleonRoot(a2dCanvasObject *cameleonRoot)
set the root where all a2dCameleon&#39;s are stored
Definition: cameleon.h:714
void Append(a2dCanvasObject *obj)
append a a2dCanvasObject to the childobjects
Definition: canobj.cpp:6224
void SetRadiusMin(const a2dDoMu &radiusMin)
Polygon/polyline to Arc Minimum radius to test.
Definition: cancom.cpp:1796
const a2dDoMu & GetAberArcToPoly() const
Arc to Polygon/polyline Maximum abberation.
Definition: canglob.h:729
const a2dDoMu & GetBooleanEngineMaxlinemerge() const
boolean engine setting
Definition: canglob.h:749
double GetBooleanEngineDGrid() const
boolean engine setting
Definition: cancom.cpp:1827
bool DisconnectEvent(wxEventType type, wxEvtHandler *eventSink)
Definition: gen.cpp:902
void SetRadiusMax(const a2dDoMu &radiusMax)
Polygon/polyline to Arc Maximum radius to test.
Definition: cancom.cpp:1798
Interactive follow link.
Definition: edsttool.h:84
Contain one drawing as hierarchical tree of a2dCanvasObject&#39;s.
Definition: drawing.h:434
a2dDocument * m_currentDocument
the current active document
Definition: doccom.h:980
void SetFill(const a2dFill &fill)
Set a fill for the object which will be used instead of the layer fill.
Definition: canobj.cpp:2874
void SetLayerSetup(a2dLayers *layersetup)
set the layersettings for the canvas.
Definition: candoc.cpp:780
void SetGridX(const a2dDoMu &gridX)
grid setting X
Definition: cancom.cpp:1627
void SetAberArcToPoly(const a2dDoMu &aber)
Arc to Polygon/polyline Maximum abberation.
Definition: canglob.cpp:821
general canvas module declarations and classes
virtual bool PopTool(a2dBaseToolPtr &poped, bool force=true)
remove first tool on the tool stack
Definition: tools.cpp:364
void SetViewRectangle(double minx, double miny, double maxx, double maxy)
Give the virtual size to be rendered to an image.
Definition: imageioh.cpp:190
a base command for the a2dCommandProcessor
Definition: comevt.h:140
cancom.cpp Source File -- Sun Oct 12 2014 17:04:13 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation