diff --git a/src/Mod/TechDraw/Gui/TaskComplexSection.cpp b/src/Mod/TechDraw/Gui/TaskComplexSection.cpp index 9b997a18f0..df8d8fc3fa 100644 --- a/src/Mod/TechDraw/Gui/TaskComplexSection.cpp +++ b/src/Mod/TechDraw/Gui/TaskComplexSection.cpp @@ -74,7 +74,8 @@ TaskComplexSection::TaskComplexSection(TechDraw::DrawPage* page, TechDraw::DrawV m_applyDeferred(0), m_angle(0.0), m_directionIsSet(false), - m_modelIsDirty(false) + m_modelIsDirty(false), + m_scaleEdited(false) { m_sectionName = std::string(); if (m_page) { @@ -105,7 +106,8 @@ TaskComplexSection::TaskComplexSection(TechDraw::DrawComplexSection* complexSect m_applyDeferred(0), m_angle(0.0), m_directionIsSet(true), - m_modelIsDirty(false) + m_modelIsDirty(false), + m_scaleEdited(false) { m_sectionName = m_section->getNameInDocument(); m_doc = m_section->getDocument(); @@ -369,6 +371,7 @@ void TaskComplexSection::onIdentifierChanged() void TaskComplexSection::onScaleChanged() { + m_scaleEdited = true; checkAll(false); apply(); } @@ -577,6 +580,20 @@ void TaskComplexSection::createComplexSection() Command::doCommand(Command::Doc, "App.ActiveDocument.%s.Scale = %0.6f", m_sectionName.c_str(), ui->sbScale->value()); + + std::string baseName = m_baseView->getNameInDocument(); + if (m_scaleEdited) { + // user has changed the scale + 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", m_sectionName.c_str(), scaleType); @@ -654,8 +671,20 @@ void TaskComplexSection::updateComplexSection() Command::doCommand(Command::Doc, "App.activeDocument().%s.translateLabel('DrawViewSection', 'Section', '%s')", m_sectionName.c_str(), makeSectionLabel(qTemp).c_str()); - Command::doCommand(Command::Doc, "App.ActiveDocument.%s.Scale = %0.6f", + std::string baseName = m_baseView->getNameInDocument(); + if (m_scaleEdited) { + // user has changed the scale + 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", m_sectionName.c_str(), scaleType); diff --git a/src/Mod/TechDraw/Gui/TaskComplexSection.h b/src/Mod/TechDraw/Gui/TaskComplexSection.h index 9a95780ea7..49ed6b7e67 100644 --- a/src/Mod/TechDraw/Gui/TaskComplexSection.h +++ b/src/Mod/TechDraw/Gui/TaskComplexSection.h @@ -146,6 +146,8 @@ private: bool m_directionIsSet; bool m_modelIsDirty; + bool m_scaleEdited; + }; class TaskDlgComplexSection : public Gui::TaskView::TaskDialog diff --git a/src/Mod/TechDraw/Gui/TaskComplexSection.ui b/src/Mod/TechDraw/Gui/TaskComplexSection.ui index 6cf80f9e0e..de55fb8c3c 100644 --- a/src/Mod/TechDraw/Gui/TaskComplexSection.ui +++ b/src/Mod/TechDraw/Gui/TaskComplexSection.ui @@ -143,6 +143,12 @@ 26 + + 6 + + + 999.000000000000000 + 1.000000000000000 diff --git a/src/Mod/TechDraw/Gui/TaskSectionView.cpp b/src/Mod/TechDraw/Gui/TaskSectionView.cpp index d26e0a392f..059145bacc 100644 --- a/src/Mod/TechDraw/Gui/TaskSectionView.cpp +++ b/src/Mod/TechDraw/Gui/TaskSectionView.cpp @@ -65,7 +65,8 @@ TaskSectionView::TaskSectionView(TechDraw::DrawViewPart* base) : m_saved(false), m_applyDeferred(0), m_directionIsSet(false), - m_modelIsDirty(false) + m_modelIsDirty(false), + m_scaleEdited(false) { //existence of base is guaranteed by CmdTechDrawSectionView (Command.cpp) @@ -93,7 +94,8 @@ TaskSectionView::TaskSectionView(TechDraw::DrawViewSection* section) : m_saved(false), m_applyDeferred(0), m_directionIsSet(true), - m_modelIsDirty(false) + m_modelIsDirty(false), + m_scaleEdited(false) { //existence of section is guaranteed by ViewProviderViewSection.setEdit @@ -202,7 +204,7 @@ void TaskSectionView::setUiCommon(Base::Vector3d origin) // will only be triggered when the arrow keys of the spinboxes are used //if this is not done, recomputes are triggered on each key press giving //unaccceptable UX - connect(ui->sbScale, qOverload(&QuantitySpinBox::valueChanged), this, &TaskSectionView::onScaleChanged); + connect(ui->sbScale, qOverload(&QDoubleSpinBox::valueChanged), this, &TaskSectionView::onScaleChanged); connect(ui->sbOrgX, qOverload(&QuantitySpinBox::valueChanged), this, &TaskSectionView::onXChanged); connect(ui->sbOrgY, qOverload(&QuantitySpinBox::valueChanged), this, &TaskSectionView::onYChanged); connect(ui->sbOrgZ, qOverload(&QuantitySpinBox::valueChanged), this, &TaskSectionView::onZChanged); @@ -335,8 +337,10 @@ void TaskSectionView::onIdentifierChanged() void TaskSectionView::onScaleChanged() { + m_scaleEdited = true; checkAll(false); apply(); + } //SectionOrigin changed @@ -530,8 +534,19 @@ TechDraw::DrawViewSection* TaskSectionView::createSectionView(void) "App.ActiveDocument.%s.SectionOrigin = FreeCAD.Vector(%.6f, %.6f, %.6f)", m_sectionName.c_str(), ui->sbOrgX->value().getValue(), ui->sbOrgY->value().getValue(), ui->sbOrgZ->value().getValue()); - Command::doCommand(Command::Doc, "App.ActiveDocument.%s.Scale = %0.6f", - m_sectionName.c_str(), ui->sbScale->value().getValue()); + + if (m_scaleEdited) { + // user has changed the scale + 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", m_sectionName.c_str(), scaleType); @@ -574,6 +589,8 @@ void TaskSectionView::updateSectionView() } const std::string objectName("SectionView"); + std::string baseName = m_base->getNameInDocument(); + Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Edit SectionView")); if (m_section) { Command::doCommand(Command::Doc, "App.ActiveDocument.%s.SectionDirection = '%s'", @@ -594,8 +611,18 @@ void TaskSectionView::updateSectionView() Command::doCommand(Command::Doc, "App.activeDocument().%s.translateLabel('DrawViewSection', 'Section', '%s')", m_sectionName.c_str(), makeSectionLabel(qTemp).c_str()); - Command::doCommand(Command::Doc, "App.ActiveDocument.%s.Scale = %0.6f", - m_sectionName.c_str(), ui->sbScale->value().getValue()); + if (m_scaleEdited) { + // user has changed the scale + 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", m_sectionName.c_str(), scaleType); diff --git a/src/Mod/TechDraw/Gui/TaskSectionView.h b/src/Mod/TechDraw/Gui/TaskSectionView.h index d428fe3ce3..989100e7e6 100644 --- a/src/Mod/TechDraw/Gui/TaskSectionView.h +++ b/src/Mod/TechDraw/Gui/TaskSectionView.h @@ -128,6 +128,8 @@ private: VectorEditWidget* m_viewDirectionWidget; bool m_directionIsSet; bool m_modelIsDirty; + + bool m_scaleEdited; }; class TaskDlgSectionView : public Gui::TaskView::TaskDialog diff --git a/src/Mod/TechDraw/Gui/TaskSectionView.ui b/src/Mod/TechDraw/Gui/TaskSectionView.ui index a05cda7bbe..f59c7bbc4c 100644 --- a/src/Mod/TechDraw/Gui/TaskSectionView.ui +++ b/src/Mod/TechDraw/Gui/TaskSectionView.ui @@ -118,43 +118,22 @@ - - - - 0 - 0 - - - - - 0 - 22 - - - - - 0 - 0 - - + Scale factor for the section view - - false + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - 0.000000000000000 + + 6 - + 999.000000000000000 - + 1.000000000000000 - - 4 - @@ -354,7 +333,7 @@ - + 0 @@ -367,7 +346,7 @@ 22 - + false @@ -395,7 +374,7 @@ - + 0 @@ -408,7 +387,7 @@ 22 - + false @@ -436,7 +415,7 @@ - + 0 @@ -449,7 +428,7 @@ 22 - + false