Re: [Qgis-developer] Is QGIS supports dynamic display?
Hi Martin, I implemented my own canvas item for SVG markers like you told me. But When I created a object of custom canvas item in main, it broke down. The error says 'This may be due to a corruption of the heap...', see more in error.jpg. I looked up for answers in exchange, which I found a similar topic here http://gis.stackexchange.com/questions/81465/how-to-refresh-layers-independently/81470#81470 , in the topic Nathan did exactly what I did. I don't know why. http://osgeo-org.1560.x6.nabble.com/file/n5161805/error.jpg Here is my code: //main.cpp int main(int argc, char ** argv) { // Start the Application QgsApplication app(argc, argv, true); QgsMapCanvas * mypMapCanvas = new QgsMapCanvas(); mypMapCanvas-setVisible(true); mypMapCanvas-refresh(); QString fileName = D:\\qgis\\svg\\symbol\\poi_tower_communications.svg; TFMapCanvasSvgItem mTFSvgItem(mypMapCanvas, fileName); mTFSvgItem.setPos(0, 0); return app.exec(); } // Custom canvas item class -TFMapCanvasSvgItem.h class TFMapCanvasSvgItem: public QgsMapCanvasItem { public: TFMapCanvasSvgItem(QgsMapCanvas* canvas, QString fileName = ); ~TFMapCanvasSvgItem(); void paint(QPainter* painter); QRectF boundingRect() const; void setFilePath(const QString file); QString filePath() const {return mFilePath;} private: QSvgRenderer mSvgRenderer; QString mFilePath; }; //TFMapCanvasSvgItem.cpp TFMapCanvasSvgItem::TFMapCanvasSvgItem(QgsMapCanvas* canvas, QString fileName): QgsMapCanvasItem(canvas), mSvgRenderer(fileName) { } TFMapCanvasSvgItem::~TFMapCanvasSvgItem() { } void TFMapCanvasSvgItem::paint(QPainter* painter) { if (!painter) { return; } QRectF viewBox = mSvgRenderer.viewBoxF(); if (viewBox.isValid()) { setPos(this-toCanvasCoordinates(QgsPoint(0.0, 0.0))); mSvgRenderer.render(painter, viewBox); } } QRectF TFMapCanvasSvgItem::boundingRect() const { QRectF viewBox = mSvgRenderer.viewBoxF(); qreal halfWeight = viewBox.width() / 2; qreal halfHeight = viewBox.height() / 2; return QRectF(-halfWeight, -halfHeight, viewBox.width(), viewBox.height()); } void TFMapCanvasSvgItem::setFilePath(const QString file) { mFilePath = file; mSvgRenderer.load(mFilePath); } -- View this message in context: http://osgeo-org.1560.x6.nabble.com/Is-QGIS-supports-dynamic-display-tp5155726p5161805.html Sent from the Quantum GIS - Developer mailing list archive at Nabble.com. ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [Qgis-developer] Is QGIS supports dynamic display?
Never mind. I solved the problem. void TFMapCanvasSvgItem::paint(QPainter* painter) { if (!painter) { return; } QImage svgImage(50, 40, QImage::Format_ARGB32); svgImage.fill(Qt::transparent); QPainter imagePainter(svgImage); mSvgRenderer.render(imagePainter); painter-drawImage(QRectF(0, 0, 100, 80), svgImage, QRectF(0, 0, 100, 80)); painter-restore(); } -- View this message in context: http://osgeo-org.1560.x6.nabble.com/Is-QGIS-supports-dynamic-display-tp5155726p5161992.html Sent from the Quantum GIS - Developer mailing list archive at Nabble.com. ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [Qgis-developer] Is QGIS supports dynamic display?
Hi Bob On Tue, Aug 19, 2014 at 7:07 PM, Tendfly Niu niu...@hotmail.com wrote: Hi Martin, I'm sorry to ask you again. I looked up QgsRubberBand class, it has 5 Geometry types: Point, Line, Polygon, UnknownGeometry, NoGeometry. It seems there's no way to add a svg symbol as a car icon on the map, or I was on a wrong way? Here is some questions: 1, How to add a svg symbol as a instance's icon? I tried QgssvgmarkerSymbolLayerV2 class, but it didn't display. SVG markers are not supported by QgsRubberBand. You may want to implement your own canvas item for that - try to have a look at QgsVertexMarker class for some inspiration. 2, How to draw a line or polygon using QgsRubberBand? I constructed a QgsRubberband instance, set some attributes, however it was not display. This section from PyQGIS cookbook should help you: http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/canvas.html#rubber-bands-and-vertex-markers Regards Martin ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [Qgis-developer] Is QGIS supports dynamic display?
Hi Bob QGIS allows you to have dynamic objects on top of map canvas. These objects are called map canvas items, having QgsMapCanvasItem as a base class. You can either implement your own item or use an existing implementation, e.g. QgsRubberBand class (used for example to highlight features when doing identification). In your case, you could have one QgsRubberBand instance and just change its position on map whenever appropriate. Cheers Martin On Mon, Aug 11, 2014 at 9:11 AM, 腾飞 牛 niu...@hotmail.com wrote: Dear all, I'm a new developer of QGIS using C++. I am doing a project which needs dynamically displaying maps/layers(just like GPS,layers automatically refreshing with the changing of object's position).I kown ARCGIS has the technique called dynamic diasplay(or something like that),which supports the capacity to do such things. Is QGIS has this ability? Any advices would be appreciated! Regards Bob ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [Qgis-developer] Is QGIS supports dynamic display?
On 2014/08/11 04:11, ?? ? wrote: Dear all, I'm a new developer of QGIS using C++. I am doing a project which needs dynamically displaying maps/layers(just like GPS,layers automatically refreshing with the changing of object's position).I kown ARCGIS has the technique called dynamic diasplay(or something like that),which supports the capacity to do such things. Is QGIS has this ability? Any advices would be appreciated! Regards Bob Hi Bob, QGIS can definitely do this already. I used this feature in November last year - but make sure you use the latest versions of QGIS of all the plugins for field editing because at that stage some of the (digitising, I think) plugins caused serious loops when refreshing the screen or adding a feature, so not great if you are dynamically panning. I used a Garmin 60CSX, but any gps that can output an NMEA stream should work. You also need the free versions of Franson GPSGate from http://gpsgate.com/ On a practical note, I found dynamic panning not very useful for my purpose. When we drove passed a POI, we couldn't easily pause the panning in order to drop a points and add the attributes needed. We found the dynamic tracking (digitising) of the incoming GPS track very useful, and we manually panned the display as needed, whilst in motion. HTH, Zoltan -- === Zoltan Szecsei PrGISc [PGP0031] Geograph (Pty) Ltd. GIS and Photogrammetric Services P.O. Box 7, Muizenberg 7950, South Africa. Mobile: +27-83-6004028 Fax:+27-86-6115323 www.geograph.co.za === ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [Qgis-developer] Is QGIS supports dynamic display?
Hi Zoltan, Thanks a lot for your reply!The version i'm using is QGIS 2.4.0. I want to develop a desktop application using QGIS API, by C++ as i said. It is not GPS, but the way it is displayed like GPS-dynamic displaying by the changing data. So i built QGIS using source code according to INSTALL. At the time of Cmake, I unchecked the Python related plugins(such as WITH_BINDINGS,WITH_STAGED_PLUGINS), hope this does not affact the function you mentioned. Do you know which function or class is the one i'm looking for? I developed a simple demo that has these features: add layer, zoom in/out, pan. When i added a vector layer(.shp), i zoom in or zoom out, the refresh is not smooth or continuous. Are there any places i did not do right? Looking forward to your reply. RegardsBob Date: Mon, 11 Aug 2014 08:15:07 +0200 From: zolt...@geograph.co.za To: qgis-developer@lists.osgeo.org Subject: Re: [Qgis-developer] Is QGIS supports dynamic display? On 2014/08/11 04:11, 腾飞 牛 wrote: Dear all, I'm a new developer of QGIS using C++. I am doing a project which needs dynamically displaying maps/layers(just like GPS,layers automatically refreshing with the changing of object's position).I kown ARCGIS has the technique called dynamic diasplay(or something like that),which supports the capacity to do such things. Is QGIS has this ability? Any advices would be appreciated! Regards Bob Hi Bob, QGIS can definitely do this already. I used this feature in November last year - but make sure you use the latest versions of QGIS of all the plugins for field editing because at that stage some of the (digitising, I think) plugins caused serious loops when refreshing the screen or adding a feature, so not great if you are dynamically panning. I used a Garmin 60CSX, but any gps that can output an NMEA stream should work. You also need the free versions of Franson GPSGate from http://gpsgate.com/ On a practical note, I found dynamic panning not very useful for my purpose. When we drove passed a POI, we couldn't easily pause the panning in order to drop a points and add the attributes needed. We found the dynamic tracking (digitising) of the incoming GPS track very useful, and we manually panned the display as needed, whilst in motion. HTH, Zoltan -- === Zoltan Szecsei PrGISc [PGP0031] Geograph (Pty) Ltd. GIS and Photogrammetric Services P.O. Box 7, Muizenberg 7950, South Africa. Mobile: +27-83-6004028 Fax:+27-86-6115323 www.geograph.co.za === ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer
[Qgis-developer] Is QGIS supports dynamic display?
Dear all, I'm a new developer of QGIS using C++. I am doing a project which needs dynamically displaying maps/layers(just like GPS,layers automatically refreshing with the changing of object's position).I kown ARCGIS has the technique called dynamic diasplay(or something like that),which supports the capacity to do such things. Is QGIS has this ability? Any advices would be appreciated! RegardsBob___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer