All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MapItem.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file MapItem.cpp
22 
23  \brief
24 
25  \ingroup layout
26 */
27 
28 // TerraLib
29 #include "MapItem.h"
30 #include "../../core/pattern/singleton/Context.h"
31 #include "../../core/AbstractScene.h"
32 #include "../../core/pattern/mvc/ItemModelObservable.h"
33 #include "../../core/pattern/mvc/ItemObserver.h"
34 #include "../../core/pattern/mvc/ItemController.h"
35 #include "../../../color/RGBAColor.h"
36 #include "../../../qt/widgets/Utils.h"
37 #include "../../../geometry/Envelope.h"
38 #include "../../../common/STLUtils.h"
39 #include "../../../qt/widgets/canvas/Canvas.h"
40 #include "../../../dataaccess/utils/Utils.h"
41 #include "../../../dataaccess/dataset/ObjectIdSet.h"
42 #include "../../../qt/widgets/canvas/MultiThreadMapDisplay.h"
43 #include "../../../common/TreeItem.h"
44 #include "../../../srs/Converter.h"
45 #include "../../../maptools/Utils.h"
46 #include "../../item/MapController.h"
47 #include "../../../qt/widgets/tools/Pan.h"
48 #include "../../../qt/widgets/tools/ZoomArea.h"
49 #include "../../../qt/widgets/tools/ZoomClick.h"
50 #include "../core/ItemUtils.h"
51 #include "../../item/MapModel.h"
52 #include "../../../common/StringUtils.h"
53 #include "../../core/enum/Enums.h"
54 #include "../core/Scene.h"
55 #include "../../core/pattern/proxy/AbstractProxyProject.h"
56 
57 // STL
58 #include <vector>
59 #include <memory>
60 
61 // Qt
62 #include <QCursor>
63 #include <QPixmap>
64 #include <QMessageBox>
65 #include <QWidget>
66 #include <QDropEvent>
67 #include <QBoxLayout>
68 #include <QGroupBox>
69 #include <QVBoxLayout>
70 #include <QLabel>
71 #include <QPointer>
72 #include <QDebug>
73 #include <QApplication>
74 #include <QGraphicsSceneMouseEvent>
75 #include <QStyleOptionGraphicsItem>
76 #include <QEvent>
77 #include <QPoint>
78 #include <QMimeData>
79 #include <QColor>
80 
81 #include <QTextEdit>
82 
84  ParentItem<QGraphicsProxyWidget>(controller, o),
85  m_mapDisplay(0),
86  m_grabbedByWidget(false),
87  m_treeItem(0),
88  m_tool(0),
89  m_wMargin(0),
90  m_hMargin(0),
91  m_layer(0),
92  m_changeLayer(false)
93 {
94  m_nameClass = std::string(this->metaObject()->className());
95 
96  Utils* utils = Context::getInstance().getUtils();
97  te::gm::Envelope box;
98 
99  MapModel* model = dynamic_cast<MapModel*>(m_model);
100  if(model)
101  {
102  box = utils->viewportBox(model->getMapBox());
103  }
104  else
105  {
106  box = utils->viewportBox(m_model->getBox());
107  }
108 
109  m_mapSize = QSize(box.getWidth(), box.getHeight());
111  m_mapDisplay->setSynchronous(true);
112  m_mapDisplay->setAcceptDrops(true);
113  m_mapDisplay->setBackgroundColor(Qt::gray);
114  m_mapDisplay->setResizeInterval(0);
115  m_mapDisplay->setMouseTracking(true);
116 
117  connect(m_mapDisplay,SIGNAL(drawLayersFinished(const QMap<QString, QString>&)),
118  this,SLOT(onDrawLayersFinished(const QMap<QString, QString>&)));
119 
120  m_zoomWheel = new te::qt::widgets::ZoomWheel(m_mapDisplay);
121  m_mapDisplay->installEventFilter(m_zoomWheel);
122 
123  setWidget(m_mapDisplay);
124 
126 
127  setWindowFrameMargins(m_wMargin, m_hMargin, m_wMargin, m_hMargin);
128 
129  m_mapDisplay->show();
130 
131  /*
132  MapItem will handle all the events.
133  For example, the event of mouse click on the child item
134  won't be handled by child item.
135  */
136  setHandlesChildEvents(true);
137 }
138 
140 {
141  clearCurrentTool();
142  if(m_zoomWheel)
143  {
144  m_mapDisplay->removeEventFilter(m_zoomWheel);
145  delete m_zoomWheel;
146  m_zoomWheel = 0;
147  }
148 }
149 
151 {
152  if(!m_model)
153  return;
154 
155  Utils* utils = context.getUtils();
156 
157  if(!utils)
158  return;
159 
160  QRectF boundRect;
161  boundRect = boundingRect();
162 
163  te::gm::Envelope box = utils->viewportBox(m_model->getBox());
164 
165  if(!box.isValid())
166  return;
167 
168  MapModel* model = dynamic_cast<MapModel*>(m_model);
169  if(model)
170  {
171  double zoomFactor = Context::getInstance().getZoomFactor();
172 
173  te::gm::Envelope mapBox = utils->viewportBox(model->getMapBox());
174  double w = mapBox.getWidth() * zoomFactor;
175  double h = mapBox.getHeight() * zoomFactor;
176 
177  /* This item ignores the transformations of the scene, so comes with no zoom.
178  His transformation matrix is the inverse scene, understanding the pixel
179  coordinates, and its position can only be given in the scene coordinates(mm).
180  For these reasons, it is necessary to resize it.*/
181  if(w != m_mapDisplay->getWidth()
182  || h != m_mapDisplay->getHeight())
183  {
184  QPointF pt = scenePos();
185  m_mapDisplay->setGeometry(pt.x(), pt.y(), w, h);
186  }
187 
189  QColor qcolor;
190  qcolor.setRed(clr.getRed());
191  qcolor.setGreen(clr.getGreen());
192  qcolor.setBlue(clr.getBlue());
193  qcolor.setAlpha(clr.getAlpha());
194  m_mapDisplay->setBackgroundColor(qcolor);
195  m_mapDisplay->refresh();
196 
197  calculateFrameMargin();
198  }
199 
200  te::color::RGBAColor** rgba = context.getPixmap();
201 
202  if(!rgba)
203  return;
204 
205  QPixmap pixmap;
206  QImage* img = 0;
207 
208  if(rgba)
209  {
210  img = te::qt::widgets::GetImage(rgba, box.getWidth(), box.getHeight());
211  pixmap = QPixmap::fromImage(*img);
212  }
213 
214  te::common::Free(rgba, box.getHeight());
215  if(img)
216  delete img;
217 
218  setPixmap(pixmap);
219  update();
220 }
221 
222 QPointF remapPointToViewport(const QPointF& point, const QRectF& item, const QRectF& widget)
223 {
224  double resX = widget.width() / item.width();
225  double resY = widget.height() / item.height();
226 
227  QMatrix matrix;
228  matrix.scale(resX, -resY);
229  matrix.translate(-item.bottomLeft().x(), -item.bottomLeft().y());
230 
231  QPointF remappedPoint = matrix.map(point);
232  return remappedPoint;
233 }
234 
235 void te::layout::MapItem::paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget /*= 0 */ )
236 {
237  Q_UNUSED( option );
238  Q_UNUSED( widget );
239  if ( !painter )
240  {
241  return;
242  }
243 
244  drawBackground( painter );
245 
246  drawMap(painter);
247 
248  drawBorder(painter);
249 
250  //Draw Selection
251  if (option->state & QStyle::State_Selected)
252  {
253  drawSelection(painter);
254  }
255 }
256 
257 void te::layout::MapItem::drawMap( QPainter * painter )
258 {
259  if(!m_mapDisplay || !painter)
260  return;
261 
262  QRectF boundRect;
263  boundRect = boundingRect();
264 
265  if( m_pixmap.isNull() || m_changeLayer)
266  {
267  m_changeLayer = false;
268 
269  m_pixmap = QPixmap(m_mapDisplay->width(), m_mapDisplay->height());
270  m_pixmap.fill(Qt::transparent);
271 
272  QPainter localPainter(&m_pixmap);
273  m_mapDisplay->render(&localPainter);
274  localPainter.end();
275 
276  QImage image = m_pixmap.toImage();
277  image = image.mirrored();
278 
279  m_pixmap = QPixmap::fromImage(image);
280  }
281 
282  painter->save();
283  painter->setClipRect(boundRect);
284  painter->drawPixmap(boundRect, m_pixmap, m_pixmap.rect());
285 
286  painter->restore();
287 }
288 
289 void te::layout::MapItem::dropEvent( QGraphicsSceneDragDropEvent * event )
290 {
291  //Copy the map from layer tree
292  Qt::DropActions actions = event->dropAction();
293  if(actions != Qt::CopyAction)
294  return;
295 
296  getMimeData(event->mimeData());
297 
298  te::map::AbstractLayerPtr al = m_treeItem->getLayer();
299  te::gm::Envelope e = al->getExtent();
300 
301  std::list<te::map::AbstractLayerPtr> layerList;
302  layerList.push_back(al);
303 
304  m_layer = al;
305 
306  m_mapDisplay->setLayerList(layerList);
307  m_mapDisplay->setSRID(al->getSRID(), false);
308  m_mapDisplay->setExtent(e, true);
309 }
310 
311 void te::layout::MapItem::dragEnterEvent( QGraphicsSceneDragDropEvent * event )
312 {
313  //Copy the map from layer tree
314  Qt::DropActions actions = event->dropAction();
315  if(actions != Qt::CopyAction)
316  return;
317 
318  const QMimeData* mime = event->mimeData();
319  QString s = mime->data("application/x-terralib;value=\"DraggedItems\"").constData();
320  if(s.isEmpty())
321  return;
322 
323  event->acceptProposedAction();
324 }
325 
326 void te::layout::MapItem::dragLeaveEvent( QGraphicsSceneDragDropEvent * event )
327 {
328 }
329 
330 void te::layout::MapItem::dragMoveEvent( QGraphicsSceneDragDropEvent * event )
331 {
332 
333 }
334 
335 void te::layout::MapItem::setPixmap( const QPixmap& pixmap )
336 {
337  m_pixmap = pixmap;
338 }
339 
341 {
342  /* Correctly position the object and change the origin for bottomLeft */
343  double x = 0;
344  double y = 0;
345  MapModel* model = dynamic_cast<MapModel*>(m_model);
346  te::gm::Envelope box;
347  if(model)
348  {
349  box = model->getMapBox();
350  x = model->getDisplacementX() * 2;
351  y = model->getDisplacementY() * 2;
352  }
353  else
354  {
355  box = m_model->getBox();
356  }
357 
358  QPointF posF = scenePos();
359 
360  qreal valuex = posF.x() - x;
361  qreal valuey = posF.y() - y;
362 
363  te::gm::Coord2D coordinate;
364  coordinate.x = valuex;
365  coordinate.y = valuey;
366 
367  return coordinate;
368 }
369 
370 void te::layout::MapItem::mouseMoveEvent( QGraphicsSceneMouseEvent * event )
371 {
373  if(!iUtils)
374  return;
375 
376  if(!iUtils->isCurrentMapTools())
377  {
378  clearCurrentTool();
380  }
381  else
382  {
383  QRectF rect = boundingRect();
384  QPointF point = event->pos();
385  QPointF remappedPoint = remapPointToViewport(point, rect, m_mapDisplay->rect());
386 
387  QMouseEvent mouseEvent(QEvent::MouseMove, remappedPoint.toPoint(),
388  event->button(),event->buttons(), event->modifiers());
389  QApplication::sendEvent(m_mapDisplay, &mouseEvent);
390  event->setAccepted(mouseEvent.isAccepted());
391 
392  this->update();
393  }
394 }
395 
396 void te::layout::MapItem::mousePressEvent( QGraphicsSceneMouseEvent * event )
397 {
399  if(!iUtils)
400  return;
401 
402  if(!iUtils->isCurrentMapTools())
403  {
404  clearCurrentTool();
406  }
407  else
408  {
409  QRectF rect = boundingRect();
410  QPointF point = event->pos();
411  QPointF remappedPoint = remapPointToViewport(point, rect, m_mapDisplay->rect());
412 
413  QMouseEvent mouseEvent(QEvent::MouseButtonPress, remappedPoint.toPoint(),
414  event->button(),event->buttons(), event->modifiers());
415  QApplication::sendEvent(m_mapDisplay, &mouseEvent);
416  event->setAccepted(mouseEvent.isAccepted());
417 
418  this->update();
419  }
420 }
421 
422 void te::layout::MapItem::mouseReleaseEvent( QGraphicsSceneMouseEvent * event )
423 {
425  if(!iUtils)
426  return;
427 
428  if(!iUtils->isCurrentMapTools())
429  {
430  clearCurrentTool();
432  }
433  else
434  {
435  QRectF rect = boundingRect();
436  QPointF point = event->pos();
437  QPointF remappedPoint = remapPointToViewport(point, rect, m_mapDisplay->rect());
438 
439  QMouseEvent mouseEvent(QEvent::MouseButtonRelease, remappedPoint.toPoint(),
440  event->button(),event->buttons(), event->modifiers());
441  QApplication::sendEvent(m_mapDisplay, &mouseEvent);
442  event->setAccepted(mouseEvent.isAccepted());
443 
444  this->update();
445  }
446  refresh();
447 }
448 
449 void te::layout::MapItem::getMimeData( const QMimeData* mime )
450 {
451  QString s = mime->data("application/x-terralib;value=\"DraggedItems\"").constData();
452  unsigned long v = s.toULongLong();
453  std::vector<te::qt::widgets::AbstractTreeItem*>* draggedItems = reinterpret_cast<std::vector<te::qt::widgets::AbstractTreeItem*>*>(v);
454 
455  if(draggedItems->empty())
456  return;
457 
458  m_treeItem = draggedItems->operator[](0);
459 }
460 
461 std::list<te::map::AbstractLayerPtr> te::layout::MapItem::getVisibleLayers()
462 {
463  std::list<te::map::AbstractLayerPtr> visibleLayers;
464 
465  if(!m_treeItem)
466  return visibleLayers;
467 
468  te::map::AbstractLayerPtr al = m_treeItem->getLayer();
469 
470  if(al.get() == 0)
471  return visibleLayers;
472 
473  std::list<te::map::AbstractLayerPtr> vis;
474  te::map::GetVisibleLayers(al, vis);
475  // remove folders
476  std::list<te::map::AbstractLayerPtr>::iterator vit;
477  for(vit = vis.begin(); vit != vis.end(); ++vit)
478  {
479  if((*vit)->getType() == "DATASETLAYER" ||
480  (*vit)->getType() == "QUERYLAYER" ||
481  (*vit)->getType() == "RASTERLAYER")
482  {
483  visibleLayers.push_front(*vit);
484  }
485  }
486 
487  return visibleLayers;
488 }
489 
491 {
493 
494  if(!m_treeItem)
495  return layer;
496 
497  layer = m_treeItem->getLayer();
498 
499  return layer;
500 }
501 
502 void te::layout::MapItem::onDrawLayersFinished( const QMap<QString, QString>& errors )
503 {
504  if(!errors.empty())
505  return;
506 
507  te::map::AbstractLayerPtr layer = getLayer();
508 
509  if(!m_controller)
510  return;
511 
512  MapController* controller = dynamic_cast<MapController*>(m_controller);
513  if(controller)
514  {
515  bool result = controller->refreshLayer(layer);
516  if(result)
517  {
518  redraw();
519  }
520  }
521 
522  generateMapPixmap();
523 
524  m_changeLayer = true;
525 
526  update();
527 }
528 
530 {
531  m_tool = tool;
532 
533  m_mapDisplay->installEventFilter(m_tool);
534 }
535 
537 {
538  if(m_tool)
539  {
540  m_mapDisplay->removeEventFilter(m_tool);
541 
542  delete m_tool;
543  m_tool = 0;
544  }
545 }
546 
548 {
549  clearCurrentTool();
550 
552 
554  if(mode == type->getModeMapPan())
555  {
556  te::qt::widgets::Pan* pan = new te::qt::widgets::Pan(m_mapDisplay, Qt::OpenHandCursor, Qt::ClosedHandCursor);
557  setCurrentTool(pan);
558  }
559  if(mode == type->getModeMapZoomIn())
560  {
561  //Zoom In
562  std::string icon_path_zoom_area = "layout-map-zoom-in";
563  QCursor zoomAreaCursor(QIcon::fromTheme(icon_path_zoom_area.c_str()).pixmap(QSize(10,10)));
564  te::qt::widgets::ZoomArea* zoomArea = new te::qt::widgets::ZoomArea(m_mapDisplay, zoomAreaCursor);
565  setCurrentTool(zoomArea);
566  }
567  if(mode == type->getModeMapZoomOut())
568  {
569  //Zoom Out
570  std::string icon_path_zoom_out = "layout-map-zoom-out";
571  QCursor zoomOutCursor(QIcon::fromTheme(icon_path_zoom_out.c_str()).pixmap(QSize(10,10)));
572  te::qt::widgets::ZoomClick* zoomOut = new te::qt::widgets::ZoomClick(m_mapDisplay, zoomOutCursor, 2.0, te::qt::widgets::Zoom::Out);
573  setCurrentTool(zoomOut);
574  }
575 }
576 
578 {
579  te::color::RGBAColor** teImg = 0;
580 
581  QImage img = m_pixmap.toImage();
582  img = img.mirrored();
583 
584  if(img.isNull())
585  {
586  return teImg;
587  }
588 
589  w = img.width();
590  h = img.height();
591 
592  teImg = te::qt::widgets::GetImage(&img);
593  return teImg;
594 }
595 
597 {
598  QColor color(0, 0, 255, 0);
599 
600  QImage generator(m_pixmap.width(), m_pixmap.height(), QImage::Format_ARGB32);
601  generator.fill(color);
602 
603  QPainter painter;
604  painter.begin(&generator);
605 
606  QPoint pt(m_wMargin, m_hMargin);
607  widget()->render(&painter, pt);
608 
609  if(!m_pixmap.isNull())
610  {
611  QRectF rectF(0, 0, m_pixmap.width(), m_pixmap.height());
612  painter.save();
613  painter.drawPixmap(rectF, m_pixmap, rectF);
614  painter.restore();
615  generator.mirrored();
616  }
617 
618  painter.end();
619  return generator;
620 }
621 
623 {
624  MapModel* model = dynamic_cast<MapModel*>(m_model);
625  if(!model)
626  return;
627 
628  Utils* utils = Context::getInstance().getUtils();
629 
630  if(!utils)
631  return;
632 
633  te::gm::Envelope box = utils->viewportBox(m_model->getBox());
634  te::gm::Envelope mapBox = utils->viewportBox(model->getMapBox());
635 
636  m_wMargin = (box.getWidth() - mapBox.getWidth()) / 2.;
637  m_hMargin = (box.getHeight() - mapBox.getHeight()) / 2.;
638 }
639 
641 {
642  QRegion srcRegion( 0, 0, this->widget()->width(), this->widget()->height());
643 
644  QColor color(255, 255, 255, 0);
645  QPixmap img(this->widget()->width(), this->widget()->height());
646  img.fill(Qt::transparent);
647 
648  QPainter ptr(&img);
649  QPoint pt(0, 0);
650  this->widget()->render(&ptr, pt, srcRegion);
651 
652  m_mapPixmap = img;
653 }
654 
656 {
657 
658  MapModel* model = dynamic_cast<MapModel*>(m_model);
659  if(!model)
660  return;
661 
662  if(!m_controller)
663  return;
664 
665  model->updateProperties(properties);
666  redraw();
667 
668  if(model->isLoadedLayer())
669  {
670  redraw();
671  return;
672  }
673 
674  std::string name = model->getNameLayer();
675 
676  if(name.compare("") == 0)
677  return;
678 
680  if(!project)
681  return;
682 
683  te::map::AbstractLayerPtr layer = project->contains(name);
684  m_mapDisplay->changeData(layer);
685 
686  MapController* controller = dynamic_cast<MapController*>(m_controller);
687  if(!controller)
688  return;
689 
690  bool result = controller->refreshLayer(layer);
691  if(result)
692  {
693  redraw();
694  }
695 }
696 
697 void te::layout::MapItem::changeZoomFactor( double currentZoomFactor )
698 {
699  QSize currentSize = m_mapDisplay->size();
700  QSize newSize = m_mapSize * currentZoomFactor;
701  if(currentSize != newSize)
702  {
703  QPointF pt = scenePos();
704  //QWidget::resize(): causes the component return to starting position
705  m_mapDisplay->setGeometry(pt.x(), pt.y(), newSize.width(), newSize.height());
706  m_changeLayer = true;
707  }
708 }
709 
711 {
712  MapModel* model = dynamic_cast<MapModel*>(m_model);
713  te::gm::Envelope box = model->getBox();
714 
715  if(m_rect.width() != box.getWidth()
716  || m_rect.height() != box.getHeight())
717  {
718  prepareGeometryChange();
719  m_rect = QRectF(0., 0., box.getWidth(), box.getHeight());
720 
721  //update model
722  te::gm::Envelope env(m_model->getBox());
723  env.m_urx = env.m_llx + m_rect.width();
724  env.m_ury = env.m_lly + m_rect.height();
725  m_controller->setBox(env);
726  }
727 }
728 
730 {
731  MapModel* model = dynamic_cast<MapModel*>(m_model);
732  te::gm::Envelope box = model->getBox();
733 
734  QRectF rect(0., 0., box.getWidth(), box.getHeight());
735  return rect;
736 }
737 
738 
739 
740 
741 
742 
743 
virtual void updateObserver(ContextItem context)
Reimplemented from ItemObserver.
Definition: MapItem.cpp:150
Abstract class to represent an observable. "Model" part of MVC component.
Definition: Observable.h:56
virtual ~MapItem()
Destructor.
Definition: MapItem.cpp:139
virtual void getMimeData(const QMimeData *mime)
Definition: MapItem.cpp:449
Class responsible for maintaining the drawing context of a MVC component. It is always used by the "M...
Definition: ContextItem.h:49
virtual bool isLoadedLayer()
Definition: MapModel.cpp:585
virtual std::string getNameLayer()
Definition: MapModel.cpp:580
virtual double getDisplacementX()
Definition: MapModel.cpp:409
virtual te::color::RGBAColor ** getRGBAColorImage(int &w, int &h)
Reimplemented from ItemObserver.
Definition: MapItem.cpp:577
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
Reimplemented from QGraphicsItem.
Definition: ParentItem.h:519
double y
y-coordinate.
Definition: Coord2D.h:114
void onDrawLayersFinished(const QMap< QString, QString > &errors)
Definition: MapItem.cpp:502
te::layout::Observable * m_model
"Model" part of MVC component.
Definition: ItemObserver.h:198
int getRed() const
It returns the red component color value (a value from 0 to 255).
Definition: RGBAColor.h:295
te::qt::widgets::ZoomWheel * m_zoomWheel
Definition: MapItem.h:202
virtual void dragEnterEvent(QGraphicsSceneDragDropEvent *event)
Reimplemented from QGraphicsProxyWidget.
Definition: MapItem.cpp:311
virtual EnumModeType * getEnumModeType()
Returns mode type enumeration.
Definition: Enums.cpp:92
virtual EnumType * getModeMapZoomIn() const
Returns value that represents map zoom in mode type belonging to enumeration.
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
Reimplemented from QGraphicsProxyWidget.
Definition: MapItem.cpp:370
double x
x-coordinate.
Definition: Coord2D.h:113
virtual QImage generateImage()
Definition: MapItem.cpp:596
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
Reimplemented from QGraphicsItem.
Definition: ParentItem.h:544
This class implements a concrete tool to geographic zoom in operation using a boundary rectangle...
Definition: ZoomArea.h:49
virtual void generateMapPixmap()
Definition: MapItem.cpp:640
virtual te::gm::Envelope getBox()=0
Returns the bounding rectangle of the component in scene coordinates(millimeters). Starting point is llx, lly. Reimplement this function in a Observable subclass to provide the model's getBox implementation.
QPointF remapPointToViewport(const QPointF &point, const QRectF &item, const QRectF &widget)
Definition: MapItem.cpp:222
virtual void changeZoomFactor(double currentZoomFactor)
It is called immediately by the Scene when the zoom factor is changed in the Context.
Definition: MapItem.cpp:697
int getBlue() const
It returns the blue component color value (a value from 0 to 255).
Definition: RGBAColor.h:305
double m_urx
Upper right corner x-coordinate.
Definition: Envelope.h:346
int getGreen() const
It returns the green component color value (a value from 0 to 255).
Definition: RGBAColor.h:300
double getWidth() const
It returns the envelope width.
Definition: Envelope.h:443
virtual bool isCurrentMapTools()
Indicates whether there is a tool active for object te::layout::MapItem.
Definition: ItemUtils.cpp:210
The Properties class represents a persistent set of properties. The Properties can be saved to a file...
Definition: Properties.h:52
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
void setPixmap(const QPixmap &pixmap)
Definition: MapItem.cpp:335
Abstract class to represent a controller. "Controller" part of MVC component. All classes representin...
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
Reimplemented from QGraphicsItem.
Definition: ParentItem.h:505
This class defines an interface for objects that can receive application events and respond to them...
Definition: AbstractTool.h:62
virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
Reimplemented from QGraphicsProxyWidget.
Definition: MapItem.cpp:326
virtual te::color::RGBAColor ** getPixmap()
Returns pixmap generated after drawing.
Definition: ContextItem.cpp:90
virtual void updateProperties(te::layout::Properties *properties)
Reimplemented from Observable.
Definition: MapModel.cpp:141
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
Reimplemented from QGraphicsProxyWidget.
Definition: MapItem.cpp:235
void Free(std::vector< T * > *v)
This function can be applied to a pointer to a vector of pointers.
Definition: STLUtils.h:131
This class implements a concrete tool to geographic pan operation.
Definition: Pan.h:49
static Context & getInstance()
It returns a reference to the singleton instance.
Class to represent a mode type enumeration. Ex.: select, pan, create text, etc. The type of mode is u...
Definition: EnumModeType.h:50
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
virtual Utils * getUtils()
AbstractProxyProject * getProxyProject()
Returns proxy to provide a surrogate or placeholder for te::qt::af::Project to control access to it...
Definition: Context.cpp:263
virtual void updateProperties(te::layout::Properties *properties)
Reimplemented from ItemObserver.
Definition: MapItem.cpp:655
virtual void recalculateBoundingRect()
The default implementation does nothing.
Definition: MapItem.cpp:710
void setCurrentTool(te::qt::widgets::AbstractTool *tool)
Definition: MapItem.cpp:529
Utils * getUtils()
Returns pointer with functions to manipulate the canvas and conversion between projections.
Definition: Context.cpp:153
virtual void dropEvent(QGraphicsSceneDragDropEvent *event)
Reimplemented from QGraphicsProxyWidget.
Definition: MapItem.cpp:289
int getAlpha() const
It returns the alpha component color value (a value from 0 to 255).
Definition: RGBAColor.h:310
ItemUtils * getItemUtils()
Returns pointer for manipulating items in the scene and vectorization of text and legend...
Definition: Context.cpp:273
std::string m_nameClass
Class name.
Definition: ItemObserver.h:201
QSize m_mapSize
The size of the map display in a zoom of 100%. This size is in pixels and is calculated based on the ...
Definition: MapItem.h:192
virtual EnumType * getModeMapPan() const
Returns value that represents map pan mode type belonging to enumeration.
This class implements a concrete tool to geographic zoom operation using the mouse click...
Definition: ZoomClick.h:49
virtual te::gm::Envelope viewportBox(te::gm::Envelope box)
Converts the box world (mm) to screen coordinates (pixel).
Definition: Utils.cpp:167
std::list< te::map::AbstractLayerPtr > getVisibleLayers()
Definition: MapItem.cpp:461
Utility class for manipulating items in the scene and vectorization of text and legend.
Definition: ItemUtils.h:62
virtual te::gm::Coord2D getPosition()
Reimplemented from ItemObserver.
Definition: MapItem.cpp:340
Class that represents a "Model" part of Map MVC component. Its coordinate system is the same of scene...
Definition: MapModel.h:61
virtual te::gm::Envelope getMapBox()
Definition: MapModel.cpp:394
Abstract class to provide a surrogate or placeholder for te::qt::af::Project to control access to it...
virtual te::color::RGBAColor getMapBackgroundColor()
Definition: MapModel.cpp:575
Class that represents a "Controller" part of Map MVC component. Its coordinate system is the same of ...
Definition: MapController.h:51
void clearCurrentTool()
Definition: MapItem.cpp:536
virtual EnumType * getModeMapZoomOut() const
Returns value that represents map zoom out mode type belonging to enumeration.
virtual void changeCurrentTool(EnumType *mode)
Definition: MapItem.cpp:547
TEQTWIDGETSEXPORT QImage * GetImage(te::color::RGBAColor **img, int width, int height)
It creates a QImage from an RGBA color array.
Definition: Utils.cpp:69
Class that represents the value of an enumeration. An enumeration is made of "1..n" objects EnumType...
Definition: EnumType.h:48
virtual double getDisplacementY()
Definition: MapModel.cpp:414
This class implements a concrete tool to geographic zoom operation using the mouse wheel...
Definition: ZoomWheel.h:49
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
virtual te::map::AbstractLayerPtr contains(std::string name)=0
Checks whether the layer is in the project.
void setMode(EnumType *mode)
Change value of the enumeration of mode type. Ex.: select, pan, create text, etc. The type of mode is...
Definition: Context.cpp:93
virtual te::gm::Envelope getBox()
Reimplemented from Observable.
te::map::AbstractLayerPtr getLayer()
Definition: MapItem.cpp:490
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
Reimplemented from QGraphicsProxyWidget.
Definition: MapItem.cpp:422
double getZoomFactor()
Returns current zoom factor. Ex.: 0.5 (50%)
Definition: Context.cpp:103
virtual void calculateFrameMargin()
Definition: MapItem.cpp:622
virtual void dragMoveEvent(QGraphicsSceneDragDropEvent *event)
Reimplemented from QGraphicsProxyWidget.
Definition: MapItem.cpp:330
virtual void drawMap(QPainter *painter)
Definition: MapItem.cpp:257
Utility class with functions to manipulate the canvas and conversion between projections.
Definition: Utils.h:61
virtual bool refreshLayer(te::map::AbstractLayerPtr layer)
virtual QRectF boundingRect() const
Reimplemented from ParentItem.
Definition: MapItem.cpp:729
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
Abstract class that represents a graphic item. Its coordinate system is the same of scene (millimeter...
Definition: ParentItem.h:86
double getHeight() const
It returns the envelope height.
Definition: Envelope.h:448
bool isValid() const
It tells if the rectangle is valid or not.
Definition: Envelope.h:438
A multi thread Qt4 widget to control the display of a set of layers.
MapItem(ItemController *controller, Observable *o)
Constructor.
Definition: MapItem.cpp:83
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.
Definition: Utils.cpp:248
te::qt::widgets::MultiThreadMapDisplay * m_mapDisplay
Definition: MapItem.h:195
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
Reimplemented from QGraphicsProxyWidget.
Definition: MapItem.cpp:396