Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[TD] some Detail View fixes
  • Loading branch information
donovaly committed Apr 18, 2020
1 parent ba34cc6 commit 6d06bdf
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 17 deletions.
35 changes: 34 additions & 1 deletion src/Mod/TechDraw/App/DrawViewDetail.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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);
}
Expand Down
21 changes: 11 additions & 10 deletions src/Mod/TechDraw/Gui/TaskDetail.cpp
Expand Up @@ -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),
Expand Down Expand Up @@ -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()));
Expand All @@ -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),
Expand Down Expand Up @@ -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()));
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/TechDraw/Gui/TaskDetail.h
Expand Up @@ -46,7 +46,7 @@ namespace TechDraw
{
class DrawPage;
class DrawView;
class DrawDetail;
class DrawViewDetail;
class DrawViewPart;
}

Expand Down
9 changes: 9 additions & 0 deletions src/Mod/TechDraw/Gui/TaskDetail.ui
Expand Up @@ -128,6 +128,9 @@
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
</property>
Expand Down Expand Up @@ -178,6 +181,9 @@
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
</property>
Expand All @@ -194,6 +200,9 @@
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="keyboardTracking">
<bool>false</bool>
</property>
<property name="unit" stdset="0">
<string notr="true"/>
</property>
Expand Down
8 changes: 4 additions & 4 deletions src/Mod/TechDraw/Gui/TaskProjGroup.cpp
Expand Up @@ -238,25 +238,25 @@ 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");
double autoScale = multiView->calculateAutomaticScale();
multiView->Scale.setValue(autoScale);
//unblock recompute

} else if(index == 2) {
} else if (index == 2) {
// Custom Scale Type
//block recompute
multiView->ScaleType.setValue("Custom");
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp
Expand Up @@ -54,10 +54,10 @@
#include <Mod/TechDraw/App/DrawViewDetail.h>
#include <Mod/TechDraw/App/DrawHatch.h>
#include <Mod/TechDraw/App/DrawGeomHatch.h>
#include <Mod/TechDraw/App/DrawPage.h>
#include <Mod/TechDraw/App/DrawWeldSymbol.h>
#include <Mod/TechDraw/App/LineGroup.h>

#include<Mod/TechDraw/App/DrawPage.h>
#include "QGIView.h"
#include "TaskDetail.h"
#include "ViewProviderViewPart.h"
Expand Down

0 comments on commit 6d06bdf

Please sign in to comment.