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

« back to all changes in this revision

Viewing changes to src/Mod/Part/Gui/Command.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) Jļæ½rgen Riegel          (juergen.riegel@web.de) 2002     *
 
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
#ifndef _PreComp_
 
26
# include <qdir.h>
 
27
# include <qfileinfo.h>
 
28
# include <qlineedit.h>
 
29
# include <Inventor/events/SoMouseButtonEvent.h>
 
30
#endif
 
31
 
 
32
#include <Base/Exception.h>
 
33
#include <App/Document.h>
 
34
#include <Gui/Application.h>
 
35
#include <Gui/BitmapFactory.h>
 
36
#include <Gui/Command.h>
 
37
#include <Gui/Document.h>
 
38
#include <Gui/FileDialog.h>
 
39
#include <Gui/MainWindow.h>
 
40
#include <Gui/Selection.h>
 
41
#include <Gui/View3DInventor.h>
 
42
#include <Gui/View3DInventorViewer.h>
 
43
 
 
44
#include <BRepPrimAPI_MakeBox.hxx>
 
45
#include <TopoDS_Shape.hxx>
 
46
 
 
47
#include "../App/PartFeature.h"
 
48
#include "DlgPartImportStepImp.h"
 
49
#include "DlgBooleanOperation.h"
 
50
#include "DlgExtrusion.h"
 
51
#include "DlgFilletEdges.h"
 
52
#include "DlgPrimitives.h"
 
53
#include "ViewProvider.h"
 
54
 
 
55
 
 
56
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
57
 
 
58
//===========================================================================
 
59
// Part_PickCurveNet
 
60
//===========================================================================
 
61
DEF_STD_CMD(CmdPartPickCurveNet);
 
62
 
 
63
CmdPartPickCurveNet::CmdPartPickCurveNet()
 
64
  :Command("Part_PickCurveNet")
 
65
{
 
66
    sAppModule    = "Part";
 
67
    sGroup        = QT_TR_NOOP("Part");
 
68
    sMenuText     = QT_TR_NOOP("Pick curve network");
 
69
    sToolTipText  = QT_TR_NOOP("Pick a curve network");
 
70
    sWhatsThis    = sToolTipText;
 
71
    sStatusTip    = sToolTipText;
 
72
    sPixmap       = "Test1";
 
73
    iAccel        = 0;
 
74
}
 
75
 
 
76
void CmdPartPickCurveNet::activated(int iMsg)
 
77
{
 
78
 
 
79
}
 
80
 
 
81
//===========================================================================
 
82
// Part_NewDoc
 
83
//===========================================================================
 
84
DEF_STD_CMD(CmdPartNewDoc);
 
85
 
 
86
CmdPartNewDoc::CmdPartNewDoc()
 
87
  :Command("Part_NewDoc")
 
88
{
 
89
    sAppModule    = "Part";
 
90
    sGroup        = "Part";
 
91
    sMenuText     = "New document";
 
92
    sToolTipText  = "Create an empty part document";
 
93
    sWhatsThis    = sToolTipText;
 
94
    sStatusTip    = sToolTipText;
 
95
    sPixmap       = "New";
 
96
    iAccel        = 0;
 
97
}
 
98
 
 
99
void CmdPartNewDoc::activated(int iMsg)
 
100
{
 
101
    doCommand(Doc,"d = App.New()");
 
102
    updateActive();
 
103
}
 
104
 
 
105
//===========================================================================
 
106
// Part_Box2
 
107
//===========================================================================
 
108
DEF_STD_CMD_A(CmdPartBox2);
 
109
 
 
110
CmdPartBox2::CmdPartBox2()
 
111
  :Command("Part_Box2")
 
112
{
 
113
    sAppModule    = "Part";
 
114
    sGroup        = QT_TR_NOOP("Part");
 
115
    sMenuText     = QT_TR_NOOP("Box fix 1");
 
116
    sToolTipText  = QT_TR_NOOP("Create a Box feature without dialog");
 
117
    sWhatsThis    = "Part_Box2";
 
118
    sStatusTip    = sToolTipText;
 
119
    sPixmap       = "Part_Box";
 
120
    iAccel        = 0;
 
121
}
 
122
 
 
123
 
 
124
void CmdPartBox2::activated(int iMsg)
 
