[TechDraw] Reimplement Leader Line parent linking
This commit is contained in:
@@ -65,6 +65,8 @@ public:
|
||||
Base::Vector3d getAttachPoint();
|
||||
DrawView* getBaseView() const;
|
||||
virtual App::DocumentObject* getBaseObject() const;
|
||||
App::PropertyLink *getOwnerProperty() override { return &LeaderParent; }
|
||||
|
||||
bool keepUpdated() override;
|
||||
double getScale() const override;
|
||||
double getBaseScale() const;
|
||||
|
||||
@@ -52,8 +52,7 @@ using namespace TechDraw;
|
||||
|
||||
//**************************************************************
|
||||
QGILeaderLine::QGILeaderLine()
|
||||
: m_parentItem(nullptr),
|
||||
m_lineColor(Qt::black),
|
||||
: m_lineColor(Qt::black),
|
||||
m_lineStyle(Qt::SolidLine),
|
||||
m_hasHover(false),
|
||||
m_saveX(0.0),
|
||||
@@ -169,22 +168,6 @@ void QGILeaderLine::hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
|
||||
QGIView::hoverLeaveEvent(event);
|
||||
}
|
||||
|
||||
void QGILeaderLine::onSourceChange(TechDraw::DrawView* newParent)
|
||||
{
|
||||
// Base::Console().Message("QGILL::onSoureChange(%s)\n", newParent->getNameInDocument());
|
||||
std::string parentName = newParent->getNameInDocument();
|
||||
QGIView* qgiParent = getQGIVByName(parentName);
|
||||
if (qgiParent) {
|
||||
m_parentItem = qgiParent;
|
||||
setParentItem(m_parentItem);
|
||||
draw();
|
||||
}
|
||||
else {
|
||||
Base::Console().Warning("QGILL::onSourceChange - new parent %s has no QGIView\n",
|
||||
parentName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void QGILeaderLine::setNormalColorAll()
|
||||
{
|
||||
// Base::Console().Message("QGILL::setNormalColorAll - normal color: %s\n", qPrintable(getNormalColor().name()));
|
||||
|
||||
@@ -100,7 +100,6 @@ public:
|
||||
public Q_SLOTS:
|
||||
void onLineEditFinished(QPointF tipDisplace,
|
||||
std::vector<QPointF> points);//QGEPath is finished editing points
|
||||
void onSourceChange(TechDraw::DrawView* newParent) override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void editComplete();//tell caller that edit session is finished
|
||||
@@ -121,7 +120,6 @@ protected:
|
||||
|
||||
private:
|
||||
std::vector<QPointF> m_pathPoints;
|
||||
QGraphicsItem* m_parentItem;
|
||||
QGIPrimPath* m_line;//actual leader line
|
||||
QColor m_lineColor;
|
||||
Qt::PenStyle m_lineStyle;
|
||||
|
||||
@@ -103,11 +103,6 @@ QGIView::QGIView()
|
||||
m_lock->hide();
|
||||
}
|
||||
|
||||
void QGIView::onSourceChange(TechDraw::DrawView* newParent)
|
||||
{
|
||||
Q_UNUSED(newParent);
|
||||
}
|
||||
|
||||
void QGIView::isVisible(bool state)
|
||||
{
|
||||
auto feat = getViewObject();
|
||||
|
||||
@@ -163,9 +163,6 @@ public:
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
|
||||
public Q_SLOTS:
|
||||
virtual void onSourceChange(TechDraw::DrawView* newParent);
|
||||
|
||||
protected:
|
||||
QGIView* getQGIVByName(std::string name);
|
||||
|
||||
|
||||
@@ -130,7 +130,6 @@ void QGSPage::addChildrenToPage()
|
||||
//therefore we need to make sure parentage of the graphics representation is set properly. bit of a kludge.
|
||||
setDimensionGroups();
|
||||
setBalloonGroups();
|
||||
setLeaderGroups();
|
||||
|
||||
App::DocumentObject* obj = m_vpPage->getDrawPage()->Template.getValue();
|
||||
auto pageTemplate(dynamic_cast<TechDraw::DrawTemplate*>(obj));
|
||||
@@ -606,29 +605,11 @@ void QGSPage::addDimToParent(QGIViewDimension* dim, QGIView* parent)
|
||||
|
||||
QGIView* QGSPage::addViewLeader(TechDraw::DrawLeaderLine* leaderFeat)
|
||||
{
|
||||
// Base::Console().Message("QGSP::addViewLeader(%s)\n", leader->getNameInDocument());
|
||||
QGILeaderLine* leaderGroup = new QGILeaderLine();
|
||||
addItem(leaderGroup);
|
||||
QGILeaderLine *leaderView = new QGILeaderLine;
|
||||
leaderView->setViewFeature(leaderFeat);
|
||||
|
||||
leaderGroup->setLeaderFeature(leaderFeat);
|
||||
|
||||
QGIView* parent = nullptr;
|
||||
parent = findParent(leaderGroup);
|
||||
|
||||
if (parent) {
|
||||
addLeaderToParent(leaderGroup, parent);
|
||||
}
|
||||
|
||||
leaderGroup->updateView(true);
|
||||
|
||||
return leaderGroup;
|
||||
}
|
||||
|
||||
void QGSPage::addLeaderToParent(QGILeaderLine* lead, QGIView* parent)
|
||||
{
|
||||
// Base::Console().Message("QGSP::addLeaderToParent()\n");
|
||||
parent->addToGroup(lead);
|
||||
lead->setZValue(ZVALUE::DIMENSION);
|
||||
addQView(leaderView);
|
||||
return leaderView;
|
||||
}
|
||||
|
||||
QGIView* QGSPage::addRichAnno(TechDraw::DrawRichAnno* richFeat)
|
||||
@@ -698,25 +679,6 @@ void QGSPage::setBalloonGroups(void)
|
||||
}
|
||||
}
|
||||
|
||||
void QGSPage::setLeaderGroups(void)
|
||||
{
|
||||
// Base::Console().Message("QGSP::setLeaderGroups()\n");
|
||||
const std::vector<QGIView*>& allItems = getViews();
|
||||
int leadItemType = QGraphicsItem::UserType + 232;
|
||||
|
||||
//make sure that qgileader belongs to correct parent.
|
||||
//quite possibly redundant
|
||||
for (auto& item : allItems) {
|
||||
if (item->type() == leadItemType && !item->group()) {
|
||||
QGIView* parent = findParent(item);
|
||||
if (parent) {
|
||||
QGILeaderLine* lead = dynamic_cast<QGILeaderLine*>(item);
|
||||
addLeaderToParent(lead, parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! find the graphic for a DocumentObject
|
||||
QGIView* QGSPage::findQViewForDocObj(App::DocumentObject* obj) const
|
||||
{
|
||||
@@ -799,23 +761,6 @@ QGIView* QGSPage::findParent(QGIView* view) const
|
||||
}
|
||||
}
|
||||
|
||||
//If type is LeaderLine we check LeaderParent
|
||||
TechDraw::DrawLeaderLine* lead = nullptr;
|
||||
lead = dynamic_cast<TechDraw::DrawLeaderLine*>(myFeat);
|
||||
|
||||
if (lead) {
|
||||
App::DocumentObject* obj = lead->LeaderParent.getValue();
|
||||
if (obj) {
|
||||
std::string parentName = obj->getNameInDocument();
|
||||
for (std::vector<QGIView*>::const_iterator it = qviews.begin(); it != qviews.end();
|
||||
++it) {
|
||||
if (strcmp((*it)->getViewName(), parentName.c_str()) == 0) {
|
||||
return *it;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if part of view collection
|
||||
for (std::vector<QGIView*>::const_iterator it = qviews.begin(); it != qviews.end(); ++it) {
|
||||
QGIViewCollection* grp = nullptr;
|
||||
|
||||
@@ -65,7 +65,6 @@ class QGIViewDimension;
|
||||
class QGITemplate;
|
||||
class ViewProviderPage;
|
||||
class QGIViewBalloon;
|
||||
class QGILeaderLine;
|
||||
class QGITile;
|
||||
|
||||
class TechDrawGuiExport QGSPage: public QGraphicsScene
|
||||
@@ -111,7 +110,6 @@ public:
|
||||
void createBalloon(QPointF origin, TechDraw::DrawView* parent);
|
||||
|
||||
void addDimToParent(QGIViewDimension* dim, QGIView* parent);
|
||||
void addLeaderToParent(QGILeaderLine* lead, QGIView* parent);
|
||||
|
||||
std::vector<QGIView*> getViews() const;
|
||||
|
||||
@@ -139,7 +137,6 @@ public:
|
||||
|
||||
void setDimensionGroups();
|
||||
void setBalloonGroups();
|
||||
void setLeaderGroups();
|
||||
|
||||
protected:
|
||||
QColor getBackgroundColor();
|
||||
|
||||
@@ -102,23 +102,6 @@ bool ViewProviderLeader::doubleClicked()
|
||||
return true;
|
||||
}
|
||||
|
||||
void ViewProviderLeader::updateData(const App::Property* p)
|
||||
{
|
||||
if (!getFeature()->isRestoring()) {
|
||||
if (p == &getFeature()->LeaderParent) {
|
||||
App::DocumentObject* docObj = getFeature()->LeaderParent.getValue();
|
||||
TechDraw::DrawView* dv = dynamic_cast<TechDraw::DrawView*>(docObj);
|
||||
if (dv) {
|
||||
QGIView* qgiv = getQView();
|
||||
if (qgiv) {
|
||||
qgiv->onSourceChange(dv);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ViewProviderDrawingView::updateData(p);
|
||||
}
|
||||
|
||||
void ViewProviderLeader::onChanged(const App::Property* p)
|
||||
{
|
||||
if ((p == &Color) ||
|
||||
|
||||
@@ -55,7 +55,6 @@ public:
|
||||
App::PropertyColor Color;
|
||||
|
||||
bool useNewSelectionModel() const override {return false;}
|
||||
void updateData(const App::Property*) override;
|
||||
void onChanged(const App::Property* p) override;
|
||||
bool setEdit(int ModNum) override;
|
||||
bool doubleClicked() override;
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/ViewProviderDocumentObject.h>
|
||||
#include <Mod/TechDraw/App/DrawHatch.h>
|
||||
#include <Mod/TechDraw/App/DrawLeaderLine.h>
|
||||
#include <Mod/TechDraw/App/DrawPage.h>
|
||||
#include <Mod/TechDraw/App/DrawProjGroupItem.h>
|
||||
#include <Mod/TechDraw/App/DrawTemplate.h>
|
||||
@@ -392,7 +391,6 @@ std::vector<App::DocumentObject*> ViewProviderPage::claimChildren(void) const
|
||||
// for Page, valid children are any View except: DrawProjGroupItem
|
||||
// DrawViewDimension
|
||||
// DrawViewBalloon
|
||||
// DrawLeaderLine
|
||||
// any FeatuerView in a DrawViewClip
|
||||
// DrawHatch
|
||||
// DrawWeldSymbol
|
||||
@@ -415,7 +413,6 @@ std::vector<App::DocumentObject*> ViewProviderPage::claimChildren(void) const
|
||||
|| docObj->isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId())
|
||||
|| docObj->isDerivedFrom(TechDraw::DrawHatch::getClassTypeId())
|
||||
|| docObj->isDerivedFrom(TechDraw::DrawViewBalloon::getClassTypeId())
|
||||
|| docObj->isDerivedFrom(TechDraw::DrawLeaderLine::getClassTypeId())
|
||||
|| docObj->isDerivedFrom(TechDraw::DrawWeldSymbol::getClassTypeId())
|
||||
|| (featView && featView->isInClip()))
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user