Restore secondary ortho view movement to v017 style

- this should also complete the fix for #3809
This commit is contained in:
wandererfan
2019-02-08 19:42:23 -05:00
committed by wmayer
parent 2240ba0e2a
commit 9de6ff802a
10 changed files with 100 additions and 76 deletions

View File

@@ -96,7 +96,6 @@ void DrawProjGroup::onChanged(const App::Property* prop)
if (!sourceObjs.empty()) {
if (!hasAnchor()) {
// if we have a Source, but no Anchor, make an anchor
// Base::Console().Message("TRACE - DPG::onChanged - adding Front\n");
Anchor.setValue(addProjection("Front"));
Anchor.purgeTouched(); //don't need to mark this
}
@@ -133,7 +132,6 @@ void DrawProjGroup::onChanged(const App::Property* prop)
Base::Console().Warning("DPG: Projection Groups do not rotate. Change ignored.\n");
}
}
}
TechDraw::DrawViewCollection::onChanged(prop);
@@ -141,6 +139,7 @@ void DrawProjGroup::onChanged(const App::Property* prop)
App::DocumentObjectExecReturn *DrawProjGroup::execute(void)
{
// Base::Console().Message("DPG::execute()\n");
if (!keepUpdated()) {
return App::DocumentObject::StdReturn;
}
@@ -183,6 +182,7 @@ short DrawProjGroup::mustExecute() const
ProjectionType.isTouched() ||
Anchor.isTouched() ||
AutoDistribute.isTouched() ||
LockPosition.isTouched()||
spacingX.isTouched() ||
spacingY.isTouched();
}
@@ -324,7 +324,6 @@ DrawProjGroupItem* DrawProjGroup::getProjItem(const char *viewProjType) const
return result;
}
bool DrawProjGroup::checkViewProjType(const char *in)
{
if ( strcmp(in, "Front") == 0 ||
@@ -379,12 +378,13 @@ App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
} else { //Front
view->LockPosition.setValue(true); //lock "Front" position within DPG (note not Page!).
view->LockPosition.setStatus(App::Property::ReadOnly,true); //Front should stay locked.
App::GetApplication().signalChangePropertyEditor(view->LockPosition);
view->LockPosition.purgeTouched();
requestPaint();
}
addView(view); //from DrawViewCollection
if (view != getAnchor()) { //anchor is done elsewhere
view->recomputeFeature();
}
requestPaint();
}
return view;
@@ -521,7 +521,8 @@ Base::Vector3d DrawProjGroup::getXYPosition(const char *viewTypeCStr)
//TODO: bounding boxes do not take view orientation into account
// ie X&Y widths might be swapped on page
if (AutoDistribute.getValue()) {
// if (AutoDistribute.getValue()) {
if (true) {
std::vector<Base::Vector3d> position(idxCount);
int idx = 0;
for (;idx < idxCount; idx++) {
@@ -627,7 +628,6 @@ Base::Vector3d DrawProjGroup::getXYPosition(const char *viewTypeCStr)
return result;
}
int DrawProjGroup::getViewIndex(const char *viewTypeCStr) const
{
int result = 4; //default to front view's position
@@ -848,7 +848,6 @@ TechDraw::DrawProjGroupItem* DrawProjGroup::getAnchor(void)
return result;
}
void DrawProjGroup::setAnchorDirection(const Base::Vector3d dir)
{
App::DocumentObject* docObj = Anchor.getValue();
@@ -869,7 +868,6 @@ Base::Vector3d DrawProjGroup::getAnchorDirection(void)
return result;
}
//*************************************
//* view direction manipulation routines
//*************************************

View File

@@ -102,6 +102,9 @@ void DrawProjGroupItem::onChanged(const App::Property *prop)
bool DrawProjGroupItem::isLocked(void) const
{
bool isLocked = DrawView::isLocked();
if (isAnchor()) { //Anchor view is always locked to DPG
return true;
}
DrawProjGroup* parent = getPGroup();
if (parent != nullptr) {
isLocked = isLocked || parent->LockPosition.getValue();
@@ -117,26 +120,32 @@ App::DocumentObjectExecReturn *DrawProjGroupItem::execute(void)
}
App::DocumentObjectExecReturn * ret = DrawViewPart::execute();
delete ret;
autoPosition();
requestPaint();
if (ret != nullptr) {
return ret;
} else {
autoPosition();
requestPaint();
delete ret;
}
return App::DocumentObject::StdReturn;
}
void DrawProjGroupItem::autoPosition()
{
// Base::Console().Message("DPGI::autoPosition(%s)\n",getNameInDocument());
auto pgroup = getPGroup();
Base::Vector3d newPos;
if ((pgroup != nullptr) &&
(pgroup->AutoDistribute.getValue()) &&
(!LockPosition.getValue())) {
newPos = pgroup->getXYPosition(Type.getValueAsString());
X.setValue(newPos.x);
Y.setValue(newPos.y);
if (pgroup != nullptr) {
if (pgroup->AutoDistribute.getValue()) {
if (!LockPosition.getValue()) {
newPos = pgroup->getXYPosition(Type.getValueAsString());
X.setValue(newPos.x);
Y.setValue(newPos.y);
}
}
}
requestPaint();
purgeTouched();
purgeTouched(); //prevents "still touched after recompute" message
}
void DrawProjGroupItem::onDocumentRestored()
@@ -160,7 +169,7 @@ DrawProjGroup* DrawProjGroupItem::getPGroup() const
return result;
}
bool DrawProjGroupItem::isAnchor(void)
bool DrawProjGroupItem::isAnchor(void) const
{
bool result = false;
auto group = getPGroup();

View File

@@ -78,7 +78,7 @@ public:
virtual double getScale(void) const override;
void autoPosition(void);
bool isAnchor(void);
bool isAnchor(void) const;
protected:

View File

@@ -141,6 +141,8 @@ void DrawView::onChanged(const App::Property* prop)
}
} else if (prop == &LockPosition) {
handleXYLock();
LockPosition.purgeTouched();
requestPaint();
}
}
App::DocumentObject::onChanged(prop);
@@ -159,21 +161,27 @@ void DrawView::handleXYLock(void)
X.setStatus(App::Property::ReadOnly,true);
App::GetApplication().signalChangePropertyEditor(X);
X.purgeTouched();
requestPaint();
}
if (!Y.testStatus(App::Property::ReadOnly)) {
Y.setStatus(App::Property::ReadOnly,true);
App::GetApplication().signalChangePropertyEditor(Y);
Y.purgeTouched();
requestPaint();
}
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();
requestPaint();
}
if (Y.testStatus(App::Property::ReadOnly)) {
Y.setStatus(App::Property::ReadOnly,false);
App::GetApplication().signalChangePropertyEditor(Y);
Y.purgeTouched();
requestPaint();
}
Y.setStatus(App::Property::ReadOnly,false);
App::GetApplication().signalChangePropertyEditor(Y);
Y.purgeTouched();
requestPaint();
}
}
@@ -182,11 +190,9 @@ short DrawView::mustExecute() const
short result = 0;
if (!isRestoring()) {
result = (Scale.isTouched() ||
ScaleType.isTouched() );
if (!isLocked()) {
result = result || X.isTouched() ||
Y.isTouched() ;
}
ScaleType.isTouched() ||
X.isTouched() ||
Y.isTouched() );
}
if ((bool) result) {
return result;
@@ -287,6 +293,7 @@ bool DrawView::checkFit(TechDraw::DrawPage* p) const
void DrawView::setPosition(double x, double y)
{
// Base::Console().Message("DV::setPosition(%.3f,%.3f) - \n",x,y,getNameInDocument());
if (!isLocked()) {
X.setValue(x);
Y.setValue(y);

View File

@@ -157,6 +157,7 @@ void DrawViewCollection::onDocumentRestored()
void DrawViewCollection::lockChildren(void)
{
// Base::Console().Message("DVC::lockChildren()\n");
for (auto& v:Views.getValues()) {
TechDraw::DrawView *view = dynamic_cast<TechDraw::DrawView *>(v);
if (!view) {