Fix movement of Front View in ProjectionGroup

This commit is contained in:
wandererfan
2019-01-20 19:16:13 -05:00
committed by wmayer
parent 3564278739
commit 79504462d1
5 changed files with 18 additions and 42 deletions

View File

@@ -204,13 +204,6 @@ Base::BoundBox3d DrawProjGroup::getBoundingBox() const
bbox.Add(bb);
}
}
// This /should/ leave the centre of the bounding box at (0,0) except when
// we're in the process of updating the anchor view's position (eg called
// by moveToCentre())
if (anchorView) { //TODO: It looks like we might be getting called before an anchor view is set - weird...
bbox.MoveX(anchorView->X.getValue());
bbox.MoveY(anchorView->Y.getValue());
}
return bbox;
}
@@ -302,18 +295,6 @@ void DrawProjGroup::minimumBbViews(DrawProjGroupItem *viewPtrs[10],
height = row0h + row1h + row2h;
}
void DrawProjGroup::moveToCentre(void)
{
// Update the anchor view's X and Y to keep the bounding box centred on the origin
Base::BoundBox3d tempbbox = getBoundingBox();
DrawProjGroupItem *anchorView = dynamic_cast<DrawProjGroupItem *>(Anchor.getValue());
if (anchorView) {
anchorView->X.setValue((tempbbox.MinX + tempbbox.MaxX) / -2.0);
anchorView->Y.setValue((tempbbox.MinY + tempbbox.MaxY) / -2.0);
}
}
App::DocumentObject * DrawProjGroup::getProjObj(const char *viewProjType) const
{
for( auto it : Views.getValues() ) {
@@ -382,14 +363,16 @@ App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
view->Type.setValue( viewProjType );
view->Label.setValue( viewProjType );
view->Source.setValues( Source.getValues() );
if (strcmp(viewProjType, "Front") != 0 ) {
if (strcmp(viewProjType, "Front") != 0 ) { //not Front!
vecs = getDirsFromFront(view);
view->Direction.setValue(vecs.first);
view->RotationVector.setValue(vecs.second);
} 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.
}
addView(view); //from DrawViewCollection
moveToCentre();
if (view != getAnchor()) { //anchor is done elsewhere
view->recomputeFeature();
}
@@ -414,7 +397,6 @@ int DrawProjGroup::removeProjection(const char *viewProjType)
if ( strcmp(viewProjType, projPtr->Type.getValueAsString()) == 0 ) {
removeView(projPtr); // Remove from collection
getDocument()->removeObject( it->getNameInDocument() ); // Remove from the document
moveToCentre();
return Views.getValues().size();
}
}
@@ -517,7 +499,11 @@ std::pair<Base::Vector3d,Base::Vector3d> DrawProjGroup::getDirsFromFront(std::st
Base::Vector3d DrawProjGroup::getXYPosition(const char *viewTypeCStr)
{
Base::Vector3d result;
Base::Vector3d result(0.0,0.0,0.0);
//Front view position is always (0,0)
if (strcmp(viewTypeCStr, "Front") == 0 ) { // Front!
return result;
}
const int idxCount = 10;
DrawProjGroupItem *viewPtrs[idxCount];
arrangeViewPointers(viewPtrs);
@@ -779,11 +765,6 @@ void DrawProjGroup::updateChildren(void)
}
}
//void DrawProjGroup::updateChildren(const App::Property* prop)
//{
// view->....setValue(s)(prop->getValue(s));
//}
/*!
* tell children DPGIs that parent DPG has changed Source
*/

View File

@@ -130,9 +130,6 @@ public:
protected:
void onChanged(const App::Property* prop) override;
//! Moves anchor view to keep our bounding box centre on the origin
void moveToCentre();
/// Annoying helper - keep in sync with DrawProjGroupItem::TypeEnums
/*!
* \todo {See note regarding App::PropertyEnumeration on my wiki page http://freecadweb.org/wiki/User:Ian.rees}

View File

@@ -140,10 +140,6 @@ void DrawView::onChanged(const App::Property* prop)
}
}
}
// if (prop == &X || //nothing needs to be calculated, just the graphic needs to be shifted.
// prop == &Y) {
// requestPaint();
// }
}
App::DocumentObject::onChanged(prop);
}

View File

@@ -52,10 +52,11 @@ QGIProjGroup::QGIProjGroup()
m_origin->setParentItem(this);
// In place to ensure correct drawing and bounding box calculations
m_backgroundItem = new QGraphicsRectItem();
m_backgroundItem->setPen(QPen(QColor(Qt::black)));
// WF: obs? not even part of QGIGroup!
m_groupBackground = new QGraphicsRectItem();
m_groupBackground->setPen(QPen(QColor(Qt::black)));
//addToGroup(m_backgroundItem);
//addToGroup(m_groupBackground);
setFlag(ItemIsSelectable, false);
setFlag(ItemIsMovable, true);
setFiltersChildEvents(true);
@@ -116,7 +117,8 @@ QVariant QGIProjGroup::itemChange(GraphicsItemChange change, const QVariant &val
QString type = QString::fromLatin1(projItemPtr->Type.getValueAsString());
if (type == QString::fromLatin1("Front")) {
gView->setLocked(true);
gView->setLocked(true); //this locks in GUI only
fView->LockPosition.setValue(true); //lock in App also
installSceneEventFilter(gView);
App::DocumentObject *docObj = getViewObject();
TechDraw::DrawProjGroup *projectionGroup = dynamic_cast<TechDraw::DrawProjGroup *>(docObj);
@@ -136,7 +138,6 @@ QVariant QGIProjGroup::itemChange(GraphicsItemChange change, const QVariant &val
return QGIViewCollection::itemChange(change, value);
}
void QGIProjGroup::mousePressEvent(QGraphicsSceneMouseEvent * event)
{
QGIView *qAnchor = getAnchorQItem();
@@ -208,7 +209,7 @@ QGIView * QGIProjGroup::getAnchorQItem() const
void QGIProjGroup::updateView(bool update)
{
m_backgroundItem->setRect(boundingRect());
m_groupBackground->setRect(boundingRect());
return QGIViewCollection::updateView(update);
}
@@ -217,3 +218,4 @@ void QGIProjGroup::drawBorder()
//QGIProjGroup does not have a border!
// Base::Console().Message("TRACE - QGIProjGroup::drawBorder - doing nothing!!\n");
}

View File

@@ -67,7 +67,7 @@ private:
/// Convenience function
TechDraw::DrawProjGroup * getDrawView(void) const;
QGraphicsRectItem *m_backgroundItem;
QGraphicsRectItem *m_groupBackground;
QGraphicsItem* m_origin;
QPoint mousePos;
};