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*>();
123 m_zoomInDisplay = display;
128 m_eyeBirdDisplay = display;
135 case QEvent::ContextMenu:
137 m_menu->exec(static_cast<QContextMenuEvent*>(e)->globalPos());
155 std::list<te::map::AbstractLayerPtr> visibleLayers;
158 configSRS(visibleLayers);
160 if(!m_display->getExtent().isValid())
163 m_display->setExtent(displayExtent,
false);
166 m_display->setLayerList(layers);
168 m_display->refresh();
171 m_zoomInDisplay->setList(visibleLayers, m_display->getSRID());
174 m_eyeBirdDisplay->setList(visibleLayers, m_display->getSRID());
180 std::list<te::map::AbstractLayerPtr> empty;
181 m_display->setLayerList(empty);
182 m_display->refresh();
190 m_display->installEventFilter(m_tool);
195 if(m_extentStack.empty())
198 if(m_currentExtentIndex < static_cast<int>(m_extentStack.size() - 1))
200 m_currentExtentIndex += 1;
201 m_display->setExtent(m_extentStack[m_currentExtentIndex]);
204 emit hasNextExtent(m_currentExtentIndex < static_cast<int>(m_extentStack.size() - 1));
205 emit hasPreviousExtent(m_currentExtentIndex > 0);
210 if(m_extentStack.empty())
213 if(m_currentExtentIndex > 0)
215 m_currentExtentIndex -= 1;
216 m_display->setExtent(m_extentStack[m_currentExtentIndex]);
219 emit hasNextExtent(m_currentExtentIndex < static_cast<int>(m_extentStack.size() - 1));
220 emit hasPreviousExtent(m_currentExtentIndex > 0);
225 std::list<te::map::AbstractLayerPtr> visibleLayers;
228 configSRS(visibleLayers);
232 m_display->setExtent(displayExtent,
false);
234 m_display->setLayerList(layers);
236 m_display->refresh();
239 m_zoomInDisplay->setList(visibleLayers, m_display->getSRID());
242 m_eyeBirdDisplay->setList(visibleLayers, m_display->getSRID());
251 m_zoomInDisplay->drawCursorPosition(static_cast<double>(coordinate.x()), static_cast<double>(coordinate.ry()));
257 m_lastDisplayContent = QPixmap(*m_display->getDisplayPixmap());
279 if(m_pantoSelectedAction->isChecked() && evt->
m_envelope != 0)
284 if(evt->
m_layer->getSRID() != m_display->getSRID())
294 m_display->setExtent(*env);
298 QPixmap* content = m_display->getDisplayPixmap();
299 content->fill(Qt::transparent);
301 QPainter painter(content);
302 painter.drawPixmap(0, 0, m_lastDisplayContent);
312 drawDataSet(highlightEvent->
m_dataset, highlightEvent->
m_layer->getGeomPropertyName(), highlightEvent->
m_layer->getSRID(), highlightEvent->
m_color);
313 m_display->repaint();
333 m_display->setBackgroundColor(mapColorChanged->
m_color);
334 m_display->refresh();
352 return m_pantoSelectedAction->isChecked();
360 std::list<te::map::AbstractLayerPtr>::const_iterator it;
361 for(it = layers.begin(); it != layers.end(); ++it)
362 drawLayerSelection(*it);
364 m_display->repaint();
374 std::auto_ptr<te::da::DataSetType> dsType = layer->getSchema();
376 if(!dsType->hasGeom())
381 if(oids == 0 || oids->
size() == 0)
386 std::size_t maxOids = 4000;
388 if(oids->
size() > maxOids)
393 std::size_t nOids = 0;
396 std::size_t nProcessedOids = 0;
398 std::set<te::da::ObjectId*, te::common::LessCmp<te::da::ObjectId*> >::const_iterator it;
399 for(it = oids->
begin(); it != oids->
end(); ++it)
402 oidsBatch->add((*it)->clone());
407 if(nProcessedOids == maxOids || nOids == oids->
size())
410 std::auto_ptr<te::da::DataSet> selected(layer->getData(oidsBatch.get()));
422 std::auto_ptr<te::da::DataSet> selected(layer->getData(oids->
getExpression()));
427 catch(std::exception& e)
429 QMessageBox::critical(m_display, tr(
"Error"), QString(tr(
"The layer selection cannot be drawn. Details:") +
" %1.").arg(e.what()));
439 assert(color.isValid());
444 bool needRemap =
false;
449 std::size_t gpos = std::string::npos;
452 assert(gpos != std::string::npos);
454 QPixmap* content = m_display->getDisplayPixmap();
465 std::set<std::string> highlightedGeoms;
469 std::auto_ptr<te::gm::Geometry> g(dataset->
getGeometry(gpos));
473 g->transform(m_display->getSRID());
476 if(currentGeomType != g->getGeomTypeId())
478 currentGeomType = g->getGeomTypeId();
484 if(highlightedGeoms.insert(g->asText()).second)
486 canvas.
draw(g.get());
490 canvas.
draw(g.get());
496 if(!m_extentStack.empty() && m_display->getExtent().equals(m_extentStack[m_currentExtentIndex]))
499 if(m_currentExtentIndex != m_extentStackMaxSize)
501 m_extentStack.push_back(m_display->getExtent());
502 m_currentExtentIndex += 1;
506 m_extentStack.erase(m_extentStack.begin());
507 m_extentStack.push_back(m_display->getExtent());
508 m_currentExtentIndex = m_extentStackMaxSize;
511 emit hasNextExtent(m_currentExtentIndex < static_cast<int>(m_extentStack.size() - 1));
512 emit hasPreviousExtent(m_currentExtentIndex > 0);
523 std::pair<int, std::string> srid(layer->getSRID(),
"EPSG");
529 std::list<te::map::AbstractLayerPtr>::const_iterator it;
531 for(it = layers.begin(); it != layers.end(); ++it)
538 m_display->setSRID(layer->getSRID(),
false);
540 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.