27 #include "../../../common/STLUtils.h"
28 #include "../../../dataaccess/dataset/DataSet.h"
29 #include "../../../dataaccess/dataset/DataSetType.h"
30 #include "../../../dataaccess/utils/Utils.h"
31 #include "../../../geometry/Coord2D.h"
32 #include "../../../geometry/Envelope.h"
33 #include "../../../geometry/Geometry.h"
34 #include "../../../geometry/GeometryProperty.h"
35 #include "../../../geometry/Point.h"
36 #include "../../../geometry/Utils.h"
37 #include "../../../maptools/MarkRendererManager.h"
38 #include "../../../raster/Raster.h"
39 #include "../../../raster/RasterProperty.h"
40 #include "../../../raster/Utils.h"
41 #include "../../../se/Fill.h"
42 #include "../../../se/Stroke.h"
43 #include "../../../se/Mark.h"
44 #include "../../../se/Utils.h"
45 #include "../../../srs/Config.h"
46 #include "../canvas/Canvas.h"
47 #include "../canvas/MapDisplay.h"
51 #include <QtCore/QPointF>
52 #include <QtCore/QString>
53 #include <QtCore/QStringList>
54 #include <QtGui/QMessageBox>
55 #include <QtGui/QMouseEvent>
64 m_infoWidget(new QTreeWidget(display))
76 labels << tr(
"Property") << tr(
"Value");
82 QPixmap* draft = m_display->getDraftPixmap();
83 draft->fill(Qt::transparent);
85 m_infoWidget->close();
92 if(e->button() != Qt::LeftButton)
98 QPointF pixelOffset(4.0, 4.0);
99 QRectF rect = QRectF(e->posF() - pixelOffset, e->posF() + pixelOffset);
102 QPointF ll(rect.left(), rect.bottom());
103 QPointF ur(rect.right(), rect.top());
104 ll = m_display->transform(ll);
105 ur = m_display->transform(ur);
111 QPixmap* draft = m_display->getDraftPixmap();
112 draft->fill(Qt::transparent);
115 m_infoWidget->clear();
118 std::list<te::map::AbstractLayerPtr>::const_iterator it;
119 for(it = m_layers.begin(); it != m_layers.end(); ++it)
120 getInfo(*it, envelope);
122 if(m_infoWidget->topLevelItemCount() > 0)
124 m_infoWidget->expandAll();
125 m_infoWidget->resizeColumnToContents(0);
126 m_infoWidget->show();
129 m_infoWidget->hide();
131 m_display->repaint();
146 bool needRemap =
false;
151 (layer->getSRID() != m_display->getSRID()))
154 reprojectedEnvelope.
transform(m_display->getSRID(), layer->getSRID());
157 if(!reprojectedEnvelope.
within(layer->getExtent()))
161 QTreeWidgetItem* layerItem =
new QTreeWidgetItem;
162 layerItem->setIcon(0, QIcon::fromTheme(
"layer"));
163 layerItem->setText(0, tr(
"Layer"));
164 layerItem->setText(1, layer->getTitle().c_str());
169 std::auto_ptr<const te::map::LayerSchema> ls(layer->getSchema());
176 std::auto_ptr<te::da::DataSet> dataset(layer->getData(gp->
getName(), &reprojectedEnvelope,
te::gm::INTERSECTS).release());
177 getGeometryInfo(layerItem, dataset.get(), reprojectedEnvelope, layer->getSRID(), needRemap);
185 std::auto_ptr<te::da::DataSet> dataset(layer->getData(rp->
getName(), &reprojectedEnvelope,
te::gm::INTERSECTS).release());
187 if(!dataset->moveNext())
191 assert(rpos != std::string::npos);
193 std::auto_ptr<te::rst::Raster> raster(dataset->getRaster(rpos));
194 assert(raster.get());
196 getRasterInfo(layerItem, raster.get(), reprojectedEnvelope, layer->getSRID(), needRemap);
199 layerItem->childCount() != 0 ? m_infoWidget->addTopLevelItem(layerItem) :
delete layerItem;
222 std::auto_ptr<te::gm::Geometry> g(dataset->
getGeometry(gpos));
224 if(g->contains(&point) || g->crosses(geometryFromEnvelope.get()) || geometryFromEnvelope->contains(g.get()))
232 QTreeWidgetItem* propertyItem =
new QTreeWidgetItem(layerItem);
236 propertyItem->setIcon(0, QIcon::fromTheme(
"geometry"));
239 propertyItem->setText(1, dataset->
getAsString(i, 3).c_str());
241 propertyItem->setText(1,
"");
247 g->transform(m_display->getSRID());
250 drawGeometry(g.get());
270 QTreeWidgetItem* lineItem =
new QTreeWidgetItem(layerItem);
271 lineItem->setText(0, tr(
"Line"));
272 lineItem->setText(1, QString::number(y));
274 QTreeWidgetItem* columnItem =
new QTreeWidgetItem(layerItem);
275 columnItem->setText(0, tr(
"Column"));
276 columnItem->setText(1, QString::number(x));
278 QTreeWidgetItem* coordXItem =
new QTreeWidgetItem(layerItem);
279 coordXItem->setText(0, tr(
"Coordinate X"));
280 coordXItem->setText(1, QString::number(center.
x));
282 QTreeWidgetItem* coordYItem =
new QTreeWidgetItem(layerItem);
283 coordYItem->setText(0, tr(
"Coordinate Y"));
284 coordYItem->setText(1, QString::number(center.
y));
292 QTreeWidgetItem* bandValueItem =
new QTreeWidgetItem(layerItem);
293 bandValueItem->setIcon(0, QIcon::fromTheme(
"channel-gray"));
294 bandValueItem->setText(0, tr(
"Band") +
" " + QString::number(b));
295 bandValueItem->setText(1, QString::number(value));
301 QPixmap* draft = m_display->getDraftPixmap();
349 std::size_t size = 24;
virtual std::string getPropertyName(std::size_t i) const =0
It returns the property name at position pos.
void setPolygonContourColor(const te::color::RGBAColor &color)
It sets the pen color used to draw the boundary of polygon geometries.
TESEEXPORT Fill * CreateFill(const std::string &color, const std::string &opacity)
Creates a fill.
void setLayers(const std::list< te::map::AbstractLayerPtr > &layers)
TEGEOMEXPORT Geometry * GetGeomFromEnvelope(const Envelope *const e, int srid)
It creates a Geometry (a polygon) from the given envelope.
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset.
A Fill specifies the pattern for filling an area geometry.
TERASTEREXPORT int Round(double val)
Round a double value to a integer value.
TEDATAACCESSEXPORT te::rst::RasterProperty * GetFirstRasterProperty(const DataSetType *dt)
void setLineColor(const te::color::RGBAColor &color)
It sets the pen color used to draw line geometries.
unsigned int getNumberOfRows() const
Returns the raster number of rows.
void setPointPattern(te::color::RGBAColor **pattern, int ncols, int nrows)
It sets the point pattern.
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
virtual std::string getAsString(std::size_t i, int precision=0) const
Method for retrieving a data value as a string plain representation.
This class implements a concrete tool to get informations about a specified feature using pointing op...
void setLineWidth(int w)
It sets the line width.
void getInfo(const te::map::AbstractLayerPtr &layer, const te::gm::Envelope &e)
QTreeWidget * m_infoWidget
Widget used to show the informations.
Grid * getGrid()
It returns the raster grid.
This class defines an interface for objects that can receive application events and respond to them...
virtual bool moveNext()=0
It moves the internal pointer to the next item of the collection.
A Stroke specifies the appearance of a linear geometry.
const std::string & getName() const
It returns the property name.
virtual bool isNull(std::size_t i) const =0
It checks if the attribute value is NULL.
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
TESEEXPORT Mark * CreateMark(const std::string &wellKnownName, Stroke *stroke, Fill *fill)
Creates a mark.
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
virtual void getValue(unsigned int c, unsigned int r, double &value, std::size_t b=0) const
Returns the attribute value of a band of a cell.
void setPolygonFillColor(const te::color::RGBAColor &color)
It sets the color used to fill the draw of polygon geometries.
An utility struct for representing 2D coordinates.
#define TE_TRANSPARENT
For an RGBA color this is the value of the alpha-channel for totally transparent. ...
virtual void setCursor(const QCursor &cursor)
void draw(const te::gm::Geometry *geom)
It draws the geometry on canvas.
void getRasterInfo(QTreeWidgetItem *layerItem, te::rst::Raster *raster, const te::gm::Envelope &e, int srid, bool needRemap)
TESEEXPORT Stroke * CreateStroke(const std::string &color, const std::string &width)
Creates a stroke.
double m_lly
Lower left corner y-coordinate.
void drawGeometry(te::gm::Geometry *g)
double m_ury
Upper right corner y-coordinate.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
A canvas built on top of Qt.
virtual int getPropertyDataType(std::size_t i) const =0
It returns the underlying data type of the property at position pos.
A point with x and y coordinate values.
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
Info(MapDisplay *display, const QCursor &cursor, const std::list< te::map::AbstractLayerPtr > &layers, QObject *parent=0)
It constructs a info tool associated with the given map display.
double m_urx
Upper right corner x-coordinate.
A widget to control the display of a set of layers.
GeomType getGeomTypeId() const
It returns the geometry subclass type identifier.
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
Coord2D getCenter() const
It returns the rectangle's center coordinate.
void transform(int oldsrid, int newsrid)
It will transform the coordinates of the Envelope from the old SRS to the new one.
void setRenderHint(QPainter::RenderHint hint, bool on=true)
Sets the given render hint on the canvas painter if on is true; otherwise clears the render hint...
void Free(std::vector< T * > *v)
This function can be applied to a pointer to a vector of pointers.
void setPolygonContourWidth(int w)
It sets the polygon contour width.
void getGeometryInfo(QTreeWidgetItem *layerItem, te::da::DataSet *dataset, const te::gm::Envelope &e, int srid, bool needRemap)
double m_llx
Lower left corner x-coordinate.
An abstract class for raster data strucutures.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
bool within(const Envelope &rhs) const
It returns true if this envelope is "spatially within" the rhs envelope.
static MarkRendererManager & getInstance()
It returns a reference to the singleton instance.
virtual std::auto_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value.
An Envelope defines a 2D rectangular region.
void setWindow(const double &llx, const double &lly, const double &urx, const double &ury)
It sets the world (or window) coordinates area (supposing a cartesian reference system).
void geoToGrid(const double &x, const double &y, double &col, double &row) const
Get the grid point associated to a spatial location.
void setPointColor(const te::color::RGBAColor &color)
It sets the point drawing color.
A dataset is the unit of information manipulated by the data access module of TerraLib.
bool mouseReleaseEvent(QMouseEvent *e)
A Mark specifies a geometric shape and applies coloring to it.