[TD]Fix Svg Export Scaling issue

- change target rectangle for render to match source
- add param for endcap style (.../General/EdgeEndCap)
This commit is contained in:
wandererfan
2019-07-22 11:50:19 -04:00
committed by WandererFan
parent df05840212
commit 506886f388
3 changed files with 24 additions and 3 deletions

View File

@@ -41,7 +41,8 @@
using namespace TechDrawGui;
QGIPrimPath::QGIPrimPath():
m_width(0)
m_width(0),
m_capStyle(Qt::RoundCap)
{
setCacheMode(QGraphicsItem::NoCache);
setFlag(QGraphicsItem::ItemIsSelectable, true);
@@ -57,7 +58,9 @@ QGIPrimPath::QGIPrimPath():
m_colCurrent = getNormalColor();
m_styleCurrent = Qt::SolidLine;
m_pen.setStyle(m_styleCurrent);
m_pen.setCapStyle(Qt::RoundCap);
m_capStyle = prefCapStyle();
m_pen.setCapStyle(m_capStyle);
// m_pen.setCapStyle(Qt::FlatCap);
m_pen.setWidthF(m_width);
setPrettyNormal();
@@ -228,6 +231,11 @@ void QGIPrimPath::setNormalColor(QColor c)
m_colOverride = true;
}
void QGIPrimPath::setCapStyle(Qt::PenCapStyle c)
{
m_capStyle = c;
m_pen.setCapStyle(c);
}
Base::Reference<ParameterGrp> QGIPrimPath::getParmGroup()
{
@@ -236,6 +244,16 @@ Base::Reference<ParameterGrp> QGIPrimPath::getParmGroup()
return hGrp;
}
Qt::PenCapStyle QGIPrimPath::prefCapStyle()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
Qt::PenCapStyle result;
unsigned int cap = hGrp->GetUnsigned("EdgeCapStyle", 0x20); //0x00 FlatCap, 0x10 SquareCap, 0x20 RoundCap
result = (Qt::PenCapStyle) cap;
return result;
}
void QGIPrimPath::mousePressEvent(QGraphicsSceneMouseEvent * event)
{
QGIView *parent;

View File

@@ -57,6 +57,7 @@ public:
void setStyle(Qt::PenStyle s);
void setStyle(int s);
virtual void setNormalColor(QColor c);
virtual void setCapStyle(Qt::PenCapStyle c);
protected:
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
@@ -68,6 +69,7 @@ protected:
virtual QColor getPreColor(void);
virtual QColor getSelectColor(void);
Base::Reference<ParameterGrp> getParmGroup(void);
virtual Qt::PenCapStyle prefCapStyle(void);
bool isHighlighted;
QPen m_pen;
@@ -76,6 +78,7 @@ protected:
bool m_colOverride;
Qt::PenStyle m_styleCurrent;
double m_width;
Qt::PenCapStyle m_capStyle;
private:

View File

@@ -785,7 +785,7 @@ void QGVPage::saveSvg(QString filename)
double width = Rez::guiX(page->getPageWidth());
double height = Rez::guiX(page->getPageHeight());
QRectF sourceRect(0.0,-height,width,height);
QRectF targetRect;
QRectF targetRect(0.0,0.0,width,height);
Gui::Selection().clearSelection();
QPainter p;