[TD]add style options for broken view

This commit is contained in:
wandererfan
2024-05-28 20:09:54 -04:00
committed by WandererFan
parent 0e3057b28c
commit 7d6e9b19fb
11 changed files with 682 additions and 495 deletions

View File

@@ -98,6 +98,11 @@ using SU = ShapeUtils;
// DrawBrokenView
//===========================================================================
const char *DrawBrokenView::BreakTypeEnums[] = {
QT_TRANSLATE_NOOP("DrawBrokenView", "None"),
QT_TRANSLATE_NOOP("DrawBrokenView", "ZigZag"),
QT_TRANSLATE_NOOP("DrawBrokenView", "Simple"),
nullptr};
PROPERTY_SOURCE(TechDraw::DrawBrokenView, TechDraw::DrawViewPart)
DrawBrokenView::DrawBrokenView()

View File

@@ -60,6 +60,14 @@ class TechDrawExport DrawBrokenView: public TechDraw::DrawViewPart
PROPERTY_HEADER_WITH_OVERRIDE(TechDraw::DrawBrokenView);
public:
enum BreakType
{
NONE,
ZIGZAG,
SIMPLE
};
static const char* BreakTypeEnums[];
DrawBrokenView();
~DrawBrokenView() override;

View File

@@ -502,6 +502,11 @@ int Preferences::HiddenLineStyle()
return getPreferenceGroup("Decorations")->GetInt("LineStyleHidden", 1) + 1;
}
int Preferences::BreakLineStyle()
{
return getPreferenceGroup("Decorations")->GetInt("LineStyleBreak", 0) + 1;
}
int Preferences::LineSpacingISO()
{
return getPreferenceGroup("Dimensions")->GetInt("LineSpacingFactorISO", 2);
@@ -578,5 +583,9 @@ bool Preferences::useExactMatchOnDims()
return getPreferenceGroup("Dimensions")->GetBool("UseMatcher", true);
}
int Preferences::BreakType()
{
return getPreferenceGroup("Decorations")->GetInt("BreakType", 2);
}

View File

@@ -119,6 +119,7 @@ public:
static int CenterLineStyle();
static int HighlightLineStyle();
static int HiddenLineStyle();
static int BreakLineStyle();
static int LineCapStyle();
static int LineCapIndex();
@@ -131,6 +132,8 @@ public:
static bool showSectionLine();
static bool includeCutLine();
static int BreakType();
static bool useExactMatchOnDims();
};

File diff suppressed because it is too large Load Diff

View File