125
{
 
126
    openCommand("Part Box Create");
 
127
    doCommand(Doc,"from FreeCAD import Base");
 
128
    doCommand(Doc,"import Part");
 
129
    doCommand(Doc,"__fb__ = App.ActiveDocument.addObject(\"Part::Box\",\"PartBox\")");
 
130
    doCommand(Doc,"__fb__.Location = Base.Vector(0.0,0.0,0.0)");
 
131
    doCommand(Doc,"__fb__.Length = 100.0");
 
132
    doCommand(Doc,"__fb__.Width = 100.0");
 
133
    doCommand(Doc,"__fb__.Height = 100.0");
 
134
    doCommand(Doc,"del __fb__");
 
135
    commitCommand();
 
136
    updateActive();
 
137
}
 
138
 
 
139
bool CmdPartBox2::isActive(void)
 
140
{
 
141
    if (getActiveGuiDocument())
 
142
        return true;
 
143
    else
 
144
        return false;
 
145
}
 
146
 
 
147
//===========================================================================
 
148
// Part_Box3
 
149
//===========================================================================
 
150
DEF_STD_CMD_A(CmdPartBox3);
 
151
 
 
152
CmdPartBox3::CmdPartBox3()
 
153
  :Command("Part_Box3")
 
154
{
 
155
    sAppModule    = "Part";
 
156
    sGroup        = QT_TR_NOOP("Part");
 
157
    sMenuText     = QT_TR_NOOP("Box fix 2");
 
158
    sToolTipText  = QT_TR_NOOP("Create a box feature without dialog");
 
159
    sWhatsThis    = "Part_Box3";
 
160
    sStatusTip    = sToolTipText;
 
161
    sPixmap       = "Part_Box";
 
162
    iAccel        = 0;
 
163
}
 
164
 
 
165
void CmdPartBox3::activated(int iMsg)
 
166
{
 
167
    openCommand("Part Box Create");
 
168
    doCommand(Doc,"from FreeCAD import Base");
 
169
    doCommand(Doc,"import Part");
 
170
    doCommand(Doc,"__fb__ = App.ActiveDocument.addObject(\"Part::Box\",\"PartBox\")");
 
171
    doCommand(Doc,"__fb__.Location = Base.Vector(50.0,50.0,50.0)");
 
172
    doCommand(Doc,"__fb__.Length = 100.0");
 
173
    doCommand(Doc,"__fb__.Width = 100.0");
 
174
    doCommand(Doc,"__fb__.Height = 100.0");
 
175
    doCommand(Doc,"del __fb__");
 
176
    commitCommand();
 
177
    updateActive();
 
178
}
 
179
 
 
180
bool CmdPartBox3::isActive(void)
 
181
{
 
182
    if (getActiveGuiDocument())
 
183
        return true;
 
184
    else
 
185
        return false;
 
186
}
 
187
 
 
188
//===========================================================================
 
189
// Part_Primitives
 
190
//===========================================================================
 
191
DEF_STD_CMD_A(CmdPartPrimitives);
 
192
 
 
193
CmdPartPrimitives::CmdPartPrimitives()
 
194
  :Command("Part_Primitives")
 
195
{
 
196
    sAppModule    = "Part";
 
197
    sGroup        = QT_TR_NOOP("Part");
 
198
    sMenuText     = QT_TR_NOOP("Create primitives...");
 
199
    sToolTipText  = QT_TR_NOOP("Creation of parametrized geometric primitives");
 
200
    sWhatsThis    = "Part_Primitives";
 
201
    sStatusTip    = sToolTipText;
 
202
    //sPixmap       = "Part_Box";
 
203
    iAccel        = 0;
 
204
}
 
205
 
 
206
void CmdPartPrimitives::activated(int iMsg)
 
207
{
 
208
    static QPointer<QDialog> dlg = 0;
 
209
    if (!dlg)
 
210
        dlg = new PartGui::DlgPrimitives(Gui::getMainWindow());
 
211
    dlg->setAttribute(Qt::WA_DeleteOnClose);
 
212
    dlg->show();
 
213
}
 
214
 
 
215
bool CmdPartPrimitives::isActive(void)
 
216
{
 
217
    return hasActiveDocument();
 
218
}
 
219
 
 
220
//===========================================================================
 
221
// Part_Cut
 
222
//===========================================================================
 
223
DEF_STD_CMD_A(CmdPartCut);
 
