~ubuntu-branches/ubuntu/maverick/freecad/maverick

« back to all changes in this revision

Viewing changes to src/Mod/Complete/Gui/Workbench.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Teemu Ikonen
  • Date: 2009-07-16 18:37:41 UTC
  • Revision ID: james.westby@ubuntu.com-20090716183741-oww9kcxqrk991i1n
Tags: upstream-0.8.2237
ImportĀ upstreamĀ versionĀ 0.8.2237

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (c) 2008 Werner Mayer <werner.wm.mayer@gmx.de>              *
 
3
 *                                                                         *
 
4
 *   This file is part of the FreeCAD CAx development system.              *
 
5
 *                                                                         *
 
6
 *   This library is free software; you can redistribute it and/or         *
 
7
 *   modify it under the terms of the GNU Library General Public           *
 
8
 *   License as published by the Free Software Foundation; either          *
 
9
 *   version 2 of the License, or (at your option) any later version.      *
 
10
 *                                                                         *
 
11
 *   This library  is distributed in the hope that it will be useful,      *
 
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
14
 *   GNU Library General Public License for more details.                  *
 
15
 *                                                                         *
 
16
 *   You should have received a copy of the GNU Library General Public     *
 
17
 *   License along with this library; see the file COPYING.LIB. If not,    *
 
18
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
 
19
 *   Suite 330, Boston, MA  02111-1307, USA                                *
 
20
 *                                                                         *
 
21
 ***************************************************************************/
 
22
 
 
23
 
 
24
#include "PreCompiled.h"
 
25
 
 
26
#ifndef _PreComp_
 
27
# include <qobject.h>
 
28
#endif
 
29
 
 
30
#include "Workbench.h"
 
31
#include <Gui/ToolBarManager.h>
 
32
#include <Gui/MenuManager.h>
 
33
#include <Gui/ToolBarManager.h>
 
34
#include <Gui/DockWindowManager.h>
 
35
#include <Gui/Application.h>
 
36
#include <Gui/Action.h>
 
37
#include <Gui/Command.h>
 
38
#include <Gui/Selection.h>
 
39
#include <Gui/ToolBoxManager.h>
 
40
#include <App/Document.h>
 
41
#include <App/DocumentObject.h>
 
42
 
 
43
 
 
44
using namespace CompleteGui;
 
45
 
 
46
TYPESYSTEM_SOURCE(CompleteGui::Workbench, Gui::StdWorkbench)
 
47
 
 
48
Workbench::Workbench()
 
49
{
 
50
}
 
51
 
 
52
Workbench::~Workbench()
 
53
{
 
54
}
 
55
 
 
56
void Workbench::setupContextMenu(const char* recipient,Gui::MenuItem* item) const
 
57
{
 
58
    if (strcmp(recipient,"View") == 0)
 
59
    {
 
60
        Gui::MenuItem* StdViews = new Gui::MenuItem();
 
61
        StdViews->setCommand( "Standard views" );
 
62
 
 
63
        *StdViews << "Std_ViewAxo" << "Separator" << "Std_ViewFront" << "Std_ViewTop" << "Std_ViewRight"
 
64
                  << "Std_ViewRear" << "Std_ViewBottom" << "Std_ViewLeft";
 
65
 
 
66
        *item << "Std_ViewFitAll" << "Std_ViewFitSelection" << StdViews
 
67
              << "Separator" << "Std_ViewDockUndockFullscreen";
 
68
 
 
69
        if ( Gui::Selection().countObjectsOfType(App::DocumentObject::getClassTypeId()) > 0 )
 
70
            *item << "Separator" << "Std_SetAppearance" << "Std_ToggleVisibility" << "Std_TreeSelection" 
 
71
                  << "Std_RandomColor" << "Separator" << "Std_Delete";
 
72
    }
 
73
    else if (strcmp(recipient,"Tree") == 0)
 
74
    {
 
75
        if ( Gui::Selection().countObjectsOfType(App::DocumentObject::getClassTypeId()) > 0 )
 
76
            *item << "Std_SetAppearance" << "Std_ToggleVisibility" 
 
77
                  << "Std_RandomColor" << "Separator" << "Std_Delete";
 
78
    }
 
79
}
 
80
 
 
81
Gui::MenuItem* Workbench::setupMenuBar() const
 
