[TD]add arrow style - Pyramid

- contributed by @lidiriel
This commit is contained in:
WandererFan
2019-12-29 22:00:48 -05:00
committed by WandererFan
parent 6886621008
commit 911ab15224
5 changed files with 179 additions and 21 deletions

View File

@@ -84,7 +84,7 @@
<property name="toolTip">
<string>Dimension text color</string>
</property>
<property name="color">
<property name="color" stdset="0">
<color>
<red>0</red>
<green>0</green>
@@ -225,6 +225,16 @@
<normaloff>:/icons/arrowfork.svg</normaloff>:/icons/arrowfork.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>6 - Pyramid</string>
</property>
<property name="icon">
<iconset>
<normalon>:/icons/arrowpyramid.svg</normalon>
</iconset>
</property>
</item>
</widget>
</item>
<item row="8" column="0">
@@ -254,11 +264,11 @@
</widget>
</item>
<item row="4" column="2">
<widget class="Gui::PrefUnitSpinBox" name="plsb_FontSize">
<widget class="Gui::PrefUnitSpinBox" name="plsb_FontSize" native="true">
<property name="toolTip">
<string>Dimension font size in units</string>
</property>
<property name="value">
<property name="value" stdset="0">
<double>5.000000000000000</double>
</property>
<property name="prefEntry" stdset="0">
@@ -270,11 +280,11 @@
</widget>
</item>
<item row="9" column="2">
<widget class="Gui::PrefUnitSpinBox" name="plsb_ArrowSize">
<widget class="Gui::PrefUnitSpinBox" name="plsb_ArrowSize" native="true">
<property name="toolTip">
<string>Dimension arrowhead size in units</string>
</property>
<property name="value">
<property name="value" stdset="0">
<double>3.500000000000000</double>
</property>
<property name="prefEntry" stdset="0">
@@ -395,7 +405,7 @@
<property name="toolTip">
<string>Color for centerlines</string>
</property>
<property name="color">
<property name="color" stdset="0">
<color>
<red>175</red>
<green>175</green>
@@ -585,7 +595,7 @@
<property name="toolTip">
<string>Line color for sectionlines</string>
</property>
<property name="color">
<property name="color" stdset="0">
<color>
<red>175</red>
<green>175</green>
@@ -648,7 +658,7 @@
<property name="toolTip">
<string>Vertex display color</string>
</property>
<property name="color">
<property name="color" stdset="0">
<color>
<red>150</red>
<green>147</green>

View File

@@ -62,40 +62,47 @@ QGIArrow::QGIArrow() :
void QGIArrow::draw() {
QPainterPath path;
if (m_style == 0) {
if (m_style == FILLED_TRIANGLE) {
setFillStyle(Qt::SolidPattern);
if (m_dirMode) {
path = makeFilledTriangle(getDirection(), m_size,m_size/6.0);
} else {
path = makeFilledTriangle(m_size,m_size/6.0,isFlipped()); //"arrow l/w sb 3/1" ??
}
} else if (m_style == 1) {
} else if (m_style == OPEN_ARROW) {
setFillStyle(Qt::NoBrush);
if (m_dirMode) {
path = makeOpenArrow(getDirection(), m_size,m_size/3.0); //broad arrow?
} else {
path = makeOpenArrow(m_size,m_size/3.0,isFlipped());
}
} else if (m_style == 2) {
} else if (m_style == HASH_MARK) {
setFillStyle(Qt::NoBrush);
if (m_dirMode) {
path = makeHashMark(getDirection(), m_size/2.0,m_size/2.0); //big enough?
} else {
path = makeHashMark(m_size/2.0,m_size/2.0,isFlipped()); //big enough?
}
} else if (m_style == 3) {
} else if (m_style == DOT) {
setFillStyle(Qt::SolidPattern);
path = makeDot(m_size/2.0,m_size/2.0,isFlipped());
} else if (m_style == 4) {
} else if (m_style == OPEN_CIRCLE) {
path = makeOpenDot(m_size/2.0,m_size/2.0,isFlipped());
} else if (m_style == 5) {
} else if (m_style == FORK) {
setFillStyle(Qt::NoBrush);
if (m_dirMode) {
path = makeForkArrow(getDirection(), m_size/2.0,m_size/2.0); //big enough?
} else {
path = makeForkArrow(m_size/2.0,m_size/2.0,isFlipped()); //big enough?
}
} else {
} else if (m_style == PYRAMID){
setFillStyle(Qt::SolidPattern);
if (m_dirMode) {
path = makePyramid(getDirection(), m_size);
} else {
path = makePyramid(m_size,isFlipped());
}
}else {
path = makeFilledTriangle(m_size,m_size/6.0,isFlipped()); //sb a question mark or ???
}
setPath(path);
@@ -262,7 +269,47 @@ QPainterPath QGIArrow::makeForkArrow(Base::Vector3d dir, double length, double w
return path;
}
QPainterPath QGIArrow::makePyramid(double length, bool flipped)
{
double half_width = length/2.;
double top = -length;
double base = 0.;
// [(0,-width), (0, width)] is base of arrow
if (flipped) {
top = 0.;
base = -length;
}
top = Rez::guiX(top);
base = Rez::guiX(base);
QPainterPath path;
path.moveTo(QPointF(top, 0.));
path.lineTo(QPointF(base,Rez::guiX(-half_width)));
path.lineTo(QPointF(base,Rez::guiX(half_width)));
path.closeSubpath();
setFillStyle(Qt::SolidPattern);
return path;
}
QPainterPath QGIArrow::makePyramid(Base::Vector3d dir, double length)
{
//(0,0) is tip of arrow
// dir is direction arrow points
Base::Vector3d negDir = -dir;
negDir.Normalize();
double width = length / 2.;
Base::Vector3d perp(-negDir.y,negDir.x, 0.0);
Base::Vector3d barb1 = perp * width;
Base::Vector3d barb2 = perp * -width;
Base::Vector3d top = negDir * length;
QPainterPath path;
path.moveTo(QPointF(Rez::guiX(top.x),Rez::guiX(top.y)));
path.lineTo(QPointF(Rez::guiX(barb1.x),Rez::guiX(barb1.y)));
path.lineTo(QPointF(Rez::guiX(barb2.x),Rez::guiX(barb2.y)));
path.closeSubpath();
setFillStyle(Qt::SolidPattern);
return path;
}
int QGIArrow::getPrefArrowStyle()
{
@@ -289,25 +336,28 @@ double QGIArrow::getOverlapAdjust(int style, double size)
// Base::Console().Message("QGIA::getOverlapAdjust(%d, %.3f) \n",style, size);
double result = 1.0;
switch(style) {
case 0: //filled triangle
case FILLED_TRIANGLE:
result = 0.50 * size;
break;
case 1: //open arrow
case OPEN_ARROW:
result = 0.10 * size;
break;
case 2: //hash mark
case HASH_MARK:
result = 0.0;
break;
case 3: //dot
case DOT:
result = 0.0;
break;
case 4: //open circle
case OPEN_CIRCLE:
//diameter is size/2 so radius is size/4
result = 0.25 * size;
break;
case 5: //fork
case FORK:
result = 0.0;
break;
case PYRAMID:
result = 0.0;
break;
default: //unknown
result = 1.0;
}

View File

@@ -35,6 +35,16 @@ QT_END_NAMESPACE
namespace TechDrawGui
{
enum ArrowType {
FILLED_TRIANGLE = 0,
OPEN_ARROW,
HASH_MARK,
DOT,
OPEN_CIRCLE,
FORK,
PYRAMID
};
class TechDrawGuiExport QGIArrow : public QGIPrimPath
{
public:
@@ -75,6 +85,8 @@ protected:
QPainterPath makeOpenDot(double length, double width, bool flipped);
QPainterPath makeForkArrow(double length, double width, bool flipped);
QPainterPath makeForkArrow(Base::Vector3d dir, double length, double width);
QPainterPath makePyramid(double length, bool flipped);
QPainterPath makePyramid(Base::Vector3d dir, double length);
private:
QBrush m_brush;

View File

@@ -42,6 +42,7 @@
<file>icons/arrowopen.svg</file>
<file>icons/arrowtick.svg</file>
<file>icons/arrowfork.svg</file>
<file>icons/arrowpyramid.svg</file>
<file>icons/actions/techdraw-PageDefault.svg</file>
<file>icons/actions/techdraw-PageTemplate.svg</file>
<file>icons/actions/techdraw-View.svg</file>

View File

@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
width="48"
height="48"
id="svg3942"
sodipodi:docname="arrowpyramid.svg"
inkscape:version="0.92.4 (5da689c313, 2019-01-14)">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1027"
id="namedview11"
showgrid="false"
inkscape:zoom="4.9166667"
inkscape:cx="-16.677966"
inkscape:cy="23.186441"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg3942" />
<defs
id="defs3944" />
<metadata
id="metadata3947">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="g4527"
style="fill:#000000"
transform="matrix(1,0,0,1.44,-2.8474576,-14.832851)">
<g
id="g1461"
transform="translate(4.1150473,2.9827342)">
<path
sodipodi:type="star"
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:1.02752149"
id="path4521"
sodipodi:sides="3"
sodipodi:cx="35.837807"
sodipodi:cy="23.984524"
sodipodi:r1="14.433757"
sodipodi:r2="7.2168779"
sodipodi:arg1="-1.0471976"
sodipodi:arg2="0"
inkscape:flatsided="true"
inkscape:rounded="0"
inkscape:randomized="0"
d="m 43.054685,11.484523 10e-7,25.000001 -21.650636,-12.5 z"
inkscape:transform-center-x="3.6084379" />
<rect
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:1.48466444"
id="rect4523"
width="30.697916"
height="6.2105837"
x="2.4101348"
y="20.879232"
ry="1.2443622" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB