Tulip  5.1.0
Large graphs analysis and drawing
CSVGraphMappingConfigurationWidget.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 #ifndef CSVGRAPHMAPPINGCONFIGURATIONWIDGET_H
22 #define CSVGRAPHMAPPINGCONFIGURATIONWIDGET_H
23 
24 #include <QComboBox>
25 #include <QPushButton>
26 #include <QString>
27 
28 #include <tulip/tulipconf.h>
29 
30 namespace Ui {
31 class CSVGraphMappingConfigurationWidget;
32 }
33 
34 namespace tlp {
35 
36 class Graph;
37 class CSVGraphImport;
38 class CSVImportParameters;
39 class CSVToGraphDataMapping;
40 
41 /**
42  * @brief Widget generating the CSVToGraphDataMapping object.
43  *
44  * This widget allow user to configure a CSVToGraphDataMapping object. This object is used during the CSV import process to map CSV columns to graph elements like nodes or edges.
45  **/
46 class TLP_QT_SCOPE CSVGraphMappingConfigurationWidget : public QWidget {
47  Q_OBJECT
48 public:
49  CSVGraphMappingConfigurationWidget(QWidget *parent = NULL);
50  ~CSVGraphMappingConfigurationWidget();
51 
52  /**
53  * @brief Configure the widget with the CSV import parameters.
54  **/
55  void updateWidget(tlp::Graph* graph,const CSVImportParameters& importParameters);
56  /**
57  * @brief Build the mapping object between the CSV columns and the graph elements.
58  **/
59  CSVToGraphDataMapping *buildMappingObject() const;
60 
61  /**
62  * @brief Check if the values entered by user are valid.
63  *
64  * If return true you are sure that buildMappingObject never return a NULL object.
65  **/
66  bool isValid()const;
67 
68 protected:
69  tlp::Graph* graph;
70  std::vector<std::string> columns;
71  std::vector<unsigned int> nodeColumnIds;
72  std::vector<std::string> nodeProperties;
73  std::vector<unsigned int> edgeColumnIds;
74  std::vector<std::string> edgeProperties;
75  std::vector<unsigned int> srcColumnIds;
76  std::vector<unsigned int> tgtColumnIds;
77  std::vector<std::string> srcProperties;
78  std::vector<std::string> tgtProperties;
79 
80 private:
81  Ui::CSVGraphMappingConfigurationWidget *ui;
82  void selectColumns(const QString& title,
83  std::vector<unsigned int>& columnIds,
84  QPushButton* button);
85  void selectProperties(const QString& title,
86  std::vector<std::string>& selProperties,
87  QPushButton* button);
88 
89 private slots:
90  void createNewProperty();
91  void selectNodeColumns();
92  void selectEdgeColumns();
93  void selectSrcColumns();
94  void selectTgtColumns();
95  void selectSrcProperties();
96  void selectTgtProperties();
97  void selectNodeProperties();
98  void selectEdgeProperties();
99 
100 signals:
101  void mappingChanged();
102 };
103 }
104 #endif // CSVGRAPHMAPPINGCONFIGURATIONWIDGET_H
105 ///@endcond