FreeCAD

Форк
0
/
TaskDetail.cpp 
682 строки · 22.6 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2020 WandererFan <wandererfan@gmail.com>                *
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
#include <App/Document.h>
26
#include <Base/Console.h>
27
#include <Base/Tools.h>
28
#include <Base/UnitsApi.h>
29
#include <Gui/Application.h>
30
#include <Gui/BitmapFactory.h>
31
#include <Gui/Command.h>
32
#include <Gui/Document.h>
33
#include <Gui/Selection.h>
34
#include <Gui/ViewProvider.h>
35
#include <Mod/TechDraw/App/DrawPage.h>
36
#include <Mod/TechDraw/App/DrawProjGroup.h>
37
#include <Mod/TechDraw/App/DrawProjGroupItem.h>
38
#include <Mod/TechDraw/App/DrawViewDetail.h>
39
#include <Mod/TechDraw/App/DrawViewPart.h>
40

41
#include "ui_TaskDetail.h"
42
#include "TaskDetail.h"
43
#include "QGIGhostHighlight.h"
44
#include "QGSPage.h"
45
#include "Rez.h"
46
#include "ViewProviderPage.h"
47

48

49
using namespace TechDrawGui;
50
using namespace TechDraw;
51
using namespace Gui;
52

53
static constexpr int CREATEMODE(0);
54
static constexpr int EDITMODE(1);
55

56
//creation constructor
57
TaskDetail::TaskDetail(TechDraw::DrawViewPart* baseFeat):
58
    ui(new Ui_TaskDetail),
59
    blockUpdate(false),
60
    m_ghost(nullptr),
61
    m_detailFeat(nullptr),
62
    m_baseFeat(baseFeat),
63
    m_basePage(nullptr),
64
    m_qgParent(nullptr),
65
    m_inProgressLock(false),
66
    m_btnOK(nullptr),
67
    m_btnCancel(nullptr),
68
    m_saveAnchor(Base::Vector3d(0.0, 0.0, 0.0)),
69
    m_saveRadius(0.0),
70
    m_saved(false),
71
    m_baseName(std::string()),
72
    m_pageName(std::string()),
73
    m_detailName(std::string()),
74
    m_doc(nullptr),
75
    m_mode(CREATEMODE),
76
    m_created(false)
77
{
78
    //existence of baseFeat checked in CmdTechDrawDetailView (Command.cpp)
79

80
    m_basePage = m_baseFeat->findParentPage();
81
    //it is possible that the basePage could be unparented and have no corresponding Page
82
    if (!m_basePage) {
83
        Base::Console().Error("TaskDetail - bad parameters - base page.  Can not proceed.\n");
84
        return;
85
    }
86

87
    m_baseName = m_baseFeat->getNameInDocument();
88
    m_doc      = m_baseFeat->getDocument();
89
    m_pageName = m_basePage->getNameInDocument();
90

91
    ui->setupUi(this);
92

93
    Gui::Document* activeGui = Gui::Application::Instance->getDocument(m_doc);
94
    Gui::ViewProvider* vp = activeGui->getViewProvider(m_basePage);
95
    m_vpp = static_cast<ViewProviderPage*>(vp);
96

97
    createDetail();
98
    setUiFromFeat();
99
    setWindowTitle(QObject::tr("New Detail View"));
100

101
    connect(ui->pbDragger, &QPushButton::clicked,
102
            this, &TaskDetail::onDraggerClicked);
103

104
    // the UI file uses keyboardTracking = false so that a recomputation
105
    // will only be triggered when the arrow keys of the spinboxes are used
106
    connect(ui->qsbX, qOverload<double>(&QuantitySpinBox::valueChanged),
107
            this, &TaskDetail::onXEdit);
108
    connect(ui->qsbY, qOverload<double>(&QuantitySpinBox::valueChanged),
109
            this, &TaskDetail::onYEdit);
110
    connect(ui->qsbRadius, qOverload<double>(&QuantitySpinBox::valueChanged),
111
            this, &TaskDetail::onRadiusEdit);
112
    connect(ui->cbScaleType, qOverload<int>(&QComboBox::currentIndexChanged),
113
            this, &TaskDetail::onScaleTypeEdit);
114
    connect(ui->qsbScale, qOverload<double>(&QuantitySpinBox::valueChanged),
115
            this, &TaskDetail::onScaleEdit);
116
    connect(ui->leReference, &QLineEdit::editingFinished,
117
            this, &TaskDetail::onReferenceEdit);
118

119
    m_ghost = new QGIGhostHighlight();
120
    m_vpp->getQGSPage()->addItem(m_ghost);
121
    m_ghost->hide();
122
    connect(m_ghost, &QGIGhostHighlight::positionChange,
123
            this, &TaskDetail::onHighlightMoved);
124
}
125

