[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:
WandererFan
2024-05-23 09:41:42 -04:00
committed by GitHub
parent a8d093280e
commit 50f970efd7
56 changed files with 1812 additions and 1076 deletions

View File

@@ -22,7 +22,6 @@
#include "PreCompiled.h"
#ifndef _PreComp_
#include <cmath>
#include <QPainterPath>
#include <QKeyEvent>
@@ -139,45 +138,25 @@ bool QGIViewPart::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
bool QGIViewPart::removeSelectedCosmetic() const
{
// Base::Console().Message("QGIVP::removeSelectedCosmetic()\n");
auto dvp(dynamic_cast<TechDraw::DrawViewPart*>(getViewObject()));
if (!dvp) {
throw Base::RuntimeError("Graphic has no feature!");
}
char* defaultDocument{nullptr};
std::vector<Gui::SelectionObject> selectionAll = Gui::Selection().getSelectionEx(
defaultDocument, TechDraw::DrawViewPart::getClassTypeId(), Gui::ResolveMode::NoResolve);
defaultDocument, TechDraw::DrawViewPart::getClassTypeId(), Gui::ResolveMode::OldStyleElement);
if (selectionAll.empty()) {
return false;
}
Gui::SelectionObject firstSelection = selectionAll.front();
App::DocumentObject* firstObject = selectionAll.front().getObject();
std::vector<std::string> subElements = selectionAll.front().getSubNames();
if (subElements.empty()) {
return false;
}
auto dvp = static_cast<TechDraw::DrawViewPart*>(firstObject);
auto subelement = subElements.front();
std::string geomName = DU::getGeomTypeFromName(subelement);
int index = DU::getIndexFromName(subelement);
if (geomName == "Edge") {
TechDraw::BaseGeomPtr base = dvp->getGeomByIndex(index);
if (!base || base->getCosmeticTag().empty()) {
return false;
}
if (base->source() == COSMETICEDGE) {
dvp->removeCosmeticEdge(base->getCosmeticTag());
dvp->refreshCEGeoms();
} else if (base->source() == CENTERLINE) {
dvp->removeCenterLine(base->getCosmeticTag());
dvp->refreshCLGeoms();
} else {
Base::Console().Message("QGIVP::removeSelectedCosmetic - not a CE or a CL\n");
return false;
}
} else if (geomName == "Vertex") {
VertexPtr vert = dvp->getProjVertexByIndex(index);
if (!vert || vert->getCosmeticTag().empty() ) {
return false;
}
dvp->removeCosmeticVertex(vert->getCosmeticTag());
dvp->refreshCVGeoms();
}
dvp->deleteCosmeticElements(subElements);
dvp->refreshCEGeoms();
dvp->refreshCLGeoms();
dvp->refreshCVGeoms();
return true;
}
@@ -403,15 +382,15 @@ void QGIViewPart::drawAllEdges()
// geometry edge - apply format if applicable
TechDraw::GeomFormat* gf = dvp->getGeomFormatBySelection(iEdge);
if (gf) {
App::Color color = Preferences::getAccessibleColor(gf->m_format.m_color);
App::Color color = Preferences::getAccessibleColor(gf->m_format.getColor());
item->setNormalColor(color.asValue<QColor>());
int lineNumber = gf->m_format.getLineNumber();
int qtStyle = gf->m_format.m_style;
int qtStyle = gf->m_format.getStyle();
item->setLinePen(m_dashedLineGenerator->getBestPen(lineNumber, (Qt::PenStyle)qtStyle,
gf->m_format.m_weight));
gf->m_format.getWidth()));
// but we need to actually draw the lines in QGScene coords (0.1 mm).
item->setWidth(Rez::guiX(gf->m_format.m_weight));
showItem = gf->m_format.m_visible;
item->setWidth(Rez::guiX(gf->m_format.getWidth()));
showItem = gf->m_format.getVisible();
} else {
if (!(*itGeom)->getHlrVisible()) {
// hidden line without a format
@@ -566,13 +545,13 @@ bool QGIViewPart::formatGeomFromCosmetic(std::string cTag, QGIEdge* item)
auto partFeat(dynamic_cast<TechDraw::DrawViewPart*>(getViewObject()));
TechDraw::CosmeticEdge* ce = partFeat ? partFeat->getCosmeticEdge(cTag) : nullptr;
if (ce) {
App::Color color = Preferences::getAccessibleColor(ce->m_format.m_color);
App::Color color = Preferences::getAccessibleColor(ce->m_format.getColor());
item->setNormalColor(color.asValue<QColor>());
item->setLinePen(m_dashedLineGenerator->getBestPen(ce->m_format.getLineNumber(),
(Qt::PenStyle)ce->m_format.m_style,
ce->m_format.m_weight));
item->setWidth(Rez::guiX(ce->m_format.m_weight));
result = ce->m_format.m_visible;
(Qt::PenStyle)ce->m_format.getStyle(),
ce->m_format.getWidth()));
item->setWidth(Rez::guiX(ce->m_format.getWidth()));
result = ce->m_format.getVisible();
}
return result;
}
@@ -585,13 +564,13 @@ bool QGIViewPart::formatGeomFromCenterLine(std::string cTag, QGIEdge* item)
auto partFeat(dynamic_cast<TechDraw::DrawViewPart*>(getViewObject()));
TechDraw::CenterLine* cl = partFeat ? partFeat->getCenterLine(cTag) : nullptr;
if (cl) {
App::Color color = Preferences::getAccessibleColor(cl->m_format.m_color);
App::Color color = Preferences::getAccessibleColor(cl->m_format.getColor());
item->setNormalColor(color.asValue<QColor>());
item->setLinePen(m_dashedLineGenerator->getBestPen(cl->m_format.getLineNumber(),
(Qt::PenStyle)cl->m_format.m_style,
cl->m_format.m_weight));
item->setWidth(Rez::guiX(cl->m_format.m_weight));
result = cl->m_format.m_visible;
(Qt::PenStyle)cl->m_format.getStyle(),
cl->m_format.getWidth()));
item->setWidth(Rez::guiX(cl->m_format.getWidth()));
result = cl->m_format.getVisible();
}
return result;
}