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);
 
   75   if(e->button() != Qt::LeftButton)
 
   78   m_selectionStarted = 
true;
 
   86   if(!m_selectionStarted)
 
   96   m_selectionStarted = 
false;
 
   98   if(e->button() != Qt::LeftButton)
 
  103   m_keepPreviousSelection = 
false;
 
  105   Qt::KeyboardModifiers keys = e->modifiers();
 
  107   if(keys & Qt::ControlModifier || keys & Qt::ShiftModifier)
 
  108     m_keepPreviousSelection = 
true;
 
  110   m_selectionByPointing = 
false;
 
  114     m_selectionByPointing = 
true;
 
  115     QPointF pixelOffset(4.0, 4.0);
 
  116 #if QT_VERSION >= 0x050000 
  117     m_rect = QRectF(e->localPos() - pixelOffset, e->localPos() + pixelOffset);
 
  119     m_rect = QRectF(e->posF() - pixelOffset, e->posF() + pixelOffset);
 
  124   QPointF ll(m_rect.left(), m_rect.bottom());
 
  125   QPointF ur(m_rect.right(), m_rect.top());
 
  126   ll = m_display->transform(ll);
 
  127   ur = m_display->transform(ur);
 
  132   std::list<te::map::AbstractLayerPtr>::iterator it;
 
  133   for(it = m_layers.begin(); it != m_layers.end(); ++it)
 
  134     executeSelection(*it, envelope);
 
  146   if(layer->getVisibility() != 
te::map::VISIBLE || !layer->isValid() || layer->getType() == 
"FOLDERLAYER")
 
  149   std::auto_ptr<te::da::DataSetType> dsType = layer->getSchema();
 
  151   if(!dsType->hasGeom())
 
  157     reprojectedEnvelope.
transform(m_display->getSRID(), layer->getSRID());
 
  160   if(!m_keepPreviousSelection)
 
  162     layer->clearSelected();
 
  163     emit layerSelectedObjectsChanged(layer);
 
  166   if(!reprojectedEnvelope.
intersects(layer->getExtent()))
 
  172     std::auto_ptr<const te::map::LayerSchema> schema(layer->getSchema());
 
  173     if(!schema->hasGeom())
 
  180     assert(dataset.get());
 
  187     std::vector<std::string> pnames;
 
  193     if(m_selectionByPointing == 
false)
 
  195       while(dataset->moveNext())
 
  197         std::auto_ptr<te::gm::Geometry> g(dataset->getGeometry(gp->
getName()));
 
  200           g->setSRID(layer->getSRID());
 
  202         if(!g->intersects(geometryFromEnvelope.get()))
 
  209       oids->setExpressionByIntersection(gp->
getName(), reprojectedEnvelope, layer->getSRID());
 
  217       while(dataset->moveNext())
 
  219         std::auto_ptr<te::gm::Geometry> g(dataset->getGeometry(gp->
getName()));
 
  222           g->setSRID(layer->getSRID());
 
  224         if(g->contains(&point) || g->crosses(geometryFromEnvelope.get()) || geometryFromEnvelope->contains(g.get()))
 
  231       oids->setExpressionByInClause();
 
  239     if(currentOids == 0 || !m_keepPreviousSelection)
 
  242       emit layerSelectedObjectsChanged(layer);
 
  251     layer->clearSelected();
 
  253     layer->select(finalSelected);
 
  255     emit layerSelectedObjectsChanged(layer);
 
  257   catch(std::exception& e)
 
  259     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)
 
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. 
 
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib. 
 
This class represents a set of unique ids created in the same context. i.e. from the same data set...
 
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.