All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Scene.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 Scene.cpp
22 
23  \brief
24 
25  \ingroup layout
26 */
27 
28 // TerraLib
29 #include "Scene.h"
30 #include "../../core/pattern/mvc/ItemObserver.h"
31 #include "../../core/pattern/mvc/Observable.h"
32 #include "../../core/pattern/singleton/Context.h"
33 #include "../../core/enum/Enums.h"
35 #include "../item/ItemGroup.h"
36 #include "BuildGraphicsItem.h"
38 #include "../../core/AbstractBuildGraphicsItem.h"
39 #include "../../core/template/TemplateEditor.h"
40 #include "../../core/template/AbstractTemplate.h"
41 #include "../../core/property/Properties.h"
42 #include "VisualizationArea.h"
43 #include "../../../qt/widgets/Utils.h"
44 #include "../../core/Utils.h"
45 #include "../../../common/STLUtils.h"
46 #include "../item/MapItem.h"
48 
49 // STL
50 #include <algorithm>
51 
52 // Qt
53 #include <QUndoCommand>
54 #include <QUndoStack>
55 #include <QGraphicsItem>
56 #include <QPainter>
57 #include <QStyleOptionGraphicsItem>
58 #include <QPrinter>
59 #include <QGraphicsTextItem>
60 
61 te::layout::Scene::Scene( QObject* object):
62  QGraphicsScene(object),
63  m_undoStack(0),
64  m_align(0),
65  m_print(0),
66  m_moveWatched(false)
67 {
68  m_backgroundColor = QColor(109,109,109);
69  setBackgroundBrush(QBrush(m_backgroundColor));
70 
71  m_undoStack = new QUndoStack(this);
72 }
73 
74 te::layout::Scene::Scene( AlignItems* align, PrintScene* print, QObject* object /*= 0*/ ) :
75  QGraphicsScene(object),
76  m_undoStack(0),
77  m_align(align),
78  m_print(print),
79  m_moveWatched(false)
80 {
81 
82 }
83 
85 {
86  m_moveWatches.clear();
87 
88  if(m_undoStack)
89  {
90  delete m_undoStack;
91  m_undoStack = 0;
92  }
93 
94  foreach( QGraphicsItem *item, m_itemStackWithoutScene )
95  {
96  if(item->scene() != this)
97  {
98  delete item;
99  item = 0;
100  }
101  }
102 
103  if(m_align)
104  {
105  delete m_align;
106  m_align = 0;
107  }
108 
109  if(m_print)
110  {
111  delete m_print;
112  m_print = 0;
113  }
114 }
115 
117 {
118  if(!item)
119  {
120  return;
121  }
122 
123  QGraphicsItem* qitem = ((QGraphicsItem*)item);
124 
125  insertItem(qitem);
126 }
127 
128 void te::layout::Scene::insertItem( QGraphicsItem* item )
129 {
130  if(!item)
131  {
132  return;
133  }
134 
135  if(item->scene() == this)
136  {
137  return;
138  }
139 
140  int total = 0;
141 
142  total = this->items().count();
143 
144  this->addItem(item);
145 
146  ItemObserver* obs = dynamic_cast<ItemObserver*>(item);
147  if(!obs)
148  {
149  return;
150  }
151 
152  if(obs->isInvertedMatrix())
153  {
154  QTransform transfItem = item->transform();
155  // Check if the item had been inserted
156  if(transfItem != m_matrix.inverted())
157  {
158  QTransform transf = m_matrix.inverted();
159  item->setTransform(transf);
160  }
161  }
162 
163  item->setZValue(total);
164  QGraphicsObject* qObj = dynamic_cast<QGraphicsObject*>(item);
165  if(qObj)
166  {
167  qObj->installEventFilter(this);
168  }
169 
170  obs->refresh(false);
171 
172  removeItemStackWithoutScene(item);
173 
174  emit addItemFinalized();
175 }
176 
177 void te::layout::Scene::init( double screenWMM, double screenHMM )
178 {
179  calculateSceneMeasures(screenWMM, screenHMM);
180 
182  if(!config)
183  return;
184 
185  if(!m_align)
186  {
187  m_align = new AlignItems(this, config);
188  }
189 
190  if(!m_print)
191  {
192  m_print = new PrintScene(this, config);
193  }
194 }
195 
197 {
198  double llx = m_box.m_llx;
199  double lly = m_box.m_lly;
200  double urx = m_box.m_urx;
201  double ury = m_box.m_ury;
202 
203  double dpiX = Context::getInstance().getDpiX();
204 
205  double factor = (dpiX / 25.4);
206 
207  //inverted Y-Axis
208  m_matrix = QTransform().scale(factor, -factor).translate(-llx, -ury);
209  //World coordinate - mm
210  setSceneRect(QRectF(QPointF(llx, lly), QPointF(urx, ury)));
211 }
212 
213 void te::layout::Scene::calculateWindow( double wMM, double hMM )
214 {
215  double ppSizeWMM;
216  double ppSizeHMM;
217 
219  config->getPaperSize(ppSizeWMM, ppSizeHMM);
220 
221  double x1 = 0;
222  double y1 = 0;
223  double x2 = 0;
224  double y2 = 0;
225 
226  double paddingX = 0;
227  double paddingY = 0;
228 
229  //X-Axis
230  double minX = std::min(ppSizeWMM, wMM);
231  double maxX = std::max(ppSizeWMM, wMM);
232 
233  paddingX = (maxX - minX) / 2;
234  x1 = - paddingX;
235  x2 = maxX - paddingX;
236 
237  //Y-Axis
238  double minY = std::min(ppSizeHMM, hMM);
239  double maxY = std::max(ppSizeHMM, hMM);
240 
241  paddingY = (maxY - minY) / 2;
242  y1 = - paddingY;
243  y2 = maxY - paddingY;
244 
245  m_box.m_llx = x1;
246  m_box.m_lly = y1;
247  m_box.m_urx = x2;
248  m_box.m_ury = y2;
249 }
250 
252 {
253  return m_matrix;
254 }
255 
257 {
258  std::vector<std::string> names;
259 
260  QList<QGraphicsItem*> graphicsItems = selectedItems();
261  foreach( QGraphicsItem *item, graphicsItems)
262  {
263  if (item)
264  {
265  removeItem(item);
266  if(item)
267  {
268  ItemObserver* obs = dynamic_cast<ItemObserver*>(item);
269  if(obs)
270  {
271  if(obs->getModel())
272  names.push_back(obs->getModel()->getName());
273  }
274  delete item;
275  item = 0;
276  }
277  }
278  }
279 
280  if(!names.empty())
281  emit deleteFinalized(names);
282 }
283 
285 {
286  std::vector<std::string> names;
287 
288  QList<QGraphicsItem*> graphicsItems = selectedItems();
289 
290  if(graphicsItems.empty())
291  return;
292 
293  foreach( QGraphicsItem *item, graphicsItems)
294  {
295  if (item)
296  {
297  ItemObserver* obs = dynamic_cast<ItemObserver*>(item);
298  if(obs)
299  {
300  if(obs->getModel())
301  names.push_back(obs->getModel()->getName());
302  }
303  }
304  }
305 
306  QUndoCommand* command = new DeleteCommand(this);
307  addUndoStack(command);
308 
309  if(!names.empty())
310  emit deleteFinalized(names);
311 }
312 
313 void te::layout::Scene::addUndoStack( QUndoCommand* command )
314 {
315  m_undoStack->push(command);
316 }
317 
319 {
320  m_undoStackLimit = limit;
321 }
322 
324 {
325  return m_undoStackLimit;
326 }
327 
329 {
330  return m_undoStack;
331 }
332 
333 QGraphicsItemGroup* te::layout::Scene::createItemGroup( const QList<QGraphicsItem *> & items )
334 {
335  //The scene create a new group with important restriction
336  QGraphicsItemGroup* p = QGraphicsScene::createItemGroup(items);
337 
339 
340  //Create a new group
342  BuildGraphicsItem* build = dynamic_cast<BuildGraphicsItem*>(abstractBuild);
343 
344  if(!build)
345  return p;
346 
347  te::gm::Coord2D coord(0,0);
348  QGraphicsItem* item = build->createItem(mode->getModeCreateItemGroup(), coord, false);
349 
350  ItemGroup* group = dynamic_cast<ItemGroup*>(item);
351 
352  if(p)
353  {
354  if(group)
355  {
356  QGraphicsItem* parent = group->parentItem();
357  group->setParentItem(p->parentItem());
358  foreach (QGraphicsItem *item, p->childItems())
359  {
360  group->addToGroup(item);
361  }
362 
363  delete p;
364 
365  group->setParentItem(parent);
366 
367  QUndoCommand* command = new AddCommand(group);
368  addUndoStack(command);
369  }
370  }
371 
372  return group;
373 }
374 
375 void te::layout::Scene::destroyItemGroup( QGraphicsItemGroup *group )
376 {
377  group->setHandlesChildEvents(false);
378  QGraphicsScene::destroyItemGroup(group);
379 }
380 
382 {
383  //Create a new group
385  BuildGraphicsItem* build = dynamic_cast<BuildGraphicsItem*>(abstractBuild);
386 
388 
389  QGraphicsItem* item = 0;
390 
391  item = build->createItem(enumObj->getMovingItemGroup());
392 
393  te::layout::MovingItemGroup* movingItem = dynamic_cast<MovingItemGroup*>(item);
394 
395  if (movingItem)
396  {
397  foreach(QGraphicsItem* i, items)
398  {
399  movingItem->addToGroup(i);
400  }
401 
402  movingItem->setHandlesChildEvents(true);
403  }
404 
405  return movingItem;
406 }
407 
408 QGraphicsItem* te::layout::Scene::createItem( const te::gm::Coord2D& coord )
409 {
410  QGraphicsItem* item = 0;
411 
413  BuildGraphicsItem* build = dynamic_cast<BuildGraphicsItem*>(abstractBuild);
414 
415  if(!build)
416  return item;
417 
420 
421  item = build->createItem(mode, coord);
422 
423  if(item)
424  {
425  ItemObserver* obs = dynamic_cast<ItemObserver*>(item);
426  if(obs)
427  {
428  if(obs->isCanChangeGraphicOrder())
429  {
430  QUndoCommand* command = new AddCommand(item);
431  addUndoStack(command);
432  }
433  }
434  }
435 
437 
438  return item;
439 }
440 
441 void te::layout::Scene::calculateSceneMeasures( double widthMM, double heightMM )
442 {
443  calculateWindow(widthMM, heightMM);
444 
445  double w = m_box.getWidth();
446  double h = m_box.getHeight();
447 
448  calculateWindow(w,h);
449 
450  calculateMatrixViewScene();
451 }
452 
454 {
455  return m_print;
456 }
457 
459 {
460  return m_align;
461 }
462 
463 bool te::layout::Scene::exportPropertiesToTemplate( EnumType* type, std::string fileName )
464 {
465  bool is_export = false;
466 
467  if(fileName.compare("") == 0)
468  {
469  return is_export;
470  }
471 
472  std::vector<te::layout::Properties*> props = getItemsProperties();
473 
474  if(props.empty())
475  return is_export;
476 
477  TemplateEditor editor(type, fileName);
478 
479  AbstractTemplate* jtemplate = editor.getTemplate();
480 
481  if(!jtemplate)
482  return is_export;
483 
484  is_export = jtemplate->exportTemplate(props);
485 
486  return is_export;
487 }
488 
489 std::vector<te::layout::Properties*> te::layout::Scene::importTemplateToProperties( EnumType* type, std::string fileName )
490 {
491  std::vector<te::layout::Properties*> props;
492 
493  if(fileName.compare("") == 0)
494  {
495  return props;
496  }
497 
498  TemplateEditor editor(type, fileName);
499 
500  AbstractTemplate* jtemplate = editor.getTemplate();
501 
502  if(!jtemplate)
503  return props;
504 
505  props = jtemplate->importTemplate();
506 
507  return props;
508 }
509 
510 std::vector<te::layout::Properties*> te::layout::Scene::getItemsProperties()
511 {
512  std::vector<te::layout::Properties*> props;
513 
514  QList<QGraphicsItem*> graphicsItems = items();
515  foreach( QGraphicsItem *item, graphicsItems)
516  {
517  if (item)
518  {
519  ItemObserver* lItem = dynamic_cast<ItemObserver*>(item);
520  if(lItem)
521  {
522  if(!lItem->isPrintable())
523  continue;
524 
525  if(lItem->getModel())
526  props.push_back(lItem->getModel()->getProperties());
527  }
528  }
529  }
530 
531  return props;
532 }
533 
535 {
536  if(!m_undoStack)
537  return;
538 
539  if(m_undoStack->count() > 0)
540  m_undoStack->clear();
541 
542  clear();
543 }
544 
545 bool te::layout::Scene::buildTemplate( VisualizationArea* vzArea, EnumType* type, std::string fileName )
546 {
548  BuildGraphicsItem* build = dynamic_cast<BuildGraphicsItem*>(abstractBuild);
549 
550  if(!build)
551  return false;
552 
553  std::vector<te::layout::Properties*> props = importTemplateToProperties(type, fileName);
554 
555  if(props.empty())
556  return false;
557 
558  reset();
559 
560  std::vector<te::layout::Properties*>::iterator it;
561 
562  te::gm::Envelope boxW = getSceneBox();
563  vzArea->changeBoxArea(boxW);
564 
565  for(it = props.begin() ; it != props.end() ; ++it)
566  {
567  te::layout::Properties* proper = (*it);
568 
569  if(!proper)
570  continue;
571 
572  build->rebuildItem(proper);
573  }
574 
575  return true;
576 }
577 
579 {
580  QList<QGraphicsItem*> selected = selectedItems();
581  foreach(QGraphicsItem *item, selected)
582  {
583  if(item)
584  {
585  ItemObserver* it = dynamic_cast<ItemObserver*>(item);
586  if(it)
587  {
588  MapItem* mt = dynamic_cast<MapItem*>(it);
589  if(mt)
590  {
591  mt->redraw();
592  }
593  }
594  }
595  }
596 }
597 
599 {
600  Utils* utils = Context::getInstance().getUtils();
601 
602  QList<QGraphicsItem*> selected = selectedItems();
603  foreach(QGraphicsItem *item, selected)
604  {
605  if(item)
606  {
607  ItemObserver* it = dynamic_cast<ItemObserver*>(item);
608  if(it)
609  {
610  QImage* img = 0;
611  int w = 0;
612  int h = 0;
613 
614  if(!it->getModel())
615  {
616  continue;
617  }
618 
619  te::color::RGBAColor** rgba = it->getRGBAColorImage(w, h);
620 
621  if(!rgba)
622  continue;
623 
624  //QRectF rect = item->boundingRect();
625  img = te::qt::widgets::GetImage(rgba, w, h);
626  if(!img)
627  continue;
628 
629  std::string dirName = dir + "/" + it->getModel()->getName() +".png";
630 
631  img->save(dirName.c_str());
632 
633  te::common::Free(rgba, h);
634 
635  if(img)
636  delete img;
637  }
638  }
639  }
640 }
641 
642 bool te::layout::Scene::eventFilter( QObject * watched, QEvent * event )
643 {
644  if(event->type() == QEvent::GraphicsSceneMousePress)
645  {
646  QGraphicsItem* item = dynamic_cast<QGraphicsItem*>(watched);
647  if(item)
648  {
649  QList<QGraphicsItem*> its = selectedItems();
650  m_moveWatches.clear();
651  if(its.empty())
652  {
653  QPointF pt = item->scenePos();
654  m_moveWatches[item] = pt;
655  }
656  foreach(QGraphicsItem *item, its)
657  {
658  QPointF pt = item->scenePos();
659  m_moveWatches[item] = pt;
660  }
661  }
662  }
663 
664  if(event->type() == QEvent::GraphicsSceneMouseMove)
665  {
666  QGraphicsItem* item = dynamic_cast<QGraphicsItem*>(watched);
667  if(item)
668  {
669  bool resultFound = false;
670  std::map<QGraphicsItem*, QPointF>::iterator it;
671  for(it = m_moveWatches.begin() ; it != m_moveWatches.end() ; ++it)
672  {
673  if(it->first == item)
674  {
675  resultFound = true;
676  }
677  }
678 
679  if(!resultFound)
680  {
681  m_moveWatches.clear();
682  QPointF pt = item->scenePos();
683  m_moveWatches[item] = pt;
684  }
685 
686  m_moveWatched = true;
687  }
688  }
689 
690  if(event->type() == QEvent::GraphicsSceneMouseRelease)
691  {
692  QGraphicsItem* item = dynamic_cast<QGraphicsItem*>(watched);
693  if(item)
694  {
695  if(m_moveWatched)
696  {
697  QUndoCommand* command = new MoveCommand(m_moveWatches);
698  addUndoStack(command);
699  m_moveWatched = false;
700  }
701  }
702  }
703 
704  return QGraphicsScene::eventFilter(watched, event);
705 }
706 
707 void te::layout::Scene::selectItem( std::string name )
708 {
709  QList<QGraphicsItem*> allItems = items();
710  foreach(QGraphicsItem *item, allItems)
711  {
712  if(item)
713  {
714  ItemObserver* it = dynamic_cast<ItemObserver*>(item);
715  if(it)
716  {
717  if(!it->getModel())
718  {
719  continue;
720  }
721 
722  if(it->getModel()->getName().compare(name) == 0)
723  {
724  item->setSelected(true);
725  }
726  else
727  {
728  item->setSelected(false);
729  }
730  }
731  }
732  }
733 }
734 
735 void te::layout::Scene::selectItem( QGraphicsItem* item )
736 {
737  if (item)
738  {
739  item->setSelected(true);
740  }
741 }
742 
743 void te::layout::Scene::selectItems( std::vector<std::string> names )
744 {
745  foreach(std::string name, names)
746  {
747  this->selectItem(name);
748  }
749 }
750 
751 void te::layout::Scene::selectItems( QList<QGraphicsItem*> items )
752 {
753  foreach(QGraphicsItem* item, items)
754  {
755  this->selectItem(item);
756  }
757 }
758 
760 {
761  QList<QGraphicsItem*> allItems = items();
762  foreach(QGraphicsItem *item, allItems)
763  {
764  if(item)
765  {
766  ItemObserver* it = dynamic_cast<ItemObserver*>(item);
767  if(it)
768  {
769  if(it->isPrintable())
770  {
771  it->redraw();
772  }
773  }
774  }
775  }
776 }
777 
779 {
780  QList<QGraphicsItem*> allItems = selectedItems();
781  foreach(QGraphicsItem *item, allItems)
782  {
783  if(item)
784  {
785  ItemObserver* it = dynamic_cast<ItemObserver*>(item);
786  if(it)
787  {
788  it->refresh();
789  }
790  }
791  }
792 }
793 
794 void te::layout::Scene::onChangeZoomFactor( double currentFactor )
795 {
796  QList<QGraphicsItem*> allItems = items();
797  foreach(QGraphicsItem *item, allItems)
798  {
799  if(item)
800  {
801  ItemObserver* it = dynamic_cast<ItemObserver*>(item);
802  if(it)
803  {
804  it->changeZoomFactor(currentFactor);
805  }
806  }
807  }
808 }
809 
811 {
812  if(!item)
813  {
814  return false;
815  }
816 
817  if(item->scene() == this)
818  {
819  return false;
820  }
821 
822  if(m_itemStackWithoutScene.contains(item))
823  {
824  return false;
825  }
826 
827  m_itemStackWithoutScene.push_back(item);
828 
829  return true;
830 }
831 
833 {
834  if(!item)
835  {
836  return false;
837  }
838 
839  return m_itemStackWithoutScene.removeOne(item);
840 }
841 
842 
843 
844 
QUndoStack * m_undoStack
Undo/Redo stack.
Definition: Scene.h:370
Class to represent a graphic object (MVC component) and widget object (MVC widget) type enumeration...
virtual void reset()
Method that clears the scene and the stack of Undo/Redo.
Definition: Scene.cpp:534
virtual void redrawSelectionMap()
Redraws the Layer of the selected map.
Definition: Scene.cpp:578
Class responsible for paper setting. Size, orientation, custom size, etc.
Definition: PaperConfig.h:45
virtual ~Scene()
Destructor.
Definition: Scene.cpp:84
virtual te::color::RGBAColor ** getRGBAColorImage(int &w, int &h)=0
Returns a image of the graphic component. Reimplement this function in a ItemObserver subclass to pro...
Creates the viewing area. Ex.: creation of the sheet of paper.
virtual EnumModeType * getEnumModeType()
Returns mode type enumeration.
Definition: Enums.cpp:92
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
QColor m_backgroundColor
background color that is applied to each observer(QGraphicsView) of the scene.
Definition: Scene.h:369
Undo/Redo for add one components.
Definition: AddCommand.h:51
Class applying the alignment of one or more objects. Ex .: send to back, bring to front...
Definition: AlignItems.h:49
Class representing the scene. This scene is child of QGraphicsScene, part of Graphics View Framework...
Creates the viewing area. Ex.: creation of the sheet of paper.
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
virtual void deleteItems()
Method that deletes all selected items in the scene.
Definition: Scene.cpp:256
virtual te::layout::AbstractTemplate * getTemplate()
QGraphicsItem * createItem(te::layout::EnumType *mode, const te::gm::Coord2D &coordinate, bool draw=true)
Method to create a graphic object from the properties.
virtual EnumObjectType * getEnumObjectType()
Returns graphic object (MVC component) and widget object (MVC widget) type enumeration.
Definition: Enums.cpp:62
virtual void selectItem(std::string name)
Select an item an item by name.
Definition: Scene.cpp:707
virtual bool isInvertedMatrix()
Returns whether the graph component has the inverted matrix, otherwise the matrix scene...
virtual void redraw(bool bRefresh=true)
Redraws the graphic component.
virtual bool isPrintable()
Returns whether the graphic component is printable.
virtual void onChangeZoomFactor(double currentFactor)
It is called immediately when the zoom factor is changed in the Context.
Definition: Scene.cpp:794
virtual bool exportPropertiesToTemplate(EnumType *type, std::string fileName)
Method that exports all the objects in the scene to a template. Ex.: JSON.
Definition: Scene.cpp:463
virtual void selectItems(std::vector< std::string > names)
Select items by name.
Definition: Scene.cpp:743
virtual AlignItems * getAlignItems()
Method that returns the object responsible for aligning objects in the scene.
Definition: Scene.cpp:458
Class responsible for creating or building graphics objects. All objects are children of QGraphicsIte...
virtual EnumType * getModeCreateItemGroup() const
Returns value that represents create item group mode type belonging to enumeration.
void Free(std::vector< T * > *v)
This function can be applied to a pointer to a vector of pointers.
Definition: STLUtils.h:131
virtual bool buildTemplate(VisualizationArea *vzArea, EnumType *type, std::string fileName)
Method that import a template and build all objects. Ex.: JSON.
Definition: Scene.cpp:545
virtual void changeZoomFactor(double currentZoomFactor)
It is called immediately by the Scene when the zoom factor is changed in the Context.
Scene(QObject *object=(QObject *) 0)
Constructor.
Definition: Scene.cpp:61
virtual PrintScene * getPrintScene()
Method that returns the object responsible for printing the scene.
Definition: Scene.cpp:453
virtual QGraphicsItemGroup * createItemGroup(const QList< QGraphicsItem * > &items)
Groups objects and creates a QGraphicsItemGroup object. A command Undo/Redo of type AddCommand is cre...
Definition: Scene.cpp:333
virtual bool exportTemplate(std::vector< te::layout::Properties * > properties)=0
virtual void calculateMatrixViewScene()
Method that calculates the transformation matrix of the scene. This matrix will be set in each QGraph...
Definition: Scene.cpp:196
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
virtual QUndoStack * getUndoStack()
Method that return stack of Undo/Redo.
Definition: Scene.cpp:328
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
virtual bool isCanChangeGraphicOrder()
Returns whether the graphic component to be or not send to back or bring to front.
Undo/Redo for moving components.
virtual EnumType * getModeNone() const
Returns value that represents none mode type belonging to enumeration.
Utils * getUtils()
Returns pointer with functions to manipulate the canvas and conversion between projections.
Definition: Context.cpp:153
virtual void redrawItems()
Definition: Scene.cpp:759
virtual void refresh(bool pos=true)
Updated model state.
virtual void init(double screenWMM, double screenHMM)
Method that starts the scene and configures. Calculates the transformation matrix of the scene and ca...
Definition: Scene.cpp:177
QGraphicsItem * rebuildItem(te::layout::Properties *props, bool draw=true)
Method to build a graphics object from the properties.
virtual bool addItemStackWithoutScene(QGraphicsItem *item)
Definition: Scene.cpp:810
virtual void changeBoxArea(te::gm::Envelope boxArea)
Undo/Redo for delete one or more components.
virtual te::layout::Properties * getProperties() const =0
Returns the model state as properties. Reimplement this function in a Observable subclass to provide ...
Calls the factory to create a template of the specified type and keep. Responsible for delete the cre...
EnumType * getMode()
Returns value of the enumeration of mode type.
Definition: Context.cpp:75
AbstractBuildGraphicsItem * getAbstractBuildGraphicsItem()
Returns pointer for build graphics MVC components.
Definition: Context.cpp:208
virtual std::vector< te::layout::Properties * > importTemplateToProperties(EnumType *type, std::string fileName)
Method that imports a template and turns it into properties. Ex.: JSON.
Definition: Scene.cpp:489
virtual void calculateSceneMeasures(double widthMM, double heightMM)
Method that resets the scene and calculates again.
Definition: Scene.cpp:441
virtual void addToGroup(QGraphicsItem *item)
Definition: ItemGroup.cpp:125
Undo/Redo for delete one or more components.
Definition: DeleteCommand.h:51
virtual EnumType * getMovingItemGroup() const
Returns value that represents moving item group (MVC Component) type belonging to enumeration...
virtual void calculateWindow(double wMM, double hMM)
Method that calculates the ratio of the size of the scene with the paper size. This calculation is ne...
Definition: Scene.cpp:213
virtual void exportItemsToImage(std::string dir)
Saves each item in the scene as image. Ex .: .png.
Definition: Scene.cpp:598
virtual bool eventFilter(QObject *watched, QEvent *event)
Reimplemented from QGraphicsScene.
Definition: Scene.cpp:642
Abstract class that represents a Template.
virtual QGraphicsItem * createItem(const te::gm::Coord2D &coord)
Method that create a graphic object and place it in the scene. A name and a position is added...
Definition: Scene.cpp:408
virtual void setUndoStackLimit(int limit)
Method that limits the size of the stack of Undo/Redo.
Definition: Scene.cpp:318
TEQTWIDGETSEXPORT QImage * GetImage(te::color::RGBAColor **img, int width, int height)
It creates a QImage from an RGBA color array.
Definition: Utils.cpp:69
virtual bool removeItemStackWithoutScene(QGraphicsItem *item)
Definition: Scene.cpp:832
virtual void getPaperSize(double &w, double &h)
Returns paper size. Height and Width.
Definition: PaperConfig.cpp:61
Undo/Redo for moving components.
Definition: MoveCommand.h:54
Class that represents the value of an enumeration. An enumeration is made of "1..n" objects EnumType...
Definition: EnumType.h:48
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
virtual Observable * getModel()
Returns the "Model" part of the MVC.
Class responsible for printing the entire content or part of the scene. As the scene is upside down...
Definition: PrintScene.h:54
virtual void addUndoStack(QUndoCommand *command)
Method that insert command Undo/Redo of type AddCommand in the Undo/Redo stack.
Definition: Scene.cpp:313
virtual QTransform sceneTransform()
Method that returns the matrix transformation scene.
Definition: Scene.cpp:251
virtual std::vector< te::layout::Properties * > importTemplate()=0
Undo/Redo for add one components.
virtual te::layout::MovingItemGroup * createMovingItemGroup(const QList< QGraphicsItem * > &items)
Definition: Scene.cpp:381
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 void updateSelectedItemsPositions()
Definition: Scene.cpp:778
virtual void removeSelectedItems()
Method that removes all selected items in the scene and creates a Command to Undo/Redo of type Delete...
Definition: Scene.cpp:284
PaperConfig * getPaperConfig() const
Returns paper setting.
Definition: Context.cpp:198
Abstract class for build graphics MVC components.
virtual std::string getName()=0
Method that returns the name of the MVC component. Reimplement this function in a Observable subclass...
virtual void insertItem(ItemObserver *item)
Method that inserts a graphic object in the scene. Inverts the matrix of the object if necessary...
Definition: Scene.cpp:116
Utility class with functions to manipulate the canvas and conversion between projections.
Definition: Utils.h:61
Class responsible for creating or building graphics objects. All objects are children of QGraphicsIte...
virtual int getUndoStackLimit()
Method that returns the size limit of the stack Undo/Redo.
Definition: Scene.cpp:323
virtual void destroyItemGroup(QGraphicsItemGroup *group)
Method that delete object grouping, but the individual objects continue to exist. ...
Definition: Scene.cpp:375
virtual std::vector< te::layout::Properties * > getItemsProperties()
Method that returns a list of the properties of all the graphic objects in the scene.
Definition: Scene.cpp:510
This class is a proxy MapDisplay. This makes it possible to add a MapDisplay as item of a scene...
Definition: MapItem.h:74