224
 
 
225
CmdPartCut::CmdPartCut()
 
226
  :Command("Part_Cut")
 
227
{
 
228
    sAppModule    = "Part";
 
229
    sGroup        = QT_TR_NOOP("Part");
 
230
    sMenuText     = QT_TR_NOOP("Cut");
 
231
    sToolTipText  = QT_TR_NOOP("Create a Cut feature");
 
232
    sWhatsThis    = "Part_Cut";
 
233
    sStatusTip    = sToolTipText;
 
234
    sPixmap       = "Part_Box";
 
235
    iAccel        = 0;
 
236
}
 
237
 
 
238
 
 
239
void CmdPartCut::activated(int iMsg)
 
240
{
 
241
    unsigned int n = getSelection().countObjectsOfType(Part::Feature::getClassTypeId());
 
242
    if (n != 2) {
 
243
        QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
 
244
            QObject::tr("Select two shapes please."));
 
245
        return;
 
246
    }
 
247
 
 
248
    std::string FeatName = getUniqueObjectName("Cut");
 
249
 
 
250
    std::vector<Gui::SelectionSingleton::SelObj> Sel = getSelection().getSelection();
 
251
 
 
252
    openCommand("Part Cut");
 
253
    doCommand(Doc,"App.activeDocument().addObject(\"Part::Cut\",\"%s\")",FeatName.c_str());
 
254
    doCommand(Doc,"App.activeDocument().%s.Base = App.activeDocument().%s",FeatName.c_str(),Sel[0].FeatName);
 
255
    doCommand(Doc,"App.activeDocument().%s.Tool = App.activeDocument().%s",FeatName.c_str(),Sel[1].FeatName);
 
256
    doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",Sel[0].FeatName);
 
257
    doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",Sel[1].FeatName);
 
258
    updateActive();
 
259
    commitCommand();
 
260
}
 
261
 
 
262
bool CmdPartCut::isActive(void)
 
263
{
 
264
    return getSelection().countObjectsOfType(Part::Feature::getClassTypeId())==2;
 
265
}
 
266
 
 
267
//===========================================================================
 
268
// Part_Common
 
269
//===========================================================================
 
270
DEF_STD_CMD_A(CmdPartCommon);
 
271
 
 
272
CmdPartCommon::CmdPartCommon()
 
273
  :Command("Part_Common")
 
274
{
 
275
    sAppModule    = "Part";
 
276
    sGroup        = QT_TR_NOOP("Part");
 
277
    sMenuText     = QT_TR_NOOP("Intersection");
 
278
    sToolTipText  = QT_TR_NOOP("Intersection of two shapes");
 
279
    sWhatsThis    = "Part_Common";
 
280
    sStatusTip    = sToolTipText;
 
281
    sPixmap       = "Part_Box";
 
282
    iAccel        = 0;
 
283
}
 
284
 
 
285
void CmdPartCommon::activated(int iMsg)
 
286
{
 
287
    unsigned int n = getSelection().countObjectsOfType(Part::Feature::getClassTypeId());
 
288
    if (n != 2) {
 
289
        QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
 
290
            QObject::tr("Select two shapes please."));
 
291
        return;
 
292
    }
 
293
 
 
294
    std::string FeatName = getUniqueObjectName("Common");
 
295
 
 
296
    std::vector<Gui::SelectionSingleton::SelObj> Sel = getSelection().getSelection();
 
297
 
 
298
    openCommand("Common");
 
299
    doCommand(Doc,"App.activeDocument().addObject(\"Part::Common\",\"%s\")",FeatName.c_str());
 
300
    doCommand(Doc,"App.activeDocument().%s.Base = App.activeDocument().%s",FeatName.c_str(),Sel[0].FeatName);
 
301
    doCommand(Doc,"App.activeDocument().%s.Tool = App.activeDocument().%s",FeatName.c_str(),Sel[1].FeatName);
 
302
    doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",Sel[0].FeatName);
 
303
    doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",Sel[1].FeatName);
 
304
    updateActive();
 
305
    commitCommand();
 
306
}
 
307
 
 
308
bool CmdPartCommon::isActive(void)
 
309
{
 
310
    return getSelection().countObjectsOfType(Part::Feature::getClassTypeId())==2;
 
311
}
 
312
 
 
313
//===========================================================================
 
314
// Part_Fuse
 
