From 12a35a09550371131b2252b8a3d6332f4ae6cf6a Mon Sep 17 00:00:00 2001 From: wandererfan Date: Wed, 17 Jul 2019 13:17:45 -0400 Subject: [PATCH] [TD]Remove NoLine option from dialogs --- src/Mod/TechDraw/Gui/TaskCenterLine.cpp | 24 +++++----- src/Mod/TechDraw/Gui/TaskCenterLine.ui | 7 +-- src/Mod/TechDraw/Gui/TaskLineDecor.cpp | 59 +++++++++++++++++-------- src/Mod/TechDraw/Gui/TaskLineDecor.h | 7 ++- src/Mod/TechDraw/Gui/TaskLineDecor.ui | 7 +-- 5 files changed, 60 insertions(+), 44 deletions(-) diff --git a/src/Mod/TechDraw/Gui/TaskCenterLine.cpp b/src/Mod/TechDraw/Gui/TaskCenterLine.cpp index 833eedb5b5..1c8fff23a0 100644 --- a/src/Mod/TechDraw/Gui/TaskCenterLine.cpp +++ b/src/Mod/TechDraw/Gui/TaskCenterLine.cpp @@ -175,7 +175,7 @@ void TaskCenterLine::setUiPrimary() ui->cpLineColor->setColor(getCenterColor()); ui->dsbWeight->setValue(getCenterWidth()); - ui->cboxStyle->setCurrentIndex(getCenterStyle()); + ui->cboxStyle->setCurrentIndex(getCenterStyle() - 1); Base::Quantity qVal; qVal.setUnit(Base::Unit::Length); qVal.setValue(getExtendBy()); @@ -197,7 +197,7 @@ void TaskCenterLine::setUiEdit() ui->cpLineColor->setColor(m_cl->m_format.m_color.asValue()); ui->dsbWeight->setValue(m_cl->m_format.m_weight); - ui->cboxStyle->setCurrentIndex(m_cl->m_format.m_style); + ui->cboxStyle->setCurrentIndex(m_cl->m_format.m_style - 1); int precision = Base::UnitsApi::getDecimals(); ui->dsbRotate->setDecimals(precision); @@ -271,7 +271,7 @@ void TaskCenterLine::createCenterLine(void) ac.setValue(ui->cpLineColor->color()); cl->m_format.m_color = ac; cl->m_format.m_weight = ui->dsbWeight->value(); - cl->m_format.m_style = ui->cboxStyle->currentIndex(); + cl->m_format.m_style = ui->cboxStyle->currentIndex() + 1; //Qt Styles start at 0:NoLine cl->m_format.m_visible = true; if (m_type == 0) { @@ -305,7 +305,7 @@ void TaskCenterLine::updateCenterLine(void) Gui::Command::openCommand("Edit CenterLine"); m_cl->m_format.m_color.setValue(ui->cpLineColor->color() ); m_cl->m_format.m_weight = ui->dsbWeight->value(); - m_cl->m_format.m_style = ui->cboxStyle->currentIndex(); + m_cl->m_format.m_style = ui->cboxStyle->currentIndex() + 1; m_cl->m_format.m_visible = true; if (ui->rbVertical->isChecked()) { @@ -316,21 +316,14 @@ void TaskCenterLine::updateCenterLine(void) m_mode =2; } m_cl->m_mode = m_mode; -// if (ui->rbVertical->isChecked()) { -// m_cl->m_mode = 0; -// } else if (ui->rbHorizontal->isChecked()) { -// m_cl->m_mode = 1; -// } else if (ui->rbAligned->isChecked()) { -// m_cl->m_mode = 2; -// } m_cl->m_rotate = ui->dsbRotate->value(); m_cl->m_vShift = ui->qsbVertShift->rawValue(); m_cl->m_hShift = ui->qsbHorizShift->rawValue(); m_cl->m_extendBy = ui->qsbExtend->rawValue(); - m_partFeat->replaceCenterLine(m_clIdx, m_cl); - m_partFeat->requestPaint(); m_cl->m_type = m_type; m_cl->m_flip2Line = m_flipped; + m_partFeat->replaceCenterLine(m_clIdx, m_cl); + m_partFeat->requestPaint(); Gui::Command::updateActive(); Gui::Command::commitCommand(); @@ -358,6 +351,11 @@ double TaskCenterLine::getCenterWidth() double width = lg->getWeight("Graphic"); delete lg; + Gui::ViewProvider* vp = QGIView::getViewProvider(m_partFeat); + auto partVP = dynamic_cast(vp); + if ( vp != nullptr ) { + width = partVP->IsoWidth.getValue(); + } return width; } diff --git a/src/Mod/TechDraw/Gui/TaskCenterLine.ui b/src/Mod/TechDraw/Gui/TaskCenterLine.ui index 26ff9876e7..577737563f 100644 --- a/src/Mod/TechDraw/Gui/TaskCenterLine.ui +++ b/src/Mod/TechDraw/Gui/TaskCenterLine.ui @@ -252,13 +252,8 @@ - 1 + 0 - - - NoLine - - Solid diff --git a/src/Mod/TechDraw/Gui/TaskLineDecor.cpp b/src/Mod/TechDraw/Gui/TaskLineDecor.cpp index f45ee6476e..49bcb5137c 100644 --- a/src/Mod/TechDraw/Gui/TaskLineDecor.cpp +++ b/src/Mod/TechDraw/Gui/TaskLineDecor.cpp @@ -51,6 +51,8 @@ #include #include +#include "QGIView.h" +#include "ViewProviderViewPart.h" #include "TaskLineDecor.h" using namespace Gui; @@ -61,7 +63,8 @@ TaskLineDecor::TaskLineDecor(TechDraw::DrawViewPart* partFeat, std::vector edgeNames) : ui(new Ui_TaskLineDecor), m_partFeat(partFeat), - m_edges(edgeNames) + m_edges(edgeNames), + m_apply(true) { getDefaults(); ui->setupUi(this); @@ -95,7 +98,7 @@ void TaskLineDecor::initUi() } ui->le_Lines->setText(Base::Tools::fromStdString(temp)); - ui->cb_Style->setCurrentIndex(m_style); + ui->cb_Style->setCurrentIndex(m_style - 1); //combobox does not have 0:NoLine choice ui->cc_Color->setColor(m_color.asValue()); ui->dsb_Weight->setValue(m_weight); ui->cb_Visible->setCurrentIndex(m_visible); @@ -103,6 +106,7 @@ void TaskLineDecor::initUi() void TaskLineDecor::getDefaults(void) { +// Base::Console().Message("TLD::getDefaults()\n"); m_style = LineFormat::getDefEdgeStyle(); m_color = LineFormat::getDefEdgeColor(); m_weight = LineFormat::getDefEdgeWidth(); @@ -128,13 +132,22 @@ void TaskLineDecor::getDefaults(void) m_visible = cl->m_format.m_visible; } } else { - TechDraw::GeomFormat* gf = m_partFeat->getGeomFormatByGeom(num); - if (gf != nullptr) { - m_style = gf->m_format.m_style; - m_color = gf->m_format.m_color; - m_weight = gf->m_format.m_weight; - m_visible = gf->m_format.m_visible; + TechDraw::GeomFormat* gf = m_partFeat->getGeomFormatByGeom(num); + if (gf != nullptr) { + m_style = gf->m_format.m_style; + m_color = gf->m_format.m_color; + m_weight = gf->m_format.m_weight; + m_visible = gf->m_format.m_visible; + } else { + Gui::ViewProvider* vp = QGIView::getViewProvider(m_partFeat); + auto partVP = dynamic_cast(vp); + if ( vp != nullptr ) { + m_weight = partVP->LineWidth.getValue(); + m_style = Qt::SolidLine; // = 1 + m_color = LineFormat::getDefEdgeColor(); + m_visible = 1; } + } } } } @@ -142,7 +155,7 @@ void TaskLineDecor::getDefaults(void) void TaskLineDecor::onStyleChanged(void) { - m_style = ui->cb_Style->currentIndex(); + m_style = ui->cb_Style->currentIndex() + 1; //livePreview(); } @@ -214,7 +227,9 @@ bool TaskLineDecor::accept() Gui::Document* doc = Gui::Application::Instance->getDocument(m_partFeat->getDocument()); if (!doc) return false; - applyDecorations(); + if (apply()) { + applyDecorations(); + } m_partFeat->requestPaint(); @@ -241,9 +256,11 @@ void TaskLineDecor::changeEvent(QEvent *e) } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -TaskRestoreLines::TaskRestoreLines(TechDraw::DrawViewPart* partFeat) : +TaskRestoreLines::TaskRestoreLines(TechDraw::DrawViewPart* partFeat, + TaskLineDecor* parent) : ui(new Ui_TaskRestoreLines), - m_partFeat(partFeat) + m_partFeat(partFeat), + m_parent(parent) { ui->setupUi(this); @@ -361,6 +378,7 @@ void TaskRestoreLines::restoreInvisibleGeoms(void) } } m_partFeat->GeomFormats.setValues(geoms); + m_parent->apply(false); //don't undo the work we just did } void TaskRestoreLines::restoreInvisibleCosmetics(void) @@ -372,6 +390,7 @@ void TaskRestoreLines::restoreInvisibleCosmetics(void) } } m_partFeat->CosmeticEdges.setValues(cosmos); + m_parent->apply(false); //don't undo the work we just did } void TaskRestoreLines::restoreInvisibleCenters(void) @@ -383,6 +402,7 @@ void TaskRestoreLines::restoreInvisibleCenters(void) } } m_partFeat->CenterLines.setValues(centers); + m_parent->apply(false); //don't undo the work we just did } @@ -418,12 +438,15 @@ TaskDlgLineDecor::TaskDlgLineDecor(TechDraw::DrawViewPart* partFeat, if (edgeNames.empty()) { taskbox->hideGroupBox(); } - - restore = new TaskRestoreLines(partFeat); - restoreBox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-linedecor"), - tr("Restore Invisible Lines"), true, 0); - restoreBox->groupLayout()->addWidget(restore); - Content.push_back(restoreBox); + + TaskLineDecor* parent = dynamic_cast(widget); + if (parent != nullptr) { + restore = new TaskRestoreLines(partFeat, parent); + restoreBox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-linedecor"), + tr("Restore Invisible Lines"), true, 0); + restoreBox->groupLayout()->addWidget(restore); + Content.push_back(restoreBox); + } } TaskDlgLineDecor::~TaskDlgLineDecor() diff --git a/src/Mod/TechDraw/Gui/TaskLineDecor.h b/src/Mod/TechDraw/Gui/TaskLineDecor.h index ca644d3e31..30d612a053 100644 --- a/src/Mod/TechDraw/Gui/TaskLineDecor.h +++ b/src/Mod/TechDraw/Gui/TaskLineDecor.h @@ -54,6 +54,8 @@ public: public: virtual bool accept(); virtual bool reject(); + bool apply(void) { return m_apply; } + void apply(bool b) { m_apply = b; } protected Q_SLOTS: void onStyleChanged(void); @@ -75,6 +77,7 @@ private: App::Color m_color; double m_weight; bool m_visible; + bool m_apply; }; class TaskRestoreLines : public QWidget @@ -82,7 +85,8 @@ class TaskRestoreLines : public QWidget Q_OBJECT public: - TaskRestoreLines(TechDraw::DrawViewPart* partFeat); + TaskRestoreLines(TechDraw::DrawViewPart* partFeat, + TechDrawGui::TaskLineDecor* parent); ~TaskRestoreLines(); public: @@ -110,6 +114,7 @@ protected: private: Ui_TaskRestoreLines* ui; TechDraw::DrawViewPart* m_partFeat; + TaskLineDecor* m_parent; }; diff --git a/src/Mod/TechDraw/Gui/TaskLineDecor.ui b/src/Mod/TechDraw/Gui/TaskLineDecor.ui index 0911d0552b..f6f46bad42 100644 --- a/src/Mod/TechDraw/Gui/TaskLineDecor.ui +++ b/src/Mod/TechDraw/Gui/TaskLineDecor.ui @@ -188,13 +188,8 @@ - 1 + 0 - - - NoLine - - Solid