Tulip  5.1.0
Large graphs analysis and drawing
GraphPropertiesSelectionWidget.h
1 /*
2  *
3  * This file is part of Tulip (http://tulip.labri.fr)
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 GRAPHPROPERTYSELECTIONWIDGET_H_
23 #define GRAPHPROPERTYSELECTIONWIDGET_H_
24 
25 #include "StringsListSelectionWidget.h"
26 
27 namespace tlp {
28 
29 class Graph;
30 /** \brief A widget which allows the user to select a subset of graph properties
31  *
32  * This widget allows the user to select a subset of graph properties. The properties
33  * to select can be filtered according to their datatypes.
34  */
35 class TLP_QT_SCOPE GraphPropertiesSelectionWidget : public StringsListSelectionWidget {
36 
37 public :
38 
39  /**
40  * Default Constructor (usefull for qt designer)
41  */
42  GraphPropertiesSelectionWidget(QWidget *parent = NULL, const StringsListSelectionWidget::ListType &listType = StringsListSelectionWidget::SIMPLE_LIST,
43  const unsigned int maxNbSelectedProperties = 0);
44 
45  /**
46  * Constructor which creates a GraphPropertiesSelectionWidget for a given graph
47  *
48  * \param graph The graph on which we want to select properties
49  * \param propertiesType To select properties with particular datatypes, fill a vector of string with the wanted datatypes name and passed it as parameter of this constructor. The datatypes name must be the same as those returned by the getTypename method of the PropertyInterface class (e.g. "int", "double", "string"). If the vector is empty, there is no restriction on property datatypes.
50  * \param includeViewProperties If true, the view properties (e.g. "viewLabel", "viewMetric") will be selectable
51  */
52  GraphPropertiesSelectionWidget(Graph *graph, QWidget *parent = NULL, const StringsListSelectionWidget::ListType &listType = StringsListSelectionWidget::SIMPLE_LIST,
53  const unsigned int maxNbSelectedProperties = 0, const std::vector<std::string> &propertiesTypes = std::vector<std::string>(),
54  const bool includeViewProperties = false);
55 
56  /**
57  * Method to set the widget parameters
58  *
59  * \param graph The graph on which we want to select properties
60  * \param propertiesType To select properties with particular datatypes, fill a vector of string with the wanted datatypes name and passed it as parameter of this constructor. The datatypes name must be the same as those returned by the getTypename method of the PropertyInterface class (e.g. "int", "double", "string"). If the vector is empty, there is no restriction on property datatypes.
61  * \param includeViewProperties If true, the view properties (e.g. "viewLabel", "viewMetric") will be selectable
62  */
63  void setWidgetParameters(Graph *graph, const std::vector<std::string> &propertiesTypes = std::vector<std::string>(), const bool includeViewProperties = false);
64 
65  /**
66  * Method to set the input graph properties list
67  * If there is datatypes restriction, the types of properties are checked before inserting them in the input list
68  * \param inputPropertiesList A vector containing input properties names
69  */
70  void setInputPropertiesList(std::vector<std::string> &inputPropertiesList);
71 
72  /**
73  * Method to set the output graph properties list
74  * If there is datatypes restriction, the types of properties are checked before inserting them in the output list
75  * \param outputPropertiesList A vector containing output properties names
76  */
77  void setOutputPropertiesList(std::vector<std::string> &outputPropertiesList);
78 
79  /**
80  * Method which returns the names of the graph properties selected by the user
81  */
82  std::vector<std::string> getSelectedProperties() const;
83 
84 
85  /**
86  * Method which clears the content of the input list and the output list
87  */
88  void clearLists();
89 
90 private :
91 
92  void initWidget();
93  bool propertySelectable(const std::string &propertyName);
94 
95  Graph *graph;
96  std::vector<std::string> propertiesTypes;
97  bool includeViewProperties;
98 
99 };
100 
101 }
102 
103 #endif /* GRAPHPROPERTYSELECTIONWIDGET_H_ */
104 ///@endcond