moveit2
The MoveIt Motion Planning Framework for ROS 2.
collision_matrix_model.hpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2016, CITEC, Bielefeld University
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: Robert Haschke */
36 
37 #pragma once
38 
39 #include <QAbstractTableModel>
40 
41 #ifndef Q_MOC_RUN
43 #endif
44 
45 #include <QItemSelection>
46 namespace moveit_setup
47 {
48 namespace srdf_setup
49 {
50 class CollisionMatrixModel : public QAbstractTableModel
51 {
52  Q_OBJECT
53 public:
54  CollisionMatrixModel(LinkPairMap& pairs, const std::vector<std::string>& names, QObject* parent = nullptr);
55  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
56  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
57  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
58  QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
59  DisabledReason reason(const QModelIndex& index) const;
60 
61  // for editing
62  Qt::ItemFlags flags(const QModelIndex& index) const override;
63  bool setData(const QModelIndex& /*index*/, const QVariant& value, int role) override;
64  void setEnabled(const QItemSelection& selection, bool value);
65  void setEnabled(const QModelIndexList& indexes, bool value);
66 
67 public Q_SLOTS:
68  void setFilterRegExp(const QString& filter);
69 
70 private:
71  LinkPairMap::iterator item(const QModelIndex& index);
72  LinkPairMap::const_iterator item(const QModelIndex& index) const
73  {
74  return const_cast<CollisionMatrixModel*>(this)->item(index);
75  }
76 
77 private:
78  LinkPairMap& pairs;
79  const std::vector<std::string> std_names; // names of links
80  QList<QString> q_names; // names of links
81  QList<int> visual_to_index; // map from visual index to actual index
82 };
83 } // namespace srdf_setup
84 } // namespace moveit_setup
int columnCount(const QModelIndex &parent=QModelIndex()) const override
bool setData(const QModelIndex &, const QVariant &value, int role) override
CollisionMatrixModel(LinkPairMap &pairs, const std::vector< std::string > &names, QObject *parent=nullptr)
void setEnabled(const QItemSelection &selection, bool value)
DisabledReason reason(const QModelIndex &index) const
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Qt::ItemFlags flags(const QModelIndex &index) const override
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
DisabledReason
Reasons for disabling link pairs. Append "in collision" for understanding. NOT_DISABLED means the lin...
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...