27 #include "../../../core/encoding/CharEncoding.h" 28 #include "../../../common/STLUtils.h" 29 #include "../../../geometry.h" 30 #include "../../../dataaccess/dataset/ObjectId.h" 31 #include "../../../dataaccess/dataset/ObjectIdSet.h" 32 #include "../../../dataaccess/query/In.h" 33 #include "../../../dataaccess/query/LiteralString.h" 34 #include "../../../dataaccess/utils/Utils.h" 35 #include "../../../datatype/AbstractData.h" 36 #include "../../../datatype/SimpleData.h" 37 #include "../../../qt/af/events/LayerEvents.h" 38 #include "../../../qt/af/events/MapEvents.h" 39 #include "../../../qt/widgets/canvas/MapDisplay.h" 40 #include "../../../qt/widgets/Utils.h" 41 #include "../../Feature.h" 42 #include "../../RepositoryManager.h" 43 #include "../../Utils.h" 44 #include "../Renderer.h" 49 #include <QMessageBox> 50 #include <QMouseEvent> 54 #include <QGridLayout> 55 #include <QPushButton> 64 m_restrictivePropertyPos(0),
70 QGridLayout* layout =
new QGridLayout(
m_dialog);
72 m_dialog->setWindowTitle(tr(
"Edit Information"));
82 labels << tr(
"Property") << tr(
"Value");
87 QLayoutItem* layoutItem =
new QSpacerItem(40, 20, QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
88 layout->addItem(layoutItem, 1, 0);
93 layout->addWidget(okPushButton, 1, 1);
94 layout->addWidget(cancelPushButton, 1, 2);
112 if (e->button() != Qt::LeftButton)
142 std::vector<std::string> oidPropertyNames;
163 QPointF pixelOffset(4.0, 4.0);
165 QRectF rect(pos - pixelOffset, pos + pixelOffset);
168 QPointF ll(rect.left(), rect.bottom());
169 QPointF ur(rect.right(), rect.top());
186 catch (std::exception& e)
188 QMessageBox::critical(
m_display, tr(
"Error"), QString(tr(
"The geometry cannot be selected from the layer. Details:") +
" %1.").arg(e.what()));
218 if (g->contains(&point) || g->crosses(geometryFromEnvelope.get()) || geometryFromEnvelope->contains(g.get()))
228 propertyItem->setIcon(0, QIcon::fromTheme(
"geometry"));
237 qvalue = QString::fromUtf8(value.c_str());
247 propertyItem->setText(1, qvalue);
250 propertyItem->setText(1, tr(
""));
256 m_data[pos] = data.release();
270 if (g->contains(&point) || g->crosses(geometryFromEnvelope.get()) || geometryFromEnvelope->contains(g.get()))
272 std::map<std::size_t, te::dt::AbstractData* > ::iterator it;
283 propertyItem->setText(1, QString(it->second->toString().c_str()));
290 propertyItem->setIcon(0, QIcon::fromTheme(
"geometry"));
296 propertyItem->setText(1, qvalue);
312 bool isrestrictive =
false;
318 isrestrictive =
true;
323 Qt::ItemFlags tmp = item->flags();
324 if (column == 1 && !isrestrictive)
325 item->setFlags(tmp | Qt::ItemIsEditable);
326 else if (tmp & Qt::ItemIsEditable)
327 item->setFlags(tmp ^ Qt::ItemIsEditable);
336 return std::unique_ptr<te::dt::AbstractData>(
new te::dt::Int16(atoi(value.toUtf8().data())));
339 return std::unique_ptr<te::dt::AbstractData>(
new te::dt::Int32(atoi(value.toUtf8().data())));
342 return std::unique_ptr<te::dt::AbstractData>(
new te::dt::Int64(atoi(value.toUtf8().data())));
345 return std::unique_ptr<te::dt::AbstractData>(
new te::dt::Float(atof(value.toUtf8().data())));
348 return std::unique_ptr<te::dt::AbstractData>(
new te::dt::Double(atof(value.toUtf8().data())));
351 return std::unique_ptr<te::dt::AbstractData>(
new te::dt::Numeric(value.toUtf8().data()));
354 return std::unique_ptr<te::dt::AbstractData>(
new te::dt::String(value.toUtf8().data()));
357 return std::unique_ptr<te::dt::AbstractData>();
371 for (std::map<std::size_t, te::dt::AbstractData*>::const_iterator it =
m_data.begin(); it !=
m_data.end(); ++it)
377 m_data[it->first] = data.release();
401 draft->fill(Qt::transparent);
virtual std::unique_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value.
virtual const std::string & getId() const
It returns the layer id.
SimpleData< std::string, STRING_TYPE > String
virtual const te::gm::Envelope & getExtent() const
It returns the Layer extent (or minimum bounding box).
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
te::da::ObjectId * getId() const
SimpleData< boost::int64_t, INT64_TYPE > Int64
SimpleData< boost::int32_t, INT32_TYPE > Int32
TEDATAACCESSEXPORT std::size_t GetPropertyPos(const DataSet *dataset, const std::string &name)
te::gm::Geometry * getGeometry() const
SimpleData< float, FLOAT_TYPE > Float
An utility struct for representing 2D coordinates.
te::edit::OperationType getOperationTypeId() const
SimpleData< std::string, NUMERIC_TYPE > Numeric
virtual std::size_t size() const =0
It returns the collection size, if it is known.
virtual bool moveNext()=0
It moves the internal pointer to the next item of the collection.
Coord2D getCenter() const
It returns the rectangle's center coordinate.
TEDATAACCESSEXPORT std::size_t GetFirstSpatialPropertyPos(const te::da::DataSet *dataset)
It returns the first dataset spatial property or NULL if none is found.
static T & getInstance()
It returns a reference to the singleton instance.
A point with x and y coordinate values.
virtual int getPropertyDataType(std::size_t i) const =0
It returns the underlying data type of the property at position pos.
An Envelope defines a 2D rectangular region.
bool within(const Envelope &rhs) const
It returns true if this envelope is "spatially within" the rhs envelope.
virtual int getSRID() const
It return the Spatial Reference System used by the Map Display.
virtual std::unique_ptr< LayerSchema > getSchema() const =0
It returns the layer schema.
TEEDITEXPORT Feature * PickFeature(const te::map::AbstractLayerPtr &layer, const te::gm::Envelope &env, int srid)
TEEDITQTEXPORT QPointF GetPosition(QMouseEvent *e)
virtual const te::gm::Envelope & getExtent() const
It returns the world extent showned by the MapDisplay.
void draw(te::gm::Geometry *geom, bool showVertexes=false)
std::string getValueAsString() const
It gets the properties values used to uniquely identify a data set element as string.
virtual AbstractData * clone() const =0
It returns a clone of this object.
virtual std::string getAsString(std::size_t i, int precision=0) const
Method for retrieving a data value as a string plain representation.
void setData(const std::map< std::size_t, te::dt::AbstractData * > &data)
This is a singleton for rendering geometries and features.
TEDATAACCESSEXPORT void GetOIDPropertyPos(const DataSetType *type, std::vector< std::size_t > &ppos)
virtual std::unique_ptr< te::da::DataSet > getData(te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess) const =0
It gets the dataset identified by the layer name.
virtual std::unique_ptr< te::dt::AbstractData > getValue(std::size_t i) const
Method for retrieving any other type of data value stored in the data source.
void begin(QPaintDevice *device, const te::gm::Envelope &e, int srid)
virtual bool moveBeforeFirst()=0
It moves the internal pointer to a position before the first item in the collection.
SimpleData< double, DOUBLE_TYPE > Double
void drawRepository(const std::string &source, const te::gm::Envelope &e, int srid)
TEDATAACCESSEXPORT void GetOIDPropertyNames(const DataSetType *type, std::vector< std::string > &pnames)
virtual bool isNull(std::size_t i) const =0
It checks if the attribute value is NULL.
virtual int getSRID() const
It returns the Spatial Reference System ID associated to the Layer.
A class that represents the IN operator.
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset.
virtual std::string getPropertyName(std::size_t i) const =0
It returns the property name at position pos.
SimpleData< boost::int16_t, INT16_TYPE > Int16
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
void setPolygonStyle(const QColor &fillColor, const QColor &contourColor, const std::size_t &contourWidth)
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.
bool isValid() const
It tells if the rectangle is valid or not.
virtual std::string getString(std::size_t i) const =0
Method for retrieving a string value attribute.
const std::map< std::size_t, te::dt::AbstractData * > & getData() const
TEGEOMEXPORT Geometry * GetGeomFromEnvelope(const Envelope *const e, int srid)
It creates a Geometry (a polygon) from the given envelope.
This class models a string Literal value.