void RoutingLayerPrivate::renderPlacemarks( GeoPainter *painter ) { m_placemarks.clear(); painter->setPen( QColor( Qt::black ) ); for ( int i = 0; i < m_placemarkModel->rowCount(); ++i ) { QModelIndex index = m_placemarkModel->index( i, 0 ); QVariant data = index.data( MarblePlacemarkModel::CoordinateRole ); if ( index.isValid() && !data.isNull() ) { GeoDataCoordinates pos = qVariantValue<GeoDataCoordinates>( data ); QPixmap pixmap = qVariantValue<QPixmap>( index.data( Qt::DecorationRole ) ); if ( !pixmap.isNull() && m_selectionModel->isSelected( index ) ) { QIcon selected = QIcon( pixmap ); QPixmap result = selected.pixmap( m_pixmapSize, QIcon::Selected, QIcon::On ); painter->drawPixmap( pos, result ); } else { painter->drawPixmap( pos, pixmap ); } QRegion region = painter->regionFromRect( pos, m_targetPixmap.width(), m_targetPixmap.height() ); m_placemarks.push_back( ModelRegion( index, region ) ); } } }
void RoutingLayerPrivate::renderRoute( GeoPainter *painter ) { GeoDataLineString waypoints = m_routingModel->route().path(); QPen standardRoutePen( m_marbleWidget->model()->routingManager()->routeColorStandard() ); standardRoutePen.setWidth( 5 ); if ( m_marbleWidget->model()->routingManager()->state() == RoutingManager::Downloading ) { standardRoutePen.setStyle( Qt::DotLine ); } painter->setPen( standardRoutePen ); painter->drawPolyline( waypoints ); if ( m_viewportChanged && m_viewContext == Still ) { int const offset = MarbleGlobal::getInstance()->profiles() & MarbleGlobal::SmallScreen ? 24 : 8; if ( m_isInteractive ) { m_routeRegion = painter->regionFromPolyline( waypoints, offset ); } } standardRoutePen.setWidth( 2 ); painter->setPen( standardRoutePen ); // Map matched position //painter->setBrush( QBrush( Oxygen::brickRed4) ); //painter->drawEllipse( m_routingModel->route().positionOnRoute(), 8, 8 ); painter->setBrush( QBrush( m_marbleWidget->model()->routingManager()->routeColorAlternative() ) ); if ( !m_dropStopOver.isNull() ) { int dx = 1 + m_pixmapSize.width() / 2; int dy = 1 + m_pixmapSize.height() / 2; QPoint center = m_dropStopOver - QPoint( dx, dy ); painter->drawPixmap( center, m_targetPixmap ); if ( !m_dragStopOver.isNull() && m_dragStopOverRightIndex >= 0 && m_dragStopOverRightIndex <= m_routeRequest->size() ) { QPoint moved = m_dropStopOver - m_dragStopOver; if ( moved.manhattanLength() > 10 ) { qreal lon( 0.0 ), lat( 0.0 ); if ( m_marbleWidget->geoCoordinates( m_dropStopOver.x(), m_dropStopOver.y(), lon, lat, GeoDataCoordinates::Radian ) ) { GeoDataCoordinates drag( lon, lat ); standardRoutePen.setStyle( Qt::DotLine ); painter->setPen( standardRoutePen ); GeoDataLineString lineString; if ( m_dragStopOverRightIndex > 0 ) { lineString << m_routeRequest->at( m_dragStopOverRightIndex-1 ); } lineString << drag; if ( m_dragStopOverRightIndex < m_routeRequest->size() ) { lineString << m_routeRequest->at( m_dragStopOverRightIndex ); } painter->drawPolyline( lineString ); standardRoutePen.setStyle( Qt::SolidLine ); painter->setPen( standardRoutePen ); } } } } if ( m_viewContext == Animation ) { return; } Q_ASSERT( m_routingModel->rowCount() == m_routingModel->route().size() ); m_instructionRegions.clear(); for ( int i = 0; i < m_routingModel->rowCount(); ++i ) { QModelIndex index = m_routingModel->index( i, 0 ); GeoDataCoordinates pos = index.data( MarblePlacemarkModel::CoordinateRole ).value<GeoDataCoordinates>(); painter->setBrush( QBrush( m_marbleWidget->model()->routingManager()->routeColorAlternative() ) ); if ( m_selectionModel && m_selectionModel->selection().contains( index ) ) { const RouteSegment &segment = m_routingModel->route().at( i ); const GeoDataLineString currentRoutePoints = segment.path(); QPen activeRouteSegmentPen( m_marbleWidget->model()->routingManager()->routeColorHighlighted() ); activeRouteSegmentPen.setWidth( 6 ); if ( m_marbleWidget->model()->routingManager()->state() == RoutingManager::Downloading ) { activeRouteSegmentPen.setStyle( Qt::DotLine ); } painter->setPen( activeRouteSegmentPen ); painter->drawPolyline( currentRoutePoints ); painter->setPen( standardRoutePen ); painter->setBrush( QBrush( alphaAdjusted( Oxygen::hotOrange4, 200 ) ) ); } painter->drawEllipse( pos, 6, 6 ); if ( m_isInteractive ) { QRegion region = painter->regionFromEllipse( pos, 12, 12 ); m_instructionRegions.push_front( ModelRegion( index, region ) ); } } if( !m_routingModel->deviatedFromRoute() ) { GeoDataCoordinates location = m_routingModel->route().currentSegment().nextRouteSegment().maneuver().position(); QString nextInstruction = m_routingModel->route().currentSegment().nextRouteSegment().maneuver().instructionText(); if( !nextInstruction.isEmpty() ) { painter->setBrush( QBrush( Oxygen::hotOrange4 ) ); painter->drawEllipse( location, 6, 6 ); } } }