Skip to content

Commit

Permalink
[TD]ANSI/ASME section line conformance
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan committed Feb 21, 2024
1 parent 23741ff commit 289c386
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 65 deletions.
5 changes: 5 additions & 0 deletions src/Mod/TechDraw/App/Preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,3 +522,8 @@ int Preferences::LineCapIndex()
return getPreferenceGroup("General")->GetInt("EdgeCapStyle", 0x20);
}

//! returns 0 (use ANSI style section cut line) or 1 (use ISO style section cut line)
int Preferences::sectionLineConvention()
{
return getPreferenceGroup("Standards")->GetInt("SectionLineStandard", 1);
}
2 changes: 2 additions & 0 deletions src/Mod/TechDraw/App/Preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ class TechDrawExport Preferences

static std::string currentLineDefFile();
static std::string currentElementDefFile();

static int sectionLineConvention();
};


Expand Down
13 changes: 0 additions & 13 deletions src/Mod/TechDraw/Gui/PreferencesGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,6 @@ double PreferencesGui::edgeFuzz()
return Preferences::getPreferenceGroup("General")->GetFloat("EdgeFuzz", 10.0);
}


// this is for the iso vs ansi positioning of arrows and text. rename to sectionLineConvention?
Qt::PenStyle PreferencesGui::sectionLineStyle()
{
Qt::PenStyle sectStyle = static_cast<Qt::PenStyle> (Preferences::getPreferenceGroup("Decorations")->GetInt("SectionLine", 2));
return sectStyle;
}

bool PreferencesGui::sectionLineMarks()
{
return Preferences::getPreferenceGroup("Decorations")->GetBool("SectionLineMarks", true);
}

QString PreferencesGui::weldingDirectory()
{
std::string defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/Symbols/Welding/AWS/";
Expand Down
3 changes: 0 additions & 3 deletions src/Mod/TechDraw/Gui/PreferencesGui.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ static double dimArrowSize();

static double edgeFuzz();

static Qt::PenStyle sectionLineStyle();
static bool sectionLineMarks();

static QString weldingDirectory();

static bool showGrid();
Expand Down
6 changes: 0 additions & 6 deletions src/Mod/TechDraw/Gui/QGIHighlight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,6 @@ QColor QGIHighlight::getHighlightColor()
return PreferencesGui::sectionLineQColor();
}

//obs??
Qt::PenStyle QGIHighlight::getHighlightStyle()
{
return PreferencesGui::sectionLineStyle();
}

int QGIHighlight::getHoleStyle()
{
return TechDraw::Preferences::mattingStyle();
Expand Down
1 change: 0 additions & 1 deletion src/Mod/TechDraw/Gui/QGIHighlight.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class TechDrawGuiExport QGIHighlight : public QGIDecoration

protected:
QColor getHighlightColor();
Qt::PenStyle getHighlightStyle();
void makeHighlight();
void makeReference();
void setTools();
Expand Down
28 changes: 5 additions & 23 deletions src/Mod/TechDraw/Gui/QGISectionLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include <Base/Parameter.h>
#include <Base/Tools.h>

#include <Mod/TechDraw/App/Preferences.h>

#include "QGISectionLine.h"
#include "PreferencesGui.h"
#include "QGIArrow.h"
Expand Down Expand Up @@ -73,15 +75,14 @@ QGISectionLine::QGISectionLine() :
addToGroup(m_symbol2);

setWidth(Rez::guiX(0.75)); //a default?
setStyle(getSectionStyle());
setColor(getSectionColor());

}