126
//edit constructor
127
TaskDetail::TaskDetail(TechDraw::DrawViewDetail* detailFeat):
128
    ui(new Ui_TaskDetail),
129
    blockUpdate(false),
130
    m_ghost(nullptr),
131
    m_detailFeat(detailFeat),
132
    m_baseFeat(nullptr),
133
    m_basePage(nullptr),
134
    m_qgParent(nullptr),
135
    m_inProgressLock(false),
136
    m_btnOK(nullptr),
137
    m_btnCancel(nullptr),
138
    m_saveAnchor(Base::Vector3d(0.0, 0.0, 0.0)),
139
    m_saveRadius(0.0),
140
    m_saved(false),
141
    m_baseName(std::string()),
142
    m_pageName(std::string()),
143
    m_detailName(std::string()),
144
    m_doc(nullptr),
145
    m_mode(EDITMODE),
146
    m_created(false)
147
{
148
    if (!m_detailFeat)  {
149
        //should be caught in CMD caller
150
        Base::Console().Error("TaskDetail - bad parameters.  Can not proceed.\n");
151
        return;
152
    }
153

154
    m_doc = m_detailFeat->getDocument();
155
    m_detailName = m_detailFeat->getNameInDocument();
156

157
    m_basePage = m_detailFeat->findParentPage();
158
    if (m_basePage) {
159
        m_pageName = m_basePage->getNameInDocument();
160
    }
161

162
    App::DocumentObject* baseObj = m_detailFeat->BaseView.getValue();
163
    m_baseFeat = dynamic_cast<TechDraw::DrawViewPart*>(baseObj);
164
    if (m_baseFeat) {
165
        m_baseName = m_baseFeat->getNameInDocument();
166
    } else {
167
        Base::Console().Error("TaskDetail - no BaseView.  Can not proceed.\n");
168
        return;
169
    }
170

171
    ui->setupUi(this);
172

173
    Gui::Document* activeGui = Gui::Application::Instance->getDocument(m_basePage->getDocument());
174
    Gui::ViewProvider* vp = activeGui->getViewProvider(m_basePage);
175
    m_vpp = static_cast<ViewProviderPage*>(vp);
176

177
    saveDetailState();
178
    setUiFromFeat();
179
    setWindowTitle(QObject::tr("Edit Detail View"));
180

181
    connect(ui->pbDragger, &QPushButton::clicked,
182
            this, &TaskDetail::onDraggerClicked);
183

184
    // the UI file uses keyboardTracking = false so that a recomputation
185
    // will only be triggered when the arrow keys of the spinboxes are used
186
    connect(ui->qsbX, qOverload<double>(&QuantitySpinBox::valueChanged),
187
            this, &TaskDetail::onXEdit);
188
    connect(ui->qsbY, qOverload<double>(&QuantitySpinBox::valueChanged),
189
            this, &TaskDetail::onYEdit);
190
    connect(ui->qsbRadius, qOverload<double>(&QuantitySpinBox::valueChanged),
191
            this, &TaskDetail::onRadiusEdit);
192
    connect(ui->cbScaleType, qOverload<int>(&QComboBox::currentIndexChanged),
193
            this, &TaskDetail::onScaleTypeEdit);
194
    connect(ui->qsbScale, qOverload<double>(&QuantitySpinBox::valueChanged),
195
            this, &TaskDetail::onScaleEdit);
196
    connect(ui->leReference, &QLineEdit::editingFinished,
197
            this, &TaskDetail::onReferenceEdit);
198

199
    m_ghost = new QGIGhostHighlight();
200
    m_vpp->getQGSPage()->addItem(m_ghost);
201
    m_ghost->hide();
202
    connect(m_ghost, &QGIGhostHighlight::positionChange,
203
            this, &TaskDetail::onHighlightMoved);
204
}
205

