A GridViewer is a layer to plot a 2D regular grid. More...
#include <GridViewer.h>
Signals | |
void | clicked (int ix, int iy) |
Public Member Functions | |
virtual Rect | boundingRect () const |
GridViewer (AxisWindow *parent=0) | |
virtual bool | mouseReleaseEvent (QMouseEvent *e, int) |
void | setGrid (Grid2D< double > *grid) |
virtual bool | trackRectangle (int, double rx1, double ry1, double rx2, double ry2, Qt::KeyboardModifiers m) |
virtual const QString & | xml_tagName () const |
~GridViewer () | |
Static Public Attributes | |
static const QString | xmlGridViewerTag = "GridViewer" |
Protected Member Functions | |
virtual void | paintData (const LayerPainterRequest &lp, QPainter &p, double dotpercm) const |
virtual XMLMember | xml_member (XML_MEMBER_ARGS) |
virtual void | xml_writeChildren (XML_WRITECHILDREN_ARGS) const |
Protected Attributes | |
Grid2D< double > * | _grid |
A GridViewer is a layer to plot a 2D regular grid.
SciFigs::GridViewer::GridViewer | ( | AxisWindow * | parent = 0 | ) |
Rect SciFigs::GridViewer::boundingRect | ( | ) | const [virtual] |
Implements SciFigs::GraphContentLayer.
References _grid, QGpCoreTools::Grid2D< ValueType >::east(), QGpCoreTools::Grid2D< ValueType >::north(), QGpCoreTools::Grid2D< ValueType >::nx(), QGpCoreTools::Grid2D< ValueType >::ny(), QGpCoreTools::Grid2D< ValueType >::south(), TRACE, and QGpCoreTools::Grid2D< ValueType >::west().
void SciFigs::GridViewer::clicked | ( | int | ix, |
int | iy | ||
) | [signal] |
Referenced by mouseReleaseEvent().
bool SciFigs::GridViewer::mouseReleaseEvent | ( | QMouseEvent * | e, |
int | |||
) | [virtual] |
Reimplemented from SciFigs::GraphContentLayer.
References _grid, clicked(), SciFigs::GraphContentLayer::graphContent(), QGpCoreTools::Grid2D< ValueType >::indexOfX(), QGpCoreTools::Grid2D< ValueType >::indexOfY(), SciFigs::GraphContent::options(), SciFigs::GraphContentOptions::s2r2D(), TRACE, QGpCoreTools::Point2D::x(), and QGpCoreTools::Point2D::y().
void SciFigs::GridViewer::paintData | ( | const LayerPainterRequest & | lp, |
QPainter & | p, | ||
double | dotpercm | ||
) | const [protected, virtual] |
void SciFigs::GridViewer::setGrid | ( | Grid2D< double > * | grid | ) |
bool SciFigs::GridViewer::trackRectangle | ( | int | , |
double | rx1, | ||
double | ry1, | ||
double | rx2, | ||
double | ry2, | ||
Qt::KeyboardModifiers | m | ||
) | [virtual] |
Reimplemented from SciFigs::GraphContentLayer.
References SciFigs::GridPlot::_fillType, SciFigs::GridPlot::_fillValue, _grid, QGpCoreTools::Grid2D< ValueType >::coordinates(), SciFigs::GraphContent::deepUpdate(), SciFigs::GraphContentLayer::graphContent(), QGpCoreTools::Rect::includes(), QGpCoreTools::Grid2D< ValueType >::nx(), QGpCoreTools::Grid2D< ValueType >::ny(), QGpCoreTools::Grid2D< ValueType >::setValue(), and TRACE.
{ TRACE; Rect r(rx1, ry1, rx2, ry2); int nx=_grid->nx(), ny=_grid->ny(); for(int iy=0;iy < ny;iy++ ) { for(int ix=0;ix < nx;ix++ ) { Point2D p=_grid->coordinates(ix, iy); if(r.includes(p, _fillType) ) _grid->setValue(ix, iy, _fillValue); } } graphContent() ->deepUpdate(); return true; }
XMLMember SciFigs::GridViewer::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::GridPlot.
References _grid, SciFigs::XMLSciFigs::data(), and TRACE.
{ TRACE; XMLSciFigs * scifigsContext=static_cast<XMLSciFigs *>(context); if(scifigsContext->data()) { if(tag=="Grid2D") return XMLMember(_grid); } return GridPlot::xml_member(tag, attributes, context); }
virtual const QString& SciFigs::GridViewer::xml_tagName | ( | ) | const [inline, virtual] |
Reimplemented from SciFigs::GridPlot.
{return xmlGridViewerTag;}
void SciFigs::GridViewer::xml_writeChildren | ( | XML_WRITECHILDREN_ARGS | ) | const [protected, virtual] |
Reimplemented from SciFigs::GridPlot.
References _grid, SciFigs::XMLSciFigs::data(), TRACE, and QGpCoreTools::XMLClass::xml_save().
{ TRACE; XMLSciFigs * scifigsContext=static_cast<XMLSciFigs *>(context); if(scifigsContext->data()) { _grid->xml_save(s, context); } GridPlot::xml_writeChildren(s, context); }
Grid2D<double>* SciFigs::GridViewer::_grid [protected] |
Referenced by boundingRect(), GridViewer(), mouseReleaseEvent(), paintData(), setGrid(), trackRectangle(), xml_member(), xml_writeChildren(), and ~GridViewer().
const QString SciFigs::GridViewer::xmlGridViewerTag = "GridViewer" [static] |