FreeCAD

Форк
0
/
ViewProviderMirror.cpp 
707 строк · 23.9 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2010 Werner Mayer <wmayer[at]users.sourceforge.net>     *
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
#include "PreCompiled.h"
24

25
#ifndef _PreComp_
26
# include <QAction>
27
# include <QMenu>
28
# include <QTimer>
29

30
# include <TopExp.hxx>
31
# include <TopTools_IndexedMapOfShape.hxx>
32

33
# include <Inventor/actions/SoSearchAction.h>
34
# include <Inventor/draggers/SoDragger.h>
35
# include <Inventor/manips/SoCenterballManip.h>
36
# include <Inventor/nodes/SoCoordinate3.h>
37
# include <Inventor/nodes/SoFaceSet.h>
38
# include <Inventor/nodes/SoMaterial.h>
39
# include <Inventor/nodes/SoSeparator.h>
40
#endif
41

42
#include <Gui/Application.h>
43
#include <Gui/Control.h>
44
#include <Gui/Document.h>
45
#include <Mod/Part/App/FeatureChamfer.h>
46
#include <Mod/Part/App/FeatureFillet.h>
47
#include <Mod/Part/App/FeatureMirroring.h>
48
#include <Mod/Part/App/FeatureOffset.h>
49
#include <Mod/Part/App/FeatureRevolution.h>
50
#include <Mod/Part/App/PartFeatures.h>
51

52
#include "ViewProviderMirror.h"
53
#include "DlgFilletEdges.h"
54
#include "TaskOffset.h"
55
#include "TaskThickness.h"
56

57

58
using namespace PartGui;
59

60
PROPERTY_SOURCE(PartGui::ViewProviderMirror, PartGui::ViewProviderPart)
61

62
ViewProviderMirror::ViewProviderMirror()
63
{
64
    sPixmap = "Part_Mirror";
65
    pcEditNode = new SoSeparator();
66
    pcEditNode->ref();
67
}
68

69
ViewProviderMirror::~ViewProviderMirror()
70
{
71
    pcEditNode->unref();
72
}
73

74
void ViewProviderMirror::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
75
{
76
    // don't add plane editor to context menu if MirrorPlane is set because it would override any changes, anyway
77
    Part::Mirroring* mf = static_cast<Part::Mirroring*>(getObject());
78
    Part::Feature* ref = static_cast<Part::Feature*>(mf->MirrorPlane.getValue());
79
    bool enabled = true;
80
    if (ref){
81
        enabled = false;
82
    }
83
    QAction* act;
84
    act = menu->addAction(QObject::tr("Edit mirror plane"), receiver, member);
85
    act->setEnabled(enabled);
86
    act->setData(QVariant((int)ViewProvider::Default));
87

88
    ViewProviderPart::setupContextMenu(menu, receiver, member);
89
}
90

