All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ItemFactory.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 ItemFactory.cpp
22 
23  \brief
24 
25  \ingroup layout
26 */
27 
28 // TerraLib
29 #include "ItemFactory.h"
30 #include "../../../../core/pattern/mvc/Observer.h"
31 #include "../../../../core/enum/Enums.h"
32 #include "../../../item/RectangleItem.h"
33 #include "../../../item/ItemGroup.h"
34 #include "../../../item/PaperItem.h"
35 #include "../../../item/MapItem.h"
36 #include "../../../item/GridMapItem.h"
37 #include "../../../item/LegendItem.h"
38 #include "../../../item/ScaleItem.h"
39 #include "../../../item/ImageItem.h"
40 #include "../../../item/PointItem.h"
41 #include "../../../item/ArrowItem.h"
42 #include "../../../item/EllipseItem.h"
43 #include "../../../item/TitleItem.h"
44 #include "../../../item/TextGridItem.h"
45 #include "../../../item/LegendChildItem.h"
46 #include "../../../item/TextItem.h"
47 #include "../../../item/MovingItemGroup.h"
48 #include "../../../item/LineItem.h"
49 #include "../../../item/PolygonItem.h"
50 #include "../../../item/BalloonItem.h"
51 #include "../../../item/BarCodeItem.h"
52 #include "../../../item/GridPlanarItem.h"
53 #include "../../../item/GridGeodesicItem.h"
54 #include "../../../item/NorthItem.h"
55 #include "../../../item/MapLocationItem.h"
56 
58 {
59 
60 }
61 
63 {
64 
65 }
66 
67 te::layout::Observer* te::layout::ItemFactory::make( EnumType* type, ItemParamsCreate params /*= LayoutItemParamsCreate()*/ )
68 {
69  Observer* item = 0;
70 
72 
73  if(type == enumObj->getRectangleItem())
74  {
75  RectangleItem* rectangle = new RectangleItem(params.getController(), params.getModel());
76  item = (Observer*)rectangle;
77  }
78  else if(type == enumObj->getLegendItem())
79  {
80  LegendItem* legend = new LegendItem(params.getController(), params.getModel());
81  item = (Observer*)legend;
82  }
83  else if(type == enumObj->getTextItem())
84  {
85  TextItem* txt = new TextItem(params.getController(), params.getModel());
86  item = (Observer*)txt;
87  }
88  else if(type == enumObj->getItemGroup())
89  {
90  ItemGroup* group = new ItemGroup(params.getController(), params.getModel());
91  item = (Observer*)group;
92  }
93  else if(type == enumObj->getPaperItem())
94  {
95  PaperItem* paper = new PaperItem(params.getController(), params.getModel());
96  item = (Observer*)paper;
97  }
98  else if(type == enumObj->getMapItem())
99  {
100  MapItem* map = new MapItem(params.getController(), params.getModel());
101  item = (Observer*)map;
102  }
103  else if(type == enumObj->getGridMapItem())
104  {
105  GridMapItem* gridMap = new GridMapItem(params.getController(), params.getModel());
106  item = (Observer*)gridMap;
107  }
108  else if(type == enumObj->getScaleItem())
109  {
110  ScaleItem* scale = new ScaleItem(params.getController(), params.getModel());
111  item = (Observer*)scale;
112  }
113  else if(type == enumObj->getImageItem())
114  {
115  ImageItem* scale = new ImageItem(params.getController(), params.getModel());
116  item = (Observer*)scale;
117  }
118  else if(type == enumObj->getPointItem())
119  {
120  PointItem* point = new PointItem(params.getController(), params.getModel());
121  item = (Observer*)point;
122  }
123  else if(type == enumObj->getArrowItem())
124  {
125  ArrowItem* arrow = new ArrowItem(params.getController(), params.getModel());
126  item = (Observer*)arrow;
127  }
128  else if(type == enumObj->getEllipseItem())
129  {
130  EllipseItem* ellipse = new EllipseItem(params.getController(), params.getModel());
131  item = (Observer*)ellipse;
132  }
133  else if(type == enumObj->getTitleItem())
134  {
135  TitleItem* title = new TitleItem(params.getController(), params.getModel());
136  item = (Observer*)title;
137  }
138  else if(type == enumObj->getTextGridItem())
139  {
140  TextGridItem* txtGrid = new TextGridItem(params.getController(), params.getModel());
141  item = (Observer*)txtGrid;
142  }
143  else if(type == enumObj->getLegendChildItem())
144  {
145  LegendChildItem* mText = new LegendChildItem(params.getController(), params.getModel());
146  item = (Observer*)mText;
147  }
148  else if (type == enumObj->getMovingItemGroup())
149  {
150  MovingItemGroup* mItemGroup = new MovingItemGroup(params.getController(), params.getModel());
151  item = (Observer*) mItemGroup;
152  }
153  else if(type == enumObj->getLineItem())
154  {
155  LineItem* line = new LineItem(params.getController(), params.getModel());
156  item = (Observer*)line;
157  }
158  else if(type == enumObj->getPolygonItem())
159  {
160  PolygonItem* polygon = new PolygonItem(params.getController(), params.getModel());
161  item = (Observer*)polygon;
162  }
163  else if(type == enumObj->getBalloonItem())
164  {
165  BalloonItem* balloon = new BalloonItem(params.getController(), params.getModel());
166  item = (Observer*)balloon;
167  }
168  else if(type == enumObj->getBarCodeItem())
169  {
170  BarCodeItem* barCode = new BarCodeItem(params.getController(), params.getModel());
171  item = (Observer*)barCode;
172  }
173  else if(type == enumObj->getGridPlanarItem())
174  {
175  GridPlanarItem* gridPlanar = new GridPlanarItem(params.getController(), params.getModel());
176  item = (Observer*)gridPlanar;
177  }
178  else if(type == enumObj->getGridMapItem())
179  {
180  GridGeodesicItem* gridGeodesic = new GridGeodesicItem(params.getController(), params.getModel());
181  item = (Observer*)gridGeodesic;
182  }
183  else if(type == enumObj->getNorthItem())
184  {
185  NorthItem* north = new NorthItem(params.getController(), params.getModel());
186  item = (Observer*)north;
187  }
188  else if(type == enumObj->getMapLocationItem())
189  {
190  MapLocationItem* location = new MapLocationItem(params.getController(), params.getModel());
191  item = (Observer*)location;
192  }
193 
194  return item;
195 }
196 
197 
virtual EnumType * getLineItem() const
Returns value that represents line (MVC Component) type belonging to enumeration. ...
virtual EnumType * getEllipseItem() const
Returns value that represents ellipse (MVC Component) type belonging to enumeration.
Class to represent a graphic object (MVC component) and widget object (MVC widget) type enumeration...
Class that represents a graphic sheet of paper. Its coordinate system is the same of scene (millimete...
Definition: PaperItem.h:52
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
virtual EnumType * getMapLocationItem() const
Returns value that represents map location (MVC Component) type belonging to enumeration.
virtual EnumType * getPaperItem() const
Returns value that represents paper (MVC Component) type belonging to enumeration.
Class that represents a graphic Arrow. Its coordinate system is the same of scene (millimeters)...
Definition: ArrowItem.h:52
ItemController * getController()
Returns the "Controller" part of the MVC.
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.
virtual EnumObjectType * getEnumObjectType()
Returns graphic object (MVC component) and widget object (MVC widget) type enumeration.
Definition: Enums.cpp:62
virtual ~ItemFactory()
Destructor.
Definition: ItemFactory.cpp:62
virtual EnumType * getPointItem() const
Returns value that represents point (MVC Component) type belonging to enumeration.
Class daughter of te::layout::TitleItem representing a grid with cells which can be inserted texts...
Definition: TextGridItem.h:48
Abstract class to represent an observer. "View" part of MVC component.
Definition: Observer.h:48
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 * 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 EnumType * getItemGroup() const
Returns value that represents item group (MVC Component) type belonging to enumeration.
static Enums & getInstance()
It returns a reference to the singleton instance.
virtual EnumType * getTextItem() const
Returns value that represents text (MVC Component) type belonging to enumeration. ...
virtual EnumType * getPolygonItem() const
Returns value that represents polygon (MVC Component) type belonging to enumeration.
Class that represents a graphic Image. Its coordinate system is the same of scene (millimeters)...
Definition: ImageItem.h:55
virtual EnumType * getTextGridItem() const
Returns value that represents text grid (MVC Component) 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 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
virtual EnumType * getLegendItem() const
Returns value that represents legend (MVC Component) type belonging to enumeration.
Class that represents a graphic Rectangle. Its coordinate system is the same of scene (millimeters)...
Definition: RectangleItem.h:52
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
Factory for creating families of related or dependent graphic objects (MVC components).
Class that represents a graphic Ellipse. Its coordinate system is the same of scene (millimeters)...
Definition: EllipseItem.h:52
Class daughter of te::layout::TextItem representing a grid with two cells which can be inserted texts...
Definition: TitleItem.h:48
Observable * getModel()
Returns the "Model" part of the MVC.
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.
Class that represents a graphic Rectangle. Its coordinate system is the same of scene (millimeters)...
Definition: NorthItem.h:52
Parameters to creation new object. Ex.: "Model" and "Controller" of the new object (MVC component)...
virtual Observer * make(EnumType *type, ItemParamsCreate params=ItemParamsCreate())
Reimplemented from AbstractItemFactory.
Definition: ItemFactory.cpp:67
virtual EnumType * getScaleItem() const
Returns value that represents scale (MVC Component) type belonging to enumeration.
ItemFactory()
Constructor.
Definition: ItemFactory.cpp:57
This class is a proxy MapDisplay. This makes it possible to add a MapDisplay as item of a scene...
Definition: MapItem.h:74
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 graphic GridMap. Its coordinate system is the same of scene (millimeters)...