All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HistogramDialog.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/HistogramDialog.cpp
22 
23  \brief A dialog used to define the basic parameters of a new histogram.
24 */
25 
26 //Terralib
27 #include "../../../dataaccess.h"
28 #include "../../../datatype/Property.h"
29 #include "ChartDisplay.h"
30 #include "ChartDisplayWidget.h"
31 #include "ChartStyle.h"
32 #include "HistogramChart.h"
33 #include "HistogramDataWidget.h"
34 #include "HistogramDialog.h"
35 #include "HistogramStyle.h"
36 #include "ui_HistogramDialogForm.h"
37 #include "ui_HistogramDataWidgetForm.h"
38 
39 //QT
40 #include <QDockWidget>
41 
42 te::qt::widgets::HistogramDialog::HistogramDialog(te::da::DataSet* dataSet, te::da::DataSetType* dataType, QWidget* parent, Qt::WindowFlags f)
43  : QDialog(parent, f),
44  m_ui(new Ui::HistogramDialogForm)
45 {
46  m_ui->setupUi(this);
47 
48  // Histogram data Widget
49  m_histogramDataWidget = new te::qt::widgets::HistogramDataWidget(dataSet, dataType, this);
50 
51  // Adjusting...
52  QGridLayout* layout = new QGridLayout(m_ui->m_dataWidgetFrame);
53  layout->addWidget(m_histogramDataWidget);
54  this->layout()->setSizeConstraint(QLayout::SetFixedSize);
55 
56 // connect signal and slots
57  connect(m_ui->m_okPushButton, SIGNAL(clicked()), this, SLOT(onOkPushButtonClicked()));
58 
59  m_ui->m_helpPushButton->setPageReference("widgets/charts/histogram/histogram.html");
60 }
61 
63 {
64  delete m_histogramDataWidget;
65 }
66 
68 {
69  return m_displayWidget;
70 }
71 
73 {
74  QApplication::setOverrideCursor(Qt::WaitCursor);
75 
76  te::qt::widgets::HistogramChart* chart = new te::qt::widgets::HistogramChart(m_histogramDataWidget->getHistogram());
77 
78  //Creating and adjusting the chart Display's style.
80  chartStyle->setTitle(QString::fromStdString("Histogram"));
81 
82  if(m_histogramDataWidget->getForm()->m_summaryComboBox->currentText() != "None")
83  chartStyle->setAxisX(m_histogramDataWidget->getForm()->m_summaryComboBox->currentText() + ": " + m_histogramDataWidget->getForm()->m_propertyComboBox->currentText());
84  else
85  chartStyle->setAxisX(m_histogramDataWidget->getForm()->m_propertyComboBox->currentText());
86 
87  chartStyle->setAxisY(QString::fromStdString("Frequency"));
88 
89  //Creating and adjusting the chart Display
90  te::qt::widgets::ChartDisplay* chartDisplay = new te::qt::widgets::ChartDisplay(0, QString::fromStdString("Histogram"), chartStyle);
91  chartDisplay->adjustDisplay();
92  chart->attach(chartDisplay);
93  chartDisplay->show();
94  chartDisplay->replot();
95 
96  //Adjusting the chart widget
97  m_displayWidget = new te::qt::widgets::ChartDisplayWidget(chart, te::qt::widgets::HISTOGRAM_CHART, chartDisplay, this->parentWidget());
98 
99  QApplication::restoreOverrideCursor();
100  this->accept();
101 }
A widget used to adjust a histogram's input data.
A widget used to adjust a histogram's input data.
void adjustDisplay()
Updates the general display settings according to the ChartStyle. The adjusted properties are: Title;...
te::qt::widgets::ChartDisplayWidget * getDisplayWidget()
Returns a pointer to the generated ChartDisplayWidget.
A class that models the description of a dataset.
Definition: DataSetType.h:72
void attach(QwtPlot *plot)
It atttaches a QwtPlot to this Cahrt.
HistogramDialog(te::da::DataSet *dataSet, te::da::DataSetType *dataType, QWidget *parent=0, Qt::WindowFlags f=0)
Constructor.
A class used to define the style of a histogram's chart.
HistogramDataWidget * m_histogramDataWidget
The histogram's data widget used to configure the basic parameters of the new histogram.
std::auto_ptr< Ui::HistogramDialogForm > m_ui
The dialog form.
A class to represent a chart display.
Definition: ChartDisplay.h:65
A class to represent a histogram chart.
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:112
A wdiget used to display a chart.
A widget used to display a set of charts.
A class used to define a chartDisplay's style.
A dialog used to define the basic parameters of a new histogram.
A class to represent a chart display.