[TD]fix section scale
- scale field in ui was QuantitySpinBox which is wrong for dimensionless number. - section view scale was being set at only GlobalDecimals precision.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -146,6 +146,8 @@ private:
|
||||
bool m_directionIsSet;
|
||||
bool m_modelIsDirty;
|
||||
|
||||
bool m_scaleEdited;
|
||||
|
||||
};
|
||||
|
||||
class TaskDlgComplexSection : public Gui::TaskView::TaskDialog
|
||||
|
||||
@@ -143,6 +143,12 @@
|
||||
<height>26</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>999.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
|
||||
@@ -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<double>(&QuantitySpinBox::valueChanged), this, &TaskSectionView::onScaleChanged);
|
||||
connect(ui->sbScale, qOverload<double>(&QDoubleSpinBox::valueChanged), this, &TaskSectionView::onScaleChanged);
|
||||
connect(ui->sbOrgX, qOverload<double>(&QuantitySpinBox::valueChanged), this, &TaskSectionView::onXChanged);
|
||||
connect(ui->sbOrgY, qOverload<double>(&QuantitySpinBox::valueChanged), this, &TaskSectionView::onYChanged);
|
||||
connect(ui->sbOrgZ, qOverload<double>(&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);
|
||||
|
||||
@@ -128,6 +128,8 @@ private:
|
||||
VectorEditWidget* m_viewDirectionWidget;
|
||||
bool m_directionIsSet;
|
||||
bool m_modelIsDirty;
|
||||
|
||||
bool m_scaleEdited;
|
||||
};
|
||||
|
||||
class TaskDlgSectionView : public Gui::TaskView::TaskDialog
|
||||
|
||||
@@ -118,43 +118,22 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="Gui::QuantitySpinBox" name="sbScale" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<widget class="QDoubleSpinBox" name="sbScale">
|
||||
<property name="toolTip">
|
||||
<string>Scale factor for the section view</string>
|
||||
</property>
|
||||
<property name="keyboardTracking" stdset="0">
|
||||
<bool>false</bool>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum" stdset="0">
|
||||
<double>0.000000000000000</double>
|
||||
<property name="decimals">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="maximum" stdset="0">
|
||||
<property name="maximum">
|
||||
<double>999.000000000000000</double>
|
||||
</property>
|
||||
<property name="value" stdset="0">
|
||||
<property name="value">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="decimals" stdset="0">
|
||||
<number>4</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -354,7 +333,7 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="Gui::QuantitySpinBox" name="sbOrgX" native="true">
|
||||
<widget class="Gui::QuantitySpinBox" name="sbOrgX">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
@@ -367,7 +346,7 @@
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="keyboardTracking" stdset="0">
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
@@ -395,7 +374,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="Gui::QuantitySpinBox" name="sbOrgY" native="true">
|
||||
<widget class="Gui::QuantitySpinBox" name="sbOrgY">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
@@ -408,7 +387,7 @@
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="keyboardTracking" stdset="0">
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
@@ -436,7 +415,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="Gui::QuantitySpinBox" name="sbOrgZ" native="true">
|
||||
<widget class="Gui::QuantitySpinBox" name="sbOrgZ">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
@@ -449,7 +428,7 @@
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="keyboardTracking" stdset="0">
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
|
||||
Reference in New Issue
Block a user