All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
VisualizationArea.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2001-2014 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 VisualizationArea.cpp
22 
23  \brief
24 
25  \ingroup layout
26 */
27 
28 // TerraLib
29 #include "VisualizationArea.h"
30 #include "HorizontalRulerModel.h"
32 #include "HorizontalRulerItem.h"
33 #include "VerticalRulerModel.h"
35 #include "VerticalRulerItem.h"
36 #include "PaperModel.h"
37 #include "PaperController.h"
38 #include "PaperItem.h"
39 #include "ItemObserver.h"
40 #include "Context.h"
41 
43 {
44  m_boxArea = boxArea;
45 }
46 
48 {
49 
50 }
51 
53 {
54  init();
55 }
56 
58 {
59  createPaper();
60  createHorizontalRuler();
61  createVerticalRuler();
62 }
63 
65 {
66  createHorizontalRuler();
67  createVerticalRuler();
68 }
69 
71 {
72  double dpiX = te::layout::Context::getInstance()->getDpiX();
73 
74  double llx = m_boxArea->getLowerLeftX();
75  double lly = m_boxArea->getLowerLeftY();
76  double urx = m_boxArea->getUpperRightX();
77  double ury = m_boxArea->getUpperRightY();
78 
79  //Régua Vertical
80  VerticalRulerModel* modelRulerV = new VerticalRulerModel();
81  modelRulerV->setBox(te::gm::Envelope(llx, lly, llx + 10, ury));
82  VerticalRulerController* controllerRulerV = new VerticalRulerController(modelRulerV);
83  ItemObserver* itemRulerV = (ItemObserver*)controllerRulerV->getView();
84  VerticalRulerItem* rectRulerV = dynamic_cast<VerticalRulerItem*>(itemRulerV);
85  rectRulerV->setPPI(dpiX);
86  rectRulerV->setPos(QPointF(llx, lly));
87  rectRulerV->redraw();
88  rectRulerV->setZValue(10001);
89 }
90 
92 {
93  double dpiX = te::layout::Context::getInstance()->getDpiX();
94 
95  double llx = m_boxArea->getLowerLeftX();
96  double lly = m_boxArea->getLowerLeftY();
97  double urx = m_boxArea->getUpperRightX();
98  double ury = m_boxArea->getUpperRightY();
99 
100  //Régua Horizontal
101  HorizontalRulerModel* modelRuler = new HorizontalRulerModel();
102  modelRuler->setBox(te::gm::Envelope(llx, lly, urx, lly + 10));
103  HorizontalRulerController* controllerRuler = new HorizontalRulerController(modelRuler);
104  ItemObserver* itemRuler = (ItemObserver*)controllerRuler->getView();
105  HorizontalRulerItem* rectRuler = dynamic_cast<HorizontalRulerItem*>(itemRuler);
106  rectRuler->setPPI(dpiX);
107  rectRuler->setPos(QPointF(llx, lly));
108  rectRuler->redraw();
109  rectRuler->setZValue(10000);
110 }
111 
113 {
114  double dpiX = te::layout::Context::getInstance()->getDpiX();
115 
116  double llx = m_boxArea->getLowerLeftX();
117  double lly = m_boxArea->getLowerLeftY();
118  double urx = m_boxArea->getUpperRightX();
119  double ury = m_boxArea->getUpperRightY();
120 
121  //Paper
122  PaperModel* modelPaper = new PaperModel(te::layout::Context::getInstance()->getPaperConfig());
123  PaperController* controllerPaper = new PaperController(modelPaper);
124  ItemObserver* itemPaper = (ItemObserver*)controllerPaper->getView();
125  PaperItem* qPaper = dynamic_cast<PaperItem*>(itemPaper);
126  qPaper->setPos(QPointF(0,lly));
127  qPaper->setZValue(1);
128  qPaper->redraw();
129 }
130 
132 {
133  m_boxArea = boxArea;
134 }
virtual void setBox(te::gm::Envelope box)
const Observer * getView()
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
void setZValue(qreal z)
Definition: ObjectItem.cpp:428
VisualizationArea(te::gm::Envelope *boxArea)
virtual void setPos(const QPointF &pos)
Definition: ObjectItem.cpp:79
virtual void setBox(te::gm::Envelope box)
virtual void changeBoxArea(te::gm::Envelope *boxArea)
virtual void redraw(const double &scaleFactor=1.)
virtual void setPPI(const double &ppi)
static Context * getInstance()
This function is called to create an instance of the class.
Definition: Context.cpp:46