All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ChartProperties.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/ChartProperties.cpp
22 
23  \brief A dialog used to customize a Chart's parameters, weather it is about it's data or it's visual style
24 */
25 //Terralib
26 
27 #include "ChartDisplay.h"
28 #include "ChartDisplayWidget.h"
29 #include "ChartProperties.h"
30 #include "ChartStyleFrameFactory.h"
31 #include "ChartWidget.h"
32 #include "ChartWidgetFactory.h"
33 #include "HistogramFrameFactory.h"
34 #include "ScatterFrameFactory.h"
35 #include "ui_ChartPropertiesDialogForm.h"
36 
37 //QWT
38 #include <qwt_plot_seriesitem.h>
39 
41  : QDialog(parent),
42  m_ui(new Ui::ChartPropertiesDialogForm),
43  m_curComp(0),
44  m_chartWidget(chartWidget)
45 {
46  m_ui->setupUi(this);
47 
48  //init factories
49  switch (m_chartWidget->getType())
50  {
54  break;
58  break;
59  }
60 
62 
63  std::vector<std::string> vec;
66 
67  while(it != d.end())
68  {
69  vec.push_back(it->first);
70  ++it;
71  }
72 
73  for(size_t i = 0; i < vec.size(); i++)
74  {
75  m_ui->m_componentsListWidget->addItem(vec[i].c_str());
76  }
77  m_ui->m_componentsListWidget->setFocus();
78  m_ui->m_tabWidget->clear();
79  m_curComp = te::qt::widgets::ChartWidgetFactory::make("Chart Style", m_ui->m_tabWidget);
80  m_ui->m_tabWidget->addTab(m_curComp, QString::fromStdString("Chart Style"));
82  m_ui->m_componentsListWidget->setCurrentRow(0);
83  m_ui->m_helpPushButton->setPageReference("widgets/charts/style/style.html");
84 
85  connect(m_ui->m_componentsListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(onItemClicked(QListWidgetItem*)));
86  connect(m_ui->m_applyPushButton, SIGNAL(clicked()), this, SLOT(onApplyButtonClicked()));
87 }
88 
90 {
91  delete m_curComp;
92 }
93 
94 void te::qt::widgets::ChartProperties::onItemClicked(QListWidgetItem * current)
95 {
96  std::string value = current->text().toStdString();
97  delete m_curComp;
98  m_curComp = te::qt::widgets::ChartWidgetFactory::make(value, m_ui->m_tabWidget);
99  m_curComp->setChart(m_chartWidget->getChart());
100  m_curComp->setDisplay(m_chartWidget->getDisplay());
101  m_ui->m_tabWidget->clear();
102  m_ui->m_tabWidget->addTab(m_curComp, QString::fromStdString(value));
103  m_curComp->show();
104 }
105 
107 {
108  if(m_ui->m_componentsListWidget->currentItem()->text() == "Chart Style")
109  {
110  m_chartWidget->setDisplay(m_curComp->getDisplay());
111  }
112  else
113  {
114  m_chartWidget->setChart(m_curComp->getChart());
115  }
116  this->close();
117 }
void onApplyButtonClicked()
Called when the user clicks on the apply button. It will set the configurations to the ChartDisplayWi...
ChartDisplayWidget * m_chartWidget
ChartProperties(te::qt::widgets::ChartDisplayWidget *chartWidget, QWidget *parent=0)
Constructor.
static dictionary_type & getDictionary()
It returns a reference to the internal dictionary of concrete factories.
virtual void setDisplay(te::qt::widgets::ChartDisplay *newDisplay)
It sets the ChartDisplay being configured.
Definition: ChartWidget.cpp:58
A factory to build the Chart frame object.
void onItemClicked(QListWidgetItem *current)
Called when the user clicks on one of the items available at the list.
std::auto_ptr< Ui::ChartPropertiesDialogForm > m_ui
static te::qt::widgets::ChartWidget * make(const std::string &cwType)
std::map< TFACTORYKEY, TFACTORY *, TKEYCOMPARE >::const_iterator const_iterator
te::qt::widgets::ChartDisplay * getDisplay()
Returns a pointer to the display being used.
std::map< TFACTORYKEY, TFACTORY *, TKEYCOMPARE >::const_iterator end() const
It returns an iterator to the end of the container.
A base widget to be used on the chart settings.
A wdiget used to display a chart.
A factory to build the histogram frame object.
std::map< TFACTORYKEY, TFACTORY *, TKEYCOMPARE >::const_iterator begin() const
It returns an iterator to the first stored factory.
A widget used to display a set of charts.
A dialog used to customize a graphic's parameters, weather it is about it's data or it's visual style...
A factory to build widget objects.
A class to represent a chart display.
This class represents a dictionary of factories.
A factory to build the scatter frame object.