diff --git a/src/Mod/TechDraw/Gui/QGISectionLine.cpp b/src/Mod/TechDraw/Gui/QGISectionLine.cpp
index 459ff9fd9a..e29136c072 100644
--- a/src/Mod/TechDraw/Gui/QGISectionLine.cpp
+++ b/src/Mod/TechDraw/Gui/QGISectionLine.cpp
@@ -32,6 +32,8 @@
#include
#include
+#include
+
#include
#include "Rez.h"
#include "QGIView.h"
@@ -44,9 +46,9 @@ QGISectionLine::QGISectionLine()
m_symbol = "";
m_symSize = 0.0;
- m_extLen = Rez::guiX(8.0);
- m_arrowSize = 0.0;
-
+ m_extLen = Rez::guiX(QGIArrow::getPrefArrowSize());
+ m_arrowSize = QGIArrow::getPrefArrowSize();
+
m_line = new QGraphicsPathItem();
addToGroup(m_line);
m_arrow1 = new QGIArrow();
@@ -78,9 +80,17 @@ void QGISectionLine::makeLine()
QPainterPath pp;
QPointF extLineStart,extLineEnd;
QPointF offset(m_arrowDir.x,-m_arrowDir.y);
- offset = 0.75 * m_extLen * offset; //0.75 is hack to hide line end behind arrowhead
- extLineStart = m_start + offset;
- extLineEnd = m_end + offset;
+ int format = getPrefSectionFormat();
+ if (format == 0) { //"ASME"
+ offset = 0.75 * m_extLen * offset; //0.75 is hack to hide line end behind arrowhead
+ extLineStart = m_start + offset;
+ extLineEnd = m_end + offset;
+ } else { //"ISO"
+ offset = 2.0* m_extLen * offset;
+ extLineStart = m_start - offset;
+ extLineEnd = m_end - offset;
+ }
+
pp.moveTo(extLineStart);
pp.lineTo(m_start);
pp.lineTo(m_end);
@@ -89,6 +99,16 @@ void QGISectionLine::makeLine()
}
void QGISectionLine::makeArrows()
+{
+ int format = getPrefSectionFormat();
+ if (format == 0) {
+ makeArrowsTrad();
+ } else {
+ makeArrowsISO();
+ }
+}
+//make Euro (ISO) Arrows
+void QGISectionLine::makeArrowsISO()
{
double arrowRotation = 0.0;
m_arrowDir.Normalize();
@@ -100,46 +120,125 @@ void QGISectionLine::makeArrows()
QPointF extLineStart,extLineEnd;
QPointF offset(m_arrowDir.x,-m_arrowDir.y); //remember Y dir is flipped
- offset = m_extLen * offset;
+ offset = (m_extLen + (2.0 * QGIArrow::getPrefArrowSize())) * offset * -1.0;
extLineStart = m_start + offset;
extLineEnd = m_end + offset;
m_arrow1->setStyle(0);
- m_arrow2->setStyle(0);
- m_arrow1->setPos(extLineStart);
- //m_arrow1->flip(true);
+ m_arrow1->setSize(QGIArrow::getPrefArrowSize());
+ m_arrow1->setPos(m_start);
m_arrow1->draw();
m_arrow1->setRotation(arrowRotation); //rotation = 0 ==> -> horizontal, pointing right
+
+ m_arrow2->setStyle(0);
+ m_arrow2->setSize(QGIArrow::getPrefArrowSize());
+ m_arrow2->setPos(m_end);
+ m_arrow2->draw();
+ m_arrow2->setRotation(arrowRotation);
+}
+
+//make traditional (ASME) section arrows
+void QGISectionLine::makeArrowsTrad()
+{
+ double arrowRotation = 0.0;
+ m_arrowDir.Normalize();
+ double angle = atan2f(m_arrowDir.y,m_arrowDir.x);
+ if (angle < 0.0) {
+ angle = 2 * M_PI + angle;
+ }
+ arrowRotation = 360.0 - angle * (180.0/M_PI); //convert to Qt rotation (clockwise degrees)
+
+ QPointF extLineStart,extLineEnd;
+ QPointF offset(m_arrowDir.x,-m_arrowDir.y); //remember Y dir is flipped
+ offset = (m_extLen + (2.0 * QGIArrow::getPrefArrowSize())) * offset;
+ extLineStart = m_start + offset;
+ extLineEnd = m_end + offset;
+
+ m_arrow1->setStyle(0);
+ m_arrow1->setSize(QGIArrow::getPrefArrowSize());
+ m_arrow1->setPos(extLineStart);
+ m_arrow1->draw();
+ m_arrow1->setRotation(arrowRotation); //rotation = 0 ==> -> horizontal, pointing right
+
+ m_arrow2->setStyle(0);
+ m_arrow2->setSize(QGIArrow::getPrefArrowSize());
m_arrow2->setPos(extLineEnd);
m_arrow2->draw();
m_arrow2->setRotation(arrowRotation);
}
void QGISectionLine::makeSymbols()
+{
+ int format = getPrefSectionFormat();
+ if (format == 0) {
+ makeSymbolsTrad();
+ } else {
+ makeSymbolsISO();
+ }
+}
+
+void QGISectionLine::makeSymbolsTrad()
{
QPointF extLineStart,extLineEnd;
QPointF offset(m_arrowDir.x,-m_arrowDir.y);
offset = 1.5 * m_extLen * offset;
extLineStart = m_start + offset;
extLineEnd = m_end + offset;
-
prepareGeometryChange();
m_symFont.setPointSize(m_symSize);
m_symbol1->setFont(m_symFont);
m_symbol1->setPlainText(QString::fromUtf8(m_symbol));
if (m_arrowDir.y < 0.0) { //pointing down
- extLineStart -= QPointF (0.0,m_symSize); //move text up a bit
+ extLineStart += QPointF (0.0, m_symSize); //move text down a bit
+ } else if (m_arrowDir.y > 0.0) { //pointing up
+ extLineStart -= QPointF (0.0, m_symSize); //move text up a bit
+ }
+ if (m_arrowDir.x < 0.0) { //pointing left
+ extLineStart -= QPointF (m_symSize, 0.0); //move text left a bit
+ } else if (m_arrowDir.x > 0.0) { //pointing rightup
+ extLineStart += QPointF (m_symSize, 0.0); //move text right a bit
}
m_symbol1->centerAt(extLineStart);
+
m_symbol2->setFont(m_symFont);
m_symbol2->setPlainText(QString::fromUtf8(m_symbol));
if (m_arrowDir.y < 0.0) { //pointing down
- extLineEnd -= QPointF (0.0,m_symSize);
+ extLineEnd += QPointF (0.0, m_symSize); //move text down a bit
+ } else if (m_arrowDir.y > 0.0) { //pointing up
+ extLineEnd -= QPointF (0.0, m_symSize); //move text up a bit
+ }
+ if (m_arrowDir.x < 0.0) { //pointing left
+ extLineEnd -= QPointF (m_symSize, 0.0); //move text left a bit
+ } else if (m_arrowDir.x > 0.0) { //pointing rightup
+ extLineEnd += QPointF (m_symSize, 0.0); //move text right a bit
}
m_symbol2->centerAt(extLineEnd);
+
}
+void QGISectionLine::makeSymbolsISO()
+{
+ QPointF symPosStart, symPosEnd;
+ QPointF dist = (m_start - m_end);
+ double lenDist = sqrt(dist.x()*dist.x() + dist.y()*dist.y());
+ QPointF distDir = dist / lenDist;
+
+ QPointF offset = m_extLen * distDir;
+ symPosStart = m_start + offset;
+ symPosEnd = m_end - offset;
+ prepareGeometryChange();
+ m_symFont.setPointSize(m_symSize);
+ m_symbol1->setFont(m_symFont);
+ m_symbol1->setPlainText(QString::fromUtf8(m_symbol));
+ m_symbol1->centerAt(symPosStart);
+
+ m_symbol2->setFont(m_symFont);
+ m_symbol2->setPlainText(QString::fromUtf8(m_symbol));
+ m_symbol2->centerAt(symPosEnd);
+
+}
+
void QGISectionLine::setBounds(double x1,double y1,double x2,double y2)
{
m_start = QPointF(x1,y1);
@@ -177,6 +276,7 @@ QColor QGISectionLine::getSectionColor()
return fcColor.asValue();
}
+//SectionLineStyle
Qt::PenStyle QGISectionLine::getSectionStyle()
{
Base::Reference hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
@@ -185,6 +285,16 @@ Qt::PenStyle QGISectionLine::getSectionStyle()
return sectStyle;
}
+//ASME("traditional") vs ISO("reference arrow method") arrows
+int QGISectionLine::getPrefSectionFormat()
+{
+ Base::Reference hGrp = App::GetApplication().GetUserParameter().
+ GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Format");
+ int format = hGrp->GetInt("SectionFormat", 0);
+ return format;
+}
+
+
void QGISectionLine::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
QStyleOptionGraphicsItem myOption(*option);
myOption.state &= ~QStyle::State_Selected;
diff --git a/src/Mod/TechDraw/Gui/QGISectionLine.h b/src/Mod/TechDraw/Gui/QGISectionLine.h
index 20f225ef05..07caf2d2f4 100644
--- a/src/Mod/TechDraw/Gui/QGISectionLine.h
+++ b/src/Mod/TechDraw/Gui/QGISectionLine.h
@@ -61,8 +61,13 @@ protected:
Qt::PenStyle getSectionStyle();
void makeLine();
void makeArrows();
+ void makeArrowsTrad();
+ void makeArrowsISO();
void makeSymbols();
+ void makeSymbolsTrad();
+ void makeSymbolsISO();
void setTools();
+ int getPrefSectionFormat();
private:
char* m_symbol;
@@ -80,6 +85,7 @@ private:
double m_arrowSize;
//QColor m_color;
double m_extLen;
+ int m_sectionFormat; //0 = ASME, 1 = ISO
};
}