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/Utils.h"
36 #include "../../../srs/Config.h"
37 #include "../../widgets/canvas/Canvas.h"
38 #include "../../widgets/canvas/EyeBirdMapDisplayWidget.h"
39 #include "../../widgets/canvas/MapDisplay.h"
40 #include "../../widgets/canvas/ZoomInMapDisplayWidget.h"
41 #include "../../widgets/tools/AbstractTool.h"
42 #include "../../widgets/tools/ZoomWheel.h"
43 #include "../../widgets/tools/CoordTracking.h"
44 #include "../../widgets/Utils.h"
45 #include "../events/LayerEvents.h"
46 #include "../events/MapEvents.h"
47 #include "../events/ProjectEvents.h"
48 #include "../events/ToolEvents.h"
49 #include "../ApplicationController.h"
50 #include "../Project.h"
56 #include <QContextMenuEvent>
57 #include <QMessageBox>
69 m_currentExtentIndex(-1),
70 m_extentStackMaxSize(5),
76 connect(coordTracking, SIGNAL(coordTracked(QPointF&)), SLOT(
onCoordTracked(QPointF&)));
77 m_display->installEventFilter(coordTracking);
105 QList<QAction*> acts =
m_menu->findChildren<QAction*>();
124 m_zoomInDisplay = display;
129 m_eyeBirdDisplay = display;
136 case QEvent::ContextMenu:
138 m_menu->exec(static_cast<QContextMenuEvent*>(e)->globalPos());
156 std::list<te::map::AbstractLayerPtr> visibleLayers;
159 configSRS(visibleLayers);
161 if(!m_display->getExtent().isValid())
164 m_display->setExtent(displayExtent,
false);
167 m_display->setLayerList(layers);
169 m_display->refresh();
172 m_zoomInDisplay->setList(visibleLayers, m_display->getSRID());
175 m_eyeBirdDisplay->setList(visibleLayers, m_display->getSRID());
181 std::list<te::map::AbstractLayerPtr> empty;
182 m_display->setLayerList(empty);
183 m_display->refresh();
191 m_display->installEventFilter(m_tool);
196 if(m_extentStack.empty())
199 if(m_currentExtentIndex < static_cast<int>(m_extentStack.size() - 1))
201 m_currentExtentIndex += 1;
202 m_display->setExtent(m_extentStack[m_currentExtentIndex]);
205 emit hasNextExtent(m_currentExtentIndex < static_cast<int>(m_extentStack.size() - 1));
206 emit hasPreviousExtent(m_currentExtentIndex > 0);
211 if(m_extentStack.empty())
214 if(m_currentExtentIndex > 0)
216 m_currentExtentIndex -= 1;
217 m_display->setExtent(m_extentStack[m_currentExtentIndex]);
220 emit hasNextExtent(m_currentExtentIndex < static_cast<int>(m_extentStack.size() - 1));
221 emit hasPreviousExtent(m_currentExtentIndex > 0);
226 std::list<te::map::AbstractLayerPtr> visibleLayers;
229 configSRS(visibleLayers);
233 m_display->setExtent(displayExtent,
false);
235 m_display->setLayerList(layers);
237 m_display->refresh();
240 m_zoomInDisplay->setList(visibleLayers, m_display->getSRID());
243 m_eyeBirdDisplay->setList(visibleLayers, m_display->getSRID());
252 m_zoomInDisplay->drawCursorPosition(static_cast<double>(coordinate.x()), static_cast<double>(coordinate.ry()));
258 m_lastDisplayContent = QPixmap(*m_display->getDisplayPixmap());
280 if(m_pantoSelectedAction->isChecked() && evt->
m_envelope != 0)
285 if(evt->
m_layer->getSRID() != m_display->getSRID())
295 m_display->setExtent(*env);
299 QPixmap* content = m_display->getDisplayPixmap();
300 content->fill(Qt::transparent);
302 QPainter painter(content);
303 painter.drawPixmap(0, 0, m_lastDisplayContent);
313 drawDataSet(highlightEvent->
m_dataset, highlightEvent->
m_layer->getGeomPropertyName(), highlightEvent->
m_layer->getSRID(), highlightEvent->
m_color);
314 m_display->repaint();
334 m_display->setBackgroundColor(mapColorChanged->
m_color);
335 m_display->refresh();
353 return m_pantoSelectedAction->isChecked();
361 std::list<te::map::AbstractLayerPtr>::const_iterator it;
362 for(it = layers.begin(); it != layers.end(); ++it)
363 drawLayerSelection(*it);
365 m_display->repaint();
375 std::auto_ptr<te::da::DataSetType> dsType = layer->getSchema();
377 if(!dsType->hasGeom())
382 if(oids == 0 || oids->
size() == 0)
387 std::size_t maxOids = 4000;
389 if(oids->
size() > maxOids)
394 std::size_t nOids = 0;
397 std::size_t nProcessedOids = 0;
399 std::set<te::da::ObjectId*, te::common::LessCmp<te::da::ObjectId*> >::const_iterator it;
400 for(it = oids->
begin(); it != oids->
end(); ++it)
403 oidsBatch->add((*it)->clone());
408 if(nProcessedOids == maxOids || nOids == oids->
size())
411 std::auto_ptr<te::da::DataSet> selected(layer->getData(oidsBatch.get()));
423 std::auto_ptr<te::da::DataSet> selected(layer->getData(oids->
getExpression()));
428 catch(std::exception& e)
430 QMessageBox::critical(m_display, tr(
"Error"), QString(tr(
"The layer selection cannot be drawn. Details:") +
" %1.").arg(e.what()));
440 assert(color.isValid());
445 bool needRemap =
false;
450 std::size_t gpos = std::string::npos;
453 assert(gpos != std::string::npos);
455 QPixmap* content = m_display->getDisplayPixmap();
466 std::set<std::string> highlightedGeoms;
470 std::auto_ptr<te::gm::Geometry> g(dataset->
getGeometry(gpos));
474 g->transform(m_display->getSRID());
477 if(currentGeomType != g->getGeomTypeId())
479 currentGeomType = g->getGeomTypeId();
485 if(highlightedGeoms.insert(g->asText()).second)
487 canvas.
draw(g.get());
491 canvas.
draw(g.get());
497 if(!m_extentStack.empty() && m_display->getExtent().equals(m_extentStack[m_currentExtentIndex]))
500 if(m_currentExtentIndex != m_extentStackMaxSize)
502 m_extentStack.push_back(m_display->getExtent());
503 m_currentExtentIndex += 1;
507 m_extentStack.erase(m_extentStack.begin());
508 m_extentStack.push_back(m_display->getExtent());
509 m_currentExtentIndex = m_extentStackMaxSize;
512 emit hasNextExtent(m_currentExtentIndex < static_cast<int>(m_extentStack.size() - 1));
513 emit hasPreviousExtent(m_currentExtentIndex > 0);
524 std::pair<int, std::string> srid(layer->getSRID(),
"EPSG");
530 std::list<te::map::AbstractLayerPtr>::const_iterator it;
532 for(it = layers.begin(); it != layers.end(); ++it)
539 m_display->setSRID(layer->getSRID(),
false);
541 std::pair<int, std::string> srid(layer->getSRID(),
"EPSG");
bool eventFilter(QObject *watched, QEvent *e)
TEQTAFEXPORT QColor GetDefaultDisplayColorFromSettings()
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
bool intersects(const Envelope &rhs) const
It returns true if the envelopes "spatially intersects".
void drawLayersSelection(const std::list< te::map::AbstractLayerPtr > &layers)
bool isPanToSelectedEnabled()
Returns the pan selected flag;.
te::map::AbstractLayerPtr m_layer
Layer whose selected objects were changed.
void setZoomInDisplay(te::qt::widgets::ZoomInMapDisplayWidget *display)
void fit(const std::list< te::map::AbstractLayerPtr > &layers)
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 base class for application events.
te::qt::widgets::MapDisplay * getDisplay()
QMenu * m_menu
The map display popup menu.
This event indicates that the objects of the given layer must be highlighted.
This event signals that the srid of the map display changed.
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)
This event indicates that the selected objects of the layer were changed.
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.
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.
double m_llx
Lower left corner x-coordinate.
QColor getSelectionColor() const
Returns the application selection color.
A connector of the te::qt::widgets::MapDisplay class to the Application Framework.
static ApplicationController & getInstance()
It returns a reference to the singleton instance.
void clear()
It clears the map display.
void setCurrentTool(te::qt::widgets::AbstractTool *tool)
Updates the current tool being used on te::qt::widgets::MapDisplay.
An Envelope defines a 2D rectangular region.
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
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...
std::size_t size() const
It returns the object id set size.
This event can be used to retrieve the MapDisplat component.
void draw(const std::list< te::map::AbstractLayerPtr > &layers)
It draws the given layer list.
virtual std::auto_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value.
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.
void broadcast(te::qt::af::evt::Event *evt)
Send events in broadcast for all registered components.
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)
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
QColor m_color
The color used to highlight.
te::qt::af::MapDisplay * m_display
te::gm::Envelope * m_envelope
The box of the last selected object.
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.
std::set< ObjectId *, te::common::LessCmp< ObjectId * > >::const_iterator begin() const
Returns an iterator for the object ids in container.
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.
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.
void setEyeBirdDisplay(te::qt::widgets::EyeBirdMapDisplayWidget *display)
MapDisplay(te::qt::widgets::MapDisplay *display)
Constructor.