您的位置:首页 > 其它

Marble 绘制线

2015-10-12 15:48 337 查看
#include <QtGui/QApplication>
#include <marble/MarbleWidget.h>
#include <marble/GeoPainter.h>
#include <marble/GeoDataLineString.h>

using namespace Marble;

class MyMarbleWidget : public MarbleWidget
{
public:
virtual void customPaint(GeoPainter* painter);
};

void MyMarbleWidget::customPaint(GeoPainter* painter) {

GeoDataCoordinates France( 2.2, 48.52, 0.0, GeoDataCoordinates::Degree );
painter->setPen( QColor( 0, 0, 0 ) );
painter->drawText( France, "France" );

GeoDataCoordinates Canada( -77.02, 48.52, 0.0, GeoDataCoordinates::Degree );
painter->setPen( QColor( 0, 0, 0 ) );
painter->drawText( Canada, "Canada" );

//A line from France to Canada without tessellation

GeoDataLineString shapeNoTessellation( NoTessellation );
shapeNoTessellation << France << Canada;

painter->setPen( oxygenSkyBlue4 );
painter->drawPolyline( shapeNoTessellation );

//The same line, but with tessellation

GeoDataLineString shapeTessellate( Tessellate );
shapeTessellate << France << Canada;

painter->setPen( oxygenBrickRed4 );
painter->drawPolyline( shapeTessellate );

//Now following the latitude circles

GeoDataLineString shapeLatitudeCircle( RespectLatitudeCircle | Tessellate );
shapeLatitudeCircle << France << Canada;

painter->setPen( oxygenForestGreen4 );
painter->drawPolyline( shapeLatitudeCircle );
}

int main(int argc, char** argv) {

QApplication app(argc,argv);

// Create a Marble QWidget without a parent
MarbleWidget *mapWidget = new MyMarbleWidget();

// Load the OpenStreetMap map
mapWidget->setMapThemeId("earth/plain/plain.dgml");

mapWidget->show();

return app.exec();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: