moveit2
The MoveIt Motion Planning Framework for ROS 2.
helper_widgets.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 <QFrame>
41 class QLabel;
42 class QLineEdit;
43 
44 namespace moveit_setup
45 {
46 // ******************************************************************************************
47 // ******************************************************************************************
48 // Class for showing the title and instructions
49 // ******************************************************************************************
50 // ******************************************************************************************
51 class HeaderWidget : public QWidget
52 {
53  Q_OBJECT
54 
55 public:
57  HeaderWidget(const std::string& title, const std::string& instructions, QWidget* parent);
58 };
59 
60 // ******************************************************************************************
61 // ******************************************************************************************
62 // Class for selecting files
63 // ******************************************************************************************
64 // ******************************************************************************************
65 class LoadPathWidget : public QFrame
66 {
67  Q_OBJECT
68 
69 private:
70  // Only allow user to select folders
71  bool dir_only_;
72  // Only allow user to load files (not save)
73  bool load_only_;
74  // Stores the path qstring
75  QLineEdit* path_box_;
76 
77 Q_SIGNALS:
78  void pathChanged(const QString& path);
80 
81 private Q_SLOTS:
83  void btnFileDialog();
84 
85 public:
87  LoadPathWidget(const QString& title, const QString& instructions, QWidget* parent, const bool dir_only = false,
88  const bool load_only = false);
89 
91  QString getQPath() const;
92 
94  std::string getPath() const;
95 
97  void setPath(const QString& path);
98 
100  void setPath(const std::string& path);
101 };
102 
105 {
106  Q_OBJECT
107 
108 private:
109  QLineEdit* args_;
110  QLabel* args_instructions_;
111 
112 public:
114  LoadPathArgsWidget(const QString& title, const QString& instructions, const QString& arg_instructions,
115  QWidget* parent, const bool dir_only = false, const bool load_only = false);
116 
117  QString getArgs() const;
118  void setArgs(const QString& args);
119  void setArgsEnabled(bool enabled = true);
120 };
121 } // namespace moveit_setup
HeaderWidget(const std::string &title, const std::string &instructions, QWidget *parent)
Constructor.
Extend LoadPathWidget with additional line edit for arguments.
void setArgsEnabled(bool enabled=true)
void setArgs(const QString &args)
LoadPathArgsWidget(const QString &title, const QString &instructions, const QString &arg_instructions, QWidget *parent, const bool dir_only=false, const bool load_only=false)
Constructor.
LoadPathWidget(const QString &title, const QString &instructions, QWidget *parent, const bool dir_only=false, const bool load_only=false)
Constructor.
void pathChanged(const QString &path)
QString getQPath() const
Returns the file path in QString format.
void setPath(const QString &path)
Set the path with QString.
std::string getPath() const
Returns the file path in std::string format.