GraphicDialog.h
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/se/GraphicDialog.h
22 
23  \brief A dialog used to build a graphic element.
24 */
25 
26 #ifndef __TERRALIB_QT_WIDGETS_SE_INTERNAL_GRAPHICDIALOG_H
27 #define __TERRALIB_QT_WIDGETS_SE_INTERNAL_GRAPHICDIALOG_H
28 
29 // TerraLib
30 #include "../Config.h"
31 
32 // Qt
33 #include <QDialog>
34 
35 // STL
36 #include <memory>
37 #include <string>
38 #include <vector>
39 
40 // Forward declaraion
41 namespace Ui { class GraphicDialogForm; }
42 
43 namespace te
44 {
45 // Forward declarations
46  namespace se
47  {
48  class Graphic;
49  }
50 
51  namespace qt
52  {
53  namespace widgets
54  {
55 // Forward declarations
56  class GraphicSelectorWidget;
57 
58  /*!
59  \class GraphicDialog
60 
61  \brief A dialog used to build a graphic element.
62  If you want to use this dialog, you can use commands like:
63  <code>
64  te::se::Graphic* g = te::qt::widgets::GraphicDialog::getGraphic(0, parent, "Title");
65  ...
66  delete g;
67  </code>
68  */
69  class TEQTWIDGETSEXPORT GraphicDialog : public QDialog
70  {
71  public:
72 
73  /** @name Initializer Methods
74  * Methods related to instantiation and destruction.
75  */
76  //@{
77 
78  /*! \brief Constructs a graphic dialog which is a child of parent, with widget flags set to f. */
79  GraphicDialog(QWidget* parent = 0, Qt::WindowFlags f = 0);
80 
81  /*! \brief Destructor. */
82  ~GraphicDialog();
83 
84  //@}
85 
86  public:
87 
88  /*!
89  \brief Pops up a modal graphic dialog with the given window title, lets the user configure the graphic,
90  and returns that graphic. The graphic is initially set to initial. The dialog is a child of parent.
91 
92  \param initial A initial graphic element that will be used.
93  The dialog form will be update based on graphic element parameters. It can be NULL.
94  \param parent Dialog parent.
95  \param title Dialog title.
96 
97  \note The dialog will NOT take the ownership of the given initial graphic.
98  \note The caller will take the ownership of the returned graphic.
99  \note It returns a NULL graphic element if the user cancels the dialog.
100  */
101  static te::se::Graphic* getGraphic(const te::se::Graphic* initial, QWidget* parent = 0, const QString& title = "");
102 
103  /*!
104  \brief Sets the graphic element.
105 
106  \return The graphic element.
107 
108  \note The dialog will NOT take the ownership of the given graphic.
109  */
110  void setGraphic(const te::se::Graphic* graphic);
111 
112  /*!
113  \brief Gets the configured graphic element.
114 
115  \return The configured graphic element.
116 
117  \note The caller will take the ownership of the returned graphic.
118  */
119  te::se::Graphic* getGraphic() const;
120 
121  /*!
122  \brief Gets the current graphic icon.
123 
124  \param size The icon size that will be generated.
125 
126  \return An icon that represents the graphic. i.e. a simple preview.
127  */
128  QIcon getGraphicIcon(const QSize& size);
129 
130  private:
131 
132  std::auto_ptr<Ui::GraphicDialogForm> m_ui; //!< Dialog form.
133  GraphicSelectorWidget* m_graphicSelector; //!< Graphic selector widget used to select the graphic.
134  };
135 
136  } // end namespace widgets
137  } // end namespace qt
138 } // end namespace te
139 
140 #endif // __TERRALIB_QT_WIDGETS_SE_INTERNAL_GRAPHICDIALOG_H
A widget used to select a graphic element.
A Graphic is a graphic symbol with an inherent shape, color(s), and possibly size.
Definition: Graphic.h:66
URI C++ Library.
A dialog used to build a graphic element. If you want to use this dialog, you can use commands like: ...
Definition: GraphicDialog.h:69
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63
std::auto_ptr< Ui::GraphicDialogForm > m_ui
Dialog form.
GraphicSelectorWidget * m_graphicSelector
Graphic selector widget used to select the graphic.