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

a viewer that displays 1d data More...

#include <one_d_viewer.h>

+ Inheritance diagram for jocassview::OneDViewer:
+ Collaboration diagram for jocassview::OneDViewer:

Public Member Functions

 OneDViewer (QString title, QWidget *parent=0)
 constructor More...
 
virtual ~OneDViewer ()
 destructor More...
 
virtual QList< Data * > data ()
 retrieve the displayed data More...
 
virtual QString type () const
 retrieve the type of the data viewer More...
 
virtual void saveData (const QString &filename)
 save the data to file More...
 
virtual void dataChanged ()
 update the plot More...
 
virtual QStringList dataFileSuffixes () const
 suffixes for the data of this viewer More...
 
- Public Member Functions inherited from jocassview::DataViewer
 DataViewer (QString title, QWidget *parent)
 constructor More...
 
virtual ~DataViewer ()
 destructor More...
 
virtual void print () const
 print the plot 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)
 

Private Slots

void replot ()
 redraw the plot More...
 
void on_legend_right_clicked (QPoint pos)
 react when an legend item has been selected More...
 
void on_legend_checked (const QVariant &item, bool on)
 react when an legend item has been clicked More...
 
void change_curve_color (PlotCurve *curve=0)
 change the curves color More...
 
void change_curve_width (PlotCurve *curve=0)
 change the curves line width More...
 
void remove_curve (PlotCurve *curve=0)
 remove the curve from the plot More...
 
void on_add_graph_triggered ()
 react when addGraph action has been triggered More...
 
void on_grid_triggered ()
 react on when the gridControl has been triggered More...
 

Private Attributes

MinMaxControl_xControl
 control for the x-axis More...
 
MinMaxControl_yControl
 control for the y-axis More...
 
QList< PlotCurve * > _curves
 this plots curves More...
 
QList< OneDViewerData * > _curvesData
 this plots curves More...
 
QAction_gridControl
 an action to control the grid in the plot More...
 
QwtPlotGrid * _grid
 a grid in the plot More...
 
quint8 _gridLines
 flags to tell which grid lines should be drawn More...
 
QAction_legendControl
 an action to control the legend of curves More...
 
QwtLegend * _legend
 a legend for the different curves More...
 
QAction_axisTitleControl
 an action to control the legend of curves More...
 

Additional Inherited Members

- Signals inherited from jocassview::DataViewer
void viewerClosed (DataViewer *viewer)
 signal emitted when viewer is about to be destroyed More...
 
- Protected Member Functions inherited from jocassview::DataViewer
void closeEvent (QCloseEvent *event)
 react when a close event is send to this viewer More...
 
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...
 
- Protected Attributes inherited from jocassview::DataViewer
QwtPlot * _plot
 the plot inside which the data will be displayed More...
 

Detailed Description

a viewer that displays 1d data

Author
Stephan Kassemeyer
Lutz Foucar

Definition at line 37 of file one_d_viewer.h.

Constructor & Destructor Documentation

OneDViewer::OneDViewer ( QString  title,
QWidget parent = 0 
)
OneDViewer::~OneDViewer ( )
virtual

destructor

Definition at line 153 of file one_d_viewer.cpp.

Member Function Documentation

void OneDViewer::change_curve_color ( PlotCurve curve = 0)
privateslot

change the curves color

if no parameter is given try to retrieve the curve from the sender signal that is connected to this slot. We're assuming this is an QAction whos parent is the curve.

Parameters
curvethe curve to change is the senders parent widget

Definition at line 334 of file one_d_viewer.cpp.

References _legend, jocassview::DataViewer::_plot, QColorDialog::getColor(), and replot().

Referenced by on_legend_right_clicked().

void OneDViewer::change_curve_width ( PlotCurve curve = 0)
privateslot

change the curves line width

if no parameter is given try to retrieve the curve from the sender signal that is connected to this slot. We're assuming this is an QAction whos parent is the curve.

Parameters
curvethe curve to change is the senders parent widget

Definition at line 354 of file one_d_viewer.cpp.

References _legend, jocassview::DataViewer::_plot, QInputDialog::getInt(), replot(), and cass::ACQIRIS::width.

Referenced by on_legend_right_clicked().

QList< Data * > OneDViewer::data ( )
virtual

retrieve the displayed data

Returns
pointer to the viewed data

Implements jocassview::DataViewer.

Definition at line 158 of file one_d_viewer.cpp.

References jocassview::DataViewer::_plot, and QList::append().

Referenced by on_add_graph_triggered(), OneDViewer(), replot(), and saveData().

void OneDViewer::dataChanged ( )
virtual

update the plot

Reimplemented from jocassview::DataViewer.

Definition at line 206 of file one_d_viewer.cpp.

References replot().

QStringList OneDViewer::dataFileSuffixes ( ) const
virtual

suffixes for the data of this viewer

Returns
suffixes for the data of this viewer

Implements jocassview::DataViewer.

Definition at line 211 of file one_d_viewer.cpp.

void OneDViewer::on_add_graph_triggered ( )
privateslot

react when addGraph action has been triggered

use the openfile dialog to get the graph. Then use the FileHandler to retrieve the data form the file.

ask the user from which source the added graph should come

if the source should be a new one, ask the user for the filename of the new source and add it to the list of sources

retrieve the list of items that are available from the source, if more than 1 ask the user which should be added

retrieve the result from the source and check if it is a 1d result

create a new data container and add the result to it

add a new curve to the plot and intialize it with the data and a random color then set up the legenditem and its context menu for the curve

and replot the plot

Definition at line 392 of file one_d_viewer.cpp.

References _curves, _legend, jocassview::DataViewer::_plot, jocassview::DataSourceManager::addSource(), QMessageBox::critical(), QDir::currentPath(), jocassview::DataSourceManager::currentSourceName(), data(), QColor::fromHsv(), QInputDialog::getItem(), QFileDialog::getOpenFileName(), QStringList::indexOf(), QString::isEmpty(), on_legend_right_clicked(), replot(), jocassview::DataSource::result(), jocassview::DataSource::resultNames(), jocassview::OneDViewerData::setResult(), jocassview::Data::setSourceName(), QPen::setWidth(), jocassview::DataSourceManager::source(), jocassview::DataSourceManager::sourceNames(), and QObject::tr().

Referenced by OneDViewer().

void OneDViewer::on_grid_triggered ( )
privateslot

react on when the gridControl has been triggered

increase the the _gridLines variable and mask off the unneeded bits

Definition at line 464 of file one_d_viewer.cpp.

References _gridLines, and replot().

Referenced by OneDViewer().

void OneDViewer::on_legend_checked ( const QVariant item,
bool  on 
)
privateslot

react when an legend item has been clicked

toggle hide / show the curve

Parameters
itemthe plot item assiciated with the legend entry
onwhen true the associated curve will be shown

Definition at line 327 of file one_d_viewer.cpp.

References jocassview::DataViewer::_plot, and replot().

Referenced by OneDViewer().

void OneDViewer::on_legend_right_clicked ( QPoint  pos)
privateslot

react when an legend item has been selected

open a context menue at the position of the legenditem.

Parameters
posthe position where the context menu should be opened

check if the sender of the signal is of widget type (is the legend item)

retrieve the legenditem widget and the corresponding curve, determine the position where the right click happen to be able to open the menu at this position

create the context menu and execute it (block in this function until a choice has been made).

In case this is the main curve (name is the name of the main curve), don't add the option to delete the curve. Otherwise create and connect their triggered signals to the appropriate private slots that will react on the choice.

Definition at line 290 of file one_d_viewer.cpp.

References _legend, jocassview::DataViewer::_plot, change_curve_color(), change_curve_width(), QWidget::mapToGlobal(), and remove_curve().

Referenced by on_add_graph_triggered(), and OneDViewer().

void OneDViewer::remove_curve ( PlotCurve curve = 0)
privateslot

remove the curve from the plot

if no parameter is given try to retrieve the curve from the sender signal that is connected to this slot. We're assuming this is an QAction whos parent is the curve.

Parameters
curvethe curve to remove from the plot

Definition at line 375 of file one_d_viewer.cpp.

References _curves, _legend, jocassview::DataViewer::_plot, and replot().

