27 #include "../../../dataaccess/dataset/DataSet.h" 28 #include "../../../dataaccess/dataset/ObjectId.h" 29 #include "../../../dataaccess/dataset/ObjectIdSet.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/Utils.h" 35 #include "../../../maptools/CanvasConfigurer.h" 36 #include "../../../maptools/Utils.h" 37 #include "../../../se/Rule.h" 38 #include "../../../se/Style.h" 39 #include "../../../se/Symbolizer.h" 40 #include "../../../srs/Config.h" 41 #include "../../widgets/canvas/Canvas.h" 42 #include "../../widgets/canvas/EyeBirdMapDisplayWidget.h" 43 #include "../../widgets/canvas/MapDisplay.h" 44 #include "../../widgets/canvas/ZoomInMapDisplayWidget.h" 45 #include "../../widgets/layer/explorer/LayerItemView.h" 46 #include "../../widgets/tools/AbstractTool.h" 47 #include "../../widgets/tools/CoordTracking.h" 48 #include "../../widgets/tools/PanMiddleClick.h" 49 #include "../../widgets/tools/ZoomWheel.h" 50 #include "../../widgets/Utils.h" 51 #include "../events/ApplicationEvents.h" 52 #include "../events/LayerEvents.h" 53 #include "../events/MapEvents.h" 54 #include "../events/TableEvents.h" 56 #include "../events/ToolEvents.h" 57 #include "../ApplicationController.h" 64 #include <QContextMenuEvent> 65 #include <QMessageBox> 77 m_currentExtentIndex(-1),
78 m_extentStackMaxSize(5),
79 m_coordTracking(nullptr),
82 m_zoomInDisplay(nullptr),
83 m_eyeBirdDisplay(nullptr),
84 m_autoPanEnabled(false)
150 case QEvent::ContextMenu:
154 if (
m_menu->objectName() ==
"Map")
155 m_menu->exec(static_cast<QContextMenuEvent*>(e)->globalPos());
175 std::list<te::map::AbstractLayerPtr> visibleLayers;
200 std::list<te::map::AbstractLayerPtr> empty;
237 std::list<te::map::AbstractLayerPtr> visibleLayers;
262 std::list<te::map::AbstractLayerPtr> visibleLayers;
265 if (visibleLayers.empty())
268 bool hasSelectedObjs =
false;
269 for (
auto i : visibleLayers)
273 if (idSet && (i->getSelected()->size() > 0))
275 hasSelectedObjs =
true;
280 if (!hasSelectedObjs)
294 double halfWidth = displayExtent.
getWidth() * 0.5;
295 double halfHeight = displayExtent.
getHeight() * 0.5;
299 newExtent.
m_llx = centerOfSelectedExtent.
x - halfWidth;
300 newExtent.
m_lly = centerOfSelectedExtent.
y - halfHeight;
302 newExtent.
m_urx = centerOfSelectedExtent.
x + halfWidth;
303 newExtent.
m_ury = centerOfSelectedExtent.
y + halfHeight;
344 content->fill(Qt::transparent);
346 QPainter painter(content);
426 std::list<te::map::AbstractLayerPtr>::const_iterator it;
427 for(it = layers.begin(); it != layers.end(); ++it)
440 std::unique_ptr<te::da::DataSetType> dsType = layer->getSchema();
442 if(!dsType.get() || !dsType->hasGeom())
447 if(oids ==
nullptr || oids->
size() == 0)
452 std::size_t maxOids = 4000;
454 if(oids->
size() > maxOids)
459 std::size_t nOids = 0;
462 std::size_t nProcessedOids = 0;
464 std::set<te::da::ObjectId*, te::common::LessCmp<te::da::ObjectId*> >::const_iterator it;
465 for(it = oids->
begin(); it != oids->
end(); ++it)
468 oidsBatch->add((*it)->clone());
473 if(nProcessedOids == maxOids || nOids == oids->
size())
476 std::unique_ptr<te::da::DataSet> selected(layer->getData(oidsBatch.get()));
478 if (layer->getSelectionStyle())
491 std::unique_ptr<te::da::DataSet> selected(layer->getData(oids->
getExpression()));
493 if (layer->getSelectionStyle())
499 catch(std::exception& e)
501 QMessageBox::critical(
m_display, tr(
"Error"), QString(tr(
"The layer selection cannot be drawn. Details:") +
" %1.").arg(e.what()));
511 assert(color.isValid());
516 bool needRemap =
false;
521 std::size_t gpos = std::string::npos;
524 assert(gpos != std::string::npos);
537 std::set<std::string> highlightedGeoms;
541 std::unique_ptr<te::gm::Geometry> g(dataset->
getGeometry(gpos));
548 if(currentGeomType != g->getGeomTypeId())
550 currentGeomType = g->getGeomTypeId();
556 if(highlightedGeoms.insert(g->asText()).second)
558 canvas.
draw(g.get());
562 canvas.
draw(g.get());
574 bool needRemap =
false;
579 std::size_t gpos = std::string::npos;
582 assert(gpos != std::string::npos);
600 const std::vector<te::se::Symbolizer*>& symbolizers = rule->
getSymbolizers();
602 if (symbolizers.empty())
612 std::set<std::string> highlightedGeoms;
616 if (dataset->
isNull(gpos))
619 std::unique_ptr<te::gm::Geometry> g(dataset->
getGeometry(gpos));
628 if (highlightedGeoms.insert(g->asText()).second)
630 canvas.
draw(g.get());
634 canvas.
draw(g.get());
646 m_currentExtentIndex += 1;
667 std::pair<int, std::string> srid(layer->getSRID(),
"EPSG");
673 std::list<te::map::AbstractLayerPtr>::const_iterator it;
675 for(it = layers.begin(); it != layers.end(); ++it)
684 std::pair<int, std::string> srid(layer->getSRID(),
"EPSG");
699 std::list<te::map::AbstractLayerPtr> lst;
709 std::list<te::map::AbstractLayerPtr> layers;
QPixmap m_lastDisplayContent
The last map display content. i.e. a "clean" pixmap.
virtual std::unique_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value.
bool eventFilter(QObject *watched, QEvent *e)
TEQTAFEXPORT QColor GetDefaultDisplayColorFromSettings()
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
std::list< te::map::AbstractLayerPtr > getVisibleLayers()
te::map::AbstractLayerPtr m_layer
Layer selected.
This event is used to get a single layer selected in layer tree.
The Style defines the styling that is to be applied to a geographic dataset (vector geometries or cov...
void drawLayersSelection(const std::list< te::map::AbstractLayerPtr > &layers)
bool isPanToSelectedEnabled()
Returns the pan selected flag;.
void setZoomInDisplay(te::qt::widgets::ZoomInMapDisplayWidget *display)
te::qt::widgets::ZoomWheel * m_zoomWheel
Tool for zoom using the wheel mouse button.
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
void fit(const std::list< te::map::AbstractLayerPtr > &layers)
te::qt::widgets::EyeBirdMapDisplayWidget * m_eyeBirdDisplay
Pointer to a component that represents a eye bird display.
TEDATAACCESSEXPORT bool HasLinkedTable(te::da::DataSetType *type)
It checks if the datasettype has a linked table.
TEMAPEXPORT te::gm::Envelope GetExtent(const std::list< te::map::AbstractLayerPtr > &layers, int srid, bool onlyVisibles)
It calculates the extent of the given layers in the given SRID.
void onCoordTracked(QPointF &coordinate)
A Symbolizer describes how a feature is to appear on a map.
int m_extentStackMaxSize
The max size of the extent stack. Used on previousExtent and nextExtent.
A base class for application events.
te::qt::widgets::MapDisplay * getDisplay()
te::qt::widgets::LayerItemView * m_layerExplorer
QMenu * m_menu
The map display popup menu.
std::vector< te::gm::Envelope > m_extentStack
The stack of MapDisplay extents.
This event indicates that the objects of the given layer must be highlighted.
void hasNextExtent(bool value)
This event signals that the srid of the map display changed.
The base API for TerraLib applications.
TEDATAACCESSEXPORT std::size_t GetPropertyPos(const DataSet *dataset, const std::string &name)
double m_urx
Upper right corner x-coordinate.
void onApplicationTriggered(te::qt::af::evt::Event *e)
Listener to the application framewrork events.
double getWidth() const
It returns the envelope width.
void onDrawLayersFinished(const QMap< QString, QString > &errors)
An utility struct for representing 2D coordinates.
te::qt::widgets::ZoomInMapDisplayWidget * m_zoomInDisplay
Pointer to a component that represents a zoom in display.
This event signals that table has auto pan enabled.
MapDisplay(te::qt::widgets::MapDisplay *display, te::qt::af::ApplicationController *app)
Constructor.
void drawDataSet(te::da::DataSet *dataset, const std::string &geomPropertyName, int srid, const QColor &color, bool isLinked=false)
QAction * m_pantoSelectedAction
Action to enable / disable pan to selected operation.
Rule * getRule(std::size_t i) const
const std::vector< Rule * > & getRules() const
TEMAPEXPORT te::gm::Envelope GetSelectedExtent(const std::list< te::map::AbstractLayerPtr > layers, int srid, bool onlyVisibles)
It calculates the extent of selected objects of the given layers in the given SRID.
virtual bool moveNext()=0
It moves the internal pointer to the next item of the collection.
bool m_redraw
Flag used to indicate if has to redraw the layer.
Coord2D getCenter() const
It returns the rectangle's center coordinate.
virtual void setLayerList(const std::list< te::map::AbstractLayerPtr > &layers)
It sets the layer list to be showed in the Map Display.
QMenu * findMenu(const QString &id) const
Returns the menu registered with key id.
double m_llx
Lower left corner x-coordinate.
te::qt::widgets::CoordTracking * m_coordTracking
Tool for tracking mouse position.
QColor getSelectionColor() const
Returns the application selection color.
A connector of the te::qt::widgets::MapDisplay class to the Application Framework.
void clear()
It clears the map display.
An Envelope defines a 2D rectangular region.
This event signals that the color of the map display changed.
This class represents a set of unique ids created in the same context. i.e. from the same data set...
void hasPreviousExtent(bool value)
te::qt::af::ApplicationController * m_app
Pointer to applicatin controller;.
virtual int getSRID() const
It return the Spatial Reference System used by the Map Display.
std::size_t size() const
It returns the object id set size.
This event can be used to retrieve the MapDisplat component.
TEQTAFEXPORT void GetDPIValuesFromSettings(int &dpiX, int &dpiY)
Load setted dpi X and Y. If there is no configuration to load, it fills dpiX and dpiY with -1...
void pan(const std::list< te::map::AbstractLayerPtr > &layers)
virtual const te::gm::Envelope & getExtent() const
It returns the world extent showned by the MapDisplay.
void draw(const std::list< te::map::AbstractLayerPtr > &layers)
It draws the given layer list.
int m_currentExtentIndex
The current extent index.
bool equals(const Envelope &rhs) const
It returns true if the envelopes are "spatially equal".
const std::vector< Symbolizer * > & getSymbolizers() const
double m_lly
Lower left corner y-coordinate.
Signals a mouse moved over the current display.
A dataset is the unit of information manipulated by the data access module of TerraLib.
This event is used to inform that drawing is finished.
A Rule is used to attach property/scale conditions to and group the individual symbols used for rende...
bool m_autoPanEnabled
Define if auto pan is enabled.
double m_ury
Upper right corner y-coordinate.
std::set< ObjectId *, te::common::LessCmp< ObjectId * > >::const_iterator end() const
Returns an iterator for the object ids in container.
te::da::DataSet * m_dataset
The dataset that represents the objects that must be highlighted.
virtual bool moveBeforeFirst()=0
It moves the internal pointer to a position before the first item in the collection.
void drawLayerSelection(te::map::AbstractLayerPtr layer)
te::qt::widgets::PanMiddleClick * m_pan
Tool for pan using the middle mouse button.
te::se::Style * m_style
The color used to highlight.
virtual bool isNull(std::size_t i) const =0
It checks if the attribute value is NULL.
te::map::AbstractLayer * m_layer
Layer selected.
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
void triggered(te::qt::af::evt::Event *e)
te::qt::af::MapDisplay * m_display
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
std::set< ObjectId *, te::common::LessCmp< ObjectId * > >::const_iterator begin() const
Returns an iterator for the object ids in container.
bool m_redraw
This flag is used to redraw layers after a layers was removed.
double getHeight() const
It returns the envelope height.
Expression * getExpression() const
It returns the expression that can be used to retrieve the data set that contains the all indentified...
void configSRS(const std::list< te::map::AbstractLayerPtr > &layers)
te::qt::widgets::MapDisplay * m_display
Pointer to a component te::qt::widgets::MapDisplay.
bool isValid() const
It tells if the rectangle is valid or not.
std::list< te::map::AbstractLayerPtr > getSelectedLayer()
te::map::AbstractLayerPtr m_layer
The layer whose objects must be highlighted.
TEMAPEXPORT void GetVisibleLayers(const std::list< te::map::AbstractLayerPtr > &layers, std::list< te::map::AbstractLayerPtr > &visibleLayers)
It gets the visible layers of the given layer list.
int getDefaultSRID() const
Returns the most recent project.
void setEyeBirdDisplay(te::qt::widgets::EyeBirdMapDisplayWidget *display)