315
//===========================================================================
 
316
DEF_STD_CMD_A(CmdPartFuse);
 
317
 
 
318
CmdPartFuse::CmdPartFuse()
 
319
  :Command("Part_Fuse")
 
320
{
 
321
    sAppModule    = "Part";
 
322
    sGroup        = QT_TR_NOOP("Part");
 
323
    sMenuText     = QT_TR_NOOP("Union");
 
324
    sToolTipText  = QT_TR_NOOP("Make union of two shapes");
 
325
    sWhatsThis    = "Part_Fuse";
 
326
    sStatusTip    = sToolTipText;
 
327
    sPixmap       = "Part_Box";
 
328
    iAccel        = 0;
 
329
}
 
330
 
 
331
 
 
332
void CmdPartFuse::activated(int iMsg)
 
333
{
 
334
    unsigned int n = getSelection().countObjectsOfType(Part::Feature::getClassTypeId());
 
335
    if (n != 2) {
 
336
        QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
 
337
            QObject::tr("Select two shapes please."));
 
338
        return;
 
339
    }
 
340
 
 
341
    std::string FeatName = getUniqueObjectName("Fusion");
 
342
 
 
343
    std::vector<Gui::SelectionSingleton::SelObj> Sel = getSelection().getSelection();
 
344
 
 
345
    openCommand("Fusion");
 
346
    doCommand(Doc,"App.activeDocument().addObject(\"Part::Fuse\",\"%s\")",FeatName.c_str());
 
347
    doCommand(Doc,"App.activeDocument().%s.Base = App.activeDocument().%s",FeatName.c_str(),Sel[0].FeatName);
 
348
    doCommand(Doc,"App.activeDocument().%s.Tool = App.activeDocument().%s",FeatName.c_str(),Sel[1].FeatName);
 
349
    doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",Sel[0].FeatName);
 
350
    doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",Sel[1].FeatName);
 
351
    updateActive();
 
352
    commitCommand();
 
353
}
 
354
 
 
355
bool CmdPartFuse::isActive(void)
 
356
{
 
357
    return getSelection().countObjectsOfType(Part::Feature::getClassTypeId())==2;
 
358
}
 
359
 
 
360
//===========================================================================
 
361
// Part_Section
 
362
//===========================================================================
 
363
DEF_STD_CMD_A(CmdPartSection);
 
364
 
 
365
CmdPartSection::CmdPartSection()
 
366
  :Command("Part_Section")
 
367
{
 
368
    sAppModule    = "Part";
 
369
    sGroup        = QT_TR_NOOP("Part");
 
370
    sMenuText     = QT_TR_NOOP("Section");
 
371
    sToolTipText  = QT_TR_NOOP("Make section of two shapes");
 
372
    sWhatsThis    = "Part_Section";
 
373
    sStatusTip    = sToolTipText;
 
374
    sPixmap       = "Part_Box";
 
375
    iAccel        = 0;
 
376
}
 
377
 
 
378
 
 
379
void CmdPartSection::activated(int iMsg)
 
380
{
 
381
    unsigned int n = getSelection().countObjectsOfType(Part::Feature::getClassTypeId());
 
382
    if (n != 2) {
 
383
        QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
 
384
            QObject::tr("Select two shapes please."));
 
385
        return;
 
386
    }
 
387
 
 
388
    std::string FeatName = getUniqueObjectName("Section");
 
389
 
 
390
    std::vector<Gui::SelectionSingleton::SelObj> Sel = getSelection().getSelection();
 
391
 
 
392
    openCommand("Section");
 
393
    doCommand(Doc,"App.activeDocument().addObject(\"Part::Section\",\"%s\")",FeatName.c_str());
 
394
    doCommand(Doc,"App.activeDocument().%s.Base = App.activeDocument().%s",FeatName.c_str(),Sel[0].FeatName);
 
395
    doCommand(Doc,"App.activeDocument().%s.Tool = App.activeDocument().%s",FeatName.c_str(),Sel[1].FeatName);
 
396
    doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",Sel[0].FeatName);
 
397
    doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",Sel[1].FeatName);
 
398
    updateActive();
 
399
    commitCommand();
 
400
}
 
401
 
 
402
bool CmdPartSection::isActive(void)
 
403
{
 
404
    return getSelection().countObjectsOfType(Part::Feature::getClassTypeId())==2;
 
405
}
 
