9 #include <QtCore/QFileInfo>
10 #include <QtCore/QDebug>
11 #include <QtCore/QSettings>
12 #include <QtCore/QDir>
13 #include <QtCore/QDateTime>
15 #if QT_VERSION >= 0x050000
16 #include <QtWidgets/QMessageBox>
17 #include <QtWidgets/QInputDialog>
18 #include <QtWidgets/QMenuBar>
19 #include <QtWidgets/QMenu>
20 #include <QtWidgets/QToolBar>
21 #include <QtWidgets/QLineEdit>
22 #include <QtWidgets/QSpinBox>
23 #include <QtWidgets/QDoubleSpinBox>
24 #include <QtWidgets/QLabel>
25 #include <QtWidgets/QStatusBar>
26 #include <QtWidgets/QListWidget>
27 #include <QtWidgets/QFileDialog>
28 #include <QtWidgets/QApplication>
30 #include <QtGui/QMessageBox>
31 #include <QtGui/QInputDialog>
32 #include <QtGui/QMenuBar>
33 #include <QtGui/QMenu>
34 #include <QtGui/QToolBar>
35 #include <QtGui/QLineEdit>
36 #include <QtGui/QSpinBox>
37 #include <QtGui/QDoubleSpinBox>
38 #include <QtGui/QLabel>
39 #include <QtGui/QStatusBar>
40 #include <QtGui/QListWidget>
41 #include <QtGui/QFileDialog>
42 #include <QtGui/QApplication>
44 #include <QtGui/QMoveEvent>
45 #include <QtGui/QResizeEvent>
67 _updateInProgress(false)
85 SLOT(
saveFile()),
QKeySequence(QKeySequence::SaveAs))->setShortcutContext(Qt::ApplicationShortcut);
87 SLOT(
print()),
QKeySequence(QKeySequence::Print))->setShortcutContext(Qt::ApplicationShortcut);
90 SLOT(closeAllWindows()),
QKeySequence(
"Ctrl+q"))->setShortcutContext(Qt::ApplicationShortcut);
98 cmenu->
addAction(tr(
"Clear Histogram"),
this,
100 cmenu->
addAction(tr(
"Send custom Command"),
this,
102 cmenu->
addAction(tr(
"Broadcast darkcal command"),
this,
104 cmenu->
addAction(tr(
"Broadcast gaincal command"),
this,
107 cmenu->
addAction(tr(
"Reload ini File"),client,
108 SLOT(reloadIni()),
QKeySequence(tr(
"Ctrl+r")))->setShortcutContext(Qt::ApplicationShortcut);
109 cmenu->
addAction(tr(
"Quit Server"),client,SLOT(quitServer()));
116 hmenu->addAction(tr(
"About"),
this,SLOT(
about()));
117 hmenu->addAction(tr(
"About Qt"),qApp,SLOT(aboutQt()));
125 _servername->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
126 _servername->setToolTip(tr(
"Name of the server to connect to."));
134 _serverport->setToolTip(tr(
"Port of the server to connect to."));
140 spacer1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
148 spacer2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
155 _autoUpdate->setToolTip(tr(
"If checked, continuously retrieve and display images."));
162 _statusLED->setToolTip(
"Status indicator (green = Data retrieved ok, red = communciation Problems, yellow = busy).");
169 _rate->setValue(settings.
value(
"Rate", 10.).toDouble());
170 _rate->setToolTip(tr(
"Image update frequency."));
171 connect(
_rate,SIGNAL(valueChanged(
double)),
175 punit->setText(
"Hz");
179 statusBar()->setToolTip(tr(
"Actual frequency to get and display "
180 "images averaged over (n) times."));
184 listview->setSelectionMode(QAbstractItemView::MultiSelection);
200 resize(settings.
value(
"MainWindowSize",
size()).toSize());
201 move(settings.
value(
"MainWindowPosition",pos()).toPoint());
216 QString filter(
"Data Files (*.csv *.hst *.h5 *.hdf5 *.cbf)");
231 setWindowTitle(
QFileInfo(filename).baseName());
265 QStringList filetypes(view.value()->dataFileSuffixes());
270 filetypes = filetypes.
filter(
"png",Qt::CaseInsensitive);
271 QStringList::const_iterator cIt;
272 for (cIt = filetypes.constBegin(); cIt != filetypes.constEnd(); ++cIt)
274 QString fname(fileNameBase + view.key() +
"." + *cIt);
291 QString filter(
"Data Files (*.png *.csv *.hst *.h5 *.hdf5 *.cbf)");
305 items.prepend(
"**ALL**");
307 int preselectItemId(items.
indexOf(
"**ALL**"));
309 preselectItemId = items.
indexOf(focusWiget->windowTitle());
313 preselectItemId,
false, &ok));
333 QStringList::const_iterator cIt;
334 for (cIt = keys.constBegin(); cIt != keys.constEnd(); ++cIt)
341 _viewers.value(*cIt)->saveData(fname);
354 tr(
"<p>The <b>JoCASSviewer</b> is a display client for the CASS software.</p>"));
359 return (1000./
rate());
364 return _rate->value();
409 const quint64 eventID(0);
410 const int nbrWindows(
_viewers.size());
452 if (!view.value()->data().isEmpty())
455 view.value()->data().front()->setResult(result);
457 view.value()->data().front()->setSourceName(sourceName);
467 const int nbrData(
data.size());
469 while (dataIt !=
data.end())
472 QString sourceName((*dataIt)->sourceName());
480 if (!(*dataIt)->result())
489 if(
_viewers.size() != nbrWindows ||
data.size() != nbrData)
494 (*dataIt)->setResult(result);
501 view.value()->dataChanged();
567 for (
int i=0; i < selectedItems.size(); ++i)
575 if (listwidgetitems.empty() || listwidgetitems.size() > 1)
579 if(simulateClickedSignal)
587 for (
int i=0; i < listwidget->count(); ++i)
588 items.append(listwidget->
item(i)->text());
597 for (
int i=0; i < selected.size(); ++i)
598 items.append(selected[i]->text());
608 preselectItem=focusWiget->windowTitle();
612 items.
indexOf(preselectItem),
false, &ok));
627 QString sourceDisplayName(newSource ==
"Server" ?
628 newSource :
QFileInfo(newSource).baseName());
629 setWindowTitle(sourceDisplayName);
637 settings.
setValue(
"Servername",servername);
638 settings.
setValue(
"Serverport",serverport);
639 QString serveraddress(servername +
":" + serverport);
642 dynamic_cast<TCPClient*
>(source)->setServer(serveraddress);
649 dynamic_cast<TCPClient*
>(source)->broadcastCommand(
"startDarkcal");
656 dynamic_cast<TCPClient*
>(source)->broadcastCommand(
"startGaincal");
673 QLineEdit::Normal,tr(
"Type command here"),&ok);
676 dynamic_cast<TCPClient*
>(source)->sendCommandTo(key,command);
699 switch (result->
dim())
711 view.
value()->show();
719 QMainWindow::moveEvent(event);
721 settings.
setValue(
"MainWindowPosition",frameGeometry().topLeft());
void autoSaveImages() const
save the data displayed by all windows as png images
contains the jocassviewer class
void clearHistogram() const
send clear histograms
size_t dim() const
what is the dimension of the result
void autoSave(bool onlyPNG=false) const
save the data displayed by all windows in the possible files
addToolBar(Qt::ToolBarArea area, QToolBar *toolbar)
void startViewer()
start the viewer
QStringList displayableItems() const
retrieve a list with all items
void on_source_changed(QString newSource)
react on when the source has been changed
a LED that should display the status
QSpinBox * _serverport
the server port input widget
QToolBar * _serverToolBar
the toolbar with the server options
void print()
react when print has been triggered
static void addSource(const QString &sourcename, DataSource *source, bool setActive=true)
add a data source
about(QWidget *parent, const QString &title, const QString &text)
std::tr1::shared_ptr< self_type > shared_pointer
a shared pointer of this class
contains the base class data sources
read and write data to files
contains the base class for add viewer data
contains singleton class to manage the data sources
file contains the classes connect to cass
QTimer _updateTimer
timer for the auto update function it is used as singleshot timer
StatusLED * _statusLED
the status LED
setRange(double minimum, double maximum)
things written only at end of run H5Dump ProcessorSummary size
QMap< QString, DataViewer * > _viewers
the container for all opened viewers
QLineEdit * _servername
the servername input widget
tr(const char *sourceText, const char *disambiguation=0, int n=-1)
contains the viewer for 1d data
a viewer that displays 1d data
setRange(int minimum, int maximum)
setValue(const QString &key, const QVariant &value)
void changeAutoUpdate()
change the autoupdate based upon what the user set
number(long n, int base=10)
QAction * _autoUpdate
the auto update input
void removeViewer(DataViewer *obj)
remove the viewer from the container when it has been destroyed
fromStdString(const std::string &str)
base class for data sources
static bool isContainerFile(const QString &filename)
return whether the file is a container file
QDoubleSpinBox * _rate
the rate input
a viewer that displays 0d data
contains the status led class
virtual result_t::shared_pointer result(const QString &key, quint64 id=0)=0
retrieve a result from the source
void setStatus(int status)
set the status
void sendCustomCommand() const
send a custom command
void openFile(QString filename=QString(), QString key=QString())
load data from a file
void setDisplayedItem(QString itemName, bool state, bool simulateClickedSignal=true)
check an item in the list
setCentralWidget(QWidget *widget)
void refreshDisplayableItemsList()
refresh the items on the displayable list
getText(QWidget *parent, const QString &title, const QString &label, QLineEdit::EchoMode mode=QLineEdit::Normal, const QString &text=QString()
contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive)
std::string toString(const Type &t)
convert any type to a string
static DataSource * source(const QString &sourcename=QString())
retrieve an available source
JoCASSViewer(QWidget *parent=0, Qt::WindowFlags flags=0)
constructor
QStringList displayedItems() const
retrieve a list with the selected items
static DataSourceManager * instance()
generate an instance of this, if not already existent
void saveFile(QString filename=QString(), QStringList keys=QStringList()) const
save a data from specific viewer or all viewers to the given filename
void changeServerAddress() const
retrieve the server address
value(const QString &key, const QVariant &defaultValue=QVariant()
void resizeEvent(QResizeEvent *event)
receive resize events to store the current size to the settings
contains the viewer for 0d data
double interval() const
retrieve the rate as interval in ms
void about()
display about this box
void changeViewers(QListWidgetItem *item)
react on when an item in the list has been checked
bool _updateInProgress
flag to tell whether an update is in progess
a viewer that displays 2d data
getSaveFileName(QWidget *parent=0, const QString &caption=QString()
the tcp client that connects to the cass server
double rate() const
retrieve the user set rate in Hz
indexOf(const QRegExp &rx, int from=0)
fromTheme(const QString &name, const QIcon &fallback=QIcon()
void broadcastGaincalCommand() const
broadcast the gaincal command
void broadcastDarkcalCommand() const
broadcast the darkcal command
getOpenFileName(QWidget *parent=0, const QString &caption=QString()
void createViewerForType(QMap< QString, DataViewer * >::iterator view, cass::Result< float >::shared_pointer result)
convenience function to create a viewer thats appropriate for a given type of data ...
filter(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive)
static void setMenu(QMenu *menu)
set the Menu where the data sources will be displayed in
insert(int position, const QString &str)
static QString currentSourceName()
return the current source name
void updateViewers()
update the contents within the viewers in the map
void moveEvent(QMoveEvent *event)
receive move events to store the current position to the settings
~JoCASSViewer()
destructor
static void createContainer(const QString &filename)
create the container file
contains the viewer for 2d data
lastIndexOf(const QString &str, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive)
virtual QStringList resultNames()=0
retrieve the list items that can be displayed