206
void TaskDetail::updateTask()
207
{
208
//    blockUpdate = true;
209

210
//    blockUpdate = false;
211
}
212

213
void TaskDetail::changeEvent(QEvent *e)
214
{
215
    if (e->type() == QEvent::LanguageChange) {
216
        ui->retranslateUi(this);
217
    }
218
}
219

220
//save the start conditions
221
void TaskDetail::saveDetailState()
222
{
223
//    Base::Console().Message("TD::saveDetailState()\n");
224
    TechDraw::DrawViewDetail* dvd = getDetailFeat();
225
    m_saveAnchor = dvd->AnchorPoint.getValue();
226
    m_saveRadius  = dvd->Radius.getValue();
227
    m_saved = true;
228
}
229

230
void TaskDetail::restoreDetailState()
231
{
232
//    Base::Console().Message("TD::restoreDetailState()\n");
233
    TechDraw::DrawViewDetail* dvd = getDetailFeat();
234
    dvd->AnchorPoint.setValue(m_saveAnchor);
235
    dvd->Radius.setValue(m_saveRadius);
236
}
237

238
//***** ui stuff ***************************************************************
239

240
void TaskDetail::setUiFromFeat()
241
{
242
//    Base::Console().Message("TD::setUIFromFeat()\n");
243
    if (m_baseFeat) {
244
        std::string baseName = getBaseFeat()->getNameInDocument();
245
        ui->leBaseView->setText(Base::Tools::fromStdString(baseName));
246
    }
247

248
    Base::Vector3d anchor;
249

250
    TechDraw::DrawViewDetail* detailFeat = getDetailFeat();
251
    QString detailDisplay = QString::fromUtf8(detailFeat->getNameInDocument()) +
252
                            QString::fromUtf8(" / ") +
253
                            QString::fromUtf8(detailFeat->Label.getValue());
254
    ui->leDetailView->setText(detailDisplay);
255
    anchor = detailFeat->AnchorPoint.getValue();
256
    double radius = detailFeat->Radius.getValue();
257
    long ScaleType = detailFeat->ScaleType.getValue();
258
    double scale = detailFeat->Scale.getValue();
259
    QString ref = QString::fromUtf8(detailFeat->Reference.getValue());
260

261
    ui->pbDragger->setText(tr("Drag Highlight"));
262
    ui->pbDragger->setEnabled(true);
263
    int decimals = Base::UnitsApi::getDecimals();
264
    ui->qsbX->setUnit(Base::Unit::Length);
265
    ui->qsbX->setDecimals(decimals);
266
    ui->qsbX->setValue(anchor.x);
267
    ui->qsbY->setUnit(Base::Unit::Length);
268
    ui->qsbY->setDecimals(decimals);
269
    ui->qsbY->setValue(anchor.y);
270
    ui->qsbRadius->setDecimals(decimals);
271
    ui->qsbRadius->setUnit(Base::Unit::Length);
272
    ui->qsbRadius->setValue(radius);
273
    ui->qsbScale->setDecimals(decimals);
274
    ui->cbScaleType->setCurrentIndex(ScaleType);
275
    if (ui->cbScaleType->currentIndex() == 2) // only if custom scale
276
        ui->qsbScale->setEnabled(true);
277
    else
278
        ui->qsbScale->setEnabled(false);
279
    ui->qsbScale->setValue(scale);
280
    ui->leReference->setText(ref);
281
}
282

