From af7d7f311835d58072902553d013fbfbbfc238e4 Mon Sep 17 00:00:00 2001 From: WandererFan Date: Sun, 6 Mar 2016 19:56:03 -0500 Subject: [PATCH] ScaleType/Scale linkage & PropertyEditor --- src/Mod/TechDraw/App/DrawProjGroup.cpp | 1 - src/Mod/TechDraw/App/DrawView.cpp | 55 +++++++++++---------- src/Mod/TechDraw/App/DrawViewCollection.cpp | 10 +--- src/Mod/TechDraw/App/DrawViewPart.cpp | 6 +-- 4 files changed, 30 insertions(+), 42 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawProjGroup.cpp b/src/Mod/TechDraw/App/DrawProjGroup.cpp index 7c395ad1c..d8b22aeff 100644 --- a/src/Mod/TechDraw/App/DrawProjGroup.cpp +++ b/src/Mod/TechDraw/App/DrawProjGroup.cpp @@ -580,7 +580,6 @@ App::DocumentObjectExecReturn *DrawProjGroup::execute(void) view->ScaleType.setValue("Custom"); view->Scale.setValue(autoScale); view->Scale.touch(); - //view->Scale.StatusBits.set(2); view->Scale.setStatus(App::Property::ReadOnly,true); view->touch(); } diff --git a/src/Mod/TechDraw/App/DrawView.cpp b/src/Mod/TechDraw/App/DrawView.cpp index c900092ec..72c89b2ed 100644 --- a/src/Mod/TechDraw/App/DrawView.cpp +++ b/src/Mod/TechDraw/App/DrawView.cpp @@ -30,6 +30,7 @@ #include +#include #include #include #include @@ -64,7 +65,6 @@ DrawView::DrawView(void) static const char *group = "Drawing view"; ADD_PROPERTY_TYPE(X ,(0),group,App::Prop_None,"X position of the view on the page in modelling units (mm)"); ADD_PROPERTY_TYPE(Y ,(0),group,App::Prop_None,"Y position of the view on the page in modelling units (mm)"); - ADD_PROPERTY_TYPE(Scale ,(1.0),group,App::Prop_None,"Scale factor of the view"); ADD_PROPERTY_TYPE(Rotation ,(0),group,App::Prop_None,"Rotation of the view on the page in degrees counterclockwise"); // The 'Visible' property is handled by the view provider exclusively. It has the 'Output' flag set to @@ -74,6 +74,9 @@ DrawView::DrawView(void) ScaleType.setEnums(ScaleTypeEnums); ADD_PROPERTY_TYPE(ScaleType,((long)0),group, App::Prop_None, "Scale Type"); + ADD_PROPERTY_TYPE(Scale ,(1.0),group,App::Prop_None,"Scale factor of the view"); + Scale.setStatus(App::Property::ReadOnly,true); + } DrawView::~DrawView() @@ -95,38 +98,36 @@ App::DocumentObjectExecReturn *DrawView::recompute(void) App::DocumentObjectExecReturn *DrawView::execute(void) { - if (ScaleType.isValue("Document")) { - Scale.setStatus(App::Property::ReadOnly,true); - //Scale.StatusBits.set(2, true); - - TechDraw::DrawPage *page = findParentPage(); - if(page) { - if(std::abs(page->Scale.getValue() - Scale.getValue()) > FLT_EPSILON) { - Scale.setValue(page->Scale.getValue()); // Recalculate scale from page - Scale.touch(); - } - } - } else if (ScaleType.isValue("Custom")) { - Scale.setStatus(App::Property::ReadOnly,false); - //Scale.StatusBits.set(2, false); - //TODO: need to ?recompute? ?redraw? to get this to stick. Mantis #1941 - //TODO: try Gui::Selection to force update - //currently need to lose focus and re-get focus to make Scale editable. - //Scale.touch(); // causes loop - } return App::DocumentObject::execute(); } /// get called by the container when a Property was changed void DrawView::onChanged(const App::Property* prop) { - if (prop == &X || - prop == &Y || - prop == &ScaleType || - prop == &Rotation) { - if (!isRestoring()) { - DrawView::execute(); - } + if (!isRestoring()) { + if (prop == &ScaleType) { + if (ScaleType.isValue("Document") && + !Scale.testStatus(App::Property::ReadOnly)) { + Scale.setStatus(App::Property::ReadOnly,true); + App::GetApplication().signalChangePropertyEditor(Scale); + TechDraw::DrawPage *page = findParentPage(); + if(page) { + if(std::abs(page->Scale.getValue() - Scale.getValue()) > FLT_EPSILON) { + Scale.setValue(page->Scale.getValue()); // Recalculate scale from page + Scale.touch(); + } + } + } else if (ScaleType.isValue("Custom") && + Scale.testStatus(App::Property::ReadOnly)) { + Scale.setStatus(App::Property::ReadOnly,false); + App::GetApplication().signalChangePropertyEditor(Scale); + } + DrawView::execute(); + } else if (prop == &X || + prop == &Y || + prop == &Rotation) { + DrawView::execute(); //trigger stuff to happen on Gui side + } } App::DocumentObject::onChanged(prop); diff --git a/src/Mod/TechDraw/App/DrawViewCollection.cpp b/src/Mod/TechDraw/App/DrawViewCollection.cpp index e54bf0dce..e1115e3be 100644 --- a/src/Mod/TechDraw/App/DrawViewCollection.cpp +++ b/src/Mod/TechDraw/App/DrawViewCollection.cpp @@ -126,11 +126,6 @@ void DrawViewCollection::onChanged(const App::Property* prop) App::DocumentObjectExecReturn *DrawViewCollection::execute(void) { if (ScaleType.isValue("Document")) { - // Recalculate scale - //Scale.StatusBits.set(App::Prop_ReadOnly); - Scale.setStatus(App::Property::ReadOnly,true); - - const std::vector &views = Views.getValues(); for(std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { App::DocumentObject *docObj = *it; @@ -143,10 +138,7 @@ App::DocumentObjectExecReturn *DrawViewCollection::execute(void) } } } else if(strcmp(ScaleType.getValueAsString(), "Custom") == 0) { - // Rebuild the view - //Scale.StatusBits.set(App::Prop_ReadOnly, false); - Scale.setStatus(App::Property::ReadOnly,false); - + // Rebuild the views const std::vector &views = Views.getValues(); for(std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { App::DocumentObject *docObj = *it; diff --git a/src/Mod/TechDraw/App/DrawViewPart.cpp b/src/Mod/TechDraw/App/DrawViewPart.cpp index 2ffb8d570..0d09dac8b 100644 --- a/src/Mod/TechDraw/App/DrawViewPart.cpp +++ b/src/Mod/TechDraw/App/DrawViewPart.cpp @@ -143,6 +143,7 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void) } touch(); + return DrawView::execute(); } @@ -187,11 +188,6 @@ void DrawViewPart::buildGeometryObject(TopoDS_Shape shape) { geometryObject->setTolerance(Tolerance.getValue()); geometryObject->setScale(Scale.getValue()); - //TODO: need to pass ShowSmoothLines, ShowSeamLines - //geometryObject->extractGeometry(shape, - // Direction.getValue(), - // ShowHiddenLines.getValue(), - // _getValidXDir(this)); geometryObject->initHLR(shape, Direction.getValue(), _getValidXDir(this));