91
bool ViewProviderMirror::setEdit(int ModNum)
92
{
93
    if (ModNum == ViewProvider::Default) {
94
        // get the properties from the mirror feature
95
        Part::Mirroring* mf = static_cast<Part::Mirroring*>(getObject());
96
        Part::Feature* ref = static_cast<Part::Feature*>(mf->MirrorPlane.getValue());
97
        if (ref) { //skip this editor if MirrorPlane property is set
98
            return false;
99
        }
100
        Base::BoundBox3d bbox = mf->Shape.getBoundingBox();
101
        float len = (float)bbox.CalcDiagonalLength();
102
        Base::Vector3d base = mf->Base.getValue();
103
        Base::Vector3d norm = mf->Normal.getValue();
104
        Base::Vector3d cent = bbox.GetCenter();
105
        base = cent.ProjectToPlane(base, norm);
106

107
        // setup the graph for editing the mirror plane
108
        SoTransform* trans = new SoTransform;
109
        SbRotation rot(SbVec3f(0,0,1), SbVec3f(norm.x,norm.y,norm.z));
110
        trans->rotation.setValue(rot);
111
        trans->translation.setValue(base.x,base.y,base.z);
112
        trans->center.setValue(0.0f,0.0f,0.0f);
113

114
        SoMaterial* color = new SoMaterial();
115
        color->diffuseColor.setValue(0,0,1);
116
        color->transparency.setValue(0.5);
117
        SoCoordinate3* points = new SoCoordinate3();
118
        points->point.setNum(4);
119
        points->point.set1Value(0, -len/2,-len/2,0);
120
        points->point.set1Value(1,  len/2,-len/2,0);
121
        points->point.set1Value(2,  len/2, len/2,0);
122
        points->point.set1Value(3, -len/2, len/2,0);
123
        SoFaceSet* face = new SoFaceSet();
124
        pcEditNode->addChild(trans);
125
        pcEditNode->addChild(color);
126
        pcEditNode->addChild(points);
127
        pcEditNode->addChild(face);
128

129
        // Now we replace the SoTransform node by a manipulator
130
        // Note: Even SoCenterballManip inherits from SoTransform
131
        // we cannot use it directly (in above code) because the
132
        // translation and center fields are overridden.
133
        SoSearchAction sa;
134
        sa.setInterest(SoSearchAction::FIRST);
135
        sa.setSearchingAll(false);
136
        sa.setNode(trans);
137
        sa.apply(pcEditNode);
138
        SoPath * path = sa.getPath();
139
        if (path) {
140
            SoCenterballManip * manip = new SoCenterballManip;
141
            manip->replaceNode(path);
142

143
            SoDragger* dragger = manip->getDragger();
144
            dragger->addStartCallback(dragStartCallback, this);
145
            dragger->addFinishCallback(dragFinishCallback, this);
146
            dragger->addMotionCallback(dragMotionCallback, this);
147
        }
148
        pcRoot->addChild(pcEditNode);
149
    }
150
    else {
151
        ViewProviderPart::setEdit(ModNum);
152
    }
153

154
    return true;
155
}
156

157
void ViewProviderMirror::unsetEdit(int ModNum)
158
{
159
    if (ModNum == ViewProvider::Default) {
160
        SoCenterballManip* manip = static_cast<SoCenterballManip *>(pcEditNode->getChild(0));
161

162
        SbVec3f move = manip->translation.getValue();
163
        SbVec3f center = manip->center.getValue();
164
        SbRotation rot = manip->rotation.getValue();
165

166
        // get the whole translation
167
        move += center;
168
        rot.multVec(center,center);
169
        move -= center;
170

171
        // the new axis of the plane
172
        SbVec3f norm(0,0,1);
173
        rot.multVec(norm,norm);
174

175
        // apply the new values
176
        Part::Mirroring* mf = static_cast<Part::Mirroring*>(getObject());
177
        mf->Base.setValue(move[0],move[1],move[2]);
178
        mf->Normal.setValue(norm[0],norm[1],norm[2]);
179

180
        pcRoot->removeChild(pcEditNode);
181
        Gui::coinRemoveAllChildren(pcEditNode);
182
    }
183
    else {
184
        ViewProviderPart::unsetEdit(ModNum);
185
    }
186
}
187

188
std::vector<App::DocumentObject*> ViewProviderMirror::claimChildren() const
189
{
190
    // Make the input object a child (see also #0001482)
191
    std::vector<App::DocumentObject*> temp;
192
    temp.push_back(static_cast<Part::Mirroring*>(getObject())->Source.getValue());
193
    return temp;
194
}
195

196
bool ViewProviderMirror::onDelete(const std::vector<std::string> &)
197
{
198
    // get the input shape
199
    Part::Mirroring* pMirroring = static_cast<Part::Mirroring*>(getObject());
200
    App::DocumentObject *pSource = pMirroring->Source.getValue();
201
    if (pSource)
202
        Gui::Application::Instance->showViewProvider(pSource);
203

204
    return true;
205
}
206

207
void ViewProviderMirror::dragStartCallback(void *, SoDragger *)
208
{
209
    // This is called when a manipulator is about to manipulating
210
    Gui::Application::Instance->activeDocument()->openCommand(QT_TRANSLATE_NOOP("Command", "Edit Mirror"));
211
}
212

213
void ViewProviderMirror::dragFinishCallback(void *, SoDragger *)
214
{
215
    // This is called when a manipulator has done manipulating
216
    Gui::Application::Instance->activeDocument()->commitCommand();
217
}
218

219
void ViewProviderMirror::dragMotionCallback(void *data, SoDragger *drag)
220
{
221
    ViewProviderMirror* that = static_cast<ViewProviderMirror*>(data);
222
    const SbMatrix& mat = drag->getMotionMatrix();
223
    // the new axis of the plane
224
    SbRotation rot(mat);
225
    SbVec3f norm(0,0,1);
226
    rot.multVec(norm,norm);
227
    Part::Mirroring* mf = static_cast<Part::Mirroring*>(that->getObject());
228
    mf->Base.setValue(mat[3][0],mat[3][1],mat[3][2]);
229
    mf->Normal.setValue(norm[0],norm[1],norm[2]);
230
}
231

232
// ----------------------------------------------------------------------------
233

234
PROPERTY_SOURCE(PartGui::ViewProviderFillet, PartGui::ViewProviderPart)
235

236
ViewProviderFillet::ViewProviderFillet()
237
{
238
    sPixmap = "Part_Fillet";
239
}
240

241
ViewProviderFillet::~ViewProviderFillet() = default;
242

243
void ViewProviderFillet::updateData(const App::Property* prop)
244
{
245
    PartGui::ViewProviderPart::updateData(prop);
246
    if (prop->is<Part::PropertyShapeHistory>()) {
247
        const std::vector<Part::ShapeHistory>& hist = static_cast<const Part::PropertyShapeHistory*>
248
            (prop)->getValues();
249
        if (hist.size() != 1)
250
            return;
251
        Part::Fillet* objFill = dynamic_cast<Part::Fillet*>(getObject());
252
        if (!objFill)
253
            return;
254
        Part::Feature* objBase = dynamic_cast<Part::Feature*>(
255
                Part::Feature::getShapeOwner(objFill->Base.getValue()));
256
        if (objBase) {
257
            const TopoDS_Shape& baseShape = objBase->Shape.getValue();
258
            const TopoDS_Shape& fillShape = objFill->Shape.getValue();
259

260
            TopTools_IndexedMapOfShape baseMap, fillMap;
261
            TopExp::MapShapes(baseShape, TopAbs_FACE, baseMap);
262
            TopExp::MapShapes(fillShape, TopAbs_FACE, fillMap);
263

264
            auto vpBase = dynamic_cast<PartGui::ViewProviderPart*>(Gui::Application::Instance->getViewProvider(objBase));
265
            if (vpBase) {
266
                auto colBase = static_cast<PartGui::ViewProviderPart*>(vpBase)->ShapeAppearance.getValues();
267
                std::vector<App::Material> colFill;
268
                colFill.resize(fillMap.Extent(), colBase[0]);
269
                applyTransparency(static_cast<PartGui::ViewProviderPart*>(vpBase)->Transparency.getValue(), colBase);
270

271
                if (static_cast<int>(colBase.size()) == baseMap.Extent()) {
272
                    applyMaterial(hist[0], colBase, colFill);
273
                }
274
                else if (!colBase.empty() && colBase[0] != this->ShapeAppearance[0]) {
275
                    colBase.resize(baseMap.Extent(), colBase[0]);
276
                    applyMaterial(hist[0], colBase, colFill);
277
                }
278

279
                // If the view provider has set a transparency then override the values
280
                // of the input shapes
281
                if (Transparency.getValue() > 0) {
282
                    applyTransparency(Transparency.getValue(), colFill);
283
                }
284

285
                this->ShapeAppearance.setValues(colFill);
286
            }
287
        }
288
    }
289
}
290

291
void ViewProviderFillet::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
292
{
293
    QAction* act;
294
    act = menu->addAction(QObject::tr("Edit fillet edges"), receiver, member);
295
    act->setData(QVariant((int)ViewProvider::Default));
296
    PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member);
297
}
298

299
bool ViewProviderFillet::setEdit(int ModNum)
300
{
301
    if (ModNum == ViewProvider::Default ) {
302
        if (Gui::Control().activeDialog())
303
            return false;
304
        Part::Fillet* fillet = static_cast<Part::Fillet*>(getObject());
305
        Gui::Control().showDialog(new PartGui::TaskFilletEdges(fillet));
306
        return true;
307
    }
308
    else {
309
        ViewProviderPart::setEdit(ModNum);
310
        return true;
311
    }
312
}
313

314
void ViewProviderFillet::unsetEdit(int ModNum)
315
{
316
    if (ModNum == ViewProvider::Default) {
317
        Gui::Control().closeDialog();
318
    }
319
    else {
320
        ViewProviderPart::unsetEdit(ModNum);
321
    }
322
}
323

324
std::vector<App::DocumentObject*> ViewProviderFillet::claimChildren() const
325
{
326
    std::vector<App::DocumentObject*> temp;
327
    temp.push_back(static_cast<Part::Fillet*>(getObject())->Base.getValue());
328
    return temp;
329
}
330

331
bool ViewProviderFillet::onDelete(const std::vector<std::string> &)
332
{
333
    // get the input shape
334
    Part::Fillet* pFillet = static_cast<Part::Fillet*>(getObject());
335
    App::DocumentObject *pBase = pFillet->Base.getValue();
336
    if (pBase)
337
        Gui::Application::Instance->showViewProvider(pBase);
338

339
    return true;
340
}
341

342
// ---------------------------------------
343

344
PROPERTY_SOURCE(PartGui::ViewProviderChamfer, PartGui::ViewProviderPart)
345

346
ViewProviderChamfer::ViewProviderChamfer()
347
{
348
    sPixmap = "Part_Chamfer";
349
}
350

351
ViewProviderChamfer::~ViewProviderChamfer() = default;
352

353
void ViewProviderChamfer::updateData(const App::Property* prop)
354
{
355
    PartGui::ViewProviderPart::updateData(prop);
356
    if (prop->is<Part::PropertyShapeHistory>()) {
357
        const std::vector<Part::ShapeHistory>& hist = static_cast<const Part::PropertyShapeHistory*>
358
            (prop)->getValues();
359
        if (hist.size() != 1)
360
            return;
361
        Part::Chamfer* objCham = dynamic_cast<Part::Chamfer*>(getObject());
362
        if (!objCham)
363
            return;
364
        Part::Feature* objBase = dynamic_cast<Part::Feature*>(
365
                Part::Feature::getShapeOwner(objCham->Base.getValue()));
366
        if (objBase) {
367
            const TopoDS_Shape& baseShape = objBase->Shape.getValue();
368
            const TopoDS_Shape& chamShape = objCham->Shape.getValue();
369

370
            TopTools_IndexedMapOfShape baseMap, chamMap;
371
            TopExp::MapShapes(baseShape, TopAbs_FACE, baseMap);
372
            TopExp::MapShapes(chamShape, TopAbs_FACE, chamMap);
373

374
            auto vpBase = dynamic_cast<PartGui::ViewProviderPart*>(Gui::Application::Instance->getViewProvider(objBase));
375
            if (vpBase) {
376
                auto colBase = static_cast<PartGui::ViewProviderPart*>(vpBase)->ShapeAppearance.getValues();
377
                std::vector<App::Material> colCham;
378
                colCham.resize(chamMap.Extent(), colBase[0]);
379
                applyTransparency(static_cast<PartGui::ViewProviderPart*>(vpBase)->Transparency.getValue(), colBase);
380

381
                if (static_cast<int>(colBase.size()) == baseMap.Extent()) {
382
                    applyMaterial(hist[0], colBase, colCham);
383
                }
384
                else if (!colBase.empty() && colBase[0] != this->ShapeAppearance[0]) {
385
                    colBase.resize(baseMap.Extent(), colBase[0]);
386
                    applyMaterial(hist[0], colBase, colCham);
387
                }
388

389
                // If the view provider has set a transparency then override the values
390
                // of the input shapes
391
                if (Transparency.getValue() > 0) {
392
                    applyTransparency(Transparency.getValue(), colCham);
393
                }
394

395
                this->ShapeAppearance.setValues(colCham);
396
            }
397
        }
398
    }
399
}
400

