1
/***************************************************************************
2
* Copyright (c) 2019 WandererFan <wandererfan@gmail.com> *
4
* This file is part of the FreeCAD CAx development system. *
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. *
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. *
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 *
21
***************************************************************************/
23
#include "PreCompiled.h"
29
#include <App/Document.h>
30
#include <Base/Console.h>
31
#include <Base/Tools.h>
32
#include <Gui/Application.h>
33
#include <Gui/BitmapFactory.h>
34
#include <Gui/Command.h>
35
#include <Gui/Document.h>
36
#include <Gui/MainWindow.h>
37
#include <Gui/ViewProvider.h>
38
#include <Mod/TechDraw/App/ArrowPropEnum.h>
39
#include <Mod/TechDraw/App/DrawLeaderLine.h>
40
#include <Mod/TechDraw/App/DrawPage.h>
41
#include <Mod/TechDraw/App/DrawView.h>
42
#include <Mod/TechDraw/App/LineGroup.h>
44
#include "TaskLeaderLine.h"
45
#include "ui_TaskLeaderLine.h"
46
#include "DrawGuiUtil.h"
47
#include "MDIViewPage.h"
48
#include "PreferencesGui.h"
49
#include "QGILeaderLine.h"
54
#include "ViewProviderLeader.h"
55
#include "ViewProviderPage.h"
59
using namespace TechDraw;
60
using namespace TechDrawGui;
63
TaskLeaderLine::TaskLeaderLine(TechDrawGui::ViewProviderLeader* leadVP) :
64
ui(new Ui_TaskLeaderLine),
72
m_trackerMode(QGTracker::None),
73
m_saveContextPolicy(Qt::DefaultContextMenu),
74
m_inProgressLock(false),
78
m_pbTrackerState(TRACKEREDIT),
82
//existence of leadVP is guaranteed by caller being ViewProviderLeaderLine.setEdit
84
m_lineFeat = m_lineVP->getFeature();
86
m_basePage = m_lineFeat->findParentPage();
88
Base::Console().Error("TaskRichAnno - bad parameters (2). Can not proceed.\n");
91
App::DocumentObject* obj = m_lineFeat->LeaderParent.getValue();
93
if (obj->isDerivedFrom(TechDraw::DrawView::getClassTypeId()) ) {
94
m_baseFeat = static_cast<TechDraw::DrawView*>(m_lineFeat->LeaderParent.getValue());
98
Gui::Document* activeGui = Gui::Application::Instance->getDocument(m_basePage->getDocument());
99
Gui::ViewProvider* vp = activeGui->getViewProvider(m_basePage);
100
m_vpp = static_cast<ViewProviderPage*>(vp);
102
m_qgParent = nullptr;
104
m_qgParent = m_vpp->getQGSPage()->findQViewForDocObj(m_baseFeat);
107
//TODO: when/if leaders are allowed to be parented to Page, check for m_baseFeat will be removed
108
if (!m_baseFeat || !m_basePage) {
109
Base::Console().Error("TaskLeaderLine - bad parameters (2). Can not proceed.\n");
117
m_attachPoint = Rez::guiX(Base::Vector3d(m_lineFeat->X.getValue(),
118
-m_lineFeat->Y.getValue(),
121
connect(ui->pbTracker, &QPushButton::clicked,
122
this, &TaskLeaderLine::onTrackerClicked);
123
connect(ui->pbCancelEdit, &QPushButton::clicked,
124
this, &TaskLeaderLine::onCancelEditClicked);
125
ui->pbCancelEdit->setEnabled(false);
129
m_trackerMode = QGTracker::TrackerMode::Line;
130
if (m_vpp->getMDIViewPage())
131
m_saveContextPolicy = m_vpp->getMDIViewPage()->contextMenuPolicy();
135
TaskLeaderLine::TaskLeaderLine(TechDraw::DrawView* baseFeat,
136
TechDraw::DrawPage* page) :
137
ui(new Ui_TaskLeaderLine),
140
m_baseFeat(baseFeat),
145
m_trackerMode(QGTracker::None),
146
m_saveContextPolicy(Qt::DefaultContextMenu),
147
m_inProgressLock(false),
150
m_btnCancel(nullptr),
151
m_pbTrackerState(TRACKERPICK),
155
//existence of basePage and baseFeat is checked in CmdTechDrawLeaderLine (CommandAnnotate.cpp)
157
Gui::Document* activeGui = Gui::Application::Instance->getDocument(m_basePage->getDocument());
158
Gui::ViewProvider* vp = activeGui->getViewProvider(m_basePage);
159
m_vpp = static_cast<ViewProviderPage*>(vp);
161
m_qgParent = nullptr;
163
m_qgParent = m_vpp->getQGSPage()->findQViewForDocObj(baseFeat);
170
connect(ui->pbTracker, &QPushButton::clicked,
171
this, &TaskLeaderLine::onTrackerClicked);
172
connect(ui->pbCancelEdit, &QPushButton::clicked,
173
this, &TaskLeaderLine::onCancelEditClicked);
174
ui->pbCancelEdit->setEnabled(false);
176
m_trackerMode = QGTracker::TrackerMode::Line;
177
if (m_vpp->getMDIViewPage())
178
m_saveContextPolicy = m_vpp->getMDIViewPage()->contextMenuPolicy();
181
void TaskLeaderLine::saveState()
184
m_savePoints = m_lineFeat->WayPoints.getValues();
185
m_saveX = m_lineFeat->X.getValue();
186
m_saveY = m_lineFeat->Y.getValue();
190
void TaskLeaderLine::restoreState()
193
m_lineFeat->WayPoints.setValues(m_savePoints);
194
m_lineFeat->X.setValue(m_saveX);
195
m_lineFeat->Y.setValue(m_saveY);
199
void TaskLeaderLine::updateTask()
201
// blockUpdate = true;
203
// blockUpdate = false;
206
void TaskLeaderLine::changeEvent(QEvent *event)
208
if (event->type() == QEvent::LanguageChange) {
209
ui->retranslateUi(this);
213
void TaskLeaderLine::setUiPrimary()
215
// Base::Console().Message("TTL::setUiPrimary()\n");
217
setWindowTitle(QObject::tr("New Leader Line"));
220
std::string baseName = m_baseFeat->getNameInDocument();
221
ui->tbBaseView->setText(Base::Tools::fromStdString(baseName));
224
ui->pbTracker->setText(tr("Pick points"));
225
if (m_vpp->getMDIViewPage()) {
226
ui->pbTracker->setEnabled(true);
227
ui->pbCancelEdit->setEnabled(true);
229
ui->pbTracker->setEnabled(false);
230
ui->pbCancelEdit->setEnabled(false);
233
DrawGuiUtil::loadArrowBox(ui->cboxStartSym);
234
int aStyle = getPrefArrowStyle();
235
ui->cboxStartSym->setCurrentIndex(aStyle);
237
DrawGuiUtil::loadArrowBox(ui->cboxEndSym);
238
ui->cboxEndSym->setCurrentIndex(TechDraw::ArrowType::NONE);
240
ui->dsbWeight->setUnit(Base::Unit::Length);
241
ui->dsbWeight->setMinimum(0);
242
ui->dsbWeight->setValue(prefWeight());
244
ui->cpLineColor->setColor(prefLineColor().asValue<QColor>());
247
//switch widgets related to ViewProvider on/off
248
//there is no ViewProvider until some time after feature is created.
249
void TaskLeaderLine::enableVPUi(bool enable)
251
ui->cpLineColor->setEnabled(enable);
252
ui->dsbWeight->setEnabled(enable);
253
ui->cboxStyle->setEnabled(enable);
256
void TaskLeaderLine::setUiEdit()
258
// Base::Console().Message("TTL::setUiEdit()\n");
260
setWindowTitle(QObject::tr("Edit Leader Line"));
263
std::string baseName = m_lineFeat->LeaderParent.getValue()->getNameInDocument();
264
ui->tbBaseView->setText(Base::Tools::fromStdString(baseName));
266
DrawGuiUtil::loadArrowBox(ui->cboxStartSym);
267
ui->cboxStartSym->setCurrentIndex(m_lineFeat->StartSymbol.getValue());
268
connect(ui->cboxStartSym, qOverload<int>(&QComboBox::currentIndexChanged), this, &TaskLeaderLine::onStartSymbolChanged);
269
DrawGuiUtil::loadArrowBox(ui->cboxEndSym);
270
ui->cboxEndSym->setCurrentIndex(m_lineFeat->EndSymbol.getValue());
271
connect(ui->cboxEndSym, qOverload<int>(&QComboBox::currentIndexChanged), this, &TaskLeaderLine::onEndSymbolChanged);
273
ui->pbTracker->setText(tr("Edit points"));
274
if (m_vpp->getMDIViewPage()) {
275
ui->pbTracker->setEnabled(true);
276
ui->pbCancelEdit->setEnabled(true);
278
ui->pbTracker->setEnabled(false);
279
ui->pbCancelEdit->setEnabled(false);
284
ui->cpLineColor->setColor(m_lineVP->Color.getValue().asValue<QColor>());
285
ui->dsbWeight->setValue(m_lineVP->LineWidth.getValue());
286
ui->cboxStyle->setCurrentIndex(m_lineVP->LineStyle.getValue());
288
connect(ui->cpLineColor, &ColorButton::changed, this, &TaskLeaderLine::onColorChanged);
289
ui->dsbWeight->setMinimum(0);
290
connect(ui->dsbWeight, qOverload<double>(&QuantitySpinBox::valueChanged), this, &TaskLeaderLine::onLineWidthChanged);
291
connect(ui->cboxStyle, qOverload<int>(&QComboBox::currentIndexChanged), this, &TaskLeaderLine::onLineStyleChanged);
294
void TaskLeaderLine::recomputeFeature()
296
App::DocumentObject* objVP = m_lineVP->getObject();
298
objVP->getDocument()->recomputeFeature(objVP);
301
void TaskLeaderLine::onStartSymbolChanged()
303
m_lineFeat->StartSymbol.setValue(ui->cboxStartSym->currentIndex());
307
void TaskLeaderLine::onEndSymbolChanged()
309
m_lineFeat->EndSymbol.setValue(ui->cboxEndSym->currentIndex());
313
void TaskLeaderLine::onColorChanged()
316
ac.setValue<QColor>(ui->cpLineColor->color());
317
m_lineVP->Color.setValue(ac);
321
void TaskLeaderLine::onLineWidthChanged()
323
m_lineVP->LineWidth.setValue(ui->dsbWeight->rawValue());
327
void TaskLeaderLine::onLineStyleChanged()
329
m_lineVP->LineStyle.setValue(ui->cboxStyle->currentIndex());
334
//******************************************************************************
335
void TaskLeaderLine::createLeaderFeature(std::vector<Base::Vector3d> converted)
337
// Base::Console().Message("TTL::createLeaderFeature()\n");
338
const std::string objectName{"LeaderLine"};
339
std::string m_leaderName = m_basePage->getDocument()->getUniqueObjectName(objectName.c_str());
340
m_leaderType = "TechDraw::DrawLeaderLine";
342
std::string PageName = m_basePage->getNameInDocument();
344
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create Leader"));
345
Command::doCommand(Command::Doc, "App.activeDocument().addObject('%s', '%s')",
346
m_leaderType.c_str(), m_leaderName.c_str());
347
Command::doCommand(Command::Doc, "App.activeDocument().%s.translateLabel('DrawLeaderLine', 'LeaderLine', '%s')",
348
m_leaderName.c_str(), m_leaderName.c_str());
350
Command::doCommand(Command::Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)",
351
PageName.c_str(), m_leaderName.c_str());
353
Command::doCommand(Command::Doc, "App.activeDocument().%s.LeaderParent = App.activeDocument().%s",
354
m_leaderName.c_str(), m_baseFeat->getNameInDocument());
357
App::DocumentObject* obj = m_basePage->getDocument()->getObject(m_leaderName.c_str());
359
throw Base::RuntimeError("TaskLeaderLine - new markup object not found");
360
if (obj->isDerivedFrom(TechDraw::DrawLeaderLine::getClassTypeId())) {
361
m_lineFeat = static_cast<TechDraw::DrawLeaderLine*>(obj);
362
m_lineFeat->setPosition(Rez::appX(m_attachPoint.x), Rez::appX(- m_attachPoint.y), true);
363
if (!converted.empty()) {
364
m_lineFeat->WayPoints.setValues(converted);
365
if (m_lineFeat->AutoHorizontal.getValue()) {
366
m_lineFeat->adjustLastSegment();
369
commonFeatureUpdate();
373
Gui::ViewProvider* vp = QGIView::getViewProvider(m_lineFeat);
374
auto leadVP = dynamic_cast<ViewProviderLeader*>(vp);
377
ac.setValue<QColor>(ui->cpLineColor->color());
378
leadVP->Color.setValue(ac);
379
leadVP->LineWidth.setValue(ui->dsbWeight->rawValue());
380
leadVP->LineStyle.setValue(ui->cboxStyle->currentIndex());
384
Gui::Command::updateActive();
385
Gui::Command::commitCommand();
387
//trigger claimChildren in tree
395
m_lineFeat->requestPaint();
399
void TaskLeaderLine::updateLeaderFeature()
401
// Base::Console().Message("TTL::updateLeaderFeature()\n");
402
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Edit Leader"));
403
//waypoints & x, y are updated by QGILeaderLine (for edits only!)
404
commonFeatureUpdate();
406
ac.setValue<QColor>(ui->cpLineColor->color());
407
m_lineVP->Color.setValue(ac);
408
m_lineVP->LineWidth.setValue(ui->dsbWeight->rawValue());
409
m_lineVP->LineStyle.setValue(ui->cboxStyle->currentIndex());
411
Gui::Command::updateActive();
412
Gui::Command::commitCommand();
415
m_baseFeat->requestPaint();
417
m_lineFeat->requestPaint();
420
void TaskLeaderLine::commonFeatureUpdate()
422
int start = ui->cboxStartSym->currentIndex();
423
int end = ui->cboxEndSym->currentIndex();
424
m_lineFeat->StartSymbol.setValue(start);
425
m_lineFeat->EndSymbol.setValue(end);
428
void TaskLeaderLine::removeFeature()
430
// Base::Console().Message("TTL::removeFeature()\n");
436
std::string PageName = m_basePage->getNameInDocument();
437
Gui::Command::doCommand(Gui::Command::Gui, "App.activeDocument().%s.removeView(App.activeDocument().%s)",
438
PageName.c_str(), m_lineFeat->getNameInDocument());
439
Gui::Command::doCommand(Gui::Command::Gui, "App.activeDocument().removeObject('%s')",
440
m_lineFeat->getNameInDocument());
443
Base::Console().Message("TTL::removeFeature - failed to delete feature\n");
447
if (Gui::Command::hasPendingCommand()) {
448
std::vector<std::string> undos = Gui::Application::Instance->activeDocument()->getUndoVector();
449
Gui::Application::Instance->activeDocument()->undo(1);
454
//********** Tracker routines *******************************************************************
455
void TaskLeaderLine::onTrackerClicked(bool clicked)
458
// Base::Console().Message("TTL::onTrackerClicked() m_pbTrackerState: %d\n",
460
if (!m_vpp->getMDIViewPage()) {
461
Base::Console().Message("TLL::onTrackerClicked - no Mdi, no Tracker!\n");
465
if ( (m_pbTrackerState == TRACKERSAVE) &&
468
m_tracker->terminateDrawing();
470
m_pbTrackerState = TRACKERPICK;
471
ui->pbTracker->setText(tr("Pick Points"));
472
ui->pbCancelEdit->setEnabled(false);
473
enableTaskButtons(true);
475
setEditCursor(Qt::ArrowCursor);
477
} else if ( (m_pbTrackerState == TRACKERSAVE) &&
478
(!getCreateMode()) ) { //edit mode
480
m_qgLine->closeEdit();
482
m_pbTrackerState = TRACKERPICK;
483
ui->pbTracker->setText(tr("Edit Points"));
484
ui->pbCancelEdit->setEnabled(false);
485
enableTaskButtons(true);
487
setEditCursor(Qt::ArrowCursor);
491
//TRACKERPICK or TRACKEREDIT
492
if (getCreateMode()) {
493
m_inProgressLock = true;
494
m_saveContextPolicy = m_vpp->getMDIViewPage()->contextMenuPolicy();
495
m_vpp->getMDIViewPage()->setContextMenuPolicy(Qt::PreventContextMenu);
496
m_trackerMode = QGTracker::TrackerMode::Line;
497
setEditCursor(Qt::CrossCursor);
500
QString msg = tr("Pick a starting point for leader line");
501
getMainWindow()->statusBar()->show();
502
Gui::getMainWindow()->showMessage(msg, 3000);
503
ui->pbTracker->setText(tr("Save Points"));
504
ui->pbTracker->setEnabled(true);
505
ui->pbCancelEdit->setEnabled(true);
506
m_pbTrackerState = TRACKERSAVE;
507
enableTaskButtons(false);
509
m_trackerPoints = m_lineFeat->WayPoints.getValues();
510
if (!m_trackerPoints.empty()) { //regular edit session
511
m_inProgressLock = true;
512
m_saveContextPolicy = m_vpp->getMDIViewPage()->contextMenuPolicy();
513
m_vpp->getMDIViewPage()->setContextMenuPolicy(Qt::PreventContextMenu);
514
QGIView* qgiv = m_vpp->getQGSPage()->findQViewForDocObj(m_lineFeat);
515
QGILeaderLine* qgLead = dynamic_cast<QGILeaderLine*>(qgiv);
519
Base::Console().Error("TaskLeaderLine - can't find leader graphic\n");
520
//now what? throw will generate "unknown unhandled exception"
523
connect(qgLead, &QGILeaderLine::editComplete,
524
this, &TaskLeaderLine::onPointEditComplete);
525
qgLead->startPathEdit();
526
QString msg = tr("Click and drag markers to adjust leader line");
527
getMainWindow()->statusBar()->show();
528
Gui::getMainWindow()->showMessage(msg, 3000);
529
ui->pbTracker->setText(tr("Save changes"));
530
ui->pbTracker->setEnabled(true);
531
ui->pbCancelEdit->setEnabled(true);
532
m_pbTrackerState = TRACKERSAVE;
533
enableTaskButtons(false);
535
} else { // need to recreate leaderline
536
m_inProgressLock = true;
537
m_saveContextPolicy = m_vpp->getMDIViewPage()->contextMenuPolicy();
538
m_vpp->getMDIViewPage()->setContextMenuPolicy(Qt::PreventContextMenu);
539
m_trackerMode = QGTracker::TrackerMode::Line;
540
setEditCursor(Qt::CrossCursor);
543
QString msg = tr("Pick a starting point for leader line");
544
getMainWindow()->statusBar()->show();
545
Gui::getMainWindow()->showMessage(msg, 3000);
546
ui->pbTracker->setText(tr("Save changes"));
547
ui->pbTracker->setEnabled(true);
548
ui->pbCancelEdit->setEnabled(true);
549
m_pbTrackerState = TRACKERSAVE;
550
enableTaskButtons(false);
555
void TaskLeaderLine::startTracker()
557
// Base::Console().Message("TTL::startTracker()\n");
558
if (!m_vpp->getQGSPage())
560
if (m_trackerMode == QGTracker::TrackerMode::None)
564
m_tracker = new QGTracker(m_vpp->getQGSPage(), m_trackerMode);
566
m_tracker, &QGTracker::drawingFinished,
567
this , &TaskLeaderLine::onTrackerFinished
570
//this is too harsh. but need to avoid restarting process
571
throw Base::RuntimeError("TechDrawNewLeader - tracker already active\n");
573
setEditCursor(Qt::CrossCursor);
574
QString msg = tr("Left click to set a point");
575
Gui::getMainWindow()->statusBar()->show();
576
Gui::getMainWindow()->showMessage(msg, 3000);
579
void TaskLeaderLine::onTrackerFinished(std::vector<QPointF> pts, QGIView* qgParent)
581
//in this case, we already know who the parent is. We don't need QGTracker to tell us.
583
// Base::Console().Message("TTL::onTrackerFinished() - parent: %X\n", qgParent);
585
Base::Console().Error("TaskLeaderLine - no points available\n");
590
double scale = m_qgParent->getScale();
591
QPointF mapped = m_qgParent->mapFromScene(pts.front()) / scale;
592
m_attachPoint = Base::Vector3d(mapped.x(), mapped.y(), 0.0);
593
trackerPointsFromQPoints(pts);
595
Base::Console().Message("TTL::onTrackerFinished - can't find parent graphic!\n");
597
throw Base::RuntimeError("TaskLeaderLine - can not find parent graphic");
600
QString msg = tr("Press OK or Cancel to continue");
601
getMainWindow()->statusBar()->show();
602
Gui::getMainWindow()->showMessage(msg, 3000);
603
enableTaskButtons(true);
605
m_tracker->sleep(true);
606
m_inProgressLock = false;
607
ui->pbTracker->setEnabled(false);
608
ui->pbCancelEdit->setEnabled(false);
609
enableTaskButtons(true);
610
setEditCursor(Qt::ArrowCursor);
613
void TaskLeaderLine::removeTracker()
615
// Base::Console().Message("TTL::removeTracker()\n");
616
if (!m_vpp->getQGSPage())
618
if (m_tracker && m_tracker->scene()) {
619
m_vpp->getQGSPage()->removeItem(m_tracker);
625
void TaskLeaderLine::onCancelEditClicked(bool clicked)
628
// Base::Console().Message("TTL::onCancelEditClicked() m_pbTrackerState: %d\n",
630
abandonEditSession();
632
m_lineFeat->requestPaint();
635
m_pbTrackerState = TRACKEREDIT;
636
ui->pbTracker->setText(tr("Edit points"));
637
ui->pbCancelEdit->setEnabled(false);
638
enableTaskButtons(true);
640
m_inProgressLock = false;
641
setEditCursor(Qt::ArrowCursor);
644
QGIView* TaskLeaderLine::findParentQGIV()
649
Gui::ViewProvider* gvp = QGIView::getViewProvider(m_baseFeat);
650
ViewProviderDrawingView* vpdv = dynamic_cast<ViewProviderDrawingView*>(gvp);
654
return vpdv->getQView();;
657
void TaskLeaderLine::setEditCursor(QCursor cursor)
659
if (!m_vpp->getQGSPage()) {
663
QGIView* qgivBase = m_vpp->getQGSPage()->findQViewForDocObj(m_baseFeat);
664
qgivBase->setCursor(cursor);
668
//from 1:1 scale scene QPointF to zero origin Vector3d points
669
void TaskLeaderLine::trackerPointsFromQPoints(std::vector<QPointF> pts)
671
// Base::Console().Message("TTL::trackerPointsFromQPoints(%d)\n", pts.size());
672
m_trackerPoints.clear();
674
QPointF mapped = p - pts.front();
675
Base::Vector3d convert(mapped.x(), mapped.y(), 0.0);
676
m_trackerPoints.push_back(convert);
680
//******************************************************************************
681
//void TaskLeaderLine::onPointEditComplete(std::vector<QPointF> pts, QGIView* parent)
682
void TaskLeaderLine::onPointEditComplete()
684
// Base::Console().Message("TTL::onPointEditComplete()\n");
685
m_inProgressLock = false;
687
m_pbTrackerState = TRACKEREDIT;
688
ui->pbTracker->setText(tr("Edit points"));
689
ui->pbTracker->setEnabled(true);
690
ui->pbCancelEdit->setEnabled(true);
691
enableTaskButtons(true);
694
void TaskLeaderLine::abandonEditSession()
696
// Base::Console().Message("TTL::abandonEditSession()\n");
698
m_qgLine->abandonEdit();
700
QString msg = tr("In progress edit abandoned. Start over.");
701
getMainWindow()->statusBar()->show();
702
Gui::getMainWindow()->showMessage(msg, 4000);
704
m_pbTrackerState = TRACKEREDIT;
705
ui->pbTracker->setText(tr("Edit points"));
706
enableTaskButtons(true);
707
ui->pbTracker->setEnabled(true);
708
ui->pbCancelEdit->setEnabled(false);
710
setEditCursor(Qt::ArrowCursor);
713
void TaskLeaderLine::saveButtons(QPushButton* btnOK,
714
QPushButton* btnCancel)
717
m_btnCancel = btnCancel;
720
void TaskLeaderLine::enableTaskButtons(bool enable)
722
m_btnOK->setEnabled(enable);
723
m_btnCancel->setEnabled(enable);
726
int TaskLeaderLine::getPrefArrowStyle()
728
return PreferencesGui::dimArrowStyle();
731
double TaskLeaderLine::prefWeight() const
733
return TechDraw::LineGroup::getDefaultWidth("Thin");
736
App::Color TaskLeaderLine::prefLineColor()
738
return PreferencesGui::leaderColor();
741
//******************************************************************************
743
bool TaskLeaderLine::accept()
745
// Base::Console().Message("TTL::accept()\n");
746
if (m_inProgressLock) {
747
//accept() button shouldn't be available if there is an edit in progress.
748
abandonEditSession();
753
Gui::Document* doc = Gui::Application::Instance->getDocument(m_basePage->getDocument());
757
if (!getCreateMode()) {
759
updateLeaderFeature();
762
createLeaderFeature(m_trackerPoints);
764
m_trackerMode = QGTracker::TrackerMode::None;
767
Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()");
769
if (m_vpp->getMDIViewPage())
770
m_vpp->getMDIViewPage()->setContextMenuPolicy(m_saveContextPolicy);
775
bool TaskLeaderLine::reject()
777
if (m_inProgressLock) {
778
// Base::Console().Message("TTL::reject - edit in progress!!\n");
779
//reject() button shouldn't be available if there is an edit in progress.
780
abandonEditSession();
785
Gui::Document* doc = Gui::Application::Instance->getDocument(m_basePage->getDocument());
789
if (getCreateMode() && m_lineFeat) {
796
m_trackerMode = QGTracker::TrackerMode::None;
799
//make sure any dangling objects are cleaned up
800
Gui::Command::doCommand(Gui::Command::Gui, "App.activeDocument().recompute()");
801
Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()");
803
if (m_vpp->getMDIViewPage()) {
804
m_vpp->getMDIViewPage()->setContextMenuPolicy(m_saveContextPolicy);
810
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
811
TaskDlgLeaderLine::TaskDlgLeaderLine(TechDraw::DrawView* baseFeat,
812
TechDraw::DrawPage* page)
815
widget = new TaskLeaderLine(baseFeat, page);
816
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/TechDraw_LeaderLine"),
817
widget->windowTitle(), true, nullptr);
818
taskbox->groupLayout()->addWidget(widget);
819
Content.push_back(taskbox);
822
TaskDlgLeaderLine::TaskDlgLeaderLine(TechDrawGui::ViewProviderLeader* leadVP)
825
widget = new TaskLeaderLine(leadVP);
826
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/TechDraw_LeaderLine"),
827
widget->windowTitle(), true, nullptr);
828
taskbox->groupLayout()->addWidget(widget);
829
Content.push_back(taskbox);
832
TaskDlgLeaderLine::~TaskDlgLeaderLine()
836
void TaskDlgLeaderLine::update()
838
// widget->updateTask();
841
void TaskDlgLeaderLine::modifyStandardButtons(QDialogButtonBox* box)
843
QPushButton* btnOK = box->button(QDialogButtonBox::Ok);
844
QPushButton* btnCancel = box->button(QDialogButtonBox::Cancel);
845
widget->saveButtons(btnOK, btnCancel);
848
//==== calls from the TaskView ===============================================================
849
void TaskDlgLeaderLine::open()
853
void TaskDlgLeaderLine::clicked(int)
857
bool TaskDlgLeaderLine::accept()
863
bool TaskDlgLeaderLine::reject()
869
#include <Mod/TechDraw/Gui/moc_TaskLeaderLine.cpp>