moveit2
The MoveIt Motion Planning Framework for ROS 2.
double_list_widget.hpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2012, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Willow Garage nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 /* Author: Dave Coleman */
36 
37 #pragma once
38 
39 #include <QWidget>
40 #include <QLabel>
41 #include <QTableWidget>
42 #include <QTableWidgetItem>
43 #include <QItemSelection>
44 
45 namespace moveit_setup
46 {
47 class DoubleListWidget : public QWidget
48 {
49  Q_OBJECT
50 
51  // ******************************************************************************************
52  // Reusable double list widget for selecting and deselecting a subset from a set
53  // ******************************************************************************************
54 public:
55  // ******************************************************************************************
56  // Public Functions
57  // ******************************************************************************************
58 
60  DoubleListWidget(QWidget* parent, const QString& long_name, const QString& short_name, bool add_ok_cancel = true);
61 
63  void setAvailable(const std::vector<std::string>& items);
64 
66  void setSelected(const std::vector<std::string>& items);
67 
68  void clearContents();
69 
71  void setTable(const std::vector<std::string>& items, QTableWidget* table);
72 
74  void setColumnNames(const QString& col1, const QString& col2);
75 
77  std::vector<std::string> getSelectedValues() const;
78 
79  // ******************************************************************************************
80  // Qt Components
81  // ******************************************************************************************
82 
83  QTableWidget* data_table_;
84  QTableWidget* selected_data_table_;
85  QLabel* title_; // specify the title from the parent widget
86  QLabel* column1_label_;
87  QLabel* column2_label_;
88 
90  QString long_name_;
91  QString short_name_;
92 
93 private Q_SLOTS:
94 
95  // ******************************************************************************************
96  // Slot Event Functions
97  // ******************************************************************************************
98 
100  void selectDataButtonClicked();
101 
103  void deselectDataButtonClicked();
104 
106  void previewSelectedLeft(const QItemSelection& selected, const QItemSelection& deselected);
107  void previewSelectedRight(const QItemSelection& selected, const QItemSelection& deselected);
108 
109 Q_SIGNALS:
110 
111  // ******************************************************************************************
112  // Emitted Signals
113  // ******************************************************************************************
115  void doneEditing();
116 
119 
121  void previewSelected(std::vector<std::string> /*_t1*/);
122 
125 
126 private:
127  // ******************************************************************************************
128  // Variables
129  // ******************************************************************************************
130 
131  // ******************************************************************************************
132  // Private Functions
133  // ******************************************************************************************
134 
136  void previewSelected(const QList<QTableWidgetItem*>& selected);
137 };
138 
139 } // namespace moveit_setup
QString long_name_
Name of datatype.
void setColumnNames(const QString &col1, const QString &col2)
Set the names of the two columns in the widget.
void doneEditing()
Event sent when this widget is done making data changes and parent widget can save.
void selectionUpdated()
When the set of selected items has changed.
std::vector< std::string > getSelectedValues() const
Return all the values that are in the "selected" subset.
void setTable(const std::vector< std::string > &items, QTableWidget *table)
Convenience function for reusing set table code.
DoubleListWidget(QWidget *parent, const QString &long_name, const QString &short_name, bool add_ok_cancel=true)
Constructor.
void previewSelected(std::vector< std::string >)
Signal to highlight parts of robot.
void cancelEditing()
Event sent when user presses cancel button.
void setAvailable(const std::vector< std::string > &items)
Loads the available data list.
void setSelected(const std::vector< std::string > &items)
Set the right box.