401
void ViewProviderChamfer::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
402
{
403
    QAction* act;
404
    act = menu->addAction(QObject::tr("Edit chamfer edges"), receiver, member);
405
    act->setData(QVariant((int)ViewProvider::Default));
406
    PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member);
407
}
408

409
bool ViewProviderChamfer::setEdit(int ModNum)
410
{
411
    if (ModNum == ViewProvider::Default ) {
412
        if (Gui::Control().activeDialog())
413
            return false;
414
        Part::Chamfer* chamfer = static_cast<Part::Chamfer*>(getObject());
415
        Gui::Control().showDialog(new PartGui::TaskChamferEdges(chamfer));
416
        return true;
417
    }
418
    else {
419
        ViewProviderPart::setEdit(ModNum);
420
        return true;
421
    }
422
}
423

424
void ViewProviderChamfer::unsetEdit(int ModNum)
425
{
426
    if (ModNum == ViewProvider::Default) {
427
        Gui::Control().closeDialog();
428
    }
429
    else {
430
        ViewProviderPart::unsetEdit(ModNum);
431
    }
432
}
433

434
std::vector<App::DocumentObject*> ViewProviderChamfer::claimChildren() const
435
{
436
    std::vector<App::DocumentObject*> temp;
437
    temp.push_back(static_cast<Part::Chamfer*>(getObject())->Base.getValue());
438
    return temp;
439
}
440

441
bool ViewProviderChamfer::onDelete(const std::vector<std::string> &)
442
{
443
    // get the input shape
444
    Part::Chamfer* pChamfer = static_cast<Part::Chamfer*>(getObject());
445
    App::DocumentObject *pBase = pChamfer->Base.getValue();
446
    if (pBase)
447
        Gui::Application::Instance->showViewProvider(pBase);
448

449
    return true;
450
}
451

452
// ---------------------------------------
453

454
PROPERTY_SOURCE(PartGui::ViewProviderRevolution, PartGui::ViewProviderPart)
455

456
ViewProviderRevolution::ViewProviderRevolution()
457
{
458
    sPixmap = "Part_Revolve";
459
}
460

461
ViewProviderRevolution::~ViewProviderRevolution() = default;
462

463
std::vector<App::DocumentObject*> ViewProviderRevolution::claimChildren() const
464
{
465
    std::vector<App::DocumentObject*> temp;
466
    temp.push_back(static_cast<Part::Revolution*>(getObject())->Source.getValue());
467
    return temp;
468
}
469

470
bool ViewProviderRevolution::onDelete(const std::vector<std::string> &)
471
{
472
    // get the input shape
473
    Part::Revolution* pRevolve = static_cast<Part::Revolution*>(getObject());
474
    App::DocumentObject *pBase = pRevolve->Source.getValue();
475
    if (pBase)
476
        Gui::Application::Instance->showViewProvider(pBase);
477

478
    return true;
479
}
480

