ProfileResultDialog.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/mnt/qt/ProfielResultDialog.cpp
22 
23 \brief A dialog Show Profile Graphic Result
24 */
25 
26 #include "../../color/RGBAColor.h"
27 #include "../../qt/widgets/charts/ChartDisplay.h"
28 #include "../../qt/widgets/charts/ChartDisplayWidget.h"
29 #include "../../qt/widgets/charts/ChartStyle.h"
30 
31 #include "ProfileResultDialog.h"
32 #include "ui_ProfileResultDialogForm.h"
33 
34 // Qt
35 #include <QFileDialog>
36 #include <QMessageBox>
37 
38 #include <fstream>
39 
40 //QWT
41 #include <qwt_symbol.h>
42 #include <qwt_text.h>
43 #include <qwt_plot_curve.h>
44 
46 {
47  profile->setOrientation(Qt::Horizontal);
48 
49  QVector<QPointF> values;
50  for (int i = 0; i < 30; ++i)
51  {
52  values.push_back(QPointF(i, rand() + cor.getRed()));
53  }
54 
55  profile->setSamples(values);
56 
57  QPen CurvePen;
58  CurvePen.setColor(QColor((QRgb)cor.getRgba()));
59  CurvePen.setStyle(Qt::SolidLine);
60  CurvePen.setWidth(0);
61  profile->setPen(CurvePen);
62 }
63 
65  QString tittle,
66  QString yaxis,
67  std::vector<te::gm::LineString*> &profileSet,
68  std::vector<te::color::RGBAColor>color,
69  QWidget* parent,
70  Qt::WindowFlags f)
71  : QDialog(parent, f),
72  m_ui(new Ui::ProfileResultDialogForm)
73 {
74  // add controls
75  m_ui->setupUi(this);
76 
77  connect(m_ui->m_okPushButton, SIGNAL(clicked()), this, SLOT(onOKPushButtonClicked()));
78 
79  m_ui->m_helpPushButton->setNameSpace("dpi.inpe.br.plugins");
80  m_ui->m_helpPushButton->setPageReference("plugins/mnt/DTM_ProfileResult.html");
81 
82  //Creating and adjusting the chart Display's style.
84  chartStyle->setTitle(tittle);
85  chartStyle->setAxisX(QString::fromUtf8("Distance (m)"));
86  chartStyle->setAxisY(yaxis);
87  chartStyle->setGridChecked(true);
88 
89  //Creating and adjusting the chart Display
90  te::qt::widgets::ChartDisplay* chartDisplay = new te::qt::widgets::ChartDisplay(this->parentWidget(), QString::fromUtf8("Profile"), chartStyle);
91  chartDisplay->adjustDisplay();
92 
93  te::qt::widgets::ChartDisplayWidget* displayWidget = nullptr;
94  for (unsigned int i = 0; i < profileSet.size(); ++i)
95  {
96  QwtPlotCurve *profile = new QwtPlotCurve();
97  profile->setOrientation(Qt::Horizontal);
98  QVector<QPointF> values;
99  for (unsigned int ii = 0; ii < profileSet[i]->size(); ++ii)
100  values.push_back(QPointF(profileSet[i]->getX(ii), profileSet[i]->getY(ii)));
101 
102  profile->setSamples(values);
103 
104  QPen CurvePen;
105  CurvePen.setColor(QColor((QRgb)color[i%color.size()].getRgba()));
106  CurvePen.setStyle(Qt::SolidLine);
107  CurvePen.setWidth(0);
108  profile->setPen(CurvePen);
109 
110  profile->attach(chartDisplay);
111  if (i == 0)
112  {
113  //Adjusting the chart widget
114  displayWidget = new te::qt::widgets::ChartDisplayWidget(profile, profile->rtti(), chartDisplay, m_ui->m_profileWidget);
115  displayWidget->setWindowTitle("Profile");
116  }
117  }
118 
119  QGridLayout* layout = new QGridLayout(m_ui->m_profileWidget);
120  layout->addWidget(displayWidget);
121 
122  displayWidget->show();
123  displayWidget->setAttribute(Qt::WA_DeleteOnClose, true);
124 }
125 
127 
129 {
130  accept();
131 }
132 
void getRgba(int *r, int *g, int *b, int *a=0) const
It gets the color value.
Definition: RGBAColor.h:327
void adjustDisplay()
Updates the general display settings according to the ChartStyle. The adjusted properties are: Title;...
int getRed() const
It returns the red component color value (a value from 0 to 255).
Definition: RGBAColor.h:307
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
void setAxisY(QString newAxisY)
It sets the style&#39;s y axis label.
Definition: ChartStyle.cpp:101
std::unique_ptr< Ui::ProfileResultDialogForm > m_ui
A class to represent a chart display.
Definition: ChartDisplay.h:65
void setAxisX(QString newAxisX)
It sets the style&#39;s x axis label.
Definition: ChartStyle.cpp:91
A wdiget used to display a chart.
void GeraTeste(QwtPlotCurve *profile, te::color::RGBAColor cor)
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
A dialog Show Profile Graphic Result.
ProfileResultDialog(QString tittle, QString yaxis, std::vector< te::gm::LineString * > &profileSet, std::vector< te::color::RGBAColor > color, QWidget *parent=0, Qt::WindowFlags f=0)