27 #include "../../../common/STLUtils.h" 28 #include "../../../dataaccess/dataset/DataSet.h" 29 #include "../../../dataaccess/dataset/DataSetType.h" 30 #include "../../../dataaccess/dataset/ObjectIdSet.h" 31 #include "../../../dataaccess/utils/Utils.h" 32 #include "../../../geometry/Coord2D.h" 33 #include "../../../geometry/Geometry.h" 34 #include "../../../geometry/GeometryProperty.h" 35 #include "../../../geometry/Point.h" 36 #include "../../../geometry/Utils.h" 37 #include "../../../srs/Config.h" 38 #include "../canvas/MapDisplay.h" 39 #include "../utils/ScopedCursor.h" 43 #include <QtCore/QString> 45 #include <QMessageBox> 46 #include <QMouseEvent> 56 m_selectionStarted(false),
57 m_keepPreviousSelection(false),
58 m_selectionByPointing(false)
64 m_pen.setColor(QColor(255, 255, 100));
66 m_brush = QColor(255, 255, 100, 80);
73 if(e->button() != Qt::LeftButton)
96 if(e->button() != Qt::LeftButton)
103 Qt::KeyboardModifiers keys = e->modifiers();
105 if(keys & Qt::ControlModifier || keys & Qt::ShiftModifier)
113 QPointF pixelOffset(4.0, 4.0);
114 #if QT_VERSION >= 0x050000 115 m_rect = QRectF(e->localPos() - pixelOffset, e->localPos() + pixelOffset);
117 m_rect = QRectF(e->posF() - pixelOffset, e->posF() + pixelOffset);
130 std::list<te::map::AbstractLayerPtr>::iterator it;
144 if(layer->getVisibility() !=
te::map::VISIBLE || !layer->isValid() || layer->getType() ==
"FOLDERLAYER")
147 std::unique_ptr<te::da::DataSetType> dsType = layer->getSchema();
149 if(!dsType->hasGeom())
160 layer->clearSelected();
164 if(!reprojectedEnvelope.
intersects(layer->getExtent()))
170 std::unique_ptr<const te::map::LayerSchema> schema(layer->getSchema());
171 if(!schema->hasGeom())
178 assert(dataset.get());
185 std::vector<std::string> pnames;
193 while(dataset->moveNext())
195 std::unique_ptr<te::gm::Geometry> g(dataset->getGeometry(gp->
getName()));
197 if(g.get() ==
nullptr)
201 g->setSRID(layer->getSRID());
203 if(!g->intersects(geometryFromEnvelope.get()))
210 oids->setExpressionByIntersection(gp->
getName(), reprojectedEnvelope, layer->getSRID());
218 while(dataset->moveNext())
220 std::unique_ptr<te::gm::Geometry> g(dataset->getGeometry(gp->
getName()));
222 if(g.get() ==
nullptr)
226 g->setSRID(layer->getSRID());
228 if(g->contains(&point) || g->crosses(geometryFromEnvelope.get()) || geometryFromEnvelope->contains(g.get()))
235 oids->setExpressionByInClause();
255 layer->clearSelected();
257 layer->select(finalSelected);
261 catch(std::exception& e)
263 QMessageBox::critical(
m_display, tr(
"Error"), QString(tr(
"The selection cannot be retrieved from the layer. Details:") +
" %1.").arg(e.what()));
TEDATAACCESSEXPORT void GetEmptyOIDSet(const DataSetType *type, ObjectIdSet *&set)
Returns an empty ObjectIdSet, with the definitions of fields that compose it.
bool intersects(const Envelope &rhs) const
It returns true if the envelopes "spatially intersects".
TEDATAACCESSEXPORT ObjectId * GenerateOID(DataSet *dataset, const std::vector< std::string > &names)
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
An utility struct for representing 2D coordinates.
Coord2D getCenter() const
It returns the rectangle's center coordinate.
A point with x and y coordinate values.
An Envelope defines a 2D rectangular region.
This class represents a set of unique ids created in the same context. i.e. from the same data set...
virtual int getSRID() const
It return the Spatial Reference System used by the Map Display.
void symDifference(const ObjectIdSet *rhs)
It performs the symmetric difference operation between this ObjectIdSet and the given ObjectIdSet...
TEDATAACCESSEXPORT void GetOIDPropertyNames(const DataSetType *type, std::vector< std::string > &pnames)
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
void transform(int oldsrid, int newsrid)
It will transform the coordinates of the Envelope from the old SRS to the new one.
ObjectIdSet * clone() const
This class implements a concrete tool to select layer features using an extent.
TEGEOMEXPORT Geometry * GetGeomFromEnvelope(const Envelope *const e, int srid)
It creates a Geometry (a polygon) from the given envelope.
const std::string & getName() const
It returns the property name.