481
// ---------------------------------------
482

483
PROPERTY_SOURCE(PartGui::ViewProviderLoft, PartGui::ViewProviderPart)
484

485
ViewProviderLoft::ViewProviderLoft()
486
{
487
    sPixmap = "Part_Loft";
488
}
489

490
ViewProviderLoft::~ViewProviderLoft() = default;
491

492
std::vector<App::DocumentObject*> ViewProviderLoft::claimChildren() const
493
{
494
    return static_cast<Part::Loft*>(getObject())->Sections.getValues();
495
}
496

497
bool ViewProviderLoft::onDelete(const std::vector<std::string> &)
498
{
499
    return true;
500
}
501

502
// ---------------------------------------
503

504
PROPERTY_SOURCE(PartGui::ViewProviderSweep, PartGui::ViewProviderPart)
505

506
ViewProviderSweep::ViewProviderSweep()
507
{
508
    sPixmap = "Part_Sweep";
509
}
510

511
ViewProviderSweep::~ViewProviderSweep() = default;
512

513
std::vector<App::DocumentObject*> ViewProviderSweep::claimChildren() const
514
{
515
    auto obj = static_cast<Part::Sweep*>(getObject());
516
    auto children = obj->Sections.getValues();
517
    if(obj->Spine.getValue())
518
        children.push_back(obj->Spine.getValue());
519
    return children;
520
}
521

522
bool ViewProviderSweep::onDelete(const std::vector<std::string> &)
523
{
524
    return true;
525
}
526

527
// ---------------------------------------
528

529
PROPERTY_SOURCE(PartGui::ViewProviderOffset, PartGui::ViewProviderPart)
530

531
ViewProviderOffset::ViewProviderOffset()
532
{
533
    sPixmap = "Part_Offset";
534
}
535

536
ViewProviderOffset::~ViewProviderOffset() = default;
537

538
void ViewProviderOffset::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
539
{
540
    addDefaultAction(menu, QObject::tr("Edit offset"));
541
    PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member);
542
}
543

544
bool ViewProviderOffset::setEdit(int ModNum)
545
{
546
    if (ModNum == ViewProvider::Default ) {
547
        Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
548
        TaskOffset* offsetDlg = qobject_cast<TaskOffset*>(dlg);
549
        if (offsetDlg && offsetDlg->getObject() != this->getObject())
550
            offsetDlg = nullptr; // another pad left open its task panel
551
        if (dlg && !offsetDlg) {
552
            if (dlg->canClose())
553
                Gui::Control().closeDialog();
554
            else
555
                return false;
556
        }
557

558
        // clear the selection (convenience)
559
        Gui::Selection().clearSelection();
560

561
        // start the edit dialog
562
        if (offsetDlg)
563
            Gui::Control().showDialog(offsetDlg);
564
        else
565
            Gui::Control().showDialog(new TaskOffset(static_cast<Part::Offset*>(getObject())));
566

567
        return true;
568
    }
569
    else {
570
        return ViewProviderPart::setEdit(ModNum);
571
    }
572
}
573

574
void ViewProviderOffset::unsetEdit(int ModNum)
575
{
576
    if (ModNum == ViewProvider::Default) {
577
        // when pressing ESC make sure to close the dialog
578
        Gui::Control().closeDialog();
579
    }
580
    else {
581
        PartGui::ViewProviderPart::unsetEdit(ModNum);
582
    }
583
}
584

585
std::vector<App::DocumentObject*> ViewProviderOffset::claimChildren() const
586
{
587
    std::vector<App::DocumentObject*> child;
588
    child.push_back(static_cast<Part::Offset*>(getObject())->Source.getValue());
589
    return child;
590
}
591

