Fix iso View position in AutoDistribute

This commit is contained in:
wandererfan
2018-07-28 20:21:04 -04:00
committed by Yorik van Havre
parent 5380a03266
commit f9aa3ea957
6 changed files with 23 additions and 57 deletions

View File

@@ -515,51 +515,57 @@ Base::Vector3d DrawProjGroup::getXYPosition(const char *viewTypeCStr)
bigRow = bigCol;
}
if (viewPtrs[0] &&
if (viewPtrs[0] && //iso
bboxes[0].IsValid()) {
position[0].x = -bigCol - xSpacing;
position[0].y = bigRow + ySpacing;
}
if (viewPtrs[1] &&
if (viewPtrs[1] && // T/B
bboxes[1].IsValid()) {
position[1].x = 0.0;
position[1].y = bigRow + ySpacing;
}
if (viewPtrs[2] &&
if (viewPtrs[2] && //iso
bboxes[2].IsValid()) {
position[2].x = bigCol + xSpacing;
position[2].y = bigRow + ySpacing;
}
if (viewPtrs[3] &&
if (viewPtrs[3] && // L/R
bboxes[3].IsValid() &&
bboxes[4].IsValid()) {
position[3].x = -bigCol - xSpacing;
position[3].y = 0.0;
}
if (viewPtrs[5] &&
if (viewPtrs[5] && // R/L
bboxes[5].IsValid() &&
bboxes[4].IsValid()) {
position[5].x = bigCol + xSpacing;
position[5].y = 0.0;
}
if (viewPtrs[6] &&
bboxes[6].IsValid()) { //"Rear"
if (viewPtrs[5] &&
bboxes[5].IsValid()) {
position[6].x = position[5].x + bigCol + xSpacing;
position[6].y = 0.0;
}else if (viewPtrs[4] &&
bboxes[4].IsValid()) {
position[6].x = bigCol + xSpacing;
position[6].y = 0.0;
}
}
if (viewPtrs[7] &&
bboxes[7].IsValid()) {
position[7].x = -bigCol - xSpacing;
bboxes[7].IsValid()) { //iso
position[7].x = -bigCol - xSpacing;
position[7].y = -bigRow - ySpacing;
}
if (viewPtrs[8] &&
if (viewPtrs[8] && // B/T
bboxes[8].IsValid() &&
bboxes[4].IsValid()) {
position[8].x = 0.0;
position[8].y = -bigRow - ySpacing;
}
if (viewPtrs[9] &&
if (viewPtrs[9] && //iso
bboxes[9].IsValid()) {
position[9].x = bigCol + xSpacing;
position[9].y = -bigRow - ySpacing;

View File

@@ -68,8 +68,6 @@ App::PropertyFloatConstraint::Constraints DrawView::scaleRange = {Precision::Con
PROPERTY_SOURCE(TechDraw::DrawView, App::DocumentObject)
DrawView::DrawView(void)
: autoPos(true),
mouseMove(false)
{
static const char *group = "Base";

View File

@@ -76,10 +76,6 @@ public:
virtual PyObject *getPyObject(void) override;
DrawPage* findParentPage() const;
bool allowAutoPos() {return autoPos;} //sb in DPGI??
void setAutoPos(bool state) {autoPos = state;} //autopos is obsolete
bool isMouseMove() {return mouseMove;}
void setMouseMove(bool state) {mouseMove = state;}
virtual QRectF getRect() const; //must be overridden by derived class
virtual double autoScale(double w, double h) const;
virtual bool checkFit(DrawPage*) const;

View File

@@ -48,8 +48,8 @@ using namespace TechDrawGui;
QGIProjGroup::QGIProjGroup()
{
origin = new QGraphicsItemGroup();
origin->setParentItem(this);
m_origin = new QGraphicsItemGroup(); //QGIG added to this QGIG??
m_origin->setParentItem(this);
// In place to ensure correct drawing and bounding box calculations
m_backgroundItem = new QGraphicsRectItem();
@@ -124,18 +124,12 @@ QVariant QGIProjGroup::itemChange(GraphicsItemChange change, const QVariant &val
updateView();
} else if ( type == QString::fromLatin1("Top") ||
type == QString::fromLatin1("Bottom")) {
gView->alignTo(origin, QString::fromLatin1("Vertical"));
gView->alignTo(m_origin, QString::fromLatin1("Vertical"));
} else if ( type == QString::fromLatin1("Left") ||
type == QString::fromLatin1("Right") ||
type == QString::fromLatin1("Rear") ) {
gView->alignTo(origin, QString::fromLatin1("Horizontal"));
} else if ( type == QString::fromLatin1("FrontTopRight") ||
type == QString::fromLatin1("FrontBottomLeft") ) {
gView->alignTo(origin, QString::fromLatin1("45slash"));
} else if ( type == QString::fromLatin1("FrontTopLeft") ||
type == QString::fromLatin1("FrontBottomRight") ) {
gView->alignTo(origin, QString::fromLatin1("45backslash"));
}
gView->alignTo(m_origin, QString::fromLatin1("Horizontal"));
}
}
}
}
@@ -149,7 +143,6 @@ void QGIProjGroup::mousePressEvent(QGraphicsSceneMouseEvent * event)
if(qAnchor) {
QPointF transPos = qAnchor->mapFromScene(event->scenePos());
if(qAnchor->shape().contains(transPos)) {
//QGIViewCollection::mousePressEvent(event);
mousePos = event->screenPos();
}
}

View File

@@ -68,7 +68,7 @@ private:
TechDraw::DrawProjGroup * getDrawView(void) const;
QGraphicsRectItem *m_backgroundItem;
QGraphicsItem *origin;
QGraphicsItem* m_origin;
QPoint mousePos;
};

View File

@@ -79,9 +79,6 @@ QGIView::QGIView()
locked(false),
borderVisible(true),
m_innerView(false)
//isAligned(false)
//alignMode("")
//alignAnchor(nullptr)
{
setCacheMode(QGraphicsItem::NoCache);
setHandlesChildEvents(false);
@@ -114,9 +111,6 @@ QGIView::QGIView()
void QGIView::alignTo(QGraphicsItem*item, const QString &alignment)
{
// isAligned = true;
// alignMode = alignment.toStdString();
// alignAnchor = item;
alignHash.clear();
alignHash.insert(alignment, item);
}
@@ -130,7 +124,6 @@ QVariant QGIView::itemChange(GraphicsItemChange change, const QVariant &value)
newPos.setX(pos().x());
newPos.setY(pos().y());
}
// TODO find a better data structure for this
// this is just a pair isn't it?
if (getViewObject()->isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) {
@@ -140,23 +133,10 @@ QVariant QGIView::itemChange(GraphicsItemChange change, const QVariant &value)
if(alignHash.size() == 1) { //if aligned.
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")) {
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")) {
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 );
}
}
}
@@ -193,7 +173,6 @@ void QGIView::mouseMoveEvent(QGraphicsSceneMouseEvent * event)
void QGIView::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
{
if(!locked && isSelected()) {
getViewObject()->setMouseMove(true);
if (!isInnerView()) {
double tempX = x(),
tempY = getY();
@@ -201,7 +180,6 @@ void QGIView::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
} else {
getViewObject()->setPosition(Rez::appX(x()),Rez::appX(getYInClip(y())));
}
getViewObject()->setMouseMove(false);
}
QGraphicsItem::mouseReleaseEvent(event);
}
@@ -214,9 +192,6 @@ void QGIView::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
m_colCurrent = getSelectColor();
} else {
m_colCurrent = getPreColor();
//if(shape().contains(event->pos())) { // TODO don't like this for determining preselect (MLP)
// m_colCurrent = getPreColor();
//}
}
drawBorder();
}
@@ -308,8 +283,6 @@ const std::string QGIView::getViewNameAsString() const
TechDraw::DrawView * QGIView::getViewObject() const
{
//DocumentObject* obj = doc->getObject(viewName.c_str());
//TechDraw::DrawView* dv = static_cast<TechDraw::DrawView*>(obj);
return viewObj;
}
@@ -356,7 +329,7 @@ void QGIView::drawCaption()
QRectF displayArea = customChildrenBoundingRect();
m_caption->setDefaultTextColor(m_colCurrent);
m_font.setFamily(getPrefFont());
m_font.setPointSize(getPrefFontSize()); //scene units (mm), not points
m_font.setPointSize(getPrefFontSize()); //scene units (0.1 mm), not points
m_caption->setFont(m_font);
QString captionStr = QString::fromUtf8(getViewObject()->Caption.getValue());
m_caption->setPlainText(captionStr);
@@ -391,7 +364,7 @@ void QGIView::drawBorder()
m_label->setDefaultTextColor(m_colCurrent);
m_font.setFamily(getPrefFont());
m_font.setPointSize(getPrefFontSize()); //scene units (mm), not points
m_font.setPointSize(getPrefFontSize()); //scene units (0.1 mm), not points
m_label->setFont(m_font);
QString labelStr = QString::fromUtf8(getViewObject()->Label.getValue());
m_label->setPlainText(labelStr);