Tulip  4.0.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 1 and Inria Bordeaux - Sud Ouest
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 #include <tulip/tulipconf.h>
27 namespace Ui {
28 class PropertyCreationDialog;
29 }
30 
31 namespace tlp {
32 
33 class PropertyInterface;
34 class Graph;
35 
36 /**
37  * @brief Provide a dialog that allow user to create a new property.
38  *
39  * The easiest way to use this class is to use the static function.
40  * @code
41  * Graph* g;
42  * QWidget* parent;
43  * PropertyCreationDialog::createNewProperty(g,parent);
44  * @endcode
45  *
46  *
47  **/
48 class TLP_QT_SCOPE PropertyCreationDialog : public QDialog {
49  Q_OBJECT
50 
51 public:
52  /**
53  * @brief Constructs a property creation dialog with the given parent.
54  **/
55  explicit PropertyCreationDialog(QWidget *parent = NULL);
56  /**
57  * @brief Constructs a property creation dialog with the given parent graph and parent widget.
58  **/
59  explicit PropertyCreationDialog(tlp::Graph* graph,QWidget *parent = NULL);
60  ~PropertyCreationDialog();
61 
62 
63  /**
64  * @brief Try to create a new property from the givent parameters.
65  * To get the created property use the createdProperty() function.
66  **/
67  void accept();
68 
69  /**
70  * @brief Change the graph to use as parent for the properties to create.
71  **/
72  void setGraph(tlp::Graph* graph);
73 
74 
75  tlp::Graph* getGraph()const {
76  return _graph;
77  }
78 
79  /**
80  * @brief Return the property created. You need to call this function after the accept() function.
81  *
82  * @return The last created property or NULL if no property there is an error during the property creation.
83  **/
84  tlp::PropertyInterface* createdProperty()const {
85  return _createdProperty;
86  }
87 
88  /**
89  * @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.
90  *
91  * The function creates a modal property creation dialog with the given graph and parent widget.
92  *
93  * @param graph The graph to use as parent for the properties to create.
94  **/
95  static PropertyInterface* createNewProperty(tlp::Graph* graph,QWidget* parent=NULL);
96 private slots:
97  void checkValidity();
98 private:
99  void initGui();
100 
101  Ui::PropertyCreationDialog *ui;
102  QPushButton* _createPropertyButton;
103  Graph* _graph;
104  PropertyInterface* _createdProperty;
105 };
106 }
107 
108 #endif // PROPERTYCREATIONDIALOG_H
109 ///@endcond