Qt Virtual Chart Table (QVCT)
CTrackOverlay.cpp
Go to the documentation of this file.
1 // INDENTING (emacs/vi): -*- mode:c++; tab-width:2; c-basic-offset:2; intent-tabs-mode:nil; -*- ex: set tabstop=2 expandtab:
2 
3 /*
4  * Qt Virtual Chart Table (QVCT)
5  * Copyright (C) 2012 Cedric Dufour <http://cedric.dufour.name>
6  * Author: Cedric Dufour <http://cedric.dufour.name>
7  *
8  * The Qt Virtual Chart Table (QVCT) is free software:
9  * you can redistribute it and/or modify it under the terms of the GNU General
10  * Public License as published by the Free Software Foundation, Version 3.
11  *
12  * The Qt Virtual Chart Table (QVCT) is distributed in the hope
13  * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
14  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  *
16  * See the GNU General Public License for more details.
17  */
18 
19 // QT
20 #include <QByteArray>
21 #include <QDataStream>
22 #include <QDomDocument> // QtXml module
23 #include <QFileInfo>
24 #include <QList>
25 #include <QMimeData>
26 #include <QPainter>
27 #include <QPointF>
28 #include <QStringList>
29 #include <QTreeWidget>
30 #include <QTreeWidgetItem>
31 #include <QWidget>
32 #include <QXmlStreamWriter>
33 
34 // QVCT
35 #include "QVCTRuntime.hpp"
40 
41 
42 //------------------------------------------------------------------------------
43 // CONSTRUCTORS / DESTRUCTOR
44 //------------------------------------------------------------------------------
45 
46 CTrackOverlay::CTrackOverlay( QWidget* _pqParent )
47  : COverlayBaseTree( _pqParent, tr("Tracks") )
48 {
50 
51  // Tree widget
52  // ... columns
53  QTreeWidget::setColumnCount( 3 );
54  QTreeWidget::setColumnWidth( NAME, 184 );
55  // ... header
56  QTreeWidgetItem* __pqTreeWidgetItem = new QTreeWidgetItem();
57  __pqTreeWidgetItem->setText( NAME, tr("Name") );
58  __pqTreeWidgetItem->setIcon( VISIBLE, QIcon( ":icons/16x16/visible.png" ) );
59  __pqTreeWidgetItem->setIcon( SELECT, QIcon( ":icons/16x16/select.png" ) );
60  QTreeWidget::setHeaderItem( __pqTreeWidgetItem );
61  QTreeWidget::resizeColumnToContents( VISIBLE );
62  QTreeWidget::resizeColumnToContents( SELECT );
63  // ... top-level item
64  QTreeWidgetItem::setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable );
65  QTreeWidgetItem::setText( NAME, COverlay::qsName );
66  QTreeWidgetItem::setCheckState( VISIBLE, Qt::Checked );
67  // ... drag 'n drop
68  QTreeWidget::setDragDropMode( QAbstractItemView::InternalMove );
69 }
70 
72 {
74  clear();
75 }
76 
77 
78 //------------------------------------------------------------------------------
79 // METHODS: QTreeWidget (implement/override)
80 //------------------------------------------------------------------------------
81 
82 QStringList CTrackOverlay::mimeTypes() const
83 {
84  static const QStringList __qStringList( "application/qvct.trackpoint" );
85  return __qStringList;
86 }
87 
88 QMimeData* CTrackOverlay::mimeData( const QList<QTreeWidgetItem*> _qListTreeWidgetItems ) const
89 {
90  QByteArray __qByteArray;
91  QDataStream __qDataStream( &__qByteArray, QIODevice::WriteOnly );
92  for( int __i=0; __i < _qListTreeWidgetItems.count(); __i++ )
93  {
94  QTreeWidgetItem* __pqTreeWidgetItem = _qListTreeWidgetItems.at( __i );
95  if( __pqTreeWidgetItem->type() != COverlayObject::ITEM ) continue;
96  ((CTrackPoint*)__pqTreeWidgetItem)->serialize( __qDataStream );
97  }
98  QMimeData* __pqMimeData = new QMimeData();
99  __pqMimeData->setData( "application/qvct.trackpoint", __qByteArray );
100  return __pqMimeData;
101 }
102 
103 bool CTrackOverlay::dropMimeData ( QTreeWidgetItem* _pqTreeWidgetItem, int _iIndex, const QMimeData* _pqMimeData, Qt::DropAction eAction )
104 {
105  if( !_pqTreeWidgetItem ) return false;
106  QByteArray __qByteArray = _pqMimeData->data( "application/qvct.trackpoint" );
107  QDataStream __qDataStream( &__qByteArray, QIODevice::ReadOnly );
108  CTrackPoint* __poTrackPoint = 0;
109  while( !__qDataStream.atEnd() )
110  {
111  __poTrackPoint = new CTrackPoint( "#MIMEDATA#" );
112  __poTrackPoint->unserialize( __qDataStream );
113  _pqTreeWidgetItem->insertChild( _iIndex, __poTrackPoint );
114  }
115  if( __poTrackPoint ) QTreeWidget::setCurrentItem( __poTrackPoint );
116  return true;
117 }
118 
119 void CTrackOverlay::dropEvent( QDropEvent* _pqDropEvent )
120 {
121  QTreeWidget::dropEvent( _pqDropEvent );
124 }
125 
126 //------------------------------------------------------------------------------
127 // METHODS: COverlay (implement/override)
128 //------------------------------------------------------------------------------
129 
130 void CTrackOverlay::drawContent( const CChart* _poChart, QPainter* _pqPainter ) const
131 {
132  if( !bVisible ) return;
133  int __iCount = QTreeWidgetItem::childCount();
134  for( int __i = 0; __i < __iCount; __i++ )
135  ((CTrackContainer*)QTreeWidgetItem::child( __i ))->draw( _poChart, _pqPainter );
136 }
137 
138 void CTrackOverlay::showDetail( const QTreeWidgetItem* _pqTreeWidgetItem ) const
139 {
140  if( !_pqTreeWidgetItem ) return;
141  switch( _pqTreeWidgetItem->type() )
142  {
143 
145  {
146  CTrackContainer* __poTrackContainer = (CTrackContainer*)_pqTreeWidgetItem;
147  __poTrackContainer->showDetail();
148  }
149  break;
150 
152  {
153  CTrackSubContainer* __poTrackSubContainer = (CTrackSubContainer*)_pqTreeWidgetItem;
154  __poTrackSubContainer->showDetail();
155  }
156  break;
157 
159  {
160  CTrackPoint* __poTrackPoint = (CTrackPoint*)_pqTreeWidgetItem;
161  CChartTable* __poChartTable = QVCTRuntime::useChartTable();
162  if( __poTrackPoint->CDataPosition::operator!=( CDataPosition::UNDEFINED )
163  && ( __poChartTable->setPointerTarget( *__poTrackPoint )
164  || __poChartTable->extendPointerPath( *__poTrackPoint ) ) )
165  __poChartTable->showGeoPosition( *__poTrackPoint );
166  else
167  __poTrackPoint->showDetail();
168  }
169  break;
170 
171  default:;
172 
173  }
174 }
175 
176 void CTrackOverlay::setPosition( const QTreeWidgetItem* _pqTreeWidgetItem ) const
177 {
178  switch( _pqTreeWidgetItem->type() )
179  {
180 
182  if( _pqTreeWidgetItem->isExpanded() ) return; // NOTE: Expansion switch is handled *AFTER* this method is called
183  {
184  CTrackContainer* __poTrackContainer = (CTrackContainer*)_pqTreeWidgetItem;
185  CDataPosition __oDataPositionLower( 180, 90, 999999 ), __oDataPositionUpper( -180, -90, -999999 );
186  int __iCountBox = 0;
187  int __iCount = __poTrackContainer->childCount();
188  for( int __i = 0; __i < __iCount; __i++ )
189  {
190  CDataPosition __oDataPositionLower_aux, __oDataPositionUpper_aux;
191  int __iCountBox_aux = COverlayPoint::getPositionBox( (COverlayObject*)__poTrackContainer->child( __i ), &__oDataPositionLower_aux, &__oDataPositionUpper_aux );
192  if( __iCountBox_aux )
193  {
194  __iCountBox += __iCountBox_aux;
195  __oDataPositionLower.setPosition( std::min( __oDataPositionLower.getLongitude(), __oDataPositionLower_aux.getLongitude() ),
196  std::min( __oDataPositionLower.getLatitude(), __oDataPositionLower_aux.getLatitude() ),
197  std::min( __oDataPositionLower.getElevation(), __oDataPositionLower_aux.getElevation() ) );
198  __oDataPositionUpper.setPosition( std::max( __oDataPositionUpper.getLongitude(), __oDataPositionUpper_aux.getLongitude() ),
199  std::max( __oDataPositionUpper.getLatitude(), __oDataPositionUpper_aux.getLatitude() ),
200  std::max( __oDataPositionUpper.getElevation(), __oDataPositionUpper_aux.getElevation() ) );
201  }
202  }
203  if( __iCountBox > 1 ) QVCTRuntime::useChartTable()->setScaleArea( __oDataPositionLower, __oDataPositionUpper, 0.9 );
204  else if( __iCountBox == 1 ) QVCTRuntime::useChartTable()->setGeoPosition( __oDataPositionLower );
205  }
206  break;
207 
209  if( _pqTreeWidgetItem->isExpanded() ) return; // NOTE: Expansion switch is handled *AFTER* this method is called
210  {
211  CDataPosition __oDataPositionLower, __oDataPositionUpper;
212  int __iCount = COverlayPoint::getPositionBox( (CTrackSubContainer*)_pqTreeWidgetItem, &__oDataPositionLower, &__oDataPositionUpper );
213  if( __iCount > 1 ) QVCTRuntime::useChartTable()->setScaleArea( __oDataPositionLower, __oDataPositionUpper, 0.9 );
214  else if( __iCount == 1 ) QVCTRuntime::useChartTable()->setGeoPosition( __oDataPositionLower );
215  }
216  break;
217 
219  {
220  CTrackPoint* __poTrackPoint = (CTrackPoint*)_pqTreeWidgetItem;
221  if( __poTrackPoint->CDataPosition::operator==( CDataPosition::UNDEFINED ) ) return;
222  QVCTRuntime::useChartTable()->setGeoPosition( *__poTrackPoint );
223  }
224  break;
225 
226  default:;
227 
228  }
229 }
230 
231 COverlayPoint* CTrackOverlay::matchScrPosition( const CChart* _poChart, const QPointF& _rqPointFScrPosition ) const
232 {
233  if( !bVisible ) return 0;
234  int __iCount = QTreeWidgetItem::childCount();
235  for( int __i = __iCount-1 ; __i >= 0; __i-- ) // we must go in the reverse order of CTrackOverlay::draw() to pick the correct (overlapping) item
236  {
237  CTrackContainer* __poTrackContainer = (CTrackContainer*)QTreeWidgetItem::child( __i );
238  COverlayPoint* __poOverlayPoint = __poTrackContainer->matchScrPosition( _poChart, _rqPointFScrPosition );
239  if( __poOverlayPoint ) return __poOverlayPoint;
240  }
241  return 0;
242 }
243 
244 
245 //------------------------------------------------------------------------------
246 // METHODS: COverlayBaseTree (implement/override)
247 //------------------------------------------------------------------------------
248 
249 void CTrackOverlay::onChange( QTreeWidgetItem* _pqTreeWidgetItem, int _iColumn )
250 {
251  bool bRedraw = false;
252  switch( _pqTreeWidgetItem->type() )
253  {
254 
256  {
257  switch( _iColumn )
258  {
259  case VISIBLE:
260  COverlay::setVisible( _pqTreeWidgetItem->checkState( VISIBLE ) == Qt::Checked );
261  bRedraw = true;
262  break;
263  default:;
264  }
265  }
266  break;
267 
269  {
270  CTrackContainer* __poTrackContainer = (CTrackContainer*)_pqTreeWidgetItem;
271  switch( _iColumn )
272  {
273  case NAME:
274  __poTrackContainer->setName( _pqTreeWidgetItem->text( NAME ) );
275  break;
276  case VISIBLE:
277  __poTrackContainer->setVisible( _pqTreeWidgetItem->checkState( VISIBLE ) == Qt::Checked );
278  bRedraw = true;
279  break;
280  default:;
281  }
282  }
283  break;
284 
286  {
287  CTrackSubContainer* __poTrackSubContainer = (CTrackSubContainer*)_pqTreeWidgetItem;
288  switch( _iColumn )
289  {
290  case VISIBLE:
291  __poTrackSubContainer->setVisible( _pqTreeWidgetItem->checkState( VISIBLE ) == Qt::Checked );
292  bRedraw = true;
293  break;
294  default:;
295  }
296  }
297  break;
298 
300  {
301  CTrackPoint* __poTrackPoint = (CTrackPoint*)_pqTreeWidgetItem;
302  switch( _iColumn )
303  {
304  case NAME:
305  __poTrackPoint->setName( _pqTreeWidgetItem->text( NAME ) );
306  bRedraw = true;
307  break;
308  case VISIBLE:
309  __poTrackPoint->setVisible( _pqTreeWidgetItem->checkState( VISIBLE ) == Qt::Checked );
310  bRedraw = true;
311  break;
312  case SELECT:
313  __poTrackPoint->setMultiSelected( _pqTreeWidgetItem->checkState( SELECT ) == Qt::Checked );
314  bRedraw = true;
315  break;
316  default:;
317  }
318  }
319  break;
320 
321  default:;
322 
323  }
324 
325  // Redraw
326  if( bRedraw )
327  {
330  }
331 }
332 
333 
334 //------------------------------------------------------------------------------
335 // METHODS
336 //------------------------------------------------------------------------------
337 
338 //
339 // OTHER
340 //
341 
343 {
344  QColor __qColor = QVCTRuntime::useSettings()->getColorTrack();
345  __qColor.setAlpha( 128 );
346  qBrushMarker.setColor( __qColor );
347  __qColor.setAlpha( 192 );
348  qPenText.setColor( QColor::fromHsv( __qColor.hue(), __qColor.saturation(), std::min( 128, __qColor.value() ), 192 ) );
349  qPenMarker.setColor( __qColor );
350  qPenLine.setColor( __qColor );
351  qPenVector.setColor( __qColor );
352 }
353 
355 {
356  int __iCount = QTreeWidgetItem::childCount();
357  for( int __i = 0; __i < __iCount; __i++ )
358  {
359  CTrackContainer* __poTrackContainer = (CTrackContainer*)QTreeWidgetItem::child( __i );
360  if( __poTrackContainer->getName() == _rqsName ) return __poTrackContainer;
361  }
362  return addContainer( _rqsName );
363 }
364 
366 {
367  CTrackContainer* __poTrackContainer = pickContainer( _rqsName );
368  return __poTrackContainer->pickSubContainer();
369 }
370 
371 CTrackContainer* CTrackOverlay::addContainer( const QString& _rqsName )
372 {
373  CTrackContainer* __poTrackContainer = new CTrackContainer( _rqsName );
374  QTreeWidgetItem::addChild( __poTrackContainer );
375  QTreeWidgetItem::setExpanded( true );
376  return __poTrackContainer;
377 }
378 
380 {
381  int __iCount = 0;
382  for( int __i = QTreeWidgetItem::childCount()-1; __i >= 0; __i-- )
383  __iCount += ((CTrackContainer*)QTreeWidgetItem::child( __i ))->deleteSelection();
384  return __iCount;
385 }
386 
388 {
389  QTreeWidgetItem* __pqTreeWidgetItem = QTreeWidgetItem::takeChild( 0 );
390  while( __pqTreeWidgetItem )
391  {
392  delete (CTrackContainer*)__pqTreeWidgetItem;
393  __pqTreeWidgetItem = QTreeWidgetItem::takeChild( 0 );
394  }
395 }
396 
397 CTrackContainer* CTrackOverlay::load( const QString& _rqsFilename )
398 {
399  QFileInfo __qFileInfo( _rqsFilename );
400  CTrackContainer* __poTrackContainer = 0;
401  QString __qsError;
402  do // error-catching context [begin]
403  {
404  // File
405  QFileInfo __qFileInfo( _rqsFilename );
406  QFile __qFile( __qFileInfo.absoluteFilePath() );
407  if( !__qFile.open( QIODevice::ReadOnly ) )
408  {
409  __qsError = QString( "Failed to open file (%1)" ).arg( __qFile.fileName() );
410  break;
411  }
412  QDomDocument __qDocDocument;
413  if( !__qDocDocument.setContent( &__qFile ) )
414  {
415  __qsError = QString( "Failed to parse XML (%1)" ).arg( __qFile.fileName() );
416  __qFile.close();
417  break;
418  }
419  __qFile.close();
420 
421  // XML
422  QDomElement __qDomElement = __qDocDocument.documentElement();
423  QString __qDocType = __qDomElement.nodeName();
424  if( __qDomElement.isNull() || ( __qDocType != "QVCT" && __qDocType != "gpx" ) )
425  {
426  __qsError = QString( "Invalid XML document type (%1); expected: 'QVCT' or 'gpx'" ).arg( __qFile.fileName() );
427  break;
428  }
429  if( __qDocType == "QVCT" ) parseQVCT( __qDomElement, &__poTrackContainer );
430  else if( __qDocType == "gpx" ) parseGPX( __qDomElement, &__poTrackContainer );
431  }
432  while( false ); // error-catching context [end]
433  if( !__qsError.isEmpty() )
434  {
435  qCritical( "ERROR[%s]: %s", Q_FUNC_INFO, qPrintable( __qsError ) );
436  QVCTRuntime::useMainWindow()->fileError( QVCT::OPEN, _rqsFilename );
437  return 0;
438  }
439  QTreeWidgetItem::setExpanded( true );
440  return __poTrackContainer;
441 }
442 
443 int CTrackOverlay::parseQVCT( const QDomElement& _rqDomElement, CTrackContainer** _ppoTrackContainer )
444 {
445  CTrackContainer* __poTrackContainer = 0;
446  int __iCount = 0;
447  for( QDomElement __qDomElement = _rqDomElement.firstChildElement( "Track" ); !__qDomElement.isNull(); __qDomElement = __qDomElement.nextSiblingElement( "Track" ) )
448  {
449  __iCount++;
450  QString __qsName = __qDomElement.attribute( "name" );
451  if( !__qsName.isEmpty() ) __qsName = COverlay::newChildName( __qsName );
452  else __qsName = COverlay::newChildName( tr("Track"), 1, true );
453  __poTrackContainer = new CTrackContainer( __qsName );
454  __poTrackContainer->parseQVCT( __qDomElement );
455  QTreeWidgetItem::addChild( __poTrackContainer );
456  }
457  if( _ppoTrackContainer ) *_ppoTrackContainer = __poTrackContainer;
458  return __iCount;
459 }
460 
461 int CTrackOverlay::parseGPX( const QDomElement& _rqDomElement, CTrackContainer** _ppoTrackContainer )
462 {
463  CTrackContainer* __poTrackContainer = 0;
464  int __iCount = 0;
465  for( QDomElement __qDomElement = _rqDomElement.firstChildElement( "trk" ); !__qDomElement.isNull(); __qDomElement = __qDomElement.nextSiblingElement( "trk" ) )
466  {
467  __iCount++;
468  QString __qsName = __qDomElement.firstChildElement( "name" ).text();
469  if( !__qsName.isEmpty() ) __qsName = COverlay::newChildName( __qsName );
470  else __qsName = COverlay::newChildName( tr("Track"), 1, true );
471  __poTrackContainer = new CTrackContainer( __qsName );
472  __poTrackContainer->parseGPX( __qDomElement );
473  QTreeWidgetItem::addChild( __poTrackContainer );
474  }
475  if( _ppoTrackContainer ) *_ppoTrackContainer = __poTrackContainer;
476  return __iCount;
477 }
478 
479 void CTrackOverlay::save( const QString& _rqsFilename, CTrackContainer* _poTrackContainer ) const
480 {
481  QFileInfo __qFileInfo( _rqsFilename );
482  QString __qsFormat = __qFileInfo.suffix();
483  if( __qsFormat != "qvct" && __qsFormat != "gpx" )
484  {
485  qCritical( "ERROR[%s]: Invalid file format/extention (%s); expected: 'qvct' or 'gpx'", Q_FUNC_INFO, qPrintable( __qsFormat ) );
486  return;
487  }
488 
489  // File [open]
490  QFile __qFile( __qFileInfo.absoluteFilePath() );
491  if( !__qFile.open( QIODevice::WriteOnly ) )
492  {
493  qCritical( "ERROR[%s]: Failed to open file (%s)", Q_FUNC_INFO, qPrintable( __qFile.fileName() ) );
494  return;
495  }
496 
497  // XML [start]
498  QXmlStreamWriter __qXmlStreamWriter( &__qFile );
499  __qXmlStreamWriter.setAutoFormatting( true );
500  __qXmlStreamWriter.writeStartDocument();
501 
502  // Data
503  if( __qsFormat == "qvct" ) dumpQVCT( __qXmlStreamWriter, _poTrackContainer );
504  else if( __qsFormat == "gpx" ) dumpGPX( __qXmlStreamWriter, _poTrackContainer );
505 
506  // XML [end]
507  __qXmlStreamWriter.writeEndDocument();
508 
509  // File [close]
510  __qFile.close();
511 }
512 
513 void CTrackOverlay::dumpQVCT( QXmlStreamWriter & _rqXmlStreamWriter, CTrackContainer* _poTrackContainer, bool _bProjectDump ) const
514 {
515  // Data
516  if( !_bProjectDump ) _rqXmlStreamWriter.writeStartElement( "QVCT" );
517  // ... containers
518  if( _poTrackContainer )
519  {
520  _poTrackContainer->dumpQVCT( _rqXmlStreamWriter, false );
521  }
522  else // no container given; assume selection dump or full dump
523  {
524  int __iCount = QTreeWidgetItem::childCount();
525  for( int __i = 0; __i < __iCount; __i++ )
526  ((CTrackContainer*)QTreeWidgetItem::child( __i ))->dumpQVCT( _rqXmlStreamWriter, !_bProjectDump );
527  }
528  // ... [end]
529  if( !_bProjectDump ) _rqXmlStreamWriter.writeEndElement(); // QVCT
530 }
531 
532 void CTrackOverlay::dumpGPX( QXmlStreamWriter & _rqXmlStreamWriter, CTrackContainer* _poTrackContainer ) const
533 {
534  // GPX format reference: see http://www.topografix.com/GPX/1/1/
535 
536  // Data
537  _rqXmlStreamWriter.writeStartElement( "gpx" );
538  _rqXmlStreamWriter.writeAttribute( "version", "1.1" );
539  _rqXmlStreamWriter.writeAttribute( "creator", "Qt Virtual Chart Table (QVCT)" );
540  // ... containers
541  if( _poTrackContainer )
542  {
543  _poTrackContainer->dumpGPX( _rqXmlStreamWriter, false );
544  }
545  else // no container given; assume selection dump
546  {
547  int __iCount = QTreeWidgetItem::childCount();
548  for( int __i = 0; __i < __iCount; __i++ )
549  ((CTrackContainer*)QTreeWidgetItem::child( __i ))->dumpGPX( _rqXmlStreamWriter, true );
550  }
551  // ... [end]
552  _rqXmlStreamWriter.writeEndElement(); // gpx
553 }
[UI] Virtual "chart table" (view)
Definition: CChartTable.hpp:55
bool extendPointerPath(const CDataPosition &_roGeoPosition)
Extends the pointer path; returns true if is was actually extended, false otherwise.
void setScaleArea(const CDataPosition &_roGeoPosition1, const CDataPosition &_roGeoPosition2, double _fdScaleCorrection=1.0)
Sets the reference scale factor to display the given (geographical) area (defined by its opposite cor...
void updateChart()
Update the (current) chart content (on screen)
bool setPointerTarget(const CDataPosition &_roGeoPosition)
Sets the pointer target's position; returns true if is was actually set, false otherwise.
void showGeoPosition(const CDataPosition &_roGeoPosition)
Shows the given (geographical) position on chart.
void setGeoPosition(const CDataPosition &_roGeoPosition, bool _bSkipCurrent=false)
Sets the reference chart (geographical) position.
[UI] Chart (view)
Definition: CChart.hpp:44
(Geographical) Position data [long,lat,elev]
double getLongitude() const
Returns this position's longitude, in degrees.
double getElevation() const
Returns this position's elevation, in meters.
double getLatitude() const
Returns this position's latitude, in degrees.
static const CDataPosition UNDEFINED
Specific value for an undefined position.
void setPosition(double _fdLongitude, double _fdLatitude, double _fdElevation=UNDEFINED_ELEVATION)
Sets new coordinates.
void fileError(QVCT::EFileOperation _eFileOperation, const QString &_rqsFilename)
Displays a generic error message for an invalid file name and operation (open/save)
Generic overlay base (tree widget)
void destroy()
Prepare the underlying QTreeWidget for destruction.
void setMultiSelected(bool _bMultiSelected)
Sets this item's selection status.
Generic overlay object.
@ CONTAINER
Container.
@ SUBCONTAINER
Sub-container.
@ OVERLAY
(Base) overlay
QString getName() const
Returns this object's name.
void setName(const QString &_rqsName)
Sets this object's name.
Generic overlay point.
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.
void setVisible(bool _bVisible)
Sets the point's (marker) visibility status.
void setVisible(bool _bVisible)
Sets this overlay items' global visibility status.
Definition: COverlay.hpp:113
QString newChildName(const QString &_rqsName, int __iZeroPrefix=0, bool __bForceSuffix=false) const
Returns a valid name for a new sibling of this object.
Definition: COverlay.cpp:123
QPen qPenLine
QPen used to draw lines on this overlay.
Definition: COverlay.hpp:91
QPen qPenVector
QPen used to draw vectors on this overlay.
Definition: COverlay.hpp:94
QPen qPenText
QPen used to draw text on this overlay.
Definition: COverlay.hpp:76
bool bVisible
Overlay items' global visibility status.
Definition: COverlay.hpp:56
void forceRedraw()
Forces this overlay's rendering (not matter its cache content)
Definition: COverlay.hpp:115
QString qsName
Overlay name.
Definition: COverlay.hpp:52
QBrush qBrushMarker
QBrush used to draw markers on this overlay.
Definition: COverlay.hpp:79
QPen qPenMarker
QPen used to draw markers on this overlay.
Definition: COverlay.hpp:82
QColor getColorTrack()
[Color] Returns the track overlay's base color
Definition: CSettings.hpp:418
[UI] Track overlay container
int parseGPX(const QDomElement &_rqDomElement)
Retrieves this object's content from the given GPX source (file)
CTrackSubContainer * pickSubContainer()
Returns the last/current sub-container of this container.
void dumpQVCT(QXmlStreamWriter &_rqXmlStreamWriter, bool bOnlySelected=false) const
Stores this object's content to the given QVCT destination (file)
virtual void showDetail()
Displays this object's details (in the appropriate widget/view)
int parseQVCT(const QDomElement &_rqDomElement)
Retrieves this object's content from the given QVCT source (file)
void dumpGPX(QXmlStreamWriter &_rqXmlStreamWriter, bool bOnlySelected=false) const
Stores this object's content to the given GPX destination (file)
virtual COverlayPoint * matchScrPosition(const CChart *_poChart, const QPointF &_rqPointFScrPosition) const
Returns the overlay container's point that (first) matches the given screen position (0 if none is fo...
@ VISIBLE
Track visibility status.
@ SELECT
Track selection status.
@ NAME
Track name.
CTrackOverlay(QWidget *_pqParent=0)
void clear()
Clear the entire content of this overlay.
virtual void dropEvent(QDropEvent *_pqDropEvent)
CTrackContainer * addContainer(const QString &_rqsName)
Add a new track (container) to this overlay.
virtual void drawContent(const CChart *_poChart, QPainter *_pqPainter) const
Draws this overlay's content.
CTrackContainer * pickContainer(const QString &_rqsName)
Returns a track (container) matching the given name.
void dumpQVCT(QXmlStreamWriter &_rqXmlStreamWriter, CTrackContainer *_poTrackContainer=0, bool _bProjectDump=false) const
Stores this object's content to the given QVCT destination (file)
virtual void showDetail(const QTreeWidgetItem *_pqTreeWidgetItem) const
Displays the given overlay object's details (in the appropriate widget/view)
virtual ~CTrackOverlay()
void dumpGPX(QXmlStreamWriter &_rqXmlStreamWriter, CTrackContainer *_poTrackContainer=0) const
Stores this object's content to the given GPX destination (file)
int parseGPX(const QDomElement &_rqDomElement, CTrackContainer **_ppoTrackContainer=0)
Retrieves this object's content from the given GPX source (file)
virtual bool dropMimeData(QTreeWidgetItem *_pqTreeWidgetItem, int _iIndex, const QMimeData *_pqMimeData, Qt::DropAction eAction)
CTrackSubContainer * pickSubContainer(const QString &_rqsName)
Returns the last/current segment (sub-container) of the track (container) matching the given name.
virtual QStringList mimeTypes() const
int deleteSelection()
Deletes selected items within this overlay's containers.
virtual COverlayPoint * matchScrPosition(const CChart *_poChart, const QPointF &_rqPointFScrPosition) const
Returns the overlay's point that (first) matches the given screen position (0 if none is found)
virtual void onChange(QTreeWidgetItem *_pqTreeWidgetItem, int __iColumn)
Handles item (content) changes in the underlying QTreeWidget.
void importSettings()
Imports settings from the application's global settings.
void save(const QString &_rqsFilename, CTrackContainer *_poTrackContainer=0) const
Save this object's content (container) to the given file (all selected items if no container is given...
CTrackContainer * load(const QString &_rqsFilename)
Load this object's content from the given file and returns the last loaded container (0 if none)
int parseQVCT(const QDomElement &_rqDomElement, CTrackContainer **_ppoTrackContainer=0)
Retrieves this object's content from the given QVCT source (file)
virtual void setPosition(const QTreeWidgetItem *_pqTreeWidgetItem) const
Centers the chart on the given overlay object's position.
virtual QMimeData * mimeData(const QList< QTreeWidgetItem * > _qListTreeWidgetItems) const
[UI] Track overlay point (item)
Definition: CTrackPoint.hpp:40
virtual void unserialize(QDataStream &_rqDataStream)
Unserializes (restore) this object's data from binary format.
Definition: CTrackPoint.cpp:71
virtual void showDetail()
Displays this object's details (in the appropriate widget/view)
Definition: CTrackPoint.cpp:77
[UI] Track overlay sub-container
virtual void showDetail()
Displays this object's details (in the appropriate widget/view)
static CMainWindow * useMainWindow()
static CChartTable * useChartTable()
static CSettings * useSettings()
@ OPEN
Definition: QVCT.hpp:42