Restore secondary ortho view movement to v017 style
- this should also complete the fix for #3809
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
#include <Mod/TechDraw/App/DrawProjGroup.h>
|
||||
|
||||
#include "Rez.h"
|
||||
#include "DrawGuiUtil.h"
|
||||
#include "QGIProjGroup.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
@@ -63,7 +64,6 @@ QGIProjGroup::QGIProjGroup()
|
||||
borderVisible = false;
|
||||
}
|
||||
|
||||
|
||||
TechDraw::DrawProjGroup * QGIProjGroup::getDrawView(void) const
|
||||
{
|
||||
App::DocumentObject *obj = getViewObject();
|
||||
@@ -118,12 +118,8 @@ QVariant QGIProjGroup::itemChange(GraphicsItemChange change, const QVariant &val
|
||||
|
||||
if (type == QString::fromLatin1("Front")) {
|
||||
gView->setLocked(true); //this locks in GUI only
|
||||
fView->LockPosition.setValue(true); //lock in App also
|
||||
gView->alignTo(m_origin, QString::fromLatin1("None"));
|
||||
installSceneEventFilter(gView);
|
||||
App::DocumentObject *docObj = getViewObject();
|
||||
TechDraw::DrawProjGroup *projectionGroup = dynamic_cast<TechDraw::DrawProjGroup *>(docObj);
|
||||
projectionGroup->Anchor.setValue(fView);
|
||||
updateView();
|
||||
} else if ( type == QString::fromLatin1("Top") ||
|
||||
type == QString::fromLatin1("Bottom")) {
|
||||
gView->alignTo(m_origin, QString::fromLatin1("Vertical"));
|
||||
@@ -131,7 +127,13 @@ QVariant QGIProjGroup::itemChange(GraphicsItemChange change, const QVariant &val
|
||||
type == QString::fromLatin1("Right") ||
|
||||
type == QString::fromLatin1("Rear") ) {
|
||||
gView->alignTo(m_origin, QString::fromLatin1("Horizontal"));
|
||||
}
|
||||
} else if ( type == QString::fromLatin1("FrontTopRight") ||
|
||||
type == QString::fromLatin1("FrontBottomLeft") ) {
|
||||
gView->alignTo(m_origin, QString::fromLatin1("45slash"));
|
||||
} else if ( type == QString::fromLatin1("FrontTopLeft") ||
|
||||
type == QString::fromLatin1("FrontBottomRight") ) {
|
||||
gView->alignTo(m_origin, QString::fromLatin1("45backslash"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,24 +170,17 @@ void QGIProjGroup::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
|
||||
QGIView *qAnchor = getAnchorQItem();
|
||||
if((mousePos - event->screenPos()).manhattanLength() < 5) {
|
||||
if(qAnchor && qAnchor->shape().contains(event->pos())) {
|
||||
qAnchor->mouseReleaseEvent(event);
|
||||
event->ignore();
|
||||
qAnchor->mouseReleaseEvent(event);
|
||||
}
|
||||
} else if(scene() && qAnchor && (qAnchor == scene()->mouseGrabberItem())) {
|
||||
} else if(scene() && qAnchor) {
|
||||
// End of Drag
|
||||
Gui::Command::openCommand("Drag Projection Group");
|
||||
//TODO: See if these commands actually handle the horizontal/vertical constraints properly...
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.X = %f",
|
||||
getViewName(), Rez::appX(x()));
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Y = %f",
|
||||
getViewName(), Rez::appX(getY()));// inverts Y
|
||||
Gui::Command::commitCommand();
|
||||
//Gui::Command::updateActive();
|
||||
getViewObject()->setPosition(Rez::appX(x()),Rez::appX(getY()));
|
||||
}
|
||||
}
|
||||
QGIViewCollection::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
|
||||
QGIView * QGIProjGroup::getAnchorQItem() const
|
||||
{
|
||||
// Get the currently assigned anchor view
|
||||
|
||||
@@ -78,7 +78,7 @@ const float labelCaptionFudge = 0.2f; // temp fiddle for devel
|
||||
QGIView::QGIView()
|
||||
:QGraphicsItemGroup(),
|
||||
viewObj(nullptr),
|
||||
locked(false),
|
||||
m_locked(false),
|
||||
borderVisible(true),
|
||||
m_innerView(false)
|
||||
{
|
||||
@@ -120,12 +120,13 @@ void QGIView::alignTo(QGraphicsItem*item, const QString &alignment)
|
||||
QVariant QGIView::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
QPointF newPos(0.0,0.0);
|
||||
// if(change == ItemPositionChange && scene()) {
|
||||
if(change == ItemPositionHasChanged && scene()) {
|
||||
if(change == ItemPositionChange && scene()) {
|
||||
// if(change == ItemPositionHasChanged && scene()) {
|
||||
newPos = value.toPointF(); //position within parent!
|
||||
if(locked){
|
||||
if(m_locked){
|
||||
newPos.setX(pos().x());
|
||||
newPos.setY(pos().y());
|
||||
return newPos;
|
||||
}
|
||||
|
||||
// TODO find a better data structure for this
|
||||
@@ -133,14 +134,30 @@ QVariant QGIView::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
if (getViewObject()->isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) {
|
||||
TechDraw::DrawProjGroupItem* dpgi = static_cast<TechDraw::DrawProjGroupItem*>(getViewObject());
|
||||
TechDraw::DrawProjGroup* dpg = dpgi->getPGroup();
|
||||
if ((dpg != nullptr) && dpg->AutoDistribute.getValue()) {
|
||||
if (dpg != nullptr) {
|
||||
if(alignHash.size() == 1) { //if aligned.
|
||||
QGraphicsItem*item = alignHash.begin().value();
|
||||
QGraphicsItem* item = alignHash.begin().value();
|
||||
QString alignMode = alignHash.begin().key();
|
||||
if(alignMode == QString::fromLatin1("Vertical")) {
|
||||
newPos.setX(item->pos().x());
|
||||
} else if(alignMode == QString::fromLatin1("Horizontal")) {
|
||||
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");
|
||||
// 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");
|
||||
// double dist = ( (newPos.x() - item->pos().x()) +
|
||||
// (newPos.y() - item->pos().y()) ) / 2.0;
|
||||
|
||||
// newPos.setX( item->pos().x() + dist);
|
||||
// newPos.setY( item->pos().y() + dist );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -162,7 +179,7 @@ QVariant QGIView::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
|
||||
void QGIView::mousePressEvent(QGraphicsSceneMouseEvent * event)
|
||||
{
|
||||
if(locked) {
|
||||
if(m_locked) {
|
||||
event->ignore();
|
||||
} else {
|
||||
QGraphicsItem::mousePressEvent(event);
|
||||
@@ -176,7 +193,7 @@ void QGIView::mouseMoveEvent(QGraphicsSceneMouseEvent * event)
|
||||
|
||||
void QGIView::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
|
||||
{
|
||||
if(!locked && isSelected()) {
|
||||
if(!m_locked) {
|
||||
if (!isInnerView()) {
|
||||
double tempX = x(),
|
||||
tempY = getY();
|
||||
@@ -255,10 +272,9 @@ QGIViewClip* QGIView::getClipGroup(void)
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void QGIView::updateView(bool update)
|
||||
{
|
||||
if (getViewObject()->LockPosition.getValue()) {
|
||||
if (getViewObject()->isLocked()) {
|
||||
setFlag(QGraphicsItem::ItemIsMovable, false);
|
||||
} else {
|
||||
setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
|
||||
|
||||
void alignTo(QGraphicsItem*, const QString &alignment);
|
||||
void setLocked(bool /*state*/ = true) { locked = true; }
|
||||
void setLocked(bool b) { m_locked = b; }
|
||||
|
||||
virtual QColor getNormalColor(void);
|
||||
virtual QColor getPreColor(void);
|
||||
@@ -124,7 +124,7 @@ protected:
|
||||
QHash<QString, QGraphicsItem*> alignHash;
|
||||
//std::string alignMode;
|
||||
//QGIView* alignAnchor;
|
||||
bool locked;
|
||||
bool m_locked;
|
||||
bool borderVisible;
|
||||
bool m_visibility;
|
||||
bool m_innerView; //View is inside another View
|
||||
|
||||
@@ -66,7 +66,8 @@ ViewProviderDrawingView::ViewProviderDrawingView()
|
||||
|
||||
ADD_PROPERTY_TYPE(KeepLabel ,(false),group,App::Prop_None,"Keep Label on Page even if toggled off");
|
||||
|
||||
// Do not show in property editor why? wf
|
||||
// Do not show in property editor why? wf WF: because DisplayMode applies only to coin and we
|
||||
// don't use coin.
|
||||
DisplayMode.setStatus(App::Property::ReadOnly,true);
|
||||
m_docReady = true;
|
||||
}
|
||||
|
||||
@@ -89,19 +89,16 @@ std::vector<std::string> ViewProviderProjGroup::getDisplayModes(void) const
|
||||
|
||||
void ViewProviderProjGroup::updateData(const App::Property* prop)
|
||||
{
|
||||
Gui::ViewProviderDocumentObject::updateData(prop);
|
||||
ViewProviderDrawingView::updateData(prop);
|
||||
|
||||
if(prop == &(getObject()->Scale) ||
|
||||
prop == &(getObject()->ScaleType) ||
|
||||
prop == &(getObject()->Views) ||
|
||||
prop == &(getObject()->ProjectionType)) {
|
||||
|
||||
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
|
||||
TaskDlgProjGroup *projDlg = qobject_cast<TaskDlgProjGroup *>(dlg);
|
||||
|
||||
if (projDlg &&
|
||||
projDlg->getViewProvider() == dynamic_cast<const ViewProviderProjGroup *>(getObject()) ) {
|
||||
projDlg->update();
|
||||
prop == &(getObject()->ProjectionType) ||
|
||||
prop == &(getObject()->LockPosition) ) {
|
||||
QGIView* qgiv = getQView();
|
||||
if (qgiv) {
|
||||
qgiv->updateView(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user