Fix #3810 X/Y Property Update on Locked View
- fixes x/y update when position locked for simple Views and ProjectionGroups.
This commit is contained in:
@@ -85,7 +85,6 @@ DrawProjGroup::~DrawProjGroup()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DrawProjGroup::onChanged(const App::Property* prop)
|
||||
{
|
||||
//TODO: For some reason, when the projection type is changed, the isometric views show change appropriately, but the orthographic ones don't... Or vice-versa. WF: why would you change from 1st to 3rd in mid drawing?
|
||||
@@ -136,7 +135,7 @@ void DrawProjGroup::onChanged(const App::Property* prop)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
TechDraw::DrawViewCollection::onChanged(prop);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,8 +29,10 @@
|
||||
#include <gp_Ax2.hxx>
|
||||
#include <gp_Ax3.hxx>
|
||||
#include <gp_Trsf.hxx>
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <App/DocumentObject.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Writer.h>
|
||||
|
||||
#include "GeometryObject.h"
|
||||
#include "DrawUtil.h"
|
||||
@@ -72,6 +74,10 @@ DrawProjGroupItem::DrawProjGroupItem(void)
|
||||
ScaleType.setStatus(App::Property::ReadOnly,true);
|
||||
}
|
||||
|
||||
DrawProjGroupItem::~DrawProjGroupItem()
|
||||
{
|
||||
}
|
||||
|
||||
short DrawProjGroupItem::mustExecute() const
|
||||
{
|
||||
short result = 0;
|
||||
@@ -91,11 +97,16 @@ short DrawProjGroupItem::mustExecute() const
|
||||
void DrawProjGroupItem::onChanged(const App::Property *prop)
|
||||
{
|
||||
TechDraw::DrawViewPart::onChanged(prop);
|
||||
|
||||
}
|
||||
|
||||
DrawProjGroupItem::~DrawProjGroupItem()
|
||||
bool DrawProjGroupItem::isLocked(void) const
|
||||
{
|
||||
bool isLocked = DrawView::isLocked();
|
||||
DrawProjGroup* parent = getPGroup();
|
||||
if (parent != nullptr) {
|
||||
isLocked = isLocked || parent->LockPosition.getValue();
|
||||
}
|
||||
return isLocked;
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *DrawProjGroupItem::execute(void)
|
||||
@@ -234,7 +245,6 @@ double DrawProjGroupItem::getScale(void) const
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void DrawProjGroupItem::unsetupObject()
|
||||
{
|
||||
if (getPGroup() != nullptr) {
|
||||
|
||||
@@ -83,6 +83,7 @@ public:
|
||||
|
||||
protected:
|
||||
void onChanged(const App::Property* prop) override;
|
||||
virtual bool isLocked(void) const override;
|
||||
|
||||
private:
|
||||
static const char* TypeEnums[];
|
||||
|
||||
@@ -72,10 +72,9 @@ DrawView::DrawView(void):
|
||||
mouseMove(false)
|
||||
{
|
||||
static const char *group = "Base";
|
||||
|
||||
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(LockPosition ,(false),group,App::Prop_None,"Prevent View from moving in Gui");
|
||||
ADD_PROPERTY_TYPE(X ,(0),group,App::Prop_None,"X position of the view on the page in internal units (mm)");
|
||||
ADD_PROPERTY_TYPE(Y ,(0),group,App::Prop_None,"Y position of the view on the page in internal units (mm)");
|
||||
ADD_PROPERTY_TYPE(LockPosition ,(false),group,App::Prop_None,"Lock View position to parent Page or Group");
|
||||
ADD_PROPERTY_TYPE(Rotation ,(0),group,App::Prop_None,"Rotation of the view on the page in degrees counterclockwise");
|
||||
|
||||
ScaleType.setEnums(ScaleTypeEnums);
|
||||
@@ -92,8 +91,9 @@ DrawView::~DrawView()
|
||||
|
||||
App::DocumentObjectExecReturn *DrawView::execute(void)
|
||||
{
|
||||
handleXYLock();
|
||||
requestPaint();
|
||||
return App::DocumentObject::StdReturn; //DO::execute returns 0
|
||||
return App::DocumentObject::execute();
|
||||
}
|
||||
|
||||
void DrawView::checkScale(void)
|
||||
@@ -139,19 +139,54 @@ void DrawView::onChanged(const App::Property* prop)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (prop == &LockPosition) {
|
||||
handleXYLock();
|
||||
}
|
||||
}
|
||||
App::DocumentObject::onChanged(prop);
|
||||
}
|
||||
|
||||
bool DrawView::isLocked(void) const
|
||||
{
|
||||
return LockPosition.getValue();
|
||||
}
|
||||
|
||||
//override this for View inside a group (ex DPGI in DPG)
|
||||
void DrawView::handleXYLock(void)
|
||||
{
|
||||
if (isLocked()) {
|
||||
if (!X.testStatus(App::Property::ReadOnly)) {
|
||||
X.setStatus(App::Property::ReadOnly,true);
|
||||
App::GetApplication().signalChangePropertyEditor(X);
|
||||
X.purgeTouched();
|
||||
}
|
||||
Y.setStatus(App::Property::ReadOnly,true);
|
||||
App::GetApplication().signalChangePropertyEditor(Y);
|
||||
Y.purgeTouched();
|
||||
requestPaint();
|
||||
} else {
|
||||
if (X.testStatus(App::Property::ReadOnly)) {
|
||||
X.setStatus(App::Property::ReadOnly,false);
|
||||
App::GetApplication().signalChangePropertyEditor(X);
|
||||
X.purgeTouched();
|
||||
}
|
||||
Y.setStatus(App::Property::ReadOnly,false);
|
||||
App::GetApplication().signalChangePropertyEditor(Y);
|
||||
Y.purgeTouched();
|
||||
requestPaint();
|
||||
}
|
||||
}
|
||||
|
||||
short DrawView::mustExecute() const
|
||||
{
|
||||
short result = 0;
|
||||
if (!isRestoring()) {
|
||||
result = (Scale.isTouched() ||
|
||||
ScaleType.isTouched() ||
|
||||
X.isTouched() ||
|
||||
Y.isTouched() );
|
||||
ScaleType.isTouched() );
|
||||
if (!isLocked()) {
|
||||
result = result || X.isTouched() ||
|
||||
Y.isTouched() ;
|
||||
}
|
||||
}
|
||||
if ((bool) result) {
|
||||
return result;
|
||||
@@ -168,6 +203,7 @@ QRectF DrawView::getRect() const
|
||||
|
||||
void DrawView::onDocumentRestored()
|
||||
{
|
||||
handleXYLock();
|
||||
DrawView::execute();
|
||||
}
|
||||
|
||||
@@ -251,8 +287,10 @@ bool DrawView::checkFit(TechDraw::DrawPage* p) const
|
||||
|
||||
void DrawView::setPosition(double x, double y)
|
||||
{
|
||||
X.setValue(x);
|
||||
Y.setValue(y);
|
||||
if (!isLocked()) {
|
||||
X.setValue(x);
|
||||
Y.setValue(y);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: getScale is no longer needed and could revert to Scale.getValue
|
||||
|
||||
@@ -87,9 +87,11 @@ public:
|
||||
virtual double getScale(void) const;
|
||||
void checkScale(void);
|
||||
void requestPaint(void);
|
||||
virtual void handleXYLock(void);
|
||||
virtual bool isLocked(void) const;
|
||||
|
||||
protected:
|
||||
void onChanged(const App::Property* prop) override;
|
||||
virtual void onChanged(const App::Property* prop) override;
|
||||
std::string pageFeatName;
|
||||
bool autoPos;
|
||||
bool mouseMove;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#endif
|
||||
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObject.h>
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Exception.h>
|
||||
@@ -45,8 +46,8 @@ PROPERTY_SOURCE(TechDraw::DrawViewCollection, TechDraw::DrawView)
|
||||
DrawViewCollection::DrawViewCollection()
|
||||
{
|
||||
nowUnsetting = false;
|
||||
static const char *group = "Drawing view";
|
||||
ADD_PROPERTY_TYPE(Views ,(0), group, App::Prop_None,"Attached Views");
|
||||
static const char *group = "Collection";
|
||||
ADD_PROPERTY_TYPE(Views ,(0), group, App::Prop_None,"Collection Views");
|
||||
Views.setScope(App::LinkScope::Global);
|
||||
}
|
||||
|
||||
@@ -54,6 +55,31 @@ DrawViewCollection::~DrawViewCollection()
|
||||
{
|
||||
}
|
||||
|
||||
void DrawViewCollection::onChanged(const App::Property* prop)
|
||||
{
|
||||
TechDraw::DrawView::onChanged(prop);
|
||||
}
|
||||
|
||||
short DrawViewCollection::mustExecute() const
|
||||
{
|
||||
if (Views.isTouched()) {
|
||||
return 1;
|
||||
} else {
|
||||
return TechDraw::DrawView::mustExecute();
|
||||
}
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *DrawViewCollection::execute(void)
|
||||
{
|
||||
if (!keepUpdated()) {
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
lockChildren();
|
||||
|
||||
return DrawView::execute();
|
||||
}
|
||||
|
||||
int DrawViewCollection::addView(DrawView *view)
|
||||
{
|
||||
// Add the new view to the collection
|
||||
@@ -106,15 +132,6 @@ void DrawViewCollection::rebuildViewList()
|
||||
Views.setValues(newViews);
|
||||
}
|
||||
|
||||
short DrawViewCollection::mustExecute() const
|
||||
{
|
||||
if (Views.isTouched()) {
|
||||
return 1;
|
||||
} else {
|
||||
return TechDraw::DrawView::mustExecute();
|
||||
}
|
||||
}
|
||||
|
||||
int DrawViewCollection::countChildren()
|
||||
{
|
||||
//Count the children recursively if needed
|
||||
@@ -138,9 +155,15 @@ void DrawViewCollection::onDocumentRestored()
|
||||
DrawView::execute();
|
||||
}
|
||||
|
||||
void DrawViewCollection::onChanged(const App::Property* prop)
|
||||
void DrawViewCollection::lockChildren(void)
|
||||
{
|
||||
TechDraw::DrawView::onChanged(prop);
|
||||
for (auto& v:Views.getValues()) {
|
||||
TechDraw::DrawView *view = dynamic_cast<TechDraw::DrawView *>(v);
|
||||
if (!view) {
|
||||
throw Base::ValueError("DrawViewCollection::lockChildren bad View\n");
|
||||
}
|
||||
view->handleXYLock();
|
||||
}
|
||||
}
|
||||
|
||||
void DrawViewCollection::unsetupObject()
|
||||
@@ -162,17 +185,6 @@ void DrawViewCollection::unsetupObject()
|
||||
Views.setValues(emptyViews);
|
||||
}
|
||||
|
||||
|
||||
App::DocumentObjectExecReturn *DrawViewCollection::execute(void)
|
||||
{
|
||||
if (!keepUpdated()) {
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
return DrawView::execute();
|
||||
}
|
||||
|
||||
|
||||
QRectF DrawViewCollection::getRect() const
|
||||
{
|
||||
QRectF result;
|
||||
|
||||
@@ -52,6 +52,7 @@ public:
|
||||
bool isUnsetting(void) { return nowUnsetting; }
|
||||
|
||||
int countChildren();
|
||||
void lockChildren(void);
|
||||
|
||||
virtual void onDocumentRestored();
|
||||
virtual App::DocumentObjectExecReturn *execute(void);
|
||||
|
||||
Reference in New Issue
Block a user