[TD]Standard Line Styles - Gui components

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

View File

@@ -38,6 +38,7 @@
#include "DrawViewPart.h"
#include "GeometryObject.h"
#include "LineGroup.h"
#include "LineGenerator.h"
#include "Preferences.h"
@@ -54,7 +55,7 @@ LineFormat::LineFormat()
m_weight = getDefEdgeWidth();
m_color= getDefEdgeColor();
m_visible = true;
m_lineNumber = InvalidLine;
m_lineNumber = LineGenerator::fromQtStyle((Qt::PenStyle)m_style);
}
LineFormat::LineFormat(const int style,
@@ -65,7 +66,7 @@ LineFormat::LineFormat(const int style,
m_weight(weight),
m_color(color),
m_visible(visible),
m_lineNumber(InvalidLine)
m_lineNumber(LineGenerator::fromQtStyle((Qt::PenStyle)m_style))
{
}

View File

@@ -171,7 +171,7 @@ QPen LineGenerator::getLinePen(size_t lineNumber, double nominalLineWidth)
//! convert Qt line style to closest ISO line number
int LineGenerator::fromQtStyle(Qt::PenStyle style) const
int LineGenerator::fromQtStyle(Qt::PenStyle style)
{
// Base::Console().Message("DLG::fromQtStyle(%d)\n", style);

View File

@@ -58,8 +58,8 @@ public:
QPen getBestPen(size_t lineNumber, Qt::PenStyle qtStyle, double width);
QPen getLinePen(size_t lineNumber, double nominalLineWidth);
int fromQtStyle(Qt::PenStyle style) const;
static int fromQtStyle(Qt::PenStyle style);
static std::vector<std::string> getAvailableLineStandards();
static std::string getLineStandardsBody();

View File

@@ -247,7 +247,7 @@ bool Preferences::showDetailMatting()
bool Preferences::showDetailHighlight()
{
return getPreferenceGroup("General")->GetBool("ShowDetailHighLight", true);
return getPreferenceGroup("General")->GetBool("ShowDetailHighlight", true);
}
std::string Preferences::svgFile()
@@ -418,3 +418,94 @@ bool Preferences::SectionUsePreviousCut()
{
return getPreferenceGroup("General")->GetBool("SectionUsePreviousCut", false);
}
//! an index into the list of available line standards/version found in LineGroupDirectory
int Preferences::lineStandard()
{
return getPreferenceGroup("Standards")->GetInt("LineStandard", 1);
}
std::string Preferences::lineDefinitionLocation()
{
std::string defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/LineGroup/";
std::string prefDir = getPreferenceGroup("Files")->GetASCII("LineDefLocation", defaultDir.c_str());
return prefDir;
}
std::string Preferences::lineElementsLocation()
{
std::string defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/LineGroup/";
std::string prefDir = getPreferenceGroup("Files")->GetASCII("LineElementLocation", defaultDir.c_str());
return prefDir;
}
int Preferences::SectionLineStyle()
{
return getPreferenceGroup("Decorations")->GetInt("LineStyleSection", 4);
}
int Preferences::CenterLineStyle()
{
return getPreferenceGroup("Decorations")->GetInt("LineStyleCenter", 10);
}
int Preferences::HighlightLineStyle()
{
return getPreferenceGroup("Decorations")->GetInt("LineStyleHighLight", 10);
}
int Preferences::HiddenLineStyle()
{
return getPreferenceGroup("Decorations")->GetInt("LineStyleHidden", 1);
}
int Preferences::LineSpacingISO()
{
return getPreferenceGroup("Dimensions")->GetInt("LineSpacingFactorISO", 2);
}
std::string Preferences::currentLineDefFile()
{
std::string lineDefDir = Preferences::lineDefinitionLocation();
std::vector<std::string> choices = LineGenerator::getAvailableLineStandards();
std::string fileName = choices.at(Preferences::lineStandard()) + ".LineDef.csv";
return lineDefDir + fileName;
}
std::string Preferences::currentElementDefFile()
{
std::string lineDefDir = Preferences::lineElementsLocation();
std::vector<std::string> choices = LineGenerator::getAvailableLineStandards();
std::string fileName = choices.at(Preferences::lineStandard()) + ".ElementDef.csv";
return lineDefDir + fileName;
}
//! returns a Qt::PenCapStyle based on the index of the preference comboBox.
//! the comboBox choices are 0-Round, 1-Square, 2-Flat. The Qt::PenCapStyles are
//! 0x00-Flat, 0x10-Square, 0x20-Round
int Preferences::LineCapStyle()
{
int currentIndex = LineCapIndex();
int result{0x20};
switch (currentIndex) {
case 0:
result = static_cast<Qt::PenCapStyle>(0x20); //round;
break;
case 1:
result = static_cast<Qt::PenCapStyle>(0x10); //square;
break;
case 2:
result = static_cast<Qt::PenCapStyle>(0x00); //flat
break;
default:
result = static_cast<Qt::PenCapStyle>(0x20);
}
return result;
}
//! returns the line cap index without conversion to a Qt::PenCapStyle
int Preferences::LineCapIndex()
{
return getPreferenceGroup("General")->GetInt("EdgeCapStyle", 0x20);
}

View File

@@ -64,7 +64,6 @@ public:
static bool keepPagesUpToDate();
static int projectionAngle();
static int lineGroup();
static int balloonArrow();
static double balloonKinkLength();
@@ -72,7 +71,6 @@ public:
static QString defaultTemplate();
static QString defaultTemplateDir();
static std::string lineGroupFile();
static const double DefaultFontSizeInMM;
static const double DefaultArrowSize;