From eb6a8e5339ea6902925bed5dbba54ca71d798d0f Mon Sep 17 00:00:00 2001 From: donovaly Date: Sun, 21 Jun 2020 05:18:47 +0200 Subject: [PATCH] [TD] add spacing to ProjGroup dialog Add the setting to auto-distribute projections to the dialog --- src/Mod/TechDraw/Gui/TaskProjGroup.cpp | 47 +- src/Mod/TechDraw/Gui/TaskProjGroup.h | 6 + src/Mod/TechDraw/Gui/TaskProjGroup.ui | 1426 +++++++++++++----------- 3 files changed, 824 insertions(+), 655 deletions(-) diff --git a/src/Mod/TechDraw/Gui/TaskProjGroup.cpp b/src/Mod/TechDraw/Gui/TaskProjGroup.cpp index 7afd578b0c..bcc9cebc9a 100644 --- a/src/Mod/TechDraw/Gui/TaskProjGroup.cpp +++ b/src/Mod/TechDraw/Gui/TaskProjGroup.cpp @@ -45,16 +45,16 @@ #include #include +#include +#include #include #include #include -#include -#include - +#include "ViewProviderPage.h" #include "ViewProviderProjGroup.h" #include "ViewProviderProjGroupItem.h" -#include "ViewProviderPage.h" + #include "TaskProjGroup.h" #include @@ -86,6 +86,13 @@ TaskProjGroup::TaskProjGroup(TechDraw::DrawProjGroup* featView, bool mode) : ui->sbScaleDen->setEnabled(false); } + ui->cbAutoDistribute->setChecked(multiView->AutoDistribute.getValue()); + // disable if no AutoDistribute + ui->sbXSpacing->setEnabled(multiView->AutoDistribute.getValue()); + ui->sbYSpacing->setEnabled(multiView->AutoDistribute.getValue()); + ui->sbXSpacing->setValue(multiView->spacingX.getValue()); + ui->sbYSpacing->setValue(multiView->spacingY.getValue()); + // Initially toggle view checkboxes if needed setupViewCheckboxes(true); @@ -112,6 +119,13 @@ TaskProjGroup::TaskProjGroup(TechDraw::DrawProjGroup* featView, bool mode) : // connect(ui->projection, SIGNAL(currentIndexChanged(int)), this, SLOT(projectionTypeChanged(int))); connect(ui->projection, SIGNAL(currentIndexChanged(QString)), this, SLOT(projectionTypeChanged(QString))); + // Spacing + connect(ui->cbAutoDistribute, SIGNAL(clicked(bool)), this, SLOT(AutoDistributeClicked(bool))); + connect(ui->sbXSpacing, SIGNAL(valueChanged(double)), this, SLOT(spacingChanged(void))); + connect(ui->sbYSpacing, SIGNAL(valueChanged(double)), this, SLOT(spacingChanged(void))); + ui->sbXSpacing->setUnit(Base::Unit::Length); + ui->sbYSpacing->setUnit(Base::Unit::Length); + m_page = multiView->findParentPage(); Gui::Document* activeGui = Gui::Application::Instance->getDocument(m_page->getDocument()); Gui::ViewProvider* vp = activeGui->getViewProvider(m_page); @@ -135,6 +149,9 @@ void TaskProjGroup::saveGroupState() m_saveProjType = multiView->ProjectionType.getValueAsString(); m_saveScaleType = multiView->ScaleType.getValueAsString(); m_saveScale = multiView->Scale.getValue(); + m_saveAutoDistribute = multiView->AutoDistribute.getValue(); + m_saveSpacingX = multiView->spacingX.getValue(); + m_saveSpacingY = multiView->spacingY.getValue(); DrawProjGroupItem* anchor = multiView->getAnchor(); m_saveDirection = anchor->Direction.getValue(); } @@ -154,6 +171,9 @@ void TaskProjGroup::restoreGroupState() multiView->ProjectionType.setValue(m_saveProjType.c_str()); multiView->ScaleType.setValue(m_saveScaleType.c_str()); multiView->Scale.setValue(m_saveScale); + multiView->AutoDistribute.setValue(m_saveAutoDistribute); + multiView->spacingX.setValue(m_saveSpacingX); + multiView->spacingY.setValue(m_saveSpacingY); multiView->purgeProjections(); for(auto & sv : m_saveViewNames) { if (sv != "Front") { @@ -269,6 +289,25 @@ void TaskProjGroup::scaleTypeChanged(int index) } } +void TaskProjGroup::AutoDistributeClicked(bool b) +{ + if (blockUpdate) { + return; + } + multiView->AutoDistribute.setValue(b); + multiView->recomputeFeature(); +} + +void TaskProjGroup::spacingChanged(void) +{ + if (blockUpdate) { + return; + } + multiView->spacingX.setValue(ui->sbXSpacing->value().getValue()); + multiView->spacingY.setValue(ui->sbYSpacing->value().getValue()); + multiView->recomputeFeature(); +} + std::pair TaskProjGroup::nearestFraction(const double val, const long int maxDenom) const { /* diff --git a/src/Mod/TechDraw/Gui/TaskProjGroup.h b/src/Mod/TechDraw/Gui/TaskProjGroup.h index c03e80648b..0f50bfdd74 100644 --- a/src/Mod/TechDraw/Gui/TaskProjGroup.h +++ b/src/Mod/TechDraw/Gui/TaskProjGroup.h @@ -85,6 +85,9 @@ protected Q_SLOTS: /* void projectionTypeChanged(int index);*/ void projectionTypeChanged(QString qText); void scaleTypeChanged(int index); + void AutoDistributeClicked(bool b); + /// Updates item spacing + void spacingChanged(void); void scaleManuallyChanged(int i); protected: @@ -122,6 +125,9 @@ private: std::string m_saveProjType; std::string m_saveScaleType; double m_saveScale; + bool m_saveAutoDistribute; + double m_saveSpacingX; + double m_saveSpacingY; Base::Vector3d m_saveDirection; std::vector m_saveViewNames; }; diff --git a/src/Mod/TechDraw/Gui/TaskProjGroup.ui b/src/Mod/TechDraw/Gui/TaskProjGroup.ui index 3be133997f..3f4f21e265 100644 --- a/src/Mod/TechDraw/Gui/TaskProjGroup.ui +++ b/src/Mod/TechDraw/Gui/TaskProjGroup.ui @@ -6,8 +6,8 @@ 0 0 - 371 - 511 + 250 + 477 @@ -25,664 +25,788 @@ Projection Group - + - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - QLayout::SetDefaultConstraint + + + + + Projection + + + + + + + First or Third Angle + + + + First Angle - - - - - - Projection - - - - - - - First or Third Angle - - - - First Angle - - - - - Third Angle - - - - - Page - - - - - - - - - - - - Scale - - - - - - - Scale Page/Auto/Custom - - - - Page - - - - - Automatic - - - - - Custom - - - - - - - - - - - - Custom Scale - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Scale Numerator - - - 1 - - - 1 - - - - - - - : - - - - - - - Scale Denominator - - - 1 - - - 999 - - - 1 - - - - - - - - - Qt::Horizontal - - - - - - - - - - 0 - 0 - - - - Adjust Primary Direction - - - true - - - Qt::AlignCenter - - - 0 - - - - - - - - - - - false - - - - 11 - 50 - false - false - - - - Qt::NoFocus - - - Current primary view direction - - - Qt::AlignCenter - - - true - - - - - - - Rotate right - - - - - - - :/icons/arrow-right.svg - - - - - 24 - 24 - - - - - - - - - 0 - 0 - - - - Rotate up - - - - - - - :/icons/arrow-up.svg - - - - - 24 - 24 - - - - - - - - Rotate left - - - - - - - :/icons/arrow-left.svg - - - - - 24 - 24 - - - - - - - - Rotate down - - - - - - - :/icons/arrow-down.svg - - - - - 24 - 24 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Horizontal - - - - - - - - - Secondary Projections - - - Qt::AlignCenter - - - - - - - - - - - true - - - Bottom - - - QCheckBox::indicator { -width: 24px; -height: 24px; -} - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - false - - - Primary - - - QCheckBox::indicator { -width: 24px; -height: 24px; -} - - - - - - - true - - - - - - - Right - - - QCheckBox::indicator { -width: 24px; -height: 24px; -} - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Left - - - QCheckBox::indicator { -width: 24px; -height: 24px; -} - - - - - - - - - - - LeftFrontBottom - - - QCheckBox::indicator { -width: 24px; -height: 24px; -} - - - - - - - - - - - Top - - - QCheckBox::indicator { -width: 24px; -height: 24px; -} - - - - - - - - - - - RightFrontBottom - - - QCheckBox::indicator { -width: 24px; -height: 24px; -} - - - - - - - - - - - RightFrontTop - - - QCheckBox::indicator { -width: 24px; -height: 24px; -} - - - - - - - - - - - Rear - - - QCheckBox::indicator { -width: 24px; -height: 24px; -} - - - - - - - - - - - LeftFrontTop - - - QCheckBox::indicator { -width: 24px; -height: 24px; -} - - - - - - - - 24 - 24 - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Spin CW - - - - - - - :/icons/arrow-cw.svg - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Spin CCW - - - - - - - :/icons/arrow-ccw.svg - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Qt::Vertical + + + + Third Angle - - - 20 - 40 - + + + + Page - - - + + + + + + + + + + + Scale + + + + + + + Scale Page/Auto/Custom + + + + Page + + + + + Automatic + + + + + Custom + + + + + + + + + + + + Custom Scale + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Scale Numerator + + + 1 + + + 1 + + + + + + + : + + + + + + + Scale Denominator + + + 1 + + + 999 + + + 1 + + + + + + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + Adjust Primary Direction + + + true + + + Qt::AlignCenter + + + 0 + + + + + + + + + + + false + + + + 11 + 50 + false + false + + + + Qt::NoFocus + + + Current primary view direction + + + Qt::AlignCenter + + + true + + + + + + + Rotate right + + + + + + + :/icons/arrow-right.svg + + + + + 24 + 24 + + + + + + + + + 0 + 0 + + + + Rotate up + + + + + + + :/icons/arrow-up.svg + + + + + 24 + 24 + + + + + + + + Rotate left + + + + + + + :/icons/arrow-left.svg + + + + + 24 + 24 + + + + + + + + Rotate down + + + + + + + :/icons/arrow-down.svg + + + + + 24 + 24 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Horizontal + + + + + + + + + Secondary Projections + + + Qt::AlignCenter + + + + + + + + + + + true + + + Bottom + + + QCheckBox::indicator { +width: 24px; +height: 24px; +} + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + false + + + Primary + + + QCheckBox::indicator { +width: 24px; +height: 24px; +} + + + + + + + true + + + + + + + Right + + + QCheckBox::indicator { +width: 24px; +height: 24px; +} + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Left + + + QCheckBox::indicator { +width: 24px; +height: 24px; +} + + + + + + + + + + + LeftFrontBottom + + + QCheckBox::indicator { +width: 24px; +height: 24px; +} + + + + + + + + + + + Top + + + QCheckBox::indicator { +width: 24px; +height: 24px; +} + + + + + + + + + + + RightFrontBottom + + + QCheckBox::indicator { +width: 24px; +height: 24px; +} + + + + + + + + + + + RightFrontTop + + + QCheckBox::indicator { +width: 24px; +height: 24px; +} + + + + + + + + + + + Rear + + + QCheckBox::indicator { +width: 24px; +height: 24px; +} + + + + + + + + + + + LeftFrontTop + + + QCheckBox::indicator { +width: 24px; +height: 24px; +} + + + + + + + + 24 + 24 + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Spin CW + + + + + + + :/icons/arrow-cw.svg + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Spin CCW + + + + + + + :/icons/arrow-ccw.svg + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Distributes projections automatically +using the given X/Y Spacing + + + Auto Distribute + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 150 + 22 + + + + Horizontal space between center of projections + + + false + + + + + + 0.000000000000000 + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + X Spacing + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Y Spacing + + + + + + + + 0 + 0 + + + + + 150 + 22 + + + + Vertical space between center of projections + + + false + + + + + + 0.000000000000000 + + + + + + + + Gui::QuantitySpinBox + QWidget +
Gui/QuantitySpinBox.h
+
+
- + + + cbAutoDistribute + clicked(bool) + sbXSpacing + setEnabled(bool) + + + 60 + 407 + + + 164 + 431 + + + + + cbAutoDistribute + clicked(bool) + sbYSpacing + setEnabled(bool) + + + 60 + 407 + + + 164 + 459 + + + +