Tulip  4.6.0
Better Visualization Through Research
library/tulip-gui/include/tulip/PropertyCreationDialog.h
00001 /*
00002  *
00003  * This file is part of Tulip (www.tulip-software.org)
00004  *
00005  * Authors: David Auber and the Tulip development Team
00006  * from LaBRI, University of Bordeaux
00007  *
00008  * Tulip is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU Lesser General Public License
00010  * as published by the Free Software Foundation, either version 3
00011  * of the License, or (at your option) any later version.
00012  *
00013  * Tulip is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016  * See the GNU General Public License for more details.
00017  *
00018  */
00019 ///@cond DOXYGEN_HIDDEN
00020 
00021 
00022 #ifndef PROPERTYCREATIONDIALOG_H
00023 #define PROPERTYCREATIONDIALOG_H
00024 
00025 #include <QDialog>
00026 
00027 #include <tulip/tulipconf.h>
00028 
00029 namespace Ui {
00030 class PropertyCreationDialog;
00031 }
00032 
00033 namespace tlp {
00034 
00035 class PropertyInterface;
00036 class Graph;
00037 
00038 /**
00039   * @brief Provide a dialog that allow user to create a new property.
00040   *
00041   * The easiest way to use this class is to use the static function.
00042   * @code
00043   * Graph* g;
00044   * QWidget* parent;
00045   * PropertyCreationDialog::createNewProperty(g,parent);
00046   * @endcode
00047   *
00048   *
00049   **/
00050 class TLP_QT_SCOPE PropertyCreationDialog : public QDialog {
00051   Q_OBJECT
00052 
00053 public:
00054   /**
00055     * @brief Constructs a property creation dialog with the given parent.
00056     **/
00057   explicit PropertyCreationDialog(QWidget *parent = NULL);
00058   /**
00059     * @brief Constructs a property creation dialog with the given parent graph and parent widget.
00060     **/
00061   explicit PropertyCreationDialog(tlp::Graph* graph,QWidget *parent = NULL,
00062                                   const std::string& selectedType = "");
00063   ~PropertyCreationDialog();
00064 
00065 
00066   /**
00067     * @brief Try to create a new property from the givent parameters.
00068     * To get the created property use the createdProperty() function.
00069     **/
00070   void accept();
00071 
00072   /**
00073     * @brief Change the graph to use as parent for the properties to create.
00074     **/
00075   void setGraph(tlp::Graph* graph);
00076 
00077 
00078   tlp::Graph* getGraph()const {
00079     return _graph;
00080   }
00081 
00082   /**
00083     * @brief Return the property created. You need to call this function after the accept() function.
00084     *
00085     * @return The last created property or NULL if no property there is an error during the property creation.
00086     **/
00087   tlp::PropertyInterface* createdProperty()const {
00088     return _createdProperty;
00089   }
00090 
00091   /**
00092     * @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.
00093     *
00094     * The function creates a modal property creation dialog with the given graph and parent widget.
00095     *
00096     * @param graph The graph to use as parent for the properties to create.
00097     **/
00098   static PropertyInterface* createNewProperty(tlp::Graph* graph,
00099       QWidget* parent=NULL,
00100       const std::string& selectedType = "");
00101 private slots:
00102   void checkValidity();
00103 private:
00104   void initGui();
00105 
00106   Ui::PropertyCreationDialog *ui;
00107   QPushButton* _createPropertyButton;
00108   Graph* _graph;
00109   PropertyInterface* _createdProperty;
00110 };
00111 }
00112 
00113 #endif // PROPERTYCREATIONDIALOG_H
00114 ///@endcond
 All Classes Files Functions Variables Enumerations Enumerator Properties