A XYPlot is a layer to plot black dots (static) More...
#include <XYPlot.h>
Public Slots | |
void | swapXY () |
Public Member Functions | |
virtual void | addProperties (PropertyProxy *pp) |
virtual Rect | boundingRect () const |
int | count () const |
double | dotDiameter () const |
virtual bool | hasProperties () |
virtual void | properties (PropertyWidget *w) const |
virtual void | removeProperties (PropertyProxy *pp) |
virtual void | select (QVector< int > *indexList) |
void | setDotDiameter (double d) |
virtual void | setProperty (uint wid, int pid, QVariant val) |
void | setSymbol (Symbol::Type s) |
void | setSymbol (const QString &s) |
void | setXData (QVector< double > *x) |
void | setYData (QVector< double > *y) |
Symbol::Type | symbol () const |
QString | symbolString () const |
virtual bool | trackRectangle (int, double rx1, double ry1, double rx2, double ry2, Qt::KeyboardModifiers eventState) |
virtual const QString & | xml_tagName () const |
XYPlot (AxisWindow *parent=0) | |
~XYPlot () | |
Static Public Attributes | |
static const QString | xmlXYPlotTag = "XYPlot" |
Protected Member Functions | |
void | getPaintParam (int &count, double &pointSize, double &halfPointSize, double dotpercm) const |
virtual void | paintData (const LayerPainterRequest &lp, QPainter &p, double dotpercm) const |
virtual bool | xml_setBinaryData (XML_SETBINARYDATA_ARGS) |
virtual void | xml_writeBinaryData (XML_WRITEBINARYDATA_ARGS) const |
virtual void | xml_writeProperties (XML_WRITEPROPERTIES_ARGS) const |
Protected Attributes | |
double | _size |
Symbol::Type | _symbol |
QVector< double > * | _xData |
QVector< double > * | _yData |
Static Protected Attributes | |
static uint | _tab = PropertyProxy::uniqueId() |
Properties | |
int | count |
double | dotDiameter |
QString | symbol |
A XYPlot is a layer to plot black dots (static)
Basic plot of black dots defined by two pointer to QVector (_xData, _yData)
SciFigs::XYPlot::XYPlot | ( | AxisWindow * | parent = 0 | ) |
References _symbol, _xData, _yData, SciFigs::Symbol::Circle, setDotDiameter(), and TRACE.
: GraphContentLayer(parent) { TRACE; _xData=0; _yData=0; setDotDiameter(0.1); // 0.1 cm _symbol=Symbol::Circle; }
void SciFigs::XYPlot::addProperties | ( | PropertyProxy * | pp | ) | [virtual] |
Setup property editor
Reimplemented from SciFigs::GraphContentLayer.
Reimplemented in SciFigs::XYValuePlot.
References _tab, QGpGuiTools::PropertyProxy::addReference(), QGpGuiTools::PropertyProxy::addTab(), QGpGuiTools::PropertyProxy::setCurrentTab(), QGpCoreTools::tr(), TRACE, and w.
{ TRACE; if(pp->setCurrentTab(_tab)) { pp->addReference(this); } else { XYPlotProperties * w=new XYPlotProperties; pp->addTab(_tab, tr("Plot"), w, this); } }
Rect SciFigs::XYPlot::boundingRect | ( | ) | const [virtual] |
Implements SciFigs::GraphContentLayer.
References _xData, _yData, QGpCoreTools::Rect::add(), and TRACE.
int SciFigs::XYPlot::count | ( | ) | const [inline] |
double SciFigs::XYPlot::dotDiameter | ( | ) | const [inline] |
Referenced by properties().
{return _size;}
void SciFigs::XYPlot::getPaintParam | ( | int & | count, |
double & | pointSize, | ||
double & | halfPointSize, | ||
double | dotpercm | ||
) | const [inline, protected] |
References _size, _xData, _yData, and TRACE.
Referenced by SciFigs::XYColorPlot::paintData(), SciFigs::XYValuePlot::paintData(), and paintData().
virtual bool SciFigs::XYPlot::hasProperties | ( | ) | [inline, virtual] |
Reimplemented from SciFigs::GraphContentLayer.
Reimplemented in SciFigs::XYValuePlot.
{return true;}
void SciFigs::XYPlot::paintData | ( | const LayerPainterRequest & | lp, |
QPainter & | p, | ||
double | dotpercm | ||
) | const [protected, virtual] |
Implements SciFigs::GraphContentLayer.
Reimplemented in SciFigs::XYValuePlot, and SciFigs::XYColorPlot.
References _symbol, count(), getPaintParam(), SciFigs::LayerPainterRequest::options(), SciFigs::GraphContentLayer::paint(), SciFigs::GraphContentOptions::r2s(), TRACE, SciFigs::GraphContentOptions::xVisMax(), SciFigs::GraphContentOptions::xVisMin(), SciFigs::GraphContentOptions::yVisMax(), and SciFigs::GraphContentOptions::yVisMin().
{ TRACE; const GraphContentOptions& gc=lp.options(); p.setRenderHints(QPainter::Antialiasing, true); int count; double pointSize, halfPointSize; getPaintParam(count, pointSize, halfPointSize, dotpercm); for(int i=0; i<count; i++) { double x=(*_xData)[i]; if(x>gc.xVisMin() && x<gc.xVisMax()) { double y=(*_yData)[i]; if(y>gc.yVisMin() && y<gc.yVisMax()) { Symbol::paint(_symbol, p, gc.r2s(x, y), pointSize, halfPointSize); } } } }
void SciFigs::XYPlot::properties | ( | PropertyWidget * | w | ) | const [virtual] |
Reimplemented from SciFigs::GraphContentLayer.
Reimplemented in SciFigs::XYValuePlot.
References _symbol, SciFigs::XYPlotProperties::DotDiameter, dotDiameter(), QGpGuiTools::PropertyWidget::setValue(), SciFigs::XYPlotProperties::Symbol, SciFigs::LegendTable::symbolItem(), and TRACE.
{ TRACE; w->setValue(XYPlotProperties::DotDiameter, dotDiameter()*10.0); w->setValue(XYPlotProperties::Symbol, LegendTable::symbolItem(_symbol)); }
void SciFigs::XYPlot::removeProperties | ( | PropertyProxy * | pp | ) | [virtual] |
Clean property editor
Reimplemented from SciFigs::GraphContentLayer.
Reimplemented in SciFigs::XYValuePlot.
References _tab, QGpGuiTools::PropertyProxy::removeTab(), and TRACE.
void SciFigs::XYPlot::select | ( | QVector< int > * | indexList | ) | [virtual] |
Can be redefined in sub classes. This function is triggered when user wants to select points
References TRACE.
Referenced by trackRectangle().
{ TRACE; // Basic functionnality to test method /*fprintf(stdout, "%i selected\n", indexList->size()); for(int i=0;i < indexList->size();i++ ) { int ind=( *indexList) [ i ]; fprintf(stdout, "%g %g\n", ( *_xData) [ ind ], ( *_yData) [ ind ] ); }*/ }
void SciFigs::XYPlot::setDotDiameter | ( | double | d | ) | [inline] |
Referenced by MonoStation::AbstractSummary::createBubbleGraph(), setProperty(), and XYPlot().
{_size=d;}
void SciFigs::XYPlot::setProperty | ( | uint | wid, |
int | pid, | ||
QVariant | val | ||
) | [virtual] |
Reimplemented from SciFigs::GraphContentLayer.
Reimplemented in SciFigs::XYValuePlot.
References SciFigs::GraphContent::deepUpdate(), SciFigs::XYPlotProperties::DotDiameter, SciFigs::GraphContentLayer::graphContent(), setDotDiameter(), setSymbol(), SciFigs::XYPlotProperties::Symbol, SciFigs::LegendTable::symbolType(), and TRACE.
{ TRACE; switch(pid) { case XYPlotProperties::DotDiameter: setDotDiameter(val.toDouble()*0.1); graphContent()->deepUpdate(); break; case XYPlotProperties::Symbol: setSymbol(LegendTable::symbolType(val.toInt())); graphContent()->deepUpdate(); break; default: break; } }
void SciFigs::XYPlot::setSymbol | ( | Symbol::Type | s | ) | [inline] |
Referenced by setProperty().
{_symbol=s;}
void SciFigs::XYPlot::setSymbol | ( | const QString & | s | ) | [inline] |
References SciFigs::Symbol::symbolValue().
{_symbol=Symbol::symbolValue(s);}
void SciFigs::XYPlot::setXData | ( | QVector< double > * | x | ) |
Set the pointer to X Data
References _xData.
Referenced by addDotPlot(), and MonoStation::AbstractSummary::setBubbleValues().
void SciFigs::XYPlot::setYData | ( | QVector< double > * | y | ) |
Set the pointer to Y Data
References _yData.
Referenced by addDotPlot(), and MonoStation::AbstractSummary::setBubbleValues().
void SciFigs::XYPlot::swapXY | ( | ) | [slot] |
References _xData, _yData, SciFigs::GraphContent::deepUpdate(), SciFigs::GraphContentLayer::graphContent(), and TRACE.
{ TRACE; QVector<double> * tmp=_xData; _xData=_yData; _yData=tmp; graphContent() ->deepUpdate(); }
Symbol::Type SciFigs::XYPlot::symbol | ( | ) | const [inline] |
{return _symbol;}
QString SciFigs::XYPlot::symbolString | ( | ) | const [inline] |
References SciFigs::Symbol::symbolName().
{return Symbol::symbolName(_symbol);}
bool SciFigs::XYPlot::trackRectangle | ( | int | , |
double | rx1, | ||
double | ry1, | ||
double | rx2, | ||
double | ry2, | ||
Qt::KeyboardModifiers | eventState | ||
) | [virtual] |
Reimplemented from SciFigs::GraphContentLayer.
References _xData, _yData, QGpCoreTools::Rect::includes(), select(), and TRACE.
{ TRACE; // Select the points inside the rectangle and call trackRectangle(QVector * indexList) // This select function can redefined in sub-classes Rect r(rx1, ry1, rx2, ry2); QVector<int> * indexList=new QVector<int>; int minSize=_xData->size(); if(minSize>_yData->size()) { minSize=_yData->size(); } for(int i=0; i<minSize; i++) { Point p=Point((*_xData)[i], (*_yData)[i]); if(r.includes(p)) indexList->push_back(i); } if(indexList->size()>0) { select(indexList); } delete indexList; return true; }
bool SciFigs::XYPlot::xml_setBinaryData | ( | XML_SETBINARYDATA_ARGS | ) | [protected, virtual] |
This function must be re-implemented in all classes dealing with binary data that cannot be saved in an ASCII xml file (e.g. due to the amount of data).
See also xml_writeBinaryData().
The difference between xml_setBinaryData() and xml_setBinaryData200410() is detected by the type of tag at the beginning of each block if it can be read with QString ==> 200510, else try with a normal C string, if it match the current tag then execute xml_setBinaryData200411().
See also xml_setBinaryData200411() to maintain compatibility with previous versions of xml storages.
For the arguments of this function use Macro XML_SETBINARYDATA_ARGS.
Reimplemented from QGpCoreTools::XMLClass.
Reimplemented in SciFigs::XYValuePlot, and SciFigs::XYColorPlot.
References _xData, _yData, and TRACE.
Referenced by SciFigs::XYColorPlot::xml_setBinaryData(), and SciFigs::XYValuePlot::xml_setBinaryData().
{ TRACE; Q_UNUSED(context); int n; s >> n; if(n>0) { QVector<double>::iterator it; QVector<double>::iterator itEnd; _xData=new QVector<double>; _xData->resize(n); itEnd=_xData->end(); for(it=_xData->begin();it!=itEnd;++it) s >> *it; _yData=new QVector<double>; _yData->resize(n); itEnd=_yData->end(); for(it=_yData->begin();it!=itEnd;++it) s >> *it; } return true; }
virtual const QString& SciFigs::XYPlot::xml_tagName | ( | ) | const [inline, virtual] |
Reimplemented from SciFigs::GraphContentLayer.
Reimplemented in SciFigs::XYValuePlot, and SciFigs::XYColorPlot.
{return xmlXYPlotTag;}
void SciFigs::XYPlot::xml_writeBinaryData | ( | XML_WRITEBINARYDATA_ARGS | ) | const [protected, virtual] |
This function must be re-implemented in all classes dealing with binary data that cannot be saved in an ASCII xml file (e.g. due to the amount of data).
The way binary data is stored drastically changed in November 2006 with the introduction of tar.gz structures for xml files. Each class willing to store binary data can automatically generate a new file (with an automatic file name) in the .tar.gz structure by sending bytes to s.
See also xml_setBinaryData().
For the arguments of this function use Macro XML_WRITEBINARYDATA_ARGS.
Reimplemented from QGpCoreTools::XMLClass.
Reimplemented in SciFigs::XYValuePlot, and SciFigs::XYColorPlot.
References _xData, _yData, count(), and TRACE.
{ TRACE; Q_UNUSED(context); s << count(); QVector<double>::iterator it; QVector<double>::iterator itEnd; itEnd=_xData->end(); for(it=_xData->begin();it!=itEnd;++it) s << *it; itEnd=_yData->end(); for(it=_yData->begin();it!=itEnd;++it) s << *it; }
void SciFigs::XYPlot::xml_writeProperties | ( | XML_WRITEPROPERTIES_ARGS | ) | const [protected, virtual] |
Reimplemented from SciFigs::GraphContentLayer.
References SciFigs::XMLSciFigs::data(), TRACE, and QGpCoreTools::XMLClass::writeBinaryData().
{ TRACE; GraphContentLayer::xml_writeProperties(s, context); XMLSciFigs * scifigsContext=static_cast<XMLSciFigs *>(context); if(scifigsContext->data()) writeBinaryData(s, context); }
double SciFigs::XYPlot::_size [protected] |
Referenced by getPaintParam().
Symbol::Type SciFigs::XYPlot::_symbol [protected] |
Referenced by SciFigs::XYColorPlot::paintData(), SciFigs::XYValuePlot::paintData(), paintData(), properties(), and XYPlot().
uint SciFigs::XYPlot::_tab = PropertyProxy::uniqueId() [static, protected] |
Referenced by addProperties(), and removeProperties().
QVector<double>* SciFigs::XYPlot::_xData [protected] |
Referenced by boundingRect(), getPaintParam(), setXData(), swapXY(), trackRectangle(), xml_setBinaryData(), xml_writeBinaryData(), XYPlot(), and ~XYPlot().
QVector<double>* SciFigs::XYPlot::_yData [protected] |
Referenced by boundingRect(), getPaintParam(), setYData(), swapXY(), trackRectangle(), xml_setBinaryData(), xml_writeBinaryData(), XYPlot(), and ~XYPlot().
const QString SciFigs::XYPlot::xmlXYPlotTag = "XYPlot" [static] |
int SciFigs::XYPlot::count [read] |
double SciFigs::XYPlot::dotDiameter [read, write] |
QString SciFigs::XYPlot::symbol [read, write] |