11#include "GeoDataCoordinates.h"
12#include "GeoPainter.h"
16#include "RenderPlugin.h"
17#include "RenderState.h"
24class Q_DECL_HIDDEN PopupLayer::Private
27 Private( MarbleWidget *marbleWidget, PopupLayer *q );
33 void setAppropriateSize(
const ViewportParams *viewport );
35 static QString filterEmptyShortDescription(
const QString &description);
36 void setupDialogSatellite(
const GeoDataPlacemark *index );
37 void setupDialogCity(
const GeoDataPlacemark *index );
38 void setupDialogNation(
const GeoDataPlacemark *index );
39 void setupDialogGeoPlaces(
const GeoDataPlacemark *index );
40 void setupDialogSkyPlaces(
const GeoDataPlacemark *index );
42 PopupItem *
const m_popupItem;
43 MarbleWidget *
const m_widget;
45 bool m_hasCrosshairsPlugin;
46 bool m_crosshairsVisible;
49PopupLayer::Private::Private( MarbleWidget *marbleWidget, PopupLayer *q ) :
50 m_popupItem( new PopupItem( q ) ),
51 m_widget( marbleWidget ),
52 m_hasCrosshairsPlugin( false ),
53 m_crosshairsVisible( true )
57PopupLayer::PopupLayer( MarbleWidget *marbleWidget,
QObject *parent ) :
59 d( new Private( marbleWidget, this ) )
61 for (
const RenderPlugin *renderPlugin: d->m_widget->renderPlugins()) {
63 d->m_hasCrosshairsPlugin =
true;
68 connect( d->m_popupItem, SIGNAL(repaintNeeded()),
this, SIGNAL(repaintNeeded()) );
69 connect( d->m_popupItem, SIGNAL(hide()),
this, SLOT(hidePopupItem()) );
72PopupLayer::~PopupLayer()
79 return QStringList(QStringLiteral(
"ALWAYS_ON_TOP"));
82bool PopupLayer::render( GeoPainter *painter, ViewportParams *viewport,
83 const QString&, GeoSceneLayer* )
86 d->setAppropriateSize( viewport );
87 d->m_popupItem->paintEvent( painter, viewport );
95 return visible() && d->m_popupItem->eventFilter(
object, e );
98qreal PopupLayer::zValue()
const
103RenderState PopupLayer::renderState()
const
105 return RenderState(QStringLiteral(
"Popup Window"));
108bool PopupLayer::visible()
const
110 return d->m_popupItem->visible();
113void PopupLayer::setVisible(
bool visible )
115 d->m_popupItem->setVisible( visible );
117 disconnect( d->m_popupItem, SIGNAL(repaintNeeded()),
this, SIGNAL(repaintNeeded()) );
118 d->m_popupItem->clearHistory();
119 emit repaintNeeded();
122 connect( d->m_popupItem, SIGNAL(repaintNeeded()),
this, SIGNAL(repaintNeeded()) );
126void PopupLayer::popup()
131 d->m_widget->viewport()->size() );
132 qreal sx, sy, lon, lat;
134 sx = viewport.radius() < viewport.width() ? 0.5 * (viewport.width() + viewport.radius()) : 0.75 * viewport.width();
135 viewport.
geoCoordinates( sx, sy, lon, lat, GeoDataCoordinates::Radian );
138 d->m_widget->centerOn( coords,
true );
140 if( d->m_hasCrosshairsPlugin ) {
141 d->m_crosshairsVisible = d->m_widget->showCrosshairs();
143 if( d->m_crosshairsVisible ) {
144 d->m_widget->setShowCrosshairs(
false );
153 d->m_popupItem->setCoordinate( coordinates );
154 d->m_popupItem->setAlignment( alignment );
157void PopupLayer::setUrl(
const QUrl &url )
159 d->m_popupItem->setUrl( url );
162void PopupLayer::setContent(
const QString &html,
const QUrl &baseUrl )
164 d->m_popupItem->setContent( html, baseUrl );
167void PopupLayer::setBackgroundColor(
const QColor &color)
170 d->m_popupItem->setBackgroundColor(color);
174void PopupLayer::setTextColor(
const QColor &color)
177 d->m_popupItem->setTextColor(color);
181void PopupLayer::setSize(
const QSizeF &size )
183 d->m_requestedSize = size;
186void PopupLayer::Private::setAppropriateSize(
const ViewportParams *viewport )
191 maximumSize.
setWidth( viewport->width() - margin );
192 maximumSize.
setHeight( viewport->height() - margin );
194 QSizeF minimumSize( 100.0, 100.0 );
196 m_popupItem->setSize( m_requestedSize.boundedTo( maximumSize ).expandedTo( minimumSize ) );
199void PopupLayer::hidePopupItem()
201 if( d->m_hasCrosshairsPlugin && d->m_crosshairsVisible ) {
202 d->m_widget->setShowCrosshairs( d->m_crosshairsVisible );
210#include "moc_PopupLayer.cpp"
This file contains the headers for ViewportParams.
A 3d point representation.
void setLatitude(qreal lat, GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian)
set the longitude in a GeoDataCoordinates object
qreal longitude(GeoDataCoordinates::Unit unit) const
retrieves the longitude of the GeoDataCoordinates object use the unit parameter to switch between Rad...
void setLongitude(qreal lon, GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian)
set the longitude in a GeoDataCoordinates object
qreal latitude(GeoDataCoordinates::Unit unit) const
retrieves the latitude of the GeoDataCoordinates object use the unit parameter to switch between Radi...
A public class that controls what is visible in the viewport of a Marble map.
bool screenCoordinates(const qreal lon, const qreal lat, qreal &x, qreal &y) const
Get the screen coordinates corresponding to geographical coordinates in the map.
bool geoCoordinates(const int x, const int y, qreal &lon, qreal &lat, GeoDataCoordinates::Unit unit=GeoDataCoordinates::Degree) const
Get the earth coordinates corresponding to a pixel in the map.
Binds a QML item to a specific geodetic location in screen coordinates.
bool isValid() const const
void setHeight(qreal height)
void setWidth(qreal width)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)