283
//update ui point fields after tracker finishes
284
void TaskDetail::updateUi(QPointF pos)
285
{
286
    ui->qsbX->setValue(pos.x());
287
    ui->qsbY->setValue(- pos.y());
288
}
289

290
void TaskDetail::enableInputFields(bool isEnabled)
291
{
292
    ui->qsbX->setEnabled(isEnabled);
293
    ui->qsbY->setEnabled(isEnabled);
294
    if (ui->cbScaleType->currentIndex() == 2) // only if custom scale
295
        ui->qsbScale->setEnabled(isEnabled);
296
    ui->qsbRadius->setEnabled(isEnabled);
297
    ui->leReference->setEnabled(isEnabled);
298
}
299

300
void TaskDetail::onXEdit()
301
{
302
    updateDetail();
303
}
304

305
void TaskDetail::onYEdit()
306
{
307
    updateDetail();
308
}
309

310
void TaskDetail::onRadiusEdit()
311
{
312
    updateDetail();
313
}
314

315
void TaskDetail::onScaleTypeEdit()
316
{
317
    TechDraw::DrawViewDetail* detailFeat = getDetailFeat();
318

319
     if (ui->cbScaleType->currentIndex() == 0) {
320
         // page scale
321
         ui->qsbScale->setEnabled(false);
322
         detailFeat->ScaleType.setValue(0.0);
323
         // set the page scale if there is a valid page
324
         if (m_basePage) {
325
             // set the page scale
326
             detailFeat->Scale.setValue(m_basePage->Scale.getValue());
327
             ui->qsbScale->setValue(m_basePage->Scale.getValue());
328
         }
329
         // finally update the view
330
         updateDetail();
331
    }
332
    else if (ui->cbScaleType->currentIndex() == 1) {
333
        // automatic scale (if view is too large to fit into page, it will be scaled down)
334
        ui->qsbScale->setEnabled(false);
335
        detailFeat->ScaleType.setValue(1.0);
336
        // updating the feature will trigger the rescaling
337
        updateDetail();
338
    }
339
    else if (ui->cbScaleType->currentIndex() == 2) {
340
        // custom scale
341
        ui->qsbScale->setEnabled(true);
342
        detailFeat->ScaleType.setValue(2.0);
343
        // no updateDetail() necessary since nothing visibly was changed
344
    }
345
}
346

347
void TaskDetail::onScaleEdit()
348
{
349
    updateDetail();
350
}
351

352
void TaskDetail::onReferenceEdit()
353
{
354
    updateDetail();
355
}
356

357
void TaskDetail::onDraggerClicked(bool clicked)
358
{
359
    Q_UNUSED(clicked);
360
    ui->pbDragger->setEnabled(false);
361
    enableInputFields(false);
362
    editByHighlight();
363
    return;
364
}
365

366
void TaskDetail::editByHighlight()
367
{
368
//    Base::Console().Message("TD::editByHighlight()\n");
369
    if (!m_ghost) {
370
        Base::Console().Error("TaskDetail::editByHighlight - no ghost object\n");
371
        return;
372
    }
373

374
    double scale = getBaseFeat()->getScale();
375
    m_vpp->getQGSPage()->clearSelection();
376
    m_ghost->setSelected(true);
377
    m_ghost->setRadius(ui->qsbRadius->rawValue() * scale);
378
    m_ghost->setPos(getAnchorScene());
379
    m_ghost->draw();
380
    m_ghost->show();
381
}
382

