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  {
75  }
76 }
77 
79 {
80  bool ok;
81  QFont font = QFontDialog::getFont(&ok, m_chartStyle->getTitleFont(), this);
82  if (ok)
83  {
85  }
86 }
87 
89 {
91 }
92 
94 {
95  // The new fill color
96  m_chartStyle->setColor(color);
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());
126  m_ui->m_gridCheckBox->setChecked(m_chartStyle->getGridChecked());
127 }
128 
void setAxisFont(QFont newAxisFont)
It sets the axis&#39; font.
Definition: ChartStyle.cpp:111
QString & getAxisX()
Returns a reference to the style&#39;s x axis label.
Definition: ChartStyle.cpp:86
QFont & getAxisFont()
Returns a reference to the axis&#39; font.
Definition: ChartStyle.cpp:106
void setColor(QColor newColor)
It sets the style&#39;s color.
Definition: ChartStyle.cpp:145
QString & getAxisY()
Returns a reference to the style&#39;s y axis label.
Definition: ChartStyle.cpp:96
void setGridChecked(bool newGridChecked)
It sets the boolean used to decided weather to display the grid or not.
Definition: ChartStyle.cpp:155
void setTitle(QString newTitle)
It sets the style&#39;s title.
Definition: ChartStyle.cpp:71
QString & getTitle()
Returns a reference to the style&#39;s Title.
Definition: ChartStyle.cpp:66
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&#39;s style that will be configured by this dialog.
void setAxisY(QString newAxisY)
It sets the style&#39;s y axis label.
Definition: ChartStyle.cpp:101
te::qt::widgets::ChartStyle * getStyle()
Returns a pointer to the ChartStyle being configured.
void setAxisX(QString newAxisX)
It sets the style&#39;s x axis label.
Definition: ChartStyle.cpp:91
QColor & getColor()
Returns a reference to the style&#39;s color.
Definition: ChartStyle.cpp:140
void onColorChanged(const QColor &color)
QFont & getTitleFont()
Returns a reference to the title&#39;s font.
Definition: ChartStyle.cpp:76
void setTitleFont(QFont newTitleFont)
It sets the title&#39;s font.
Definition: ChartStyle.cpp:81
bool getGridChecked()
Returns true if the grid is to be displayed, otherwise returns false.
Definition: ChartStyle.cpp:150
ColorPickerToolButton * m_colorPicker
The color picker used to customise the color of several chart parameters.
A class used to define a chartDisplay&#39;s style.
std::unique_ptr< Ui::chartStyleWidgetForm > m_ui
The widget form.