Hi Tim,
Marco what is the plan / status of that for 1.0?
Prior 1.0, there will be no major redesign of vector rendering mechanism. Post
1.0, I think it is absolutely necessary to do so and to let renderer subclasses
decide what shapes to draw.
I think the patch only makes sense if, as you suggested in February (see
below), the arrow heads can be enabled/disabled via vector layer props and the
state is saved to the project file.
If anyone vigorously disagrees let me know,
otherwise I'll incorporate your patch in 0.9.3 with some additions
from myself to enabled or disable line arrows via the layer props
dialog, the vector api and the layer properties serialisation
mechanism.
Regards,
Marco
-Ursprüngliche Nachricht-
Von: Tim Sutton [mailto:[EMAIL PROTECTED]
Gesendet: Mo 02.06.2008 22:10
An: Stefanie Tellex
Cc: qgis-user@lists.osgeo.org; Hugentobler Marco
Betreff: Re: [Qgis-user] lines with arrowheads
Hi
Yes I was for accepting the patch, but I believe others wanted to
wait under we had rendering stuff revised. Marco what is the plan /
status of that for 1.0? My feeling is we should reconsider the patch
if we wont have the render modules in place for 1.0
Regards
Tim
2008/6/2 Stefanie Tellex [EMAIL PROTECTED]:
I submitted a patch to do this a while back, but I don't think it was
accepted. I thought it was because it was decided to wait until a more
modular rendering pipeline was added, but I can't find the messages about
that in the thread. In fact the thread implies it would be accepted, but
if it made it into svn, I never noticed it.
(http://lists.osgeo.org/pipermail/qgis-developer/2008-February/003248.html)
The patches are attached. (arrows_in_linestrings draws arrows;
draw_start_and_stop draws a green dot at the start and a red dot at the
end.)
This message suggests an alternative solution that doesn't require compiling
qgis yourself:
http://lists.osgeo.org/pipermail/qgis-developer/2008-February/003250.html
Stefanie
M S wrote:
One of the outputs from r.flow in GRASS is downslope flow lines. Without
arrowheads (or some similar symbol like that) at the end of lines pointing
which way is downhill, the lines become ambiguous.
Is there a way to draw these lines with arrowheads? Or some other
approach that might achieve this?
Mark
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user
Index: qgis/qgis_unstable/src/core/qgsvectorlayer.cpp
===
--- qgis.orig/qgis_unstable/src/core/qgsvectorlayer.cpp 2008-06-02
12:17:11.0 -0400
+++ qgis/qgis_unstable/src/core/qgsvectorlayer.cpp 2008-06-02
12:34:47.0 -0400
@@ -360,7 +360,8 @@
QPainter* p,
const QgsMapToPixel* mtp,
const QgsCoordinateTransform* ct,
-bool drawingToEditingCanvas)
+bool drawingToEditingCanvas,
+bool drawArrows)
{
unsigned char *ptr = feature + 5;
unsigned int wkbType = *((int*)(feature+1));
@@ -432,6 +433,7 @@
// 255 = opaque
//
QPen myTransparentPen = p-pen(); // store current pen
+ QBrush brush = p-brush(); //to be kept as original
QColor myColor = myTransparentPen.color();
//only set transparency from layer level if renderer does not provide
//transparency on class level
@@ -459,8 +461,45 @@
}
}
+ // draw arrows
+ if (drawArrows) {
+#define PI 3.14159
+p-setBrush(QBrush(myColor, Qt::SolidPattern));
+
+for (int i = 0; i pa.size(); ++i)
+ {
+ if (i 0)
+ {
+ QPointF p1 = pa[i];
+ QPointF p2 = pa[i-1];
+
+ QLineF line = QLineF(p1, p2);
+ double angle = ::acos(line.dx() / line.length());
+ if (line.dy() = 0)
+ {
+ angle = (PI * 2) - angle;
+ }
+
+ float arrowSize = 5;
+ QPointF arrowP1 =
+ line.p1() + QPointF(sin(angle + PI / 3) * arrowSize,
+ cos(angle + PI / 3) * arrowSize);
+ QPointF arrowP2 =
+ line.p1() + QPointF(sin(angle + PI - PI / 3) * arrowSize,
+ cos(angle + PI - PI / 3) * arrowSize);
+ QPolygonF arrowHead;
+ arrowHead line.p1() arrowP1 arrowP2;
+ if (i % 2 == 0) {
+ p-drawPolygon(arrowHead);
+ }
+
+
+ }
+ }
+ }
//restore the pen
p-setPen(pen);
+ p-setBrush(brush);
return ptr;
}
@@ -3057,7 +3096,7 @@
p,
theMapToPixelTransform,
ct,
- drawingToEditingCanvas);
+ drawingToEditingCanvas, TRUE);
break;
}
case QGis::WKBMultiLineString:
Index: