A 2D grid with regular cell sizes. More...
#include <Grid2D.h>
Public Member Functions | |
| void | clear () |
| Point2D | coordinates (int ix, int iy) const |
| double | deltaX () const |
| double | deltaY () const |
| double | east (int ix) const |
| Grid2D () | |
| Grid2D (int nx, int ny) | |
| Grid2D (const Grid2D &m) | |
| int | indexOfX (double x) const |
| int | indexOfY (double y) const |
| void | init (int nx, int ny) |
| void | init (ValueType value) |
| void | init (int nx, int ny, ValueType value) |
| ValueType | maximumValue () const |
| ValueType | minimumValue () const |
| double | north (int iy) const |
| int | nx () const |
| int | ny () const |
| const Point2D & | origin () const |
| void | setDeltaX (double dx) |
| void | setDeltaY (double dy) |
| void | setOrigin (const Point2D &p) |
| void | setValue (int ix, int iy, double val) |
| double | south (int iy) const |
| ValueType | value (int ix, int iy) const |
| ValueType * | valuePointer (int ix, int iy) |
| const ValueType * | valuePointer (int ix, int iy) const |
| double | west (int ix) const |
| double | x (int ix) const |
| virtual const QString & | xml_tagName () const |
| double | y (int iy) const |
| virtual | ~Grid2D () |
Static Public Attributes | |
| static const QString | xmlGrid2DTag = "Grid2D" |
Protected Member Functions | |
| virtual XMLMember | xml_member (XML_MEMBER_ARGS) |
| virtual bool | xml_setBinaryData (XML_SETBINARYDATA_ARGS) |
| virtual bool | xml_setProperty (XML_SETPROPERTY_ARGS) |
| virtual void | xml_writeBinaryData (XML_WRITEBINARYDATA_ARGS) const |
| virtual void | xml_writeProperties (XML_WRITEPROPERTIES_ARGS) const |
A 2D grid with regular cell sizes.
| QGpCoreTools::Grid2D< ValueType >::Grid2D | ( | ) |
| QGpCoreTools::Grid2D< ValueType >::Grid2D | ( | int | nx, |
| int | ny | ||
| ) |
| QGpCoreTools::Grid2D< ValueType >::Grid2D | ( | const Grid2D< ValueType > & | m | ) |
References QGpCoreTools::Grid2D< ValueType >::init(), and TRACE.
| QGpCoreTools::Grid2D< ValueType >::~Grid2D | ( | ) | [virtual] |
| void QGpCoreTools::Grid2D< ValueType >::clear | ( | ) |
| Point2D QGpCoreTools::Grid2D< ValueType >::coordinates | ( | int | ix, |
| int | iy | ||
| ) | const |
| double QGpCoreTools::Grid2D< ValueType >::deltaX | ( | ) | const [inline] |
Referenced by SciFigs::GridPlot::drawGrid2DBlock(), and SciFigs::GridPlot::drawGrid2DYSmooth().
{return _delta.x();}
| double QGpCoreTools::Grid2D< ValueType >::deltaY | ( | ) | const [inline] |
Referenced by SciFigs::GridPlot::drawGrid2DBlock(), and SciFigs::GridPlot::drawGrid2DYSmooth().
{return _delta.y();}
| double QGpCoreTools::Grid2D< ValueType >::east | ( | int | ix | ) | const [inline] |
Referenced by SciFigs::GridViewer::boundingRect(), and SciFigs::GridPlot::drawGridLines().
| int QGpCoreTools::Grid2D< ValueType >::indexOfX | ( | double | x | ) | const [inline] |
Referenced by SciFigs::GridViewer::mouseReleaseEvent().
| int QGpCoreTools::Grid2D< ValueType >::indexOfY | ( | double | y | ) | const [inline] |
Referenced by SciFigs::GridViewer::mouseReleaseEvent().
| void QGpCoreTools::Grid2D< ValueType >::init | ( | int | nx, |
| int | ny | ||
| ) |
References TRACE.
Referenced by QGpCoreTools::Grid2D< ValueType >::Grid2D(), and QGpCoreTools::operator>>().
| void QGpCoreTools::Grid2D< ValueType >::init | ( | ValueType | value | ) |
| void QGpCoreTools::Grid2D< ValueType >::init | ( | int | nx, |
| int | ny, | ||
| ValueType | value | ||
| ) | [inline] |
| ValueType QGpCoreTools::Grid2D< ValueType >::maximumValue | ( | ) | const |
| ValueType QGpCoreTools::Grid2D< ValueType >::minimumValue | ( | ) | const |
| double QGpCoreTools::Grid2D< ValueType >::north | ( | int | iy | ) | const [inline] |
Referenced by SciFigs::GridViewer::boundingRect(), and SciFigs::GridPlot::drawGridLines().
| int QGpCoreTools::Grid2D< ValueType >::nx | ( | ) | const [inline] |
| int QGpCoreTools::Grid2D< ValueType >::ny | ( | ) | const [inline] |
| const Point2D& QGpCoreTools::Grid2D< ValueType >::origin | ( | ) | const [inline] |
Referenced by SciFigs::GridPlot::drawGrid2DBlock(), and SciFigs::GridPlot::drawGrid2DYSmooth().
{return _origin;}
| void QGpCoreTools::Grid2D< ValueType >::setDeltaX | ( | double | dx | ) | [inline] |
| void QGpCoreTools::Grid2D< ValueType >::setDeltaY | ( | double | dy | ) | [inline] |
| void QGpCoreTools::Grid2D< ValueType >::setOrigin | ( | const Point2D & | p | ) | [inline] |
| void QGpCoreTools::Grid2D< ValueType >::setValue | ( | int | ix, |
| int | iy, | ||
| double | val | ||
| ) | [inline] |
Referenced by QGpCoreTools::operator>>(), and SciFigs::GridViewer::trackRectangle().
{_values[ix+_nx*iy]=val;}
| double QGpCoreTools::Grid2D< ValueType >::south | ( | int | iy | ) | const [inline] |
Referenced by SciFigs::GridViewer::boundingRect(), and SciFigs::GridPlot::drawGridLines().
| ValueType QGpCoreTools::Grid2D< ValueType >::value | ( | int | ix, |
| int | iy | ||
| ) | const [inline] |
Referenced by QGpCoreTools::operator>>().
{return _values[ix+_nx*iy];}
| ValueType* QGpCoreTools::Grid2D< ValueType >::valuePointer | ( | int | ix, |
| int | iy | ||
| ) | [inline] |
Referenced by QGpCoreTools::Grid3D< ValueType >::crossSectionX(), QGpCoreTools::Grid3D< ValueType >::crossSectionY(), QGpCoreTools::Grid3D< ValueType >::crossSectionZ(), SciFigs::GridPlot::drawGrid2DBlock(), SciFigs::GridPlot::drawGrid2DYSmooth(), and GeopsyGui::SignalLayer::updateGrid().
{return _values+ix+_nx*iy;}
| const ValueType* QGpCoreTools::Grid2D< ValueType >::valuePointer | ( | int | ix, |
| int | iy | ||
| ) | const [inline] |
{return _values+ix+_nx*iy;}
| double QGpCoreTools::Grid2D< ValueType >::west | ( | int | ix | ) | const [inline] |
Referenced by SciFigs::GridViewer::boundingRect(), and SciFigs::GridPlot::drawGridLines().
| double QGpCoreTools::Grid2D< ValueType >::x | ( | int | ix | ) | const [inline] |
| XMLMember QGpCoreTools::Grid2D< ValueType >::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 QGpCoreTools::XMLClass.
References TRACE, and QGpCoreTools::XMLMember::Unknown.
{
TRACE;
Q_UNUSED(attributes);
Q_UNUSED(context);
if(tag=="origin" ) return XMLMember(0);
else if(tag=="delta" ) return XMLMember(1);
else if(tag=="nx" ) return XMLMember(2);
else if(tag=="ny" ) return XMLMember(3);
return XMLMember(XMLMember::Unknown);
}
| bool QGpCoreTools::Grid2D< ValueType >::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.
References QGpCoreTools::endl(), QGpCoreTools::App::stream(), QGpCoreTools::tr(), and TRACE.
{
TRACE;
Q_UNUSED(context);
int nx, ny;
s >> nx;
s >> ny;
if(nx!=_nx || ny!=ny) {
App::stream() << tr( "Grid2D size in binary file: %1x%2\n"
" in XML data : %3x%4" )
.arg(nx).arg(ny).arg(_nx).arg(_ny) << endl;
_nx=nx;
_ny=ny;
}
init(_nx, _ny);
s.readRawData((char *)_values, sizeof(double)*_nx * _ny);
return true;
}
| bool QGpCoreTools::Grid2D< ValueType >::xml_setProperty | ( | XML_SETPROPERTY_ARGS | ) | [protected, virtual] |
Re-implement this function to offer XML restore properties support to your class.
From memberID set the corresponding property with value content. The map of attributes is given as a supplementary information (not useful in all cases).
For a general case:
Q_UNUSED(attributes); double val=content.toDouble(); switch (memberID) { case 0: _x1=val; return true; case 1: _y1=val; return true; case 2: _x2=val; return true; case 3: _y2=val; return true; default: return false; }
For classes inheriting other classes (see also xml_member())
switch (memberID) { case 0: _anInteger=content.toString(); return true; case 1: _aString=content.toInt(); return true; case 2: _aDouble=content.toDouble(); return true; default: return AbstractLine::xml_setProperty(memberID-3, map, content);
For the arguments of this function use Macro XML_SETPROPERTY_ARGS.
Reimplemented from QGpCoreTools::XMLClass.
References TRACE.
{
TRACE;
Q_UNUSED(tag);
Q_UNUSED(attributes);
Q_UNUSED(context);
switch (memberID) {
case 0: _origin.fromString(content); return true;
case 1:
_delta.fromString(content);
_invDelta.setX(1.0/_delta.x());
_invDelta.setY(1.0/_delta.y());
return true;
case 2: _nx=content.toInt(); return true;
case 3: _ny=content.toInt(); return true;
}
return false;
}
| virtual const QString& QGpCoreTools::Grid2D< ValueType >::xml_tagName | ( | ) | const [inline, virtual] |
Implements QGpCoreTools::XMLClass.
{return xmlGrid2DTag;}
| void QGpCoreTools::Grid2D< ValueType >::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.
References TRACE.
{
TRACE;
Q_UNUSED(context);
s << _nx;
s << _ny;
s.writeRawData((const char *)_values, sizeof(double)*_nx * _ny);
}
| void QGpCoreTools::Grid2D< ValueType >::xml_writeProperties | ( | XML_WRITEPROPERTIES_ARGS | ) | const [protected, virtual] |
Reimplemented from QGpCoreTools::XMLClass.
References TRACE.
{
TRACE;
writeProperty(s, "nx", _nx);
writeProperty(s, "ny", _ny);
writeProperty(s, "origin", _origin.toString());
writeProperty(s, "delta", _delta.toString());
writeBinaryData(s, context);
}
| double QGpCoreTools::Grid2D< ValueType >::y | ( | int | iy | ) | const [inline] |
const QString QGpCoreTools::Grid2D< ValueType >::xmlGrid2DTag = "Grid2D" [static] |