diff --git a/src/Mod/TechDraw/App/DrawProjGroupItem.cpp b/src/Mod/TechDraw/App/DrawProjGroupItem.cpp index 17755f4ea8..d49cbedaa4 100644 --- a/src/Mod/TechDraw/App/DrawProjGroupItem.cpp +++ b/src/Mod/TechDraw/App/DrawProjGroupItem.cpp @@ -329,6 +329,16 @@ double DrawProjGroupItem::getScale(void) const return 1.0; } +int DrawProjGroupItem::getScaleType() const +{ + auto pgroup = getPGroup(); + if (pgroup) { + return pgroup->getScaleType(); + } + + return ScaleType.getValue(); +} + void DrawProjGroupItem::unsetupObject() { if (!getPGroup()) { diff --git a/src/Mod/TechDraw/App/DrawProjGroupItem.h b/src/Mod/TechDraw/App/DrawProjGroupItem.h index 7e1a93fe4d..1a15f68241 100644 --- a/src/Mod/TechDraw/App/DrawProjGroupItem.h +++ b/src/Mod/TechDraw/App/DrawProjGroupItem.h @@ -86,6 +86,7 @@ public: const bool flip=true) const override; double getScale() const override; + int getScaleType() const override; void autoPosition(); bool isAnchor() const; diff --git a/src/Mod/TechDraw/App/DrawView.h b/src/Mod/TechDraw/App/DrawView.h index 4082c1fcb3..7bd6adce88 100644 --- a/src/Mod/TechDraw/App/DrawView.h +++ b/src/Mod/TechDraw/App/DrawView.h @@ -100,6 +100,7 @@ public: void showProgressMessage(std::string featureName, std::string text); virtual double getScale(void) const; + virtual int getScaleType() const { return ScaleType.getValue(); }; void checkScale(void); virtual void handleXYLock(void); diff --git a/src/Mod/TechDraw/Gui/TaskSectionView.cpp b/src/Mod/TechDraw/Gui/TaskSectionView.cpp index 059145bacc..3eaa4a937d 100644 --- a/src/Mod/TechDraw/Gui/TaskSectionView.cpp +++ b/src/Mod/TechDraw/Gui/TaskSectionView.cpp @@ -126,11 +126,15 @@ void TaskSectionView::setUiPrimary() // Base::Console().Message("TSV::setUiPrimary()\n"); setWindowTitle(QObject::tr("Create Section View")); + // note DPGI will have a custom scale type and scale = 1.0. In this case, + // we need the values from the parent DPG! ui->sbScale->setValue(m_base->getScale()); - ui->cmbScaleType->setCurrentIndex(m_base->ScaleType.getValue()); + + ui->cmbScaleType->setCurrentIndex(m_base->getScaleType()); //Allow or prevent scale changing initially - if (m_base->ScaleType.isValue("Custom")) { + if (m_base->getScaleType() == 2) { + // custom scale type ui->sbScale->setEnabled(true); } else { @@ -160,7 +164,7 @@ void TaskSectionView::setUiEdit() ui->leSymbol->setText(qTemp); ui->sbScale->setValue(m_section->getScale()); - ui->cmbScaleType->setCurrentIndex(m_section->ScaleType.getValue()); + ui->cmbScaleType->setCurrentIndex(m_section->getScaleType()); //Allow or prevent scale changing initially if (m_section->ScaleType.isValue("Custom")) { ui->sbScale->setEnabled(true); @@ -240,7 +244,7 @@ void TaskSectionView::saveSectionState() if (m_section) { m_saveSymbol = m_section->SectionSymbol.getValue(); m_saveScale = m_section->getScale(); - m_saveScaleType = m_section->ScaleType.getValue(); + m_saveScaleType = m_section->getScaleType(); m_saveNormal = m_section->SectionNormal.getValue(); m_normal = m_saveNormal; m_saveDirection = m_section->Direction.getValue(); @@ -493,7 +497,7 @@ void TaskSectionView::applyAligned() TechDraw::DrawViewSection* TaskSectionView::createSectionView(void) { - // Base::Console().Message("TSV::createSectionView()\n"); + // Base::Console().Message("TSV::createSectionView()\n"); if (!isBaseValid()) { failNoObject(); return nullptr; @@ -535,17 +539,8 @@ TechDraw::DrawViewSection* TaskSectionView::createSectionView(void) m_sectionName.c_str(), ui->sbOrgX->value().getValue(), ui->sbOrgY->value().getValue(), ui->sbOrgZ->value().getValue()); - if (m_scaleEdited) { - // user has changed the scale - Command::doCommand(Command::Doc, "App.ActiveDocument.%s.Scale = %0.7f", + Command::doCommand(Command::Doc, "App.ActiveDocument.%s.Scale = %0.7f", m_sectionName.c_str(), ui->sbScale->value()); - } else { - // scale is untouched, use value from base view - Command::doCommand(Command::Doc, - "App.ActiveDocument.%s.Scale = App.ActiveDocument.%s.Scale", - m_sectionName.c_str(), - baseName.c_str()); - } int scaleType = ui->cmbScaleType->currentIndex(); Command::doCommand(Command::Doc, "App.ActiveDocument.%s.ScaleType = %d", @@ -582,7 +577,7 @@ TechDraw::DrawViewSection* TaskSectionView::createSectionView(void) void TaskSectionView::updateSectionView() { -// Base::Console().Message("TSV::updateSectionView() - m_sectionName: %s\n", m_sectionName.c_str()); + // Base::Console().Message("TSV::updateSectionView() - m_sectionName: %s\n", m_sectionName.c_str()); if (!isSectionValid()) { failNoObject(); return; @@ -611,17 +606,8 @@ void TaskSectionView::updateSectionView() Command::doCommand(Command::Doc, "App.activeDocument().%s.translateLabel('DrawViewSection', 'Section', '%s')", m_sectionName.c_str(), makeSectionLabel(qTemp).c_str()); - if (m_scaleEdited) { - // user has changed the scale - Command::doCommand(Command::Doc, "App.ActiveDocument.%s.Scale = %0.7f", + Command::doCommand(Command::Doc, "App.ActiveDocument.%s.Scale = %0.7f", m_sectionName.c_str(), ui->sbScale->value()); - } else { - // scale is untouched, use value from base view - Command::doCommand(Command::Doc, - "App.ActiveDocument.%s.Scale = App.ActiveDocument.%s.Scale", - m_sectionName.c_str(), - baseName.c_str()); - } int scaleType = ui->cmbScaleType->currentIndex(); Command::doCommand(Command::Doc, "App.ActiveDocument.%s.ScaleType = %d",