[TD]fix Dimension selection issues
This commit is contained in:
@@ -1016,43 +1016,52 @@ void MDIViewPage::blockSelection(const bool state)
|
||||
//Set all QGIViews to unselected state
|
||||
void MDIViewPage::clearSceneSelection()
|
||||
{
|
||||
blockSelection(true);
|
||||
m_sceneSelected.clear();
|
||||
// Base::Console().Message("MDIVP::clearSceneSelection()\n");
|
||||
blockSelection(true);
|
||||
m_sceneSelected.clear();
|
||||
|
||||
std::vector<QGIView *> views = m_view->getViews();
|
||||
std::vector<QGIView *> views = m_view->getViews();
|
||||
|
||||
// Iterate through all views and unselect all
|
||||
for (std::vector<QGIView *>::iterator it = views.begin(); it != views.end(); ++it) {
|
||||
QGIView *item = *it;
|
||||
bool state = item->isSelected();
|
||||
if (state) {
|
||||
item->setSelected(false);
|
||||
item->updateView();
|
||||
}
|
||||
}
|
||||
// Iterate through all views and unselect all
|
||||
for (std::vector<QGIView *>::iterator it = views.begin(); it != views.end(); ++it) {
|
||||
QGIView *item = *it;
|
||||
bool state = item->isSelected();
|
||||
|
||||
blockSelection(false);
|
||||
//handle oddballs
|
||||
QGIViewDimension* dim = dynamic_cast<QGIViewDimension*>(*it);
|
||||
if (dim != nullptr) {
|
||||
state = dim->getDatumLabel()->isSelected();
|
||||
} else {
|
||||
QGIViewBalloon* bal = dynamic_cast<QGIViewBalloon*>(*it);
|
||||
if (bal != nullptr) {
|
||||
state = bal->getBalloonLabel()->isSelected();
|
||||
}
|
||||
}
|
||||
|
||||
if (state) {
|
||||
item->setGroupSelection(false);
|
||||
item->updateView();
|
||||
}
|
||||
}
|
||||
|
||||
blockSelection(false);
|
||||
}
|
||||
|
||||
//!Update QGIView's selection state based on Selection made outside Drawing Interface
|
||||
void MDIViewPage::selectQGIView(App::DocumentObject *obj, const bool isSelected)
|
||||
{
|
||||
// Base::Console().Message("MDIVP::selectQGIV(%s) - %d\n", obj->getNameInDocument(), isSelected);
|
||||
|
||||
App::DocumentObject* objCopy = obj;
|
||||
TechDraw::DrawHatch* hatchObj = dynamic_cast<TechDraw::DrawHatch*>(objCopy);
|
||||
if (hatchObj) { //Hatch does not have a QGIV of it's own. mark parent as selected.
|
||||
objCopy = hatchObj->getSourceView(); //possible to highlight subObject?
|
||||
}
|
||||
QGIView *view = m_view->findQViewForDocObj(objCopy);
|
||||
QGIView *view = m_view->findQViewForDocObj(obj);
|
||||
|
||||
blockSelection(true);
|
||||
if(view) {
|
||||
bool state = view->isSelected();
|
||||
if (state != isSelected) {
|
||||
if (!isSelected) {
|
||||
view->setGroupSelection(false);
|
||||
} else if (state != isSelected) {
|
||||
view->setSelected(isSelected);
|
||||
view->updateView();
|
||||
}
|
||||
view->updateView();
|
||||
}
|
||||
blockSelection(false);
|
||||
}
|
||||
@@ -1074,15 +1083,16 @@ void MDIViewPage::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
}
|
||||
}
|
||||
blockSelection(false);
|
||||
} else {
|
||||
bool selectState = (msg.Type == Gui::SelectionChanges::AddSelection) ? true : false;
|
||||
} else if(msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
blockSelection(true);
|
||||
for (auto& so: selObjs){
|
||||
if (so.pObject->isDerivedFrom(TechDraw::DrawView::getClassTypeId())) {
|
||||
selectQGIView(so.pObject, selectState);
|
||||
selectQGIView(so.pObject, true);
|
||||
}
|
||||
}
|
||||
blockSelection(false);
|
||||
} else {
|
||||
Base::Console().Log("MDIVP::onSelectionChanged - unhandled: %d\n", msg.Type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1290,12 +1300,6 @@ void MDIViewPage::setTreeToSceneSelect(void)
|
||||
// Base::Console().Message("MDIVP::setTreeToScene - mText has no parent Feature\n");
|
||||
continue;
|
||||
}
|
||||
// if (!parentFeat->isDerivedFrom(TechDraw::DrawLeaderLine::getClassTypeId())) {
|
||||
// //mtext is parented to something other than Leader
|
||||
// //need special cases here?
|
||||
// Base::Console().Message("MDIVP::setTreeToScene - mText parentFeat is not LeaderLine\n");
|
||||
// continue;
|
||||
// }
|
||||
const char* name = parentFeat->getNameInDocument();
|
||||
if (!name) { //can happen during undo/redo if Dim is selected???
|
||||
// Base::Console().Message("INFO - MDIVP::sceneSelectionChanged - parentFeat name is null!\n");
|
||||
|
||||
@@ -10,6 +10,7 @@ QGraphicsItemFace: 104
|
||||
QGraphicsItemVertex: 105
|
||||
QGraphicsItemViewDimension : 106
|
||||
QGraphicsItemViewBalloon : 140
|
||||
QGraphicsItemBalloonLabel : 141
|
||||
QGraphicsItemDatumLabel : 107
|
||||
QGraphicsItemViewSection : 108
|
||||
QGraphicsItemArrow: 109
|
||||
|
||||
@@ -158,6 +158,12 @@ bool QGIView::isVisible(void)
|
||||
return result;
|
||||
}
|
||||
|
||||
//Set selection state for this and it's children
|
||||
void QGIView::setGroupSelection(bool b)
|
||||
{
|
||||
setSelected(b);
|
||||
}
|
||||
|
||||
void QGIView::alignTo(QGraphicsItem*item, const QString &alignment)
|
||||
{
|
||||
alignHash.clear();
|
||||
|
||||
@@ -83,6 +83,9 @@ public:
|
||||
virtual void drawBorder(void);
|
||||
virtual void isVisible(bool state);
|
||||
virtual bool isVisible(void);
|
||||
|
||||
virtual void setGroupSelection(bool b);
|
||||
|
||||
virtual void draw(void);
|
||||
virtual void drawCaption(void);
|
||||
virtual void rotateView(void);
|
||||
|
||||
@@ -275,6 +275,7 @@ QGIViewBalloon::QGIViewBalloon() :
|
||||
|
||||
balloonLabel->setZValue(ZVALUE::LABEL);
|
||||
arrow->setZValue(ZVALUE::DIMENSION);
|
||||
|
||||
balloonLines->setZValue(ZVALUE::DIMENSION);
|
||||
balloonLines->setStyle(Qt::SolidLine);
|
||||
|
||||
@@ -305,61 +306,44 @@ QGIViewBalloon::QGIViewBalloon() :
|
||||
this , SLOT (hover(bool)));
|
||||
|
||||
// toggleBorder(false);
|
||||
setZValue(ZVALUE::DIMENSION); //note: this won't paint dimensions over another View if it stacks
|
||||
//above this Dimension's parent view. need Layers?
|
||||
|
||||
setZValue(ZVALUE::DIMENSION);
|
||||
}
|
||||
|
||||
//from QGVP::mouseReleaseEvent - pos = eventPos
|
||||
void QGIViewBalloon::placeBalloon(QPointF pos)
|
||||
QVariant QGIViewBalloon::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
// Base::Console().Message("QGIVB::placeBalloon(%s)\n",
|
||||
// DrawUtil::formatVector(pos).c_str());
|
||||
auto balloon( dynamic_cast<TechDraw::DrawViewBalloon*>(getViewObject()) );
|
||||
if( balloon == nullptr ) {
|
||||
return;
|
||||
if (change == ItemSelectedHasChanged && scene()) {
|
||||
if(isSelected()) {
|
||||
balloonLabel->setSelected(true);
|
||||
} else {
|
||||
balloonLabel->setSelected(false);
|
||||
}
|
||||
draw();
|
||||
}
|
||||
return QGIView::itemChange(change, value);
|
||||
}
|
||||
|
||||
DrawView* balloonParent = nullptr;
|
||||
App::DocumentObject* docObj = balloon->SourceView.getValue();
|
||||
if (docObj == nullptr) {
|
||||
return;
|
||||
} else {
|
||||
balloonParent = dynamic_cast<DrawView*>(docObj);
|
||||
}
|
||||
|
||||
auto featPage = balloonParent->findParentPage();
|
||||
if (featPage == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto vp = static_cast<ViewProviderBalloon*>(getViewProvider(getViewObject()));
|
||||
if ( vp == nullptr ) {
|
||||
return;
|
||||
}
|
||||
|
||||
balloon->OriginX.setValue(Rez::appX(mapFromScene(pos).x()));
|
||||
balloon->OriginY.setValue(Rez::appX(mapFromScene(pos).y()));
|
||||
balloon->X.setValue(Rez::appX(mapFromScene(pos).x() + 200));
|
||||
balloon->Y.setValue(- Rez::appX(mapFromScene(pos).y() - 200));
|
||||
|
||||
int idx = featPage->getNextBalloonIndex();
|
||||
QString labelText = QString::number(idx);
|
||||
balloon->Text.setValue(std::to_string(idx).c_str());
|
||||
|
||||
QFont font = balloonLabel->getFont();
|
||||
font.setPixelSize(calculateFontPixelSize(vp->Fontsize.getValue()));
|
||||
font.setFamily(QString::fromUtf8(vp->Font.getValue()));
|
||||
balloonLabel->setFont(font);
|
||||
prepareGeometryChange();
|
||||
|
||||
// Default label position
|
||||
balloonLabel->setPosFromCenter(mapFromScene(pos).x() + 200, mapFromScene(pos).y() -200);
|
||||
balloonLabel->setDimString(labelText, Rez::guiX(balloon->TextWrapLen.getValue()));
|
||||
//Set selection state for this and it's children
|
||||
void QGIViewBalloon::setGroupSelection(bool b)
|
||||
{
|
||||
// Base::Console().Message("QGIVB::setGroupSelection(%d)\n",b);
|
||||
setSelected(b);
|
||||
balloonLabel->setSelected(b);
|
||||
balloonLines->setSelected(b);
|
||||
arrow->setSelected(b);
|
||||
}
|
||||
|
||||
void QGIViewBalloon::select(bool state)
|
||||
{
|
||||
// Base::Console().Message("QGIVBall::select(%d)\n", state);
|
||||
setSelected(state);
|
||||
draw();
|
||||
}
|
||||
|
||||
void QGIViewBalloon::hover(bool state)
|
||||
{
|
||||
hasHover = state;
|
||||
draw();
|
||||
}
|
||||
|
||||
void QGIViewBalloon::setViewPartFeature(TechDraw::DrawViewBalloon *balloon)
|
||||
{
|
||||
@@ -382,18 +366,6 @@ void QGIViewBalloon::setViewPartFeature(TechDraw::DrawViewBalloon *balloon)
|
||||
draw();
|
||||
}
|
||||
|
||||
void QGIViewBalloon::select(bool state)
|
||||
{
|
||||
setSelected(state);
|
||||
draw();
|
||||
}
|
||||
|
||||
void QGIViewBalloon::hover(bool state)
|
||||
{
|
||||
hasHover = state;
|
||||
draw();
|
||||
}
|
||||
|
||||
void QGIViewBalloon::updateView(bool update)
|
||||
{
|
||||
Q_UNUSED(update);
|
||||
@@ -478,6 +450,58 @@ void QGIViewBalloon::balloonLabelDragFinished()
|
||||
Gui::Command::commitCommand();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//from QGVP::mouseReleaseEvent - pos = eventPos
|
||||
void QGIViewBalloon::placeBalloon(QPointF pos)
|
||||
{
|
||||
// Base::Console().Message("QGIVB::placeBalloon(%s)\n",
|
||||
// DrawUtil::formatVector(pos).c_str());
|
||||
auto balloon( dynamic_cast<TechDraw::DrawViewBalloon*>(getViewObject()) );
|
||||
if( balloon == nullptr ) {
|
||||
return;
|
||||
}
|
||||
|
||||
DrawView* balloonParent = nullptr;
|
||||
App::DocumentObject* docObj = balloon->SourceView.getValue();
|
||||
if (docObj == nullptr) {
|
||||
return;
|
||||
} else {
|
||||
balloonParent = dynamic_cast<DrawView*>(docObj);
|
||||
}
|
||||
|
||||
auto featPage = balloonParent->findParentPage();
|
||||
if (featPage == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto vp = static_cast<ViewProviderBalloon*>(getViewProvider(getViewObject()));
|
||||
if ( vp == nullptr ) {
|
||||
return;
|
||||
}
|
||||
|
||||
balloon->OriginX.setValue(Rez::appX(mapFromScene(pos).x()));
|
||||
balloon->OriginY.setValue(Rez::appX(mapFromScene(pos).y()));
|
||||
balloon->X.setValue(Rez::appX(mapFromScene(pos).x() + 200));
|
||||
balloon->Y.setValue(- Rez::appX(mapFromScene(pos).y() - 200));
|
||||
|
||||
int idx = featPage->getNextBalloonIndex();
|
||||
QString labelText = QString::number(idx);
|
||||
balloon->Text.setValue(std::to_string(idx).c_str());
|
||||
|
||||
QFont font = balloonLabel->getFont();
|
||||
font.setPixelSize(calculateFontPixelSize(vp->Fontsize.getValue()));
|
||||
font.setFamily(QString::fromUtf8(vp->Font.getValue()));
|
||||
balloonLabel->setFont(font);
|
||||
prepareGeometryChange();
|
||||
|
||||
// Default label position
|
||||
balloonLabel->setPosFromCenter(mapFromScene(pos).x() + 200, mapFromScene(pos).y() -200);
|
||||
balloonLabel->setDimString(labelText, Rez::guiX(balloon->TextWrapLen.getValue()));
|
||||
|
||||
draw();
|
||||
}
|
||||
|
||||
void QGIViewBalloon::draw()
|
||||
{
|
||||
draw_modifier(false);
|
||||
@@ -516,7 +540,7 @@ void QGIViewBalloon::draw_modifier(bool modifier)
|
||||
}
|
||||
|
||||
m_colNormal = getNormalColor();
|
||||
balloonLabel->setColor(m_colNormal);
|
||||
// balloonLabel->setColor(m_colNormal);
|
||||
|
||||
m_lineWidth = Rez::guiX(vp->LineWidth.getValue());
|
||||
|
||||
@@ -661,19 +685,13 @@ void QGIViewBalloon::draw_modifier(bool modifier)
|
||||
arrow->setRotation(arAngle);
|
||||
arrow->show();
|
||||
|
||||
// redraw the Dimension and the parent View
|
||||
// redraw the Balloon and the parent View
|
||||
if (hasHover && !isSelected()) {
|
||||
arrow->setPrettyPre();
|
||||
balloonLines->setPrettyPre();
|
||||
balloonShape->setPrettyPre();
|
||||
setPrettyPre();
|
||||
} else if (isSelected()) {
|
||||
arrow->setPrettySel();
|
||||
balloonLines->setPrettySel();
|
||||
balloonShape->setPrettySel();
|
||||
setPrettySel();
|
||||
} else {
|
||||
arrow->setPrettyNormal();
|
||||
balloonLines->setPrettyNormal();
|
||||
balloonShape->setPrettyNormal();
|
||||
setPrettyNormal();
|
||||
}
|
||||
|
||||
update();
|
||||
@@ -681,30 +699,40 @@ void QGIViewBalloon::draw_modifier(bool modifier)
|
||||
//TODO: parent redraw still required with new frame/label??
|
||||
parentItem()->update();
|
||||
} else {
|
||||
Base::Console().Log("INFO - QGIVD::draw - no parent to update\n");
|
||||
Base::Console().Log("INFO - QGIVB::draw - no parent to update\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void QGIViewBalloon::setPrettyPre(void)
|
||||
{
|
||||
arrow->setPrettyPre();
|
||||
balloonShape->setPrettyPre();
|
||||
balloonLines->setPrettyPre();
|
||||
}
|
||||
|
||||
void QGIViewBalloon::setPrettySel(void)
|
||||
{
|
||||
// Base::Console().Message("QGIVBal::setPrettySel()\n");
|
||||
arrow->setPrettySel();
|
||||
balloonShape->setPrettySel();
|
||||
balloonLines->setPrettySel();
|
||||
}
|
||||
|
||||
void QGIViewBalloon::setPrettyNormal(void)
|
||||
{
|
||||
arrow->setPrettyNormal();
|
||||
balloonShape->setPrettyNormal();
|
||||
balloonLines->setPrettyNormal();
|
||||
}
|
||||
|
||||
|
||||
void QGIViewBalloon::drawBorder(void)
|
||||
{
|
||||
//Dimensions have no border!
|
||||
// Base::Console().Message("TRACE - QGIViewDimension::drawBorder - doing nothing!\n");
|
||||
}
|
||||
|
||||
QVariant QGIViewBalloon::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
if (change == ItemSelectedHasChanged && scene()) {
|
||||
if(isSelected()) {
|
||||
balloonLabel->setSelected(true);
|
||||
} else {
|
||||
balloonLabel->setSelected(false);
|
||||
}
|
||||
draw();
|
||||
}
|
||||
return QGIView::itemChange(change, value);
|
||||
}
|
||||
|
||||
void QGIViewBalloon::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
|
||||
QStyleOptionGraphicsItem myOption(*option);
|
||||
myOption.state &= ~QStyle::State_Selected;
|
||||
|
||||
@@ -137,15 +137,21 @@ public:
|
||||
virtual void paint( QPainter * painter,
|
||||
const QStyleOptionGraphicsItem * option,
|
||||
QWidget * widget = 0 ) override;
|
||||
|
||||
QString getLabelText(void);
|
||||
void draw_modifier(bool modifier);
|
||||
void placeBalloon(QPointF pos);
|
||||
TechDraw::DrawViewBalloon *dvBalloon;
|
||||
void setPrettyPre(void);
|
||||
void setPrettySel(void);
|
||||
void setPrettyNormal(void);
|
||||
|
||||
virtual void setGroupSelection(bool b) override;
|
||||
virtual QGIBalloonLabel* getBalloonLabel(void) { return balloonLabel; }
|
||||
|
||||
virtual QColor getNormalColor(void) override;
|
||||
int prefDefaultArrow() const;
|
||||
|
||||
|
||||
public Q_SLOTS:
|
||||
void balloonLabelDragged(bool ctrl);
|
||||
void balloonLabelDragFinished(void);
|
||||
@@ -171,7 +177,7 @@ protected:
|
||||
bool m_obtuse;
|
||||
void parentViewMousePressed(QGIView *view, QPointF pos);
|
||||
QPointF *oldLabelCenter;
|
||||
QGIView *parent;
|
||||
QGIView *parent; //used to create edit dialog
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -102,7 +102,6 @@ QGIDatumLabel::QGIDatumLabel()
|
||||
m_unitText->setParentItem(this);
|
||||
|
||||
m_ctrl = false;
|
||||
hasHover = false;
|
||||
|
||||
m_isFramed = false;
|
||||
m_lineWidth = Rez::guiX(0.5);
|
||||
@@ -146,6 +145,7 @@ void QGIDatumLabel::mouseMoveEvent(QGraphicsSceneMouseEvent * event)
|
||||
|
||||
void QGIDatumLabel::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
|
||||
{
|
||||
// Base::Console().Message("QGIDL::mouseReleaseEvent()\n");
|
||||
m_ctrl = false;
|
||||
if(scene() && this == scene()->mouseGrabberItem()) {
|
||||
Q_EMIT dragFinished();
|
||||
@@ -157,7 +157,6 @@ void QGIDatumLabel::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
|
||||
void QGIDatumLabel::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_EMIT hover(true);
|
||||
hasHover = true;
|
||||
if (!isSelected()) {
|
||||
setPrettyPre();
|
||||
} else {
|
||||
@@ -173,7 +172,6 @@ void QGIDatumLabel::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
Q_UNUSED(view);
|
||||
|
||||
Q_EMIT hover(false);
|
||||
hasHover = false;
|
||||
if (!isSelected()) {
|
||||
setPrettyNormal();
|
||||
} else {
|
||||
@@ -336,8 +334,8 @@ void QGIDatumLabel::setTolString()
|
||||
underFormat = qs2.sprintf(qsFormatUnder.toStdString().c_str(), underTol);
|
||||
#endif
|
||||
|
||||
m_tolTextOver->setHtml(overFormat);
|
||||
m_tolTextUnder->setHtml(underFormat);
|
||||
m_tolTextOver->setPlainText(overFormat);
|
||||
m_tolTextUnder->setPlainText(underFormat);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -376,14 +374,17 @@ double QGIDatumLabel::getTolAdjust(void)
|
||||
|
||||
void QGIDatumLabel::setPrettySel(void)
|
||||
{
|
||||
// Base::Console().Message("QGIDL::setPrettySel()\n");
|
||||
m_dimText->setPrettySel();
|
||||
m_tolTextOver->setPrettySel();
|
||||
m_tolTextUnder->setPrettySel();
|
||||
m_unitText->setPrettySel();
|
||||
update();
|
||||
}
|
||||
|
||||
void QGIDatumLabel::setPrettyPre(void)
|
||||
{
|
||||
// Base::Console().Message("QGIDL::setPrettyPre()\n");
|
||||
m_dimText->setPrettyPre();
|
||||
m_tolTextOver->setPrettyPre();
|
||||
m_tolTextUnder->setPrettyPre();
|
||||
@@ -392,6 +393,7 @@ void QGIDatumLabel::setPrettyPre(void)
|
||||
|
||||
void QGIDatumLabel::setPrettyNormal(void)
|
||||
{
|
||||
// Base::Console().Message("QGIDL::setPrettyNormal()\n");
|
||||
m_dimText->setPrettyNormal();
|
||||
m_tolTextOver->setPrettyNormal();
|
||||
m_tolTextUnder->setPrettyNormal();
|
||||
@@ -412,14 +414,14 @@ QGIViewDimension::QGIViewDimension() :
|
||||
hasHover(false),
|
||||
m_lineWidth(0.0)
|
||||
{
|
||||
|
||||
setHandlesChildEvents(false);
|
||||
setFlag(QGraphicsItem::ItemIsMovable, false);
|
||||
setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||
// setAcceptHoverEvents(true);
|
||||
setAcceptHoverEvents(false);
|
||||
setCacheMode(QGraphicsItem::NoCache);
|
||||
|
||||
datumLabel = new QGIDatumLabel();
|
||||
// datumLabel->m_parent = this; //for dialog setup eventually
|
||||
|
||||
addToGroup(datumLabel);
|
||||
datumLabel->setColor(getNormalColor());
|
||||
datumLabel->setPrettyNormal();
|
||||
@@ -442,9 +444,10 @@ QGIViewDimension::QGIViewDimension() :
|
||||
aHead2->setPrettyNormal();
|
||||
|
||||
datumLabel->setZValue(ZVALUE::DIMENSION);
|
||||
dimLines->setZValue(ZVALUE::DIMENSION);
|
||||
aHead1->setZValue(ZVALUE::DIMENSION);
|
||||
aHead2->setZValue(ZVALUE::DIMENSION);
|
||||
dimLines->setZValue(ZVALUE::DIMENSION);
|
||||
dimLines->setStyle(Qt::SolidLine);
|
||||
|
||||
//centerMark = new QGICMark();
|
||||
//addToGroup(centerMark);
|
||||
@@ -467,27 +470,15 @@ QGIViewDimension::QGIViewDimension() :
|
||||
datumLabel, SIGNAL(hover(bool)),
|
||||
this , SLOT (hover(bool)));
|
||||
|
||||
dimLines->setStyle(Qt::SolidLine);
|
||||
|
||||
setZValue(ZVALUE::DIMENSION); //note: this won't paint dimensions over another View if it stacks
|
||||
//above this Dimension's parent view. need Layers?
|
||||
|
||||
m_label->hide();
|
||||
m_border->hide();
|
||||
m_caption->hide();
|
||||
m_lock->hide();
|
||||
|
||||
setPrettyNormal();
|
||||
|
||||
}
|
||||
|
||||
QVariant QGIViewDimension::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
if (change == ItemSelectedHasChanged && scene()) {
|
||||
if(isSelected()) {
|
||||
setSelected(false);
|
||||
datumLabel->setSelected(true);
|
||||
|
||||
} else {
|
||||
datumLabel->setSelected(false);
|
||||
}
|
||||
@@ -496,14 +487,21 @@ QVariant QGIViewDimension::itemChange(GraphicsItemChange change, const QVariant
|
||||
return QGIView::itemChange(change, value);
|
||||
}
|
||||
|
||||
//Set selection state for this and it's children
|
||||
void QGIViewDimension::setGroupSelection(bool b)
|
||||
{
|
||||
// Base::Console().Message("QGIVD::setGroupSelection(%d)\n",b);
|
||||
setSelected(b);
|
||||
datumLabel->setSelected(b);
|
||||
dimLines->setSelected(b);
|
||||
aHead1->setSelected(b);
|
||||
aHead2->setSelected(b);
|
||||
}
|
||||
|
||||
void QGIViewDimension::select(bool state)
|
||||
{
|
||||
// Base::Console().Message("QGIVD::select(%d)\n", state);
|
||||
if (state) {
|
||||
setPrettySel();
|
||||
} else {
|
||||
setPrettyNormal();
|
||||
}
|
||||
// Base::Console().Message("QGIVDim::select(%d)\n", state);
|
||||
setSelected(state);
|
||||
draw();
|
||||
}
|
||||
|
||||
@@ -511,19 +509,6 @@ void QGIViewDimension::select(bool state)
|
||||
void QGIViewDimension::hover(bool state)
|
||||
{
|
||||
hasHover = state;
|
||||
if (state) {
|
||||
if (datumLabel->isSelected()) {
|
||||
setPrettySel();
|
||||
} else {
|
||||
setPrettyPre(); //have hover, not selected -> preselect
|
||||
}
|
||||
} else {
|
||||
if (datumLabel->isSelected()) {
|
||||
setPrettySel();
|
||||
} else {
|
||||
setPrettyNormal();
|
||||
}
|
||||
}
|
||||
draw();
|
||||
}
|
||||
|
||||
@@ -544,6 +529,15 @@ void QGIViewDimension::setViewPartFeature(TechDraw::DrawViewDimension *obj)
|
||||
draw();
|
||||
}
|
||||
|
||||
//special handling to prevent unwanted repositioning
|
||||
//clicking on the dimension, but outside the label, should do nothing to position
|
||||
//label will get clicks before QGIVDim
|
||||
void QGIViewDimension::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
|
||||
{
|
||||
// Base::Console().Message("QGIVDim::mouseReleaseEvent() - %s\n",getViewName());
|
||||
QGraphicsItem::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void QGIViewDimension::updateView(bool update)
|
||||
{
|
||||
Q_UNUSED(update);
|
||||
@@ -618,24 +612,6 @@ void QGIViewDimension::updateDim()
|
||||
datumLabel->setLineWidth(m_lineWidth);
|
||||
}
|
||||
|
||||
//this is for formatting and finding centers, not display
|
||||
QString QGIViewDimension::getLabelText(void)
|
||||
{
|
||||
QString result;
|
||||
QString first = datumLabel->getDimText()->toPlainText();
|
||||
// QString second = datumLabel->getTolText()->toPlainText();
|
||||
QString second = datumLabel->getTolTextOver()->toPlainText();
|
||||
QString third = datumLabel->getTolTextUnder()->toPlainText();
|
||||
if (second.length() > third.length()) {
|
||||
result = first + second;
|
||||
} else {
|
||||
result = first + third;
|
||||
}
|
||||
|
||||
// result = first + second;
|
||||
return result;
|
||||
}
|
||||
|
||||
void QGIViewDimension::datumLabelDragged(bool ctrl)
|
||||
{
|
||||
Q_UNUSED(ctrl);
|
||||
@@ -658,6 +634,23 @@ void QGIViewDimension::datumLabelDragFinished()
|
||||
Gui::Command::commitCommand();
|
||||
}
|
||||
|
||||
//this is for formatting and finding centers, not display
|
||||
QString QGIViewDimension::getLabelText(void)
|
||||
{
|
||||
QString result;
|
||||
QString first = datumLabel->getDimText()->toPlainText();
|
||||
// QString second = datumLabel->getTolText()->toPlainText();
|
||||
QString second = datumLabel->getTolTextOver()->toPlainText();
|
||||
QString third = datumLabel->getTolTextUnder()->toPlainText();
|
||||
if (second.length() > third.length()) {
|
||||
result = first + second;
|
||||
} else {
|
||||
result = first + third;
|
||||
}
|
||||
|
||||
// result = first + second;
|
||||
return result;
|
||||
}
|
||||
|
||||
void QGIViewDimension::draw()
|
||||
{
|
||||
@@ -694,7 +687,6 @@ void QGIViewDimension::draw()
|
||||
m_lineWidth = Rez::guiX(vp->LineWidth.getValue());
|
||||
m_colNormal = getNormalColor();
|
||||
|
||||
datumLabel->setColor(m_colNormal);
|
||||
datumLabel->setRotation(0.0);
|
||||
datumLabel->show();
|
||||
|
||||
@@ -728,6 +720,14 @@ void QGIViewDimension::draw()
|
||||
drawArrows(0, nullptr, nullptr, false);
|
||||
}
|
||||
|
||||
if (isSelected()) {
|
||||
setPrettySel();
|
||||
} else if (hasHover) {
|
||||
setPrettyPre();
|
||||
} else {
|
||||
setPrettyNormal();
|
||||
}
|
||||
|
||||
update();
|
||||
if (parentItem()) {
|
||||
//TODO: parent redraw still required with new frame/label??
|
||||
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
void setTolTextUnder(QGCustomText* newTol) { m_tolTextOver = newTol; }
|
||||
|
||||
double getTolAdjust(void);
|
||||
bool hasHover;
|
||||
/* bool hasHover;*/
|
||||
|
||||
bool isFramed(void) { return m_isFramed; }
|
||||
void setFramed(bool framed) { m_isFramed = framed; }
|
||||
@@ -160,6 +160,8 @@ public:
|
||||
void setPrettySel(void);
|
||||
void setPrettyNormal(void);
|
||||
|
||||
virtual void setGroupSelection(bool b) override;
|
||||
virtual QGIDatumLabel* getDatumLabel(void) { return datumLabel; }
|
||||
|
||||
public Q_SLOTS:
|
||||
void datumLabelDragged(bool ctrl);
|
||||
@@ -243,7 +245,9 @@ protected:
|
||||
Base::Vector3d findIsoDir(Base::Vector3d ortho);
|
||||
Base::Vector3d findIsoExt(Base::Vector3d isoDir);
|
||||
QString getPrecision(void);
|
||||
|
||||
|
||||
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * event) override;
|
||||
|
||||
protected:
|
||||
bool hasHover;
|
||||
QGIDatumLabel* datumLabel; //dimension text
|
||||
@@ -275,6 +279,8 @@ private:
|
||||
double getDefaultAsmeHorizontalLeaderLength() const;
|
||||
double getDefaultAsmeExtensionLineGap() const;
|
||||
|
||||
/* QGIView* m_parent; //for edit dialog set up eventually*/
|
||||
|
||||
};
|
||||
|
||||
} // namespace MDIViewPageGui
|
||||
|
||||
Reference in New Issue
Block a user