[TD]Cosmetic function overhaul (#14216)
* [TD]Cosmetic geometry and tools update - all cosmetics to store geometry in same form - all cosmetics to survive scaling and rotation - extension functions to survive scaling and rotation * [TD]overhaul leader point storage and editing - add py routine makeLeader(points) * [TD]add leader conversion utility * [TD]Set Leader RotateWithView default to true * [TD]fix intersection vertex position * [TD]add CosmeticEdge::makeLineFromCanonicalPoints * [TD]fix 2 Extension tools - positioning in DrawCosmeticCircle - mishandling of points in execLineParallelPerpendicular * [TD]Remove duplicate constexpr * [TD]fix 2x Cosmetic arc tools * [TD]refactor LineFormat out of Cosmetic * [TD]move cosmetic appearance settings to LineFormat * [TD]remove 2 unused methods * [TD]apply format to blue line & circle tools * [TD]fix ballon arrowhead does not rotate with view * [TD]fix CosmeticCircle3Points * [TD]allow multiple cosmetic object deletions * [TD]fix extend/shorten centerline
This commit is contained in:
@@ -41,10 +41,13 @@
|
||||
#include "QGIView.h"
|
||||
#include "Rez.h"
|
||||
#include "ZVALUE.h"
|
||||
#include "DrawGuiUtil.h"
|
||||
|
||||
|
||||
using namespace TechDrawGui;
|
||||
using namespace TechDraw;
|
||||
using DU = DrawUtil;
|
||||
using DGU = DrawGuiUtil;
|
||||
|
||||
QGMarker::QGMarker(int idx) : QGIVertex(idx),
|
||||
m_dragging(false)
|
||||
@@ -62,7 +65,9 @@ void QGMarker::mousePressEvent(QGraphicsSceneMouseEvent * event)
|
||||
Q_EMIT endEdit();
|
||||
event->accept();
|
||||
return;
|
||||
} else if(scene() && this == scene()->mouseGrabberItem()) {
|
||||
}
|
||||
|
||||
if(scene() && this == scene()->mouseGrabberItem()) {
|
||||
//start dragging
|
||||
m_dragging = true;
|
||||
Q_EMIT dragging(pos(), getProjIndex()); //pass center of marker[i] to epath
|
||||
@@ -72,7 +77,8 @@ void QGMarker::mousePressEvent(QGraphicsSceneMouseEvent * event)
|
||||
|
||||
void QGMarker::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
|
||||
{
|
||||
if (event->button() == Qt::RightButton) { //we're done
|
||||
if (event->button() == Qt::RightButton) {
|
||||
// we are finished our edit session
|
||||
Q_EMIT endEdit();
|
||||
m_dragging = false;
|
||||
return;
|
||||
@@ -82,6 +88,7 @@ void QGMarker::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
|
||||
if (m_dragging) {
|
||||
m_dragging = false;
|
||||
setSelected(false);
|
||||
// send this marker's new position to QGEPath
|
||||
Q_EMIT dragFinished(pos(), getProjIndex()); //pass center of marker[i] to epath
|
||||
}
|
||||
}
|
||||
@@ -92,7 +99,9 @@ void QGMarker::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event)
|
||||
{
|
||||
// Base::Console().Message("QGMarker::mouseDoubleClickEvent(%d)\n", getProjIndex());
|
||||
if (event->button() == Qt::RightButton) { //we're done
|
||||
// we are finished our edit session
|
||||
Q_EMIT endEdit();
|
||||
m_dragging = false;
|
||||
return;
|
||||
}
|
||||
QGIVertex::mouseDoubleClickEvent(event);
|
||||
@@ -102,28 +111,34 @@ void QGMarker::keyPressEvent(QKeyEvent * event)
|
||||
{
|
||||
// Base::Console().Message("QGMarker::keyPressEvent(%d)\n", getProjIndex());
|
||||
if (event->key() == Qt::Key_Escape) {
|
||||
m_dragging = false;
|
||||
Q_EMIT endEdit();
|
||||
}
|
||||
QGIVertex::keyPressEvent(event);
|
||||
}
|
||||
|
||||
//! adjust the size of this marker
|
||||
void QGMarker::setRadius(float radius)
|
||||
{
|
||||
//TODO:: implement different marker shapes. circle, square, triangle, ???
|
||||
//if (m_markerShape == Circle) { ...
|
||||
//setRect(QRectF) for rectangular markers
|
||||
m_radius = radius;
|
||||
QPainterPath p;
|
||||
p.addRect(-radius/2.0, -radius/2.0, radius, radius);
|
||||
setPath(p);
|
||||
QPainterPath pPath;
|
||||
pPath.addRect(-radius/2.0, -radius/2.0, radius, radius);
|
||||
setPath(pPath);
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
|
||||
QGEPath::QGEPath(QGILeaderLine* leader) :
|
||||
|
||||
//! QGEPath is an editable version of QGIPrimPath. Points along the path can be dragged to new
|
||||
//! positions that are returned to the caller on completion of the edit session. The points are in
|
||||
//! scene coordinates and are relative to the scene position of the caller.
|
||||
|
||||
QGEPath::QGEPath() :
|
||||
m_scale(1.0),
|
||||
m_inEdit(false),
|
||||
m_parentLeader(leader),
|
||||
m_startAdj(0.0),
|
||||
m_endAdj(0.0)
|
||||
{
|
||||
@@ -169,7 +184,7 @@ void QGEPath::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
|
||||
void QGEPath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
QGIView *view = dynamic_cast<QGIView *> (parentItem());
|
||||
auto view = dynamic_cast<QGIView *> (parentItem());
|
||||
assert(view);
|
||||
Q_UNUSED(view);
|
||||
|
||||
@@ -186,7 +201,9 @@ void QGEPath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
// QGIPrimPath::hoverLeaveEvent(event); //QGIPP::hoverleave will reset pretty to normal
|
||||
}
|
||||
|
||||
void QGEPath::startPathEdit(std::vector<QPointF> pathPoints)
|
||||
|
||||
//! this begins an edit session for a path described by pathPoints.
|
||||
void QGEPath::startPathEdit(const std::vector<QPointF>& pathPoints)
|
||||
{
|
||||
// Base::Console().Message("QGEPath::startPathEdit()\n");
|
||||
inEdit(true);
|
||||
@@ -194,7 +211,7 @@ void QGEPath::startPathEdit(std::vector<QPointF> pathPoints)
|
||||
showMarkers(m_ghostPoints);
|
||||
}
|
||||
|
||||
void QGEPath::showMarkers(std::vector<QPointF> points)
|
||||
void QGEPath::showMarkers(const std::vector<QPointF>& points)
|
||||
{
|
||||
// Base::Console().Message("QGEPath::showMarkers()\n");
|
||||
if (!inEdit()) {
|
||||
@@ -231,9 +248,8 @@ void QGEPath::showMarkers(std::vector<QPointF> points)
|
||||
v, &QGMarker::endEdit,
|
||||
this, &QGEPath::onEndEdit
|
||||
);
|
||||
//TODO: double r = getMarkerSize();
|
||||
// v->setRadius(r);
|
||||
v->setRadius(50.0);
|
||||
v->setRadius(PreferencesGui::get3dMarkerSize());
|
||||
// v->setRadius(50.0); // this make a huge marker
|
||||
v->setNormalColor(PreferencesGui::getAccessibleQColor(QColor(Qt::black)));
|
||||
v->setZValue(ZVALUE::VERTEX);
|
||||
v->setPos(p);
|
||||
@@ -304,31 +320,6 @@ void QGEPath::onEndEdit()
|
||||
clearMarkers();
|
||||
}
|
||||
|
||||
std::vector<QPointF> QGEPath::getDeltasFromLeader()
|
||||
{
|
||||
std::vector<QPointF> qDeltas;
|
||||
if (!m_parentLeader) {
|
||||
Base::Console().Message("QGEP::getDeltasFromLeader - m_parentLeader is nullptr\n");
|
||||
return qDeltas;
|
||||
}
|
||||
|
||||
DrawLeaderLine* featLeader = m_parentLeader->getFeature();
|
||||
if (!featLeader) {
|
||||
Base::Console().Message("QGEP::getDeltasFromLeader - featLeader is nullptr\n");
|
||||
return qDeltas;
|
||||
}
|
||||
|
||||
std::vector<Base::Vector3d> vDeltas = featLeader->WayPoints.getValues();
|
||||
for (auto& d: vDeltas) {
|
||||
Base::Vector3d vTemp = Rez::guiX(d);
|
||||
QPointF temp(vTemp.x, -vTemp.y);
|
||||
qDeltas.push_back(temp);
|
||||
}
|
||||
if (qDeltas.empty()) {
|
||||
Base::Console().Warning("QGEPath::getDeltasFromLeader - no points\n");
|
||||
}
|
||||
return qDeltas;
|
||||
}
|
||||
|
||||
//announce points editing is finished
|
||||
void QGEPath::updateParent()
|
||||
@@ -341,7 +332,7 @@ void QGEPath::updateParent()
|
||||
}
|
||||
}
|
||||
|
||||
//the ghost is the red line drawn when creating or editing the Leader points
|
||||
//! the ghost is the red line drawn when creating or editing the points
|
||||
void QGEPath::drawGhost()
|
||||
{
|
||||
// Base::Console().Message("QGEPath::drawGhost()\n");
|
||||
|
||||
Reference in New Issue
Block a user