void QGISectionLine::draw()
{
prepareGeometryChange();
int format = getPrefSectionStandard();
int format = Preferences::sectionLineConvention();
if (format == ANSISTANDARD) { //"ASME"/"ANSI"
extensionEndsTrad();
} else {
Expand Down Expand Up @@ -128,7 +129,7 @@ void QGISectionLine::makeSectionLine()

void QGISectionLine::makeArrows()
{
int format = getPrefSectionStandard();
int format = Preferences::sectionLineConvention();
if (format == ANSISTANDARD) {
makeArrowsTrad();
} else {
Expand Down Expand Up @@ -193,7 +194,7 @@ void QGISectionLine::makeArrowsTrad()

void QGISectionLine::makeSymbols()
{
int format = getPrefSectionStandard();
int format = Preferences::sectionLineConvention();
if (format == ANSISTANDARD) {
makeSymbolsTrad();
} else {
Expand Down Expand Up @@ -471,25 +472,6 @@ QColor QGISectionLine::getSectionColor()
return PreferencesGui::sectionLineQColor();
}

//SectionLineStyle
void QGISectionLine::setSectionStyle(int style)
{
Qt::PenStyle sectStyle = static_cast<Qt::PenStyle> (style);
setStyle(sectStyle);
}

Qt::PenStyle QGISectionLine::getSectionStyle()
{
return PreferencesGui::sectionLineStyle();
}

//ASME("traditional") vs ISO("reference arrow method") arrows
int QGISectionLine::getPrefSectionStandard()
{
return Preferences::getPreferenceGroup("Standards")->GetInt("SectionLineStandard", ISOSTANDARD);
}


void QGISectionLine::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
QStyleOptionGraphicsItem myOption(*option);
myOption.state &= ~QStyle::State_Selected;
Expand Down
2 changes: 0 additions & 2 deletions src/Mod/TechDraw/Gui/QGISectionLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class TechDrawGuiExport QGISectionLine : public QGIDecoration
void setDirection(Base::Vector3d dir);
void setArrowDirections(Base::Vector3d dir1, Base::Vector3d dir2);
void setFont(QFont f, double fsize);
void setSectionStyle(int style);
void setSectionColor(QColor c);
void setPathMode(bool mode) { m_pathMode = mode; }
bool pathMode() { return m_pathMode; }
Expand All @@ -86,7 +85,6 @@ class TechDrawGuiExport QGISectionLine : public QGIDecoration
void makeSymbolsISO();
void makeChangePointMarks();
void setTools();
int getPrefSectionStandard();
void extensionEndsISO();
void extensionEndsTrad();
double getArrowRotation(Base::Vector3d arrowDir);
Expand Down
3 changes: 1 addition & 2 deletions src/Mod/TechDraw/Gui/QGIViewPart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,7 @@ void QGIViewPart::drawAllSectionLines()

void QGIViewPart::drawSectionLine(TechDraw::DrawViewSection* viewSection, bool b)
{
// Base::Console().Message("QGIVP::drawSectionLine()\n");
TechDraw::DrawViewPart* viewPart = static_cast<TechDraw::DrawViewPart*>(getViewObject());
if (!viewPart)
return;
Expand Down Expand Up @@ -665,7 +666,6 @@ void QGIViewPart::drawSectionLine(TechDraw::DrawViewSection* viewSection, bool b
QGISectionLine* sectionLine = new QGISectionLine();
addToGroup(sectionLine);
sectionLine->setSymbol(const_cast<char*>(viewSection->SectionSymbol.getValue()));
sectionLine->setSectionStyle(vp->SectionLineStyle.getValue());
App::Color color = Preferences::getAccessibleColor(vp->SectionLineColor.getValue());
sectionLine->setSectionColor(color.asValue<QColor>());
sectionLine->setPathMode(false);
Expand Down Expand Up @@ -754,7 +754,6 @@ void QGIViewPart::drawComplexSectionLine(TechDraw::DrawViewSection* viewSection,
QGISectionLine* sectionLine = new QGISectionLine();
addToGroup(sectionLine);
sectionLine->setSymbol(const_cast<char*>(viewSection->SectionSymbol.getValue()));
sectionLine->setSectionStyle(vp->SectionLineStyle.getValue());
App::Color color = Preferences::getAccessibleColor(vp->SectionLineColor.getValue());
sectionLine->setSectionColor(color.asValue<QColor>());
sectionLine->setPathMode(true);
Expand Down
32 changes: 17 additions & 15 deletions src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,25 +107,15 @@ ViewProviderViewPart::ViewProviderViewPart()
ADD_PROPERTY_TYPE(ArcCenterMarks ,(defShowCenters), dgroup, App::Prop_None, "Center marks on/off");
ADD_PROPERTY_TYPE(CenterScale, (defScale), dgroup, App::Prop_None, "Center mark size adjustment, if enabled");

std::string bodyName = LineGenerator::getLineStandardsBody();
if (bodyName == "ISO") {
SectionLineStyle.setEnums(ISOLineName::ISOLineNameEnums);
HighlightLineStyle.setEnums(ISOLineName::ISOLineNameEnums);
} else if (bodyName == "ANSI") {
SectionLineStyle.setEnums(ANSILineName::ANSILineNameEnums);
HighlightLineStyle.setEnums(ANSILineName::ANSILineNameEnums);
} else if (bodyName == "ASME") {
SectionLineStyle.setEnums(ASMELineName::ASMELineNameEnums);
HighlightLineStyle.setEnums(ASMELineName::ASMELineNameEnums);
}

//properties that affect Section Line
ADD_PROPERTY_TYPE(ShowSectionLine ,(true) ,sgroup, App::Prop_None, "Show/hide section line if applicable");
ADD_PROPERTY_TYPE(SectionLineStyle, (PreferencesGui::sectionLineStyle()), sgroup, App::Prop_None,
ADD_PROPERTY_TYPE(SectionLineStyle, (Preferences::SectionLineStyle()), sgroup, App::Prop_None,
"Set section line style if applicable");
ADD_PROPERTY_TYPE(SectionLineColor, (prefSectionColor()), sgroup, App::Prop_None,
"Set section line color if applicable");
ADD_PROPERTY_TYPE(SectionLineMarks, (PreferencesGui::sectionLineMarks()), sgroup, App::Prop_None,

bool marksDefault = Preferences::sectionLineConvention() == 1 ? true : false;
ADD_PROPERTY_TYPE(SectionLineMarks, (marksDefault), sgroup, App::Prop_None,
"Show marks at direction changes for ComplexSection");

//properties that affect Detail Highlights
Expand All @@ -135,14 +125,26 @@ 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");

ADD_PROPERTY_TYPE(ShowAllEdges ,(false) ,dgroup, App::Prop_None, "Temporarily show invisible lines");
ADD_PROPERTY_TYPE(ShowAllEdges ,(false),dgroup, App::Prop_None, "Temporarily show invisible lines");

// Faces related properties
ADD_PROPERTY_TYPE(FaceColor, (Preferences::getPreferenceGroup("Colors")->GetUnsigned("FaceColor", 0xFFFFFF)),
fgroup, App::Prop_None, "Set color of faces");
ADD_PROPERTY_TYPE(FaceTransparency, (Preferences::getPreferenceGroup("Colors")->GetBool("ClearFace", false) ? 100 : 0),
fgroup, App::Prop_None, "Set transparency of faces");
FaceTransparency.setConstraints(&intPercent);

std::string bodyName = LineGenerator::getLineStandardsBody();
if (bodyName == "ISO") {
SectionLineStyle.setEnums(ISOLineName::ISOLineNameEnums);
HighlightLineStyle.setEnums(ISOLineName::ISOLineNameEnums);
} else if (bodyName == "ANSI") {
SectionLineStyle.setEnums(ANSILineName::ANSILineNameEnums);
HighlightLineStyle.setEnums(ANSILineName::ANSILineNameEnums);
} else if (bodyName == "ASME") {
SectionLineStyle.setEnums(ASMELineName::ASMELineNameEnums);
HighlightLineStyle.setEnums(ASMELineName::ASMELineNameEnums);
}
}

ViewProviderViewPart::~ViewProviderViewPart()
Expand Down

0 comments on commit 289c386

Please sign in to comment.