CFEL - ASG Software Suite  2.5.0
CASS
Public Slots | Public Member Functions | Protected Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
jocassview::JoCASSViewer Class Reference

the jocassview class More...

#include <jocassviewer.h>

+ Inheritance diagram for jocassview::JoCASSViewer:
+ Collaboration diagram for jocassview::JoCASSViewer:

Public Slots

void openFile (QString filename=QString(), QString key=QString())
 load data from a file More...
 
void startViewer ()
 start the viewer More...
 
void refreshDisplayableItemsList ()
 refresh the items on the displayable list More...
 
void setDisplayedItem (QString itemName, bool state, bool simulateClickedSignal=true)
 check an item in the list More...
 

Public Member Functions

 JoCASSViewer (QWidget *parent=0, Qt::WindowFlags flags=0)
 constructor More...
 
 ~JoCASSViewer ()
 destructor More...
 
- Public Member Functions inherited from QMainWindow
 TabShape
 
 ToolButtonStyle
 
 QMainWindow (QWidget *parent=0, Qt::WindowFlags flags=0)
 
 addDockWidget (Qt::DockWidgetArea area, QDockWidget *dockwidget)
 
 addDockWidget (Qt::DockWidgetArea area, QDockWidget *dockwidget, Qt::Orientation orientation)
 
 addToolBar (Qt::ToolBarArea area, QToolBar *toolbar)
 
 addToolBar (QToolBar *toolbar)
 
 addToolBar (const QString &title)
 
 addToolBarBreak (Qt::ToolBarArea area=Qt::TopToolBarArea)
 
 centralWidget ()
 
 contextMenuEvent (QContextMenuEvent *event)
 
 DockWidgetArea QMainWindow::corner(Qt::Corner corner)
 
 createPopupMenu ()
 
 DockWidgetArea QMainWindow::dockWidgetArea(QDockWidget *dockwidget)
 
 event (QEvent *event)
 
 iconSizeChanged (const QSize &iconSize)
 
 insertToolBar (QToolBar *before, QToolBar *toolbar)
 
 insertToolBarBreak (QToolBar *before)
 
 menuBar ()
 
 menuWidget ()
 
 removeDockWidget (QDockWidget *dockwidget)
 
 removeToolBar (QToolBar *toolbar)
 
 removeToolBarBreak (QToolBar *before)
 
 restoreDockWidget (QDockWidget *dockwidget)
 
 restoreState (const QByteArray &state, int version=0)
 
 saveState (int version=0)
 
 setCentralWidget (QWidget *widget)
 
 setCorner (Qt::Corner corner, Qt::DockWidgetArea area)
 
 setMenuBar (QMenuBar *menuBar)
 
 setMenuWidget (QWidget *menuBar)
 
 setStatusBar (QStatusBar *statusbar)
 
 setTabPosition (Qt::DockWidgetAreas areas, QTabWidget::TabPosition tabPosition)
 
 splitDockWidget (QDockWidget *first, QDockWidget *second, Qt::Orientation orientation)
 
 statusBar ()
 
 TabPosition QMainWindow::tabPosition(Qt::DockWidgetArea area)
 
 tabifiedDockWidgets (QDockWidget *dockwidget)
 
 tabifyDockWidget (QDockWidget *first, QDockWidget *second)
 
 ToolBarArea QMainWindow::toolBarArea(QToolBar *toolbar)
 
 toolBarBreak (QToolBar *toolbar)
 
 toolButtonStyleChanged (Qt::ToolButtonStyle toolButtonStyle)
 
 data ()
 
 iterator_category
 
 const_iterator ()
 
 const_iterator (const iterator &other)
 
 key ()
 
 value ()
 
 operator!= (const const_iterator &other)
 
 operator* ()
 
 operator+ (int j)
 
 operator++ ()
 
 operator++ (int)
 
 operator+= (int j)
 
 operator- (int j)
 
 operator-- ()
 
 operator-- (int)
 
 operator-= (int j)
 
 operator-& gt;()
 
 operator== (const const_iterator &other)
 
 data ()
 
 iterator_category
 
 iterator ()
 
 key ()
 
 value ()
 
 operator!= (const iterator &other)
 
 operator!= (const const_iterator &other)
 
 operator* ()
 
 operator+ (int j)
 
 operator++ ()
 
 operator++ (int)
 
 operator+= (int j)
 
 operator- (int j)
 
 operator-- ()
 
 operator-- (int)
 
 operator-= (int j)
 
 operator-& gt;()
 
 operator== (const iterator &other)
 
 operator== (const const_iterator &other)
 
 erase (const Key &key)
 
 insert (const Key &key, const T &value, bool overwrite)
 
 remove (iterator it)
 
 replace (const Key &key, const T &value)
 

