[TD]Standard Line Styles - Gui components

This commit is contained in:
wandererfan
2023-11-16 11:33:45 -05:00
committed by WandererFan
parent b64fd9ac03
commit 762e1b53ff
42 changed files with 1494 additions and 1395 deletions

View File

@@ -62,7 +62,6 @@
#include "ZVALUE.h"
#include "PathBuilder.h"
using namespace TechDraw;
using namespace TechDrawGui;
using namespace std;
@@ -72,7 +71,6 @@ using DU = DrawUtil;
#define COSMETICEDGE 1
#define CENTERLINE 2
const float lineScaleFactor = Rez::guiX(1.);// temp fiddle for devel
QGIViewPart::QGIViewPart()
@@ -87,12 +85,14 @@ QGIViewPart::QGIViewPart()
showSection = false;
m_pathBuilder = new PathBuilder(this);
m_dashedLineGenerator = new LineGenerator();
}
QGIViewPart::~QGIViewPart()
{
tidy();
delete m_pathBuilder;
delete m_dashedLineGenerator;
}
QVariant QGIViewPart::itemChange(GraphicsItemChange change, const QVariant& value)
@@ -279,8 +279,6 @@ void QGIViewPart::drawAllEdges()
auto dvp(static_cast<TechDraw::DrawViewPart*>(getViewObject()));
auto vp = static_cast<ViewProviderViewPart*>(getViewProvider(getViewObject()));
// float lineWidthExtra = dvp->ExtraWidth.getValue() * lineScaleFactor; //extra lines not used here
const TechDraw::BaseGeomPtrVector& geoms = dvp->getEdgeGeometry();
TechDraw::BaseGeomPtrVector::const_iterator itGeom = geoms.begin();
QGIEdge* item;
@@ -294,9 +292,7 @@ void QGIViewPart::drawAllEdges()
addToGroup(item); //item is created at scene(0, 0), not group(0, 0)
item->setPath(drawPainterPath(*itGeom));
item->setWidth(vp->LineWidth.getValue() * lineScaleFactor); //thick
item->setNormalColor(PreferencesGui::getAccessibleQColor(PreferencesGui::normalQColor()));
item->setStyle(Qt::SolidLine);
if ((*itGeom)->getCosmetic()) {
// cosmetic edge - format appropriately
int source = (*itGeom)->source();
@@ -318,21 +314,34 @@ void QGIViewPart::drawAllEdges()
if (gf) {
App::Color color = Preferences::getAccessibleColor(gf->m_format.m_color);
item->setNormalColor(color.asValue<QColor>());
item->setWidth(gf->m_format.m_weight * lineScaleFactor);
item->setStyle(gf->m_format.m_style);
int lineNumber = gf->m_format.getLineNumber();
int qtStyle = gf->m_format.m_style;
item->setLinePen(m_dashedLineGenerator->getBestPen(lineNumber, (Qt::PenStyle)qtStyle,
gf->m_format.m_weight));
// 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;
} else {
// unformatted line, draw as continuous line
item->setLinePen(m_dashedLineGenerator->getLinePen(1, vp->LineWidth.getValue()));
item->setWidth(Rez::guiX(vp->LineWidth.getValue()));
}
}
if (!(*itGeom)->getHlrVisible()) {
// TODO: item->setISOLineNumber(getISOLineNumber(iEdge));
item->setWidth(vp->HiddenWidth.getValue() * lineScaleFactor); //thin
item->setHiddenEdge(true);
// the HiddenLine parameter is 0 (solid) or 1 (dashed)
// Qt PenStyle(1) is continuous and PenStyle(2) is dashed
int qtStyle = Preferences::getPreferenceGroup("General")->GetInt("HiddenLine", 0) + 1;
item->setLinePen(m_dashedLineGenerator->getBestPen( 0, (Qt::PenStyle)qtStyle,
vp->HiddenWidth.getValue()));
item->setWidth(Rez::guiX(vp->HiddenWidth.getValue())); //thin
item->setZValue(ZVALUE::HIDEDGE);
}
if ((*itGeom)->getClassOfEdge() == ecUVISO) {
item->setWidth(vp->IsoWidth.getValue() * lineScaleFactor); //graphic
// we don't have a style option for iso-parametric lines so draw continuous
item->setLinePen(m_dashedLineGenerator->getLinePen(1, vp->IsoWidth.getValue()));
item->setWidth(Rez::guiX(vp->IsoWidth.getValue())); //graphic
}
item->setPos(0.0, 0.0);//now at group(0, 0)
@@ -470,8 +479,10 @@ bool QGIViewPart::formatGeomFromCosmetic(std::string cTag, QGIEdge* item)
if (ce) {
App::Color color = Preferences::getAccessibleColor(ce->m_format.m_color);
item->setNormalColor(color.asValue<QColor>());
item->setWidth(ce->m_format.m_weight * lineScaleFactor);
item->setStyle(ce->m_format.m_style);
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;
}
return result;
@@ -480,15 +491,17 @@ bool QGIViewPart::formatGeomFromCosmetic(std::string cTag, QGIEdge* item)
bool QGIViewPart::formatGeomFromCenterLine(std::string cTag, QGIEdge* item)
{
// Base::Console().Message("QGIVP::formatGeomFromCenterLine(%d)\n", sourceIndex);
// Base::Console().Message("QGIVP::formatGeomFromCenterLine()\n");
bool result = true;
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);
item->setNormalColor(color.asValue<QColor>());
item->setWidth(cl->m_format.m_weight * lineScaleFactor);
item->setStyle(cl->m_format.m_style);
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;
}
return result;
@@ -626,7 +639,6 @@ void QGIViewPart::drawSectionLine(TechDraw::DrawViewSection* viewSection, bool b
if (!vp) {
return;
}
float lineWidthThin = vp->HiddenWidth.getValue() * lineScaleFactor;//thin
if (b) {
QGISectionLine* sectionLine = new QGISectionLine();
@@ -671,7 +683,11 @@ void QGIViewPart::drawSectionLine(TechDraw::DrawViewSection* viewSection, bool b
//set the general parameters
sectionLine->setPos(0.0, 0.0);
sectionLine->setWidth(lineWidthThin);
// sectionLines are typically ISO 8 (long dash, short dash) or ISO 4 (long dash, dot)
sectionLine->setLinePen(
m_dashedLineGenerator->getLinePen((size_t)vp->SectionLineStyle.getValue(),
vp->HiddenWidth.getValue()));
sectionLine->setWidth(Rez::guiX(vp->HiddenWidth.getValue()));
double fontSize = Preferences::dimFontSizeMM();
sectionLine->setFont(getFont(), fontSize);
sectionLine->setZValue(ZVALUE::SECTIONLINE);
@@ -692,7 +708,6 @@ void QGIViewPart::drawComplexSectionLine(TechDraw::DrawViewSection* viewSection,
if (!vp) {
return;
}
float lineWidthThin = vp->HiddenWidth.getValue() * lineScaleFactor;//thin
auto dcs = static_cast<DrawComplexSection*>(viewSection);
BaseGeomPtrVector edges = dcs->makeSectionLineGeometry();
@@ -743,7 +758,11 @@ void QGIViewPart::drawComplexSectionLine(TechDraw::DrawViewSection* viewSection,
//set the general parameters
sectionLine->setPos(0.0, 0.0);
sectionLine->setWidth(lineWidthThin);
// sectionLines are typically ISO 8 (long dash, short dash) or ISO 4 (long dash, dot)
sectionLine->setLinePen(
m_dashedLineGenerator->getLinePen((size_t)vp->SectionLineStyle.getValue(),
vp->HiddenWidth.getValue()));
sectionLine->setWidth(Rez::guiX(vp->HiddenWidth.getValue()));
double fontSize = Preferences::dimFontSizeMM();
sectionLine->setFont(getFont(), fontSize);
sectionLine->setZValue(ZVALUE::SECTIONLINE);
@@ -752,6 +771,7 @@ void QGIViewPart::drawComplexSectionLine(TechDraw::DrawViewSection* viewSection,
}
//TODO: use Cosmetic::CenterLine object for this to make it usable for dims.
// these are the view center lines (ie x,y axes)
void QGIViewPart::drawCenterLines(bool b)
{
TechDraw::DrawViewPart* viewPart = dynamic_cast<TechDraw::DrawViewPart*>(getViewObject());
@@ -780,7 +800,10 @@ void QGIViewPart::drawCenterLines(bool b)
yVal = 0.0;
centerLine->setIntersection(horiz && vert);
centerLine->setBounds(-xVal, -yVal, xVal, yVal);
centerLine->setLinePen(m_dashedLineGenerator->getLinePen((size_t)Preferences::CenterLineStyle(),
vp->HiddenWidth.getValue()));
centerLine->setWidth(Rez::guiX(vp->HiddenWidth.getValue()));
centerLine->setColor(Qt::green);
centerLine->setZValue(ZVALUE::SECTIONLINE);
centerLine->draw();
}
@@ -794,7 +817,10 @@ void QGIViewPart::drawCenterLines(bool b)
yVal = sectionSpan / 2.0;
centerLine->setIntersection(horiz && vert);
centerLine->setBounds(-xVal, -yVal, xVal, yVal);
centerLine->setLinePen(m_dashedLineGenerator->getLinePen((size_t)Preferences::CenterLineStyle(),
vp->HiddenWidth.getValue()));
centerLine->setWidth(Rez::guiX(vp->HiddenWidth.getValue()));
centerLine->setColor(Qt::red);
centerLine->setZValue(ZVALUE::SECTIONLINE);
centerLine->draw();
}
@@ -803,6 +829,9 @@ void QGIViewPart::drawCenterLines(bool b)
void QGIViewPart::drawAllHighlights()
{
if (!Preferences::showDetailHighlight()) {
return;
}
// dvp and vp already validated
auto dvp(static_cast<TechDraw::DrawViewPart*>(getViewObject()));
@@ -828,12 +857,11 @@ void QGIViewPart::drawHighlight(TechDraw::DrawViewDetail* viewDetail, bool b)
return;
}
if (b) {
// double fontSize = getPrefFontSize();
double fontSize = Preferences::labelFontSizeMM();
QGIHighlight* highlight = new QGIHighlight();
scene()->addItem(highlight);
highlight->setReference(viewDetail->Reference.getValue());
highlight->setStyle((Qt::PenStyle)vp->HighlightLineStyle.getValue());
App::Color color = Preferences::getAccessibleColor(vp->HighlightLineColor.getValue());
highlight->setColor(color.asValue<QColor>());
highlight->setFeatureName(viewDetail->getNameInDocument());
@@ -849,6 +877,8 @@ void QGIViewPart::drawHighlight(TechDraw::DrawViewDetail* viewDetail, bool b)
double radius = viewDetail->Radius.getValue() * viewPart->getScale();
highlight->setBounds(center.x - radius, center.y + radius, center.x + radius,
center.y - radius);
highlight->setLinePen(m_dashedLineGenerator->getLinePen((size_t)vp->HighlightLineStyle.getValue(),
vp->IsoWidth.getValue()));
highlight->setWidth(Rez::guiX(vp->IsoWidth.getValue()));
highlight->setFont(getFont(), fontSize);
highlight->setZValue(ZVALUE::HIGHLIGHT);
@@ -880,6 +910,9 @@ void QGIViewPart::highlightMoved(QGIHighlight* highlight, QPointF newPos)
void QGIViewPart::drawMatting()
{
if (!Preferences::showDetailMatting()) {
return;
}
auto viewPart(dynamic_cast<TechDraw::DrawViewPart*>(getViewObject()));
TechDraw::DrawViewDetail* dvd = nullptr;
if (viewPart && viewPart->isDerivedFrom(TechDraw::DrawViewDetail::getClassTypeId())) {