27 #include "../../../color/RGBAColor.h"
28 #include "../../../dataaccess/dataset/ObjectIdSet.h"
29 #include "../../../se.h"
38 #include <qwt_plot_curve.h>
39 #include <qwt_plot_grid.h>
40 #include <qwt_plot_histogram.h>
41 #include <qwt_plot_magnifier.h>
42 #include <qwt_plot_panner.h>
43 #include <qwt_plot_picker.h>
44 #include <qwt_plot_zoomer.h>
45 #include <qwt_picker_machine.h>
47 #include <qwt_symbol.h>
50 #include <qapplication.h>
70 setAutoFillBackground(
true );
71 setAutoReplot(
true );
74 ( void )
new QwtPlotMagnifier( this->canvas() );
77 m_panner =
new QwtPlotPanner(this->canvas());
78 m_panner->setMouseButton(Qt::MidButton);
82 m_leftPicker->setStateMachine(
new QwtPickerClickPointMachine );
85 m_ctrlPicker->setStateMachine(
new QwtPickerClickPointMachine );
86 m_ctrlPicker->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton, Qt::ControlModifier);
89 m_shiftPicker->setStateMachine(
new QwtPickerClickPointMachine );
90 m_shiftPicker->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton, Qt::ShiftModifier);
94 canvas()->setCursor( Qt::ArrowCursor);
108 delete m_shiftPicker;
119 delete m_shiftPicker;
121 m_leftPicker =
new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft, QwtPlotPicker::RectRubberBand, QwtPicker::AlwaysOff, this->canvas());
122 m_leftPicker->setStateMachine(
new QwtPickerDragRectMachine );
124 m_ctrlPicker =
new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft, QwtPlotPicker::RectRubberBand, QwtPicker::AlwaysOff, this->canvas());
125 m_ctrlPicker->setStateMachine(
new QwtPickerDragRectMachine );
126 m_ctrlPicker->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton, Qt::ControlModifier);
128 m_shiftPicker =
new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft, QwtPlotPicker::RectRubberBand, QwtPicker::AlwaysOff, this->canvas());
129 m_shiftPicker->setStateMachine(
new QwtPickerDragRectMachine );
130 m_shiftPicker->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton, Qt::ShiftModifier);
132 connect(m_leftPicker, SIGNAL(selected(
const QRectF&)), SLOT(onRectPicked(
const QRectF&)));
133 connect(m_ctrlPicker, SIGNAL(selected(
const QRectF&)), SLOT(onRectPicked(
const QRectF&)));
134 connect(m_shiftPicker, SIGNAL(selected(
const QRectF&)), SLOT(onRectPicked(
const QRectF&)));
136 canvas()->setCursor(Qt::CrossCursor);
143 delete m_shiftPicker;
145 m_leftPicker =
new QwtPlotPicker(this->canvas());
146 m_leftPicker->setStateMachine(
new QwtPickerClickPointMachine );
148 m_ctrlPicker =
new QwtPlotPicker(this->canvas());
149 m_ctrlPicker->setStateMachine(
new QwtPickerClickPointMachine );
150 m_ctrlPicker->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton, Qt::ControlModifier);
152 m_shiftPicker =
new QwtPlotPicker(this->canvas());
153 m_shiftPicker->setStateMachine(
new QwtPickerClickPointMachine );
154 m_shiftPicker->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton, Qt::ShiftModifier);
156 connect(m_leftPicker, SIGNAL(selected(
const QPointF&)), SLOT(onPointPicked(
const QPointF&)));
157 connect(m_ctrlPicker, SIGNAL(selected(
const QPointF&)), SLOT(onPointPicked(
const QPointF&)));
158 connect(m_shiftPicker, SIGNAL(selected(
const QPointF&)), SLOT(onPointPicked(
const QPointF&)));
170 m_chartStyle = newStyle;
178 QApplication::setOverrideCursor(Qt::WaitCursor);
179 const QwtPlotItemList& itmList = itemList();
181 for ( QwtPlotItemIterator it = itmList.begin();
182 it != itmList.end(); ++it )
195 QApplication::restoreOverrideCursor();
201 const QwtPlotItemList& itmList = itemList();
203 for ( QwtPlotItemIterator it = itmList.begin();
204 it != itmList.end(); ++it )
224 QwtText title( m_chartStyle->getTitle());
225 QwtText axisX(m_chartStyle->getAxisX());
226 QwtText axisY(m_chartStyle->getAxisY());
228 title.setFont(m_chartStyle->getTitleFont());
229 axisX.setFont(m_chartStyle->getAxisFont());
230 axisY.setFont(m_chartStyle->getAxisFont());
233 setAxisTitle( QwtPlot::yLeft, axisY);
234 setAxisTitle( QwtPlot::xBottom, axisX);
236 if(m_chartStyle->getGridChecked())
237 m_grid->attach(
this);
241 canvas()->setPalette(m_chartStyle->getColor());
247 QApplication::setOverrideCursor(Qt::WaitCursor);
248 const QwtPlotItemList& itmList = itemList();
249 for ( QwtPlotItemIterator it = itmList.begin();
250 it != itmList.end(); ++it )
254 if (QObject::sender() == m_ctrlPicker)
255 emit selected(static_cast<te::qt::widgets::ScatterChart*>(*it)->highlight( pos),
true);
257 emit selected(static_cast<te::qt::widgets::ScatterChart*>(*it)->highlight( pos),
false);
263 if (QObject::sender() == m_ctrlPicker || QObject::sender() == m_shiftPicker)
264 emit selected(static_cast<te::qt::widgets::HistogramChart*>(*it)->highlight( pos),
true);
266 emit selected(static_cast<te::qt::widgets::HistogramChart*>(*it)->highlight( pos),
false);
271 QApplication::restoreOverrideCursor();
276 QApplication::setOverrideCursor(Qt::WaitCursor);
277 const QwtPlotItemList& itmList = itemList();
278 for ( QwtPlotItemIterator it = itmList.begin();
279 it != itmList.end(); ++it )
283 if (QObject::sender() == m_ctrlPicker || QObject::sender() == m_shiftPicker)
284 emit selected(static_cast<te::qt::widgets::ScatterChart*>(*it)->highlight( rect),
true);
286 emit selected(static_cast<te::qt::widgets::ScatterChart*>(*it)->highlight( rect),
false);
291 QApplication::restoreOverrideCursor();
QwtPlotPicker * m_ctrlPicker
The display's control button picker.
A class to represent a scatter's chart.
ChartStyle * m_chartStyle
The display's style.
void adjustDisplay()
Updates the general display settings according to the ChartStyle. The adjusted properties are: Title;...
void highlight(const te::da::ObjectIdSet *oids)
Highlights the objects identified by oids.
This class represents a set of unique ids created in the same context. i.e. from the same data set...
ChartDisplay(QWidget *parent=NULL, QString title="", ChartStyle *style=0)
Constructor.
QwtPlotGrid * m_grid
The display's grid.
void onPointPicked(const QPointF &pos)
Called when the user clicks on the canvas area. Will highlight the data, if possible, depending on the type of chart being displayed (f.e. histogram, scatter, etc).
QwtPlotPicker * m_shiftPicker
The display's control button picker.
void onRectPicked(const QRectF &rect)
Called when the user selects an area of the canvas. Will highlight the data, if possible, depending on the type of chart being displayed (f.e. histogram, scatter, etc).
void setPickerStyle(int chartType)
It sets the QwtPlotPicker's state machine (selection mode)
QwtPlotPanner * m_panner
The display's panner.
QwtPlotPicker * m_leftPicker
The display's left button picker.
void highlightOIds(const te::da::ObjectIdSet *oids)
Highlights the objects identified by oids.
void setSelectionColor(QColor selColor)
color used to hgihlight selected objects on this display.
A class to represent a scatter chart.
This file contains a set of utility chart functions.
void setStyle(te::qt::widgets::ChartStyle *newStyle)
It sets the display's style.
A class to represent a histogram chart.
void setSelectionColor(QColor selColor)
color used to hgihlight selected objects on this chart.
A class used to define a chartDisplay's style.
A class to represent a chart display.
~ChartDisplay()
Destructor.
void highlight(const te::da::ObjectIdSet *oids)
Highlights the objects identified by oids.
void setSelectionColor(QColor selColor)
color used to hgihlight selected objects on this chart.
void selected(te::da::ObjectIdSet *, const bool &)
Emmit when objects were selected.
te::qt::widgets::ChartStyle * getStyle()
Returns a pointer to the display's style.