406
 
 
407
//===========================================================================
 
408
// CmdPartImport
 
409
//===========================================================================
 
410
DEF_STD_CMD_A(CmdPartImport);
 
411
 
 
412
CmdPartImport::CmdPartImport()
 
413
  :Command("Part_Import")
 
414
{
 
415
    sAppModule    = "Part";
 
416
    sGroup        = QT_TR_NOOP("Part");
 
417
    sMenuText     = QT_TR_NOOP("Import CAD...");
 
418
    sToolTipText  = QT_TR_NOOP("Imports a CAD file");
 
419
    sWhatsThis    = "Part_Import";
 
420
    sStatusTip    = sToolTipText;
 
421
    sPixmap       = "Part_Box";
 
422
    iAccel        = 0;
 
423
}
 
424
 
 
425
 
 
426
void CmdPartImport::activated(int iMsg)
 
427
{
 
428
    QStringList filter;
 
429
    filter << QObject::tr("All CAD Files (*.stp *.step *.igs *.iges *.brp *.brep)");
 
430
    filter << QObject::tr("STEP (*.stp *.step)");
 
431
    filter << QObject::tr("IGES (*.igs *.iges)");
 
432
    filter << QObject::tr("BREP (*.brp *.brep)");
 
433
    filter << QObject::tr("All Files (*.*)");
 
434
 
 
435
    QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(), QString(), QString(), filter.join(QLatin1String(";;")));
 
436
    if (!fn.isEmpty()) {
 
437
        App::Document* pDoc = getDocument();
 
438
        if (!pDoc) return; // no document
 
439
        openCommand("Part Import Create");
 
440
        doCommand(Doc, "import Part");
 
441
        doCommand(Doc, "Part.insert(\"%s\",\"%s\")", (const char*)fn.toAscii(), pDoc->getName());
 
442
        commitCommand();
 
443
    }
 
444
}
 
445
 
 
446
bool CmdPartImport::isActive(void)
 
447
{
 
448
    if (getActiveGuiDocument())
 
449
        return true;
 
450
    else
 
451
        return false;
 
452
}
 
453
 
 
454
//===========================================================================
 
455
// PartImportCurveNet
 
456
//===========================================================================
 
457
DEF_STD_CMD_A(CmdPartImportCurveNet);
 
458
 
 
459
CmdPartImportCurveNet::CmdPartImportCurveNet()
 
460
  :Command("Part_ImportCurveNet")
 
461
{
 
462
    sAppModule  = "Part";
 
463
    sGroup      = QT_TR_NOOP("Part");
 
464
    sMenuText   = QT_TR_NOOP("Import curve network...");
 
465
    sToolTipText= QT_TR_NOOP("Import a curve network");
 
466
    sWhatsThis  = "Part_ImportCurveNet";
 
467
    sStatusTip  = sToolTipText;
 
468
    sPixmap     = "Part_Box";
 
469
    iAccel      = 0;
 
470
}
 
471
 
 
472
void CmdPartImportCurveNet::activated(int iMsg)
 
473
{
 
474
    QStringList filter;
 
475
    filter << QObject::tr("All CAD Files (*.stp *.step *.igs *.iges *.brp *.brep)");
 
476
    filter << QObject::tr("STEP (*.stp *.step)");
 
477
    filter << QObject::tr("IGES (*.igs *.iges)");
 
478
    filter << QObject::tr("BREP (*.brp *.brep)");
 
479
    filter << QObject::tr("All Files (*.*)");
 
480
 
 
481
    QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(), QString(), QString(), filter.join(QLatin1String(";;")));
 
482
    if (!fn.isEmpty()) {
 
483
        QFileInfo fi; fi.setFile(fn);
 
484
        openCommand("Part Import Curve Net");
 
485
        doCommand(Doc,"f = App.activeDocument().addObject(\"Part::CurveNet\",\"%s\")", (const char*)fi.baseName().toAscii());
 
486
        doCommand(Doc,"f.FileName = \"%s\"",(const char*)fn.toAscii());
 
487
        commitCommand();
 
488
        updateActive();
 
489
    }
 
490
}
 
491
 
 
492
bool CmdPartImportCurveNet::isActive(void)
 
493
{
 
494
    if (getActiveGuiDocument())
 
495
        return true;
 
496
    else
 
497
        return false;
 
498
}
 
