Palette.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef GAZEBO_GUI_PLOT_PALETTE_HH_
18 #define GAZEBO_GUI_PLOT_PALETTE_HH_
19 
20 #include <memory>
21 #include <set>
22 #include <string>
23 
24 #include "gazebo/gui/qt.h"
25 #include "gazebo/msgs/msgs.hh"
26 
27 #include "gazebo/util/system.hh"
28 
29 namespace google
30 {
31  namespace protobuf
32  {
33  class Message;
34  }
35 }
36 
37 namespace gazebo
38 {
39  namespace common
40  {
41  class URI;
42  }
43 
44  namespace gui
45  {
47  class SearchModel : public QSortFilterProxyModel
48  {
70  public: bool filterAcceptsRow(const int _srcRow,
71  const QModelIndex &_srcParent) const;
72 
78  public: bool filterAcceptsRowItself(const int _srcRow, const
79  QModelIndex &_srcParent, QString _word) const;
80 
85  public: bool hasAcceptedChildren(const int _srcRow,
86  const QModelIndex &_srcParent) const;
87 
92  public: bool hasChildAcceptsItself(const QModelIndex &_srcParent,
93  const QString &_word) const;
94 
97  public: void SetSearch(const QString &_search);
98 
100  public: QString search;
101  };
102 
103  // Forward declare private data class
104  class PalettePrivate;
105 
108  class GZ_GUI_VISIBLE Palette : public QWidget
109  {
110  Q_OBJECT
111 
114  public: Palette(QWidget *_parent);
115 
117  public: ~Palette();
118 
120  private: void FillTopics();
121 
123  private: void FillModels();
124 
126  private: void FillSim();
127 
133  private: void FillFromMsg(google::protobuf::Message *_msg,
134  QStandardItem *_item, const std::string &_uri);
135 
140  private: void InsertPoseItem(QStandardItem *_item,
141  const common::URI &_uri, const std::string &_query);
142 
150  private: void InsertVector3dItem(QStandardItem *_item,
151  const common::URI &_uri, const std::string &_query);
152 
157  private: void InsertQuaterniondItem(QStandardItem *_item,
158  const common::URI &_uri, const std::string &_query);
159 
164  private: void InsertAxisItem(QStandardItem *_item,
165  const common::URI &_uri, const std::string &_query);
166 
169  private slots: void UpdateSearch(const QString &_search);
170 
175  private: void ExpandChildren(QSortFilterProxyModel *_model,
176  QTreeView *_tree, const QModelIndex &_srcParent) const;
177 
183  private: void OnIntrospectionUpdate(const std::set<std::string> &_items,
184  const bool _result);
185 
189  private: void OnIntrospectionUpdate(const gazebo::msgs::Param_V &_msg);
190 
193  Q_SIGNALS: void IntrospectionUpdateSignal(
194  const std::set<std::string> &_items);
195 
198  private slots: void IntrospectionUpdateSlot(
199  const std::set<std::string> &_items);
200 
203  private slots: void ExpandTree(const QModelIndex &_index);
204 
207  private: std::unique_ptr<PalettePrivate> dataPtr;
208  };
209  }
210 }
211 #endif
std::vector< common::Param * > Param_V
Definition: CommonTypes.hh:97
bool hasAcceptedChildren(const int _srcRow, const QModelIndex &_srcParent) const
Check if any of the children is fully accepted.
A complete URI.
Definition: URI.hh:176
bool filterAcceptsRow(const int _srcRow, const QModelIndex &_srcParent) const
Customize so we accept rows where:
bool filterAcceptsRowItself(const int _srcRow, const QModelIndex &_srcParent, QString _word) const
Check if row contains the word on itself.
Customize the proxy model to display search results.
Definition: Palette.hh:47
QString search
Full search string.
Definition: Palette.hh:100
A palette for the plot window, where plottable items can be dragged from.
Definition: Palette.hh:108
void SetSearch(const QString &_search)
Set a new search value.
bool hasChildAcceptsItself(const QModelIndex &_srcParent, const QString &_word) const
Check if any of the children accepts a specific word.