diff --git a/src/Mod/TechDraw/App/DrawViewSymbol.cpp b/src/Mod/TechDraw/App/DrawViewSymbol.cpp
index afec6bc3f..2a63f39bd 100644
--- a/src/Mod/TechDraw/App/DrawViewSymbol.cpp
+++ b/src/Mod/TechDraw/App/DrawViewSymbol.cpp
@@ -35,6 +35,7 @@
#include
#include
+#include "DrawPage.h"
#include "DrawViewSymbol.h"
using namespace TechDraw;
@@ -117,29 +118,43 @@ App::DocumentObjectExecReturn *DrawViewSymbol::execute(void)
QRectF DrawViewSymbol::getRect() const
{
- std::string svg = Symbol.getValue();
double w = 64.0; //must default to something
double h = 64.0;
- string::const_iterator begin, end;
- begin = svg.begin();
- end = svg.end();
- boost::match_results what;
+ return (QRectF(0,0,w,h));
+// std::string svg = Symbol.getValue();
+// string::const_iterator begin, end;
+// begin = svg.begin();
+// end = svg.end();
+// boost::match_results what;
- boost::regex e1 ("width=\"([0-9.]*?)[a-zA-Z]*?\"");
- if (boost::regex_search(begin, end, what, e1)) {
- //std::string wText = what[0].str(); //this is the whole match 'width="100"'
- std::string wNum = what[1].str(); //this is just the number 100
- w = std::stod(wNum);
- }
- boost::regex e2 ("Height=\"([0-9.]*?)[a-zA-Z]*?\"");
- if (boost::regex_search(begin, end, what, e1)) {
- //std::string hText = what[0].str();
- std::string hNum = what[1].str();
- h = std::stod(hNum);
- }
- return (QRectF(0,0,Scale.getValue() * w,Scale.getValue() * h));
+// boost::regex e1 ("width=\"([0-9.]*?)[a-zA-Z]*?\"");
+// if (boost::regex_search(begin, end, what, e1)) {
+// //std::string wText = what[0].str(); //this is the whole match 'width="100"'
+// std::string wNum = what[1].str(); //this is just the number 100
+// w = std::stod(wNum);
+// }
+//
+// boost::regex e2 ("height=\"([0-9.]*?)[a-zA-Z]*?\"");
+// if (boost::regex_search(begin, end, what, e2)) {
+// //std::string hText = what[0].str();
+// std::string hNum = what[1].str();
+// h = std::stod(hNum);
+// }
+// return (QRectF(0,0,Scale.getValue() * w,Scale.getValue() * h));
+//we now have a w x h, but we don't really know what it means - px,mm,in,...
+
}
+//!Assume all svg files fit the page and/or the user will scale manually
+//see getRect() above
+bool DrawViewSymbol::checkFit(TechDraw::DrawPage* p) const
+{
+ (void)p;
+ bool result = true;
+ return result;
+}
+
+
// Python Drawing feature ---------------------------------------------------------
diff --git a/src/Mod/TechDraw/App/DrawViewSymbol.h b/src/Mod/TechDraw/App/DrawViewSymbol.h
index 665b42fcb..da7e049c2 100644
--- a/src/Mod/TechDraw/App/DrawViewSymbol.h
+++ b/src/Mod/TechDraw/App/DrawViewSymbol.h
@@ -32,6 +32,7 @@
namespace TechDraw
{
+class DrawPage;
class TechDrawExport DrawViewSymbol : public TechDraw::DrawView
@@ -57,6 +58,8 @@ public:
return "TechDrawGui::ViewProviderSymbol";
}
virtual QRectF getRect() const;
+ virtual bool checkFit(TechDraw::DrawPage* p) const override;
+
protected:
virtual void onChanged(const App::Property* prop);
diff --git a/src/Mod/TechDraw/Gui/CMakeLists.txt b/src/Mod/TechDraw/Gui/CMakeLists.txt
index a0221bc8b..09cdad3e4 100644
--- a/src/Mod/TechDraw/Gui/CMakeLists.txt
+++ b/src/Mod/TechDraw/Gui/CMakeLists.txt
@@ -94,6 +94,8 @@ SET(TechDrawGui_SRCS
TaskSectionView.h
DrawGuiUtil.cpp
DrawGuiUtil.h
+ Rez.cpp
+ Rez.h
)
SET(TechDrawGuiView_SRCS
MDIViewPage.cpp
diff --git a/src/Mod/TechDraw/Gui/MDIViewPage.cpp b/src/Mod/TechDraw/Gui/MDIViewPage.cpp
index 741989f81..919b4eb4d 100644
--- a/src/Mod/TechDraw/Gui/MDIViewPage.cpp
+++ b/src/Mod/TechDraw/Gui/MDIViewPage.cpp
@@ -77,6 +77,7 @@
#include
#include
+#include "Rez.h"
#include "QGIDrawingTemplate.h"
#include "QGIView.h"
#include "QGIViewPart.h"
@@ -169,8 +170,8 @@ MDIViewPage::MDIViewPage(ViewProviderPage *pageVp, Gui::Document* doc, QWidget*
auto pageTemplate( dynamic_cast(obj) );
if( pageTemplate ) {
//make sceneRect 1 pagesize bigger in every direction
- double width = pageTemplate->Width.getValue();
- double height = pageTemplate->Height.getValue();
+ double width = Rez::guiX(pageTemplate->Width.getValue());
+ double height = Rez::guiX(pageTemplate->Height.getValue());
m_view->scene()->setSceneRect(QRectF(-width,-2.0 * height,3.0*width,3.0*height));
attachTemplate(pageTemplate);
viewAll();
@@ -254,8 +255,8 @@ void MDIViewPage::attachTemplate(TechDraw::DrawTemplate *obj)
QPointF MDIViewPage::getTemplateCenter(TechDraw::DrawTemplate *obj)
{
- double cx = obj->Width.getValue()/2.0;
- double cy = -obj->Height.getValue()/2.0;
+ double cx = Rez::guiX(obj->Width.getValue())/2.0;
+ double cy = -Rez::guiX(obj->Height.getValue())/2.0;
QPointF result(cx,cy);
return result;
}
@@ -731,8 +732,8 @@ void MDIViewPage::print(QPrinter* printer)
double width = 0.0;
double height = 0.0;
if( pageTemplate ) {
- width = pageTemplate->Width.getValue();
- height = pageTemplate->Height.getValue();
+ width = Rez::guiX(pageTemplate->Width.getValue());
+ height = Rez::guiX(pageTemplate->Height.getValue());
}
QRectF sourceRect(0.0,-height,width,height);
diff --git a/src/Mod/TechDraw/Gui/QGIArrow.cpp b/src/Mod/TechDraw/Gui/QGIArrow.cpp
index ab06a0ecf..3d3c4165e 100644
--- a/src/Mod/TechDraw/Gui/QGIArrow.cpp
+++ b/src/Mod/TechDraw/Gui/QGIArrow.cpp
@@ -32,6 +32,11 @@
#include
#endif
+#include
+#include
+#include
+
+#include "Rez.h"
#include "QGIArrow.h"
using namespace TechDrawGui;
@@ -56,39 +61,75 @@ void QGIArrow::flip(bool state) {
}
void QGIArrow::draw() {
- // the center is the end point on a dimension
QPainterPath path;
- //QPen pen(Qt::black);
- //pen.setWidth(1);
-
- //QBrush brush(Qt::black);
- //setPen(pen);
- //setBrush(brush);
-
- float length = -m_size; //TODO: Arrow heads sb preference? size & type?
-
- if(isFlipped)
- length *= -1;
- path.moveTo(QPointF(0.,0.));
- path.lineTo(QPointF(length,-0.6));
- path.lineTo(QPointF(length, 0.6));
-
- path.closeSubpath();
-// path.moveTo(QPointF(-1,1));
-// path.lineTo(QPointF(1,-1));
+ if (m_style == 0) {
+ path = makeFilledTriangle(m_size,m_size/6.0,isFlipped); //"arrow l/w sb 3/1" ??
+ } else if (m_style == 1) {
+ path = makeOpenArrow(m_size,m_size/3.0,isFlipped); //broad arrow?
+ } else if (m_style == 2) {
+ path = makeHashMark(m_size/2.0,m_size/2.0,isFlipped); //big enough?
+ }
setPath(path);
}
void QGIArrow::setSize(double s)
{
m_size = s;
- //???
}
-void QGIArrow::setStyle(int s)
+
+QPainterPath QGIArrow::makeFilledTriangle(double length, double width, bool flipped)
{
- m_style = s;
- //???
+//(0,0) is tip of arrow
+ if (!flipped) {
+ length *= -1;
+ }
+
+ QPainterPath path;
+ path.moveTo(QPointF(0.,0.));
+ path.lineTo(QPointF(Rez::guiX(length),Rez::guiX(-width)));
+ path.lineTo(QPointF(Rez::guiX(length),Rez::guiX(width)));
+ path.closeSubpath();
+ m_fill = Qt::SolidPattern;
+ return path;
+}
+
+QPainterPath QGIArrow::makeOpenArrow(double length, double width, bool flipped)
+{
+//(0,0) is tip of arrow
+ if (!flipped) {
+ length *= -1;
+ }
+
+ QPainterPath path;
+ path.moveTo(QPointF(Rez::guiX(length),Rez::guiX(-width)));
+ path.lineTo(QPointF(0.,0.));
+ path.lineTo(QPointF(Rez::guiX(length),Rez::guiX(width)));
+ m_fill = Qt::NoBrush;
+ return path;
+}
+
+QPainterPath QGIArrow::makeHashMark(double length, double width, bool flipped)
+{
+ double adjWidth = 1.0;
+//(0,0) is tip of arrow
+ if (!flipped) {
+ length *= -1;
+ adjWidth *= -1;
+ }
+ QPainterPath path;
+ path.moveTo(QPointF(Rez::guiX(length),Rez::guiX(adjWidth * (-width))));
+ path.lineTo(QPointF(Rez::guiX(-length),Rez::guiX(adjWidth * width)));
+ m_fill = Qt::NoBrush;
+ return path;
+}
+
+int QGIArrow::getPrefArrowStyle()
+{
+ Base::Reference hGrp = App::GetApplication().GetUserParameter().
+ GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
+ int style = hGrp->GetInt("ArrowStyle", 0);
+ return style;
}
void QGIArrow::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
@@ -96,6 +137,7 @@ void QGIArrow::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QStyleOptionGraphicsItem myOption(*option);
myOption.state &= ~QStyle::State_Selected;
+ setPen(m_pen);
m_brush.setColor(m_colCurrent);
m_brush.setStyle(m_fill);
setBrush(m_brush);
diff --git a/src/Mod/TechDraw/Gui/QGIArrow.h b/src/Mod/TechDraw/Gui/QGIArrow.h
index 2fef9a317..3c6019505 100644
--- a/src/Mod/TechDraw/Gui/QGIArrow.h
+++ b/src/Mod/TechDraw/Gui/QGIArrow.h
@@ -49,13 +49,18 @@ public:
double getSize() { return m_size; }
void setSize(double s);
int getStyle() { return m_style; }
- void setStyle(int s);
+ void setStyle(int s) { m_style = s; }
//QPainterPath shape() const;
+ static int getPrefArrowStyle();
+
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
protected:
//QVariant itemChange(GraphicsItemChange change, const QVariant &value);
-
+ QPainterPath makeFilledTriangle(double length, double width, bool flipped);
+ QPainterPath makeOpenArrow(double length, double width, bool flipped);
+ QPainterPath makeHashMark(double length, double width, bool flipped);
+
private:
QBrush m_brush;
Qt::BrushStyle m_fill;
diff --git a/src/Mod/TechDraw/Gui/QGISVGTemplate.cpp b/src/Mod/TechDraw/Gui/QGISVGTemplate.cpp
index 6317c86a7..7ee5b0f3c 100644
--- a/src/Mod/TechDraw/Gui/QGISVGTemplate.cpp
+++ b/src/Mod/TechDraw/Gui/QGISVGTemplate.cpp
@@ -40,6 +40,7 @@
#include
#include
+#include "Rez.h"
#include "ZVALUE.h"
#include "TemplateTextField.h"
#include "QGISVGTemplate.h"
@@ -100,15 +101,15 @@ void QGISVGTemplate::load(const QString &fileName)
firstTime = false;
}
- //This is probably first time only logic too.
+ //convert from pixels or mm or inches in svg file to mm page size
TechDraw::DrawSVGTemplate *tmplte = getSVGTemplate();
double xaspect, yaspect;
xaspect = tmplte->getWidth() / (double) size.width();
yaspect = tmplte->getHeight() / (double) size.height();
QTransform qtrans;
- qtrans.translate(0.f, -tmplte->getHeight());
- qtrans.scale(xaspect , yaspect);
+ qtrans.translate(0.f, Rez::guiX(-tmplte->getHeight()));
+ qtrans.scale(Rez::guiX(xaspect) , Rez::guiX(yaspect));
m_svgItem->setTransform(qtrans);
}
@@ -190,11 +191,11 @@ void QGISVGTemplate::createClickHandles(void)
QString yStr = QString::fromStdString(yMatch[1].str());
QString editableName = QString::fromStdString(nameMatch[1].str());
- double x = xStr.toDouble();
- double y = yStr.toDouble();
+ double x = Rez::guiX(xStr.toDouble());
+ double y = Rez::guiX(yStr.toDouble());
//TODO: this should probably be configurable without a code change
- double editClickBoxSize = 1.5;
+ double editClickBoxSize = Rez::guiX(1.5);
QColor editClickBoxColor = Qt::green;
double width = editClickBoxSize;
@@ -202,7 +203,7 @@ void QGISVGTemplate::createClickHandles(void)
TemplateTextField *item = new TemplateTextField(this, tmplte, nameMatch[1].str(), qgview);
float pad = 1;
- item->setRect(x - pad, -tmplte->getHeight() + y - height - pad,
+ item->setRect(x - pad, Rez::guiX(-tmplte->getHeight()) + y - height - pad,
width + 2 * pad, height + 2 * pad);
QPen myPen;
diff --git a/src/Mod/TechDraw/Gui/QGISectionLine.cpp b/src/Mod/TechDraw/Gui/QGISectionLine.cpp
index b3022f0c1..8350ccc3b 100644
--- a/src/Mod/TechDraw/Gui/QGISectionLine.cpp
+++ b/src/Mod/TechDraw/Gui/QGISectionLine.cpp
@@ -33,6 +33,7 @@
#include
#include
+#include "Rez.h"
#include "QGIView.h"
#include "QGISectionLine.h"
@@ -40,7 +41,7 @@ using namespace TechDrawGui;
QGISectionLine::QGISectionLine()
{
- m_extLen = 8.0;
+ m_extLen = Rez::guiX(8.0);
m_arrowSize = 0.0;
m_line = new QGraphicsPathItem();
@@ -54,7 +55,7 @@ QGISectionLine::QGISectionLine()
m_symbol2 = new QGCustomText();
addToGroup(m_symbol2);
- setWidth(0.75);
+ setWidth(Rez::guiX(0.75));
setStyle(getSectionStyle());
setColor(getSectionColor());
@@ -74,7 +75,7 @@ void QGISectionLine::makeLine()
QPainterPath pp;
QPointF extLineStart,extLineEnd;
QPointF offset(m_arrowDir.x,-m_arrowDir.y);
- offset = 0.80 * m_extLen * offset; //0.80 is hack to hide line end behind arrowhead
+ offset = 0.75 * m_extLen * offset; //0.75 is hack to hide line end behind arrowhead
extLineStart = m_start + offset;
extLineEnd = m_end + offset;
pp.moveTo(extLineStart);
@@ -100,6 +101,8 @@ void QGISectionLine::makeArrows()
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->draw();
@@ -121,9 +124,15 @@ void QGISectionLine::makeSymbols()
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
+ }
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);
+ }
m_symbol2->centerAt(extLineEnd);
}
diff --git a/src/Mod/TechDraw/Gui/QGIView.cpp b/src/Mod/TechDraw/Gui/QGIView.cpp
index e06122a7e..011c7043c 100644
--- a/src/Mod/TechDraw/Gui/QGIView.cpp
+++ b/src/Mod/TechDraw/Gui/QGIView.cpp
@@ -45,6 +45,7 @@
#include
#include
+#include "Rez.h"
#include "QGCustomBorder.h"
#include "QGCustomLabel.h"
#include "QGIView.h"
@@ -190,11 +191,11 @@ void QGIView::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
tempY = getY();
// getViewObject()->X.setValue(tempX);
// getViewObject()->Y.setValue(tempY);
- getViewObject()->setPosition(tempX,tempY);
+ getViewObject()->setPosition(Rez::appX(tempX),Rez::appX(tempY));
} else {
// getViewObject()->X.setValue(x());
// getViewObject()->Y.setValue(getYInClip(y()));
- getViewObject()->setPosition(x(),getYInClip(y()));
+ getViewObject()->setPosition(Rez::appX(x()),Rez::appX(getYInClip(y())));
}
getViewObject()->setMouseMove(false);
}
@@ -244,7 +245,7 @@ double QGIView::getYInClip(double y)
if (parentView) {
auto parentFeat( dynamic_cast(parentView->getViewObject()) );
if (parentFeat) {
- return parentFeat->Height.getValue() - y;
+ return Rez::guiX(parentFeat->Height.getValue()) - y;
}
}
}
@@ -259,8 +260,8 @@ void QGIView::updateView(bool update)
if (update ||
getViewObject()->X.isTouched() ||
getViewObject()->Y.isTouched()) {
- double featX = getViewObject()->X.getValue();
- double featY = getViewObject()->Y.getValue();
+ double featX = Rez::guiX(getViewObject()->X.getValue());
+ double featY = Rez::guiX(getViewObject()->Y.getValue());
setPosition(featX,featY);
}
@@ -501,7 +502,7 @@ double QGIView::getPrefFontSize()
Base::Reference hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Labels");
double fontSize = hGrp->GetFloat("LabelSize", 5.0);
- return fontSize;
+ return Rez::guiX(fontSize);
}
void QGIView::dumpRect(char* text, QRectF r) {
diff --git a/src/Mod/TechDraw/Gui/QGIViewAnnotation.cpp b/src/Mod/TechDraw/Gui/QGIViewAnnotation.cpp
index b21cd5ebb..1eabc8089 100644
--- a/src/Mod/TechDraw/Gui/QGIViewAnnotation.cpp
+++ b/src/Mod/TechDraw/Gui/QGIViewAnnotation.cpp
@@ -50,6 +50,7 @@
#include
#include
+#include "Rez.h"
#include "QGIViewAnnotation.h"
#include "QGCustomText.h"
@@ -129,7 +130,7 @@ void QGIViewAnnotation::drawAnnotation()
ss << "\n\n