Re: [Qgis-developer] Open a *.qgs project file in API, why maps do not show?
Hi Gary, According to the QgisApp::addProject( QString projectFile ) function, I did some change in my code. However, the map still doesn't show, but the CRS in project works fine. So I think the project file was read but there is something wrong about display(or MapCanvas). I don't use Python plug-ins and ScaleComboBox, so I remove the relevant part, the code is: -- View this message in context: http://osgeo-org.1560.x6.nabble.com/Open-a-qgs-project-file-in-API-why-maps-do-not-show-tp5168545p5168673.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] Open a *.qgs project file in API, why maps do not show?
Hi Gary , Thanks for reply! I don't what iface is. Is it another name of QgsProject::instance()? I'm using C++ to developing app. -- View this message in context: http://osgeo-org.1560.x6.nabble.com/Open-a-qgs-project-file-in-API-why-maps-do-not-show-tp5168545p5168547.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] Open a *.qgs project file in API, why maps do not show?
Thanks a lot! I will try that. -- View this message in context: http://osgeo-org.1560.x6.nabble.com/Open-a-qgs-project-file-in-API-why-maps-do-not-show-tp5168545p5168549.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 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