[TD]add arrow style - Pyramid
- contributed by @lidiriel
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user