9 #include <QtCore/QSettings>
10 #include <QtCore/QVector>
11 #include <QtCore/QDebug>
12 #include <QtCore/QTime>
14 #if QT_VERSION >= 0x050000
15 #include <QtWidgets/QVBoxLayout>
16 #include <QtWidgets/QToolBar>
17 #include <QtWidgets/QWidgetAction>
18 #include <QtWidgets/QMenu>
19 #include <QtWidgets/QColorDialog>
20 #include <QtWidgets/QInputDialog>
21 #include <QtWidgets/QFileDialog>
22 #include <QtWidgets/QMessageBox>
24 #include <QtGui/QVBoxLayout>
25 #include <QtGui/QToolBar>
26 #include <QtGui/QWidgetAction>
27 #include <QtGui/QMenu>
28 #include <QtGui/QColorDialog>
29 #include <QtGui/QInputDialog>
30 #include <QtGui/QFileDialog>
31 #include <QtGui/QMessageBox>
33 #include <QtGui/QIcon>
36 #include <qwt_plot_curve.h>
37 #include <qwt_plot_grid.h>
38 #include <qwt_scale_widget.h>
39 #include <qwt_legend.h>
40 #include <qwt_scale_engine.h>
41 #include <qwt_legend_label.h>
65 _plot =
new QwtPlot(
this);
74 _curves[0]->setStyle(QwtPlotCurve::Steps);
78 _grid =
new QwtPlotGrid;
79 _grid->setMajorPen(
QPen(Qt::black, 0, Qt::DashLine));
80 _grid->setMinorPen(
QPen(Qt::black, 0, Qt::DotLine));
85 _legend->setDefaultItemMode(QwtLegendData::Checkable);
87 QwtLegendLabel *curveLegendLabel(qobject_cast<QwtLegendLabel *>(
_legend->legendWidget(
_plot->itemToInfo(
_curves[0]))));
88 curveLegendLabel->setContextMenuPolicy(Qt::CustomContextMenu);
89 curveLegendLabel->setChecked(
true);
101 tr(
"Add a reference Graph to the Plot"),
106 tr(
"toggle Grid"),toolbar);
112 tr(
"Toggle Axis Titles"),toolbar);
147 resize(settings.
value(
"WindowSize",
size()).toSize());
148 move(settings.
value(
"WindowPosition",pos()).toPoint());
161 QwtPlotItemList plotlist(
_plot->itemList(QwtPlotItem::Rtti_PlotCurve));
162 for (QwtPlotItemIterator it = plotlist.begin(); it != plotlist.end() ; ++it)
164 PlotCurve *curve(dynamic_cast<PlotCurve*>(*it));
165 list.
append(dynamic_cast<OneDViewerData*>(curve->data()));
186 pix.
save(filename,
"PNG");
195 while (dataIt != dataList.
end())
214 list <<
"h5"<<
"hst"<<
"csv"<<
"png";
230 QwtPlotItemList list(
_plot->itemList(QwtPlotItem::Rtti_PlotCurve));
231 for (QwtPlotItemIterator it = list.begin(); it != list.end() ; ++it)
238 _plot->setAxisScaleEngine(QwtPlot::xBottom,
new QwtLogScaleEngine);
240 _plot->setAxisScaleEngine(QwtPlot::xBottom,
new QwtLinearScaleEngine);
244 _plot->setAxisScaleEngine(QwtPlot::yLeft,
new QwtLogScaleEngine);
246 _plot->setAxisScaleEngine(QwtPlot::yLeft,
new QwtLinearScaleEngine);
250 _plot->setAxisAutoScale(QwtPlot::xBottom);
255 _plot->setAxisAutoScale(QwtPlot::yLeft);
262 if (!this->
data().isEmpty())
268 _plot->axisWidget(QwtPlot::xBottom)->setTitle(xtitle);
273 _plot->axisWidget(QwtPlot::xBottom)->setTitle(
"");
276 _plot->updateLayout();
293 if (!sender()->isWidgetType())
300 QWidget *curveWidget(dynamic_cast<QWidget*>(sender()));
315 act->setParent(curveWidget);
317 act->setParent(curveWidget);
318 if(curve->title() != windowTitle())
320 act = menu.addSeparator();
321 act = menu.addAction(tr(
"Delete"),
this,SLOT(
remove_curve()));
322 act->setParent(curveWidget);
324 menu.exec(globalPos);
329 QwtPlotItem *curve(
_plot->infoToItem(itemInfo));
330 curve->setVisible(on);
338 if (!sender()->parent()->isWidgetType())
340 QWidget *curveWidget(dynamic_cast<QWidget*>(sender()->parent()));
344 QPen pen(curve->pen());
358 if (!sender()->parent()->isWidgetType())
360 QWidget *curveWidget(dynamic_cast<QWidget*>(sender()->parent()));
364 QPen pen(curve->pen());
379 if (!sender()->parent()->isWidgetType())
381 QWidget *curveWidget(dynamic_cast<QWidget*>(sender()->parent()));
396 sourceNames <<
"***New Source***";
401 currentIdx,
false, &ok));
402 if (!ok || sourceName.
isEmpty())
407 if (sourceName ==
"***New Source***")
409 QString filter(
"Data Files (*.csv *.hst *.h5 *.hdf5)");
411 tr(
"Open Reference Data File"),
416 sourceName = fileName;
426 if (!ok || item.isEmpty())
431 if (!(result && result->dim() ==1))
451 curve->setTitle(item);
452 curve->setStyle(QwtPlotCurve::Steps);
453 curve->attach(
_plot);
454 curve->setData(data);
455 QwtLegendLabel *curveWidget(qobject_cast<QwtLegendLabel*>(
_legend->legendWidget(
_plot->itemToInfo(curve))));
456 curveWidget->setContextMenuPolicy(Qt::CustomContextMenu);
457 curveWidget->setChecked(
true);
contains the jocassviewer class
virtual QList< Data * > data()
retrieve the displayed data
addToolBar(Qt::ToolBarArea area, QToolBar *toolbar)
QAction * _legendControl
an action to control the legend of curves
OneDViewer(QString title, QWidget *parent=0)
constructor
static void addSource(const QString &sourcename, DataSource *source, bool setActive=true)
add a data source
virtual void setSourceName(const QString &name)
set the source name
std::tr1::shared_ptr< self_type > shared_pointer
a shared pointer of this class
bool log() const
return wether log is enabled
static void saveData(const QString &filename, result_t::shared_pointer data)
save data to a given file
read and write data to files
contains the base class for add viewer data
contains singleton class to manage the data sources
QwtPlot * _plot
the plot inside which the data will be displayed
true Then one can use the IsHit Processor later on
things written only at end of run H5Dump ProcessorSummary size
quint8 _gridLines
flags to tell which grid lines should be drawn
virtual QString type() const
retrieve the type of the data viewer
tr(const char *sourceText, const char *disambiguation=0, int n=-1)
virtual QStringList dataFileSuffixes() const
suffixes for the data of this viewer
contains the viewer for 1d data
widget to control the min and max values
QAction * _axisTitleControl
an action to control the legend of curves
QAction * _gridControl
an action to control the grid in the plot
void setResult(result_t::shared_pointer result)
set the cass data to be wrapped by this
fromHsv(int h, int s, int v, int a=255)
setValue(const QString &key, const QVariant &value)
virtual void saveData(const QString &filename)
save the data to file
void change_curve_color(PlotCurve *curve=0)
change the curves color
void on_legend_checked(const QVariant &item, bool on)
react when an legend item has been clicked
fromStdString(const std::string &str)
base class for data sources
save(const QString &fileName, const char *format=0, int quality=-1)
static bool isContainerFile(const QString &filename)
return whether the file is a container file
void change_curve_width(PlotCurve *curve=0)
change the curves line width
bool autoscale() const
return whether the plot should be autoscaled
virtual result_t::shared_pointer result(const QString &key, quint64 id=0)=0
retrieve a result from the source
virtual void dataChanged()
update the plot
setCentralWidget(QWidget *widget)
void on_grid_triggered()
react on when the gridControl has been triggered
setColor(const QColor &color)
void on_legend_right_clicked(QPoint pos)
react when an legend item has been selected
MinMaxControl * _xControl
control for the x-axis
void replot()
redraw the plot
getColor(const QColor &initial, QWidget *parent, const QString &title, ColorDialogOptions options=0)
static DataSource * source(const QString &sourcename=QString())
retrieve an available source
value(const QString &key, const QVariant &defaultValue=QVariant()
MinMaxControl * _yControl
control for the y-axis
static QStringList sourceNames()
retrieve the names of all current active sources
void setYRangeForLog(bool log)
set up the bounding rect for when y should be log scale
QwtPlotGrid * _grid
a grid in the plot
an alternative curve plot
critical(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
double max() const
retieve the maximum value
QwtLegend * _legend
a legend for the different curves
contains a control over min and max values
QList< PlotCurve * > _curves
this plots curves
contains an alternative curve plot
indexOf(const QRegExp &rx, int from=0)
void setXRangeForLog(bool log)
set up the bounding rect for when x should be log scale
getOpenFileName(QWidget *parent=0, const QString &caption=QString()
insert(int position, const QString &str)
static QString currentSourceName()
return the current source name
void on_add_graph_triggered()
react when addGraph action has been triggered
virtual ~OneDViewer()
destructor
double min() const
retrieve the minimum value
void remove_curve(PlotCurve *curve=0)
remove the curve from the plot
contains the wrapper of the data for the 1d viewer
beginGroup(const QString &prefix)
lastIndexOf(const QString &str, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive)
virtual QStringList resultNames()=0
retrieve the list items that can be displayed