default_collisions_widget.h
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 #ifndef MOVEIT_MOVEIT_SETUP_ASSISTANT_WIDGETS_DEFAULT_COLLISIONS_WIDGET__
38 #define MOVEIT_MOVEIT_SETUP_ASSISTANT_WIDGETS_DEFAULT_COLLISIONS_WIDGET__
39 
40 #include <QWidget>
41 #include <QLabel>
42 #include <QVBoxLayout>
43 #include <QTableView>
44 #include <QSlider>
45 #include <QPushButton>
46 #include <QGroupBox>
47 #include <QProgressBar>
48 #include <QCheckBox>
49 #include <QRadioButton>
50 #include <QSpinBox>
51 #include <QThread>
52 #include <QLineEdit>
53 #include <QAction>
54 
55 #ifndef Q_MOC_RUN
56 #include <boost/thread.hpp>
57 #include <boost/function.hpp>
60 #endif
61 
62 #include "header_widget.h"
63 #include "setup_screen_widget.h" // a base class for screens in the setup assistant
64 
65 namespace moveit_setup_assistant
66 {
67 class MonitorThread;
68 
73 {
74  Q_OBJECT
75 
76 public:
77  enum ViewMode
78  {
81  };
82 
83  // ******************************************************************************************
84  // Public Functions
85  // ******************************************************************************************
86 
91  DefaultCollisionsWidget(QWidget* parent, moveit_setup_assistant::MoveItConfigDataPtr config_data);
93 
97  void linkPairsToSRDF();
98 
102  void linkPairsFromSRDF();
103 
104 private Q_SLOTS:
105 
106  // ******************************************************************************************
107  // Slot Event Functions
108  // ******************************************************************************************
109 
118 
123  void changeDensityLabel(int value);
124 
128  void loadCollisionTable();
129 
133  void checkedFilterChanged();
134 
138  void collisionsChanged(const QModelIndex& index);
139 
143  void revertChanges();
144 
148  void previewSelectedMatrix(const QModelIndex& index);
149  void previewSelectedLinear(const QModelIndex& index);
150 
154  void focusGiven();
155 
159  bool focusLost();
160 
161  void showHeaderContextMenu(const QPoint& p);
162  void hideSections();
163  void hideOtherSections();
164  void showSections();
165 
166 private:
167  // ******************************************************************************************
168  // Qt Components
169  // ******************************************************************************************
170  QLabel* page_title_;
171  QTableView* collision_table_;
172  QAbstractItemModel* model_;
173  QItemSelectionModel* selection_model_;
174  QVBoxLayout* layout_;
176  QSlider* density_slider_;
177  QPushButton* btn_generate_;
178  QGroupBox* controls_box_;
179  QProgressBar* progress_bar_;
181  QLineEdit* link_name_filter_;
184  QSpinBox* fraction_spinbox_;
185  QPushButton* btn_revert_;
186  QButtonGroup* view_mode_buttons_;
187 
188  QList<QAction*> header_actions_; // context actions for header sections
189  Qt::Orientations clicked_headers_; // remember which header section activated context actions
190  int clicked_section_; // remember which header section activated context actions
191 
192  // ******************************************************************************************
193  // Variables
194  // ******************************************************************************************
196 
199 
201  moveit_setup_assistant::MoveItConfigDataPtr config_data_;
202 
203  // ******************************************************************************************
204  // Private Functions
205  // ******************************************************************************************
206 
212  void generateCollisionTable(unsigned int* collision_progress);
213 
218  void disableControls(bool disable);
219 
223  bool eventFilter(QObject* object, QEvent* event);
224 
228  void showSections(QHeaderView* header, const QList<int>& logicalIndexes);
232  void toggleSelection(QItemSelection selection);
233 };
234 
238 class MonitorThread : public QThread
239 {
240  Q_OBJECT
241 
242 public:
243  MonitorThread(const boost::function<void(unsigned int*)>& f, QProgressBar* progress_bar = NULL);
244  void run();
245  void cancel()
246  {
247  canceled_ = true;
248  }
249  bool canceled() const
250  {
251  return canceled_;
252  }
253 
254 Q_SIGNALS:
255  void progress(int);
256 
257 private:
258  boost::thread worker_;
259  unsigned int progress_;
260  bool canceled_;
261 };
262 }
263 
264 #endif
#define NULL
void disableControls(bool disable)
Helper function to disable parts of GUI during computation.
DefaultCollisionsWidget(QWidget *parent, moveit_setup_assistant::MoveItConfigDataPtr config_data)
User interface for editing the default collision matrix list in an SRDF.
void linkPairsFromSRDF()
Load Link Pairs from SRDF Format.
f
moveit_setup_assistant::LinkPairMap link_pairs_
main storage of link pair data
void collisionsChanged(const QModelIndex &index)
Collision model changed.
void linkPairsToSRDF()
Output Link Pairs to SRDF Format.
void generateCollisionTable(unsigned int *collision_progress)
The thread that is called to allow the GUI to update. Calls an external function to do calcs...
void loadCollisionTable()
Update view and data model for the link_pairs data structure.
User interface for editing the default collision matrix list in an SRDF.
void previewSelectedMatrix(const QModelIndex &index)
Called when current row has changed.
void changeDensityLabel(int value)
GUI func for showing sampling density amount.
moveit_setup_assistant::MoveItConfigDataPtr config_data_
Contains all the configuration data for the setup assistant.
bool focusLost()
Called when setup assistant navigation switches away from this screen.
void focusGiven()
Called when setup assistant navigation switches to this screen.
QThread to monitor progress of a boost::thread.
void toggleSelection(QItemSelection selection)
Toggle enabled status of selection.
void checkedFilterChanged()
Change filter settings to show/hide enabled collisions.
bool eventFilter(QObject *object, QEvent *event)
Allow toggling of all checkboxes in selection by filtering <space> keypresses.
void startGeneratingCollisionTable()
start generating collision matrix in a worker thread
void revertChanges()
Revert current changes to collision matrix.
void finishGeneratingCollisionTable()
finish generating collision matrix after worker thread has finished
void run(ClassLoader *loader)
std::map< std::pair< std::string, std::string >, LinkPairData > LinkPairMap
LinkPairMap is an adjacency list structure containing links in string-based form. Used for disabled l...


moveit_setup_assistant
Author(s): Dave Coleman
autogenerated on Sun Oct 18 2020 13:19:28