383
//dragEnd is in scene coords.
384
void TaskDetail::onHighlightMoved(QPointF dragEnd)
385
{
386
//    Base::Console().Message("TD::onHighlightMoved(%s) - highlight: %X\n",
387
//                            DrawUtil::formatVector(dragEnd).c_str(), m_ghost);
388
    ui->pbDragger->setEnabled(true);
389

390
    double scale = getBaseFeat()->getScale();
391
    double x = Rez::guiX(getBaseFeat()->X.getValue());
392
    double y = Rez::guiX(getBaseFeat()->Y.getValue());
393

394
    DrawViewPart* dvp = getBaseFeat();
395
    DrawProjGroupItem* dpgi = dynamic_cast<DrawProjGroupItem*>(dvp);
396
    if (dpgi) {
397
        DrawProjGroup* dpg = dpgi->getPGroup();
398
        if (!dpg) {
399
            Base::Console().Message("TD::getAnchorScene - projection group is confused\n");
400
            //TODO::throw something.
401
            return;
402
        }
403
        x += Rez::guiX(dpg->X.getValue());
404
        y += Rez::guiX(dpg->Y.getValue());
405
    }
406

407
    QPointF basePosScene(x, -y);                 //base position in scene coords
408
    QPointF anchorDisplace = dragEnd - basePosScene;
409
    QPointF newAnchorPos = Rez::appX(anchorDisplace / scale);
410

411
    updateUi(newAnchorPos);
412
    updateDetail();
413
    enableInputFields(true);
414
    m_ghost->setSelected(false);
415
    m_ghost->hide();
416
}
417

418
void TaskDetail::saveButtons(QPushButton* btnOK,
419
                             QPushButton* btnCancel)
420
{
421
    m_btnOK = btnOK;
422
    m_btnCancel = btnCancel;
423
}
424

425
void TaskDetail::enableTaskButtons(bool button)
426
{
427
    m_btnOK->setEnabled(button);
428
    m_btnCancel->setEnabled(button);
429
}
430

431
//***** Feature create & edit stuff *******************************************
432
void TaskDetail::createDetail()
433
{
434
//    Base::Console().Message("TD::createDetail()\n");
435
    Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create Detail View"));
436

437
    const std::string objectName{"Detail"};
438
    m_detailName = m_doc->getUniqueObjectName(objectName.c_str());
439
    std::string generatedSuffix {m_detailName.substr(objectName.length())};
440

441
    Gui::Command::doCommand(Command::Doc, "App.activeDocument().addObject('TechDraw::DrawViewDetail', '%s')",
442
                            m_detailName.c_str());
443

444
    Gui::Command::doCommand(Command::Doc, "App.activeDocument().%s.translateLabel('DrawViewDetail', 'Detail', '%s')",
445
              m_detailName.c_str(), m_detailName.c_str());
446

447
    App::DocumentObject *docObj = m_baseFeat->getDocument()->getObject(m_detailName.c_str());
448
    TechDraw::DrawViewDetail* dvd = dynamic_cast<TechDraw::DrawViewDetail *>(docObj);
449
    if (!dvd) {
450
        throw Base::TypeError("TaskDetail - new detail view not found\n");
451
    }
452
    m_detailFeat = dvd;
453
    dvd->Source.setValues(getBaseFeat()->Source.getValues());
454

455
    Gui::Command::doCommand(Command::Doc, "App.activeDocument().%s.BaseView = App.activeDocument().%s",
456
                            m_detailName.c_str(), m_baseName.c_str());
457
    Gui::Command::doCommand(Command::Doc, "App.activeDocument().%s.Direction = App.activeDocument().%s.Direction",
458
                            m_detailName.c_str(), m_baseName.c_str());
459
    Gui::Command::doCommand(Command::Doc, "App.activeDocument().%s.XDirection = App.activeDocument().%s.XDirection",
460
                            m_detailName.c_str(), m_baseName.c_str());
461
    Gui::Command::doCommand(Command::Doc, "App.activeDocument().%s.Scale = App.activeDocument().%s.Scale",
462
                            m_detailName.c_str(), m_baseName.c_str());
463
    Gui::Command::doCommand(Command::Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)",
464
                            m_pageName.c_str(), m_detailName.c_str());