82
{
 
83
    // Setup the default menu bar
 
84
    Gui::MenuItem* menuBar = new Gui::MenuItem;
 
85
 
 
86
    // File
 
87
    Gui::MenuItem* file = new Gui::MenuItem( menuBar );
 
88
    file->setCommand(QT_TR_NOOP("&File"));
 
89
    *file << "Std_New" << "Std_Open" << "Std_Save" << "Std_SaveAs"
 
90
          << "Separator" << "Std_Import" << "Std_Export" << "Std_ProjectInfo" 
 
91
          //<< "Separator" << "Std_Print" << "Std_PrintPdf"
 
92
          << "Separator" << "Std_RecentFiles" << "Separator" << "Std_Quit";
 
93
 
 
94
    // Edit
 
95
    Gui::MenuItem* edit = new Gui::MenuItem( menuBar );
 
96
    edit->setCommand(QT_TR_NOOP("&Edit"));
 
97
    *edit << "Std_Undo" << "Std_Redo" << "Separator" << "Std_Cut" << "Std_Copy" << "Std_Paste" 
 
98
          << "Separator" << "Std_Refresh" << "Std_SelectAll" << "Std_Delete"
 
99
          << "Separator" << "Std_DlgPreferences";
 
100
 
 
101
    // Standard views
 
102
    Gui::MenuItem* stdviews = new Gui::MenuItem;
 
103
    stdviews->setCommand(QT_TR_NOOP("Standard views"));
 
104
    *stdviews << "Std_ViewFitAll" << "Std_ViewFitSelection" << "Std_ViewAxo"
 
105
              << "Separator" << "Std_ViewFront" << "Std_ViewRight"
 
106
              << "Std_ViewTop" << "Separator" << "Std_ViewRear" 
 
107
              << "Std_ViewLeft" << "Std_ViewBottom";
 
108
 
 
109
    // stereo
 
110
    Gui::MenuItem* view3d = new Gui::MenuItem;
 
111
    view3d->setCommand(QT_TR_NOOP("&3D View"));
 
112
    *view3d << "Std_ViewIvStereoRedGreen" << "Std_ViewIvStereoQuadBuff" 
 
113
            << "Std_ViewIvStereoInterleavedRows" << "Std_ViewIvStereoInterleavedColumns" 
 
114
            << "Std_ViewIvStereoOff" << "Separator" << "Std_ViewIvIssueCamPos";
 
115
 
 
116
    // zoom
 
117
    Gui::MenuItem* zoom = new Gui::MenuItem;
 
118
    zoom->setCommand(QT_TR_NOOP("&Zoom"));
 
119
    *zoom << "Std_ViewZoomIn" << "Std_ViewZoomOut" << "Separator" << "Std_ViewBoxZoom";
 
120
 
 
121
    // View
 
122
    Gui::MenuItem* view = new Gui::MenuItem( menuBar );
 
123
    view->setCommand(QT_TR_NOOP("&View"));
 
124
    *view << "Std_ViewCreate" << "Std_OrthographicCamera" << "Std_PerspectiveCamera" << "Separator" 
 
125
          << stdviews << "Std_FreezeViews" << "Separator" << view3d << zoom
 
126
          << "Std_ViewDockUndockFullscreen" << "Std_ToggleClipPlane" << "Separator"
 
127
          << "Std_SetAppearance" << "Std_ToggleVisibility" << "Std_RandomColor" << "Separator" 
 
128
          //<< "Std_MeasureDistance" << "Separator" 
 
129
          << "Std_Workbench" << "Std_ToolBarMenu" << "Std_DockViewMenu" << "Separator" 
 
130
          << "Std_ViewStatusBar" << "Std_UserInterface";
 
131
 
 
132
    // Tools
 
133
    Gui::MenuItem* tool = new Gui::MenuItem( menuBar );
 
134
    tool->setCommand(QT_TR_NOOP("&Tools"));
 
135
    *tool << "Std_CommandLine" << "Std_DlgParameter" << "Separator" << "Std_DlgMacroRecord"
 
136
          << "Std_DlgMacroStop" << "Std_DlgMacroExecute" << "Std_DlgMacroExecuteDirect" 
 
137
          << "Separator" << "Std_ViewScreenShot" << "Separator" << "Std_DlgCustomize";
 
138
 
 
139
        // Mesh ****************************************************************************************************
 
140
        Gui::MenuItem* mesh = new Gui::MenuItem( menuBar );
 
141
 
 
142
        // submenu analyze
 
143
    Gui::MenuItem* analyze = new Gui::MenuItem();
 
144
    analyze->setCommand(QT_TR_NOOP("Analyze"));
 
145
    *analyze << "Mesh_Evaluation" 
 
146
             << "Mesh_EvaluateFacet" 
 
147
             << "Mesh_CurvatureInfo" 
 
148
             << "Separator" 
 
149
             << "Mesh_EvaluateSolid" 
 
150
             << "Mesh_BoundingBox";
 
151
 
 
152
    // submenu boolean
 
153
    Gui::MenuItem* boolean = new Gui::MenuItem();
 
154
    boolean->setCommand(QT_TR_NOOP("Boolean"));
 
155
    *boolean << "Mesh_Union" 
 
156
             << "Mesh_Intersection" 
 
157
             << "Mesh_Difference";
 
158
 
 
159
    mesh->setCommand(QT_TR_NOOP("&Meshes"));
 
160
    *mesh << "Mesh_Import" 
 
161
          << "Mesh_Export" 
 
162
          << "Mesh_FromGeometry" 
 
163
          << "Separator"
 
164
          << analyze 
 
165
          << "Mesh_HarmonizeNormals" 
 
166
          << "Mesh_FlipNormals" 
 
167
          << "Separator" 
 
168
          << "Mesh_FillupHoles" 
 
169
          << "Mesh_FillInteractiveHole" 
 
170
          << "Mesh_RemoveComponents"
 
171
          << "Mesh_RemoveCompByHand" 
 
172
          << "Separator" 
 
173
          << "Mesh_BuildRegularSolid" 
 
174
          << boolean << "Separator" 
 
175
          << "Mesh_PolyCut"
 
176
          << "Mesh_PolySplit" 
 
177
          << "Mesh_PolySegm" 
 
178
          << "Mesh_ToolMesh" 
 
179
          << "Mesh_VertexCurvature";
 
180
 
 
181
        // Part ****************************************************************************************************
 
182
 
 
183
    Gui::MenuItem* part = new Gui::MenuItem(menuBar);
 
184
 
 
185
    // submenu boolean
 
186
    Gui::MenuItem* simple = new Gui::MenuItem();
 
187
    simple->setCommand(QT_TR_NOOP("Simple"));
 
188
    *simple  << "Part_Cylinder"  
 
189
          << "Part_Box" 
 
190
          << "Part_Primitives" 
 
191
          << "Separator" 
 
192
          << "Part_Boolean" 
 
193
          << "Part_Extrude"
 
194
          << "Part_FilletEdges" 
 
195
;
 
196
 
 
197
        part->setCommand(QT_TR_NOOP("&Part"));
 
198
    *part << "Part_Import" 
 
199
          << "Separator" 
 
200
                  << "Sketcher_NewSketch"
 
201
                  << "Sketcher_LeaveSketch"
 
202
                  << "Sketcher_CreateLine"
 
203
                  << "Sketcher_CreatePolyline"
 
204
          << "Separator" 
 
205
                  << "PartDesign_Pad" 
 
206
                  << "PartDesign_Fillet"
 
207
          << "Separator" 
 
208
                  << simple
 
209
          << "Part_ShapeInfo";
 
210
 
 
211
        // Drawing ****************************************************************************************************
 
212
 
 
213
    Gui::MenuItem* drawing = new Gui::MenuItem(menuBar);
 
214
 
 
215
        drawing->setCommand(QT_TR_NOOP("&Drawing"));
 
216
    *drawing << "Drawing_Open" 
 
217
             << "Separator" 
 
218
             << "Drawing_NewA3Landscape"  
 
219
             << "Drawing_NewView" ;
 
220
 
 
221
 
 
222
        // xxx ****************************************************************************************************
 
223
 
 
224
 
 
225
    // Windows
 
226
    Gui::MenuItem* wnd = new Gui::MenuItem( menuBar );
 
227
    wnd->setCommand(QT_TR_NOOP("&Windows"));
 
228
    *wnd << "Std_CloseActiveWindow" << "Std_CloseAllWindows" << "Separator" << "Std_ActivateNextWindow"
 
229
         << "Std_ActivatePrevWindow" << "Separator" << "Std_TileWindows" << "Std_CascadeWindows"
 
230
         << "Std_ArrangeIcons" << "Separator" << "Std_WindowsMenu" << "Std_Windows";
 
231
    
 
232
    // help ****************************************************************************************************
 
233
    // Separator
 
234
    Gui::MenuItem* sep = new Gui::MenuItem( menuBar );
 
235
    sep->setCommand( "Separator" );
 
236
 
 
237
    // Help
 
238
    Gui::MenuItem* helpWebsites = new Gui::MenuItem;
 
239
    helpWebsites->setCommand(QT_TR_NOOP("&Online-help"));
 
240
    *helpWebsites << "Std_OnlineHelpWebsite" 
 
241
                  << "Std_FreeCADWebsite" 
 
242
                  << "Std_PythonWebsite";
 
243
 
 
244
    Gui::MenuItem* help = new Gui::MenuItem( menuBar );
 
245
    help->setCommand(QT_TR_NOOP("&Help"));
 
246
    *help << "Std_OnlineHelp" 
 
247
          << "Std_OnlineHelpPython" 
 
248
          << "Std_PythonHelp"
 
249
          << helpWebsites  
 
250
          << "Std_TipOfTheDay"
 
251
          << "Separator" 
 
252
          << "Test_Test" 
 
253
          << "Separator" 
 
254
          << "Std_About"
 
255
          << "Std_AboutQt" 
 
256
          << "Separator" 
 
257
          << "Std_WhatsThis" ;
 
258
 
 
259
    return menuBar;
 
260
}
 
