A XYValuePlot is a layer to draw dots of color (static) More...
#include <XYValuePlot.h>
Public Slots | |
void | setPalette (const ColorPalette &pal) |
Signals | |
void | paletteChanged (const ColorPalette &pal) |
Public Member Functions | |
virtual void | addProperties (PropertyProxy *pp) |
virtual bool | hasProperties () |
const ColorPalette & | palette () const |
virtual void | properties (PropertyWidget *w) const |
virtual void | removeProperties (PropertyProxy *pp) |
void | setLinearPalette (double minVal, double maxVal) |
void | setLogPalette (double minVal, double maxVal) |
virtual void | setProperty (uint wid, int pid, QVariant val) |
void | setValues (QVector< double > *val) |
void | valueRange (double &min, double &max) const |
virtual const QString & | xml_tagName () const |
XYValuePlot (AxisWindow *parent=0) | |
~XYValuePlot () | |
Static Public Attributes | |
static const QString | xmlXYValuePlotTag = "XYValuePlot" |
Protected Member Functions | |
virtual void | paintData (const LayerPainterRequest &lp, QPainter &p, double dotpercm) const |
virtual XMLMember | xml_member (XML_MEMBER_ARGS) |
virtual void | xml_polishChild (XML_POLISHCHILD_ARGS) |
virtual bool | xml_setBinaryData (XML_SETBINARYDATA_ARGS) |
virtual void | xml_writeBinaryData (XML_WRITEBINARYDATA_ARGS) const |
virtual void | xml_writeChildren (XML_WRITECHILDREN_ARGS) const |
Protected Attributes | |
ColorPalette | _pal |
QVector< double > * | _values |
Static Protected Attributes | |
static uint | _tabPalette = PropertyProxy::uniqueId() |
A XYValuePlot is a layer to draw dots of color (static)
The difference with XYColorPlot is that color can be directly set through a color palette. A color is not directly affected to points but a value, the color is calculated from the value and the palette.
SciFigs::XYValuePlot::XYValuePlot | ( | AxisWindow * | parent = 0 | ) |
References _pal, _values, QGpGuiTools::ColorPalette::defaultColors(), and TRACE.
: XYPlot(parent) { TRACE; _values=0; _pal.defaultColors(20); }
void SciFigs::XYValuePlot::addProperties | ( | PropertyProxy * | pp | ) | [virtual] |
Setup property editor
Reimplemented from SciFigs::XYPlot.
References _tabPalette, QGpGuiTools::PropertyProxy::addReference(), QGpGuiTools::PropertyProxy::addTab(), QGpGuiTools::PropertyProxy::setCurrentTab(), QGpCoreTools::tr(), TRACE, and w.
{ TRACE; XYPlot::addProperties(pp); if(pp->setCurrentTab(_tabPalette)) { pp->addReference(this); } else { PaletteProperties * w=new PaletteProperties; pp->addTab(_tabPalette, tr("Palette"), w, this); } }
virtual bool SciFigs::XYValuePlot::hasProperties | ( | ) | [inline, virtual] |
Reimplemented from SciFigs::XYPlot.
{return true;}
void SciFigs::XYValuePlot::paintData | ( | const LayerPainterRequest & | lp, |
QPainter & | p, | ||
double | dotpercm | ||
) | const [protected, virtual] |
Reimplemented from SciFigs::XYPlot.
References _pal, SciFigs::XYPlot::_symbol, _values, QGpGuiTools::ColorPalette::color(), SciFigs::XYPlot::count(), SciFigs::XYPlot::getPaintParam(), SciFigs::LayerPainterRequest::options(), SciFigs::GraphContentLayer::paint(), SciFigs::GraphContentOptions::r2sF(), TRACE, SciFigs::GraphContentOptions::xVisMax(), SciFigs::GraphContentOptions::xVisMin(), SciFigs::GraphContentOptions::yVisMax(), and SciFigs::GraphContentOptions::yVisMin().
{ TRACE; // Make a copy of current palette (mandatory for multi-thread, palette are implicitly shared // objects so deep copy probably is not occuring right now, only upon user request for modification) ColorPalette pal=_pal; const GraphContentOptions& gc=lp.options(); p.setRenderHints(QPainter::Antialiasing, true); int count; double pointSize, halfPointSize; getPaintParam(count, pointSize, halfPointSize, dotpercm); if(count>_values->count()) count=_values->count(); 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()) { QColor c=pal.color(_values->at(i)); p.setBrush(c); p.setPen(c); Symbol::paint(_symbol, p, gc.r2sF(x, y), pointSize, halfPointSize); } } } }
const ColorPalette& SciFigs::XYValuePlot::palette | ( | ) | const [inline] |
Referenced by properties(), setLinearPalette(), and setLogPalette().
{return _pal;}
void SciFigs::XYValuePlot::paletteChanged | ( | const ColorPalette & | pal | ) | [signal] |
Referenced by setLinearPalette(), setLogPalette(), and setPalette().
void SciFigs::XYValuePlot::properties | ( | PropertyWidget * | w | ) | const [virtual] |
Reimplemented from SciFigs::XYPlot.
References _tabPalette, QGpGuiTools::PropertyWidget::id(), SciFigs::PaletteProperties::Palette, palette(), and QGpGuiTools::PropertyWidget::setValue().
{ if(w->id()==_tabPalette) { w->setValue(PaletteProperties::Palette, QVariant::fromValue(palette())); } else { XYPlot::properties(w); } }
void SciFigs::XYValuePlot::removeProperties | ( | PropertyProxy * | pp | ) | [virtual] |
Clean property editor
Reimplemented from SciFigs::XYPlot.
References _tabPalette, QGpGuiTools::PropertyProxy::removeTab(), and TRACE.
{ TRACE; XYPlot::removeProperties(pp); pp->removeTab(_tabPalette, this); }
void SciFigs::XYValuePlot::setLinearPalette | ( | double | minVal, |
double | maxVal | ||
) |
Set a linear scale on palette. Safe for painting threads. For other modification of the palette see setPalette().
References _pal, palette(), paletteChanged(), QGpGuiTools::ColorPalette::setVLinear(), and TRACE.
Referenced by addDotPlot().
{ TRACE; LayerLocker ll(this); _pal.setVLinear(minVal, maxVal); emit paletteChanged(palette()); }
void SciFigs::XYValuePlot::setLogPalette | ( | double | minVal, |
double | maxVal | ||
) |
Set a log scale on palette. Safe for painting threads. For other modification of the palette see setPalette().
References _pal, palette(), paletteChanged(), QGpGuiTools::ColorPalette::setVLog(), and TRACE.
Referenced by MonoStation::AbstractSummary::setBubbleValues().
{ TRACE; LayerLocker ll(this); _pal.setVLog(minVal, maxVal); emit paletteChanged(palette()); }
void SciFigs::XYValuePlot::setPalette | ( | const ColorPalette & | pal | ) | [slot] |
Set the palette. Safe for painting threads.
References _pal, SciFigs::GraphContent::deepUpdate(), SciFigs::GraphContentLayer::graphContent(), paletteChanged(), and TRACE.
Referenced by MonoStation::AbstractSummary::createBubbleGraph(), createDotsPlot(), setProperty(), and xml_polishChild().
{ TRACE; // Avoid recurrent loop static bool locked=false; if(!locked) { locked=true; LayerLocker ll(this); _pal=pal; // This layer takes generally time to repaint (useless to repaint only this layer) graphContent()->deepUpdate(); emit paletteChanged(pal); locked=false; } }
void SciFigs::XYValuePlot::setProperty | ( | uint | wid, |
int | pid, | ||
QVariant | val | ||
) | [virtual] |
Reimplemented from SciFigs::XYPlot.
References _tabPalette, SciFigs::PaletteProperties::Palette, and setPalette().
{ if(wid==_tabPalette) { switch(pid) { case PaletteProperties::Palette: setPalette(val.value<ColorPalette>()); break; default: break; } } else { XYPlot::setProperty(wid, pid, val); } }
void SciFigs::XYValuePlot::setValues | ( | QVector< double > * | val | ) |
Set the pointer to value Data
References _values, and TRACE.
Referenced by addDotPlot(), and MonoStation::AbstractSummary::setBubbleValues().
void SciFigs::XYValuePlot::valueRange | ( | double & | min, |
double & | max | ||
) | const |
Get min and maximum of values (usually to adjust the palette). It is the responsability of the caller to initialize min and max to 1e99 and -1e99 respectively
References _values, and TRACE.
Referenced by addDotPlot(), and MonoStation::AbstractSummary::setBubbleValues().
XMLMember SciFigs::XYValuePlot::xml_member | ( | XML_MEMBER_ARGS | ) | [protected, virtual] |
Re-implement this function to offer XML restore (children and properties) support to your class.
From tag and map (with contains the attibute value) return a unique identifier under the format of a XMLMember. XMLMember is initialized with 3 types of contructors:
Map of attributes can be inspected in this way (can be achived also in xml_setProperty()):
static const QString tmp("childrenName"); XMLRestoreAttributeIterator it=map.find(tmp); if(it!=map.end()) { // found attribute "childrenName" }
If the map of attributes is not used:
Q_UNUSED(attributes); if(tag=="x1") return XMLMember(0); else if(tag=="y1") return XMLMember(1); else if(tag=="x2") return XMLMember(2); else if(tag=="y2") return XMLMember(3); else return XMLMember(XMLMember::Unknown);
Arithmetic operations + and - apply to XMLMember to avoid confusion of property id numbers between inherited objects. Offset 3 corresponds to the number of properties defined in this object.
if(tag=="anInteger") return XMLMember(0); else if(tag=="aString") return XMLMember(1); else if(tag=="aDouble") return XMLMember(2); return AbstractLine::xml_member(tag, attributes, context)+3;
For the arguments of this function use Macro XML_MEMBER_ARGS.
Reimplemented from SciFigs::GraphContentLayer.
References SciFigs::XMLSciFigs::data(), and TRACE.
{ TRACE; XMLSciFigs * scifigsContext=static_cast<XMLSciFigs *>(context); if(scifigsContext->data()) { if(tag=="ColorPalette") return XMLMember(new ColorPalette, true); } return XYPlot::xml_member(tag, attributes, context); }
void SciFigs::XYValuePlot::xml_polishChild | ( | XML_POLISHCHILD_ARGS | ) | [protected, virtual] |
Reimplemented from QGpCoreTools::XMLClass.
References setPalette().
{ Q_UNUSED(context); if(child->xml_tagName()=="ColorPalette") { ColorPalette * pal=static_cast<ColorPalette *>(child); setPalette( *pal); } }
bool SciFigs::XYValuePlot::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 SciFigs::XYPlot.
References _values, SciFigs::XYPlot::count(), TRACE, and SciFigs::XYPlot::xml_setBinaryData().
{ TRACE; int n; if(XYPlot::xml_setBinaryData(s, context) && (n=count())>0) { QVector<double>::iterator it; QVector<double>::iterator itEnd; _values=new QVector<double>; _values->resize(n); itEnd=_values->end(); for(it=_values->begin();it!=itEnd;++it) s >> *it; } return true; }
virtual const QString& SciFigs::XYValuePlot::xml_tagName | ( | ) | const [inline, virtual] |
Reimplemented from SciFigs::XYPlot.
{return xmlXYValuePlotTag;}
void SciFigs::XYValuePlot::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 SciFigs::XYPlot.
References _values, and TRACE.
{ TRACE; XYPlot::xml_writeBinaryData(s, context); QVector<double>::iterator it; QVector<double>::iterator itEnd; itEnd=_values->end(); for(it=_values->begin();it!=itEnd;++it) s << *it; }
void SciFigs::XYValuePlot::xml_writeChildren | ( | XML_WRITECHILDREN_ARGS | ) | const [protected, virtual] |
Reimplemented from QGpCoreTools::XMLClass.
References _pal, SciFigs::XMLSciFigs::data(), TRACE, and QGpCoreTools::XMLClass::xml_save().
ColorPalette SciFigs::XYValuePlot::_pal [protected] |
Referenced by paintData(), setLinearPalette(), setLogPalette(), setPalette(), xml_writeChildren(), and XYValuePlot().
uint SciFigs::XYValuePlot::_tabPalette = PropertyProxy::uniqueId() [static, protected] |
Referenced by addProperties(), properties(), removeProperties(), and setProperty().
QVector<double>* SciFigs::XYValuePlot::_values [protected] |
Referenced by paintData(), setValues(), valueRange(), xml_setBinaryData(), xml_writeBinaryData(), XYValuePlot(), and ~XYValuePlot().
const QString SciFigs::XYValuePlot::xmlXYValuePlotTag = "XYValuePlot" [static] |