All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
BuildGraphicsItem.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 BuildGraphicsItem.cpp
22 
23  \brief
24 
25  \ingroup layout
26 */
27 
28 // TerraLib
29 #include "BuildGraphicsItem.h"
30 #include "Scene.h"
31 #include "ItemUtils.h"
32 #include "../../core/pattern/singleton/Context.h"
33 #include "../../core/property/SharedProperties.h"
34 #include "../../item/RectangleModel.h"
35 #include "../../item/RectangleController.h"
36 #include "../item/RectangleItem.h"
37 #include "../../item/MapModel.h"
38 #include "../../item/MapController.h"
39 #include "../item/MapItem.h"
40 #include "../../item/LegendModel.h"
41 #include "../../item/LegendController.h"
42 #include "../item/LegendItem.h"
43 #include "../../item/PaperModel.h"
44 #include "../../item/PaperController.h"
45 #include "../item/PaperItem.h"
46 #include "../../item/ScaleModel.h"
47 #include "../../item/ScaleController.h"
48 #include "../item/ScaleItem.h"
49 #include "../../item/ItemGroupModel.h"
50 #include "../../item/ItemGroupController.h"
51 #include "../item/ItemGroup.h"
52 #include "../../item/ImageModel.h"
53 #include "../../item/ImageController.h"
54 #include "../item/ImageItem.h"
55 #include "../../item/ArrowModel.h"
56 #include "../../item/ArrowController.h"
57 #include "../item/ArrowItem.h"
58 #include "../../item/EllipseModel.h"
59 #include "../../item/EllipseController.h"
60 #include "../item/EllipseItem.h"
61 #include "../../item/PointModel.h"
62 #include "../../item/PointController.h"
63 #include "../item/PointItem.h"
64 #include "../../item/TitleModel.h"
65 #include "../../item/TitleController.h"
66 #include "../item/TitleItem.h"
67 #include "../../item/TextGridModel.h"
68 #include "../../item/TextGridController.h"
69 #include "../item/TextGridItem.h"
70 #include "../../core/enum/Enums.h"
71 #include "../../item/LegendChildModel.h"
72 #include "../../item/LegendChildController.h"
73 #include "../item/LegendChildItem.h"
74 #include "../../item/TextController.h"
75 #include "../item/TextItem.h"
76 #include "../../item/TextModel.h"
77 #include "../../core/property/Properties.h"
78 #include "../item/MovingItemGroup.h"
79 #include "../../item/MovingItemGroupController.h"
80 #include "../../item/MovingItemGroupModel.h"
81 #include "../../item/LineModel.h"
82 #include "../../item/LineController.h"
83 #include "../item/LineItem.h"
84 #include "../../item/PolygonModel.h"
85 #include "../../item/PolygonController.h"
86 #include "../item/PolygonItem.h"
87 #include "../../item/BalloonModel.h"
88 #include "../../item/BalloonController.h"
89 #include "../item/BalloonItem.h"
90 #include "../../item/BarCodeModel.h"
91 #include "../../item/BarCodeController.h"
92 #include "../item/BarCodeItem.h"
93 #include "../../item/GridMapModel.h"
94 #include "../../item/GridMapController.h"
95 #include "../item/GridMapItem.h"
96 #include "../../item/GridPlanarModel.h"
97 #include "../../item/GridPlanarController.h"
98 #include "../item/GridPlanarItem.h"
99 #include "../../item/GridGeodesicModel.h"
100 #include "../../item/GridGeodesicController.h"
101 #include "../item/GridGeodesicItem.h"
102 #include "../../item/NorthModel.h"
103 #include "../../item/NorthController.h"
104 #include "../item/NorthItem.h"
105 #include "../../item/MapLocationModel.h"
106 #include "../../item/MapLocationController.h"
107 #include "../item/MapLocationItem.h"
108 
109 // Qt
110 #include <QGraphicsItem>
111 
112 // STL
113 #include <sstream>
114 #include <string>
115 
117 {
118 
119 }
120 
122 {
123 
124 }
125 
127 {
128  QGraphicsItem* item = 0;
129 
130  if(!props)
131  return item;
132 
133  clear();
134 
135  m_props = props;
136  m_coord = findCoordinate(props);
137  m_zValue = findZValue(props);
138 
140 
141  EnumType* type = props->getTypeObj();
142 
143  item = createItem(type, draw);
144 
145  return item;
146 }
147 
148 QGraphicsItem* te::layout::BuildGraphicsItem::createItem( te::layout::EnumType* mode, const te::gm::Coord2D& coordinate, bool draw )
149 {
150  QGraphicsItem* item = 0;
151 
152  m_coord = coordinate;
153  clear();
154 
157 
158  if(mode == enumMode->getModeCreateMap())
159  {
160  item = createItem(enumObj->getMapItem(), draw);
161  }
162  else if(mode == enumMode->getModeCreateGridMap())
163  {
164  item = createItem(enumObj->getGridMapItem(), draw);
165  }
166  else if(mode == enumMode->getModeCreateText())
167  {
168  item = createItem(enumObj->getTextItem(), draw);
169  }
170  else if(mode == enumMode->getModeCreateImage())
171  {
172  item = createItem(enumObj->getImageItem(), draw);
173  }
174  else if(mode == enumMode->getModeCreateRectangle())
175  {
176  item = createItem(enumObj->getRectangleItem(), draw);
177  }
178  else if(mode == enumMode->getModeCreateLegend())
179  {
180  item = createItem(enumObj->getLegendItem(), draw);
181  }
182  else if(mode == enumMode->getModeCreateScale())
183  {
184  item = createItem(enumObj->getScaleItem(), draw);
185  }
186  else if(mode == enumMode->getModeCreateItemGroup())
187  {
188  item = createItem(enumObj->getItemGroup(), draw);
189  }
190  else if(mode == enumMode->getModeCreatePoint())
191  {
192  item = createItem(enumObj->getPointItem(), draw);
193  }
194  else if(mode == enumMode->getModeCreateArrow())
195  {
196  item = createItem(enumObj->getArrowItem(), draw);
197  }
198  else if(mode == enumMode->getModeCreateEllipse())
199  {
200  item = createItem(enumObj->getEllipseItem(), draw);
201  }
202  else if(mode == enumMode->getModeCreateTitle())
203  {
204  item = createItem(enumObj->getTitleItem(), draw);
205  }
206  else if(mode == enumMode->getModeCreateTextGrid())
207  {
208  item = createItem(enumObj->getTextGridItem(), draw);
209  }
210  else if(mode == enumMode->getModeCreateLegendChild())
211  {
212  item = createItem(enumObj->getLegendChildItem(), draw);
213  }
214  else if (mode == enumMode->getModeCreateLine())
215  {
216  item = createItem(enumObj->getLineItem(), draw);
217  }
218  else if (mode == enumMode->getModeCreatePolygon())
219  {
220  item = createItem(enumObj->getPolygonItem(), draw);
221  }
222  else if (mode == enumMode->getModeCreateBalloon())
223  {
224  item = createItem(enumObj->getBalloonItem(), draw);
225  }
226  else if (mode == enumMode->getModeCreateBarCode())
227  {
228  item = createItem(enumObj->getBarCodeItem(), draw);
229  }
230  else if (mode == enumMode->getModeCreateGridPlanar())
231  {
232  item = createItem(enumObj->getGridPlanarItem(), draw);
233  }
234  else if (mode == enumMode->getModeCreateGridGeodesic())
235  {
236  item = createItem(enumObj->getGridGeodesicItem(), draw);
237  }
238  else if (mode == enumMode->getModeCreateNorth())
239  {
240  item = createItem(enumObj->getNorthItem(), draw);
241  }
242  else if (mode == enumMode->getModeCreateMapLocation())
243  {
244  item = createItem(enumObj->getMapLocationItem(), draw);
245  }
246 
247  return item;
248 }
249 
251 {
252  QGraphicsItem* item = 0;
253 
255 
256  if(type == enumObj->getMovingItemGroup())
257  {
258  item = createMovingItemGroup();
259  }
260  else if(type == enumObj->getMapItem())
261  {
262  item = createMap();
263  }
264  else if(type == enumObj->getGridMapItem())
265  {
266  item = createGridMap();
267  }
268  else if(type == enumObj->getTextItem())
269  {
270  item = createText();
271  }
272  else if(type == enumObj->getImageItem())
273  {
274  item = createImage();
275  }
276  else if(type == enumObj->getRectangleItem())
277  {
278  item = createRectangle();
279  }
280  else if(type == enumObj->getLegendItem())
281  {
282  item = createLegend();
283  }
284  else if(type == enumObj->getPaperItem())
285  {
286  item = createPaper();
287  }
288  else if(type == enumObj->getScaleItem())
289  {
290  item = createScale();
291  }
292  else if(type == enumObj->getItemGroup())
293  {
294  item = createItemGroup();
295  }
296  else if(type == enumObj->getArrowItem())
297  {
298  item = createArrow();
299  }
300  else if(type == enumObj->getEllipseItem())
301  {
302  item = createEllipse();
303  }
304  else if(type == enumObj->getPointItem())
305  {
306  item = createPoint();
307  }
308  else if(type == enumObj->getTextGridItem())
309  {
310  item = createTextGrid();
311  }
312  else if(type == enumObj->getTitleItem())
313  {
314  item = createTitle();
315  }
316  else if(type == enumObj->getLegendChildItem())
317  {
318  item = createLegendChild();
319  }
320  else if(type == enumObj->getLineItem())
321  {
322  item = createLine();
323  }
324  else if(type == enumObj->getPolygonItem())
325  {
326  item = createPolygon();
327  }
328  else if(type == enumObj->getBalloonItem())
329  {
330  item = createBalloon();
331  }
332  else if(type == enumObj->getBarCodeItem())
333  {
334  item = createBarCode();
335  }
336  else if(type == enumObj->getGridPlanarItem())
337  {
338  item = createGridPlanar();
339  }
340  else if(type == enumObj->getGridGeodesicItem())
341  {
342  item = createGridGeodesic();
343  }
344  else if(type == enumObj->getNorthItem())
345  {
346  item = createNorth();
347  }
348  else if(type == enumObj->getMapLocationItem())
349  {
350  item = createMapLocation();
351  }
352 
353  afterBuild(item, draw);
354 
355  return item;
356 }
357 
359 {
360  std::string name = "";
361 
363 
364  QList<QGraphicsItem*> graphicsItems;
365  std::stringstream ss;//create a stringstream
366 
367  if(abstScene)
368  {
369  Scene* sc = dynamic_cast<Scene*>(abstScene);
370  if(sc)
371  {
372  graphicsItems = sc->items();
373  }
374  }
375 
377  if(!iUtils)
378  {
379  return name;
380  }
381 
382  m_id = iUtils->maxTypeId(type);
383 
384  if(m_id < 0)
385  m_id = 0;
386  else
387  m_id+= 1;
388 
389  ss << m_id;
390 
391  name = type->getName();
392  name+="_";
393  name+=ss.str();
394 
395  return name;
396 }
397 
398 bool te::layout::BuildGraphicsItem::addChild( QGraphicsItem* child, int x, int y )
399 {
400  bool result = false;
401 
402  if(!child)
403  {
404  return result;
405  }
406 
408  if(!iUtils)
409  {
410  return result;
411  }
412 
413  QGraphicsItem* parentItem = iUtils->intersectionSelectionItem(x, y);
414 
415  if(!parentItem)
416  {
417  return result;
418  }
419 
420  // No add child in unselected items
421  if(!parentItem->isSelected())
422  {
423  return result;
424  }
425 
426  ItemObserver* itemOb = dynamic_cast<ItemObserver*>(parentItem);
427  if(!itemOb)
428  {
429  return result;
430  }
431 
432  if(!itemOb->getModel())
433  {
434  return result;
435  }
436 
437  ItemModelObservable* model = dynamic_cast<ItemModelObservable*>(itemOb->getModel());
438  if(model)
439  {
440  if(model->isEnableChildren())
441  {
442  child->setParentItem(parentItem);
443  result = true;
444  }
445  }
446 
447  emit addChildFinalized(parentItem, child);
448 
449  return result;
450 }
451 
452 void te::layout::BuildGraphicsItem::afterBuild( QGraphicsItem* item, bool draw )
453 {
454  if(!item)
455  {
456  return;
457  }
458 
459  bool result = addChild(item, m_coord.x, m_coord.y);
460  if(!result)
461  {
462  item->setPos(QPointF(m_coord.x, m_coord.y));
463  }
464 
465  if(m_props)
466  {
467  item->setZValue(m_zValue);
468  }
469 
470  ItemObserver* itemObs = dynamic_cast<ItemObserver*>(item);
471  if(itemObs && draw)
472  {
473  itemObs->redraw();
474  }
475 }
476 
478 {
479  PaperModel* model = new PaperModel(te::layout::Context::getInstance().getPaperConfig());
480  if(!m_props)
481  {
482  model->setId(m_id);
483 
485  std::string name = nameItem(enumObj->getPaperItem());
486  model->setName(name);
487  }
488 
489  PaperController* controllerMap = new PaperController(model);
490  ItemObserver* itemObs = (ItemObserver*)controllerMap->getView();
491 
492  PaperItem* view = dynamic_cast<PaperItem*>(itemObs);
493  if(m_props && view)
494  {
495  model->updateProperties(m_props);
496  }
497  return view;
498 }
499 
501 {
502  MapModel* model = new MapModel();
503  if(!m_props)
504  {
505  model->setId(m_id);
506 
508  std::string name = nameItem(enumObj->getMapItem());
509  model->setName(name);
510  }
511 
512  MapController* controller = new MapController(model);
513  ItemObserver* itemObs = (ItemObserver*)controller->getView();
514 
515  MapItem* view = dynamic_cast<MapItem*>(itemObs);
516  if(m_props && view)
517  {
518  model->updateProperties(m_props);
519  }
520  return view;
521 }
522 
524 {
525  GridMapModel* model = new GridMapModel();
526  if(!m_props)
527  {
528  model->setId(m_id);
529 
531  std::string name = nameItem(enumObj->getGridMapItem());
532  model->setName(name);
533  }
534 
535  GridMapController* controller = new GridMapController(model);
536  ItemObserver* itemObs = (ItemObserver*)controller->getView();
537 
538  GridMapItem* view = dynamic_cast<GridMapItem*>(itemObs);
539  if(m_props && view)
540  {
541  model->updateProperties(m_props);
542  }
543  return view;
544 }
545 
547 {
548  TextModel* model = new TextModel();
549  if(!m_props)
550  {
551  model->setId(m_id);
552 
554  std::string name = nameItem(enumObj->getTextItem());
555  model->setName(name);
556  }
557 
558  TextController* controller = new TextController(model);
559  ItemObserver* itemObs = (ItemObserver*)controller->getView();
560 
561  TextItem* view = dynamic_cast<TextItem*>(itemObs);
562  if(m_props && view)
563  {
564  model->updateProperties(m_props);
565  }
566  return view;
567 }
568 
570 {
571  RectangleModel* model = new RectangleModel();
572  if(!m_props)
573  {
574  model->setId(m_id);
575 
577  std::string name = nameItem(enumObj->getRectangleItem());
578  model->setName(name);
579  }
580 
581  RectangleController* controller = new RectangleController(model);
582  ItemObserver* itemObs = (ItemObserver*)controller->getView();
583 
584  RectangleItem* view = dynamic_cast<RectangleItem*>(itemObs);
585  if(m_props && view)
586  {
587  model->updateProperties(m_props);
588  }
589  return view;
590 }
591 
593 {
594  LegendModel* model = new LegendModel();
595  if(!m_props)
596  {
597  model->setId(m_id);
598 
600  std::string name = nameItem(enumObj->getLegendItem());
601  model->setName(name);
602  }
603 
604  LegendController* controller = new LegendController(model);
605  ItemObserver* itemObs = (ItemObserver*)controller->getView();
606 
607  LegendItem* view = dynamic_cast<LegendItem*>(itemObs);
608  if(m_props && view)
609  {
610  model->updateProperties(m_props);
611  }
612  return view;
613 }
614 
616 {
617  ScaleModel* model = new ScaleModel();
618  if(!m_props)
619  {
620  model->setId(m_id);
621 
623  std::string name = nameItem(enumObj->getScaleItem());
624  model->setName(name);
625  }
626 
627  ScaleController* controller = new ScaleController(model);
628  ItemObserver* itemObs = (ItemObserver*)controller->getView();
629 
630  ScaleItem* view = dynamic_cast<ScaleItem*>(itemObs);
631  if(m_props && view)
632  {
633  model->updateProperties(m_props);
634  }
635  return view;
636 }
637 
639 {
640  ItemGroupModel* model = new ItemGroupModel();
641  if(!m_props)
642  {
643  model->setId(m_id);
644 
646  std::string name = nameItem(enumObj->getItemGroup());
647  model->setName(name);
648  }
649 
650  ItemGroupController* controller = new ItemGroupController(model);
651  ItemObserver* itemObs = (ItemObserver*)controller->getView();
652 
653  ItemGroup* view = dynamic_cast<ItemGroup*>(itemObs);
654  if(m_props && view)
655  {
656  model->updateProperties(m_props);
657  }
658  return view;
659 }
660 
662 {
664  if(!m_props)
665  {
666  model->setId(m_id);
667 
669  std::string name = nameItem(enumObj->getMovingItemGroup());
670  model->setName(name);
671  }
672 
673  MovingItemGroupController* controller = new MovingItemGroupController(model);
674  ItemObserver* itemObs = (ItemObserver*)controller->getView();
675 
676  MovingItemGroup* view = dynamic_cast<MovingItemGroup*>(itemObs);
677  if(m_props && view)
678  {
679  model->updateProperties(m_props);
680  }
681  return view;
682 }
683 
685 {
686  ImageModel* model = new ImageModel();
687  if(!m_props)
688  {
689  model->setId(m_id);
690 
692  std::string name = nameItem(enumObj->getImageItem());
693  model->setName(name);
694  }
695 
696  ImageController* controller = new ImageController(model);
697  ItemObserver* itemObs = (ItemObserver*)controller->getView();
698 
699  ImageItem* view = dynamic_cast<ImageItem*>(itemObs);
700  if(m_props && view)
701  {
702  model->updateProperties(m_props);
703  }
704  return view;
705 }
706 
708 {
709  ArrowModel* model = new ArrowModel();
710  if(!m_props)
711  {
712  model->setId(m_id);
713 
715  std::string name = nameItem(enumObj->getArrowItem());
716  model->setName(name);
717  }
718 
719  ArrowController* controller = new ArrowController(model);
720  ItemObserver* itemObs = (ItemObserver*)controller->getView();
721 
722  ArrowItem* view = dynamic_cast<ArrowItem*>(itemObs);
723  if(m_props && view)
724  {
725  model->updateProperties(m_props);
726  }
727  return view;
728 }
729 
731 {
732  EllipseModel* model = new EllipseModel();
733  if(!m_props)
734  {
735  model->setId(m_id);
736 
738  std::string name = nameItem(enumObj->getEllipseItem());
739  model->setName(name);
740  }
741 
742  EllipseController* controller = new EllipseController(model);
743  ItemObserver* itemObs = (ItemObserver*)controller->getView();
744 
745  EllipseItem* view = dynamic_cast<EllipseItem*>(itemObs);
746  if(m_props && view)
747  {
748  model->updateProperties(m_props);
749  }
750  return view;
751 }
752 
754 {
755  PointModel* model = new PointModel();
756  if(!m_props)
757  {
758  model->setId(m_id);
759 
761  std::string name = nameItem(enumObj->getPointItem());
762  model->setName(name);
763  }
764 
765  PointController* controller = new PointController(model);
766  ItemObserver* itemObs = (ItemObserver*)controller->getView();
767 
768  PointItem* view = dynamic_cast<PointItem*>(itemObs);
769  if(m_props && view)
770  {
771  model->updateProperties(m_props);
772  }
773  return view;
774 }
775 
777 {
778  TextGridModel* model = new TextGridModel();
779  if(!m_props)
780  {
781  model->setId(m_id);
782 
784  std::string name = nameItem(enumObj->getTextGridItem());
785  model->setName(name);
786  }
787 
788  TextGridController* controller = new TextGridController(model);
789  ItemObserver* itemObs = (ItemObserver*)controller->getView();
790 
791  TextGridItem* view = dynamic_cast<TextGridItem*>(itemObs);
792  if(m_props && view)
793  {
794  model->updateProperties(m_props);
795  }
796  return view;
797 }
798 
800 {
801  TitleModel* model = new TitleModel();
802  if(!m_props)
803  {
804  model->setId(m_id);
805 
807  std::string name = nameItem(enumObj->getTitleItem());
808  model->setName(name);
809  }
810 
811  TitleController* controller = new TitleController(model);
812  ItemObserver* itemObs = (ItemObserver*)controller->getView();
813 
814  TitleItem* view = dynamic_cast<TitleItem*>(itemObs);
815  if(m_props && view)
816  {
817  model->updateProperties(m_props);
818  }
819  return view;
820 }
821 
823 {
824  LegendChildModel* model = new LegendChildModel();
825  if(!m_props)
826  {
827  model->setId(m_id);
828 
830  std::string name = nameItem(enumObj->getLegendChildItem());
831  model->setName(name);
832  }
833 
834  LegendChildController* controller = new LegendChildController(model);
835  ItemObserver* itemObs = (ItemObserver*)controller->getView();
836 
837  LegendChildItem* view = dynamic_cast<LegendChildItem*>(itemObs);
838  if(m_props && view)
839  {
840  model->updateProperties(m_props);
841  }
842  return view;
843 }
844 
846 {
847  LineModel* model = new LineModel();
848  if(m_props)
849  {
850  model->updateProperties(m_props);
851  }
852  else
853  {
854  model->setId(m_id);
855 
857  std::string name = nameItem(enumObj->getLineItem());
858  model->setName(name);
859  }
860 
861  LineController* controller = new LineController(model);
862  ItemObserver* itemObs = (ItemObserver*)controller->getView();
863 
864  LineItem* view = dynamic_cast<LineItem*>(itemObs);
865  if(m_props && view)
866  {
867  model->updateProperties(m_props);
868  }
869  return view;
870 }
871 
873 {
874  PolygonModel* model = new PolygonModel();
875  if(m_props)
876  {
877  model->updateProperties(m_props);
878  }
879  else
880  {
881  model->setId(m_id);
882 
884  std::string name = nameItem(enumObj->getPolygonItem());
885  model->setName(name);
886  }
887 
888  PolygonController* controller = new PolygonController(model);
889  ItemObserver* itemObs = (ItemObserver*)controller->getView();
890 
891  PolygonItem* view = dynamic_cast<PolygonItem*>(itemObs);
892  if(m_props && view)
893  {
894  model->updateProperties(m_props);
895  }
896  return view;
897 }
898 
900 {
901  BalloonModel* model = new BalloonModel();
902  if(m_props)
903  {
904  model->updateProperties(m_props);
905  }
906  else
907  {
908  model->setId(m_id);
909 
911  std::string name = nameItem(enumObj->getBalloonItem());
912  model->setName(name);
913  }
914 
915  BalloonController* controller = new BalloonController(model);
916  ItemObserver* itemObs = (ItemObserver*)controller->getView();
917 
918  BalloonItem* view = dynamic_cast<BalloonItem*>(itemObs);
919  if(m_props && view)
920  {
921  model->updateProperties(m_props);
922  }
923  return view;
924 }
925 
927 {
928  BarCodeModel* model = new BarCodeModel;
929  if(m_props)
930  {
931  model->updateProperties(m_props);
932  }
933  else
934  {
935  model->setId(m_id);
936 
938  std::string name = nameItem(enumObj->getBarCodeItem());
939  model->setName(name);
940  }
941 
942  BarCodeController* controller = new BarCodeController(model);
943  ItemObserver* itemObs = (ItemObserver*)controller->getView();
944 
945  BarCodeItem* view = dynamic_cast<BarCodeItem*>(itemObs);
946  if(m_props && view)
947  {
948  model->updateProperties(m_props);
949  }
950  return view;
951 }
952 
954 {
955  GridPlanarModel* model = new GridPlanarModel();
956  if(!m_props)
957  {
958  model->setId(m_id);
959 
961  std::string name = nameItem(enumObj->getGridPlanarItem());
962  model->setName(name);
963  }
964 
965  GridPlanarController* controller = new GridPlanarController(model);
966  ItemObserver* itemObs = (ItemObserver*)controller->getView();
967 
968  GridPlanarItem* view = dynamic_cast<GridPlanarItem*>(itemObs);
969  if(m_props && view)
970  {
971  model->updateProperties(m_props);
972  }
973  return view;
974 }
975 
977 {
978  GridGeodesicModel* model = new GridGeodesicModel();
979  if(!m_props)
980  {
981  model->setId(m_id);
982 
984  std::string name = nameItem(enumObj->getGridGeodesicItem());
985  model->setName(name);
986  }
987 
988  GridGeodesicController* controller = new GridGeodesicController(model);
989  ItemObserver* itemObs = (ItemObserver*)controller->getView();
990 
991  GridGeodesicItem* view = dynamic_cast<GridGeodesicItem*>(itemObs);
992  if(m_props && view)
993  {
994  model->updateProperties(m_props);
995  }
996  return view;
997 }
998 
1000 {
1001  NorthModel* model = new NorthModel;
1002  if(m_props)
1003  {
1004  model->updateProperties(m_props);
1005  }
1006  else
1007  {
1008  model->setId(m_id);
1009 
1011  std::string name = nameItem(enumObj->getNorthItem());
1012  model->setName(name);
1013  }
1014 
1015  NorthController* controller = new NorthController(model);
1016  ItemObserver* itemObs = (ItemObserver*)controller->getView();
1017 
1018  NorthItem* view = dynamic_cast<NorthItem*>(itemObs);
1019  if(m_props && view)
1020  {
1021  model->updateProperties(m_props);
1022  }
1023  return view;
1024 }
1025 
1027 {
1028  MapLocationModel* model = new MapLocationModel;
1029  if(m_props)
1030  {
1031  model->updateProperties(m_props);
1032  }
1033  else
1034  {
1035  model->setId(m_id);
1036 
1038  std::string name = nameItem(enumObj->getMapLocationItem());
1039  model->setName(name);
1040  }
1041 
1042  MapLocationController* controller = new MapLocationController(model);
1043  ItemObserver* itemObs = (ItemObserver*)controller->getView();
1044 
1045  MapLocationItem* view = dynamic_cast<MapLocationItem*>(itemObs);
1046  if(m_props && view)
1047  {
1048  model->updateProperties(m_props);
1049  }
1050  return view;
1051 }
1052 
1053 
1054 
1055 
1056 
1057 
1058 
1059 
1060 
1061 
1062 
1063 
1064 
1065 
virtual void updateProperties(te::layout::Properties *properties)
Reimplemented from ItemModelObservable.
Definition: ImageModel.cpp:86
virtual EnumType * getLineItem() const
Returns value that represents line (MVC Component) type belonging to enumeration. ...
Class that represents a "Controller" part of Arrow MVC component. Its coordinate system is the same o...
QGraphicsItem * createItemGroup()
Create graphic object of type ItemGroup.
virtual EnumType * getModeCreateTextGrid() const
Returns value that represents create text grid mode type belonging to enumeration.
virtual EnumType * getEllipseItem() const
Returns value that represents ellipse (MVC Component) type belonging to enumeration.
virtual void afterBuild(QGraphicsItem *item, bool draw=true)
After component construction, this method checks and adds a child, position and zValue. If necessary, also redraws.
Class to represent a graphic object (MVC component) and widget object (MVC widget) type enumeration...
std::string nameItem(te::layout::EnumType *type)
Creates the name of the new graphic object. Adds the number that corresponds to how many objects of t...
Class that represents a "Controller" part of Legend MVC component. Its coordinate system is the same ...
Class that represents a "Model" part of Paper MVC component. Its coordinate system is the same of sce...
Definition: PaperModel.h:54
Class that represents a "Model" part of Legend MVC component. Its coordinate system is the same of sc...
Definition: LegendModel.h:62
Class that represents a "Model" part of GridMap MVC component. Its coordinate system is the same of s...
Definition: GridMapModel.h:67
Class that represents a graphic sheet of paper. Its coordinate system is the same of scene (millimete...
Definition: PaperItem.h:52
std::string getName()
Returns name.
Definition: EnumType.cpp:54
QGraphicsItem * createLegendChild()
Create graphic object of type LegendChildItem.
virtual EnumModeType * getEnumModeType()
Returns mode type enumeration.
Definition: Enums.cpp:92
virtual EnumType * getTitleItem() const
Returns value that represents title (MVC Component) type belonging to enumeration.
Class that represents the grouping of objects of type QGraphicsItem, MVC components. Its coordinate system is the same of scene (millimeters). He is also the son of ItemObserver and ObjectItem, so it can become observer of a model (Observable).
Definition: ItemGroup.h:63
QGraphicsItem * createMapLocation()
Create graphic object of type MapLocationItem.
virtual EnumType * getMapLocationItem() const
Returns value that represents map location (MVC Component) type belonging to enumeration.
virtual EnumType * getModeCreateRectangle() const
Returns value that represents create rectangle mode type belonging to enumeration.
virtual EnumType * getModeCreateText() const
Returns value that represents create text mode type belonging to enumeration.
virtual ~BuildGraphicsItem()
Destructor.
virtual EnumType * getPaperItem() const
Returns value that represents paper (MVC Component) type belonging to enumeration.
Class that represents a "Controller" part of Rectangle MVC component. Its coordinate system is the sa...
QGraphicsItem * createLine()
Create graphic object of type LineItem.
const Observer * getView()
Returns the "View" part of the MVC component.
virtual void updateProperties(te::layout::Properties *properties)
Reimplemented from Observable.
Definition: PointModel.cpp:73
virtual void updateProperties(te::layout::Properties *properties)
Reimplemented from Observable.
Definition: ScaleModel.cpp:103
virtual void updateProperties(te::layout::Properties *properties)
Reimplemented from Observable.
virtual EnumType * getGridGeodesicItem() const
Returns value that represents grid geodesic type belonging to enumeration.
Class that represents a graphic Arrow. Its coordinate system is the same of scene (millimeters)...
Definition: ArrowItem.h:52
Utility class for manipulating items in the scene and vectorization of text and legend.
virtual EnumType * getModeCreateLegendChild() const
Returns value that represents create legend child mode type belonging to enumeration.
Abstract class to represent an observable. "Model" part of MVC component. All classes representing th...
Class representing the scene. This scene is child of QGraphicsScene, part of Graphics View Framework...
virtual EnumType * getBarCodeItem() const
Returns value that represents barcode (MVC Component) type belonging to enumeration.
Class that represents a graphic Point. Its coordinate system is the same of scene (millimeters)...
Definition: PointItem.h:52
virtual EnumType * getNorthItem() const
Returns value that represents north (MVC Component) type belonging to enumeration.
The Properties class represents a persistent set of properties. The Properties can be saved to a file...
Definition: Properties.h:52
Abstract class to represent an observer. "View" part of MVC component. All classes representing the g...
Definition: ItemObserver.h:52
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
QGraphicsItem * createText()
Create graphic object of type TextItem.
QGraphicsItem * createItem(te::layout::EnumType *mode, const te::gm::Coord2D &coordinate, bool draw=true)
Method to create a graphic object from the properties.
QGraphicsItem * createScale()
Create graphic object of type ScaleItem.
virtual EnumObjectType * getEnumObjectType()
Returns graphic object (MVC component) and widget object (MVC widget) type enumeration.
Definition: Enums.cpp:62
Class that represents a "Model" part of TextGrid MVC component. Its coordinate system is the same of ...
Definition: TextGridModel.h:55
Class that represents a "Controller" part of Paper MVC component. Its coordinate system is the same o...
virtual void updateProperties(te::layout::Properties *properties)
Reimplemented from Observable.
Class that represents a "Model" part of ItemGroup MVC component. Its coordinate system is the same of...
virtual EnumType * getPointItem() const
Returns value that represents point (MVC Component) type belonging to enumeration.
Class that represents a "Controller" part of Rectangle MVC component. Its coordinate system is the sa...
Class that represents a "Model" part of Text MVC component. Its coordinate system is the same of scen...
Definition: TextModel.h:58
QGraphicsItem * createArrow()
Create graphic object of type ArrowItem.
virtual void redraw(bool bRefresh=true)
Redraws the graphic component.
QGraphicsItem * createBarCode()
Create graphic object of type BarCode.
virtual void updateProperties(te::layout::Properties *properties)
Reimplemented from Observable.
Definition: TextModel.cpp:78
Class daughter of te::layout::TitleItem representing a grid with cells which can be inserted texts...
Definition: TextGridItem.h:48
Class that represents a "Controller" part of Image MVC component. Its coordinate system is the same o...
virtual EnumType * getModeCreateLegend() const
Returns value that represents create legend mode type belonging to enumeration.
virtual void updateProperties(te::layout::Properties *properties)
Reimplemented from Observable.
Definition: MapModel.cpp:141
virtual EnumType * getGridPlanarItem() const
Returns value that represents grid planar type belonging to enumeration.
Class that represents a graphic legend of a map. Its coordinate system is the same of scene (millimet...
Definition: LegendItem.h:54
virtual EnumType * getModeCreateItemGroup() const
Returns value that represents create item group mode type belonging to enumeration.
virtual bool addChild(QGraphicsItem *child, int x, int y)
Checks whether the coordinated intersects an item and adds a child. Checks ItemModelObservable::isEna...
virtual EnumType * getBalloonItem() const
Returns value that represents balloon (MVC Component) type belonging to enumeration.
virtual EnumType * getImageItem() const
Returns value that represents image (MVC Component) type belonging to enumeration.
virtual QGraphicsItem * intersectionSelectionItem(int x, int y)
Checks whether the coordinated intersects an item and returns.
Definition: ItemUtils.cpp:472
Class that represents a "Controller" part of Title MVC component. Its coordinate system is the same o...
virtual bool isEnableChildren()
Returns true if MVC component can have children, false otherwise.
QGraphicsItem * createPolygon()
Create graphic object of type PolygonItem.
virtual EnumType * getItemGroup() const
Returns value that represents item group (MVC Component) type belonging to enumeration.
Class that represents a "Controller" part of TextGrid MVC component. Its coordinate system is the sam...
virtual EnumType * getModeCreateTitle() const
Returns value that represents create title mode type belonging to enumeration.
static Enums & 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
virtual EnumType * getTextItem() const
Returns value that represents text (MVC Component) type belonging to enumeration. ...
QGraphicsItem * createLegend()
Create graphic object of type LegendItem.
virtual EnumType * getTypeObj()
Returns object type that owns these properties.
Definition: Properties.h:241
QGraphicsItem * createMovingItemGroup()
Create graphic object of type MovingItemGroup.
virtual EnumType * getModeCreateMapLocation() const
Returns value that represents create map location mode type belonging to enumeration.
Class that represents a "Model" part of Map MVC component. Its coordinate system is the same of scene...
Class that represents a "Controller" part of Ellipse MVC component. Its coordinate system is the same...
virtual EnumType * getModeCreatePolygon() const
Returns value that represents create polygon mode type belonging to enumeration.
virtual EnumType * getPolygonItem() const
Returns value that represents polygon (MVC Component) type belonging to enumeration.
QGraphicsItem * createPoint()
Create graphic object of type PointItem.
ItemUtils * getItemUtils()
Returns pointer for manipulating items in the scene and vectorization of text and legend...
Definition: Context.cpp:273
Class that represents a graphic Image. Its coordinate system is the same of scene (millimeters)...
Definition: ImageItem.h:55
virtual EnumType * getModeCreateGridMap() const
Returns value that represents wait coordinate mode type belonging to enumeration. ...
Class that represents a "Controller" part of ItemGroup MVC component. Its coordinate system is the sa...
QGraphicsItem * rebuildItem(te::layout::Properties *props, bool draw=true)
Method to build a graphics object from the properties.
Class that represents a "Controller" part of Point MVC component. Its coordinate system is the same o...
QGraphicsItem * createGridGeodesic()
Create graphic object of type GridGeodesicItem.
QGraphicsItem * createMap()
Create graphic object of type MapItem.
Class that represents a "Model" part of Rectangle MVC component. Its coordinate system is the same of...
Definition: NorthModel.h:52
virtual void updateProperties(te::layout::Properties *properties)
Reimplemented from Observable.
Definition: LineModel.cpp:146
virtual EnumType * getTextGridItem() const
Returns value that represents text grid (MVC Component) type belonging to enumeration.
QGraphicsItem * createRectangle()
Create graphic object of type RectangleItem.
Utility class for manipulating items in the scene and vectorization of text and legend.
Definition: ItemUtils.h:62
virtual void setName(std::string name)
Change the name of the MVC component.
Class representing the scene. This scene is child of QGraphicsScene, part of Graphics View Framework...
Definition: Scene.h:80
virtual EnumType * getModeCreateLine() const
Returns value that represents create line mode type belonging to enumeration.
virtual EnumType * getMovingItemGroup() const
Returns value that represents moving item group (MVC Component) type belonging to enumeration...
Class that represents a "Model" part of Map MVC component. Its coordinate system is the same of scene...
Definition: MapModel.h:61
Class that represents a "Model" part of Ellipse MVC component. Its coordinate system is the same of s...
Definition: EllipseModel.h:51
Abstract scene for Scene, a QGraphicsScene class, part of Graphics View Framework.
Definition: AbstractScene.h:48
Class that represents a "Controller" part of Scale MVC component. Its coordinate system is the same o...
Class that represents a graphic GridMap. Its coordinate system is the same of scene (millimeters)...
Definition: GridMapItem.h:52
virtual EnumType * getArrowItem() const
Returns value that represents arrow (MVC Component) type belonging to enumeration.
Class that represents a graphic scale of a map. Its coordinate system is the same of scene (millimete...
Definition: ScaleItem.h:52
Class that represents a "Model" part of Title MVC component. Its coordinate system is the same of sce...
Definition: TitleModel.h:52
virtual EnumType * getLegendItem() const
Returns value that represents legend (MVC Component) type belonging to enumeration.
Class that represents a "Controller" part of Map MVC component. Its coordinate system is the same of ...
Definition: MapController.h:51
Class that represents a graphic Rectangle. Its coordinate system is the same of scene (millimeters)...
Definition: RectangleItem.h:52
Class that represents a "Model" part of Point MVC component. Its coordinate system is the same of sce...
Definition: PointModel.h:54
Class that represents a "Controller" part of Map MVC component. Its coordinate system is the same of ...
Class that represents a "Model" part of Rectangle MVC component. Its coordinate system is the same of...
virtual void setId(int id)
Reimplemented from Observable.
QGraphicsItem * createGridMap()
Create graphic object of type GridMapItem.
virtual EnumType * getModeCreateEllipse() const
Returns value that represents create ellipse mode type belonging to enumeration.
Class that represents a "Controller" part of Text MVC component. Its coordinate system is the same of...
This class is a proxy MapDisplay. This makes it possible to add a MapDisplay as item of a scene...
virtual EnumType * getRectangleItem() const
Returns value that represents rectangle (MVC Component) type belonging to enumeration.
Class that represents the value of an enumeration. An enumeration is made of "1..n" objects EnumType...
Definition: EnumType.h:48
QGraphicsItem * createEllipse()
Create graphic object of type EllipseItem.
Class that represents a "Model" part of Image MVC component. Its coordinate system is the same of sce...
Definition: ImageModel.h:55
QGraphicsItem * createPaper()
Create graphic object of type PaperItem.
Class that represents a graphic Ellipse. Its coordinate system is the same of scene (millimeters)...
Definition: EllipseItem.h:52
virtual Observable * getModel()
Returns the "Model" part of the MVC.
Class daughter of te::layout::TextItem representing a grid with two cells which can be inserted texts...
Definition: TitleItem.h:48
virtual EnumType * getModeCreatePoint() const
Returns value that represents create point mode type belonging to enumeration.
Class that represents a "Model" part of Arrow MVC component. Its coordinate system is the same of sce...
Definition: ArrowModel.h:54
virtual EnumType * getModeCreateNorth() const
Returns value that represents create north mode type belonging to enumeration.
Class that represents a graphic GridMap. Its coordinate system is the same of scene (millimeters)...
virtual EnumType * getGridMapItem() const
Returns value that represents gridmapitem (MVC Component) type belonging to enumeration.
virtual EnumType * getMapItem() const
Returns value that represents map (MVC Component) type belonging to enumeration.
virtual EnumType * getModeCreateBarCode() const
Returns value that represents wait coordinate mode type belonging to enumeration. ...
QGraphicsItem * createGridPlanar()
Create graphic object of type GridPlanarItem.
AbstractScene * getScene()
Returns abstract scene for QGraphicsScene class, part of Graphics View Framework. ...
Definition: Context.cpp:88
virtual EnumType * getModeCreateBalloon() const
Returns value that represents create balloon mode type belonging to enumeration.
virtual EnumType * getModeCreateGridPlanar() const
Returns value that represents create grid planar mode type belonging to enumeration.
virtual EnumType * getModeCreateScale() const
Returns value that represents create scale mode type belonging to enumeration.
QGraphicsItem * createBalloon()
Create graphic object of type Balloon.
virtual EnumType * getModeCreateArrow() const
Returns value that represents create arrow mode type belonging to enumeration.
QGraphicsItem * createImage()
Create graphic object of type ImageItem.
Class that represents a "Controller" part of Rectangle MVC component. Its coordinate system is the sa...
Class that represents a graphic Rectangle. Its coordinate system is the same of scene (millimeters)...
Definition: NorthItem.h:52
QGraphicsItem * createNorth()
Create graphic object of type NorthItem.
virtual void updateProperties(te::layout::Properties *properties)
Reimplemented from Observable.
Definition: TitleModel.cpp:169
virtual EnumType * getModeCreateMap() const
Returns value that represents create map mode type belonging to enumeration.
QGraphicsItem * createTextGrid()
Create graphic object of type TextGridItem.
Class responsible for creating or building graphics objects. All objects are children of QGraphicsIte...
virtual EnumType * getScaleItem() const
Returns value that represents scale (MVC Component) type belonging to enumeration.
Class that represents a "Controller" part of Rectangle MVC component. Its coordinate system is the sa...
Class that represents a "Controller" part of Rectangle MVC component. Its coordinate system is the sa...
This class is a proxy MapDisplay. This makes it possible to add a MapDisplay as item of a scene...
Definition: MapItem.h:74
virtual EnumType * getModeCreateImage() const
Returns value that represents create image mode type belonging to enumeration.
virtual int maxTypeId(te::layout::EnumType *type)
Search max id for a type.
Definition: ItemUtils.cpp:173
virtual EnumType * getModeCreateGridGeodesic() const
Returns value that represents create grid geodesic mode type belonging to enumeration.
virtual void updateProperties(te::layout::Properties *properties)
Reimplemented from Observable.
QGraphicsItem * createTitle()
Create graphic object of type TitleItem.
Class that represents text. This object is of type QGraphicsTextItem. He is directly editable via use...
Definition: TextItem.h:70
virtual EnumType * getLegendChildItem() const
Returns value that represents legend child (MVC Component) type belonging to enumeration.
Class that represents a "Model" part of Scale MVC component. Its coordinate system is the same of sce...
Definition: ScaleModel.h:63
Class that represents a graphic GridMap. Its coordinate system is the same of scene (millimeters)...