Protected Member Functions

void moveEvent (QMoveEvent *event)
 receive move events to store the current position to the settings More...
 
void resizeEvent (QResizeEvent *event)
 receive resize events to store the current size to the settings More...
 

Private Slots

void autoSaveImages () const
 save the data displayed by all windows as png images More...
 
void autoSave (bool onlyPNG=false) const
 save the data displayed by all windows in the possible files More...
 
void saveFile (QString filename=QString(), QStringList keys=QStringList()) const
 save a data from specific viewer or all viewers to the given filename More...
 
void about ()
 display about this box More...
 
double interval () const
 retrieve the rate as interval in ms More...
 
double rate () const
 retrieve the user set rate in Hz More...
 
void changeAutoUpdate ()
 change the autoupdate based upon what the user set More...
 
void updateViewers ()
 update the contents within the viewers in the map More...
 
void changeViewers (QListWidgetItem *item)
 react on when an item in the list has been checked More...
 
void removeViewer (DataViewer *obj)
 remove the viewer from the container when it has been destroyed More...
 
QStringList displayableItems () const
 retrieve a list with all items More...
 
QStringList displayedItems () const
 retrieve a list with the selected items More...
 
void print ()
 react when print has been triggered More...
 
void on_source_changed (QString newSource)
 react on when the source has been changed More...
 
void changeServerAddress () const
 retrieve the server address More...
 
void broadcastDarkcalCommand () const
 broadcast the darkcal command More...
 
void broadcastGaincalCommand () const
 broadcast the gaincal command More...
 
void sendCustomCommand () const
 send a custom command More...
 
void clearHistogram () const
 send clear histograms More...
 

Private Member Functions

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 More...
 

Private Attributes

StatusLED_statusLED
 the status LED More...
 
QLineEdit_servername
 the servername input widget More...
 
QSpinBox_serverport
 the server port input widget More...
 
QDoubleSpinBox_rate
 the rate input More...
 
QAction_autoUpdate
 the auto update input More...
 
QToolBar_serverToolBar
 the toolbar with the server options More...
 
QMap< QString, DataViewer * > _viewers
 the container for all opened viewers More...
 
QTimer _updateTimer
 timer for the auto update function it is used as singleshot timer More...
 
bool _updateInProgress
 flag to tell whether an update is in progess More...
 

Detailed Description

the jocassview class

Author
Lutz Foucar

Definition at line 41 of file jocassviewer.h.

Constructor & Destructor Documentation

JoCASSViewer::JoCASSViewer ( QWidget parent = 0,
Qt::WindowFlags  flags = 0 
)
JoCASSViewer::~JoCASSViewer ( )

destructor

Definition at line 206 of file jocassviewer.cpp.

Member Function Documentation

void JoCASSViewer::about ( )
privateslot

display about this box

Definition at line 351 of file jocassviewer.cpp.

References QMessageBox::about().

Referenced by JoCASSViewer().

void JoCASSViewer::autoSave ( bool  onlyPNG = false) const
privateslot

save the data displayed by all windows in the possible files

generate the correct filenames and call saveFile() to save the data.

See also
saveFile();
Parameters
onlyPNGflag that allows to only save png files fo the open viewer

generate the general automatic filename

save all open windows data to a single container file, if not only png

save the individual viewers to their specific savable file types (exclude the container files type

if only png files should be saved, check if view can be saved as png remove all other options from the file list

Definition at line 243 of file jocassviewer.cpp.

References _viewers, QDateTime::currentDateTime(), QDir::currentPath(), displayedItems(), QStringList::filter(), jocassview::FileHandler::isContainerFile(), saveFile(), and cass::toString().

Referenced by autoSaveImages(), and JoCASSViewer().

void JoCASSViewer::autoSaveImages ( ) const
privateslot

save the data displayed by all windows as png images

call autoSave with parameter onlyPNG as true

See also
autoSave();

Definition at line 238 of file jocassviewer.cpp.

References autoSave().

Referenced by JoCASSViewer().

void JoCASSViewer::broadcastDarkcalCommand ( ) const
privateslot

broadcast the darkcal command

Definition at line 645 of file jocassviewer.cpp.

References jocassview::DataSourceManager::source().

Referenced by JoCASSViewer().

void JoCASSViewer::broadcastGaincalCommand ( ) const
privateslot

broadcast the gaincal command

Definition at line 652 of file jocassviewer.cpp.

References jocassview::DataSourceManager::source().

Referenced by JoCASSViewer().

void JoCASSViewer::changeAutoUpdate ( )
privateslot

change the autoupdate based upon what the user set

change the interval. If the autoupdate button is checked, start the timer. Otherwise just stop the timer.

Definition at line 367 of file jocassviewer.cpp.

References _autoUpdate, _updateTimer, interval(), rate(), QSettings::setValue(), QTimer::start(), and QTimer::stop().

Referenced by JoCASSViewer(), startViewer(), and updateViewers().

void JoCASSViewer::changeServerAddress ( ) const
privateslot

retrieve the server address

assemble the server string and port to a server address, save them in the ini file and return and emit serverChanged signal

Definition at line 632 of file jocassviewer.cpp.

References _servername, _serverport, QString::number(), QSettings::setValue(), and jocassview::DataSourceManager::source().

Referenced by JoCASSViewer().

void JoCASSViewer::changeViewers ( QListWidgetItem item)
privateslot

react on when an item in the list has been checked

Parameters
itemthe item that has changed and by which the viewers will change

if the container already has a viewer with the requested name, exit here

create an entry in the viewers container with a 0 pointer and initialize the viewer based upon the type of data using update_viewers();

if the key is on the list of viewers and the viewer has been created close it (which will delete the window, because all dataviewer windows have the delete on close flag set)

Definition at line 518 of file jocassviewer.cpp.

References _viewers, QListWidgetItem::isSelected(), QListWidgetItem::text(), and updateViewers().

Referenced by JoCASSViewer(), and setDisplayedItem().

void JoCASSViewer::clearHistogram ( ) const
privateslot

send clear histograms

ask the user which processors histograms should be cleared and tell the server to clear the requested histogram

Definition at line 679 of file jocassviewer.cpp.

References displayableItems(), QInputDialog::getItem(), QMainWindow::key(), jocassview::DataSourceManager::source(), and QObject::tr().

Referenced by JoCASSViewer().

void JoCASSViewer::createViewerForType ( QMap< QString, DataViewer * >::iterator  view,
cass::Result< float >::shared_pointer  result 
)
private

convenience function to create a viewer thats appropriate for a given type of data

Parameters
viewiterator to the item in the viewer list where the viewer needs to be created.
histpointer to the histogram that hold the data

Definition at line 695 of file jocassviewer.cpp.

References cass::Result< T >::dim(), QMap::key(), removeViewer(), and QMap::value().

Referenced by updateViewers().

QStringList JoCASSViewer::displayableItems ( ) const
privateslot

retrieve a list with all items

Returns
list with all items

Definition at line 583 of file jocassviewer.cpp.

References QMainWindow::centralWidget(), and QListWidget::item().

Referenced by clearHistogram(), openFile(), and sendCustomCommand().

QStringList JoCASSViewer::displayedItems ( ) const
privateslot

retrieve a list with the selected items

Returns
list with all selected items

Definition at line 592 of file jocassviewer.cpp.

References QMainWindow::centralWidget(), and QListWidget::selectedItems().

Referenced by autoSave(), print(), refreshDisplayableItemsList(), saveFile(), and updateViewers().

double JoCASSViewer::interval ( ) const
privateslot

retrieve the rate as interval in ms

convert the rate in hz to an interval in ms (1000/rate()) and return it.

Returns
the interval in ms

Definition at line 357 of file jocassviewer.cpp.

References rate().

Referenced by changeAutoUpdate().

void JoCASSViewer::moveEvent ( QMoveEvent event)
protected

receive move events to store the current position to the settings

Parameters
eventthe move event

Definition at line 717 of file jocassviewer.cpp.

References QSettings::setValue().

void JoCASSViewer::on_source_changed ( QString  newSource)
privateslot

react on when the source has been changed

hide the server toolbar when the source is not the server, show it otherwise Then refresh the list by calling refreshDisplayableItemsList()

Parameters
newSourcethe name of source that has been activated

Definition at line 622 of file jocassviewer.cpp.

References _serverToolBar, and refreshDisplayableItemsList().

Referenced by JoCASSViewer().

void JoCASSViewer::openFile ( QString  filename = QString(),
QString  key = QString() 
)
slot

load data from a file

Parameters
filenamethe file to load the data from
keythe key of the datafield in case its an h5 file

if no filename is given ask for a file

if the file doesn't exist exit here

add a source with the requested file and set the window title to the filename

in case the key is on the list of displayable items, display it

Definition at line 211 of file jocassviewer.cpp.

References jocassview::DataSourceManager::addSource(), QDir::currentPath(), displayableItems(), QFileInfo::exists(), QFileDialog::getOpenFileName(), QString::isEmpty(), and setDisplayedItem().

Referenced by JoCASSViewer(), and main().

void JoCASSViewer::print ( )
privateslot

react when print has been triggered

ask the user which window should be printed, and then call print for the requested window.

Definition at line 602 of file jocassviewer.cpp.

References _viewers, displayedItems(), QApplication::focusWidget(), QInputDialog::getItem(), QStringList::indexOf(), and QObject::tr().

Referenced by JoCASSViewer().

double JoCASSViewer::rate ( ) const
privateslot

retrieve the user set rate in Hz

Returns
the rate in Hz

Definition at line 362 of file jocassviewer.cpp.

References _rate.

Referenced by changeAutoUpdate(), and interval().

void JoCASSViewer::refreshDisplayableItemsList ( )
slot

refresh the items on the displayable list

retrieve the list of possible displayable items from the current source and set them in the list.

Definition at line 556 of file jocassviewer.cpp.

References QListWidget::addItems(), QMainWindow::centralWidget(), QListWidget::clear(), displayedItems(), jocassview::DataSource::resultNames(), setDisplayedItem(), QListWidget::sortItems(), and jocassview::DataSourceManager::source().

Referenced by JoCASSViewer(), main(), and on_source_changed().

void JoCASSViewer::removeViewer ( DataViewer obj)
privateslot

remove the viewer from the container when it has been destroyed

Parameters
objThe viewer object that has been destroyed

retrieve the window title from the dataviewer that is beeing destroyed (because its the key in the list of viewers) and remove the key from the list. Then set the entry in the list as not highlighted.

Definition at line 545 of file jocassviewer.cpp.

References _viewers, QMainWindow::key(), and setDisplayedItem().

Referenced by createViewerForType().

void JoCASSViewer::resizeEvent ( QResizeEvent event)
protected

receive resize events to store the current size to the settings

Parameters
eventthe resize event

Definition at line 729 of file jocassviewer.cpp.

References QSettings::setValue(), and QResizeEvent::size().

void JoCASSViewer::saveFile ( QString  filename = QString(),
QStringList  keys = QStringList() 
) const
privateslot

save a data from specific viewer or all viewers to the given filename

Parameters
filenameThe name of the file
keysThe list of keys of the window whos contens should be written

if not filename was given ask for one

if no keys are given, request at least one using the iteminput dialog The preselected item in the dialog should be the currently highlighted window or, in case of a container file, "all"

if the file is a container file, create the container first before adding data to it.

go through the list and tell the viewer to save the data Append the name of the viewer to the filaname in case this is not a container file and more that one file should be saved with data so that the files are not overwritten.

Definition at line 283 of file jocassviewer.cpp.

References _viewers, QString::contains(), jocassview::FileHandler::createContainer(), QDir::currentPath(), displayedItems(), QApplication::focusWidget(), QInputDialog::getItem(), QFileDialog::getSaveFileName(), QStringList::indexOf(), QString::insert(), jocassview::FileHandler::isContainerFile(), QString::isEmpty(), QString::lastIndexOf(), and QObject::tr().

Referenced by autoSave(), and JoCASSViewer().

void JoCASSViewer::sendCustomCommand ( ) const
privateslot

send a custom command

ask to whom the command should be sent to and for the command to send and tell the server to send the command.

Definition at line 659 of file jocassviewer.cpp.

References displayableItems(), QInputDialog::getItem(), QInputDialog::getText(), QMainWindow::key(), jocassview::DataSourceManager::source(), and QObject::tr().

Referenced by JoCASSViewer().

void JoCASSViewer::setDisplayedItem ( QString  itemName,
bool  state,
bool  simulateClickedSignal = true 
)
slot

check an item in the list

find the listwidget item by the itemname. In case there is no or more than one item with the requested name return without doing anything. Otherwise change the checked state of the item to the requested state and call the slot on_listitem_clicked() to ensure that it is the same behavious as if the user clicked the item in the gui.

Parameters
itemNamethe name of the item
statethe state of the item
simulateClickedSignalif set to true emit the clicked signal

Definition at line 571 of file jocassviewer.cpp.

References QMainWindow::centralWidget(), changeViewers(), QListWidget::findItems(), and QListWidgetItem::setSelected().

Referenced by main(), openFile(), refreshDisplayableItemsList(), removeViewer(), and updateViewers().

void JoCASSViewer::startViewer ( )
slot

start the viewer

uses on_autoupdate_changed() to initalize the autoupdate parameters.

Definition at line 346 of file jocassviewer.cpp.

References changeAutoUpdate().

Referenced by main().

void JoCASSViewer::updateViewers ( )
privateslot

update the contents within the viewers in the map

if another process is still updating return here

Note
this can happen, because while retrieving data from the server all pending processes on the eventloop will be processed. One of them could be the user trying to retrieve data another time (while another retrieval process is still ongoing, thus resulting this function will be reentered, even though it is still working.

get an iterator to go through the map and retrieve the first item where we get the id from. Then check whether all the other histograms should have the same id (if not then set the id to 0). Remember how big the container is for validating whether nothing has changed while the data was retrieved from the source.

check if current source is available, if remove the viewer from the list and quit updating

if the viewer hasn't been initalized, initialize it with new result from the current active source.

validate container consistency

validate result. If the viewer can't be initialzed, remove it from the list

Set the result to the data of the viewer and let the data now what source type it has been filled with

validate data

otherwise retrieve all the data containers from a viewer and update them with the latest data

validate source

validate result to update

validate container consistency

tell the viewer the data has changed

set the report to sucess or failure

remember which viewers are active

restart the updatetimer when requested and reset the in progress flag

Definition at line 380 of file jocassviewer.cpp.

References _statusLED, _updateInProgress, _viewers, jocassview::StatusLED::busy, changeAutoUpdate(), createViewerForType(), jocassview::DataSourceManager::currentSourceName(), QMainWindow::data(), displayedItems(), jocassview::StatusLED::fail, QString::fromStdString(), QMainWindow::key(), jocassview::StatusLED::ok, jocassview::DataSource::result(), setDisplayedItem(), jocassview::StatusLED::setStatus(), QSettings::setValue(), and jocassview::DataSourceManager::source().

Referenced by changeViewers(), and JoCASSViewer().

Member Data Documentation

QAction* jocassview::JoCASSViewer::_autoUpdate
private

the auto update input

Definition at line 258 of file jocassviewer.h.

Referenced by changeAutoUpdate(), and JoCASSViewer().

QDoubleSpinBox* jocassview::JoCASSViewer::_rate
private

the rate input

Definition at line 255 of file jocassviewer.h.

Referenced by JoCASSViewer(), and rate().

QLineEdit* jocassview::JoCASSViewer::_servername
private

the servername input widget

Definition at line 249 of file jocassviewer.h.

Referenced by changeServerAddress(), and JoCASSViewer().

QSpinBox* jocassview::JoCASSViewer::_serverport
private

the server port input widget

Definition at line 252 of file jocassviewer.h.

Referenced by changeServerAddress(), and JoCASSViewer().

QToolBar* jocassview::JoCASSViewer::_serverToolBar
private

the toolbar with the server options

Definition at line 261 of file jocassviewer.h.

Referenced by JoCASSViewer(), and on_source_changed().

StatusLED* jocassview::JoCASSViewer::_statusLED
private

the status LED

Definition at line 246 of file jocassviewer.h.

Referenced by JoCASSViewer(), and updateViewers().

bool jocassview::JoCASSViewer::_updateInProgress
private

flag to tell whether an update is in progess

Definition at line 270 of file jocassviewer.h.

Referenced by updateViewers().

QTimer jocassview::JoCASSViewer::_updateTimer
private

timer for the auto update function it is used as singleshot timer

Definition at line 267 of file jocassviewer.h.

Referenced by changeAutoUpdate(), and JoCASSViewer().

QMap<QString,DataViewer*> jocassview::JoCASSViewer::_viewers
private

the container for all opened viewers

Definition at line 264 of file jocassviewer.h.

Referenced by autoSave(), changeViewers(), print(), removeViewer(), saveFile(), and updateViewers().


The documentation for this class was generated from the following files: