21 #include <QApplication>
23 #include <QDockWidget>
24 #include <QFileDialog>
26 #include <QHBoxLayout>
30 #include <QMessageBox>
31 #include <QMessageBox>
36 #include <QTreeWidget>
52 : fdTimeLastRedraw( 0.0 )
54 setWindowTitle( tr(
"Qt Virtual Chart Table") );
59 QObject::connect( __qTimerRefresh, SIGNAL( timeout() ),
this, SLOT(
slotTimerRefresh() ) );
68 __poDeviceOverlay->
clear();
71 __qTimerRefresh->stop();
73 struct timespec __tsDelay;
76 nanosleep( &__tsDelay, NULL );
78 __pqMutexDataChange->lock();
79 __pqMutexDataChange->unlock();
85 QWidget* __pqWidget =
new QWidget();
86 QHBoxLayout* __pqHBoxLayout =
new QHBoxLayout();
91 __pqHBoxLayout->addWidget( __poChartTable, 1 );
96 __poChartControl->installEventFilter( __poChartTable );
97 __pqHBoxLayout->addWidget( __poChartControl );
103 QMainWindow::addDockWidget( Qt::LeftDockWidgetArea, __poOverlayListView );
107 QMainWindow::addDockWidget( Qt::LeftDockWidgetArea, __poOverlayDetailView );
108 __poOverlayDetailView->resize( __poOverlayDetailView->width(), 100 );
114 QMainWindow::addDockWidget( Qt::TopDockWidgetArea, __poTimeView );
118 QMainWindow::addDockWidget( Qt::TopDockWidgetArea, __poVesselTarget );
122 QMainWindow::addDockWidget( Qt::BottomDockWidgetArea, __poVesselPosition );
126 QMainWindow::addDockWidget( Qt::BottomDockWidgetArea, __poVesselCourse );
133 __pqWidget->setLayout( __pqHBoxLayout );
134 QMainWindow::setCentralWidget( __pqWidget );
140 QMenu* __pqMenuFile =
new QMenu( tr(
"&File") );
141 QAction* __pqActionLoad =
new QAction( tr(
"L&oad Project..." ),
this );
142 __pqActionLoad->setShortcuts( QKeySequence::Open );
144 __pqMenuFile->addAction( __pqActionLoad );
145 QAction* __pqActionSave =
new QAction( tr(
"&Save Project..." ),
this );
146 __pqActionSave->setShortcuts( QKeySequence::Save );
148 __pqMenuFile->addAction( __pqActionSave );
149 __pqMenuFile->addSeparator();
150 QAction* __pqActionLoadChart =
new QAction( tr(
"L&oad Chart..." ),
this );
152 __pqMenuFile->addAction( __pqActionLoadChart );
153 QAction* __pqActionAddElevation =
new QAction( tr(
"Add &Elevation..." ),
this );
155 __pqMenuFile->addAction( __pqActionAddElevation );
156 QAction* __pqActionLoadLandmarks =
new QAction( tr(
"Load &Landmarks..." ),
this );
158 __pqMenuFile->addAction( __pqActionLoadLandmarks );
159 QAction* __pqActionLoadRoute =
new QAction( tr(
"Load &Route..." ),
this );
161 __pqMenuFile->addAction( __pqActionLoadRoute );
162 QAction* __pqActionLoadTrack =
new QAction( tr(
"Load &Track..." ),
this );
164 __pqMenuFile->addAction( __pqActionLoadTrack );
165 QAction* __pqActionLoadVessel =
new QAction( tr(
"Load &Vessel..." ),
this );
167 __pqMenuFile->addAction( __pqActionLoadVessel );
168 __pqMenuFile->addSeparator();
169 QAction* __pqActionSettings =
new QAction( tr(
"S&ettings..."),
this );
170 __pqActionSettings->setShortcuts( QKeySequence::Preferences );
171 QMainWindow::connect( __pqActionSettings, SIGNAL( triggered() ),
this, SLOT(
slotShowSettings() ) );
172 __pqMenuFile->addAction( __pqActionSettings );
173 __pqMenuFile->addSeparator();
174 QAction* __pqActionPrint =
new QAction( tr(
"&Print..."),
this );
175 __pqActionPrint->setShortcuts( QKeySequence::Print );
177 __pqMenuFile->addAction( __pqActionPrint );
178 __pqMenuFile->addSeparator();
179 QAction* __pqActionExit =
new QAction( tr(
"E&xit"),
this );
180 __pqActionExit->setShortcuts( QKeySequence::Quit );
181 QMainWindow::connect( __pqActionExit, SIGNAL( triggered() ),
this, SLOT(
slotExit() ) );
182 __pqMenuFile->addAction( __pqActionExit );
183 menuBar()->addMenu( __pqMenuFile );
185 QMenu* __pqMenuWindow =
new QMenu( tr(
"&Window") );
186 QAction* __pqActionShowOverlayListView =
new QAction( tr(
"Show Overlay &List" ),
this );
187 QMainWindow::connect( __pqActionShowOverlayListView, SIGNAL( triggered() ),
this, SLOT(
slotShowOverlayListView() ) );
188 __pqMenuWindow->addAction( __pqActionShowOverlayListView );
189 QAction* __pqActionShowOverlayDetailView =
new QAction( tr(
"Show Overlay &Detail" ),
this );
190 QMainWindow::connect( __pqActionShowOverlayDetailView, SIGNAL( triggered() ),
this, SLOT(
slotShowOverlayDetailView() ) );
191 __pqMenuWindow->addAction( __pqActionShowOverlayDetailView );
192 QAction* __pqActionShowTimeView =
new QAction( tr(
"Show System &Time" ),
this );
193 QMainWindow::connect( __pqActionShowTimeView, SIGNAL( triggered() ),
this, SLOT(
slotShowTimeView() ) );
194 __pqMenuWindow->addAction( __pqActionShowTimeView );
195 QAction* __pqActionShowVesselTarget =
new QAction( tr(
"Show Vessel T&arget" ),
this );
196 QMainWindow::connect( __pqActionShowVesselTarget, SIGNAL( triggered() ),
this, SLOT(
slotShowVesselTarget() ) );
197 __pqMenuWindow->addAction( __pqActionShowVesselTarget );
198 QAction* __pqActionShowVesselPosition =
new QAction( tr(
"Show Vessel &Position" ),
this );
199 QMainWindow::connect( __pqActionShowVesselPosition, SIGNAL( triggered() ),
this, SLOT(
slotShowVesselPosition() ) );
200 __pqMenuWindow->addAction( __pqActionShowVesselPosition );
201 QAction* __pqActionShowVesselCourse =
new QAction( tr(
"Show Vessel &Course" ),
this );
202 QMainWindow::connect( __pqActionShowVesselCourse, SIGNAL( triggered() ),
this, SLOT(
slotShowVesselCourse() ) );
203 __pqMenuWindow->addAction( __pqActionShowVesselCourse );
204 QAction* __pqActionShowVesselCockpit =
new QAction( tr(
"Show Vessel Coc&kpit" ),
this );
205 QMainWindow::connect( __pqActionShowVesselCockpit, SIGNAL( triggered() ),
this, SLOT(
slotShowVesselCockpit() ) );
206 __pqMenuWindow->addAction( __pqActionShowVesselCockpit );
207 __pqMenuWindow->addSeparator();
208 QAction* __pqActionToggleFullscreen =
new QAction( tr(
"Toggle &Fullscreen" ),
this );
209 QMainWindow::connect( __pqActionToggleFullscreen, SIGNAL( triggered() ),
this, SLOT(
slotToggleFullscreen() ) );
210 __pqMenuWindow->addAction( __pqActionToggleFullscreen );
211 menuBar()->addMenu( __pqMenuWindow );
213 QMenu* __pqMenuHelp =
new QMenu( tr(
"&Help") );
214 QAction* __pqActionAbout =
new QAction( tr(
"&About"),
this );
215 QMainWindow::connect( __pqActionAbout, SIGNAL( triggered() ),
this, SLOT(
slotAbout() ) );
216 __pqMenuHelp->addAction( __pqActionAbout );
217 QAction* __pqActionAboutQt =
new QAction( tr(
"About &Qt"),
this );
218 QMainWindow::connect( __pqActionAboutQt, SIGNAL( triggered() ), qApp, SLOT( aboutQt() ) );
219 __pqMenuHelp->addAction( __pqActionAboutQt );
220 QMainWindow::menuBar()->addMenu( __pqMenuHelp );
240 QMessageBox::about(
this, tr(
"Qt Virtual Chart Table (QVCT)"),
241 QString(
"<H3 ALIGN=\"center\">Qt Virtual Chart Table (QVCT)<BR/>" ) +
243 QString(
"</H3>\n" ) +
244 tr(
"<P><B>Authors & Contributors:</B></P>\n"
245 "<P>Cédric Dufour <<A HREF=\"http://cedric.dufour.name\">http://cedric.dufour.name</A>>,\n"
246 "<BR/>Samuel Gaist <<A HREF=\"http://http://www.edeltech.ch\">http://www.edeltech.ch</A>></P>\n"
247 "<P><B>Website:</B></P>\n"
248 "<P><A HREF=\"http://cedric.dufour.name/software/qvct\">http://cedric.dufour.name/software/qvct</A></P>\n"
249 "<P><B>Copyright:</B></P>\n"
250 "<P>The Qt Virtual Chart Table (QVCT) is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, Version 3.</P>\n"
251 "<P>The Qt Virtual Chart Table (QVCT) is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</P>\n"
252 "<P>See the <A HREF=\"http://www.gnu.org/copyleft/gpl.html\">GNU General Public License</A> for more details.</P>\n" ) );
258 __poSettingsEditView->exec();
259 delete __poSettingsEditView;
263 __qTimerRefresh->stop();
304 QWidget::setWindowState( QWidget::windowState() ^ Qt::WindowFullScreen );
311 __pqMutexDataChange->lock();
327 __pqMutexDataChange->unlock();
347 QMessageBox::warning( 0,
"[QVCT] "+tr(
"WARNING"), _rqsMessage );
352 QMessageBox::critical( 0,
"[QVCT] "+tr(
"ERROR"), _rqsMessage );
357 return( QMessageBox::question( 0,
"[QVCT] "+tr(
"Please Confirm")+
"...", tr(
"The following data are about to be deleted")+QString(
":\n %1\n").arg( _rqsName )+tr(
"Do you want to proceed?"), QMessageBox::Cancel|QMessageBox::Ok, QMessageBox::Cancel ) == QMessageBox::Ok );
362 QString __qsFilename;
363 switch( _eFileOperation )
366 __qsFilename = QFileDialog::getOpenFileName( 0,
"[QVCT] "+_rqsTitle,
QVCTRuntime::useSettings()->getPathWorkingDirectory(), _rqsFilter );
369 __qsFilename = QFileDialog::getSaveFileName( 0,
"[QVCT] "+_rqsTitle,
QVCTRuntime::useSettings()->getPathWorkingDirectory(), _rqsFilter );
372 if( !__qsFilename.isEmpty() )
374 QFileInfo __qFileInfo( __qsFilename );
382 QFileInfo __qFileInfo( _rqsFilename );
385 switch( _eFileOperation )
389 if( !__qFileInfo.exists() )
391 errorMessage( tr(
"The requested file cannot be found")+QString(
":\n .../%1").arg( __qFileInfo.fileName() ) );
394 if( !__qFileInfo.isFile() || !__qFileInfo.isReadable() )
396 errorMessage( tr(
"The requested file cannot be read from")+QString(
":\n .../%1").arg( __qFileInfo.fileName() ) );
402 if( __qFileInfo.exists() )
404 if( !__qFileInfo.isFile() || !__qFileInfo.isWritable() )
406 errorMessage( tr(
"The requested file cannot be written to")+QString(
":\n .../%1").arg( __qFileInfo.fileName() ) );
415 if( _pqsListExtensions )
417 QString __qsExtension = __qFileInfo.suffix();
418 if( !_pqsListExtensions->contains( __qsExtension ) )
421 errorMessage( tr(
"The file format/extension is not supported")+QString(
":\n .../%1").arg( __qFileInfo.fileName() ) );
432 QFileInfo __qFileInfo( _rqsFilename );
433 switch( _eFileOperation )
436 errorMessage( tr(
"The requested file could not be loaded")+QString(
":\n .../%1").arg( __qFileInfo.fileName() ) );
439 errorMessage( tr(
"The requested file could not be saved")+QString(
":\n .../%1").arg( __qFileInfo.fileName() ) );
446 errorMessage( tr(
"The following data could not be parsed")+QString(
":\n %1").arg( _rqsString ) );
451 if( _rqsSymbol.isEmpty() )
return false;
452 QFileInfo __qFileInfo( _rqsSymbol.toLower().remove(
' ' ) );
454 return( __qFileInfo.exists() && __qFileInfo.isReadable() );
459 QFileInfo __qFileInfo( _rqsSymbol.toLower().remove(
' ' ) );
461 return QPixmap( __qFileInfo.absoluteFilePath() );
[UI] Chart control user-interface
[UI] Virtual "chart table" (view)
void updateChart()
Update the (current) chart content (on screen)
[UI] Device overlay container
void clear()
Clear the entire content of this overlay.
void slotWarning(const QString &_rqsMessage)
Slot to display a warning message.
bool fileCheck(QVCT::EFileOperation _eFileOperation, const QString &_rqsFilename, const QStringList *_pqsListExtensions=0)
Checks the validity of the given file name for the given file operation (open/save)
void slotExit()
Slot to exit this application.
void slotShowTimeView()
Slot to display the application's system time (dock widget)
bool deleteConfirm(const QString &_rqsName)
Displays a generic confirmation request before deleting content.
void slotTimerRefresh()
Slot to periodically refresh the user interface.
QPixmap symbolPixmap(const QString &_rqsSymbol)
Returns pixmap matching the given symbol (loaded from the application's symbol directory)
void slotAbout()
Slot to display this application's "About" details.
void slotToggleFullscreen()
Slot to toggle full-screen.
void errorMessage(const QString &_rqsMessage)
Display an error message.
void slotShowVesselCourse()
Slot to display the application's vessel course widget (dock widget)
void constructLayout()
Constructs the layout of the application.
void fileError(QVCT::EFileOperation _eFileOperation, const QString &_rqsFilename)
Displays a generic error message for an invalid file name and operation (open/save)
void slotShowVesselPosition()
Slot to display the application's vessel position widget (dock widget)
void slotShowVesselTarget()
Slot to display the application's vessel target widget (dock widget)
void warningMessage(const QString &_rqsMessage)
Display a warning message.
void slotShowVesselCockpit()
Slot to display the application's vessel cockpit view (window)
void slotShowOverlayListView()
Slot to display the application's overlay list (dock widget)
double fdTimeLastRedraw
Content last redraw time.
bool symbolExists(const QString &_rqsSymbol)
Returns whether the given symbol exists (in the application's symbol directory)
QString fileDialog(QVCT::EFileOperation _eFileOperation, const QString &_rqsTitle, const QString &_rqsFilter)
Displays a generic dialog to pick a file for the given operation (open/save)
void constructMenus()
Constructs the menus of the application.
void parseError(const QString &_rqsString)
Displays a generic error message for an invalid parsing operation.
void slotError(const QString &_rqsMessage)
Slot to display an error message.
void slotShowOverlayDetailView()
Slot to display the application's overlay detail (dock widget)
void slotShowSettings()
Slot to display the application's settings edit dialog.
[UI] Overlays detail view (dock widget)
[UI] Overlays list view (dock widget)
void forceRedraw()
Forces this overlay's rendering (not matter its cache content)
[UI] Application settings - main dialog
void setPathWorkingDirectory(const QString &_rqsPathWorkingDirectory)
[Path] Sets the current working directory
int getRateRefresh()
[Misc] Returns the content refresh rate, in milliseconds
[UI] Time view (dock widget)
void refreshContent()
Refreshes the content of the underlying widget.
virtual void refreshContent()
Refreshes the content of the underlying widget.
virtual void refreshContent()
Refreshes the content of the underlying widget.
[UI] General aviation cockpit view (dock widget)
virtual void refreshContent()=0
Refreshes the content of the underlying widget.
[UI] Vessel course view (dock widget)
virtual void refreshContent()
Refreshes the content of the underlying widget.
virtual void refreshContent()
Refreshes the content of the underlying widget.
[UI] Vessel position view (dock widget)
virtual void refreshContent()
Refreshes the content of the underlying widget.
[UI] Vessel target view (dock widget)
virtual void refreshContent()
Refreshes the content of the underlying widget.
static CVesselPosition * useVesselPosition()
static void registerVesselTarget(CVesselTarget *_poVesselTarget)
static CVesselOverlayListView * useVesselOverlayListView()
static COverlayDetailView * useOverlayDetailView()
static CVesselPointDetailView * useVesselPointDetailView()
static CVesselCockpit * useVesselCockpit()
static CVesselCourse * useVesselCourse()
static void registerOverlayDetailView(COverlayDetailView *_poOverlayDetailView)
static void registerVesselCourse(CVesselCourse *_poVesselCourse)
static CVesselOverlay * useVesselOverlay()
static QTimer * useTimerRefresh()
static CTrackOverlayListView * useTrackOverlayListView()
static CVesselTarget * useVesselTarget()
static CDeviceOverlay * useDeviceOverlay()
static void registerTimeView(CTimeView *_poTimeView)
static CTrackContainerDetailView * useTrackContainerDetailView()
static void registerVesselPosition(CVesselPosition *_poVesselPosition)
static QMutex * useMutexDataChange()
static CChartControl * useChartControl()
static void registerChartControl(CChartControl *_poChartControl)
static COverlayListView * useOverlayListView()
static void registerChartTable(CChartTable *_poChartTable)
static void registerOverlayListView(COverlayListView *_poOverlayListView)
static void registerVesselCockpit(CVesselCockpit *_poVesselCockpit)
static CChartTable * useChartTable()
static CRouteOverlayListView * useRouteOverlayListView()
static CTrackSubContainerDetailView * useTrackSubContainerDetailView()
static CSettings * useSettings()
static CLandmarkOverlayListView * useLandmarkOverlayListView()
static CTimeView * useTimeView()
double microtime()
Returns the system time with microseconds resolution, in seconds.