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 "../utils/ScopedCursor.h"
28 #include "ChartDisplay.h"
29 #include "ChartDisplayWidget.h"
30 #include "ChartStyle.h"
31 #include "HistogramChart.h"
32 #include "HistogramDataWidget.h"
33 #include "HistogramDialog.h"
34 #include "HistogramStyle.h"
35 #include "ui_ChartDialogForm.h"
36 #include "ui_HistogramDataWidgetForm.h"
37 
38 //QT
39 #include <QDockWidget>
40 
42  : QDialog(parent, f),
43  m_ui(new Ui::ChartDialogForm)
44 {
45  m_ui->setupUi(this);
46 
47  // Histogram data Widget
49 
50  // Adjusting...
51  QGridLayout* layout = new QGridLayout(m_ui->m_dataWidgetFrame);
52  layout->addWidget(m_histogramDataWidget);
53  this->layout()->setSizeConstraint(QLayout::SetFixedSize);
54 
55 // connect signal and slots
56  connect(m_ui->m_okPushButton, SIGNAL(clicked()), this, SLOT(onOkPushButtonClicked()));
57 
58  m_ui->m_helpPushButton->setPageReference("widgets/charts/histogram/histogram.html");
59 }
60 
62 {
63  delete m_histogramDataWidget;
64 }
65 
67 {
68  return m_displayWidget;
69 }
70 
72 {
73  te::qt::widgets::ScopedCursor c(Qt::WaitCursor);
74 
76 
77  //Creating and adjusting the chart Display's style.
79  chartStyle->setTitle(QString::fromUtf8("Histogram"));
80 
81  if(m_histogramDataWidget->getForm()->m_summaryComboBox->currentText() != "None")
82  chartStyle->setAxisX(QString::fromUtf8(m_histogramDataWidget->getSummaryFunction().c_str()) + ": " + m_histogramDataWidget->getForm()->m_propertyComboBox->currentText());
83  else
84  chartStyle->setAxisX(m_histogramDataWidget->getForm()->m_propertyComboBox->currentText());
85 
86  chartStyle->setAxisY(QString::fromUtf8("Frequency"));
87 
88  //Creating and adjusting the chart Display
89  te::qt::widgets::ChartDisplay* chartDisplay = new te::qt::widgets::ChartDisplay(nullptr, QString::fromUtf8("Histogram"), chartStyle);
90  chartDisplay->adjustDisplay();
91  chart->setPen(Qt::black);
92  chart->setBrush(QBrush(Qt::blue));
93  chart->attach(chartDisplay);
94  chartDisplay->show();
95  chartDisplay->replot();
96 
97  //Adjusting the chart widget
98  m_displayWidget = new te::qt::widgets::ChartDisplayWidget(chart, te::qt::widgets::HISTOGRAM_CHART, chartDisplay, this->parentWidget());
99 
100  this->accept();
101 }
A widget used to adjust a histogram&#39;s input data.
A widget used to adjust a histogram&#39;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.
te::qt::widgets::Histogram * getHistogram()
Returns a pointer to the widget&#39;s form.
void attach(QwtPlot *plot)
It atttaches a QwtPlot to this Cahrt.
HistogramDialog(te::map::AbstractLayerPtr layer, QWidget *parent=0, Qt::WindowFlags f=0)
Constructor.
ChartDisplayWidget * m_displayWidget
The display&#39;s widget that will be populated by this widget.
A class used to define the style of a histogram&#39;s chart.
HistogramDataWidget * m_histogramDataWidget
The histogram&#39;s data widget used to configure the basic parameters of the new histogram.
std::string getSummaryFunction()
Returns the name of the chosen summary function. Default is None.
A class to represent a chart display.
Definition: ChartDisplay.h:65
std::unique_ptr< Ui::ChartDialogForm > m_ui
The dialog form.
A class to represent a histogram chart.
A wdiget used to display a chart.
Ui::HistogramDataWidgetForm * getForm()
Returns a pointer to the widget&#39;s form.
A widget used to display a set of charts.
A class used to define a chartDisplay&#39;s style.
A dialog used to define the basic parameters of a new histogram.
A class to represent a chart display.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
An object that when created shows a cursor during its scope.
Definition: ScopedCursor.h:48