Skip to content

Commit

Permalink
Fix update of children on parent LockPosition change
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan authored and wwmayer committed Feb 14, 2019
1 parent 41ab00c commit 4ced49d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
27 changes: 23 additions & 4 deletions src/Mod/TechDraw/App/DrawProjGroup.cpp
Expand Up @@ -109,6 +109,10 @@ void DrawProjGroup::onChanged(const App::Property* prop)
if (prop == &Source) {
updateChildrenSource();
}

if (prop == &LockPosition) {
updateChildrenLock();
}

if (prop == &ScaleType) {
double newScale = getScale();
Expand All @@ -129,7 +133,7 @@ void DrawProjGroup::onChanged(const App::Property* prop)
if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) {
Rotation.setValue(0.0);
purgeTouched();
Base::Console().Warning("DPG: Projection Groups do not rotate. Change ignored.\n");
Base::Console().Log("DPG: Projection Groups do not rotate. Change ignored.\n");
}
}
}
Expand Down Expand Up @@ -382,9 +386,10 @@ App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
view->LockPosition.purgeTouched();
requestPaint();
}

addView(view); //from DrawViewCollection
requestPaint();
addView(view); //from DrawViewCollection
if (view != getAnchor()) { //anchor is done elsewhere
view->recomputeFeature();
}
}

return view;
Expand Down Expand Up @@ -787,6 +792,20 @@ void DrawProjGroup::updateChildrenSource(void)
}
}

/*!
* tell children DPGIs that parent DPG has changed LockPosition
* (really for benefit of QGIV on Gui side)
*/
void DrawProjGroup::updateChildrenLock(void)
{
for( const auto it : Views.getValues() ) {
auto view( dynamic_cast<DrawProjGroupItem *>(it) );
if( view ) {
view->requestPaint();
}
}
}

/*!
* check if ProjectionGroup fits on Page
*/
Expand Down
1 change: 1 addition & 0 deletions src/Mod/TechDraw/App/DrawProjGroup.h
Expand Up @@ -160,6 +160,7 @@ class TechDrawExport DrawProjGroup : public TechDraw::DrawViewCollection
TechDraw::DrawPage * getPage(void) const;
void updateChildren(void);
void updateChildrenSource(void);
void updateChildrenLock(void);
int getViewIndex(const char *viewTypeCStr) const;

};
Expand Down
9 changes: 6 additions & 3 deletions src/Mod/TechDraw/Gui/QGIView.cpp
Expand Up @@ -144,15 +144,15 @@ QVariant QGIView::itemChange(GraphicsItemChange change, const QVariant &value)
newPos.setY(item->pos().y());
} else if(alignMode == QString::fromLatin1("45slash")) {
//this logic is wrong since the constained movement direction is not necessarily 45*
Base::Console().Message("QGIV::itemChange - oblique BL-TR\n");
// Base::Console().Message("QGIV::itemChange - oblique BL-TR\n");
// double dist = ( (newPos.x() - item->pos().x()) +
// (item->pos().y() - newPos.y()) ) / 2.0;

// newPos.setX( item->pos().x() + dist);
// newPos.setY( item->pos().y() - dist );
} else if(alignMode == QString::fromLatin1("45backslash")) {
//this logic is wrong since the constained movement direction is not necessarily 45*
Base::Console().Message("QGIV::itemChange - oblique TL-BR\n");
// Base::Console().Message("QGIV::itemChange - oblique TL-BR\n");
// double dist = ( (newPos.x() - item->pos().x()) +
// (newPos.y() - item->pos().y()) ) / 2.0;

Expand Down Expand Up @@ -274,6 +274,7 @@ QGIViewClip* QGIView::getClipGroup(void)

void QGIView::updateView(bool update)
{
// Base::Console().Message("QGIV::updateView() - %s\n",getViewObject()->getNameInDocument());
if (getViewObject()->isLocked()) {
setFlag(QGraphicsItem::ItemIsMovable, false);
} else {
Expand All @@ -287,7 +288,9 @@ void QGIView::updateView(bool update)
setPosition(featX,featY);
}

if (getViewObject()->Rotation.isTouched() ) {
double appRotation = getViewObject()->Rotation.getValue();
double guiRotation = rotation();
if (!TechDraw::DrawUtil::fpCompare(appRotation,guiRotation)) {
rotateView();
}

Expand Down

0 comments on commit 4ced49d

Please sign in to comment.