261
 
 
262
Gui::ToolBarItem* Workbench::setupToolBars() const
 
263
{
 
264
    Gui::ToolBarItem* root = new Gui::ToolBarItem;
 
265
 
 
266
    // File
 
267
    Gui::ToolBarItem* file = new Gui::ToolBarItem( root );
 
268
    file->setCommand(QT_TR_NOOP("File"));
 
269
    *file << "Std_New" 
 
270
                  << "Std_Open" 
 
271
                  << "Std_Save" 
 
272
                  << "Std_Print" 
 
273
                  << "Separator" 
 
274
                  << "Std_Cut"
 
275
          << "Std_Copy" 
 
276
                  << "Std_Paste" 
 
277
                  << "Separator" 
 
278
                  << "Std_Undo" 
 
279
                  << "Std_Redo" 
 
280
                  << "Separator"
 
281
          << "Std_Refresh" 
 
282
                  << "Separator" 
 
283
                  //<< "Std_Workbench" 
 
284
                  << "Std_WhatsThis";
 
285
 
 
286
    // Macro
 
287
    Gui::ToolBarItem* macro = new Gui::ToolBarItem( root );
 
288
    macro->setCommand(QT_TR_NOOP("Macro"));
 
289
    *macro << "Std_DlgMacroRecord" << "Std_DlgMacroStop" << "Std_DlgMacroExecute"
 
290
           << "Std_DlgMacroExecuteDirect";
 
291
 
 
292
    // View
 
293
    Gui::ToolBarItem* view = new Gui::ToolBarItem( root );
 
294
    view->setCommand(QT_TR_NOOP("View"));
 
295
    *view << "Std_ViewFitAll" << "Separator" << "Std_ViewAxo" << "Separator" << "Std_ViewFront" 
 
296
          << "Std_ViewRight" << "Std_ViewTop" << "Separator" << "Std_ViewRear" << "Std_ViewLeft" 
 
297
          << "Std_ViewBottom";
 
298
    
 
299
        // Part Design
 
300
    Gui::ToolBarItem* part_design = new Gui::ToolBarItem( root );
 
301
    part_design->setCommand(QT_TR_NOOP("View"));
 
302
    *part_design  << "Sketcher_NewSketch"
 
303
                          << "Sketcher_LeaveSketch"
 
304
                                  << "Separator" 
 
305
                                  << "Sketcher_CreatePoint" 
 
306
                                  << "Sketcher_CreateArc"
 
307
                                  << "Sketcher_CreateCircle"
 
308
                                  << "Sketcher_CreateLine"
 
309
                                  << "Sketcher_CreatePolyline"
 
310
                                  << "Sketcher_CreateRectangle"
 
311
                                  << "Sketcher_CreateText"
 
312
                                  << "Sketcher_CreateDraftLine"   
 
313
                                  << "Separator" 
 
314
                                  << "PartDesign_Pad" 
 
315
                                  << "PartDesign_Fillet"
 
316
        ;
 
317
 
 
318
    return root;
 
319
}
 
