Tulip  4.3.0
Better Visualization Through Research
 All Classes Namespaces 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 
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  ~PropertyCreationDialog();
63 
64 
65  /**
66  * @brief Try to create a new property from the givent parameters.
67  * To get the created property use the createdProperty() function.
68  **/
69  void accept();
70 
71  /**
72  * @brief Change the graph to use as parent for the properties to create.
73  **/
74  void setGraph(tlp::Graph* graph);
75 
76 
77  tlp::Graph* getGraph()const {
78  return _graph;
79  }
80 
81  /**
82  * @brief Return the property created. You need to call this function after the accept() function.
83  *
84  * @return The last created property or NULL if no property there is an error during the property creation.
85  **/
86  tlp::PropertyInterface* createdProperty()const {
87  return _createdProperty;
88  }
89 
90  /**
91  * @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.
92  *
93  * The function creates a modal property creation dialog with the given graph and parent widget.
94  *
95  * @param graph The graph to use as parent for the properties to create.
96  **/
97  static PropertyInterface* createNewProperty(tlp::Graph* graph,QWidget* parent=NULL);
98 private slots:
99  void checkValidity();
100 private:
101  void initGui();
102 
103  Ui::PropertyCreationDialog *ui;
104  QPushButton* _createPropertyButton;
105  Graph* _graph;
106  PropertyInterface* _createdProperty;
107 };
108 }
109 
110 #endif // PROPERTYCREATIONDIALOG_H
111 ///@endcond