499
 
 
500
//===========================================================================
 
501
// Part_Boolean
 
502
//===========================================================================
 
503
DEF_STD_CMD_A(CmdPartBoolean);
 
504
 
 
505
CmdPartBoolean::CmdPartBoolean()
 
506
  :Command("Part_Boolean")
 
507
{
 
508
    sAppModule    = "Part";
 
509
    sGroup        = QT_TR_NOOP("Part");
 
510
    sMenuText     = QT_TR_NOOP("Boolean...");
 
511
    sToolTipText  = QT_TR_NOOP("Run a boolean operation with two shapes selected");
 
512
    sWhatsThis    = "Part_Boolean";
 
513
    sStatusTip    = sToolTipText;
 
514
    //sPixmap       = "Part_Box";
 
515
    iAccel        = 0;
 
516
}
 
517
 
 
518
void CmdPartBoolean::activated(int iMsg)
 
519
{
 
520
    PartGui::DlgBooleanOperation dlg(Gui::getMainWindow());
 
521
    dlg.exec();
 
522
}
 
523
 
 
524
bool CmdPartBoolean::isActive(void)
 
525
{
 
526
    return hasActiveDocument();
 
527
}
 
528
 
 
529
//===========================================================================
 
530
// Part_Extrude
 
531
//===========================================================================
 
532
DEF_STD_CMD_A(CmdPartExtrude);
 
533
 
 
534
CmdPartExtrude::CmdPartExtrude()
 
535
  :Command("Part_Extrude")
 
536
{
 
537
    sAppModule    = "Part";
 
538
    sGroup        = QT_TR_NOOP("Part");
 
539
    sMenuText     = QT_TR_NOOP("Extrude...");
 
540
    sToolTipText  = QT_TR_NOOP("Extrude a selected sketch");
 
541
    sWhatsThis    = sToolTipText;
 
542
    sStatusTip    = sToolTipText;
 
543
    iAccel        = 0;
 
544
}
 
545
 
 
546
void CmdPartExtrude::activated(int iMsg)
 
547
{
 
548
    PartGui::DlgExtrusion dlg(Gui::getMainWindow());
 
549
    dlg.exec();
 
550
}
 
551
 
 
552
bool CmdPartExtrude::isActive(void)
 
553
{
 
554
    return hasActiveDocument();
 
555
}
 
556
 
 
557
//===========================================================================
 
558
// Part_FilletEdges
 
559
//===========================================================================
 
560
DEF_STD_CMD_A(CmdPartFilletEdges);
 
561
 
 
562
CmdPartFilletEdges::CmdPartFilletEdges()
 
563
  :Command("Part_FilletEdges")
 
564
{
 
565
    sAppModule    = "Part";
 
566
    sGroup        = QT_TR_NOOP("Part");
 
567
    sMenuText     = QT_TR_NOOP("Fillet...");
 
568
    sToolTipText  = QT_TR_NOOP("Fillet the selected edges of a shape");
 
569
    sWhatsThis    = sToolTipText;
 
570
    sStatusTip    = sToolTipText;
 
571
    iAccel        = 0;
 
572
}
 
573
 
 
574
void CmdPartFilletEdges::activated(int iMsg)
 
575
{
 
576
    PartGui::DlgFilletEdges dlg(Gui::getMainWindow());
 
577
    dlg.exec();
 
578
}
 
579
 
 
580
bool CmdPartFilletEdges::isActive(void)
 
581
{
 
582
    return hasActiveDocument();
 
583
}
 
584
 
 
585
//--------------------------------------------------------------------------------------
 
586
 
 
587
DEF_STD_CMD_A(CmdShapeInfo);
 
588
 
 
589
CmdShapeInfo::CmdShapeInfo()
 
590
  :Command("Part_ShapeInfo")
 
591
{
 
592
    sAppModule    = "Part";
 
593
    sGroup        = "Part";
 
594
    sMenuText     = "Shape info...";
 
595
    sToolTipText  = "Info about shape";
 
596
    sWhatsThis    = sToolTipText;
 
597
    sStatusTip    = sToolTipText;
 
598
}
 
599
 
 
600
void CmdShapeInfo::activated(int iMsg)
 