320
 
 
321
Gui::ToolBarItem* Workbench::setupCommandBars() const
 
322
{
 
323
    Gui::ToolBarItem* root = new Gui::ToolBarItem;
 
324
 
 
325
    //// View
 
326
    //ToolBarItem* view = new ToolBarItem( root );
 
327
    //view->setCommand(QT_TR_NOOP("Standard views"));
 
328
    //*view << "Std_ViewFitAll" << "Std_ViewFitSelection" << "Std_ViewAxo" << "Separator"
 
329
    //      << "Std_ViewFront" << "Std_ViewRight" << "Std_ViewTop" << "Separator"
 
330
    //      << "Std_ViewRear" << "Std_ViewLeft" << "Std_ViewBottom";
 
331
    //// Special Ops
 
332
    //ToolBarItem* macro = new ToolBarItem( root );
 
333
    //macro->setCommand(QT_TR_NOOP("Special Ops"));
 
334
    //*macro << "Std_DlgParameter" << "Std_DlgPreferences" << "Std_DlgMacroRecord" << "Std_DlgMacroStop" 
 
335
    //       << "Std_DlgMacroExecute" << "Std_DlgCustomize" << "Std_CommandLine";
 
336
 
 
337
 
 
338
    return root;
 
339
}
 
340
 
 
341
Gui::DockWindowItems* Workbench::setupDockWindows() const
 
342
{
 
343
    Gui::DockWindowItems* root = Gui::StdWorkbench::setupDockWindows();
 
344
    root->setVisibility(false); // hide all dock windows by default
 
345
    root->setVisibility("Std_CombiView",true); // except of the combi view
 
346
    return root;
 
347
}