00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef __WXCANDOCPROC_H__
00016 #define __WXCANDOCPROC_H__
00017
00018 #ifndef WX_PRECOMP
00019 #include "wx/wx.h"
00020 #endif
00021
00022 #include "wx/cmdproc.h"
00023
00024 #include "wx/editor/edit.h"
00025 #include "wx/editor/sttool.h"
00026 #include "wx/editor/sttool2.h"
00027 #include "wx/editor/sttoolext.h"
00028 #include "wx/editor/sttoolmes.h"
00029 #include "wx/editor/snap.h"
00030 #if wxART2D_USE_CANEXTOBJ
00031 #include "wx/canextobj/canextmod.h"
00032 #include "wx/canextobj/imageioh.h"
00033 #endif //wxART2D_USE_CANEXTOBJ
00034 #include "wx/canvas/cancom.h"
00035
00036 class a2dCoordinateEntry;
00037
00038 class A2DEDITORDLLEXP ToolDlg;
00039
00040 class A2DEDITORDLLEXP a2dStyleDialog;
00041
00042 class A2DEDITORDLLEXP LayerPropertiesDialog;
00043
00044 class A2DEDITORDLLEXP a2dLayerOrderDialog;
00045
00046 class A2DEDITORDLLEXP a2dLayerDialog;
00047
00048 class A2DEDITORDLLEXP IdentifyDialog;
00049
00050 class A2DEDITORDLLEXP ExecDlg;
00051
00052 class A2DEDITORDLLEXP a2dCentralEditorCommandProcessor;
00053
00054 class A2DEDITORDLLEXP a2dPathSettings;
00055
00056 class A2DEDITORDLLEXP a2dPathSettings;
00057
00058 class A2DEDITORDLLEXP a2dSettings;
00059
00060 class A2DEDITORDLLEXP a2dTransDlg;
00061
00062 class A2DEDITORDLLEXP a2dPropertyEditorDlg;
00063
00064 class A2DEDITORDLLEXP a2dCanvasObjectsDialog;
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 class A2DEDITORDLLEXP a2dEditorModule : public wxModule
00075 {
00076 public:
00077
00078 a2dEditorModule();
00079
00080 virtual bool OnInit();
00081 virtual void OnExit();
00082
00083 private:
00084 DECLARE_DYNAMIC_CLASS(a2dEditorModule)
00085
00086 a2dSmrtPtr<a2dDocumentCommandProcessor> m_prevCmdProc;
00087 a2dSmrtPtr<a2dCentralEditorCommandProcessor> m_currentCmdProc;
00088 };
00089
00090 extern const a2dMenuIdItem CmdMenu_PopTool;
00091 extern const a2dMenuIdItem CmdMenu_InsertGroupRef;
00092 extern const a2dMenuIdItem CmdMenu_ShowDlgLayers;
00093 extern const a2dMenuIdItem CmdMenu_ShowDlgLayersDocument;
00094 extern const a2dMenuIdItem CmdMenu_ShowDlgLayersGlobal;
00095 extern const a2dMenuIdItem CmdMenu_ShowDlgLayerOrderDocument;
00096 extern const a2dMenuIdItem CmdMenu_ShowDlgLayerOrderGlobal;
00097 extern const a2dMenuIdItem CmdMenu_ShowDlgTools;
00098 extern const a2dMenuIdItem CmdMenu_ShowDlgStyle;
00099 extern const a2dMenuIdItem CmdMenu_ShowDlgSnap;
00100 extern const a2dMenuIdItem CmdMenu_ShowDlgGroups;
00101 extern const a2dMenuIdItem CmdMenu_ShowDlgIdentify;
00102 extern const a2dMenuIdItem CmdMenu_ShowDlgCoordEntry;
00103 extern const a2dMenuIdItem CmdMenu_ShowDlgMeasure;
00104 extern const a2dMenuIdItem CmdMenu_ShowDlgStructure;
00105 extern const a2dMenuIdItem CmdMenu_ShowDlgStructureModal;
00106 extern const a2dMenuIdItem CmdMenu_ShowDlgPathSettings;
00107 extern const a2dMenuIdItem CmdMenu_ShowDlgSettings;
00108 extern const a2dMenuIdItem CmdMenu_ShowDlgTrans;
00109 extern const a2dMenuIdItem CmdMenu_ShowDlgPropEdit;
00110
00111 extern const a2dMenuIdItem CmdMenu_SetFont;
00112
00113 extern const a2dMenuIdItem CmdMenu_PushTool_Zoom;
00114 extern const a2dMenuIdItem CmdMenu_PushTool_FastZoom;
00115 extern const a2dMenuIdItem CmdMenu_PushTool_Select;
00116 extern const a2dMenuIdItem CmdMenu_PushTool_Select2;
00117 extern const a2dMenuIdItem CmdMenu_PushTool_FastSelect;
00118 extern const a2dMenuIdItem CmdMenu_PushTool_FastSelect2;
00119 extern const a2dMenuIdItem CmdMenu_PushTool_RecursiveEdit;
00120 extern const a2dMenuIdItem CmdMenu_PushTool_MultiEdit;
00121 extern const a2dMenuIdItem CmdMenu_PushTool_Drag;
00122 extern const a2dMenuIdItem CmdMenu_PushTool_DragOriginal;
00123 extern const a2dMenuIdItem CmdMenu_PushTool_RenderImageZoom;
00124 extern const a2dMenuIdItem CmdMenu_PushTool_Copy;
00125 extern const a2dMenuIdItem CmdMenu_PushTool_Rotate;
00126 extern const a2dMenuIdItem CmdMenu_PushTool_Delete;
00127 extern const a2dMenuIdItem CmdMenu_PushTool_DrawText;
00128 extern const a2dMenuIdItem CmdMenu_PushTool_Image;
00129 extern const a2dMenuIdItem CmdMenu_PushTool_DrawRectangleFast;
00130 extern const a2dMenuIdItem CmdMenu_PushTool_DrawRectangle;
00131 extern const a2dMenuIdItem CmdMenu_PushTool_DrawCircle;
00132 extern const a2dMenuIdItem CmdMenu_PushTool_DrawCircleFast;
00133 extern const a2dMenuIdItem CmdMenu_PushTool_DrawLine;
00134 extern const a2dMenuIdItem CmdMenu_PushTool_DrawLineScaledArrow;
00135 extern const a2dMenuIdItem CmdMenu_PushTool_DrawEllipse;
00136 extern const a2dMenuIdItem CmdMenu_PushTool_DrawEllipticArc;
00137 extern const a2dMenuIdItem CmdMenu_PushTool_DrawEllipticArc_Chord;
00138 extern const a2dMenuIdItem CmdMenu_PushTool_DrawArc;
00139 extern const a2dMenuIdItem CmdMenu_PushTool_DrawArc_Chord;
00140 extern const a2dMenuIdItem CmdMenu_PushTool_DrawPolylineL;
00141 extern const a2dMenuIdItem CmdMenu_PushTool_DrawPolylineL_Splined;
00142 extern const a2dMenuIdItem CmdMenu_PushTool_DrawPolylineLFast;
00143 extern const a2dMenuIdItem CmdMenu_PushTool_DrawPolygonL;
00144 extern const a2dMenuIdItem CmdMenu_PushTool_DrawPolygonL_Splined;
00145 extern const a2dMenuIdItem CmdMenu_PushTool_DrawPolygonLFast;
00146 extern const a2dMenuIdItem CmdMenu_PushTool_Property;
00147 extern const a2dMenuIdItem CmdMenu_PushTool_DragMulti;
00148 extern const a2dMenuIdItem CmdMenu_PushTool_FastDragMulti;
00149 extern const a2dMenuIdItem CmdMenu_PushTool_CopyMulti;
00150 extern const a2dMenuIdItem CmdMenu_PushTool_FastCopyMulti;
00151 extern const a2dMenuIdItem CmdMenu_PushTool_Measure;
00152 extern const a2dMenuIdItem CmdMenu_PushTool_DrawWirePolylineL;
00153 extern const a2dMenuIdItem CmdMenu_PushTool_DrawVPath;
00154
00155 extern const a2dMenuIdItem CmdMenu_SetMasterTool_SelectFirst;
00156 extern const a2dMenuIdItem CmdMenu_SetMasterTool_ZoomFirst;
00157
00158 extern const a2dMenuIdItem CmdMenu_LineBegin;
00159 extern const a2dMenuIdItem CmdMenu_LineEnd;
00160 extern const a2dMenuIdItem CmdMenu_LineScale;
00161
00162 extern const a2dMenuIdItem CmdMenu_SetLayerDlg;
00163 extern const a2dMenuIdItem CmdMenu_SetTargetDlg;
00164 extern const a2dMenuIdItem CmdMenu_SetLayerDlgModeless;
00165 extern const a2dMenuIdItem CmdMenu_SetBackgroundStyle;
00166
00167 extern const a2dMenuIdItem CmdMenu_ViewAsImage;
00168 extern const a2dMenuIdItem CmdMenu_ViewAsImage_Png;
00169 extern const a2dMenuIdItem CmdMenu_ViewAsImage_Bmp;
00170 extern const a2dMenuIdItem CmdMenu_DocumentAsImage_Png;
00171 extern const a2dMenuIdItem CmdMenu_DocumentAsImage_Bmp;
00172 extern const a2dMenuIdItem CmdMenu_DocumentAsOdbXml;
00173 extern const a2dMenuIdItem CmdMenu_ViewAsSvg;
00174
00175 extern const a2dMenuIdItem CmdMenu_Selected_MoveXY;
00176 extern const a2dMenuIdItem CmdMenu_Selected_MoveLayer;
00177 extern const a2dMenuIdItem CmdMenu_Selected_CopyXY;
00178 extern const a2dMenuIdItem CmdMenu_Selected_CopyLayer;
00179 extern const a2dMenuIdItem CmdMenu_Selected_Transform;
00180
00181
00182
00183
00184
00185
00186
00187 class A2DEDITORDLLEXP a2dCentralEditorCommandProcessor : public a2dCentralCanvasCommandProcessor
00188 {
00189 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
00190 a2dInitCurrentSmartPointerOwner m_initCurrentSmartPointerOwner;
00191 #endif
00192
00193 A2D_DECLARE_EVENT_TABLE()
00194 DECLARE_CLASS(a2dCentralEditorCommandProcessor)
00195
00196 public:
00197
00198 static const a2dCommandId COMID_PopTool;
00199 static const a2dCommandId COMID_InsertGroupRef;
00200 static const a2dCommandId COMID_ShowDlgLayers;
00201 static const a2dCommandId COMID_ShowDlgLayersDocument;
00202 static const a2dCommandId COMID_ShowDlgLayersGlobal;
00203 static const a2dCommandId COMID_ShowDlgLayerOrderDocument;
00204 static const a2dCommandId COMID_ShowDlgLayerOrderGlobal;
00205 static const a2dCommandId COMID_ShowDlgTools;
00206 static const a2dCommandId COMID_ShowDlgStyle;
00207 static const a2dCommandId COMID_ShowDlgSnap;
00208 static const a2dCommandId COMID_ShowDlgGroups;
00209 static const a2dCommandId COMID_ShowDlgIdentify;
00210 static const a2dCommandId COMID_ShowDlgCoordEntry;
00211 static const a2dCommandId COMID_ShowDlgMeasure;
00212 static const a2dCommandId COMID_ShowDlgStructure;
00213 static const a2dCommandId COMID_ShowDlgPathSettings;
00214 static const a2dCommandId COMID_ShowDlgSettings;
00215 static const a2dCommandId COMID_ShowDlgTrans;
00216 static const a2dCommandId COMID_ShowDlgPropEdit;
00217
00218 public:
00219
00220
00221 a2dCentralEditorCommandProcessor(long flags = a2dDEFAULT_DOCUMENT_FLAGS,
00222 bool initialize = true,
00223 int maxCommands = -1 );
00224
00225
00226 a2dCentralEditorCommandProcessor( a2dDocumentCommandProcessor* other );
00227
00228
00229 ~a2dCentralEditorCommandProcessor();
00230
00231 void OnEditProperties( a2dPropertyEditEvent& event );
00232
00233 void OnUpdateMenu(wxUpdateUIEvent& event);
00234
00235 void OnMenu( wxCommandEvent& event );
00236
00237
00238 virtual void OnExit();
00239
00240 virtual bool ShowDlg( const a2dCommandId* comID, bool modal, bool onTop );
00241
00242 void DeleteDlgs();
00243
00244 bool IsShownToolDlg();
00245
00246 bool IsShowna2dStyleDialog();
00247
00248 bool IsShownLayerPropertiesDialog();
00249
00250 bool IsShownLayerOrderDialog();
00251
00252 bool IsShownIdentifyDialog();
00253
00254 bool IsShowna2dSnapSettings();
00255
00256 bool IsShowna2dCoordinateEntry();
00257
00258 bool IsShowna2dMeasureDlg();
00259
00260 bool IsShowna2dPathSettings();
00261
00262 bool IsShowna2dSettings();
00263
00264 bool IsShowna2dTransDlg();
00265
00266 bool IsShownPropEditDlg();
00267
00268 bool IsShownStructureDlg();
00269
00270 protected:
00271
00272 bool InsertGroupRef();
00273
00274 ToolDlg* m_tooldlg;
00275
00276 a2dStyleDialog* m_styledlg;
00277
00278 LayerPropertiesDialog* m_layersdlg;
00279
00280 a2dLayerOrderDialog* m_layerOrderDlg;
00281
00282 a2dLayerDialog* m_layerChooseDlg;
00283
00284 IdentifyDialog* m_identifyDlg;
00285
00286 a2dSnapSettings* m_snapSettings;
00287
00288 a2dCoordinateEntry* m_coordEntry;
00289
00290 a2dMeasureDlg* m_measure;
00291
00292 a2dPathSettings* m_pathsettings;
00293
00294 a2dSettings* m_settings;
00295
00296 a2dTransDlg* m_transset;
00297
00298 a2dPropertyEditorDlg* m_propEdit;
00299
00300 a2dCanvasObjectsDialog* m_structDlg;
00301
00302 };
00303
00304 A2DEDITORDLLEXP extern a2dCentralEditorCommandProcessor* a2dGetCmdhEditor();
00305
00306
00307
00308
00309
00310
00311 class A2DEDITORDLLEXP a2dCommand_PushTool: public a2dCommand
00312 {
00313 DECLARE_DYNAMIC_CLASS(a2dCommand_PushTool)
00314
00315 public:
00316
00317
00318
00319
00320 static const a2dCommandId Id;
00321
00322 class A2DEDITORDLLEXP Args
00323 {
00324 public:
00325 Args()
00326 {
00327 argSet.which = false;
00328 argSet.shiftadd = false;
00329 }
00330
00331 Args& which( const a2dCommandId& arg)
00332 {
00333 this->argValue.which = &arg;
00334 this->argSet.which = true;
00335 return *this;
00336 }
00337
00338 A2D_ARGUMENT_SETTER( bool, shiftadd )
00339
00340 struct argValue
00341 {
00342 const a2dCommandId* which;
00343 bool shiftadd;
00344 } argValue;
00345
00346 struct argSet
00347 {
00348 bool which;
00349 bool shiftadd;
00350 } argSet;
00351 };
00352
00353 a2dCommand_PushTool( const a2dCommandId& which = a2dZoomTool::COMID_PushTool_Zoom ): a2dCommand( false, Id )
00354 {
00355 m_args.argSet.which = true;
00356 m_args.argValue.which = &which;
00357 }
00358
00359 a2dCommand_PushTool( const Args& args ): a2dCommand( false, Id )
00360 {
00361 m_args = args;
00362 }
00363
00364 virtual a2dObject* Clone( CloneOptions options = clone_deep ) const
00365 {
00366 return new a2dCommand_PushTool( m_args );
00367 }
00368
00369 bool Do();
00370 bool Undo();
00371
00372 inline a2dCentralCanvasCommandProcessor *GetCanvasCmp() { return wxStaticCast( m_cmp, a2dCentralCanvasCommandProcessor); }
00373
00374
00375 private:
00376
00377 Args m_args;
00378
00379 };
00380
00381
00382
00383
00384
00385 class A2DEDITORDLLEXP a2dCommand_ShowDlg: public a2dCommand
00386 {
00387 DECLARE_DYNAMIC_CLASS(a2dCommand_ShowDlg)
00388
00389 public:
00390
00391
00392
00393
00394 static const a2dCommandId Id;
00395
00396 class A2DEDITORDLLEXP Args
00397 {
00398 public:
00399 Args()
00400 {
00401 argSet.which = false;
00402 argSet.modal = false;
00403 argValue.modal = false;
00404 argValue.onTop = false;
00405 }
00406
00407 Args& which( const a2dCommandId& arg)
00408 {
00409 this->argValue.which = &arg;
00410 this->argSet.which = true;
00411 return *this;
00412 }
00413
00414 A2D_ARGUMENT_SETTER( bool, modal )
00415 A2D_ARGUMENT_SETTER( bool, onTop )
00416
00417 struct argValue
00418 {
00419 const a2dCommandId* which;
00420 bool modal;
00421 bool onTop;
00422 } argValue;
00423
00424 struct argSet
00425 {
00426 bool which;
00427 bool modal;
00428 bool onTop;
00429 } argSet;
00430 };
00431
00432 a2dCommand_ShowDlg( const a2dCommandId& which = a2dCentralEditorCommandProcessor::COMID_ShowDlgStyle, bool modal = false, bool onTop = true ): a2dCommand( false, Id )
00433 {
00434 m_args.argSet.which = true;
00435 m_args.argValue.which = &which;
00436 m_args.argSet.modal = true;
00437 m_args.argValue.modal = modal;
00438 m_args.argValue.onTop = onTop;
00439 }
00440
00441 a2dCommand_ShowDlg( const Args& args ): a2dCommand( false, Id )
00442 {
00443 m_args = args;
00444 }
00445
00446 virtual a2dObject* Clone( CloneOptions options = clone_deep ) const
00447 {
00448 return new a2dCommand_ShowDlg( m_args );
00449 }
00450
00451 inline a2dCentralEditorCommandProcessor *GetCanvasCmp() { return wxStaticCast( m_cmp, a2dCentralEditorCommandProcessor); }
00452
00453 private:
00454
00455 Args m_args;
00456
00457 virtual bool Do()
00458 {
00459 return GetCanvasCmp()->ShowDlg( m_args.argValue.which, m_args.argValue.modal, m_args.argValue.onTop );
00460 }
00461
00462 virtual bool Undo()
00463 {
00464 return false;
00465 }
00466 };
00467
00468
00469
00470
00471
00472 class A2DCANVASDLLEXP a2dCommand_ViewAsImageAdv: public a2dCommand
00473 {
00474 DECLARE_DYNAMIC_CLASS(a2dCommand_ViewAsImageAdv)
00475 public:
00476
00477
00478
00479
00480 static const a2dCommandId Id;
00481
00482 class A2DCANVASDLLEXP Args
00483 {
00484 public:
00485 Args()
00486 {
00487 argSet.file = false;
00488 argSet.btype = false;
00489 argSet.onView = false;
00490 argValue.onView = false;
00491 argValue.btype = wxBITMAP_TYPE_PNG;
00492 }
00493
00494 A2D_ARGUMENT_SETTER( wxFileName, file )
00495 A2D_ARGUMENT_SETTER( wxBitmapType, btype )
00496 A2D_ARGUMENT_SETTER( bool, onView )
00497
00498 struct argValue
00499 {
00500 wxFileName file;
00501 wxBitmapType btype;
00502 bool onView;
00503 } argValue;
00504
00505 struct argSet
00506 {
00507 bool file;
00508 bool btype;
00509 bool onView;
00510 } argSet;
00511 };
00512
00513 a2dCommand_ViewAsImageAdv( const Args& args = Args() ): a2dCommand( false, Id )
00514 {
00515 m_args = args;
00516 if ( args.argSet.file )
00517 m_args.argValue.file = args.argValue.file;
00518 else
00519 throw a2dCommandException( _( "file argument must be set" ) );
00520 }
00521
00522 virtual a2dObject* Clone( CloneOptions options = clone_deep ) const
00523 {
00524 return new a2dCommand_ViewAsImageAdv( m_args );
00525 }
00526
00527 inline a2dCentralCanvasCommandProcessor *GetCanvasCmp() { return wxStaticCast( m_cmp, a2dCentralCanvasCommandProcessor); }
00528
00529 Args m_args;
00530
00531 protected:
00532
00533 virtual bool Do()
00534 {
00535 a2dCanvasDocument* doc = GetCanvasCmp()->CheckCanvasDocument();
00536 if ( !doc )
00537 return false;
00538 a2dCanvasView* drawer = GetCanvasCmp()->CheckDrawer();
00539 if ( !drawer )
00540 return false;
00541
00542 a2dPathList path;
00543 path.Add( wxT(".") );
00544 wxString foundfile = m_args.argValue.file.GetFullPath();
00545 if ( !path.ExpandPath( foundfile ) )
00546 {
00547 a2dDocviewGlobals->ReportErrorF( a2dError_CouldNotEvaluatePath, _("Could not expand %s resulted in %s"), m_args.argValue.file.GetFullPath().c_str(),foundfile.c_str() );
00548 return false;
00549 }
00550 if ( foundfile.IsEmpty() )
00551 {
00552 a2dDocviewGlobals->ReportErrorF( a2dError_NotSpecified, _("Filename %s not in %s"), foundfile.c_str(), path.GetAsString().c_str() );
00553 return false;
00554 }
00555
00556 a2dCanvasDocumentIOHandlerImageOut imagehout = a2dCanvasDocumentIOHandlerImageOut( m_args.argValue.btype );
00557 imagehout.SetBorder( 10 );
00558 imagehout.SetShowObject( drawer->GetShowObject() );
00559
00560 if ( m_args.argValue.onView )
00561 imagehout.SetViewRectangle( drawer->GetDrawer2D()->GetVisibleBbox() );
00562
00563 #if wxUSE_STD_IOSTREAM
00564 a2dDocumentFileOutputStream store( foundfile.mb_str() );
00565 if (store.fail() || store.bad())
00566 #else
00567 wxFileOutputStream storeUnbuf( foundfile );
00568 wxBufferedOutputStream store( storeUnbuf );
00569 if ( store.GetLastError() != wxSTREAM_NO_ERROR )
00570 #endif
00571 {
00572 a2dDocviewGlobals->ReportErrorF( a2dError_FileCouldNotOpen, _("Sorry, could not open file %s for saving"), foundfile.c_str() );
00573 return false;
00574 }
00575
00576 if ( ! doc->SaveObject( store, &imagehout ) )
00577 {
00578 a2dDocviewGlobals->ReportErrorF( a2dError_SaveFile, _("Sorry, could not save document to file %s"), foundfile.c_str() );
00579 return false;
00580 }
00581
00582 return true;
00583 }
00584
00585 virtual bool Undo()
00586 {
00587 return false;
00588 }
00589 };
00590
00591
00592 #endif
00593