465

466
    Gui::Command::updateActive();
467
    Gui::Command::commitCommand();
468

469
    getBaseFeat()->requestPaint();
470
    m_created = true;
471
}
472

473
void TaskDetail::updateDetail()
474
{
475
//    Base::Console().Message("TD::updateDetail()\n");
476
    try {
477
        Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Update Detail"));
478
        double x = ui->qsbX->rawValue();
479
        double y = ui->qsbY->rawValue();
480
        Base::Vector3d temp(x, y, 0.0);
481
        TechDraw::DrawViewDetail* detailFeat = getDetailFeat();
482
        detailFeat->AnchorPoint.setValue(temp);
483
        double scale = ui->qsbScale->rawValue();
484
        detailFeat->Scale.setValue(scale);
485
        double radius = ui->qsbRadius->rawValue();
486
        detailFeat->Radius.setValue(radius);
487
        QString qRef = ui->leReference->text();
488
        std::string ref = Base::Tools::toStdString(qRef);
489
        detailFeat->Reference.setValue(ref);
490

491
        detailFeat->recomputeFeature();
492
        getBaseFeat()->requestPaint();
493
        Gui::Command::updateActive();
494
        Gui::Command::commitCommand();
495
    }
496
    catch (...) {
497
        //this is probably due to appl closing while dialog is still open
498
        Base::Console().Error("Task Detail - detail feature update failed.\n");
499
    }
500
}
501

502
//***** Getters ****************************************************************
503

504
//get the current Anchor highlight position in scene coords
505
QPointF TaskDetail::getAnchorScene()
506
{
507
    DrawViewPart* dvp = getBaseFeat();
508
    DrawProjGroupItem* dpgi = dynamic_cast<DrawProjGroupItem*>(dvp);
509
    DrawViewDetail* dvd = getDetailFeat();
510
    Base::Vector3d anchorPos = dvd->AnchorPoint.getValue();
511
    anchorPos.y = -anchorPos.y;
512
    Base::Vector3d basePos;
513
    double scale = 1;
514

515
    if (!dpgi) {          //base is normal view
516
        double x = dvp->X.getValue();
517
        double y = dvp->Y.getValue();
518
        basePos = Base::Vector3d (x, -y, 0.0);
519
        scale = dvp->getScale();
520
    } else {                       //part of projection group
521

522
        DrawProjGroup* dpg = dpgi->getPGroup();
523
        if (!dpg) {
524
            Base::Console().Message("TD::getAnchorScene - projection group is confused\n");
525
            //TODO::throw something.
526
            return QPointF(0.0, 0.0);
527
        }
528
        double x = dpg->X.getValue();
529
        x += dpgi->X.getValue();
530
        double y = dpg->Y.getValue();
531
        y += dpgi->Y.getValue();
532
        basePos = Base::Vector3d(x, -y, 0.0);
533
        scale = dpgi->getScale();
534
    }
535

536
    Base::Vector3d xyScene = Rez::guiX(basePos);
537
    Base::Vector3d anchorOffsetScene = Rez::guiX(anchorPos) * scale;
538
    Base::Vector3d netPos = xyScene + anchorOffsetScene;
539
    return QPointF(netPos.x, netPos.y);
540
}
541

542
// protects against stale pointers
543
DrawViewPart* TaskDetail::getBaseFeat()
544
{
545
//    Base::Console().Message("TD::getBaseFeat()\n");
546

547
    if (m_doc) {
548
        App::DocumentObject* baseObj = m_doc->getObject(m_baseName.c_str());
549
        if (baseObj) {
550
            return static_cast<DrawViewPart*>(baseObj);
551
        }
552
    }
553

554
    std::string msg = "TaskDetail - base feature " +
555
                        m_baseName +
556
                        " not found \n";
557
    throw Base::TypeError(msg);
558
    return nullptr;
559
}
560

