29 #include "../../../dataaccess/dataset/ObjectIdSet.h"
30 #include "../../../se/Mark.h"
31 #include "../../../se/Graphic.h"
32 #include "../../../se/Utils.h"
40 #include <qwt_symbol.h>
51 setStyle(QwtPlotCurve::NoCurve);
52 setPaintAttribute(QwtPlotCurve::FilterPoints );
56 m_selection->setPaintAttribute(QwtPlotCurve::FilterPoints);
67 newSymbol->setSize(QSize( 1, 1 ));
72 setSymbol(
new QwtSymbol( QwtSymbol::Ellipse, QBrush( Qt::gray ), QPen( Qt::black, 1 ), QSize( 8, 8 )));
88 m_selection->setPaintAttribute(QwtPlotCurve::FilterPoints);
92 setStyle(QwtPlotCurve::NoCurve);
93 setPaintAttribute(QwtPlotCurve::FilterPoints);
103 if(m_scatter->sizeX() < m_scatter->sizeY())
105 for (
size_t i = 0; i < m_scatter->sizeX(); i++)
107 samples += QPointF( m_scatter->getX(i), m_scatter->getY(i));
112 for (
size_t i = 0; i < m_scatter->sizeY(); i++)
114 samples += QPointF( m_scatter->getX(i), m_scatter->getY(i));
118 setSamples( samples );
124 delete m_scatterStyle;
141 m_scatter = newScatter;
146 return m_scatterStyle->
clone();
151 delete m_scatterStyle;
152 m_scatterStyle = newSymbol;
155 setSymbol(m_scatterStyle->getSymbol());
158 QwtSymbol* selSymbol =
new QwtSymbol( symbol()->style(), symbol()->brush().color().darker (180 ), symbol()->pen().color().darker( 180), symbol()->size());
159 QPixmap selPixmap = symbol()->pixmap();
160 selPixmap.fill(m_selColor);
161 selSymbol->setPixmap(selPixmap);
162 m_selection->setSymbol(selSymbol);
168 m_selection->detach();
170 std::set<te::da::ObjectId*, te::common::LessCmp<te::da::ObjectId*> >::const_iterator itObjSet;
171 QVector<QPointF> highlightedPoints;
173 for(itObjSet = oids->
begin(); itObjSet != oids->
end(); ++itObjSet)
175 std::pair<double, double> point = m_scatter->find((*itObjSet));
176 highlightedPoints.push_back(QPointF(point.first, point.second));
179 m_selection->setSamples(highlightedPoints);
180 m_selection->attach(plot());
186 const QwtScaleMap xMap = plot()->canvasMap( xAxis() );
187 const QwtScaleMap yMap = plot()->canvasMap( yAxis() );
189 const double cx = xMap.transform( point.rx());
190 const double cy = yMap.transform( point.ry() );
192 QPoint mappedPoint = QPoint(cx, cy);
195 int index = closestPoint( mappedPoint, &dist );
199 double x = sample(index).x();
200 double y = sample(index).y();
201 return m_scatter->find(x, y);
205 double x = std::numeric_limits<double>::max();
206 double y = std::numeric_limits<double>::max();
207 return m_scatter->find(x, y);
213 QwtSeriesData<QPointF>* values = data();
214 std::vector<QPointF> selected;
217 for(
size_t i = 0; i < values->size(); ++i)
219 if( rect.contains(values->sample(i)))
221 selected.push_back(values->sample(i));
224 return m_scatter->find(selected);
229 m_selColor = selColor;
232 m_selColor.setAlpha(100);
A class to represent a scatter's chart.
void setScatterStyle(ScatterStyle *newStyle)
It sets the chart's style.
QwtSymbol * getSymbol()
Returns a pointer to a QwtSymbol representing the current scatter's point style.
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Scatter * m_scatter
The scatter that will be shown on this chart.
ScatterStyle * m_scatterStyle
The symbol that defines the look of a scatter's point.
QColor m_selColor
THe color used to highlight selected obecjts.
virtual int rtti() const
Returns the chart's type.
ScatterStyle * clone()
Returns a pointer to a clone of this ScatterStyle.
A class to represent a scatter.
te::qt::widgets::Scatter * getScatter()
It returns the chart's scatter.
std::size_t sizeY()
It returns the size of the scatter.
QwtPlotCurve * m_selection
The PlotItems to be highlighted when a selection occurs;.
ScatterStyle * getScatterStyle()
Returns a clone of the pointer to the scatter's style.
A class to represent a scatter.
std::set< ObjectId *, te::common::LessCmp< ObjectId * > >::const_iterator begin() const
Returns an iterator for the object ids in container.
std::set< ObjectId *, te::common::LessCmp< ObjectId * > >::const_iterator end() const
Returns an iterator for the object ids in container.
This file contains a set of utility chart functions.
std::size_t sizeX()
It returns the size of the scatter.
ScatterChart(Scatter *data)
Constructor.
void setScatter(te::qt::widgets::Scatter *newScatter)
It sets the chart's scatter.
~ScatterChart()
Destructor.
void setSelectionColor(QColor selColor)
color used to hgihlight selected objects on this chart.
void highlight(const te::da::ObjectIdSet *oids)
Highlights the objects identified by oids.