wxArt2D
luawrap.cpp
1 /*! \file luawrap/src/luawrap.cpp
2  \author Klaas Holwerda
3 
4  Copyright: 2001-2004 (c) Klaas Holwerda
5 
6  Licence: wxWidgets Licence
7 
8  RCS-ID: $Id: luawrap.cpp,v 1.64 2009/09/26 19:01:08 titato Exp $
9 */
10 
11 #include "a2dprec.h"
12 
13 #ifdef __BORLANDC__
14 #pragma hdrstop
15 #endif
16 
17 #ifndef WX_PRECOMP
18 #include "wx/wx.h"
19 #endif
20 
21 #include "wx/luawraps/luawrap.h"
22 #include "wx/canvas/objlist.h"
23 #include "wx/editor/candoc.h"
24 #include "wx/canvas/drawer.h"
25 #include "wx/editor/editmod.h"
26 
27 #include "wxbind/include/wxbinddefs.h"
28 #include "wxbind/include/wxcore_bind.h"
29 #include "wxlua/wxlstate.h"
30 #include "wxlua/wxlbind.h"
31 
32 #include "wx/luawraps/luabind.h"
33 
34 //----------------------------------------------------------------------------
35 // a2dCanvasObjectLua
36 //----------------------------------------------------------------------------
37 IMPLEMENT_DYNAMIC_CLASS( a2dCanvasObjectLua, a2dCanvasObject )
38 
39 BEGIN_EVENT_TABLE( a2dCanvasObjectLua, a2dCanvasObject )
40 END_EVENT_TABLE()
41 
42 a2dCanvasObjectLua::a2dCanvasObjectLua( double x, double y, const wxString& script, const wxString& function ): a2dCanvasObject()
43 {
44  m_function = function;
45  m_script = script;
46  m_lworld.Translate( x, y );
47  m_xoffset = 0;
48  m_yoffset = 0;
49  m_run = false;
50 }
51 
53 {
54 }
55 
56 a2dCanvasObjectLua::a2dCanvasObjectLua( const a2dCanvasObjectLua& other, CloneOptions options, a2dRefMap* refs )
57  : a2dCanvasObject( other, options, refs )
58 {
59 }
60 
62 
63 {
64  return new a2dCanvasObjectLua( *this, options, refs );
65 }
66 
67 void a2dCanvasObjectLua::SetField( wxLuaState lst, const wxString& name, const wxString& value )
68 {
69  lst.lua_PushString( name );
70  lst.lua_PushString( value );
71  lst.lua_SetTable( -3 );
72 }
73 
74 void a2dCanvasObjectLua::SetField( wxLuaState lst, const wxString& name, double value )
75 {
76  lst.lua_PushString( name );
77  lst.lua_PushNumber( value );
78 
79  lst.lua_SetTable( -3 );
80 }
81 
82 void a2dCanvasObjectLua::SetField( wxLuaState lst, const wxString& name, long value )
83 {
84  lst.lua_PushString( name );
85  lst.lua_PushInteger( value );
86  lst.lua_SetTable( -3 );
87 }
88 
89 void a2dCanvasObjectLua::SetField( wxLuaState lst, const wxString& name, bool value )
90 {
91  lst.lua_PushString( name );
92  lst.lua_PushBoolean( value );
93  lst.lua_SetTable( -3 );
94 }
95 
96 void a2dCanvasObjectLua::SetField( wxLuaState lst, const wxString& name, wxColour value )
97 {
98  lst.lua_PushString( name );
99 
100  wxColour* returns = new wxColour( value );
101  // add the new object to the tracked memory list
102  wxluaO_addgcobject( lst.GetLuaState(), returns, wxluatype_TSTRING );
103  // push the result datatype
104  wxluaT_pushuserdatatype( lst.GetLuaState(), returns, wxluatype_wxColour );
105  lst.lua_SetTable( -3 );
106 }
107 
108 bool a2dCanvasObjectLua::DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox )
109 {
110  if ( !m_run )
111  {
112  m_run = true;
113 
114  wxLuaState lst = a2dLuaWP->GetLuaState();
115  lua_State* L = lst.GetLuaState();
116  if ( 0 != lst.RunString( m_script ) )
117  {
118  wxLogWarning( _( "Error in Lua Script" ) );
119  }
120  else
121  {
122  lua_getglobal( L, wx2lua( m_function ) );
123  lst.wxluaT_PushUserDataType( this, wxluatype_a2dCanvasObject, true );
124 
125  lst.lua_PushNumber( m_xoffset );
126  lst.lua_PushNumber( m_yoffset );
127 
128  lst.lua_NewTable();
129 
130  a2dNamedPropertyList allprops;
131  CollectProperties2( &allprops, NULL );
132  a2dNamedPropertyList::const_iterator iter;
133  for( iter = allprops.begin(); iter != allprops.end(); ++iter )
134  {
135  const a2dNamedProperty* prop = *iter;
136  if ( wxDynamicCast( prop, a2dInt32Property ) != 0 )
137  SetField( lst, prop->GetName(), ( long ) prop->GetInt32() );
138  else if ( wxDynamicCast( prop, a2dInt16Property ) != 0 )
139  SetField( lst, prop->GetName(), ( long ) prop->GetInt16() );
140  else if ( wxDynamicCast( prop, a2dUint32Property ) != 0 )
141  SetField( lst, prop->GetName(), ( long ) prop->GetUint32() );
142  else if ( wxDynamicCast( prop, a2dUint16Property ) != 0 )
143  SetField( lst, prop->GetName(), ( long ) prop->GetUint16() );
144  else if ( wxDynamicCast( prop, a2dDoubleProperty ) != 0 )
145  SetField( lst, prop->GetName(), prop->GetDouble() );
146  else if ( wxDynamicCast( prop, a2dFloatProperty ) != 0 )
147  SetField( lst, prop->GetName(), prop->GetFloat() );
148  else if ( wxDynamicCast( prop, a2dBoolProperty ) != 0 )
149  SetField( lst, prop->GetName(), prop->GetBool() );
150  else if ( wxDynamicCast( prop, a2dStringProperty ) != 0 )
151  SetField( lst, prop->GetName(), prop->GetString() );
152  else if ( wxDynamicCast( prop, a2dColourProperty ) != 0 )
153  {
155  SetField( lst, prop->GetName(), p->GetColour() );
156  }
157  }
158 
159  //SetField( lst, wxT("maxY"), 800.0 );
160  //SetField( lst, wxT("maxX"), 70 );
161 
162  //if ( lst.LuaPCall( 4, 0 ) != 0 )
163  if ( lst.lua_PCall( 4, 0, 0 ) != 0 )
164  {
165  wxString error;
166  error.Printf( wxT( "%s %s" ), m_function.c_str() , lua_tostring( L, -1 ) );
167  wxLuaEvent event( wxEVT_LUA_ERROR, lst.GetId(), lst );
168  event.SetString( error );
169  lst.SendEvent( event );
170  lua_pop( L, 1 );
171  }
172  SetRoot( m_root );
173  //childbox.SetValid(false);
174  }
175  return true;
176  }
177  return false;
178 }
179 
181 {
182 }
183 
184 #if wxART2D_USE_CVGIO
185 void a2dCanvasObjectLua::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
186 {
187  a2dCanvasObject::DoSave( parent, out, xmlparts, towrite );
188  if ( xmlparts == a2dXmlSer_attrib )
189  {
190  }
191  else
192  {
193  }
194 }
195 
196 void a2dCanvasObjectLua::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
197 {
198  a2dCanvasObject::DoLoad( parent, parser, xmlparts );
199  if ( xmlparts == a2dXmlSer_attrib )
200  {
201  }
202  else
203  {
204  }
205 }
206 #endif //wxART2D_USE_CVGIO
207 
208 
209 //----------------------------------------------------------------------------
210 // a2dLuaCentralCommandProcessor
211 //----------------------------------------------------------------------------
212 
214 
215 a2dLuaCentralCommandProcessor* a2dGetLuaWP()
216 {
217  return a2dLuaWP;
218 }
219 
221 {
222  return m_luaExecDlg != NULL && m_luaExecDlg->IsShown();
223 }
224 
226 
227 const a2dCommandId a2dLuaCentralCommandProcessor::COMID_ShowLuaExecDlg( wxT( "ShowLuaExecDlg" ) );
228 
229 a2dLuaCentralCommandProcessor::a2dLuaCentralCommandProcessor( long flags , bool initialize, int maxCommands )
230  : a2dCentralCanvasCommandProcessor( flags, initialize, maxCommands )
231 {
232  //m_listOfIdforAddPrims.push_back( ( a2dPropertyId* ) &a2dCanvasObject::PROPID_Layer );
233 
234  // intitialize the global commandprocessor, must be done just before the interpreter is initialized,
235  // since it uses this pointer.
236  a2dLuaWP = this;
237 
238  m_interp = wxLuaState( wxTheApp, wxID_ANY );
239 
240  m_interp.SetEventHandler( wxTheApp );
241 
242  m_luaExecDlg = NULL;
243 
244  //RunBuffer(plotto_lua, plotto_lua_len-1, wxT("plotto.lua"));
245 }
246 
248 {
249  if ( m_luaExecDlg )
250  m_luaExecDlg->Destroy();
251 
252  m_luaExecDlg = NULL;
253 
254  m_interp.CloseLuaState( true );
255  m_interp.Destroy();
256 
257 }
258 
260 {
261  if ( m_luaExecDlg )
262  m_luaExecDlg->Destroy();
263 
264  m_luaExecDlg = NULL;
266 }
267 
268 bool a2dLuaCentralCommandProcessor::ExecuteF( bool withUndo, wxChar* Format, ... )
269 {
270  va_list ap;
271 
272  wxString commands;
273  va_start( ap, Format );
274 
275  commands.PrintfV( Format, ap );
276  va_end( ap );
277 
278  return Execute( commands, withUndo );
279 }
280 
281 
282 bool a2dLuaCentralCommandProcessor::Execute( const wxString& commandsString, bool withUndo )
283 {
284  bool oldlog = a2dDocviewGlobals->GetDoLog();
285  if ( oldlog )
286  a2dDocviewGlobals->SetDoLog( false );
287 
288  a2dDocviewGlobals->SetDoLog( oldlog );
289  // Run a string that contains lua code
290  if ( 0 != m_interp.RunString( commandsString ) )
291  {
292  if ( !a2dDocviewGlobals->GetErrors().empty() )
293  wxLogWarning( _( "Error in Lua Command: %s \n" ), commandsString.c_str() );
294 
295  //a2dDocviewGlobals->RecordF( NULL, wxT( "%s" ), commandsString.c_str() );
296  }
297 
298  a2dDocviewGlobals->SetDoLog( oldlog );
299  return true;
300 }
301 
302 bool a2dLuaCentralCommandProcessor::ExecuteFile( const wxString& fileName )
303 {
304  bool oldlog = a2dDocviewGlobals->GetDoLog();
305 // if ( oldlog )
306 // a2dDocviewGlobals->SetDoLog( false );
307 
308  // Run a file that contains lua code
309  if ( 0 != m_interp.RunFile( fileName ) )
310  {
311  // if empty still show some error, since it went wrong somehow.
312  if ( a2dDocviewGlobals->GetErrors().empty() )
313  wxLogWarning( _( "Error in Lua File: %s \n" ), fileName.c_str() );
314  }
315 
316  a2dDocviewGlobals->SetDoLog( oldlog );
317  return true;
318 }
319 
321 {
322  a2dCanvasView* drawer = CheckDrawer();
323  if ( drawer )
324  {
325  if ( drawer->GetCanvas() && drawer->GetCanvas() )
326  {
327  wxWindow* frame = drawer->GetCanvas()->GetParent();
328  a2dLuaEditorFrame* frameEditor = wxDynamicCast( frame, a2dLuaEditorFrame );
329  if ( frameEditor )
330  return frameEditor;
331  }
332  }
333  return NULL;
334 }
335 
336 bool a2dLuaCentralCommandProcessor::ShowLuaExecDlg()
337 {
338  if ( !m_luaExecDlg )
339  m_luaExecDlg = new a2dLuaExecDlg( this, NULL );
340 
341  if ( m_luaExecDlg->IsShown() )
342  {
343  m_luaExecDlg->Show( false );
344  }
345  else
346  {
347  m_luaExecDlg->Show( true );
348  }
349  return true;
350 }
351 
352 
353 
354 bool a2dLuaCentralCommandProcessor::ShowDlg( const a2dCommandId* comID, bool modal, bool onTop )
355 {
356  if ( comID == &a2dLuaCentralCommandProcessor::COMID_ShowLuaExecDlg )
357  {
358  if ( !m_luaExecDlg )
359  m_luaExecDlg = new a2dLuaExecDlg( this, NULL );
360 
361  if ( m_luaExecDlg->IsShown() )
362  {
363  m_luaExecDlg->Show( false );
364  }
365  else
366  {
367  m_luaExecDlg->Show( true );
368  }
369  return true;
370  }
371  else
372  {
373  return a2dCentralCanvasCommandProcessor::ShowDlg( comID, modal, onTop );
374  }
375 }
376 
377 bool a2dLuaCentralCommandProcessor::FileNew()
378 {
379  a2dDocumentPtr doc;
381  return error == a2dError_NoError;
382 }
383 
384 a2dError a2dLuaCentralCommandProcessor::FileOpen( a2dDocumentPtr& doc , wxFileName& path )
385 {
386  return a2dDocumentCommandProcessor::FileOpen( doc, path );
387 }
388 
389 bool a2dLuaCentralCommandProcessor::FileOpen( const wxString& path )
390 {
391  a2dDocumentPtr doc;
392  a2dError error = a2dDocumentCommandProcessor::FileOpen( doc, path );
393  return error == a2dError_NoError;
394 }
395 
396 bool a2dLuaCentralCommandProcessor::FileSaveAs( const wxString& path, bool silent )
397 {
398  return a2dDocumentCommandProcessor::FileSaveAs( wxFileName( path ), a2dREFDOC_NON );
399 }
400 
401 bool a2dLuaCentralCommandProcessor::FileImport( const wxString& path, const wxString& description )
402 {
403  return a2dDocumentCommandProcessor::FileImport( wxFileName( path ), description, a2dREFDOC_NON );
404 }
405 
406 bool a2dLuaCentralCommandProcessor::FileExport( const wxString& path, const wxString& description, bool silent )
407 {
408  return a2dDocumentCommandProcessor::FileExport( wxFileName( path ), description, a2dREFDOC_NON );
409 }
410 
411 bool a2dLuaCentralCommandProcessor::Message( const wxString& message )
412 {
413  wxFrame* pf = ( wxFrame* ) wxTheApp->GetTopWindow();
414  wxMessageBox( message, wxT( "Gedi::Message" ), ( int )wxOK | wxCENTRE, pf, 0, 0 );
415  return true;
416 }
417 
418 bool a2dLuaCentralCommandProcessor::PushTool( const a2dCommandId& which, bool shiftadd, bool oneshot )
419 {
420  return GetDrawingCmdProcessor()->PushTool( which, shiftadd, oneshot );
421 }
422 
423 bool a2dLuaCentralCommandProcessor::SetDocumentLayers( const wxString& propertyname, const wxString& value )
424 {
426  if ( !doc )
427  return false;
428 
429  a2dLayers* layers = doc->GetLayerSetup();
430 
431  GetDrawingCmdProcessor()->SetOrAddPropertyToObject( layers, propertyname, value, false );
432  return true;
433 }
434 
435 
436 a2dLayers* a2dLuaCentralCommandProcessor::GetLayersDocument()
437 {
439  if ( !doc )
440  return false;
441  return doc->GetLayerSetup();
442 }
443 
444 a2dLayers* a2dLuaCentralCommandProcessor::GetLayersGlobal()
445 {
446  return a2dCanvasGlobals->GetHabitat()->GetLayerSetup();
447 }
448 
449 bool a2dLuaCentralCommandProcessor::SetLayersDocument( a2dLayers* layers )
450 {
452  if ( !doc )
453  return false;
454 
455  doc->SetLayerSetup( layers );
456  return true;
457 }
458 
459 bool a2dLuaCentralCommandProcessor::SetLayersGlobal( a2dLayers* layers )
460 {
461  a2dCanvasGlobals->GetHabitat()->SetLayerSetup( layers );
462  return true;
463 }
464 
465 a2dLayers* a2dLuaCentralCommandProcessor::LoadLayers( const wxString& filename )
466 {
467  a2dLayers* layers = new a2dLayers();
468  if ( layers->LoadLayers( filename ) )
469  {
470  return layers;
471  }
472  delete layers;
473  return NULL;
474 }
475 
476 bool a2dLuaCentralCommandProcessor::SaveLayersDocument( const wxString& filename )
477 {
479  if ( !doc )
480  return false;
481 
482  if ( doc->GetLayerSetup()->SaveLayers( filename ) )
483  return true;
484  return false;
485 }
486 
487 bool a2dLuaCentralCommandProcessor::SaveLayersGlobal( const wxString& filename )
488 {
489  if ( a2dCanvasGlobals->GetHabitat()->GetLayerSetup() )
490  return a2dCanvasGlobals->GetHabitat()->GetLayerSetup()->SaveLayers( filename );
491  return false;
492 }
493 
494 bool a2dLuaCentralCommandProcessor::SetLayer( wxUint16 layer )
495 {
496  a2dCanvasGlobals->GetHabitat()->SetLayer( layer, true );
497  return true;
498 }
499 
500 bool a2dLuaCentralCommandProcessor::SetTarget( wxUint16 target )
501 {
502  a2dCanvasGlobals->GetHabitat()->SetTarget( target );
503  return true;
504 }
505 
506 bool a2dLuaCentralCommandProcessor::ClearGroup( const wxString& group )
507 {
510  return Submit( command, m_withUndo );
511 }
512 
513 void a2dLuaCentralCommandProcessor::AddGroupA( wxUint16 layer )
514 {
515  a2dCanvasGlobals->GetHabitat()->AddGroupA( layer );
516 }
517 
518 void a2dLuaCentralCommandProcessor::AddGroupB( wxUint16 layer )
519 {
520  a2dCanvasGlobals->GetHabitat()->AddGroupB( layer );
521 }
522 
523 bool a2dLuaCentralCommandProcessor::DeleteGroupA()
524 {
525  a2dCanvasView* drawer = CheckDrawer();
526  if ( !drawer )
527  return false;
528 
529  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
530 
531  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
532 
535  return SubmitToDrawing( command, m_withUndo );
536 }
537 
538 bool a2dLuaCentralCommandProcessor::MoveGroupA()
539 {
540  a2dCanvasView* drawer = CheckDrawer();
541  if ( !drawer )
542  return false;
543 
544  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
545 
546  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
547 
550 
551  return SubmitToDrawing( command, m_withUndo );
552 }
553 
554 bool a2dLuaCentralCommandProcessor::CopyGroupA()
555 {
556  a2dCanvasView* drawer = CheckDrawer();
557  if ( !drawer )
558  return false;
559  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
560 
561  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
562 
565 
566  return SubmitToDrawing( command, m_withUndo );
567 }
568 
569 bool a2dLuaCentralCommandProcessor::ConvertToArcsGroupA( bool detectCircle )
570 {
571  a2dCanvasView* drawer = CheckDrawer();
572  if ( !drawer )
573  return false;
574  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
575 
576  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
577 
579  what( a2dCommand_GroupAB::ConvertToArcs ).detectCircle( detectCircle ) );
580  return SubmitToDrawing( command, m_withUndo );
581 }
582 
583 bool a2dLuaCentralCommandProcessor::ConvertPolygonToArcsGroupA( bool detectCircle )
584 {
585  a2dCanvasView* drawer = CheckDrawer();
586  if ( !drawer )
587  return false;
588 
589  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
590 
591  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
592 
594  what( a2dCommand_GroupAB::ConvertPolygonToArcs ).detectCircle( detectCircle ) );
595  return SubmitToDrawing( command, m_withUndo );
596 }
597 
598 bool a2dLuaCentralCommandProcessor::ConvertToPolygonPolylinesWithArcsGroupA()
599 {
600  a2dCanvasView* drawer = CheckDrawer();
601  if ( !drawer )
602  return false;
603 
604  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
605 
606  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
607 
610  return SubmitToDrawing( command, m_withUndo );
611 }
612 
613 bool a2dLuaCentralCommandProcessor::ConvertToPolygonPolylinesWithoutArcsGroupA()
614 {
615  a2dCanvasView* drawer = CheckDrawer();
616  if ( !drawer )
617  return false;
618 
619  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
620 
621  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
622 
625  return SubmitToDrawing( command, m_withUndo );
626 }
627 
628 bool a2dLuaCentralCommandProcessor::ConvertPolylineToArcsGroupA()
629 {
630  a2dCanvasView* drawer = CheckDrawer();
631  if ( !drawer )
632  return false;
633 
634  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
635 
636  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
637 
640  return Submit( command, m_withUndo );
641 }
642 
643 bool a2dLuaCentralCommandProcessor::ConvertToVPathsGroupA()
644 {
645  a2dCanvasView* drawer = CheckDrawer();
646  if ( !drawer )
647  return false;
648 
649  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
650 
651  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
652 
655  return SubmitToDrawing( command, m_withUndo );
656 }
657 
658 bool a2dLuaCentralCommandProcessor::ConvertLinesArcsGroupA()
659 {
660  a2dCanvasView* drawer = CheckDrawer();
661  if ( !drawer )
662  return false;
663 
664  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
665 
666  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
667 
670  return SubmitToDrawing( command, m_withUndo );
671 }
672 
673 bool a2dLuaCentralCommandProcessor::ConvertToPolylinesGroupA()
674 {
675  a2dCanvasView* drawer = CheckDrawer();
676  if ( !drawer )
677  return false;
678 
679  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
680 
681  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
682 
685  return SubmitToDrawing( command, m_withUndo );
686 }
687 
688 bool a2dLuaCentralCommandProcessor::RemoveRedundantGroupA()
689 {
690  a2dCanvasView* drawer = CheckDrawer();
691  if ( !drawer )
692  return false;
693 
694  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
695 
696  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
697 
700  return SubmitToDrawing( command, m_withUndo );
701 }
702 
703 bool a2dLuaCentralCommandProcessor::DetectSmallGroupA()
704 {
705  a2dCanvasView* drawer = CheckDrawer();
706  if ( !drawer )
707  return false;
708 
709  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
710 
711  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
712 
714  what( a2dCommand_GroupAB::DetectSmall ) );
715  return SubmitToDrawing( command, m_withUndo );
716 }
717 
718 #if wxART2D_USE_KBOOL
719 bool a2dLuaCentralCommandProcessor::BoolOperation_GroupAB( a2dCommand_GroupAB::a2dDoWhat operation, bool clearTarget, bool selectedA, bool selectedB )
720 {
721  a2dCanvasView* drawer = CheckDrawer();
722  if ( !drawer )
723  return false;
724 
725  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
726 
727  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
728 
730  what( operation ).
731  clearTarget( clearTarget ).
732  selectedA( selectedA ).
733  selectedB( selectedB )
734  );
735 
736  return SubmitToDrawing( command, m_withUndo );
737 }
738 #endif //wxART2D_USE_KBOOL
739 
740 bool a2dLuaCentralCommandProcessor::UnGroup( bool selected, bool deep )
741 {
742  a2dCanvasView* drawer = CheckDrawer();
743  if ( !drawer )
744  return false;
745 
746  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
747 
748  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
749 
751  return SubmitToDrawing( com, m_withUndo );
752 }
753 
754 bool a2dLuaCentralCommandProcessor::SetVariable( const wxString& varnamep, const wxString& varvaluep )
755 {
756  a2dSmrtPtr<a2dCommand_SetVariable> command = new a2dCommand_SetVariable( a2dCommand_SetVariable::Args().varname( varnamep ).varvalue( varvaluep ) );
757  return Submit( command, m_withUndo );
758 }
759 
760 wxString a2dLuaCentralCommandProcessor::GetVariable( const wxString& varname )
761 {
762  const a2dNamedProperty* propfound = a2dDocviewGlobals->GetVariablesHash().GetVariable( varname );
763  if( !propfound )
764  {
765  a2dDocviewGlobals->ReportError( a2dError_GetVar, _( "wrong variable name, variable does not exist" ) );
766  return _( "NOT_A_VARIABLE" ); // error, variable does not exist
767  }
768 
769  return propfound->StringValueRepresentation();
770 }
771 
772 void a2dLuaCentralCommandProcessor::AddConfigPath( const wxString& path )
773 {
774  a2dCanvasGlobals->GetConfigPathList().Add( path );
775 }
776 
777 void a2dLuaCentralCommandProcessor::AddLayersPath( const wxString& path )
778 {
779  a2dCanvasGlobals->GetLayersPathList().Add( path );
780 }
781 
782 void a2dLuaCentralCommandProcessor::AddFontPath( const wxString& path )
783 {
784  a2dGlobals->GetFontPathList().Add( path );
785 }
786 
787 void a2dLuaCentralCommandProcessor::AddImagePath( const wxString& path )
788 {
789  a2dGlobals->GetImagePathList().Add( path );
790 }
791 
792 void a2dLuaCentralCommandProcessor::AddIconPath( const wxString& path )
793 {
794  a2dGlobals->GetIconPathList().Add( path );
795 }
796 
797 bool a2dLuaCentralCommandProcessor::SetSnap( bool snap )
798 {
799  a2dCanvasGlobals->GetHabitat()->GetRestrictionEngine()->SetSnap( snap );
800  return true;
801 }
802 
803 bool a2dLuaCentralCommandProcessor::SetSnapFeatures( wxUint32 features )
804 {
805  a2dCanvasGlobals->GetHabitat()->GetRestrictionEngine()->SetSnapTargetFeatures( features );
806  return true;
807 }
808 
809 bool a2dLuaCentralCommandProcessor::ViewAsImageAdv( const wxFileName& file, wxBitmapType type, bool onView )
810 {
812  if ( !doc )
813  return false;
814  a2dCanvasView* drawer = CheckDrawer();
815  if ( !drawer )
816  return false;
817  if ( !drawer->GetDrawingPart()->GetDrawing() )
818  return false;
819 
820  return SaveViewAsImage( doc, file.GetFullPath(), type, drawer->GetDrawingPart()->GetShowObject() );
821 }
822 
823 void a2dLuaCentralCommandProcessor::SetCursor( double x, double y )
824 {
826  Submit( command, m_withUndo );
827 }
828 
829 bool a2dLuaCentralCommandProcessor::Find( const wxString& objectname )
830 {
831  a2dCanvasView* drawer = CheckDrawer();
832  if ( !drawer )
833  return false;
834 
835  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
836 
837  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
838 
840  name( objectname ) );
841  return drawing->GetCanvasCommandProcessor()->Submit( command, m_withUndo );
842 }
843 
844 bool a2dLuaCentralCommandProcessor::Ask( const wxString& variablename, const wxString& mes )
845 {
846  wxString text = wxGetTextFromUser( mes );
847  a2dDocviewGlobals->GetVariablesHash().SetVariableString( variablename, text );
848 
849  return true;
850 }
851 
852 bool a2dLuaCentralCommandProcessor::AskFile( const wxString& storeInVariable,
853  const wxString& message,
854  const wxString& defaultDir,
855  const wxString& extension,
856  const wxString& fileFilter
857  )
858 {
859  wxString file = a2dDocumentCommandProcessor::AskFile( message, defaultDir, _T( "" ), extension, fileFilter, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
861  return true;
862 }
863 
864 wxFileName a2dLuaCentralCommandProcessor::AskFile2(
865  const wxString& message,
866  const wxString& defaultDir,
867  const wxString& extension,
868  const wxString& fileFilter
869 )
870 {
871  wxString storeInVariable = _T( "ask_file_result" );
872  wxString file = a2dDocumentCommandProcessor::AskFile( message, defaultDir, _T( "" ), extension, fileFilter, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
873  return wxFileName( file );
874 }
875 
876 bool a2dLuaCentralCommandProcessor::ShowVariable( const wxString& variableName,
877  const wxString& message
878  )
879 {
880  const a2dNamedProperty* prop = a2dDocviewGlobals->GetVariablesHash().GetVariable( variableName );
881  if ( !prop )
882  return false;
883 
884  wxString mes = message + prop->StringValueRepresentation();
885  wxMessageBox( mes , _( "ShowVariable" ), wxOK , NULL );
886 
887  return true;
888 }
889 
890 //----------------------------------------------------------------------------
891 // object add
892 //----------------------------------------------------------------------------
893 
895 {
896  if ( !CheckCanvasDocument() )
897  return NULL;
898 
899  return AddCurrent( new a2dCanvasObject( x, y ), false, &m_listOfIdforAddPrims );
900 }
901 
903 {
904  if ( !CheckCanvasDocument() )
905  return NULL;
906 
907  return ( a2dCanvasObjectReference* ) AddCurrent( new a2dCanvasObjectReference( x, y, obj ), false, &m_listOfIdforAddPrims );
908 }
909 
910 /* TODO
911 a2dNameReference* a2dLuaCentralCommandProcessor::Add_a2dNameReference( double x, double y, a2dCanvasObject* obj, const wxString &text, double size, double angle )
912 {
913  if ( !CheckCanvasDocument() )
914  return NULL;
915 
916  return (a2dNameReference*) AddCurrent( new a2dNameReference( x, y, obj, text, size, angle ) );
917 }
918 */
919 
921 {
922  if ( !CheckCanvasDocument() )
923  return NULL;
924 
925  return ( a2dOrigin* ) AddCurrent( new a2dOrigin( w, h ), false, &m_listOfIdforAddPrims );
926 }
927 
928 a2dRectC* a2dLuaCentralCommandProcessor::Add_a2dRectC( double xc, double yc, double w, double h, double angle, double radius )
929 {
930  if ( !CheckCanvasDocument() )
931  return NULL;
932 
933  return ( a2dRectC* ) AddCurrent( new a2dRectC( xc, yc, w, h, angle, radius ), false, &m_listOfIdforAddPrims );
934 }
935 
936 a2dArrow* a2dLuaCentralCommandProcessor::Add_a2dArrow( double xt, double yt, double l1, double l2, double b, bool spline )
937 {
938  if ( !CheckCanvasDocument() )
939  return NULL;
940 
941  return ( a2dArrow* ) AddCurrent( new a2dArrow( xt, yt, l1, l2, b, spline ), false, &m_listOfIdforAddPrims );
942 }
943 
944 a2dRect* a2dLuaCentralCommandProcessor::Add_a2dRect( double x, double y, double w, double h , double radius )
945 {
946  if ( !CheckCanvasDocument() )
947  return NULL;
948 
949  return ( a2dRect* ) AddCurrent( new a2dRect( x, y, w, h, radius ), false, &m_listOfIdforAddPrims );
950 }
951 
952 a2dCircle* a2dLuaCentralCommandProcessor::Add_a2dCircle( double x, double y, double radius )
953 {
954  if ( !CheckCanvasDocument() )
955  return NULL;
956 
957  return ( a2dCircle* ) AddCurrent( new a2dCircle( x, y, radius ), false, &m_listOfIdforAddPrims );
958 }
959 
960 a2dEllipse* a2dLuaCentralCommandProcessor::Add_a2dEllipse( double xc, double yc, double width, double height )
961 {
962  if ( !CheckCanvasDocument() )
963  return NULL;
964 
965  return ( a2dEllipse* ) AddCurrent( new a2dEllipse( xc, yc, width, height ), false, &m_listOfIdforAddPrims );
966 }
967 
968 a2dEllipticArc* a2dLuaCentralCommandProcessor::Add_a2dEllipticArc( double xc, double yc, double width, double height, double start, double end )
969 {
970  if ( !CheckCanvasDocument() )
971  return NULL;
972 
973  return ( a2dEllipticArc* ) AddCurrent( new a2dEllipticArc( xc, yc, width, height, start, end ), false, &m_listOfIdforAddPrims );
974 }
975 
976 a2dArc* a2dLuaCentralCommandProcessor::Add_a2dArc( double xc, double yc, double radius, double start, double end )
977 {
978  if ( !CheckCanvasDocument() )
979  return NULL;
980 
981  return ( a2dArc* ) AddCurrent( new a2dArc( xc, yc, radius, start, end ), false, &m_listOfIdforAddPrims );
982 }
983 
984 a2dSLine* a2dLuaCentralCommandProcessor::Add_a2dSLine( double x1, double y1, double x2, double y2 )
985 {
986  if ( !CheckCanvasDocument() )
987  return NULL;
988 
989  return ( a2dSLine* ) AddCurrent( new a2dSLine( x1, y1, x2, y2 ), false, &m_listOfIdforAddPrims );
990 }
991 
992 a2dEndsLine* a2dLuaCentralCommandProcessor::Add_a2dEndsLine( double x1, double y1, double x2, double y2 )
993 {
994  if ( !CheckCanvasDocument() )
995  return NULL;
996 
997  return ( a2dEndsLine* ) AddCurrent( new a2dEndsLine( x1, y1, x2, y2 ), false, &m_listOfIdforAddPrims );
998 }
999 
1000 a2dImage* a2dLuaCentralCommandProcessor::Add_a2dImage( const wxImage& image, double xc, double yc, double w, double h )
1001 {
1002  if ( !CheckCanvasDocument() )
1003  return NULL;
1004 
1005  return ( a2dImage* ) AddCurrent( new a2dImage( image, xc, yc, w, h ) );
1006 }
1007 
1008 a2dImage* a2dLuaCentralCommandProcessor::Add_a2dImage( const wxString& imagefile, wxBitmapType type, double xc, double yc, double w, double h )
1009 {
1010  if ( !CheckCanvasDocument() )
1011  return NULL;
1012 
1013  wxString foundfile = imagefile;
1014  a2dPathList path;
1015  path.Add( wxT( "." ) );
1016  if ( !path.ExpandPath( foundfile ) )
1017  {
1018  a2dDocviewGlobals->ReportErrorF( a2dError_CouldNotEvaluatePath, _( "Could not expand %s resulted in %s" ), imagefile.c_str(), foundfile.c_str() );
1019  return false;
1020  }
1021  if ( foundfile.IsEmpty() )
1022  {
1023  a2dDocviewGlobals->ReportErrorF( a2dError_NotSpecified, _( "Filename %s not in %s" ), foundfile.c_str(), imagefile.c_str() );
1024  return false;
1025  }
1026 
1027 
1028  return ( a2dImage* ) AddCurrent( new a2dImage( foundfile, type, xc, yc, w, h ), false, &m_listOfIdforAddPrims );
1029 }
1030 
1031 a2dText* a2dLuaCentralCommandProcessor::Add_a2dText( const wxString& text, double x, double y, double angle, const a2dFont& font )
1032 {
1033  if ( !CheckCanvasDocument() )
1034  return NULL;
1035 
1036  return ( a2dText* ) AddCurrent( new a2dText( text, x, y, font, angle ), false, &m_listOfIdforAddPrims );
1037 }
1038 
1040 {
1041  if ( !CheckCanvasDocument() )
1042  return NULL;
1043 
1044  return ( a2dPolygonL* ) AddCurrent( new a2dPolygonL( points, spline ), false, &m_listOfIdforAddPrims );
1045 }
1046 
1048 {
1049  if ( !CheckCanvasDocument() )
1050  return NULL;
1051 
1052  return ( a2dPolylineL* ) AddCurrent( new a2dPolylineL( points, spline ), false, &m_listOfIdforAddPrims );
1053 }
1054 
1055 bool a2dLuaCentralCommandProcessor::Add_Point( double x, double y )
1056 {
1058  if ( !doc )
1059  return false;
1060  a2dCanvasView* drawer = CheckDrawer();
1061  if ( !drawer )
1062  return false;
1063  if ( !drawer->GetDrawingPart()->GetDrawing() )
1064  return false;
1065 
1066  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
1068 
1069  return true;
1070 }
1071 
1072 bool a2dLuaCentralCommandProcessor::Move_Point( int index , double x, double y )
1073 {
1075  if ( !doc )
1076  return false;
1077  a2dCanvasView* drawer = CheckDrawer();
1078  if ( !drawer )
1079  return false;
1080  if ( !drawer->GetDrawingPart()->GetDrawing() )
1081  return false;
1082 
1083  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
1085  drawing->GetCommandProcessor()->Submit( new a2dCommand_MovePoint( sline, x, y, true ), m_withUndo );
1086 
1087  return true;
1088 }
1089 
1090 
1091 
1092 
1093 //--------------------- drawer related commands ------------------
1094 
1095 bool a2dLuaCentralCommandProcessor::DrawWireFrame( bool onOff )
1096 {
1098  if ( !onOff )
1100 
1101  return SetPropertyToObject( _T( "a2dDrawingPart" ), new a2dUint16Property( a2dDrawingPart::PROPID_drawstyle, style ) );
1102 }
1103 
1104 bool a2dLuaCentralCommandProcessor::DrawGridLines( bool onOff )
1105 {
1106  return SetPropertyToObject( _T( "a2dDrawingPart" ), new a2dBoolProperty( a2dDrawingPart::PROPID_gridlines, onOff ) );
1107 }
1108 
1109 bool a2dLuaCentralCommandProcessor::DrawGridAtFront( bool onOff )
1110 {
1111  return SetPropertyToObject( _T( "a2dDrawingPart" ), new a2dBoolProperty( a2dDrawingPart::PROPID_gridatfront, onOff ) );
1112 }
1113 
1114 bool a2dLuaCentralCommandProcessor::DrawGrid( bool onOff )
1115 {
1116  return SetPropertyToObject( _T( "a2dDrawingPart" ), new a2dBoolProperty( a2dDrawingPart::PROPID_grid, onOff ) );
1117 }
1118 
1119 bool a2dLuaCentralCommandProcessor::ZoomOut()
1120 {
1121  return GetDrawingCmdProcessor()->ZoomOut();
1122 }
1123 
1124 bool a2dLuaCentralCommandProcessor::Refresh()
1125 {
1127  if ( !doc )
1128  return false;
1129 
1131  a2dCanvasView* drawer = CheckDrawer();
1132  if ( drawer )
1134  return true;
1135 }
1136 
1137 bool a2dLuaCentralCommandProcessor::InsertGroupRef( double x, double y )
1138 {
1140  if ( !doc )
1141  return false;
1142 
1143  a2dCanvasView* drawer = CheckDrawer();
1144  if ( drawer )
1145  {
1146  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
1147  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
1148 
1150  collector.Start( doc->GetDrawing()->GetRootObject() );
1151 
1152  a2dCanvasObjectsDialog groups( doc->GetAssociatedWindow(), &collector.m_found, false, ( wxSTAY_ON_TOP | wxRESIZE_BORDER | wxCAPTION ) );
1153  if ( groups.ShowModal() == wxID_OK )
1154  {
1155  a2dCanvasObjectReference* groupref = new a2dCanvasObjectReference( x, y, groups.GetCanvasObject() );
1156  top->Prepend( groupref );
1157  }
1158  }
1159  return true;
1160 }
1161 
1162 bool a2dLuaCentralCommandProcessor::AddGroupObject( const wxString& groupName, double x, double y, wxUint16 layer )
1163 {
1164  a2dCanvasView* drawer = CheckDrawer();
1165  if ( !drawer )
1166  return false;
1167 
1168  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
1169  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
1170 
1172  name( groupName ).
1173  x( x ).
1174  y( y ).
1175  layer( layer ) );
1176  return Submit( command, m_withUndo );
1177 }
1178 
1179 bool a2dLuaCentralCommandProcessor::NewPin( double x, double y, const wxString& groupname )
1180 {
1182  if ( !doc )
1183  return false;
1184 
1185  a2dCanvasView* drawer = CheckDrawer();
1186  if ( drawer )
1187  {
1188  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
1189  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
1190 
1191  wxString name = groupname;
1192  if ( name.IsEmpty() )
1193  name = wxGetTextFromUser( _( "give name of new pin:" ) );
1194  long ang = wxGetNumberFromUser( _( "Give pin angle:" ), _( "angle:" ), _( "pin angle" ), 0, -360, 360 );
1195 
1196  a2dPin* pin = new a2dPin( top, name, a2dPinClass::Standard, 0, 0, ang );
1197  top->Prepend( pin );
1198  }
1199  return true;
1200 }
1201 
1202 bool a2dLuaCentralCommandProcessor::PushInto( const wxString& name )
1203 {
1205  if ( !doc )
1206  return false;
1207 
1208  a2dCanvasView* drawer = CheckDrawer();
1209  if ( drawer )
1210  {
1211  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
1212 
1213  a2dCanvasObject* g = NULL;
1214  if ( name.IsEmpty() )
1215  g = wxStaticCast( top->Find( wxT( "" ), wxT( "" ), a2dCanvasOFlags::SELECTED ), a2dCanvasObject );
1216  else
1217  g = wxStaticCast( top->Find( name ), a2dCanvasObject );
1218 
1219  if ( g )
1220  {
1221  //let drawer follow document if needed.
1222  //if ( doc->GetRootObject() != g->GetRoot() )
1223  // drawer->SetDocument( g->GetCanvasDocument() );
1224  drawer->GetDrawingPart()->SetShowObject( g );
1225  }
1226  else
1227  ( void )wxMessageBox( _( "Does not contain a group, unable to push into" ), _( "push into" ), wxICON_INFORMATION | wxOK );
1228  }
1229  return true;
1230 }
1231 
1232 bool a2dLuaCentralCommandProcessor::SelectAll()
1233 {
1234  a2dCanvasView* drawer = CheckDrawer();
1235  if ( !drawer )
1236  return false;
1237 
1238  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
1239  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
1240 
1242 
1243  return true;
1244 }
1245 
1246 bool a2dLuaCentralCommandProcessor::DeSelectAll()
1247 {
1248  a2dCanvasView* drawer = CheckDrawer();
1249  if ( !drawer )
1250  return false;
1251 
1252  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
1253  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
1254 
1256  return true;
1257 }
1258 
1259 bool a2dLuaCentralCommandProcessor::SelectedChangeLayer( long layer )
1260 {
1261  a2dCanvasView* drawer = CheckDrawer();
1262  if ( !drawer )
1263  return false;
1264 
1265  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
1266  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
1267 
1268  SetTarget( layer );
1270  return true;
1271 }
1272 
1273 bool a2dLuaCentralCommandProcessor::SetFillStrokeSelected()
1274 {
1276  if ( !doc )
1277  return false;
1278 
1279  a2dCanvasView* drawer = CheckDrawer();
1280  if ( drawer )
1281  {
1282  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
1283  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
1284 
1286  }
1287  return true;
1288 }
1289 
1290 bool a2dLuaCentralCommandProcessor::ToTop()
1291 {
1292  a2dCanvasView* drawer = CheckDrawer();
1293  if ( !drawer )
1294  return false;
1295 
1296  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
1297  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
1298 
1300 }
1301 
1302 bool a2dLuaCentralCommandProcessor::ToBack()
1303 {
1304  a2dCanvasView* drawer = CheckDrawer();
1305  if ( !drawer )
1306  return false;
1307 
1308  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
1309  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
1310 
1312 }
1313 
1314 bool a2dLuaCentralCommandProcessor::DeleteSelected()
1315 {
1316  a2dCanvasView* drawer = CheckDrawer();
1317  if ( !drawer )
1318  return false;
1319 
1320  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
1321  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
1322 
1324 }
1325 
1326 bool a2dLuaCentralCommandProcessor::MoveSelected( double x, double y, long layer )
1327 {
1328  a2dCanvasView* drawer = CheckDrawer();
1329  if ( !drawer )
1330  return false;
1331 
1332  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
1333  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
1334 
1335  a2dCommand_MoveMask* com = new a2dCommand_MoveMask( top, x, y, layer );
1336  return GetDrawingCmdProcessor()->Submit( com, m_withUndo );
1337 }
1338 
1339 bool a2dLuaCentralCommandProcessor::CopySelected( double x, double y, long layer )
1340 {
1341  a2dCanvasView* drawer = CheckDrawer();
1342  if ( !drawer )
1343  return false;
1344 
1345  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
1346  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
1347 
1348  a2dCommand_CopyMask* com = new a2dCommand_CopyMask( top, x, y, layer );
1349  return GetDrawingCmdProcessor()->Submit( com, m_withUndo );
1350 }
1351 
1352 bool a2dLuaCentralCommandProcessor::TransformSelected( const wxString& str )
1353 {
1354  a2dAffineMatrix lworld;
1355 
1356  wxString error;
1357  if ( !str.IsEmpty() && !::ParseCvgTransForm( lworld, str, error ) )
1358  {
1359  a2dGeneralGlobals->ReportErrorF( a2dError_CommandError, _( "CVG : invalid transform %s " ), str.c_str() );
1360  }
1361 
1362  a2dCanvasView* drawer = CheckDrawer();
1363  if ( !drawer )
1364  return false;
1365 
1366  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
1367  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
1368 
1369  a2dCommand_TransformMask* com = new a2dCommand_TransformMask( top, lworld );
1370  return GetDrawingCmdProcessor()->Submit( com, m_withUndo );
1371 }
1372 
1373 bool a2dLuaCentralCommandProcessor::Group()
1374 {
1375  a2dCanvasView* drawer = CheckDrawer();
1376  if ( !drawer )
1377  return false;
1378 
1379  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
1380  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
1381 
1382  a2dCommand_GroupMask* com = new a2dCommand_GroupMask( top );
1383  return GetDrawingCmdProcessor()->Submit( com, m_withUndo );
1384 }
1385 
1386 bool a2dLuaCentralCommandProcessor::UnGroup()
1387 {
1388  a2dCanvasView* drawer = CheckDrawer();
1389  if ( !drawer )
1390  return false;
1391 
1392  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
1393  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
1394 
1396  return GetDrawingCmdProcessor()->Submit( com, m_withUndo );
1397 }
1398 
1399 bool a2dLuaCentralCommandProcessor::SetUrl()
1400 {
1401  a2dCanvasView* drawer = CheckDrawer();
1402  if ( !drawer )
1403  return false;
1404 
1405  a2dDrawing* drawing = drawer->GetDrawingPart()->GetDrawing();
1406  a2dCanvasObject* top = drawer->GetDrawingPart()->GetShowObject();
1407 
1408  a2dCommand_UrlOnMask* com = new a2dCommand_UrlOnMask( top );
1409  return GetDrawingCmdProcessor()->Submit( com, m_withUndo );
1410 }
1411 
1412 //----------------------------------------------------------------------------
1413 // a2dLuaConsole
1414 //----------------------------------------------------------------------------
1415 IMPLEMENT_ABSTRACT_CLASS( a2dLuaConsole, wxLuaIDE );
1416 
1417 BEGIN_EVENT_TABLE( a2dLuaConsole, wxLuaIDE )
1418  EVT_LUA_PRINT ( wxID_ANY, a2dLuaConsole::OnLua )
1419  EVT_LUA_ERROR ( wxID_ANY, a2dLuaConsole::OnLua )
1420  EVT_LUA_DEBUG_HOOK ( wxID_ANY, a2dLuaConsole::OnLua )
1421 END_EVENT_TABLE()
1422 
1423 a2dLuaConsole::a2dLuaConsole( a2dLuaCentralCommandProcessor* cmdh, wxWindow* parent, int id,
1424  const wxPoint& pos, const wxSize& size,
1425  long style, long options, const wxString& name )
1426  : wxLuaIDE( parent, id, pos, size, style | wxCLIP_CHILDREN | wxNO_FULL_REPAINT_ON_RESIZE, options, name )
1427 {
1428  m_cmdh = cmdh;
1429 
1430  wxFrame* pf = ( wxFrame* ) wxTheApp->GetTopWindow();
1431 
1432  wxMenuBar* menuBar = 0;//pf->GetMenuBar();
1433  wxToolBar* toolBar = 0;//pf->GetToolBar();
1434 
1435  GetEditorNotebook()->GetOptions().SetMenuBar( menuBar );
1436  GetLuaOutputWin()->GetOptions().SetMenuBar( menuBar );
1437  GetLuaShellWin()->GetOptions().SetMenuBar( menuBar );
1438 
1439  GetEditorNotebook()->GetOptions().SetToolBar( toolBar );
1440  GetLuaOutputWin()->GetOptions().SetToolBar( toolBar );
1441  GetLuaShellWin()->GetOptions().SetToolBar( toolBar );
1442 }
1443 
1444 a2dLuaConsole::~a2dLuaConsole()
1445 {
1446 }
1447 
1448 void a2dLuaConsole::OnLua( wxLuaEvent& event )
1449 {
1450  if ( event.GetwxLuaState() == m_cmdh->GetLuaState() )
1451  OutputLuaEvent( event, m_luaOutput );
1452  else
1453  wxLuaIDE::OnLua( event );
1454 }
1455 
1456 BEGIN_EVENT_TABLE( a2dLuaExecDlg, wxDialog )
1457  EVT_CLOSE( a2dLuaExecDlg::OnCloseWindow )
1458  EVT_CHAR_HOOK( a2dLuaExecDlg::OnCharHook )
1459 
1460  EVT_RECORD( a2dLuaExecDlg::OnRecord )
1461  EVT_DO( a2dLuaExecDlg::OnDoEvent )
1462  EVT_UNDO( a2dLuaExecDlg::OnUndoEvent )
1463 END_EVENT_TABLE()
1464 
1465 a2dLuaExecDlg::a2dLuaExecDlg( a2dLuaCentralCommandProcessor* commandProcessor, wxFrame* parent, const wxString& title, long style, const wxString& name ):
1466  wxDialog( parent, -1, title, wxDefaultPosition, wxDefaultSize, style, name )
1467 {
1468  m_parent = parent;
1469 
1470  wxBoxSizer* itemBoxSizer = new wxBoxSizer( wxVERTICAL );
1471  SetSizer( itemBoxSizer );
1472 
1473  m_commandProcessor = commandProcessor;
1474 
1475  m_luaConsole = new a2dLuaConsole( commandProcessor, this, wxID_ANY, wxDefaultPosition, wxSize( 400, 400 ) );
1476  itemBoxSizer->Add( m_luaConsole, 1, wxGROW | wxALL, 0 );
1477 
1478  SetSizeHints( wxSize( 400, 400 ) );
1479  GetSizer()->Fit( this );
1480  GetSizer()->SetSizeHints( this );
1481  Centre();
1482  // The size of the frame isn't set when the splitter is created, resize it
1483  wxSplitterWindow* splitWin = m_luaConsole->GetSplitterWin();
1484  splitWin->SetSashPosition( splitWin->GetSize().y / 2 );
1485 }
1486 
1487 a2dLuaExecDlg::~a2dLuaExecDlg()
1488 {
1489 }
1490 
1491 void a2dLuaExecDlg::OnCloseWindow( wxCloseEvent& WXUNUSED( event ) )
1492 {
1493  Show( false );
1494 }
1495 
1496 void a2dLuaExecDlg::OnRecord( a2dCommandEvent& event )
1497 {
1498  wxString cmdName = event.GetRecord();
1499 }
1500 
1501 void a2dLuaExecDlg::OnUndoEvent( a2dCommandProcessorEvent& WXUNUSED( event ) )
1502 {
1503 
1504 }
1505 
1506 void a2dLuaExecDlg::OnDoEvent( a2dCommandProcessorEvent& WXUNUSED( event ) )
1507 {
1508 }
1509 
1510 void a2dLuaExecDlg::OnCharHook( wxKeyEvent& event )
1511 {
1512  /*
1513  if ( event.GetKeyCode() == WXK_RETURN )
1514  {
1515  Execute();
1516  }
1517  else*/ if ( event.GetKeyCode() == WXK_ESCAPE )
1518  {
1519  wxCommandEvent eventc;
1520  Show( false );
1521 
1522  }
1523  else
1524  {
1525  // key code is within legal range. we call event.Skip() so the
1526  // event can be processed either in the base wxWindows class
1527  // or the native control.
1528 
1529  event.Skip();
1530  }
1531 }
1532 
1533 //----------------------------------------------------------------------------
1534 // a2dLuaEditorFrame
1535 //----------------------------------------------------------------------------
1536 
1537 extern const long SCRIPT_luawrap = wxNewId();
1538 extern const long EXECDLG_lua = wxNewId();
1539 
1540 IMPLEMENT_DYNAMIC_CLASS( a2dLuaEditorFrame, a2dEditorFrame )
1541 
1542 BEGIN_EVENT_TABLE( a2dLuaEditorFrame, a2dEditorFrame )
1543 
1544  EVT_THEME_EVENT( a2dLuaEditorFrame::OnTheme )
1545  EVT_INIT_EVENT( a2dLuaEditorFrame::OnInit )
1546 
1547 END_EVENT_TABLE()
1548 
1549 //! canvas window to display the view upon to be defined by user
1550 #define DOC ((a2dCanvasView*)m_view.Get())->GetCanvasDocument()
1551 
1553  : a2dEditorFrame()
1554 {
1555  m_initialized = false;
1556 }
1557 
1558 a2dLuaEditorFrame::a2dLuaEditorFrame( bool isParent,
1559  wxFrame* parent, const wxPoint& pos, const wxSize& size, long style )
1560  : a2dEditorFrame( isParent, parent, pos, size, style )
1561 {
1562  m_initialized = false;
1563 
1564  // create a canvas in Create, the first arg. is true.
1565  Create( true, isParent, parent, pos, size, style );
1566 }
1567 
1568 a2dLuaEditorFrame::~a2dLuaEditorFrame()
1569 {
1570 }
1571 
1572 void a2dLuaEditorFrame::OnInit( a2dEditorFrameEvent& initEvent )
1573 {
1574  initEvent.Skip();
1575 }
1576 
1577 
1578 void a2dLuaEditorFrame::OnTheme( a2dEditorFrameEvent& themeEvent )
1579 {
1580 
1581  //CreateThemeDefault();
1582  wxMenu* dlg_menu = new wxMenu;
1583  m_menuBar->Append( dlg_menu, _( "&Lua Dialogs" ) );
1584 
1585  AddFunctionToMenu( EXECDLG_lua, dlg_menu, _( "&Lua Commandline Dialog" ), _( "interactive lua command dialog" ), ( wxObjectEventFunctionM ) &a2dLuaEditorFrame::OnShowExecDlg2, true );
1586  AddFunctionToMenu( SCRIPT_luawrap, dlg_menu, _T( "Run Lua Script" ), _T( "choose a wxLua script to run" ), ( wxObjectEventFunctionM ) &a2dLuaEditorFrame::OnRunScript , true );
1587 
1588  themeEvent.Skip();
1589 }
1590 
1591 void a2dLuaEditorFrame::OnShowExecDlg2( wxCommandEvent& event )
1592 {
1593  a2dCommand_ShowDlg* command = new a2dCommand_ShowDlg( a2dLuaCentralCommandProcessor::COMID_ShowLuaExecDlg );
1595  luacmd->Submit( command );
1596 }
1597 
1598 void a2dLuaEditorFrame::OnRunScript( wxCommandEvent& event )
1599 {
1600 #if wxART2D_USE_LUA
1601  if ( !wxDynamicCast( a2dGetCmdh(), a2dLuaCentralCommandProcessor ) )
1602  {
1603  ( void )wxMessageBox( _( "For this function a a2dLuaCentralCommandProcessor is needed" ), _( "Lua Scripts" ), wxICON_INFORMATION | wxOK );
1604  return;
1605  }
1606 
1608 
1609  wxString fullPath = wxFileSelector( _( "Select a script file" ),
1610  _( "" ),
1611  _( "" ),
1612  _( "lua" ),
1613  _( "*.lua" ) ,
1614  0,
1615  this
1616  );
1617 
1618  if ( !fullPath.IsEmpty() && ::wxFileExists( fullPath ) )
1619  {
1620  if ( !luacmd->ExecuteFile( fullPath ) )
1621  {
1622  wxLogWarning( _( "Error in Lua Script" ) );
1623  }
1624  }
1625 #endif
1626 }
1627 
1628 void a2dLuaEditorFrame::OnUpdateUI( wxUpdateUIEvent& event )
1629 {
1631  if ( event.GetId() == EXECDLG_lua )
1632  {
1633  m_menuBar->Check( event.GetId(), luacmd->IsShowna2dLuaExecDlg() );
1634  }
1635 
1636 }
1637 
1638 bool a2dLuaEditorFrame::CallLuaScriptThemeFunction( const wxString& fileName, const wxString& function )
1639 {
1640  a2dLuaCentralCommandProcessor* luacmd = a2dGetLuaWP();
1641 
1642  wxLuaState lst = luacmd->GetLuaState();
1643  lua_State* L = lst.GetLuaState();
1644  if ( 0 != lst.RunFile( fileName ) )
1645  {
1646  wxLogWarning( _( "Error in Lua Script" ) );
1647  return false;
1648  }
1649  else
1650  {
1651  lua_getglobal( L, wx2lua( function ) );
1652  lst.wxluaT_PushUserDataType( this, wxluatype_a2dLuaEditorFrame, true );
1653  if ( lst.lua_PCall( 1, 0, 0 ) != 0 )
1654  {
1655  wxString error;
1656  error.Printf( wxT( "%s %s" ), function.c_str() , lua_tostring( L, -1 ) );
1657  wxLuaEvent event( wxEVT_LUA_ERROR, lst.GetId(), lst );
1658  event.SetString( error );
1659  lst.SendEvent( event );
1660  lua_pop( L, 1 );
1661  }
1662  }
1663  return true;
1664 }
virtual double GetDouble() const
when a2dDoubleProperty, return its value else assert
Definition: gen.cpp:1928
a2dCircle at x,y, and with radius
Definition: canprim.h:554
a2dCanvasObject * GetCurrentCanvasObject()
get the current canvas object to add to parent as child
Definition: drawing.h:1198
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
property to hold an unsigned 4 byte integer type variable to be associated with a a2dObject ...
Definition: gen.h:2453
(In) Visible property that can be added to Docview Objects.
Definition: gen.h:1785
virtual wxString GetString() const
when a2dStringProperty, return its value else assert
Definition: gen.cpp:1922
#define wxDynamicCast(obj, className)
Define wxDynamicCast so that it will give a compiler error for unrelated types.
Definition: gen.h:75
void SetRoot(a2dDrawing *root, bool recurse=true)
Sets this object to a a2dCanvasDocument.
Definition: canobj.cpp:5933
objects which fit the mask to bottom in parent (rendered first)
Definition: drawing.h:2999
a2dCanvasObjectReference is a reference to any a2dCanvasObject derived class.
Definition: recur.h:53
a2dEllipticArc * Add_a2dEllipticArc(double xc, double yc, double width, double height, double start, double end)
add specific object
Definition: luawrap.cpp:968
a2dPolygonL * Add_a2dPolygonL(a2dVertexList *points, bool spline=false)
add specific object
Definition: luawrap.cpp:1039
bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
Definition: luawrap.cpp:108
const a2dError a2dError_CommandError
used to move start or end point in line objects
Definition: drawing.h:2130
virtual void OnExit()
cleaup modeless dialogs created from here
Definition: luawrap.cpp:259
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: luawrap.cpp:196
convert segments in polygon/polyline with width objects in group A to Arcs where possible ...
Definition: drawing.h:2609
bool IsShowna2dLuaExecDlg()
if m_luaExecDlg is visible or not
Definition: luawrap.cpp:220
~a2dLuaCentralCommandProcessor()
destructor
Definition: luawrap.cpp:247
void SetLayer(wxUint16 layer, bool setStyleOfLayer=false)
Definition: canglob.cpp:1076
a2dPolylineL * Add_a2dPolylineL(a2dVertexList *points, bool spline=false)
add specific object
Definition: luawrap.cpp:1047
const a2dError a2dError_GetVar
a2dCanvasCommandProcessor * GetDrawingCmdProcessor()
get commandprocessor of document
Definition: cancom.h:240
void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
Definition: luawrap.cpp:180
class to map references to objects stored in XML, in order to make the connection later on...
Definition: gen.h:3462
a2dDrawing * m_root
root group for rendering and accessing the canvas&#39;s also contains layer settings
Definition: canobj.h:2525
virtual wxInt32 GetInt32() const
when a2dInt32Property, return its value else assert
Definition: gen.cpp:1958
#define EVT_RECORD(func)
event sent to a2dDocumentCommandProcessor when a document has been added to the a2dDocumentCommandPro...
Definition: doccom.h:183
View on a a2dCanvasDocument.
Definition: candoc.h:212
set cursor
Definition: drawing.h:4227
const a2dError a2dError_CouldNotEvaluatePath
static a2dPropertyIdTyped< basetype, proptype > * GetDummy()
returns a dummy property id of this type, that can be used in non-id applications ...
Definition: id.inl:389
a2dArrow * Add_a2dArrow(double xt, double yt, double l1, double l2, double b, bool spline=false)
add specific object
Definition: luawrap.cpp:936
a2dCanvasObject * GetRootObject() const
get the root object, which holds the objects in the document
Definition: drawing.h:521
a2dArc * Add_a2dArc(double xc, double yc, double radius, double start, double end)
add specific object
Definition: luawrap.cpp:976
a2dPin is used in a2dCanvasObject to add pins to it.
Definition: canpin.h:233
polygon defined with list of points.
Definition: polygon.h:45
a2dError FileOpen(a2dDocumentPtr &doc, const wxFileName &file=wxFileName(wxT("")), a2dTemplateFlagMask docTemplateFlags=a2dTemplateFlag::VISIBLE|a2dTemplateFlag::LOAD)
Creates a new document and reads in the selected file.
Definition: doccom.cpp:553
used to add points to polygon objects
Definition: drawing.h:1959
a2dRectC * Add_a2dRectC(double xc, double yc, double w, double h, double angle=0, double radius=0)
add specific object
Definition: luawrap.cpp:928
Ref Counted base object.
Definition: gen.h:1045
#define EVT_DO(func)
event sent from a2DocumentCommandProcessor when a command is initially done
Definition: comevt.h:795
const a2dError a2dError_NoError
objects which fit the mask to top in parent (rendered last)
Definition: drawing.h:2968
virtual bool Update(UpdateMode mode)
Update the state of the object according to its current position etc.
Definition: canobj.cpp:5149
property to hold a double type variable to be associated with a a2dObject
Definition: gen.h:2503
convert segments in polygon/polyline objects in group A to Arcs where possible
Definition: drawing.h:2606
see a2dCommandEvent
Definition: doccom.h:79
property to hold a bool type variable to be associated with a a2dObject
Definition: gen.h:2004
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
Defines a font to be set to a2dDrawer2D or stored in a2dCanvsObject etc.
Definition: stylebase.h:779
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:819
Path searching.
Definition: gen.h:2926
UpdateMode
Various mode flags for Update.
Definition: canobj.h:1091
virtual wxUint32 GetUint32() const
when a2dUint32Property, return its value else assert
Definition: gen.cpp:1964
OVERLAP
Result of a a2dBoundingBox intersection or hittest.
Definition: bbox.h:24
bool ParseCvgTransForm(a2dAffineMatrix &matrix, const wxString &str, wxString &error)
function to parse a string in SVG/CVG format and return the resulting matrix
Definition: afmatrix.cpp:890
convert shapes to polylines even if polygons
Definition: drawing.h:2613
convert to simple polygons and polylines
Definition: drawing.h:2607
a2dGlobal * a2dGlobals
global a2dCanvasGlobal to have easy access to global settings
Definition: artglob.cpp:34
a2dOrigin * Add_a2dOrigin(double w, double h)
add specific object
Definition: luawrap.cpp:920
a2dDrawing * GetDrawing() const
get the root object, which holds the objects in the document.
Definition: candoc.h:418
a2dPathList & GetIconPathList()
Path for Icons and small bitmaps.
Definition: artglob.h:155
a2dRectC is a centered rectangle
Definition: canprim.h:99
a2dCanvas * GetCanvas() const
Get the Display window of the a2dView. But casted to a a2dCanvas.
Definition: candoc.cpp:447
wxString GetName() const
Get the name of the a2dPropertyId object.
Definition: gen.h:1864
list of a2dNamedProperty objects
Definition: gen.h:804
convert shapes to vector paths
Definition: drawing.h:2611
a2dError FileNew(a2dDocumentPtr &doc, a2dTemplateFlagMask docTemplateFlags=a2dTemplateFlag::VISIBLE)
Creates a document from a list of templates (if more than one template).
Definition: doccom.cpp:535
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: canobj.cpp:5728
set layer of objects which fit the mask
Definition: drawing.h:2891
a2dCanvasObject is the base class for Canvas Objects.
Definition: canobj.h:371
a2dCanvasObjectList m_found
objects found
Definition: algos.h:384
a2dCanvasView * CheckDrawer() const
is a view with a2dCanvasView active
Definition: cancom.cpp:1726
property to hold a FileName type variable to be associated with a a2dObject
Definition: gen.h:3035
a2dEndsLine * Add_a2dEndsLine(double x1, double y1, double x2, double y2)
add specific object
Definition: luawrap.cpp:992
a2dLayers * GetLayerSetup()
Get the layersettings for the canvas.
Definition: candoc.h:555
a2dCanvasObjectList * GetChildObjectList()
get the list where the child objects are stored in.
Definition: canobj.cpp:2551
vertex list of line and arc segments.
Definition: polyver.h:600
property to hold a 2 byte integer type variable to be associated with a a2dObject ...
Definition: gen.h:2301
bool SaveLayers(const wxString &filename)
save layer object to CVG file
Definition: layerinf.cpp:615
const a2dNamedProperty * GetVariable(const wxString &variableName)
get an existing variable of unknown type (not cloned)
Definition: gen.cpp:4294
virtual void Update(unsigned int hint=0, wxObject *hintObject=NULL)
force a2dDocumentEvent ::wxEVT_UPDATE_VIEWS event
clear all layers in operation group B
Definition: drawing.h:3981
bool Create(bool createCanvas, bool isParent, wxFrame *parent, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE)
delayed creation of window.
Definition: canedit.cpp:278
objects which fit the mask are grouped into a new object
Definition: drawing.h:3126
clear all layers in operation group A
Definition: drawing.h:3980
used to theme a a2dEditorFrame
Definition: canedit.h:85
property to hold a 2 byte integer type variable to be associated with a a2dObject ...
Definition: gen.h:2401
static a2dErrorVector & GetErrors()
get the errors found sofar.
Definition: comevt.h:1136
bool SetVariable(const wxString &variableName, a2dNamedProperty *property)
set a new or replace an existing variable of arbitrary type
Definition: gen.cpp:4229
for changing only the matrix of objects for which a certain mask was set
Definition: drawing.h:1822
a2dText is an abstract base class.
Definition: cantext.h:93
collect a2dCanvasObject&#39;s in a hierarchy of a a2dCanvasDocument
Definition: algos.h:363
a2dPathList & GetFontPathList()
Path for Fonts.
Definition: artglob.h:149
command on selected objects
Definition: drawing.h:2471
a2dOrigin stays at World Coordinate Zero (0,0) not matter what.
Definition: canprim.h:31
const a2dStroke & GetStroke() const
get the current stroke
Definition: canglob.h:797
delete objects which fit the mask
Definition: drawing.h:2937
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
a2dEllipse centered at x,y.
Definition: canprim.h:635
delete group A objects
Definition: drawing.h:2603
polyline defined with list of points.
Definition: polygon.h:332
bool FileSaveAs(const wxFileName &file=wxFileName(wxT("")), a2dDocumentFlagMask flags=a2dREFDOC_NON)
Calls wxDocument::SaveAs for the current document.
Definition: doccom.cpp:766
bool SubmitToDrawing(a2dCommand *command, bool storeIt=true)
Submit a command to the active drawing.
Definition: cancom.cpp:1004
a2dCanvasObjectReference * Add_a2dCanvasObjectReference(double x, double y, a2dCanvasObject *obj)
add specific object
Definition: luawrap.cpp:902
virtual bool GetBool() const
when a2dBoolProperty, return its value else assert
Definition: gen.cpp:1940
a2dEllipse * Add_a2dEllipse(double xc, double yc, double width, double height)
add specific object
Definition: luawrap.cpp:960
#define wxStaticCast(obj, className)
The wxWindows 2.4.2 wxStaticCast is buggy. It evaluates its argument twice.
Definition: gen.h:123
a2dCanvasObject * GetShowObject() const
return pointer of then currently shown object on the drawer.
Definition: drawer.h:680
a2dImage (will scale/rotate image when needed)
Definition: canimage.h:33
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: luawrap.cpp:185
a2dSLine
Definition: canprim.h:987
A2DGENERALDLLEXP a2dSmrtPtr< a2dGeneralGlobal > a2dGeneralGlobals
a global pointer to get to global instance of important classes.
Definition: comevt.cpp:1148
Set a string variable inside wxDocview.
Definition: comevt.h:1277
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: canobj.cpp:5569
void SetTarget(wxUint16 target)
set target layer in operation
Definition: canglob.cpp:1088
void Translate(double x, double y)
relative translate the object to position x,y in world coordinates
Definition: canobj.h:569
objects which fit the mask are copied to target and translated
Definition: drawing.h:3031
convert to simple polygons and polylines
Definition: drawing.h:2608
void Prepend(a2dCanvasObject *obj)
prepend a a2dCanvasObject to the childobjects
Definition: canobj.cpp:6209
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:862
static const a2dCanvasObjectFlagsMask SELECTED
Definition: candefs.h:180
a2dLuaEditorFrame * GetActiveEditorFrame()
if active view has as display frame a a2dLuaEditorFrame, return it.
Definition: luawrap.cpp:320
a2dVariablesHash & GetVariablesHash()
aliases list for setting internal variables
Definition: comevt.h:1168
virtual wxUint16 GetUint16() const
when a2dUint16Property, return its value else assert
Definition: gen.cpp:1952
bool FileImport(const wxFileName &file=wxFileName(wxT("")), const wxString &description=wxT(""), a2dDocumentFlagMask flags=a2dREFDOC_NON)
Calls a2dDocument::Import for the current document.
Definition: doccom.cpp:900
#define EVT_THEME_EVENT(func)
static wxEvtHandler for theme event, send from a2dEditorFrame
Definition: canedit.h:111
a2dCircle * Add_a2dCircle(double x, double y, double radius)
add specific object
Definition: luawrap.cpp:952
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: luawrap.cpp:61
bool GetDoLog()
Is logging to wxLog target on or off?
Definition: comevt.h:1162
a2dArrow is used for having line begin and ends on specific objects.
Definition: canprim.h:198
Each a2dCommand is given a command id at construction.
Definition: comevt.h:99
a2dPathList & GetImagePathList()
Path for Images.
Definition: artglob.h:152
sepcialized Frame for editor of a2dCanvas
Definition: luawrap.h:429
a2dText * Add_a2dText(const wxString &text, double x, double y, double angle, const a2dFont &font)
add specific object
Definition: luawrap.cpp:1031
virtual bool Submit(a2dCommand *command, bool storeIt=true)
next to the base class submit, it sets a2DocumentCommandProcessor for a2dCommand
Definition: comevt.cpp:842
property to hold a wxString type variable to be associated with a a2dObject
Definition: gen.h:2066
A 2x3 affine matrix class for 2D transformations.
Definition: afmatrix.h:53
bool LoadLayers(const wxString &filename)
save layers to a file
Definition: layerinf.cpp:576
void AddGroupB(wxUint16 layer)
add layer to group B layers
Definition: canglob.h:667
virtual wxWindow * GetAssociatedWindow() const
Returns a window that can be used as a parent for document-related dialogs. Override if necessary...
convert segments in polyline objects in group A to Arcs where possible
Definition: drawing.h:2610
while iterating a a2dCanvasDocument, this holds the context.
Definition: canobj.h:3212
bool Start(a2dCanvasObject *object)
Definition: algos.cpp:409
All updates of these modes force an update (e.g. update non-pending valid bounding boxes) ...
Definition: canobj.h:1107
void AddGroupA(wxUint16 layer)
add layer to group A layers
Definition: canglob.h:664
a2dCommandProcessor * GetCommandProcessor() const
Returns a pointer to the command processor associated with this document.
Definition: drawing.h:549
virtual float GetFloat() const
when a2dFloatProperty, return its value else assert
Definition: gen.cpp:1934
const a2dFill & GetFill() const
get the current fill
Definition: canglob.h:804
virtual bool Submit(a2dCommand *command, bool storeIt=true)
Definition: drawing.cpp:5966
a2dDocviewGlobal * a2dDocviewGlobals
a global pointer to get to global instance of important classes.
Definition: doccom.cpp:2348
a2dCanvasObject * Add_a2dCanvasObject(double x=0, double y=0)
add specific object
Definition: luawrap.cpp:894
a2dLuaEditorFrame()
this makes dynamic creation possible ( e.g. a derived a2dLuaEditorFrame )
Definition: luawrap.cpp:1552
virtual wxInt16 GetInt16() const
when a2dInt16Property, return its value else assert
Definition: gen.cpp:1946
a2dDoWhat
defines what to do
Definition: drawing.h:2601
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
a2dCanvasObjectLua(double x=0, double y=0, const wxString &script=wxT(""), const wxString &function=wxT(""))
construct at given position
Definition: luawrap.cpp:42
void SetDoLog(bool onOff)
Set logging to wxLog target on or off.
Definition: comevt.h:1159
Lua script used to draw the object.
Definition: luawrap.h:57
a2dRestrictionEngine * GetRestrictionEngine()
Get restriction engine (grid snapping)
Definition: canglob.cpp:934
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
sepcialized Frame for editor of a2dCanvas
Definition: canedit.h:117
create new group at x,y
Definition: drawing.h:2708
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
a2dCanvasCommandProcessor * GetCanvasCommandProcessor()
get a pointer to the command processor
Definition: drawing.cpp:375
a2dPathList & GetConfigPathList()
Path(s) for configuration file(s) in an application.
Definition: comevt.h:1174
a2dEndsLine with begin and/or end object.
Definition: canprim.h:1174
bool SetVariableString(const wxString &variableName, const wxString &value)
set a new or replace an existing wxString variable
Definition: gen.cpp:4255
a2dCanvasObject * SetShowObject(const wxString &name)
set object available in the a2dDrawing to be shown on the drawer
Definition: drawer.cpp:2947
void AddFunctionToMenu(int id, wxMenu *parentMenu, const wxString &text, const wxString &helpString, wxObjectEventFunctionM func, bool check=false)
add a menu which executes a function
Definition: canedit.cpp:683
list for a2dCanvasObject
static a2dPinClass * Standard
Pins of this class can only connect to pins of the same class.
Definition: canpin.h:766
select all objects
Definition: drawing.h:2486
virtual ~a2dCanvasObjectLua()
destructor
Definition: luawrap.cpp:52
a2dImage * Add_a2dImage(const wxImage &image, double xc, double yc, double w, double h)
add specific object
Definition: luawrap.cpp:1000
virtual void ReportErrorF(const a2dError &error, const wxChar *Format,...)
concatenate to the the error report the given error.
Definition: comevt.cpp:1312
layer group A and B commands
Definition: drawing.h:3961
a2dPathList & GetLayersPathList() const
Path for Icons and small bitmaps.
Definition: canglob.h:1234
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
a2dRect * Add_a2dRect(double x, double y, double w, double h, double radius=0)
add specific object
Definition: luawrap.cpp:944
const a2dError a2dError_NotSpecified
void SetLayerSetup(a2dLayers *layersetup)
set the layersettings for the canvas library.
Definition: canglob.cpp:1071
command to show a dialog
Definition: cancom.h:762
virtual wxString StringValueRepresentation() const
Definition: gen.h:1905
a2dRect
Definition: canprim.h:440
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
Definition: bbox.h:39
de-select all objects
Definition: drawing.h:2487
a2dSLine * Add_a2dSLine(double x1, double y1, double x2, double y2)
add specific object
Definition: luawrap.cpp:984
a2dDrawing * GetDrawing() const
get drawing via top object
Definition: drawer.cpp:726
bool SetDrawerStyle(const a2dFill &brush, const a2dStroke &stroke, a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL)
set only in this list fill and stroke of objects with the given mask
Definition: objlist.cpp:607
a2dArc centered at x,y
Definition: canprim.h:823
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.
move group A objects
Definition: drawing.h:2604
copy group A objects
Definition: drawing.h:2605
a2dCanvasGlobal * a2dCanvasGlobals
global a2dCanvasGlobal to have easy access to global settings
Definition: canglob.cpp:1234
objects which fit the mask are grouped into a new object
Definition: drawing.h:3170
#define EVT_UNDO(func)
event sent from a2DocumentCommandProcessor when a command is undone
Definition: comevt.h:797
a command wrapper specially designed to work with wxArt2D docview classes and rest.
Definition: cancom.h:100
holds one error report.
Definition: gen.h:623
all headers in the editor module
void SetSnap(bool snap)
enable all snapping features or not
Definition: restrict.h:189
static const a2dCanvasObjectFlagsMask ALL
Definition: candefs.h:220
command on selected objects
Definition: drawing.h:2589
objects which fit the mask are moved to target and translated
Definition: drawing.h:3078
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
property to hold a FileName type variable to be associated with a a2dObject
Definition: gen.h:2656
objects which fit the mask are given an Url property
Definition: drawing.h:3433
list of a2dObject&#39;s
Definition: gen.h:3157
property to hold a float type variable to be associated with a a2dObject
Definition: gen.h:2553
CloneOptions
options for cloning
Definition: gen.h:1200
convert shapes to seperate lines and arcs
Definition: drawing.h:2612
Contain one drawing as hierarchical tree of a2dCanvasObject&#39;s.
Definition: drawing.h:434
property to hold an unsigned 2 byte integer type variable to be associated with a a2dObject ...
Definition: gen.h:2351
void SetSnapTargetFeatures(wxUint32 snapTargetFeatures)
Definition: restrict.h:231
a2dEllipticArc centered at x,y
Definition: canprim.h:697
void SetLayerSetup(a2dLayers *layersetup)
set the layersettings for the canvas.
Definition: candoc.cpp:780
&lt; generate a report of small objects
Definition: drawing.h:2615
luawrap.cpp Source File -- Sun Oct 12 2014 17:04:22 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation