diff --git a/src/Mod/TechDraw/App/DrawViewDetail.cpp b/src/Mod/TechDraw/App/DrawViewDetail.cpp index 53c02f5894b5..919be9fee1ca 100644 --- a/src/Mod/TechDraw/App/DrawViewDetail.cpp +++ b/src/Mod/TechDraw/App/DrawViewDetail.cpp @@ -84,9 +84,10 @@ #include "Cosmetic.h" #include "EdgeWalker.h" #include "DrawProjectSplit.h" +#include "DrawProjGroupItem.h" +#include "DrawPage.h" #include "DrawUtil.h" #include "DrawViewDetail.h" -#include "DrawProjGroupItem.h" #include "DrawViewSection.h" using namespace TechDraw; @@ -115,6 +116,9 @@ DrawViewDetail::DrawViewDetail() //hide Properties not relevant to DVDetail Direction.setStatus(App::Property::ReadOnly,true); //Should be same as BaseView Rotation.setStatus(App::Property::ReadOnly,true); //same as BaseView + + //hide Properties that can only be set in Base View + //HighlightLineColor.setStatus(App::Property::ReadOnly, true); //Should be same as BaseView } DrawViewDetail::~DrawViewDetail() @@ -153,6 +157,35 @@ void DrawViewDetail::onChanged(const App::Property* prop) // to see AnchorPoint changes repainting is not enough, we must recompute recomputeFeature(true); } + if (prop == &ScaleType) { + auto page = findParentPage(); + // if ScaleType is "Page", the user cannot change it + if (ScaleType.isValue("Page")) { + Scale.setStatus(App::Property::ReadOnly, true); + // apply the page-wide Scale + if (page != nullptr) { + if (std::abs(page->Scale.getValue() - getScale()) > FLT_EPSILON) { + Scale.setValue(page->Scale.getValue()); + Scale.purgeTouched(); + } + } + } + else if (ScaleType.isValue("Custom")) { + // allow the change Scale + Scale.setStatus(App::Property::ReadOnly, false); + } + else if (ScaleType.isValue("Automatic")) { + Scale.setStatus(App::Property::ReadOnly, true); + // apply a Scale + if (!checkFit(page)) { + double newScale = autoScale(page->getPageWidth(), page->getPageHeight()); + if (std::abs(newScale - getScale()) > FLT_EPSILON) { //stops onChanged/execute loop + Scale.setValue(newScale); + Scale.purgeTouched(); + } + } + } + } } DrawView::onChanged(prop); } diff --git a/src/Mod/TechDraw/Gui/TaskDetail.cpp b/src/Mod/TechDraw/Gui/TaskDetail.cpp index f7b1a6214f9d..d1eba52135b0 100644 --- a/src/Mod/TechDraw/Gui/TaskDetail.cpp +++ b/src/Mod/TechDraw/Gui/TaskDetail.cpp @@ -71,7 +71,7 @@ using namespace Gui; #define CREATEMODE 0 #define EDITMODE 1 -//creation ctor +//creation constructor TaskDetail::TaskDetail(TechDraw::DrawViewPart* baseFeat): ui(new Ui_TaskDetail), m_detailFeat(nullptr), @@ -119,11 +119,11 @@ TaskDetail::TaskDetail(TechDraw::DrawViewPart* baseFeat): //use editingFinished signal instead of valueChanged to prevent keyboard lock out //valueChanged fires every keystroke causing a recompute. - connect(ui->qsbX, SIGNAL(editingFinished()), + connect(ui->qsbX, SIGNAL(valueChanged(double)), this, SLOT(onXEdit())); - connect(ui->qsbY, SIGNAL(editingFinished()), + connect(ui->qsbY, SIGNAL(valueChanged(double)), this, SLOT(onYEdit())); - connect(ui->qsbRadius, SIGNAL(editingFinished()), + connect(ui->qsbRadius, SIGNAL(valueChanged(double)), this, SLOT(onRadiusEdit())); connect(ui->aeReference, SIGNAL(editingFinished()), this, SLOT(onReferenceEdit())); @@ -135,7 +135,7 @@ TaskDetail::TaskDetail(TechDraw::DrawViewPart* baseFeat): this, SLOT(onHighlightMoved(QPointF))); } -//edit ctor +//edit constructor TaskDetail::TaskDetail(TechDraw::DrawViewDetail* detailFeat): ui(new Ui_TaskDetail), m_detailFeat(detailFeat), @@ -190,13 +190,14 @@ TaskDetail::TaskDetail(TechDraw::DrawViewDetail* detailFeat): connect(ui->pbDragger, SIGNAL(clicked(bool)), this, SLOT(onDraggerClicked(bool))); - //use editingFinished signal instead of valueChanged to prevent keyboard lock out - //valueChanged fires every keystroke causing a recompute. - connect(ui->qsbX, SIGNAL(editingFinished()), + // the UI file uses setKeyboardTracking(false) so that a + // recomputation will only be triggered when the arrow yeys of the spinboxes are used + + connect(ui->qsbX, SIGNAL(valueChanged(double)), this, SLOT(onXEdit())); - connect(ui->qsbY, SIGNAL(editingFinished()), + connect(ui->qsbY, SIGNAL(valueChanged(double)), this, SLOT(onYEdit())); - connect(ui->qsbRadius, SIGNAL(editingFinished()), + connect(ui->qsbRadius, SIGNAL(valueChanged(double)), this, SLOT(onRadiusEdit())); connect(ui->aeReference, SIGNAL(editingFinished()), this, SLOT(onReferenceEdit())); diff --git a/src/Mod/TechDraw/Gui/TaskDetail.h b/src/Mod/TechDraw/Gui/TaskDetail.h index 588dcaea2370..ad1bb6a7404e 100644 --- a/src/Mod/TechDraw/Gui/TaskDetail.h +++ b/src/Mod/TechDraw/Gui/TaskDetail.h @@ -46,7 +46,7 @@ namespace TechDraw { class DrawPage; class DrawView; -class DrawDetail; +class DrawViewDetail; class DrawViewPart; } diff --git a/src/Mod/TechDraw/Gui/TaskDetail.ui b/src/Mod/TechDraw/Gui/TaskDetail.ui index 0aa0a2fe2158..5ea4e5937e24 100644 --- a/src/Mod/TechDraw/Gui/TaskDetail.ui +++ b/src/Mod/TechDraw/Gui/TaskDetail.ui @@ -128,6 +128,9 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + false + @@ -178,6 +181,9 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + false + @@ -194,6 +200,9 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + false + diff --git a/src/Mod/TechDraw/Gui/TaskProjGroup.cpp b/src/Mod/TechDraw/Gui/TaskProjGroup.cpp index 53240341d130..d27caa7b92bb 100644 --- a/src/Mod/TechDraw/Gui/TaskProjGroup.cpp +++ b/src/Mod/TechDraw/Gui/TaskProjGroup.cpp @@ -238,17 +238,17 @@ void TaskProjGroup::projectionTypeChanged(int index) void TaskProjGroup::scaleTypeChanged(int index) { - if(blockUpdate) + if (blockUpdate) return; //defaults to prevent scale changing ui->sbScaleNum->setEnabled(false); ui->sbScaleDen->setEnabled(false); - if(index == 0) { + if (index == 0) { // Document Scale Type multiView->ScaleType.setValue("Page"); - } else if(index == 1) { + } else if (index == 1) { // Automatic Scale Type //block recompute multiView->ScaleType.setValue("Automatic"); @@ -256,7 +256,7 @@ void TaskProjGroup::scaleTypeChanged(int index) multiView->Scale.setValue(autoScale); //unblock recompute - } else if(index == 2) { + } else if (index == 2) { // Custom Scale Type //block recompute multiView->ScaleType.setValue("Custom"); diff --git a/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp b/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp index b8469fc1a217..14682108e9e0 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp @@ -54,10 +54,10 @@ #include #include #include +#include #include #include -#include #include "QGIView.h" #include "TaskDetail.h" #include "ViewProviderViewPart.h"