All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PageSetupOutside.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 PageSetupOutside.cpp
22 
23  \brief
24 
25  \ingroup layout
26 */
27 
28 // TerraLib
29 #include "PageSetupOutside.h"
30 #include "ui_PageSetup.h"
31 #include "../../core/pattern/mvc/OutsideObserver.h"
32 #include "../../core/pattern/mvc/OutsideController.h"
33 #include "../../core/pattern/singleton/Context.h"
34 
35 // STL
36 #include <string>
37 #include <sstream>
38 
39 // Qt
40 #include <QColorDialog>
41 #include <QFrame>
42 #include <QLineEdit>
43 #include <QValidator>
44 #include <QComboBox>
45 #include <QCheckBox>
46 #include <QMessageBox>
47 #include <QObjectList>
48 
50  QDialog(0),
51  OutsideObserver(controller, o),
52  m_orientation(te::layout::Portrait),
53  m_paperType(te::layout::A4),
54  m_ui(new Ui::PageSetup)
55 {
56  m_ui->setupUi(this);
57 
58  setWindowFlags( Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint
59  | Qt::WindowTitleHint | Qt::WindowStaysOnTopHint );
60 
61  init();
62 }
63 
65 {
66 
67 }
68 
70 {
71  m_ui->lneCustomWidth->setValidator(new QDoubleValidator(this));
72  m_ui->lneCustomHeight->setValidator(new QDoubleValidator(this));
73 }
74 
76 {
77  setVisible(context.isShow());
78  if(context.isShow() == true)
79  show();
80  else
81  hide();
82 }
83 
84 void te::layout::PageSetupOutside::setPosition( const double& x, const double& y )
85 {
86  move(x,y);
87  refresh();
88 }
89 
91 {
92  QPointF posF = pos();
93  qreal valuex = posF.x();
94  qreal valuey = posF.y();
95 
96  te::gm::Coord2D coordinate;
97  coordinate.x = valuex;
98  coordinate.y = valuey;
99 
100  return coordinate;
101 }
102 
104 {
106 
107  double w = 0;
108  double h = 0;
109  pConfig->getPaperSize(w, h);
110 
111  configureOrientationPage();
112  configurePageSize();
113 }
114 
116 {
117  if (m_orientation == te::layout::Landscape)
118  {
119  m_ui->rdbLandscape->setChecked(true);
120  }
121  else
122  {
123  m_ui->rdbPortrait->setChecked(true);
124  }
125 }
126 
128 {
129  m_ui->cmbPageSize->clear();
130  int index = 0;
131  index = m_ui->cmbPageSize->findData("ISO A0 - 841 x 1189 mm");
132  m_ui->cmbPageSize->insertItem(index,"ISO A0 - 841 x 1189 mm");
133 
134  index = m_ui->cmbPageSize->findData("ISO A1 - 594 x 841 mm");
135  m_ui->cmbPageSize->insertItem(index,"ISO A1 - 594 x 841 mm");
136 
137  index = m_ui->cmbPageSize->findData("ISO A2 - 420 x 594 mm");
138  m_ui->cmbPageSize->insertItem(index,"ISO A2 - 420 x 594 mm");
139 
140  index = m_ui->cmbPageSize->findData("ISO A3 - 297 x 420 mm");
141  m_ui->cmbPageSize->insertItem(index,"ISO A3 - 297 x 420 mm");
142 
143  index = m_ui->cmbPageSize->findData("ISO A4 - 210 x 297 mm");
144  m_ui->cmbPageSize->insertItem(index,"ISO A4 - 210 x 297 mm");
145 
146  index = m_ui->cmbPageSize->findData("ISO A5 - 148 x 210 mm");
147  m_ui->cmbPageSize->insertItem(index,"ISO A5 - 148 x 210 mm");
148 
149  /*index = m_ui->cmbPageSize->findData("Custom");
150  m_ui->cmbPageSize->insertItem(index,"Custom");*/
151 
153 
154  std::string curItem;
155  if (pConfig->getPaperType() == te::layout::A0)
156  curItem = "ISO A0 - 841 x 1189 mm";
157  else if (pConfig->getPaperType() == te::layout::A1)
158  curItem = "ISO A1 - 594 x 841 mm";
159  else if (pConfig->getPaperType() == te::layout::A2)
160  curItem = "ISO A2 - 420 x 594 mm";
161  else if (pConfig->getPaperType() == te::layout::A3)
162  curItem = "ISO A3 - 297 x 420 mm";
163  else if (pConfig->getPaperType() == te::layout::A4)
164  curItem = "ISO A4 - 210 x 297 mm";
165  else if (pConfig->getPaperType() == te::layout::A5)
166  curItem = "ISO A5 - 148 x 210 mm";
167  else
168  curItem = "Custom";
169 
170  switchSize();
171 
172  if(pConfig->getPaperType() == te::layout::Custom)
173  {
174  m_ui->gbCustom->setEnabled(true);
175  }
176 }
177 
179 {
181 
182  double w = 0;
183  double h = 0;
184  pConfig->getPaperSize(w, h);
185 
186  QVariant wv(w);
187  m_ui->lneCustomWidth->setText(wv.toString());
188  QVariant hv(w);
189  m_ui->lneCustomHeight->setText(hv.toString());
190 }
191 
193 {
194  std::string curItem;
195  if (text.toStdString().compare("ISO A0 - 841 x 1189 mm") == 0)
196  m_paperType = te::layout::A0;
197  else if (text.toStdString().compare("ISO A1 - 594 x 841 mm") == 0)
198  m_paperType = te::layout::A1;
199  else if (text.toStdString().compare("ISO A2 - 420 x 594 mm") == 0)
200  m_paperType = te::layout::A2;
201  else if (text.toStdString().compare("ISO A3 - 297 x 420 mm") == 0)
202  m_paperType = te::layout::A3;
203  else if (text.toStdString().compare("ISO A4 - 210 x 297 mm") == 0)
204  m_paperType = te::layout::A4;
205  else if (text.toStdString().compare("ISO A5 - 148 x 210 mm") == 0)
206  m_paperType = te::layout::A5;
207  else
208  m_paperType = te::layout::Custom;
209 }
210 
212 {
214 
215  if(m_orientation != pConfig->getPaperOrientantion()
216  || m_paperType != pConfig->getPaperType())
217  {
218  pConfig->setPaperType(m_paperType);
219  pConfig->setPaperOrientation(m_orientation);
220  emit changeConfig();
221  }
222 }
223 
225 {
226  if(m_ui->rdbLandscape->isChecked())
227  {
228  m_orientation = te::layout::Landscape;
229  }
230 }
231 
233 {
234  if(m_ui->rdbPortrait->isChecked())
235  {
236  m_orientation = te::layout::Portrait;
237  }
238 }
landScape orientation
Definition: AbstractType.h:86
Abstract class to represent an observable. "Model" part of MVC component.
Definition: Observable.h:56
Class responsible for maintaining the drawing context of a MVC component. It is always used by the "M...
Definition: ContextItem.h:49
Class responsible for paper setting. Size, orientation, custom size, etc.
Definition: PaperConfig.h:45
double y
y-coordinate.
Definition: Coord2D.h:114
double x
x-coordinate.
Definition: Coord2D.h:113
virtual void configurePageSize()
Configures the page size getting from layout.
Abstract class to represent an observer. "View" part of MVC widget. All classes representing the grap...
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
portrait orientation
Definition: AbstractType.h:85
virtual LayoutOrientationType getPaperOrientantion()
Returns paper orientation type enum.
virtual te::gm::Coord2D getPosition()
Method that returns the position llx, lly Reimplement this function in a ItemObserver subclass to pro...
static Context & getInstance()
It returns a reference to the singleton instance.
virtual void configureOrientationPage()
Configures the orientation page getting from layout.
virtual void updateObserver(ContextItem context)
Reimplemented from Observer.
virtual void getPaperSize(double &w, double &h)
Returns paper size. Height and Width.
Definition: PaperConfig.cpp:61
virtual void on_cmbPageSize_currentIndexChanged(const QString &text)
std::auto_ptr< Ui::PageSetup > m_ui
PaperConfig * getPaperConfig() const
Returns paper setting.
Definition: Context.cpp:198
Abstract class to represent a controller. "Controller" part of MVC widget. All classes representing t...
virtual LayoutAbstractPaperType getPaperType()
Returns paper type.
Definition: PaperConfig.cpp:56
virtual void setPaperOrientation(LayoutOrientationType orientation)
Sets paper orientation type enum. Ex.: Portrait.
virtual void setPaperType(LayoutAbstractPaperType paperType)
Sets paper type enum. Ex.: A4.
Definition: PaperConfig.cpp:51
virtual void setPosition(const double &x, const double &y)
Change coordinate llx,lly of the MVC widget. Reimplement this function in a ItemController subclass t...
PageSetupOutside(OutsideController *controller, Observable *o)