@@ -118,6 +118,9 @@ void DlgPrefsTechDrawAnnotationImp::saveSettings()
ui->pcbDetailMatting->onSave();
ui->pcbDetailHighlight->onSave();
ui->pcbBreakType->onSave();
ui->pcbBreakStyle->onSave();
}
void DlgPrefsTechDrawAnnotationImp::loadSettings()
@@ -177,7 +180,10 @@ void DlgPrefsTechDrawAnnotationImp::loadSettings()
ui->pcbCenterStyle->onRestore();
ui->pcbHighlightStyle->onRestore();
ui->pcbHiddenStyle->onRestore();
ui->pcbBreakStyle->onRestore();
loadLineStyleBoxes();
ui->pcbBreakType->onRestore();
}
/**
@@ -265,6 +271,11 @@ void DlgPrefsTechDrawAnnotationImp::loadLineStyleBoxes()
if (ui->pcbHiddenStyle->count() > Preferences::HiddenLineStyle()) {
ui->pcbHiddenStyle->setCurrentIndex(Preferences::HiddenLineStyle() - 1);
}
DrawGuiUtil::loadLineStyleChoices(ui->pcbBreakStyle, m_lineGenerator);
if (ui->pcbBreakStyle->count() > Preferences::BreakLineStyle()) {
ui->pcbBreakStyle->setCurrentIndex(Preferences::BreakLineStyle() - 1);
}
}
#include <Mod/TechDraw/Gui/moc_DlgPrefsTechDrawAnnotationImp.cpp>

View File

@@ -71,7 +71,33 @@ QGIBreakLine::QGIBreakLine()
void QGIBreakLine::draw()
{
// Base::Console().Message("QGIBL::draw()\n");
if (breakType() == 0) {
// none
m_background->hide();
m_line0->hide();
m_line1->hide();
}
if (breakType() == 1) {
drawLargeZigZag();
m_background->show();
m_line0->show();
m_line1->show();
}
if (breakType() == 2) {
// simple line from pref
drawSimpleLines();
m_background->hide();
m_line0->show();
m_line1->show();
}
update();
}
void QGIBreakLine::drawLargeZigZag()
{
Base::Vector3d horizontal{1.0, 0.0, 0.0};
prepareGeometryChange();
double offset = zigzagWidth / 2.0;
@@ -100,11 +126,6 @@ void QGIBreakLine::draw()
std::fabs(m_right - m_left + zigzagWidth),
std::fabs(m_top - m_bottom + zigzagWidth));
m_background->setRect(backgroundRect);
m_line0->show();
m_line1->show();
m_background->show();
update();
}
// start needs to be Rez'd and +Y up
@@ -150,6 +171,44 @@ QPainterPath QGIBreakLine::makeVerticalZigZag(Base::Vector3d start) const
return pPath;
}
void QGIBreakLine::drawSimpleLines()
{
Base::Vector3d horizontal{1.0, 0.0, 0.0};
prepareGeometryChange();
if (DU::fpCompare(fabs(m_direction.Dot(horizontal)), 1.0, EWTOLERANCE)) {
// m_direction connects the two cut points. The break lines have
// to be perpendicular to m_direction
Base::Vector3d start = Base::Vector3d(m_left, m_bottom, 0.0);
Base::Vector3d end = Base::Vector3d(m_left, m_top, 0.0);
m_line0->setPath(pathFromPoints(start, end));
start = Base::Vector3d(m_right, m_bottom, 0.0);
end = Base::Vector3d(m_right, m_top, 0.0);
m_line1->setPath(pathFromPoints(start, end));
} else {
// m_top is lower than m_bottom due to Qt Y+ down coords
// the higher break line
// 2x horizontal zigszags
Base::Vector3d start = Base::Vector3d(m_left, m_bottom, 0.0);
Base::Vector3d end = Base::Vector3d(m_right, m_bottom, 0.0);
m_line0->setPath(pathFromPoints(start, end));
// the lower break line
start = Base::Vector3d(m_left, m_top, 0.0);
end = Base::Vector3d(m_right, m_top, 0.0);
m_line1->setPath(pathFromPoints(start, end));
}
}
QPainterPath QGIBreakLine::pathFromPoints(Base::Vector3d start, Base::Vector3d end)
{
QPainterPath result(DU::toQPointF(start));
result.lineTo(DU::toQPointF(end));
return result;
}
void QGIBreakLine::setBounds(double left, double top, double right, double bottom)
{
// Base::Console().Message("QGIBL::setBounds(%.3f, %.3f, %.3f, %.3f\n", left, top, right, bottom);

View File

@@ -59,11 +59,18 @@ public:
void setLinePen(QPen isoPen);
void setBreakColor(QColor c);
void setBreakType(int style) { m_breakType = style; }
int breakType() const { return m_breakType; }
protected:
private:
void drawLargeZigZag();
QPainterPath makeHorizontalZigZag(Base::Vector3d start) const;
QPainterPath makeVerticalZigZag(Base::Vector3d start) const;
void drawSimpleLines();
QPainterPath pathFromPoints(Base::Vector3d start, Base::Vector3d end);
void setTools();
QGraphicsPathItem* m_line0;
@@ -76,6 +83,8 @@ private:
double m_bottom;
double m_left;
double m_right;
int m_breakType{0};
};
}

View File

@@ -1046,6 +1046,7 @@ void QGIViewPart::drawBreakLines()
return;
}
auto breakType = vp->BreakLineType.getValue();
auto breaks = dbv->Breaks.getValues();
for (auto& breakObj : breaks) {
QGIBreakLine* breakLine = new QGIBreakLine();
@@ -1061,8 +1062,9 @@ void QGIViewPart::drawBreakLines()
breakLine->setBounds(topLeft, bottomRight);
breakLine->setPos(0.0, 0.0);
breakLine->setLinePen(
m_dashedLineGenerator->getLinePen(1, vp->HiddenWidth.getValue()));
m_dashedLineGenerator->getLinePen(vp->BreakLineStyle.getValue(), vp->HiddenWidth.getValue()));
breakLine->setWidth(Rez::guiX(vp->HiddenWidth.getValue()));
breakLine->setBreakType(breakType);
breakLine->setZValue(ZVALUE::SECTIONLINE);
App::Color color = prefBreaklineColor();
breakLine->setBreakColor(color.asValue<QColor>());

View File

@@ -46,6 +46,7 @@
#include <Mod/TechDraw/App/DrawViewDetail.h>
#include <Mod/TechDraw/App/DrawViewDimension.h>
#include <Mod/TechDraw/App/DrawViewMulti.h>
#include <Mod/TechDraw/App/DrawBrokenView.h>
#include <Mod/TechDraw/App/LineGroup.h>
#include <Mod/TechDraw/App/Cosmetic.h>
#include <Mod/TechDraw/App/CenterLine.h>
@@ -84,6 +85,7 @@ ViewProviderViewPart::ViewProviderViewPart()
static const char *hgroup = "Highlight";
static const char *sgroup = "Section Line";
static const char *fgroup = "Faces";
static const char *bvgroup = "Broken View";
//default line weights
@@ -128,6 +130,13 @@ ViewProviderViewPart::ViewProviderViewPart()
"Set highlight line color if applicable");
ADD_PROPERTY_TYPE(HighlightAdjust, (0.0), hgroup, App::Prop_None, "Adjusts the rotation of the Detail highlight");
// properties that affect BrokenViews
BreakLineType.setEnums(DrawBrokenView::BreakTypeEnums);
ADD_PROPERTY_TYPE(BreakLineType, (Preferences::BreakType()), bvgroup, App::Prop_None,
"Adjusts the type of break line depiction on broken views");
ADD_PROPERTY_TYPE(BreakLineStyle, (Preferences::BreakLineStyle()), bvgroup, App::Prop_None,
"Set break line style if applicable");
ADD_PROPERTY_TYPE(ShowAllEdges ,(false),dgroup, App::Prop_None, "Temporarily show invisible lines");
// Faces related properties
@@ -141,12 +150,15 @@ ViewProviderViewPart::ViewProviderViewPart()
if (bodyName == "ISO") {
SectionLineStyle.setEnums(ISOLineName::ISOLineNameEnums);
HighlightLineStyle.setEnums(ISOLineName::ISOLineNameEnums);
BreakLineStyle.setEnums(ISOLineName::ISOLineNameEnums);
} else if (bodyName == "ANSI") {
SectionLineStyle.setEnums(ANSILineName::ANSILineNameEnums);
HighlightLineStyle.setEnums(ANSILineName::ANSILineNameEnums);
BreakLineStyle.setEnums(ANSILineName::ANSILineNameEnums);
} else if (bodyName == "ASME") {
SectionLineStyle.setEnums(ASMELineName::ASMELineNameEnums);
HighlightLineStyle.setEnums(ASMELineName::ASMELineNameEnums);
BreakLineStyle.setEnums(ASMELineName::ASMELineNameEnums);
}
}
@@ -184,7 +196,9 @@ void ViewProviderViewPart::onChanged(const App::Property* prop)
prop == &(HorizCenterLine) ||
prop == &(VertCenterLine) ||
prop == &(FaceColor) ||
prop == &(FaceTransparency)) {
prop == &(FaceTransparency) ||
prop == &(BreakLineType) ||
prop == &(BreakLineStyle) ) {
// redraw QGIVP
QGIView* qgiv = getQView();
if (qgiv) {

View File

@@ -60,6 +60,8 @@ public:
App::PropertyEnumeration HighlightLineStyle;
App::PropertyColor HighlightLineColor;
App::PropertyFloat HighlightAdjust;
App::PropertyEnumeration BreakLineType;
App::PropertyEnumeration BreakLineStyle;
App::PropertyBool ShowAllEdges;
App::PropertyColor FaceColor;
App::PropertyPercent FaceTransparency;