601
{
 
602
    static const char * const part_pipette[]={
 
603
        "32 32 17 1",
 
604
        "# c #000000",
 
605
        "j c #080808",
 
606
        "b c #101010",
 
607
        "f c #1c1c1c",
 
608
        "g c #4c4c4c",
 
609
        "c c #777777",
 
610
        "a c #848484",
 
611
        "i c #9c9c9c",
 
612
        "l c #b9b9b9",
 
613
        "e c #cacaca",
 
614
        "n c #d6d6d6",
 
615
        "k c #dedede",
 
616
        "d c #e7e7e7",
 
617
        "m c #efefef",
 
618
        "h c #f7f7f7",
 
619
        "w c #ffffff",
 
620
        ". c None",
 
621
        "................................",
 
622
        ".....................#####......",
 
623
        "...................#######......",
 
624
        "...................#########....",
 
625
        "..................##########....",
 
626
        "..................##########....",
 
627
        "..................##########....",
 
628
        ".................###########....",
 
629
        "...............#############....",
 
630
        ".............###############....",
 
631
        ".............#############......",
 
632
        ".............#############......",
 
633
        "...............ab######.........",
 
634
        "..............cdef#####.........",
 
635
        ".............ghdacf####.........",
 
636
        "............#ehiacj####.........",
 
637
        "............awiaaf####..........",
 
638
        "...........iheacf##.............",
 
639
        "..........#kdaag##..............",
 
640
        ".........gedaacb#...............",
 
641
        ".........lwiac##................",
 
642
        ".......#amlaaf##................",
 
643
        ".......cheaag#..................",
 
644
        "......#ndaag##..................",
 
645
        ".....#imaacb#...................",
 
646
        ".....iwlacf#....................",
 
647
        "....#nlaag##....................",
 
648
        "....feaagj#.....................",
 
649
        "....caag##......................",
 
650
        "....ffbj##......................",
 
651
        "................................",
 
652
        "................................"};
 
653
 
 
654
    Gui::Document* doc = Gui::Application::Instance->activeDocument();
 
655
    Gui::View3DInventor* view = static_cast<Gui::View3DInventor*>(doc->getActiveView());
 
656
    if (view) {
 
657
        Gui::View3DInventorViewer* viewer = view->getViewer();
 
658
        viewer->setEditing(true);
 
659
        viewer->getWidget()->setCursor(QCursor(QPixmap(part_pipette),4,29));
 
660
        viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), PartGui::ViewProviderPart::shapeInfoCallback);
 
661
     }
 
662
}
 
663
 
 
664
bool CmdShapeInfo::isActive(void)
 
665
{
 
666
    App::Document* doc = App::GetApplication().getActiveDocument();
 
667
    if (!doc || doc->countObjectsOfType(Part::Feature::getClassTypeId()) == 0)
 
668
        return false;
 
669
 
 
670
    Gui::MDIView* view = Gui::getMainWindow()->activeWindow();
 
671
    if (view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
 
672
        Gui::View3DInventorViewer* viewer = static_cast<Gui::View3DInventor*>(view)->getViewer();
 
673
        return !viewer->isEditing();
 
674
    }
 
675
 
 
676
    return false;
 
677
}
 
678
 
 
679
 
 
680
void CreatePartCommands(void)
 
681
{
 
682
    Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
 
683
 
 
684
    rcCmdMgr.addCommand(new CmdPartBoolean());
 
685
    rcCmdMgr.addCommand(new CmdPartExtrude());
 
686
    rcCmdMgr.addCommand(new CmdPartFilletEdges());
 
687
    rcCmdMgr.addCommand(new CmdPartCommon());
 
688
    rcCmdMgr.addCommand(new CmdPartCut());
 
689
    rcCmdMgr.addCommand(new CmdPartFuse());
 
690
    rcCmdMgr.addCommand(new CmdPartSection());
 
691
    rcCmdMgr.addCommand(new CmdPartBox2());
 
692
    rcCmdMgr.addCommand(new CmdPartBox3());
 
693
    rcCmdMgr.addCommand(new CmdPartPrimitives());
 
694
 
 
695
    rcCmdMgr.addCommand(new CmdPartImport());
 
696
    rcCmdMgr.addCommand(new CmdPartImportCurveNet());
 
697
    rcCmdMgr.addCommand(new CmdPartPickCurveNet());
 
698
    rcCmdMgr.addCommand(new CmdShapeInfo());
 
699
 
700