561
// protects against stale pointers
562
DrawViewDetail* TaskDetail::getDetailFeat()
563
{
564
//    Base::Console().Message("TD::getDetailFeat()\n");
565

566
    if (m_baseFeat) {
567
        App::DocumentObject* detailObj = m_baseFeat->getDocument()->getObject(m_detailName.c_str());
568
        if (detailObj) {
569
            return static_cast<DrawViewDetail*>(detailObj);
570
        }
571
    }
572

573
    std::string msg = "TaskDetail - detail feature " +
574
                        m_detailName +
575
                        " not found \n";
576
//        throw Base::TypeError("TaskDetail - detail feature not found\n");
577
    throw Base::TypeError(msg);
578
    return nullptr;
579
}
580

581
//******************************************************************************
582

583
bool TaskDetail::accept()
584
{
585
//    Base::Console().Message("TD::accept()\n");
586

587
    Gui::Document* doc = Gui::Application::Instance->getDocument(m_basePage->getDocument());
588
    if (!doc)
589
        return false;
590

591
    m_ghost->hide();
592
    getDetailFeat()->requestPaint();
593
    getBaseFeat()->requestPaint();
594
    Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()");
595

596
    return true;
597
}
598

599
bool TaskDetail::reject()
600
{
601
//    Base::Console().Message("TD::reject()\n");
602
    Gui::Document* doc = Gui::Application::Instance->getDocument(m_basePage->getDocument());
603
    if (!doc)
604
        return false;
605

606
    m_ghost->hide();
607
    if (m_mode == CREATEMODE) {
608
        if (m_created) {
609
            Gui::Command::doCommand(Gui::Command::Gui, "App.activeDocument().removeObject('%s')",
610
                                    m_detailName.c_str());
611
        }
612
    } else {
613
        restoreDetailState();
614
        getDetailFeat()->recomputeFeature();
615
        getBaseFeat()->requestPaint();
616
    }
617

618
    Gui::Command::doCommand(Gui::Command::Gui, "App.activeDocument().recompute()");
619
    Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()");
620

621
    return false;
622
}
623

624
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
625
TaskDlgDetail::TaskDlgDetail(TechDraw::DrawViewPart* baseFeat)
626
    : TaskDialog()
627
{
628
    widget  = new TaskDetail(baseFeat);
629
    taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/TechDraw_DetailView"),
630
                                             widget->windowTitle(), true, nullptr);
631
    taskbox->groupLayout()->addWidget(widget);
632
    Content.push_back(taskbox);
633
}
634

635
TaskDlgDetail::TaskDlgDetail(TechDraw::DrawViewDetail* detailFeat)
636
    : TaskDialog()
637
{
638
    widget  = new TaskDetail(detailFeat);
639
    taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/TechDraw_DetailView"),
640
                                             widget->windowTitle(), true, nullptr);
641
    taskbox->groupLayout()->addWidget(widget);
642
    Content.push_back(taskbox);
643
}
644

645
TaskDlgDetail::~TaskDlgDetail()
646
{
647
}
648

649
void TaskDlgDetail::update()
650
{
651
//    widget->updateTask();
652
}
653

654
void TaskDlgDetail::modifyStandardButtons(QDialogButtonBox* box)
655
{
656
    QPushButton* btnOK = box->button(QDialogButtonBox::Ok);
657
    QPushButton* btnCancel = box->button(QDialogButtonBox::Cancel);
658
    widget->saveButtons(btnOK, btnCancel);
659
}
660

661
//==== calls from the TaskView ===============================================================
662
void TaskDlgDetail::open()
663
{
664
}
665

666
void TaskDlgDetail::clicked(int)
667
{
668
}
669

670
bool TaskDlgDetail::accept()
671
{
672
    widget->accept();
673
    return true;
674
}
675

676
bool TaskDlgDetail::reject()
677
{
678
    widget->reject();
679
    return true;
680
}
681

682
#include <Mod/TechDraw/Gui/moc_TaskDetail.cpp>
683

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

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

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

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