moveit2
The MoveIt Motion Planning Framework for ROS 2.
collision_linear_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 <QAbstractProxyModel>
40 #include <QSortFilterProxyModel>
41 #include <QVector>
42 
43 #ifndef Q_MOC_RUN
45 #endif
46 
48 
49 namespace moveit_setup
50 {
51 namespace srdf_setup
52 {
53 class CollisionLinearModel : public QAbstractProxyModel
54 {
55  Q_OBJECT
56 
57 public:
58  CollisionLinearModel(CollisionMatrixModel* src, QObject* parent = nullptr);
59  ~CollisionLinearModel() override;
60 
61  // reimplement to return the model index in the proxy model that to the sourceIndex from the source model
62  QModelIndex mapFromSource(const QModelIndex& sourceIndex) const override;
63  // Reimplement this function to return the model index in the source model that corresponds to the proxyIndex in the
64  // proxy model
65  QModelIndex mapToSource(const QModelIndex& proxyIndex) const override;
66 
67  int rowCount(const QModelIndex& parent) const override;
68  int columnCount(const QModelIndex& parent) const override;
69 
70  QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
71  QModelIndex parent(const QModelIndex& child) const override;
72  QVariant data(const QModelIndex& index, int role) const override;
73  DisabledReason reason(int row) const;
74 
75  bool setData(const QModelIndex& index, const QVariant& value, int role) override;
76  void setEnabled(const QItemSelection& selection, bool value);
77 
78  Qt::ItemFlags flags(const QModelIndex& index) const override;
79  QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
80 };
81 
83 class SortFilterProxyModel : public QSortFilterProxyModel
84 {
85  Q_OBJECT
86 
87 public:
88  SortFilterProxyModel(QObject* parent = nullptr);
89  QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
90  void sort(int column, Qt::SortOrder order) override;
91  void setShowAll(bool show_all);
92  void setEnabled(const QItemSelection& selection, bool value);
93 
94 protected:
95  bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override;
96  bool lessThan(const QModelIndex& src_left, const QModelIndex& src_right) const override;
97 
98 private Q_SLOTS:
99  void initSorting();
100 
101 private:
102  bool show_all_;
103  QVector<int> sort_columns_; // sorting history
104  QVector<int> sort_orders_; // corresponding sort orders
105 };
106 } // namespace srdf_setup
107 } // namespace moveit_setup
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
bool setData(const QModelIndex &index, const QVariant &value, int role) override
QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override
CollisionLinearModel(CollisionMatrixModel *src, QObject *parent=nullptr)
QModelIndex mapToSource(const QModelIndex &proxyIndex) const override
Qt::ItemFlags flags(const QModelIndex &index) const override
int columnCount(const QModelIndex &parent) const override
int rowCount(const QModelIndex &parent) const override
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
void setEnabled(const QItemSelection &selection, bool value)
QVariant data(const QModelIndex &index, int role) const override
QModelIndex parent(const QModelIndex &child) const override
bool lessThan(const QModelIndex &src_left, const QModelIndex &src_right) const override
void setEnabled(const QItemSelection &selection, bool value)
void sort(int column, Qt::SortOrder order) override
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
DisabledReason
Reasons for disabling link pairs. Append "in collision" for understanding. NOT_DISABLED means the lin...