23 #include <QDataStream>
64 int _iIndexMin,
int _iIndexMax )
69 double __fdLongitudeLower = _poDataPositionLower->
getLongitude();
71 double __fdLongitudeUpper = _poDataPositionUpper->
getLongitude();
73 if( __fdLongitudeLower > __fdLongitudeUpper )
75 double __fd = __fdLongitudeLower;
76 __fdLongitudeUpper = __fdLongitudeLower;
77 __fdLongitudeLower = __fd;
80 double __fdLatitudeLower = _poDataPositionLower->
getLatitude();
82 double __fdLatitudeUpper = _poDataPositionUpper->
getLatitude();
84 if( __fdLatitudeLower > __fdLatitudeUpper )
86 double __fd = __fdLatitudeLower;
87 __fdLatitudeUpper = __fdLatitudeLower;
88 __fdLatitudeLower = __fd;
91 double __fdElevationLower = _poDataPositionLower->
getElevation();
93 double __fdElevationUpper = _poDataPositionUpper->
getElevation();
95 if( __fdElevationLower > __fdElevationUpper )
97 double __fd = __fdElevationLower;
98 __fdElevationUpper = __fdElevationLower;
99 __fdElevationLower = __fd;
102 int __iIndexMax = _iIndexMax >= 0 ? _iIndexMax : _pqTreeWidgetItem->childCount()-1;
105 int __iCountValid = 0;
106 double __fdLongitudeMin = 180, __fdLongitudeMax = -180;
107 double __fdLatitudeMin = 90, __fdLatitudeMax = -90;
108 double __fdElevationMin = 9999999, __fdElevationMax = -9999999;
109 for(
int __i = _iIndexMin; __i <= __iIndexMax; __i++ )
113 double __fdLongitude = __poDataPosition->
getLongitude();
114 if( __fdLongitude < __fdLongitudeLower || __fdLongitude > __fdLongitudeUpper )
continue;
115 double __fdLatitude = __poDataPosition->
getLatitude();
116 if( __fdLatitude < __fdLatitudeLower || __fdLatitude > __fdLatitudeUpper )
continue;
117 double __fdElevation = __poDataPosition->
getElevation();
119 && ( __fdElevation < __fdElevationLower || __fdElevation > __fdElevationUpper ) )
continue;
121 if( __fdLongitude < __fdLongitudeMin ) __fdLongitudeMin = __fdLongitude;
122 if( __fdLongitude > __fdLongitudeMax ) __fdLongitudeMax = __fdLongitude;
123 if( __fdLatitude < __fdLatitudeMin ) __fdLatitudeMin = __fdLatitude;
124 if( __fdLatitude > __fdLatitudeMax ) __fdLatitudeMax = __fdLatitude;
127 if( __fdElevation < __fdElevationMin ) __fdElevationMin = __fdElevation;
128 if( __fdElevation > __fdElevationMax ) __fdElevationMax = __fdElevation;
138 return __iCountValid;
168 const QString& _rqsText,
const QPointF& _rqPointFScrPosition,
172 static const QSizeF __qSizeFRect(200,14), __qSizeRBackgroundGrow( 4, 0 );
173 static const QPointF __qPointFBackOffset(2,0);
176 double __fdZoom = _poChart->
getZoom();
177 if( __fdZoom < 0.5 )
return;
178 else if( __fdZoom > 2.0 ) __fdZoom = 2.0;
180 QString __qsText = _rqsText;
184 QFont __qFont = __poOverlay->
getFont();
185 __qFont.setPixelSize( __qFont.pixelSize() * __fdZoom );
186 __qFont.setBold(
false );
187 __qFont.setItalic( _bItalic );
188 _pqPainter->setFont( __qFont );
191 QRectF __qRectFBackground;
192 _pqPainter->setPen( QPen( Qt::transparent ) );
193 _pqPainter->drawText( QRectF( _rqPointFScrPosition, __qSizeFRect ), Qt::AlignLeft|Qt::AlignTop, __qsText, &__qRectFBackground );
196 __qRectFBackground.setSize( __qRectFBackground.size() + __qSizeRBackgroundGrow );
197 __qRectFBackground.moveCenter( _rqPointFScrPosition );
199 _pqPainter->drawRect( __qRectFBackground );
200 _pqPainter->setPen( __poOverlay->
getPenText() );
202 _pqPainter->drawText( QRectF( __qRectFBackground.topLeft()+__qPointFBackOffset, __qRectFBackground.size() ), Qt::AlignHCenter|Qt::AlignTop, __qsText );
208 static const QPointF __qPointFCrosshairA1(6,0), __qPointFCrosshairA2(12,0);
209 static const QPointF __qPointFCrosshairB1(0,6), __qPointFCrosshairB2(0,12);
210 static const QPointF __qPointFCrosshairC1(-6,0), __qPointFCrosshairC2(-12,0);
211 static const QPointF __qPointFCrosshairD1(0,-6), __qPointFCrosshairD2(0,-12);
212 static const QSize __qSizeSelect(32,32);
213 static const QPixmap __qPixmapSelect(
":icons/32x32/select.png" );
219 double __fdZoom = _poChart->
getZoom();
220 if( __fdZoom < 0.5 ) __fdZoom = 0.5;
221 else if( __fdZoom > 2.0 ) __fdZoom = 2.0;
228 __qPen.setWidth( __qPen.width() * __fdZoom );
229 if( _poDataPositionValidity && !_poDataPositionValidity->
isValidPosition() ) __qPen.setStyle( Qt::DotLine );
234 __qPenSelected.setWidth( __qPenSelected.width() * __fdZoom );
235 _pqPainter->setPen( __qPenSelected );
237 _pqPainter->drawEllipse( __qPointF, 15*__fdZoom, 15*__fdZoom );
239 _pqPainter->setPen( __qPen );
241 _pqPainter->drawEllipse( __qPointF, 9*__fdZoom, 9*__fdZoom );
242 _pqPainter->drawPoint( __qPointF );
243 _pqPainter->drawLine( __qPointF + __qPointFCrosshairA1*__fdZoom, __qPointF + __qPointFCrosshairA2*__fdZoom );
244 _pqPainter->drawLine( __qPointF + __qPointFCrosshairB1*__fdZoom, __qPointF + __qPointFCrosshairB2*__fdZoom );
245 _pqPainter->drawLine( __qPointF + __qPointFCrosshairC1*__fdZoom, __qPointF + __qPointFCrosshairC2*__fdZoom );
246 _pqPainter->drawLine( __qPointF + __qPointFCrosshairD1*__fdZoom, __qPointF + __qPointFCrosshairD2*__fdZoom );
249 _pqPainter->drawPixmap( __qPointF, __qPixmapSelect.scaled( __qSizeSelect*(__fdZoom/2.0), Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
255 static const QPointF __qPointFSymbol(-32,-32);
256 static const QSize __qSizeSymbol(32,32);
265 double __fdZoom = _poChart->
getZoom();
266 if( __fdZoom <= 0.5 )
return;
267 if( __fdZoom > 2.0 ) __fdZoom = 2.0;
270 _pqPainter->drawPixmap( _poChart->
toDrawPosition( *
this )+__qPointFSymbol*(__fdZoom/2.0), __poMainWindow->
symbolPixmap( _rqsSymbol ).scaled( __qSizeSymbol*(__fdZoom/2.0), Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
280 double __fdZoom = _poChart->
getZoom();
281 if( __fdZoom <= 0.5 )
return;
282 else if( __fdZoom > 2.0 ) __fdZoom = 2.0;
286 if( __qsName.length() > 20 ) { __qsName.truncate( 19 ); __qsName += QString::fromUtf8(
"…"); }
290 QFont __qFont = __poOverlay->
getFont();
291 int __iFontSize = __qFont.pixelSize() * __fdZoom;
292 __qFont.setPixelSize( __iFontSize );
295 QPointF __qPointFaux = __qPointF;
296 QSizeF __qSizeFRect( __iFontSize*20, __iFontSize+4 ), __qSizeRBackgroundGrow( __iFontSize/2, 0 );
297 QPointF __qPointFBackOffset( __iFontSize/4, 0 ), __qPointFTextOffset( 0, __iFontSize );
298 QRectF __qRectFBounding, __qRectFBackground;
299 _pqPainter->setPen( QPen( Qt::transparent ) );
301 __qFont.setBold(
true ); __qFont.setItalic(
false ); _pqPainter->setFont( __qFont );
302 _pqPainter->drawText( QRectF( __qPointFaux, __qSizeFRect ), Qt::AlignLeft|Qt::AlignTop, __qsName, &__qRectFBounding );
303 __qRectFBackground = __qRectFBounding;
306 __qFont.setBold(
false );
310 __qFont.setItalic( !_poDataTimeValidity || _poDataTimeValidity->
isValidTime() ?
false :
true );
311 _pqPainter->setFont( __qFont );
312 __qPointFaux += __qPointFTextOffset;
314 __qRectFBackground = __qRectFBackground.united( __qRectFBounding );
317 __qFont.setItalic( !_poDataPositionValidity || _poDataPositionValidity->
isValidPosition() ?
false :
true );
318 _pqPainter->setFont( __qFont );
319 __qPointFaux += __qPointFTextOffset;
321 __qRectFBackground = __qRectFBackground.united( __qRectFBounding );
322 __qPointFaux += __qPointFTextOffset;
324 __qRectFBackground = __qRectFBackground.united( __qRectFBounding );
328 __qFont.setItalic( !_poDataPositionValidity || _poDataPositionValidity->
isValidElevation() ?
false :
true );
329 _pqPainter->setFont( __qFont );
330 __qPointFaux += __qPointFTextOffset;
332 __qRectFBackground = __qRectFBackground.united( __qRectFBounding );
337 QPointF __qPointFPositionOffset = QPointF( 20*__fdZoom, -20*__fdZoom );
338 __qRectFBackground.setSize( __qRectFBackground.size() + __qSizeRBackgroundGrow );
340 _eTagPosition = __qPointF.x() + __qPointFPositionOffset.x() + __qRectFBackground.width() < _poChart->
getDrawArea().width()
345 __qPointF += __qPointFPositionOffset;
346 __qRectFBackground.moveTopLeft( __qPointF );
348 else if( _eTagPosition ==
TAG_LEFT )
350 __qPointFPositionOffset += QPointF( __qRectFBackground.width(), 0 );
351 __qPointF += QPointF( -__qPointFPositionOffset.x(), __qPointFPositionOffset.y() );
352 __qRectFBackground.moveTopLeft( __qPointF );
354 __qPointF += __qPointFBackOffset;
359 _pqPainter->drawRect( __qRectFBackground );
360 _pqPainter->setPen( __poOverlay->
getPenText() );
362 __qFont.setBold(
true ); __qFont.setItalic(
false ); _pqPainter->setFont( __qFont );
363 _pqPainter->drawText( QRectF( __qPointF, __qSizeFRect ), Qt::AlignLeft|Qt::AlignTop, __qsName );
366 __qFont.setBold(
false );
370 __qFont.setItalic( !_poDataTimeValidity || _poDataTimeValidity->
isValidTime() ?
false :
true );
371 _pqPainter->setFont( __qFont );
372 __qPointF += __qPointFTextOffset;
376 __qFont.setItalic( !_poDataPositionValidity || _poDataPositionValidity->
isValidPosition() ?
false :
true );
377 _pqPainter->setFont( __qFont );
378 __qPointF += __qPointFTextOffset;
380 __qPointF += __qPointFTextOffset;
385 __qFont.setItalic( !_poDataPositionValidity || _poDataPositionValidity->
isValidElevation() ?
false :
true );
386 _pqPainter->setFont( __qFont );
387 __qPointF += __qPointFTextOffset;
400 double __fdZoom = _poChart->
getZoom();
401 if( __fdZoom < 0.5 ) __fdZoom = 0.5;
402 else if( __fdZoom > 2.0 ) __fdZoom = 2.0;
405 QPointF __qPointFTo = _poChart->
toDrawPosition( *_poOverlayPoint );
406 QPointF __qPointFDelta = __qPointFTo - __qPointFFrom;
411 __qPen.setWidth( __qPen.width() * __fdZoom );
413 _pqPainter->setPen( __qPen );
414 _pqPainter->drawLine( __qPointFFrom, __qPointFTo );
417 double __fdDeltaLimit = ( 100.0 + 100.0*fabs( pow( sin( __fdBearingTo*
QVCT::DEG2RAD ), 3 ) ) ) * __fdZoom;
419 || __qPointFDelta.x()*__qPointFDelta.x() + __qPointFDelta.y()*__qPointFDelta.y() < __fdDeltaLimit*__fdDeltaLimit
420 || __fdZoom <= 0.5 )
return;
423 drawText( _poChart, _pqPainter, __qsDistance, 0.5 * __qPointFFrom + 0.5 * __qPointFTo );
426 double __fdBearingFrom = __fdBearingTo + 180.0;
427 if( __fdBearingFrom > 360.0 ) __fdBearingFrom -= 360.0;
432 double __fdBearingOffset = ( 35.0 + 25.0*fabs( pow( sin( __fdBearingTo ), 3 ) ) ) * __fdZoom;
433 if(
bVisibleRouting )
drawText( _poChart, _pqPainter, __qsBearingTo+QString::fromUtf8(
"·")+__qsBearingFrom, __qPointFFrom+QPointF( __fdBearingOffset*sin( __fdBearingTo ), -__fdBearingOffset*cos( __fdBearingTo ) ) );
434 if( _poOverlayPoint->
bVisibleRouting )
drawText( _poChart, _pqPainter, __qsBearingFrom+QString::fromUtf8(
"·")+__qsBearingTo, __qPointFTo+QPointF( __fdBearingOffset*sin( __fdBearingFrom ), -__fdBearingOffset*cos( __fdBearingFrom ) ) );
444 double __fdZoom = _poChart->
getZoom();
445 if( __fdZoom < 0.5 ) __fdZoom = 0.5;
446 else if( __fdZoom > 2.0 ) __fdZoom = 2.0;
451 __qPointF -= _rqPointFScrPosition;
452 return( __qPointF.x()*__qPointF.x() + __qPointF.y()*__qPointF.y() <= 100*__fdZoom*__fdZoom );
double getZoom() const
Returns the current zoom factor.
QRectF getDrawArea() const
Returns the viewport draw area.
QPointF toDrawPosition(const CDataPosition &_roGeoPosition) const
Converts the given (geographical) position [long,lat,elev] to chart draw point [px].
bool isValidPosition() const
Returns the position's (global) validity status.
bool isValidElevation() const
Returns the elevation's (global) validity status.
(Geographical) Position data [long,lat,elev]
double getLongitude() const
Returns this position's longitude, in degrees.
static constexpr double UNDEFINED_LATITUDE
Specific value for an undefined latitude.
void resetPosition()
Resets all coordinates (to an undefined position)
double getElevation() const
Returns this position's elevation, in meters.
static double bearingRL(const CDataPosition &_roPosition1, const CDataPosition &_roPosition2)
Returns the rhumb-line (constant) bearing between two points, in degrees.
static double distanceRL(const CDataPosition &_roPosition1, const CDataPosition &_roPosition2)
Returns the rhumb-line distance between two points, in meters.
double getLatitude() const
Returns this position's latitude, in degrees.
static const CDataPosition UNDEFINED
Specific value for an undefined position.
static constexpr double UNDEFINED_LONGITUDE
Specific value for an undefined longitude.
void serialize(QDataStream &_rqDataStream) const
Serializes (store) this object's data to binary format.
void setPosition(double _fdLongitude, double _fdLatitude, double _fdElevation=UNDEFINED_ELEVATION)
Sets new coordinates.
static constexpr double UNDEFINED_ELEVATION
Specific value for an undefined elevation.
void unserialize(QDataStream &_rqDataStream)
Unserializes (restore) this object's data from binary format.
bool isValidTime() const
Returns the time's (global) validity status.
double getTime() const
Returns this time's time, in seconds from Unix epoch.
static constexpr double UNDEFINED_TIME
Specific value for an undefined time.
[UI] Application main window
QPixmap symbolPixmap(const QString &_rqsSymbol)
Returns pixmap matching the given symbol (loaded from the application's symbol directory)
bool symbolExists(const QString &_rqsSymbol)
Returns whether the given symbol exists (in the application's symbol directory)
bool isMultiSelected() const
Returns this item's selection status.
virtual COverlay * useOverlay()=0
Returns this object's (base) overlay.
virtual void serialize(QDataStream &_rqDataStream) const
Serializes (store) this object's data to binary format.
QString getName() const
Returns this object's name.
virtual void unserialize(QDataStream &_rqDataStream)
Unserializes (restore) this object's data from binary format.
virtual bool matchScrPosition(const CChart *_poChart, const QPointF &_rqPointFScrPosition) const
Returns whether this point matches the given screen position.
static int getPositionBox(const QTreeWidgetItem *_pqTreeWidgetItem, CDataPosition *_poDataPositionLower, CDataPosition *_poDataPositionUpper, int _iIndexMin=0, int _iIndexMax=-1)
Returns the minimal geographical positions box containing the points in the given overlay/container.
virtual void drawSymbol(const CChart *_poChart, QPainter *_pqPainter, const QString &_rqsSymbol)
Draws the symbol (user-defined)
virtual void drawText(const CChart *_poChart, QPainter *_pqPainter, const QString &_rqsText, const QPointF &_rqPointFScrPosition, bool _bItalic=false)
Draws the given text, at the given screen position.
virtual void drawTag(const CChart *_poChart, QPainter *_pqPainter, ETagPosition _eTagPosition=TAG_AUTO, const CDataTimeValidity *_poDataTimeValidity=0, const CDataPositionValidity *_poDataPositionValidity=0)
Draws the tag (name)
virtual void drawMarker(const CChart *_poChart, QPainter *_pqPainter, const CDataPositionValidity *_poDataPositionValidity=0, bool _bSelected=false)
Draws the point (marker)
virtual void unserialize(QDataStream &_rqDataStream)
Unserializes (restore) this object's data from binary format.
virtual void serialize(QDataStream &_rqDataStream) const
Serializes (store) this object's data to binary format.
COverlayPoint(const QString &_rqsName)
virtual void drawLine(const CChart *_poChart, QPainter *_pqPainter, const COverlayPoint *_poOverlayPoint)
Draws a line (between this and the other specified point), including distance/bearing data.
Generic overlay visibility.
bool bVisibleRouting
Routing's (data) visibility status.
bool bVisible
Global (marker) visibility status.
bool bVisiblePosition
Position's visibility status.
bool bVisibleName
Name's (tag) visibility status.
const QBrush & getBrushText() const
const QBrush & getBrushMarker() const
const QPen & getPenText() const
const QPen & getPenMarkerSelected() const
const QPen & getPenLine() const
const QBrush & getBrushMarkerSelected() const
const QFont & getFont() const
const QPen & getPenMarker() const
int getScreenDpi()
[Misc] Returns the screen Dots-per-Inch (DPI)
static QString toString(double _fdValue, EUnit _eUnit, int _iPrecision=0)
Returns the formatted represention of the given value, using the specified format/unit and decimal pr...
static QString toString(double _fdValue, EUnit _eUnit, int _iPrecision=0)
Returns the formatted represention of the given value, using the specified format/unit and decimal pr...
static QString toString(double _fdValue, EUnit _eUnit, int _iPrecision=0)
Returns the formatted represention of the given value, using the specified format/unit and decimal pr...
static QString toString(double _fdValue, EType _eType, EUnit _eUnit, int _iPrecision=0)
Returns the formatted represention of the given value, using the specified format/unit and decimal pr...
static QString toString(double _fdValue, CUnitTimeZone::EUnit _eUnitTimeZone, EUnit _eUnit, int _iPrecision=0)
Returns the formatted represention of the given value, using the specified format/unit and decimal pr...
static CMainWindow * useMainWindow()
static CSettings * useSettings()
static constexpr double DEG2RAD