Tulip  4.8.0
Better Visualization Through Research
 All Classes Files Functions Variables Enumerations Enumerator Properties Groups Pages
PropertyCreationDialog.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 ///@cond DOXYGEN_HIDDEN
20 
21 
22 #ifndef PROPERTYCREATIONDIALOG_H
23 #define PROPERTYCREATIONDIALOG_H
24 
25 #include <QDialog>
26 
27 #include <tulip/tulipconf.h>
28 
29 namespace Ui {
30 class PropertyCreationDialog;
31 }
32 
33 namespace tlp {
34 
35 class PropertyInterface;
36 class Graph;
37 
38 /**
39  * @brief Provide a dialog that allow user to create a new property.
40  *
41  * The easiest way to use this class is to use the static function.
42  * @code
43  * Graph* g;
44  * QWidget* parent;
45  * PropertyCreationDialog::createNewProperty(g,parent);
46  * @endcode
47  *
48  *
49  **/
50 class TLP_QT_SCOPE PropertyCreationDialog : public QDialog {
51  Q_OBJECT
52 
53 public:
54  /**
55  * @brief Constructs a property creation dialog with the given parent.
56  **/
57  explicit PropertyCreationDialog(QWidget *parent = NULL);
58  /**
59  * @brief Constructs a property creation dialog with the given parent graph and parent widget.
60  **/
61  explicit PropertyCreationDialog(tlp::Graph* graph,QWidget *parent = NULL,
62  const std::string& selectedType = "");
63  ~PropertyCreationDialog();
64 
65 
66  /**
67  * @brief Try to create a new property from the givent parameters.
68  * To get the created property use the createdProperty() function.
69  **/
70  void accept();
71 
72  /**
73  * @brief Change the graph to use as parent for the properties to create.
74  **/
75  void setGraph(tlp::Graph* graph);
76 
77 
78  tlp::Graph* getGraph()const {
79  return _graph;
80  }
81 
82  /**
83  * @brief Return the property created. You need to call this function after the accept() function.
84  *
85  * @return The last created property or NULL if no property there is an error during the property creation.
86  **/
87  tlp::PropertyInterface* createdProperty()const {
88  return _createdProperty;
89  }
90 
91  /**
92  * @brief This is a convenience static function that create a new property using user parameters. If the user presses Cancel or an error occur, it returns a null pointer.
93  *
94  * The function creates a modal property creation dialog with the given graph and parent widget.
95  *
96  * @param graph The graph to use as parent for the properties to create.
97  **/
98  static PropertyInterface* createNewProperty(tlp::Graph* graph,
99  QWidget* parent=NULL,
100  const std::string& selectedType = "");
101 private slots:
102  void checkValidity();
103 private:
104  void initGui();
105 
106  Ui::PropertyCreationDialog *ui;
107  QPushButton* _createPropertyButton;
108  Graph* _graph;
109  PropertyInterface* _createdProperty;
110 };
111 }
112 
113 #endif // PROPERTYCREATIONDIALOG_H
114 ///@endcond
PropertyInterface describes the interface of a graph property.