Mod/Complete/Gui/Workbench.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "PreCompiled.h"
00025
00026 #ifndef _PreComp_
00027 # include <qobject.h>
00028 #endif
00029
00030 #include "Workbench.h"
00031 #include <Gui/ToolBarManager.h>
00032 #include <Gui/MenuManager.h>
00033 #include <Gui/ToolBarManager.h>
00034 #include <Gui/DockWindowManager.h>
00035 #include <Gui/Application.h>
00036 #include <Gui/Action.h>
00037 #include <Gui/Command.h>
00038 #include <Gui/Selection.h>
00039 #include <Gui/ToolBoxManager.h>
00040 #include <App/Document.h>
00041 #include <App/DocumentObject.h>
00042
00043 #include <Mod/Complete/App/CompleteConfiguration.h>
00044
00045 using namespace CompleteGui;
00046
00047 #if 0 // needed for Qt's lupdate utility
00048 qApp->translate("Workbench", "Ske&tch");
00049 qApp->translate("Workbench", "&Drawing");
00050 qApp->translate("Workbench", "&Raytracing");
00051 qApp->translate("Workbench", "&Drafting");
00052 qApp->translate("Workbench", "Sketch based");
00053 qApp->translate("Workbench", "Parametric");
00054 qApp->translate("Workbench", "Object appearence");
00055 qApp->translate("Workbench", "Wire Tools");
00056
00057 qApp->translate("Test_Test", "Self-test...");
00058 qApp->translate("Test_Test", "Runs a self-test to check if the application works properly");
00059 #endif
00060
00062 TYPESYSTEM_SOURCE(CompleteGui::Workbench, Gui::StdWorkbench)
00063
00064 Workbench::Workbench()
00065 {
00066 }
00067
00068 Workbench::~Workbench()
00069 {
00070 }
00071
00072 void Workbench::setupContextMenu(const char* recipient,Gui::MenuItem* item) const
00073 {
00074 if (strcmp(recipient,"View") == 0)
00075 {
00076 Gui::MenuItem* StdViews = new Gui::MenuItem();
00077 StdViews->setCommand( "Standard views" );
00078
00079 *StdViews << "Std_ViewAxo" << "Separator" << "Std_ViewFront" << "Std_ViewTop" << "Std_ViewRight"
00080 << "Std_ViewRear" << "Std_ViewBottom" << "Std_ViewLeft";
00081
00082 *item << "Std_ViewFitAll" << "Std_ViewFitSelection" << StdViews
00083 << "Separator" << "Std_ViewDockUndockFullscreen";
00084
00085 if ( Gui::Selection().countObjectsOfType(App::DocumentObject::getClassTypeId()) > 0 )
00086 {
00087 Gui::MenuItem* DraftContext = new Gui::MenuItem();
00088 DraftContext->setCommand("Display options");
00089
00090 *DraftContext << "Draft_ApplyStyle" << "Draft_ToggleDisplayMode"
00091 << "Draft_AddToGroup";
00092 *item << "Separator" << "Std_SetAppearance" << "Std_ToggleVisibility" << "Std_TreeSelection"
00093 << "Std_RandomColor" << "Separator" << "Std_Delete" << DraftContext;
00094 }
00095 }
00096 else if (strcmp(recipient,"Tree") == 0)
00097 {
00098 if ( Gui::Selection().countObjectsOfType(App::DocumentObject::getClassTypeId()) > 0 )
00099 {
00100 Gui::MenuItem* DraftContext = new Gui::MenuItem();
00101 DraftContext->setCommand("Display options");
00102
00103 *DraftContext << "Draft_ApplyStyle" << "Draft_ToggleDisplayMode"
00104 << "Draft_AddToGroup";
00105
00106 *item << "Std_SetAppearance" << "Std_ToggleVisibility"
00107 << "Std_RandomColor" << "Separator" << "Std_Delete"
00108 << DraftContext;
00109 }
00110
00111 }
00112 }
00113
00114 Gui::MenuItem* Workbench::setupMenuBar() const
00115 {
00116 Gui::CommandManager &mgr = Gui::Application::Instance->commandManager();
00117
00118 Gui::MenuItem* menuBar = new Gui::MenuItem;
00119
00120
00121 Gui::MenuItem* file = new Gui::MenuItem( menuBar );
00122 file->setCommand("&File");
00123 *file << "Std_New" << "Std_Open" << "Separator" << "Std_CloseActiveWindow"
00124 << "Std_CloseAllWindows" << "Separator" << "Std_Save" << "Std_SaveAs"
00125 << "Separator" << "Std_Import" << "Std_Export"
00126 << "Std_MergeProjects" << "Std_ProjectInfo"
00127 << "Separator" << "Std_Print" << "Std_PrintPreview" << "Std_PrintPdf"
00128 << "Separator" << "Std_RecentFiles" << "Separator" << "Std_Quit";
00129
00130
00131 Gui::MenuItem* edit = new Gui::MenuItem( menuBar );
00132 edit->setCommand("&Edit");
00133 *edit << "Std_Undo" << "Std_Redo" << "Separator" << "Std_Cut" << "Std_Copy"
00134 << "Std_Paste" << "Std_DuplicateSelection" << "Separator"
00135 << "Std_Refresh" << "Std_SelectAll" << "Std_Delete" << "Std_Placement"
00136 << "Separator" << "Std_DlgPreferences";
00137
00138
00139 Gui::MenuItem* stdviews = new Gui::MenuItem;
00140 stdviews->setCommand("Standard views");
00141 *stdviews << "Std_ViewFitAll" << "Std_ViewFitSelection" << "Std_ViewAxo"
00142 << "Separator" << "Std_ViewFront" << "Std_ViewRight"
00143 << "Std_ViewTop" << "Separator" << "Std_ViewRear"
00144 << "Std_ViewLeft" << "Std_ViewBottom";
00145
00146
00147 Gui::MenuItem* view3d = new Gui::MenuItem;
00148 view3d->setCommand("&Stereo");
00149 *view3d << "Std_ViewIvStereoRedGreen" << "Std_ViewIvStereoQuadBuff"
00150 << "Std_ViewIvStereoInterleavedRows" << "Std_ViewIvStereoInterleavedColumns"
00151 << "Std_ViewIvStereoOff" << "Separator" << "Std_ViewIvIssueCamPos";
00152
00153
00154 Gui::MenuItem* zoom = new Gui::MenuItem;
00155 zoom->setCommand("&Zoom");
00156 *zoom << "Std_ViewZoomIn" << "Std_ViewZoomOut" << "Separator" << "Std_ViewBoxZoom";
00157
00158
00159 Gui::MenuItem* visu = new Gui::MenuItem;
00160 visu->setCommand("Visibility");
00161 *visu << "Std_ToggleVisibility" << "Std_ShowSelection" << "Std_HideSelection"
00162 << "Separator" << "Std_ToggleObjects" << "Std_ShowObjects" << "Std_HideObjects"
00163 << "Separator" << "Std_ToggleSelectability";
00164
00165
00166 Gui::MenuItem* view = new Gui::MenuItem( menuBar );
00167 view->setCommand("&View");
00168 *view << "Std_ViewCreate" << "Std_OrthographicCamera" << "Std_PerspectiveCamera" << "Separator"
00169 << stdviews << "Std_FreezeViews" << "Separator" << view3d << "Std_DrawStyle" << zoom
00170 << "Std_ViewDockUndockFullscreen" << "Std_AxisCross" << "Std_ToggleClipPlane"
00171 << "Std_TextureMapping" << "Separator" << visu
00172 << "Std_ToggleVisibility" << "Std_ToggleNavigation"
00173 << "Std_SetAppearance" << "Std_RandomColor" << "Separator"
00174 << "Std_MeasureDistance" << "Separator"
00175 << "Std_Workbench" << "Std_ToolBarMenu" << "Std_DockViewMenu" << "Separator"
00176 << "Std_ViewStatusBar";
00177
00178
00179 Gui::MenuItem* tool = new Gui::MenuItem( menuBar );
00180 tool->setCommand("&Tools");
00181 *tool << "Std_DlgParameter" << "Separator"
00182 << "Std_DlgMacroRecord" << "Std_MacroStopRecord"
00183 << "Std_DlgMacroExecute" << "Std_DlgMacroExecuteDirect"
00184 << "Separator" << "Std_ViewScreenShot" << "Std_SceneInspector"
00185 << "Std_ProjectUtil" << "Std_DemoMode" << "Separator" << "Std_DlgCustomize";
00186
00187
00188 Gui::MenuItem* mesh = new Gui::MenuItem( menuBar );
00189
00190
00191 Gui::MenuItem* analyze = new Gui::MenuItem();
00192 analyze->setCommand("Analyze");
00193 *analyze << "Mesh_Evaluation"
00194 << "Mesh_EvaluateFacet"
00195 << "Mesh_CurvatureInfo"
00196 << "Separator"
00197 << "Mesh_EvaluateSolid"
00198 << "Mesh_BoundingBox";
00199
00200
00201 Gui::MenuItem* boolean = new Gui::MenuItem();
00202 boolean->setCommand("Boolean");
00203 *boolean << "Mesh_Union"
00204 << "Mesh_Intersection"
00205 << "Mesh_Difference";
00206
00207 mesh->setCommand("&Meshes");
00208 *mesh << "Mesh_Import"
00209 << "Mesh_Export"
00210 << "Mesh_FromGeometry"
00211 << "MeshPart_Mesher"
00212 << "Separator"
00213 << analyze
00214 << "Mesh_HarmonizeNormals"
00215 << "Mesh_FlipNormals"
00216 << "Separator"
00217 << "Mesh_FillupHoles"
00218 << "Mesh_FillInteractiveHole"
00219 << "Mesh_RemoveComponents"
00220 << "Mesh_RemoveCompByHand"
00221 << "Mesh_AddFacet"
00222 << "Mesh_Smoothing"
00223 << "Separator"
00224 << "Mesh_BuildRegularSolid"
00225 << boolean << "Separator"
00226 << "Mesh_PolySelect"
00227 << "Mesh_PolyCut"
00228 << "Mesh_PolySplit"
00229 << "Mesh_PolySegm"
00230 << "Mesh_ToolMesh"
00231 << "Mesh_VertexCurvature";
00232
00233
00234
00235 Gui::MenuItem* part = new Gui::MenuItem(menuBar);
00236 part->setCommand("&Part");
00237
00238
00239 Gui::MenuItem* para = new Gui::MenuItem();
00240 para->setCommand("Parametric");
00241 *para << "Part_Box"
00242 << "Part_Cylinder"
00243 << "Part_Sphere"
00244 << "Part_Cone"
00245 << "Part_Torus"
00246 << "Part_Primitives";
00247
00248 Gui::MenuItem* PartDesign = new Gui::MenuItem();
00249 PartDesign->setCommand("Part design");
00250
00251 *PartDesign << "Sketcher_NewSketch"
00252 << "Sketcher_LeaveSketch"
00253 << "Sketcher_ViewSketch"
00254 << "Sketcher_MapSketch"
00255 << "Separator"
00256 << "Sketcher_CreateArc"
00257 << "Sketcher_CreateCircle"
00258 << "Sketcher_CreateLine"
00259 << "Sketcher_CreatePolyline"
00260 << "Sketcher_CreateRectangle"
00261 << "Sketcher_CreateFillet"
00262 << "Sketcher_Trimming"
00263 << "Sketcher_ToggleConstruction"
00264 << "Separator"
00265 << "Sketcher_ConstrainLock"
00266 << "Sketcher_ConstrainCoincident"
00267 << "Sketcher_ConstrainPointOnObject"
00268 << "Sketcher_ConstrainDistanceX"
00269 << "Sketcher_ConstrainDistanceY"
00270 << "Sketcher_ConstrainVertical"
00271 << "Sketcher_ConstrainHorizontal"
00272 << "Sketcher_ConstrainDistance"
00273 << "Sketcher_ConstrainRadius"
00274 << "Sketcher_ConstrainParallel"
00275 << "Sketcher_ConstrainPerpendicular"
00276 << "Sketcher_ConstrainAngle"
00277 << "Sketcher_ConstrainTangent"
00278 << "Sketcher_ConstrainEqual"
00279 << "Sketcher_ConstrainSymmetric"
00280 << "Separator"
00281 << "PartDesign_Pad"
00282 << "PartDesign_Pocket"
00283 << "PartDesign_Revolution"
00284 << "PartDesign_Fillet"
00285 << "PartDesign_Chamfer";
00286
00287
00288 *part << para
00289 << PartDesign
00290 << "Part_ShapeFromMesh"
00291 << "Part_MakeSolid"
00292 << "Part_ReverseShape"
00293 << "Part_SimpleCopy"
00294 << "Separator"
00295 << "Part_Boolean"
00296 << "Part_Extrude"
00297 << "Part_Revolve"
00298 << "Part_Mirror"
00299 << "Part_Fillet"
00300 << "PartDesign_Chamfer";
00301
00302
00303
00304
00305 Gui::MenuItem* drawing = new Gui::MenuItem(menuBar);
00306
00307 drawing->setCommand("&Drawing");
00308 *drawing
00309 << "Drawing_Open"
00310 << "Separator"
00311 << "Drawing_NewA3Landscape"
00312 << "Drawing_NewView"
00313 << "Drawing_ExportPage"
00314 << "Separator"
00315 << "Drawing_ProjectShape"
00316 ;
00317
00318
00319
00320 Gui::MenuItem* raytracing = new Gui::MenuItem(menuBar);
00321
00322 raytracing->setCommand("&Raytracing");
00323 *raytracing
00324 << "Raytracing_WriteView"
00325 << "Raytracing_WriteCamera"
00326 << "Raytracing_WritePart"
00327 << "Separator"
00328 << "Raytracing_NewPovrayProject"
00329 << "Raytracing_NewPartSegment"
00330 << "Raytracing_ExportProject";
00331 ;
00332
00333
00334 # ifdef COMPLETE_USE_DRAFTING
00335 if (mgr.getCommandByName("Draft_Line")) {
00336 Gui::MenuItem* Drafting = new Gui::MenuItem(menuBar);
00337 Drafting->setCommand("&Drafting");
00338
00339 Gui::MenuItem* DraftContext = new Gui::MenuItem();
00340 DraftContext->setCommand("Object appearence");
00341
00342 *DraftContext << "Draft_ApplyStyle" << "Draft_ToggleDisplayMode";
00343
00344 Gui::MenuItem* DraftWireTools = new Gui::MenuItem();
00345 DraftWireTools->setCommand("Wire Tools");
00346
00347 *DraftWireTools << "Draft_WireToBSpline" << "Draft_AddPoint" << "Draft_DelPoint";
00348
00349 *Drafting
00350 << "Draft_Line"
00351 << "Draft_Wire"
00352 << "Draft_Circle"
00353 << "Draft_Arc"
00354 << "Draft_Rectangle"
00355 << "Draft_Polygon"
00356 << "Draft_BSpline"
00357 << "Draft_Text"
00358 << "Draft_Dimension"
00359 << "Separator"
00360 << "Draft_Move"
00361 << "Draft_Rotate"
00362 << "Draft_Offset"
00363 << "Draft_Trimex"
00364 << "Draft_Upgrade"
00365 << "Draft_Downgrade"
00366 << "Draft_Scale"
00367 << "Draft_Edit"
00368 << "Draft_Drawing"
00369 << "Draft_Shape2DView"
00370 << DraftWireTools
00371 << DraftContext
00372 ;
00373 }
00374 # endif
00375
00376
00377
00378
00379
00380 Gui::MenuItem* wnd = new Gui::MenuItem( menuBar );
00381 wnd->setCommand("&Windows");
00382 *wnd << "Std_ActivateNextWindow" << "Std_ActivatePrevWindow" << "Separator"
00383 << "Std_TileWindows" << "Std_CascadeWindows"
00384 << "Std_ArrangeIcons" << "Separator" << "Std_WindowsMenu" << "Std_Windows";
00385
00386
00387
00388 Gui::MenuItem* sep = new Gui::MenuItem( menuBar );
00389 sep->setCommand( "Separator" );
00390
00391
00392 Gui::MenuItem* helpWebsites = new Gui::MenuItem;
00393 helpWebsites->setCommand("&Online-help");
00394 *helpWebsites << "Std_OnlineHelpWebsite"
00395 << "Std_FreeCADWebsite"
00396 << "Std_PythonWebsite";
00397
00398 Gui::MenuItem* help = new Gui::MenuItem( menuBar );
00399 help->setCommand("&Help");
00400 *help << "Std_OnlineHelp"
00401 << "Std_OnlineHelpPython"
00402 << "Std_PythonHelp"
00403 << helpWebsites
00404 << "Separator"
00405 << "Test_Test"
00406 << "Separator"
00407 << "Std_About"
00408 << "Std_AboutQt"
00409 << "Separator"
00410 << "Std_WhatsThis" ;
00411
00412 return menuBar;
00413 }
00414
00415 Gui::ToolBarItem* Workbench::setupToolBars() const
00416 {
00417 Gui::CommandManager &mgr = Gui::Application::Instance->commandManager();
00418 Gui::ToolBarItem* root = new Gui::ToolBarItem;
00419
00420
00421 Gui::ToolBarItem* file = new Gui::ToolBarItem( root );
00422 file->setCommand("File");
00423 *file << "Std_New"
00424 << "Std_Open"
00425 << "Std_Save"
00426 << "Std_Print"
00427 << "Separator"
00428 << "Std_Cut"
00429 << "Std_Copy"
00430 << "Std_Paste"
00431 << "Separator"
00432 << "Std_Undo"
00433 << "Std_Redo"
00434 << "Separator"
00435 << "Std_Refresh"
00436 << "Separator"
00437
00438 << "Std_WhatsThis";
00439
00440
00441 Gui::ToolBarItem* macro = new Gui::ToolBarItem( root );
00442 macro->setCommand("Macro");
00443 *macro << "Std_DlgMacroRecord" << "Std_MacroStopRecord" << "Std_DlgMacroExecute"
00444 << "Std_DlgMacroExecuteDirect";
00445
00446
00447 Gui::ToolBarItem* view = new Gui::ToolBarItem( root );
00448 view->setCommand("View");
00449 *view << "Std_ViewFitAll" << "Separator" << "Std_ViewAxo" << "Separator" << "Std_ViewFront"
00450 << "Std_ViewRight" << "Std_ViewTop" << "Separator" << "Std_ViewRear" << "Std_ViewLeft"
00451 << "Std_ViewBottom";
00452
00453
00454 Gui::ToolBarItem* part_design = new Gui::ToolBarItem( root );
00455 part_design->setCommand("Part");
00456 *part_design
00457 << "Part_Box"
00458 << "Part_Cylinder"
00459 << "Part_Sphere"
00460 << "Part_Cone"
00461 << "Part_Torus"
00462
00463 << "Separator"
00464 << "Part_Boolean"
00465 << "Part_Cut"
00466 << "Part_Fuse"
00467 << "Part_Common"
00468 << "Part_Section"
00469 << "Separator"
00470 << "Part_Extrude"
00471 << "Part_Revolve"
00472 << "Part_Mirror"
00473 << "Part_Fillet"
00474 << "PartDesign_Chamfer"
00475 ;
00476
00477
00478 Gui::ToolBarItem* sketch_based = new Gui::ToolBarItem( root );
00479 sketch_based->setCommand("Sketch based");
00480 *sketch_based
00481 << "Sketcher_NewSketch"
00482 << "Sketcher_LeaveSketch"
00483 << "Separator"
00484 << "Sketcher_CreateArc"
00485 << "Sketcher_CreateCircle"
00486 << "Sketcher_CreateLine"
00487 << "Sketcher_CreatePolyline"
00488 << "Sketcher_CreateRectangle"
00489 << "Sketcher_CreateFillet"
00490 << "Sketcher_Trimming"
00491 << "Sketcher_ToggleConstruction"
00492 << "Separator"
00493 << "Sketcher_ConstrainLock"
00494 << "Sketcher_ConstrainCoincident"
00495 << "Sketcher_ConstrainPointOnObject"
00496 << "Sketcher_ConstrainDistanceX"
00497 << "Sketcher_ConstrainDistanceY"
00498 << "Sketcher_ConstrainVertical"
00499 << "Sketcher_ConstrainHorizontal"
00500 << "Sketcher_ConstrainDistance"
00501 << "Sketcher_ConstrainRadius"
00502 << "Sketcher_ConstrainParallel"
00503 << "Sketcher_ConstrainPerpendicular"
00504 << "Sketcher_ConstrainAngle"
00505 << "Sketcher_ConstrainTangent"
00506 << "Sketcher_ConstrainEqual"
00507 << "Sketcher_ConstrainSymmetric"
00508 << "Separator"
00509 << "PartDesign_Pad"
00510 << "PartDesign_Pocket"
00511 << "PartDesign_Revolution"
00512 << "PartDesign_Fillet"
00513 << "PartDesign_Chamfer";
00514
00515
00516
00517 Gui::ToolBarItem* drawing = new Gui::ToolBarItem( root );
00518 drawing->setCommand("Drawings");
00519 *drawing << "Drawing_Open"
00520 << "Separator"
00521 << "Drawing_NewA3Landscape"
00522 << "Drawing_NewView"
00523 << "Drawing_ExportPage" ;
00524
00525
00526 Gui::ToolBarItem* raytracing = new Gui::ToolBarItem( root );
00527 raytracing->setCommand("Raytracing");
00528 *raytracing << "Raytracing_WriteView"
00529 << "Raytracing_WriteCamera"
00530 << "Raytracing_WritePart";
00531
00532
00533 # ifdef COMPLETE_USE_DRAFTING
00534 if (mgr.getCommandByName("Draft_Line")) {
00535 Gui::ToolBarItem* Drafting = new Gui::ToolBarItem( root );
00536 Drafting->setCommand("Drafting");
00537 *Drafting
00538 << "Draft_Line"
00539 << "Draft_Wire"
00540 << "Draft_Circle"
00541 << "Draft_Arc"
00542 << "Draft_Rectangle"
00543 << "Draft_Polygon"
00544 << "Draft_BSpline"
00545 << "Draft_Text"
00546 << "Draft_Dimension"
00547 << "Separator"
00548 << "Draft_Move"
00549 << "Draft_Rotate"
00550 << "Draft_Offset"
00551 << "Draft_Trimex"
00552 << "Draft_Upgrade"
00553 << "Draft_Downgrade"
00554 << "Draft_Scale"
00555 << "Draft_Edit"
00556 << "Draft_Drawing"
00557 << "Draft_WireToBSpline"
00558 << "Draft_AddPoint"
00559 << "Draft_DelPoint"
00560 << "Draft_Shape2DView"
00561 ;
00562 }
00563 # endif
00564
00565 return root;
00566 }
00567
00568 Gui::ToolBarItem* Workbench::setupCommandBars() const
00569 {
00570 Gui::ToolBarItem* root = new Gui::ToolBarItem;
00571 return root;
00572 }
00573
00574 Gui::DockWindowItems* Workbench::setupDockWindows() const
00575 {
00576 Gui::DockWindowItems* root = Gui::StdWorkbench::setupDockWindows();
00577 root->setVisibility(false);
00578 root->setVisibility("Std_CombiView",true);
00579 return root;
00580 }