All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ChartStyleWidget.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 terralib/qt/widgets/charts/chartStyleWidget.cpp
22 
23  \brief A widget created to customize the style parameters of a chart
24 */
25 
26 //Terralib
27 #include "../../../qt/widgets/se/Utils.h"
28 #include "../utils/ColorPickerToolButton.h"
29 #include "ChartStyle.h"
30 #include "ChartStyleWidget.h"
31 #include "ui_ChartStyleWidgetForm.h"
32 
33 //QT
34  #include <QFontDialog>
35 
36 te::qt::widgets::ChartStyleWidget::ChartStyleWidget(QWidget* parent, Qt::WindowFlags f, QString title, QString PropertyX, QString PropertyY)
37  : QWidget(parent, f),
38  m_ui(new Ui::chartStyleWidgetForm)
39 {
40  m_ui->setupUi(this);
41  m_ui->m_chartTitleLineEdit->setText(title);
42  m_ui->m_labelXlLineEdit->setText(PropertyX);
43  m_ui->m_labelYlLineEdit->setText(PropertyY);
44 
45  // Color Picker
47  m_colorPicker->setFixedSize(107, 24);
48 
49  // Adjusting the color picker
50  QGridLayout* layout = new QGridLayout(m_ui->m_colorPickerFrame);
51  layout->setContentsMargins(0, 0, 0, 0);
52  layout->setSizeConstraint(QLayout::SetFixedSize);
53  layout->addWidget(m_colorPicker);
54 
56 
57  connect(m_ui->m_chartTitleLineEdit, SIGNAL(editingFinished()), this, SLOT(onTitleLineEditFinish()));
58  connect(m_ui->m_labelXlLineEdit, SIGNAL(editingFinished()), this, SLOT(onlabelXEditFinish()));
59  connect(m_ui->m_labelYlLineEdit, SIGNAL(editingFinished()), this, SLOT(onlabelYEditFinish()));
60  connect(m_ui->m_labelStylePushButton, SIGNAL(clicked()), this, SLOT(onLabelStylePushButtonClicked()));
61  connect(m_ui->m_titleStylePushButton, SIGNAL(clicked()), this, SLOT(onTitleStylePushButtonClicked()));
62  connect(m_ui->m_gridCheckBox, SIGNAL(stateChanged(int)), this, SLOT(onGridCheckBoxToggled(int)));
63  connect(m_colorPicker, SIGNAL(colorChanged(const QColor&)), SLOT(onColorChanged(const QColor&)));
64 }
65 
67 
69 {
70  bool ok;
71  QFont font = QFontDialog::getFont(&ok, m_chartStyle->getAxisFont(), this);
72  if (ok)
73  {
74  m_chartStyle->setAxisFont(font);
75  }
76 }
77 
79 {
80  bool ok;
81  QFont font = QFontDialog::getFont(&ok, m_chartStyle->getTitleFont(), this);
82  if (ok)
83  {
84  m_chartStyle->setTitleFont(font);
85  }
86 }
87 
89 {
90  m_chartStyle->setGridChecked(state);
91 }
92 
94 {
95  // The new fill color
96  m_chartStyle->setColor(color);
97  m_colorPicker->setColor(m_chartStyle->getColor());
98 }
99 
101 {
102  m_chartStyle->setTitle(m_ui->m_chartTitleLineEdit->text());
103 }
104 
106 {
107  m_chartStyle->setAxisX(m_ui->m_labelXlLineEdit->text());
108 }
109 
111 {
112  m_chartStyle->setAxisY(m_ui->m_labelYlLineEdit->text());
113 }
115 {
116  return m_chartStyle;
117 }
118 
120 {
121  m_chartStyle = newStyle;
122  m_ui->m_chartTitleLineEdit->setText(m_chartStyle->getTitle());
123  m_ui->m_labelXlLineEdit->setText(m_chartStyle->getAxisX());
124  m_ui->m_labelYlLineEdit->setText(m_chartStyle->getAxisY());
125  m_colorPicker->setColor(m_chartStyle->getColor());
126  m_ui->m_gridCheckBox->setChecked(m_chartStyle->getGridChecked());
127 }
128 
void setColor(QColor newColor)
It sets the style's color.
Definition: ChartStyle.cpp:145
A widget used to customize the style parameters of a chart.
ChartStyleWidget(QWidget *parent=0, Qt::WindowFlags f=0, QString title="", QString PropertyX="", QString PropertyY="")
Constructor.
void setStyle(te::qt::widgets::ChartStyle *newStyle)
It sets the ChartStyle being configured.
Custom tool button used to pick a color.
ChartStyle * m_chartStyle
The display's style that will be configured by this dialog.
te::qt::widgets::ChartStyle * getStyle()
Returns a pointer to the ChartStyle being configured.
void onColorChanged(const QColor &color)
std::auto_ptr< Ui::chartStyleWidgetForm > m_ui
The widget form.
ColorPickerToolButton * m_colorPicker
The color picker used to customise the color of several chart parameters.
A class used to define a chartDisplay's style.