592
bool ViewProviderOffset::onDelete(const std::vector<std::string> &)
593
{
594
    // get the support and Sketch
595
    Part::Offset* offset = static_cast<Part::Offset*>(getObject());
596
    App::DocumentObject* source = offset->Source.getValue();
597
    if (source){
598
        Gui::Application::Instance->getViewProvider(source)->show();
599
    }
600

601
    return true;
602
}
603

604
// ---------------------------------------
605

606
PROPERTY_SOURCE(PartGui::ViewProviderOffset2D, PartGui::ViewProviderOffset)
607

608

609
// ---------------------------------------
610

611
PROPERTY_SOURCE(PartGui::ViewProviderThickness, PartGui::ViewProviderPart)
612

613
ViewProviderThickness::ViewProviderThickness()
614
{
615
    sPixmap = "Part_Thickness";
616
}
617

618
ViewProviderThickness::~ViewProviderThickness() = default;
619

620
void ViewProviderThickness::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
621
{
622
    addDefaultAction(menu, QObject::tr("Edit thickness"));
623
    PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member);
624
}
625

626
bool ViewProviderThickness::setEdit(int ModNum)
627
{
628
    if (ModNum == ViewProvider::Default ) {
629
        Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
630
        TaskThickness* thicknessDlg = qobject_cast<TaskThickness*>(dlg);
631
        if (thicknessDlg && thicknessDlg->getObject() != this->getObject())
632
            thicknessDlg = nullptr; // another pad left open its task panel
633
        if (dlg && !thicknessDlg) {
634
            if (dlg->canClose())
635
                Gui::Control().closeDialog();
636
            else
637
                return false;
638
        }
639

640
        // clear the selection (convenience)
641
        Gui::Selection().clearSelection();
642

643
        // start the edit dialog
644
        if (thicknessDlg)
645
            Gui::Control().showDialog(thicknessDlg);
646
        else
647
            Gui::Control().showDialog(new TaskThickness(static_cast<Part::Thickness*>(getObject())));
648

649
        return true;
650
    }
651
    else {
652
        return ViewProviderPart::setEdit(ModNum);
653
    }
654
}
655

656
void ViewProviderThickness::unsetEdit(int ModNum)
657
{
658
    if (ModNum == ViewProvider::Default) {
659
        // when pressing ESC make sure to close the dialog
660
        QTimer::singleShot(0, &Gui::Control(), &Gui::ControlSingleton::closeDialog);
661
    }
662
    else {
663
        PartGui::ViewProviderPart::unsetEdit(ModNum);
664
    }
665
}
666

667
std::vector<App::DocumentObject*> ViewProviderThickness::claimChildren() const
668
{
669
    std::vector<App::DocumentObject*> child;
670
    child.push_back(static_cast<Part::Thickness*>(getObject())->Faces.getValue());
671
    return child;
672
}
673

674
bool ViewProviderThickness::onDelete(const std::vector<std::string> &)
675
{
676
    // get the support and Sketch
677
    Part::Thickness* thickness = static_cast<Part::Thickness*>(getObject());
678
    App::DocumentObject* source = thickness->Faces.getValue();
679
    if (source){
680
        Gui::Application::Instance->getViewProvider(source)->show();
681
    }
682

683
    return true;
684
}
685

686
// ---------------------------------------
687

688
PROPERTY_SOURCE(PartGui::ViewProviderRefine, PartGui::ViewProviderPart)
689

690
ViewProviderRefine::ViewProviderRefine()
691
{
692
    sPixmap = "Part_Refine_Shape";
693
}
694

695
ViewProviderRefine::~ViewProviderRefine() = default;
696

697
// ---------------------------------------
698

699
PROPERTY_SOURCE(PartGui::ViewProviderReverse, PartGui::ViewProviderPart)
700

701
ViewProviderReverse::ViewProviderReverse()
702
{
703
    //TODO: Need a specific icon here!
704
    //sPixmap = "Part_Reverse_Shape";
705
}
706

707
ViewProviderReverse::~ViewProviderReverse() = default;
708

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.