本文整理汇总了C++中MarbleWidget::centerOn方法的典型用法代码示例。如果您正苦于以下问题:C++ MarbleWidget::centerOn方法的具体用法?C++ MarbleWidget::centerOn怎么用?C++ MarbleWidget::centerOn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MarbleWidget
的用法示例。
在下文中一共展示了MarbleWidget::centerOn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv)
{
QApplication app(argc,argv);
// Create a Marble QWidget without a parent
MarbleWidget *mapWidget = new MarbleWidget();
// Load the OpenStreetMap map
mapWidget->setMapThemeId(QStringLiteral("earth/openstreetmap/openstreetmap.dgml"));
mapWidget->setProjection( Mercator );
// Access the shared route request (start, destination and parameters)
RoutingManager* manager = mapWidget->model()->routingManager();
RouteRequest* request = manager->routeRequest();
// Use default routing settings for cars
request->setRoutingProfile( manager->defaultProfile( RoutingProfile::Motorcar ) );
// Set start and destination
request->append( GeoDataCoordinates( 8.38942, 48.99738, 0.0, GeoDataCoordinates::Degree ) );
request->append( GeoDataCoordinates( 8.42002, 49.0058, 0.0, GeoDataCoordinates::Degree ) );
// Calculate the route
manager->retrieveRoute();
// Center the map on the route start point and show it
mapWidget->centerOn( request->at( 0 ) );
mapWidget->setDistance( 0.75 );
mapWidget->show();
return app.exec();
}
示例2: eventFilter
bool ElevationProfileFloatItem::eventFilter( QObject *object, QEvent *e )
{
if ( !enabled() || !visible() ) {
return false;
}
MarbleWidget *widget = dynamic_cast<MarbleWidget*>( object );
if ( !widget ) {
return AbstractFloatItem::eventFilter(object,e);
}
if ( widget && !m_marbleWidget ) {
m_marbleWidget = widget;
connect( this, SIGNAL(dataUpdated()), this, SLOT(updateVisiblePoints()) );
connect( m_marbleWidget, SIGNAL(visibleLatLonAltBoxChanged(GeoDataLatLonAltBox)),
this, SLOT(updateVisiblePoints()) );
connect( this, SIGNAL(settingsChanged(QString)), this, SLOT(updateVisiblePoints()) );
}
if ( e->type() == QEvent::MouseButtonDblClick || e->type() == QEvent::MouseMove ) {
GeoDataTreeModel *const treeModel = const_cast<MarbleModel *>( marbleModel() )->treeModel();
QMouseEvent *event = static_cast<QMouseEvent*>( e );
QRectF plotRect = QRectF ( m_leftGraphMargin, 0, m_eleGraphWidth, contentSize().height() );
plotRect.translate( positivePosition() );
plotRect.translate( padding(), padding() );
// for antialiasing: increase size by 1 px to each side
plotRect.translate(-1, -1);
plotRect.setSize(plotRect.size() + QSize(2, 2) );
const bool cursorAboveFloatItem = plotRect.contains(event->pos());
if ( cursorAboveFloatItem ) {
const int start = m_zoomToViewport ? m_firstVisiblePoint : 0;
const int end = m_zoomToViewport ? m_lastVisiblePoint : m_eleData.size();
// Double click triggers recentering the map at the specified position
if ( e->type() == QEvent::MouseButtonDblClick ) {
const QPointF mousePosition = event->pos() - plotRect.topLeft();
const int xPos = mousePosition.x();
for ( int i = start; i < end; ++i) {
const int plotPos = ( m_eleData.value(i).x() - m_axisX.minValue() ) * m_eleGraphWidth / m_axisX.range();
if ( plotPos >= xPos ) {
widget->centerOn( m_points[i], true );
break;
}
}
return true;
}
if ( e->type() == QEvent::MouseMove && !(event->buttons() & Qt::LeftButton) ) {
// Cross hair cursor when moving above the float item
// and mark the position on the graph
widget->setCursor(QCursor(Qt::CrossCursor));
if ( m_cursorPositionX != event->pos().x() - plotRect.left() ) {
m_cursorPositionX = event->pos().x() - plotRect.left();
const qreal xpos = m_axisX.minValue() + ( m_cursorPositionX / m_eleGraphWidth ) * m_axisX.range();
GeoDataCoordinates currentPoint; // invalid coordinates
for ( int i = start; i < end; ++i) {
if ( m_eleData.value(i).x() >= xpos ) {
currentPoint = m_points[i];
currentPoint.setAltitude( m_eleData.value(i).y() );
break;
}
}
m_markerPlacemark->setCoordinate( currentPoint );
if ( m_documentIndex < 0 ) {
m_documentIndex = treeModel->addDocument( &m_markerDocument );
}
emit repaintNeeded();
}
return true;
}
}
else {
if ( m_documentIndex >= 0 ) {
m_markerPlacemark->setCoordinate( GeoDataCoordinates() ); // set to invalid
treeModel->removeDocument( &m_markerDocument );
m_documentIndex = -1;
emit repaintNeeded();
}
}
}
return AbstractFloatItem::eventFilter(object,e);
}