Referenced by on_legend_right_clicked().

void OneDViewer::replot ( )
privateslot

redraw the plot

check if grid should be enabled

hide /show the legend (this is a hack, since legends can't be directly hidden) retrieve all curve plots from the plot and get theier corresponding legend widget. This needs to be hidden and then the legend to be updated

set the scales to be log or linear

check if autoscale, and set the axis limits

display the axis titles

update the layout and replot the plot

save the states of the controls

Definition at line 218 of file one_d_viewer.cpp.

References _axisTitleControl, _curves, _grid, _gridLines, _legend, _legendControl, jocassview::DataViewer::_plot, _xControl, _yControl, jocassview::MinMaxControl::autoscale(), QSettings::beginGroup(), data(), QSettings::endGroup(), QString::fromStdString(), front, jocassview::MinMaxControl::log(), jocassview::MinMaxControl::max(), jocassview::MinMaxControl::min(), QSettings::setValue(), jocassview::OneDViewerData::setXRangeForLog(), jocassview::OneDViewerData::setYRangeForLog(), cass::ACQIRIS::width, and cass::Result< float >::xAxis.

Referenced by change_curve_color(), change_curve_width(), dataChanged(), on_add_graph_triggered(), on_grid_triggered(), on_legend_checked(), OneDViewer(), and remove_curve().

void OneDViewer::saveData ( const QString filename)
virtual

save the data to file

Parameters
filenamethe filename to save the data to

when the filename indicates that it should be saved as png, do so

otherwise store the data individually as data files

Implements jocassview::DataViewer.

Definition at line 175 of file one_d_viewer.cpp.

References QList::begin(), data(), QList::end(), QFileInfo::exists(), QString::fromStdString(), QString::insert(), jocassview::FileHandler::isContainerFile(), QString::lastIndexOf(), QPixmap::save(), jocassview::FileHandler::saveData(), QFileInfo::suffix(), and QString::toUpper().

QString OneDViewer::type ( ) const
virtual

retrieve the type of the data viewer

Returns
the type as name

Implements jocassview::DataViewer.

Definition at line 170 of file one_d_viewer.cpp.

Member Data Documentation

QAction* jocassview::OneDViewer::_axisTitleControl
private

an action to control the legend of curves

Definition at line 172 of file one_d_viewer.h.

Referenced by OneDViewer(), and replot().

QList<PlotCurve*> jocassview::OneDViewer::_curves
private

this plots curves

Definition at line 151 of file one_d_viewer.h.

Referenced by on_add_graph_triggered(), OneDViewer(), remove_curve(), and replot().

QList<OneDViewerData*> jocassview::OneDViewer::_curvesData
private

this plots curves

Definition at line 154 of file one_d_viewer.h.

QwtPlotGrid* jocassview::OneDViewer::_grid
private

a grid in the plot

Definition at line 160 of file one_d_viewer.h.

Referenced by OneDViewer(), and replot().

QAction* jocassview::OneDViewer::_gridControl
private

an action to control the grid in the plot

Definition at line 157 of file one_d_viewer.h.

Referenced by OneDViewer().

quint8 jocassview::OneDViewer::_gridLines
private

flags to tell which grid lines should be drawn

Definition at line 163 of file one_d_viewer.h.

Referenced by on_grid_triggered(), OneDViewer(), and replot().

QwtLegend* jocassview::OneDViewer::_legend
private

a legend for the different curves

Definition at line 169 of file one_d_viewer.h.

Referenced by change_curve_color(), change_curve_width(), on_add_graph_triggered(), on_legend_right_clicked(), OneDViewer(), remove_curve(), and replot().

QAction* jocassview::OneDViewer::_legendControl
private

an action to control the legend of curves

Definition at line 166 of file one_d_viewer.h.

Referenced by OneDViewer(), and replot().

MinMaxControl* jocassview::OneDViewer::_xControl
private

control for the x-axis

Definition at line 145 of file one_d_viewer.h.

Referenced by OneDViewer(), and replot().

MinMaxControl* jocassview::OneDViewer::_yControl
private

control for the y-axis

Definition at line 148 of file one_d_viewer.h.

Referenced by OneDViewer(), and replot().


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