GridPropertyWidget.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 widgets/canvas/GridPropertyWidget.cpp
22  */
23 
24 #include "GridPropertyWidget.h"
25 #include "Grid.h"
26 
27 // TerraLib
28 #include "../propertybrowser/AbstractPropertyManager.h"
29 
30 // Qt
31 #include <QAction>
32 #include <QLayout>
33 
34 
36  QDockWidget(nullptr),
37  m_editAction(editAction),
38  m_gridStatus(true)
39 {
40  QWidget* w = new QWidget(this);
41 
42  QtTreePropertyBrowser* pb = new QtTreePropertyBrowser(w);
43  pb->setPropertiesWithoutValueMarked(true);
44  pb->setResizeMode(QtTreePropertyBrowser::ResizeToContents);
45 
46  new GridPropertyBrowser(pb, wid);
47 
48  QGridLayout* lay = new QGridLayout(w);
49  lay->addWidget(pb);
50 
51  setWidget(w);
52 
53  connect(wid, SIGNAL(aboutToBeclosed()), SLOT(gridClosed()));
54 
55  m_editAction->setEnabled(false);
56 
57  setAttribute(Qt::WA_DeleteOnClose, true);
58 }
59 
61 {
62  m_editAction->setEnabled(m_gridStatus);
63 }
64 
66 {
67  m_gridStatus = false;
68  close();
69 }
70 
72  te::qt::widgets::AbstractPropertyItem(pb)
73 {
74  QStringList types_names;
75 
76  types_names <<tr("Planar Grid")
77  <<tr("Geographic Grid");
78 
79  QtProperty* grid_prop = te::qt::widgets::AbstractPropertyManager::getInstance().m_groupManager->addProperty(tr("Grid properties"));
80 
81  // font
82  QtProperty* font_prop = te::qt::widgets::AbstractPropertyManager::getInstance().m_fontManager->addProperty(tr("Font"));
83  te::qt::widgets::AbstractPropertyManager::getInstance().m_fontManager->setValue(font_prop, wid->getFont());
84  grid_prop->addSubProperty(font_prop);
85 
86  // color
87  QtProperty* color_prop = te::qt::widgets::AbstractPropertyManager::getInstance().m_colorManager->addProperty(tr("Color"));
88  te::qt::widgets::AbstractPropertyManager::getInstance().m_colorManager->setValue(color_prop, wid->getColor());
89  grid_prop->addSubProperty(color_prop);
90 
91  // scale type
92  QtProperty* type_prop = te::qt::widgets::AbstractPropertyManager::getInstance().m_enumManager->addProperty(tr("Grid type"));
93  te::qt::widgets::AbstractPropertyManager::getInstance().m_enumManager->setEnumNames(type_prop, types_names);
94  te::qt::widgets::AbstractPropertyManager::getInstance().m_enumManager->setValue(type_prop, wid->getType());
95  grid_prop->addSubProperty(type_prop);
96  // ===================
97 
98  addProperty(grid_prop, tr("Grid"), QColor(175, 255, 175));
99 
100  wid->connect(this, SIGNAL(colorChanged(const QColor&)), SLOT(setColor(const QColor&)));
101  wid->connect(this, SIGNAL(fontChanged(const QFont&)), SLOT(setFont(const QFont&)));
102  wid->connect(this, SIGNAL(gridTypeChanged(const int&)), SLOT(setGridType(const int&)));
103 }
104 
106 
107 void te::qt::widgets::GridPropertyBrowser::valueChanged(QtProperty*, const QColor& value)
108 {
109  emit colorChanged(value);
110 }
111 
112 void te::qt::widgets::GridPropertyBrowser::valueChanged(QtProperty*, const QFont& value)
113 {
114  emit fontChanged(value);
115 }
116 
118 {
119  emit gridTypeChanged(value);
120 }
A widget used to define the main property items that can be used to describe a se object...
GridPropertyBrowser(QtTreePropertyBrowser *pb, Grid *wid)
Constructor.
void fontChanged(const QFont &)
Emmited when the font was changed.
QColor getColor() const
Returns the current color being used.
bool m_gridStatus
Grid widget enabling status.
void gridClosed()
This function must be called when the Grid related to it was closed.
GridPropertyWidget(Grid *wid, QAction *editAction)
Constructor.
Widget with propeties of a Grid for the users to change the presentation of the grid on the display...
static AbstractPropertyManager & getInstance()
It returns a reference to the singleton instance.
int getType() const
Returns the current type of grid being used.
void gridTypeChanged(const int &)
Emmited when the type was changed.
URI C++ Library.
Definition: Attributes.h:37
This class implements the grid, planar or geographic, to be used with the MapDisplay.
void addProperty(QtProperty *property, const QString &id, QColor c)
Defines a class that presents a widget with the grid properties to be edited.
Contains an implementation of a grid.
void colorChanged(const QColor &)
Emmited when the color was changed.
QFont getFont() const
Returns the current font being used.
void valueChanged(QtProperty *p, const QColor &value)
Called when a property of color type changed.
QAction * m_editAction
Action used to show the widget.