diff --git a/src/Mod/TechDraw/App/DrawPage.h b/src/Mod/TechDraw/App/DrawPage.h index 07933dca70..63811b455a 100644 --- a/src/Mod/TechDraw/App/DrawPage.h +++ b/src/Mod/TechDraw/App/DrawPage.h @@ -109,6 +109,11 @@ public: void translateLabel(std::string context, std::string baseName, std::string uniqueName); + enum class PageProjectionConvention { + FirstAngle = 0, + ThirdAngle + }; + protected: void onBeforeChange(const App::Property* prop) override; diff --git a/src/Mod/TechDraw/App/DrawProjGroup.cpp b/src/Mod/TechDraw/App/DrawProjGroup.cpp index fb21dbe93c..c974fc3f3b 100644 --- a/src/Mod/TechDraw/App/DrawProjGroup.cpp +++ b/src/Mod/TechDraw/App/DrawProjGroup.cpp @@ -49,6 +49,8 @@ using namespace TechDraw; +// this needs to be kept in the same sequence as the enum in the h file and with the QComboBox +// in TaskProjGroup.ui. const char* DrawProjGroup::ProjectionTypeEnums[] = {"First angle", "Third angle", "Default",//Use Page setting nullptr}; diff --git a/src/Mod/TechDraw/App/DrawProjGroup.h b/src/Mod/TechDraw/App/DrawProjGroup.h index b4bbf8e95b..9589493699 100644 --- a/src/Mod/TechDraw/App/DrawProjGroup.h +++ b/src/Mod/TechDraw/App/DrawProjGroup.h @@ -23,7 +23,6 @@ #ifndef TECHDRAW_FEATUREVIEWGROUP_H_ #define TECHDRAW_FEATUREVIEWGROUP_H_ -#include #include #include @@ -74,6 +73,14 @@ public: App::PropertyLink Anchor; /// Anchor Element to align views to + // this needs to be kept in the same sequence as the literals in the cpp file and with the QComboBox + // in TaskProjGroup.ui. + enum class ViewProjectionConvention { + FirstAngle = 0, + ThirdAngle, + Page + }; + double autoScale() const override; double autoScale(double w, double h) const override; QRectF getRect() const override; //always scaled diff --git a/src/Mod/TechDraw/App/Preferences.cpp b/src/Mod/TechDraw/App/Preferences.cpp index cc3f9c8f92..7b87739711 100644 --- a/src/Mod/TechDraw/App/Preferences.cpp +++ b/src/Mod/TechDraw/App/Preferences.cpp @@ -32,7 +32,7 @@ #include #include "Preferences.h" -#include "DrawBrokenView.h" +#include "DrawProjGroup.h" #include "LineGenerator.h" //getters for parameters used in multiple places. @@ -151,7 +151,9 @@ bool Preferences::useGlobalDecimals() int Preferences::projectionAngle() { - return getPreferenceGroup("General")->GetInt("ProjectionAngle", 0); //First angle + int defaultConvention = (int)DrawProjGroup::ViewProjectionConvention::FirstAngle; + return getPreferenceGroup("General")->GetInt("ProjectionAngle", + defaultConvention); } bool Preferences::groupAutoDistribute() diff --git a/src/Mod/TechDraw/Gui/TaskProjGroup.cpp b/src/Mod/TechDraw/Gui/TaskProjGroup.cpp index e4bc1018bf..fa84645162 100644 --- a/src/Mod/TechDraw/Gui/TaskProjGroup.cpp +++ b/src/Mod/TechDraw/Gui/TaskProjGroup.cpp @@ -109,8 +109,8 @@ void TaskProjGroup::connectWidgets() connect(ui->sbScaleDen, qOverload(&QSpinBox::valueChanged), this, &TaskProjGroup::scaleManuallyChanged); // Slot for Projection Type (layout) - connect(ui->projection, qOverload(&QComboBox::currentIndexChanged), this, [this](int index) { - projectionTypeChanged(ui->projection->itemText(index)); + connect(ui->projection, qOverload(&QComboBox::currentIndexChanged), this, [this]() { + projectionTypeChanged(ui->projection->currentIndex()); }); // Spacing @@ -211,7 +211,7 @@ void TaskProjGroup::saveGroupState() if (multiView) { m_saveSource = multiView->Source.getValues(); - m_saveProjType = multiView->ProjectionType.getValueAsString(); + m_saveProjType = multiView->ProjectionType.getValue(); m_saveAutoDistribute = multiView->AutoDistribute.getValue(); m_saveSpacingX = multiView->spacingX.getValue(); m_saveSpacingY = multiView->spacingY.getValue(); @@ -238,7 +238,7 @@ void TaskProjGroup::restoreGroupState() view->Scale.setValue(m_saveScale); if (multiView) { - multiView->ProjectionType.setValue(m_saveProjType.c_str()); + multiView->ProjectionType.setValue(m_saveProjType); multiView->AutoDistribute.setValue(m_saveAutoDistribute); multiView->spacingX.setValue(m_saveSpacingX); multiView->spacingY.setValue(m_saveSpacingY); @@ -484,20 +484,13 @@ void TaskProjGroup::rotateButtonClicked() } } -//void TaskProjGroup::projectionTypeChanged(int index) -void TaskProjGroup::projectionTypeChanged(QString qText) +void TaskProjGroup::projectionTypeChanged(int index) { if(blockUpdate || !multiView) { return; } - if (qText == QStringLiteral("Page")) { - multiView->ProjectionType.setValue("Default"); - } - else { - std::string text = qText.toStdString(); - multiView->ProjectionType.setValue(text.c_str()); - } + multiView->ProjectionType.setValue((long)index); // Update checkboxes so checked state matches the drawing blockCheckboxes = true; @@ -687,18 +680,19 @@ bool TaskProjGroup::useThirdAngle() return false; } - bool thirdAngle = (bool) Preferences::projectionAngle(); - if (!multiView) { - return thirdAngle; + if (!multiView) { + return Preferences::projectionAngle(); } - if (multiView->usedProjectionType().isValue("Third angle")) { - thirdAngle = true; - } else if (multiView->usedProjectionType().isValue("Default") && - page->ProjectionType.isValue("Third angle")) { - thirdAngle = true; + if (multiView->ProjectionType.getValue() == (long)DrawProjGroup::ViewProjectionConvention::ThirdAngle) { + return true; } - return thirdAngle; + + if (multiView->ProjectionType.getValue() == (long)DrawProjGroup::ViewProjectionConvention::Page && + page->ProjectionType.getValue() == (long)DrawPage::PageProjectionConvention::ThirdAngle) { + return true; + } + return false; } void TaskProjGroup::setupViewCheckboxes(bool addConnections) diff --git a/src/Mod/TechDraw/Gui/TaskProjGroup.h b/src/Mod/TechDraw/Gui/TaskProjGroup.h index 2c40f4e952..dd793b0abc 100644 --- a/src/Mod/TechDraw/Gui/TaskProjGroup.h +++ b/src/Mod/TechDraw/Gui/TaskProjGroup.h @@ -99,7 +99,7 @@ protected Q_SLOTS: void customDirectionClicked(); - void projectionTypeChanged(QString qText); + void projectionTypeChanged(int index); void scaleTypeChanged(int index); void AutoDistributeClicked(bool clicked); /// Updates item spacing @@ -127,7 +127,7 @@ private: QPushButton* m_btnCancel{nullptr}; std::vector m_saveSource; - std::string m_saveProjType; + long m_saveProjType; std::string m_saveScaleType; double m_saveScale{1}; bool m_saveAutoDistribute{false};