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  event->setDropAction(Qt::CopyAction);
292 
293  getMimeData(event->mimeData());
294 
295  te::map::AbstractLayerPtr al = m_treeItem->getLayer();
296  te::gm::Envelope e = al->getExtent();
297 
298  std::list<te::map::AbstractLayerPtr> layerList;
299  layerList.push_back(al);
300 
301  m_layer = al;
302 
303  m_mapDisplay->setLayerList(layerList);
304  m_mapDisplay->setSRID(al->getSRID(), false);
305  m_mapDisplay->setExtent(e, true);
306 }
307 
308 void te::layout::MapItem::dragEnterEvent( QGraphicsSceneDragDropEvent * event )
309 {
310  //Copy the map from layer tree
311  Qt::DropActions actions = event->dropAction();
312  if(actions != Qt::CopyAction)
313  return;
314 
315  const QMimeData* mime = event->mimeData();
316  QString s = mime->data("application/x-terralib;value=\"DraggedItems\"").constData();
317  if(s.isEmpty())
318  return;
319 
320  event->acceptProposedAction();
321 }
322 
323 void te::layout::MapItem::dragLeaveEvent( QGraphicsSceneDragDropEvent * event )
324 {
325 }
326 
327 void te::layout::MapItem::dragMoveEvent( QGraphicsSceneDragDropEvent * event )
328 {
329 
330 }
331 
332 void te::layout::MapItem::setPixmap( const QPixmap& pixmap )
333 {
334  m_pixmap = pixmap;
335 }
336 
338 {
339  /* Correctly position the object and change the origin for bottomLeft */
340  double x = 0;
341  double y = 0;
342  MapModel* model = dynamic_cast<MapModel*>(m_model);
343  te::gm::Envelope box;
344  if(model)
345  {
346  box = model->getMapBox();
347  x = model->getDisplacementX() * 2;
348  y = model->getDisplacementY() * 2;
349  }
350  else
351  {
352  box = m_model->getBox();
353  }
354 
355  QPointF posF = scenePos();
356 
357  qreal valuex = posF.x() - x;
358  qreal valuey = posF.y() - y;
359 
360  te::gm::Coord2D coordinate;
361  coordinate.x = valuex;
362  coordinate.y = valuey;
363 
364  return coordinate;
365 }
366 
367 void te::layout::MapItem::mouseMoveEvent( QGraphicsSceneMouseEvent * event )
368 {
370  if(!iUtils)
371  return;
372 
373  if(!iUtils->isCurrentMapTools())
374  {
375  clearCurrentTool();
377  }
378  else
379  {
380  QRectF rect = boundingRect();
381  QPointF point = event->pos();
382  QPointF remappedPoint = remapPointToViewport(point, rect, m_mapDisplay->rect());
383 
384  QMouseEvent mouseEvent(QEvent::MouseMove, remappedPoint.toPoint(),
385  event->button(),event->buttons(), event->modifiers());
386  QApplication::sendEvent(m_mapDisplay, &mouseEvent);
387  event->setAccepted(mouseEvent.isAccepted());
388 
389  this->update();
390  }
391 }
392 
393 void te::layout::MapItem::mousePressEvent( QGraphicsSceneMouseEvent * event )
394 {
396  if(!iUtils)
397  return;
398 
399  if(!iUtils->isCurrentMapTools())
400  {
401  clearCurrentTool();
403  }
404  else
405  {
406  QRectF rect = boundingRect();
407  QPointF point = event->pos();
408  QPointF remappedPoint = remapPointToViewport(point, rect, m_mapDisplay->rect());
409 
410  QMouseEvent mouseEvent(QEvent::MouseButtonPress, remappedPoint.toPoint(),
411  event->button(),event->buttons(), event->modifiers());
412  QApplication::sendEvent(m_mapDisplay, &mouseEvent);
413  event->setAccepted(mouseEvent.isAccepted());
414 
415  this->update();
416  }
417 }
418 
419 void te::layout::MapItem::mouseReleaseEvent( QGraphicsSceneMouseEvent * event )
420 {
422  if(!iUtils)
423  return;
424 
425  if(!iUtils->isCurrentMapTools())
426  {
427  clearCurrentTool();
429  }
430  else
431  {
432  QRectF rect = boundingRect();
433  QPointF point = event->pos();
434  QPointF remappedPoint = remapPointToViewport(point, rect, m_mapDisplay->rect());
435 
436  QMouseEvent mouseEvent(QEvent::MouseButtonRelease, remappedPoint.toPoint(),
437  event->button(),event->buttons(), event->modifiers());
438  QApplication::sendEvent(m_mapDisplay, &mouseEvent);
439  event->setAccepted(mouseEvent.isAccepted());
440 
441  this->update();
442  }
443  refresh();
444 }
445 
446 void te::layout::MapItem::getMimeData( const QMimeData* mime )
447 {
448  QString s = mime->data("application/x-terralib;value=\"DraggedItems\"").constData();
449  unsigned long v = s.toULongLong();
450  std::vector<te::qt::widgets::AbstractTreeItem*>* draggedItems = reinterpret_cast<std::vector<te::qt::widgets::AbstractTreeItem*>*>(v);
451 
452  if(draggedItems->empty())
453  return;
454 
455  m_treeItem = draggedItems->operator[](0);
456 }
457 
458 std::list<te::map::AbstractLayerPtr> te::layout::MapItem::getVisibleLayers()
459 {
460  std::list<te::map::AbstractLayerPtr> visibleLayers;
461 
462  if(!m_treeItem)
463  return visibleLayers;
464 
465  te::map::AbstractLayerPtr al = m_treeItem->getLayer();
466 
467  if(al.get() == 0)
468  return visibleLayers;
469 
470  std::list<te::map::AbstractLayerPtr> vis;
471  te::map::GetVisibleLayers(al, vis);
472  // remove folders
473  std::list<te::map::AbstractLayerPtr>::iterator vit;
474  for(vit = vis.begin(); vit != vis.end(); ++vit)
475  {
476  if((*vit)->getType() == "DATASETLAYER" ||
477  (*vit)->getType() == "QUERYLAYER" ||
478  (*vit)->getType() == "RASTERLAYER")
479  {
480  visibleLayers.push_front(*vit);
481  }
482  }
483 
484  return visibleLayers;
485 }
486 
488 {
490 
491  if(!m_treeItem)
492  return layer;
493 
494  layer = m_treeItem->getLayer();
495 
496  return layer;
497 }
498 
499 void te::layout::MapItem::onDrawLayersFinished( const QMap<QString, QString>& errors )
500 {
501  if(!errors.empty())
502  return;
503 
504  te::map::AbstractLayerPtr layer = getLayer();
505 
506  if(!m_controller)
507  return;
508 
509  MapController* controller = dynamic_cast<MapController*>(m_controller);
510  if(controller)
511  {
512  bool result = controller->refreshLayer(layer);
513  if(result)
514  {
515  redraw();
516  }
517  }
518 
519  generateMapPixmap();
520 
521  m_changeLayer = true;
522 
523  update();
524 }
525 
527 {
528  m_tool = tool;
529 
530  m_mapDisplay->installEventFilter(m_tool);
531 }
532 
534 {
535  if(m_tool)
536  {
537  m_mapDisplay->removeEventFilter(m_tool);
538 
539  delete m_tool;
540  m_tool = 0;
541  }
542 }
543 
545 {
546  clearCurrentTool();
547 
549 
551  if(mode == type->getModeMapPan())
552  {
553  te::qt::widgets::Pan* pan = new te::qt::widgets::Pan(m_mapDisplay, Qt::OpenHandCursor, Qt::ClosedHandCursor);
554  setCurrentTool(pan);
555  }
556  if(mode == type->getModeMapZoomIn())
557  {
558  //Zoom In
559  std::string icon_path_zoom_area = "layout-map-zoom-in";
560  QCursor zoomAreaCursor(QIcon::fromTheme(icon_path_zoom_area.c_str()).pixmap(QSize(10,10)));
561  te::qt::widgets::ZoomArea* zoomArea = new te::qt::widgets::ZoomArea(m_mapDisplay, zoomAreaCursor);
562  setCurrentTool(zoomArea);
563  }
564  if(mode == type->getModeMapZoomOut())
565  {
566  //Zoom Out
567  std::string icon_path_zoom_out = "layout-map-zoom-out";
568  QCursor zoomOutCursor(QIcon::fromTheme(icon_path_zoom_out.c_str()).pixmap(QSize(10,10)));
569  te::qt::widgets::ZoomClick* zoomOut = new te::qt::widgets::ZoomClick(m_mapDisplay, zoomOutCursor, 2.0, te::qt::widgets::Zoom::Out);
570  setCurrentTool(zoomOut);
571  }
572 }
573 
575 {
576  te::color::RGBAColor** teImg = 0;
577 
578  QImage img = m_pixmap.toImage();
579  img = img.mirrored();
580 
581  if(img.isNull())
582  {
583  return teImg;
584  }
585 
586  w = img.width();
587  h = img.height();
588 
589  teImg = te::qt::widgets::GetImage(&img);
590  return teImg;
591 }
592 
594 {
595  QColor color(0, 0, 255, 0);
596 
597  QImage generator(m_pixmap.width(), m_pixmap.height(), QImage::Format_ARGB32);
598  generator.fill(color);
599 
600  QPainter painter;
601  painter.begin(&generator);
602 
603  QPoint pt(m_wMargin, m_hMargin);
604  widget()->render(&painter, pt);
605 
606  if(!m_pixmap.isNull())
607  {
608  QRectF rectF(0, 0, m_pixmap.width(), m_pixmap.height());
609  painter.save();
610  painter.drawPixmap(rectF, m_pixmap, rectF);
611  painter.restore();
612  generator.mirrored();
613  }
614 
615  painter.end();
616  return generator;
617 }
618 
620 {
621  MapModel* model = dynamic_cast<MapModel*>(m_model);
622  if(!model)
623  return;
624 
625  Utils* utils = Context::getInstance().getUtils();
626 
627  if(!utils)
628  return;
629 
630  te::gm::Envelope box = utils->viewportBox(m_model->getBox());
631  te::gm::Envelope mapBox = utils->viewportBox(model->getMapBox());
632 
633  m_wMargin = (box.getWidth() - mapBox.getWidth()) / 2.;
634  m_hMargin = (box.getHeight() - mapBox.getHeight()) / 2.;
635 }
636 
638 {
639  QRegion srcRegion( 0, 0, this->widget()->width(), this->widget()->height());
640 
641  QColor color(255, 255, 255, 0);
642  QPixmap img(this->widget()->width(), this->widget()->height());
643  img.fill(Qt::transparent);
644 
645  QPainter ptr(&img);
646  QPoint pt(0, 0);
647  this->widget()->render(&ptr, pt, srcRegion);
648 
649  m_mapPixmap = img;
650 }
651 
653 {
654 
655  MapModel* model = dynamic_cast<MapModel*>(m_model);
656  if(!model)
657  return;
658 
659  if(!m_controller)
660  return;
661 
662  model->updateProperties(properties);
663  redraw();
664 
665  if(model->isLoadedLayer())
666  {
667  redraw();
668  return;
669  }
670 
671  std::string name = model->getNameLayer();
672 
673  if(name.compare("") == 0)
674  return;
675 
677  if(!project)
678  return;
679 
680  te::map::AbstractLayerPtr layer = project->contains(name);
681  m_mapDisplay->changeData(layer);
682 
683  MapController* controller = dynamic_cast<MapController*>(m_controller);
684  if(!controller)
685  return;
686 
687  bool result = controller->refreshLayer(layer);
688  if(result)
689  {
690  redraw();
691  }
692 }
693 
694 void te::layout::MapItem::changeZoomFactor( double currentZoomFactor )
695 {
696  QSize currentSize = m_mapDisplay->size();
697  QSize newSize = m_mapSize * currentZoomFactor;
698  if(currentSize != newSize)
699  {
700  QPointF pt = scenePos();
701  //QWidget::resize(): causes the component return to starting position
702  m_mapDisplay->setGeometry(pt.x(), pt.y(), newSize.width(), newSize.height());
703  m_changeLayer = true;
704  }
705 }
706 
708 {
709  MapModel* model = dynamic_cast<MapModel*>(m_model);
710  te::gm::Envelope box = model->getBox();
711 
712  if(m_rect.width() != box.getWidth()
713  || m_rect.height() != box.getHeight())
714  {
715  prepareGeometryChange();
716  m_rect = QRectF(0., 0., box.getWidth(), box.getHeight());
717 
718  //update model
719  te::gm::Envelope env(m_model->getBox());
720  env.m_urx = env.m_llx + m_rect.width();
721  env.m_ury = env.m_lly + m_rect.height();
722  m_controller->setBox(env);
723  }
724 }
725 
727 {
728  MapModel* model = dynamic_cast<MapModel*>(m_model);
729  te::gm::Envelope box = model->getBox();
730 
731  QRectF rect(0., 0., box.getWidth(), box.getHeight());
732  return rect;
733 }
734 
735 
736 
737 
738 
739 
740 
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:446
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:574
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:499
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:308
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:367
double x
x-coordinate.
Definition: Coord2D.h:113
virtual QImage generateImage()
Definition: MapItem.cpp:593
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:637
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:694
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:332
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:323
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:652
virtual void recalculateBoundingRect()
The default implementation does nothing.
Definition: MapItem.cpp:707
void setCurrentTool(te::qt::widgets::AbstractTool *tool)
Definition: MapItem.cpp:526
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:458
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:337
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:533
virtual EnumType * getModeMapZoomOut() const
Returns value that represents map zoom out mode type belonging to enumeration.
virtual void changeCurrentTool(EnumType *mode)
Definition: MapItem.cpp:544
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:487
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
Reimplemented from QGraphicsProxyWidget.
Definition: MapItem.cpp:419
double getZoomFactor()
Returns current zoom factor. Ex.: 0.5 (50%)
Definition: Context.cpp:103
virtual void calculateFrameMargin()
Definition: MapItem.cpp:619
virtual void dragMoveEvent(QGraphicsSceneDragDropEvent *event)
Reimplemented from QGraphicsProxyWidget.
Definition: MapItem.cpp:327
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:726
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:393