Fix Leader point edit
This commit is contained in:
@@ -43,7 +43,8 @@
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
QGMarker::QGMarker(int idx) : QGIVertex(idx)
|
||||
QGMarker::QGMarker(int idx) : QGIVertex(idx),
|
||||
m_dragging(false)
|
||||
{
|
||||
// Base::Console().Message("QGMarker::QGMarker(%d)\n", idx);
|
||||
setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||
@@ -77,6 +78,8 @@ void QGMarker::mousePressEvent(QGraphicsSceneMouseEvent * event)
|
||||
event->accept();
|
||||
return;
|
||||
} else if(scene() && this == scene()->mouseGrabberItem()) {
|
||||
//start dragging
|
||||
m_dragging = true;
|
||||
QPointF mapped = mapToParent(event->pos());
|
||||
Q_EMIT dragging(mapped, getProjIndex());
|
||||
}
|
||||
@@ -94,16 +97,20 @@ void QGMarker::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
|
||||
// Base::Console().Message("QGMarker::mouseReleaseEvent(%d) - focus: %d\n", getProjIndex(), hasFocus());
|
||||
if (event->button() == Qt::RightButton) { //we're done
|
||||
Q_EMIT endEdit();
|
||||
event->accept(); //this is mine!
|
||||
m_dragging = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if(this->scene() && this == this->scene()->mouseGrabberItem()) {
|
||||
QPointF mapped = mapToParent(event->pos());
|
||||
Q_EMIT dragFinished(mapped, getProjIndex());
|
||||
event->accept();
|
||||
if (m_dragging) {
|
||||
m_dragging = false;
|
||||
setSelected(false);
|
||||
QPointF mapped = mapToParent(event->pos());
|
||||
Q_EMIT dragFinished(mapped, getProjIndex());
|
||||
}
|
||||
} else {
|
||||
Base::Console().Message("QGMarker::mouseReleaseEvent - not mouse grabber\n");
|
||||
}
|
||||
|
||||
QGIVertex::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
@@ -112,7 +119,6 @@ void QGMarker::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event)
|
||||
// Base::Console().Message("QGMarker::mouseDoubleClickEvent(%d)\n",getProjIndex());
|
||||
if (event->button() == Qt::RightButton) { //we're done
|
||||
Q_EMIT endEdit();
|
||||
event->accept(); //this is mine!
|
||||
return;
|
||||
}
|
||||
QGIVertex::mouseDoubleClickEvent(event);
|
||||
@@ -382,7 +388,7 @@ void QGEPath::makeDeltasFromPoints(std::vector<QPointF> pts)
|
||||
m_deltas = deltas;
|
||||
}
|
||||
|
||||
//tell parent points editing is finished
|
||||
//announce points editing is finished
|
||||
void QGEPath::updateFeature(void)
|
||||
{
|
||||
// Base::Console().Message("QGEPath::updateFeature()\n");
|
||||
|
||||
@@ -72,6 +72,7 @@ protected:
|
||||
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
|
||||
private:
|
||||
bool m_dragging;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -160,19 +160,37 @@ void QGILeaderLine::hover(bool state)
|
||||
|
||||
void QGILeaderLine::onLineEditFinished(std::vector<QPointF> pts)
|
||||
{
|
||||
// Base::Console().Message("QGIVL::onLineEditFinished(%d)\n",pts.size());
|
||||
// Base::Console().Message("QGILL::onLineEditFinished(%d)\n",pts.size());
|
||||
QPointF p0 = pts.front();
|
||||
if ( !(TechDraw::DrawUtil::fpCompare(p0.x(),0.0) &&
|
||||
TechDraw::DrawUtil::fpCompare(p0.y(),0.0)) ) {
|
||||
//p0 was moved. need to change AttachPoint and intervals from p0
|
||||
QPointF mapped = m_parentItem->mapFromItem(this,p0);
|
||||
Base::Vector3d attachPoint = Base::Vector3d(mapped.x(),mapped.y(),0.0);
|
||||
for (auto& p : pts) {
|
||||
p -= p0;
|
||||
}
|
||||
pts.at(0) = QPointF(0.0,0.0);
|
||||
getFeature()->setPosition(Rez::appX(attachPoint.x),Rez::appX(- attachPoint.y), true);
|
||||
}
|
||||
|
||||
std::vector<Base::Vector3d> waypoints;
|
||||
for (auto& p: pts) {
|
||||
Base::Vector3d v(p.x(),p.y(),0.0);
|
||||
waypoints.push_back(v);
|
||||
}
|
||||
|
||||
getFeature()->WayPoints.setValues(waypoints);
|
||||
if (getFeature()->AutoHorizontal.getValue()) {
|
||||
getFeature()->adjustLastSegment();
|
||||
}
|
||||
|
||||
if (m_parentItem == nullptr) {
|
||||
Base::Console().Log("QGILL::onLineEditFinished - m_parentItem is NULL\n");
|
||||
} else {
|
||||
QGIView* qgiv = dynamic_cast<QGIView*>(m_parentItem);
|
||||
if (qgiv != nullptr) {
|
||||
Q_EMIT editComplete(pts, qgiv); //leader's parent if QGIView
|
||||
Q_EMIT editComplete(pts, qgiv);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -230,6 +248,11 @@ void QGILeaderLine::draw()
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_line->inEdit()) {
|
||||
Base::Console().Log("QGIL::draw - m_line is in edit\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (leadFeat->isLocked()) {
|
||||
setFlag(QGraphicsItem::ItemIsMovable, false);
|
||||
} else {
|
||||
@@ -264,7 +287,7 @@ void QGILeaderLine::draw()
|
||||
m_line->setNormalColor(m_lineColor);
|
||||
scale = getScale();
|
||||
m_line->setScale(scale);
|
||||
m_line->makeDeltasFromPoints(qPoints);
|
||||
m_line->makeDeltasFromPoints(qPoints); //this is what messes up edit!??
|
||||
m_line->setPos(0,0);
|
||||
m_line->updatePath();
|
||||
m_line->show();
|
||||
|
||||
@@ -247,7 +247,13 @@ void TaskLeaderLine::createLeaderFeature(std::vector<Base::Vector3d> converted)
|
||||
}
|
||||
if (obj->isDerivedFrom(TechDraw::DrawLeaderLine::getClassTypeId())) {
|
||||
m_lineFeat = static_cast<TechDraw::DrawLeaderLine*>(obj);
|
||||
commonFeatureUpdate(converted);
|
||||
if (!converted.empty()) {
|
||||
m_lineFeat->WayPoints.setValues(converted);
|
||||
if (m_lineFeat->AutoHorizontal.getValue()) {
|
||||
m_lineFeat->adjustLastSegment();
|
||||
}
|
||||
}
|
||||
commonFeatureUpdate();
|
||||
}
|
||||
|
||||
Gui::Command::updateActive();
|
||||
@@ -255,11 +261,12 @@ void TaskLeaderLine::createLeaderFeature(std::vector<Base::Vector3d> converted)
|
||||
m_lineFeat->requestPaint();
|
||||
}
|
||||
|
||||
void TaskLeaderLine::updateLeaderFeature(std::vector<Base::Vector3d> converted)
|
||||
void TaskLeaderLine::updateLeaderFeature(void)
|
||||
{
|
||||
// Base::Console().Message("TTL::updateLeaderFeature(%d)\n",converted.size());
|
||||
Gui::Command::openCommand("Edit Leader");
|
||||
commonFeatureUpdate(converted);
|
||||
//waypoints & x,y are updated by QGILeaderLine
|
||||
commonFeatureUpdate();
|
||||
App::Color ac;
|
||||
ac.setValue<QColor>(ui->cpLineColor->color());
|
||||
m_lineVP->Color.setValue(ac);
|
||||
@@ -270,16 +277,16 @@ void TaskLeaderLine::updateLeaderFeature(std::vector<Base::Vector3d> converted)
|
||||
m_lineFeat->requestPaint();
|
||||
}
|
||||
|
||||
void TaskLeaderLine::commonFeatureUpdate(std::vector<Base::Vector3d> converted)
|
||||
void TaskLeaderLine::commonFeatureUpdate(void)
|
||||
{
|
||||
// Base::Console().Message("TTL::commonFeatureUpdate()\n");
|
||||
m_lineFeat->setPosition(Rez::appX(m_attachPoint.x),Rez::appX(- m_attachPoint.y), true);
|
||||
if (!converted.empty()) {
|
||||
m_lineFeat->WayPoints.setValues(converted);
|
||||
if (m_lineFeat->AutoHorizontal.getValue()) {
|
||||
m_lineFeat->adjustLastSegment();
|
||||
}
|
||||
}
|
||||
// m_lineFeat->setPosition(Rez::appX(m_attachPoint.x),Rez::appX(- m_attachPoint.y), true);
|
||||
// if (!converted.empty()) {
|
||||
// m_lineFeat->WayPoints.setValues(converted);
|
||||
// if (m_lineFeat->AutoHorizontal.getValue()) {
|
||||
// m_lineFeat->adjustLastSegment();
|
||||
// }
|
||||
// }
|
||||
int start = ui->cboxStartSym->currentIndex() - 1;
|
||||
int end = ui->cboxEndSym->currentIndex() - 1;
|
||||
m_lineFeat->StartSymbol.setValue(start);
|
||||
@@ -524,13 +531,14 @@ void TaskLeaderLine::convertTrackerPoints(std::vector<QPointF> pts)
|
||||
void TaskLeaderLine::onPointEditComplete(std::vector<QPointF> pts, QGIView* parent)
|
||||
{
|
||||
// Base::Console().Message("TTL::onPointEditComplete(%d)\n", pts.size());
|
||||
|
||||
if (pts.empty()) {
|
||||
return;
|
||||
}
|
||||
QPointF p0 = pts.front();
|
||||
|
||||
if (parent == nullptr) {
|
||||
// Base::Console().Message("TTL::onPointEditComplete - passed parent is NULL!\n");
|
||||
Base::Console().Message("TTL::onPointEditComplete - passed parent is NULL!\n");
|
||||
} else {
|
||||
m_qgParent = parent;
|
||||
// double scale = m_qgParent->getScale();
|
||||
@@ -608,7 +616,7 @@ bool TaskLeaderLine::accept()
|
||||
if (!doc) return false;
|
||||
|
||||
if (!getCreateMode()) {
|
||||
updateLeaderFeature(m_trackerPoints);
|
||||
updateLeaderFeature();
|
||||
} else {
|
||||
removeTracker();
|
||||
createLeaderFeature(m_trackerPoints);
|
||||
|
||||
@@ -103,8 +103,8 @@ protected:
|
||||
void abandonEditSession(void);
|
||||
|
||||
void createLeaderFeature(std::vector<Base::Vector3d> converted);
|
||||
void updateLeaderFeature(std::vector<Base::Vector3d> converted);
|
||||
void commonFeatureUpdate(std::vector<Base::Vector3d> converted);
|
||||
void updateLeaderFeature();
|
||||
void commonFeatureUpdate(void);
|
||||
void removeFeature(void);
|
||||
|
||||
/* QPointF calcTextStartPos(double scale);*/
|
||||
|
||||
Reference in New Issue
Block a user