configuration_files_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 #pragma once
38 
39 #include <QList>
40 class QLabel;
41 class QListWidget;
42 class QListWidgetItem;
43 class QProgressBar;
44 class QPushButton;
45 
46 #ifndef Q_MOC_RUN
48 #endif
49 
50 #include "setup_screen_widget.h" // a base class for screens in the setup assistant
51 
52 namespace moveit_setup_assistant
53 {
54 class LoadPathWidget;
55 
56 // Struct for storing all the file operations
58 {
60  {
61  }
62  std::string file_name_;
63  std::string rel_path_;
64  std::string description_;
65  unsigned long write_on_changes; // bitfield indicating required rewrite
66  bool generate_; // "generate" checkbox ticked?
67  bool modified_; // file externally modified?
68  std::function<bool(std::string)> gen_func_;
69 };
70 
71 // Typedef for storing template string replacement pairs
72 typedef std::vector<std::pair<std::string, std::string> > StringPairVector;
73 
74 // Class
76 {
77  Q_OBJECT
78 
79 public:
80  // ******************************************************************************************
81  // Public Functions
82  // ******************************************************************************************
83 
84  ConfigurationFilesWidget(QWidget* parent, const MoveItConfigDataPtr& config_data);
85 
87  void focusGiven() override;
88 
89  // ******************************************************************************************
90  // Qt Components
91  // ******************************************************************************************
92  QPushButton* btn_save_;
94  QProgressBar* progress_bar_;
95  QListWidget* action_list_;
96  QLabel* action_label_;
97  QLabel* success_label_;
98  QList<QString> action_desc_; // Holds the descriptions explaining all performed actions
99 
100 private Q_SLOTS:
101 
102  // ******************************************************************************************
103  // Slot Event Functions
104  // ******************************************************************************************
105 
107  void savePackage();
108 
110  bool generatePackage();
111 
113  void exitSetupAssistant();
114 
116  void changeActionDesc(int id);
117 
119  void changeCheckedState(QListWidgetItem* item);
120 
122  void setCheckSelected(bool checked);
123 
124 private:
125  // ******************************************************************************************
126  // Variables
127  // ******************************************************************************************
128 
130  moveit_setup_assistant::MoveItConfigDataPtr config_data_;
131 
133  std::string new_package_name_;
134 
136  unsigned int action_num_;
137 
140 
142  std::vector<GenerateFile> gen_files_;
143 
146 
147  // ******************************************************************************************
148  // Private Functions
149  // ******************************************************************************************
150 
152  bool loadGenFiles();
153 
156  bool checkGenFiles();
157 
159  bool showGenFiles();
160 
162  bool checkDependencies();
163 
165  void updateProgress();
166 
168  const std::string getPackageName(std::string package_path);
169 
171  bool noGroupsEmpty();
172 
177  void loadTemplateStrings();
178 
185  bool addTemplateString(const std::string& key, const std::string& value);
186 
196  bool copyTemplate(const std::string& template_path, const std::string& output_path);
197 
203  bool createFolder(const std::string& output_path);
204 };
205 
206 } // namespace moveit_setup_assistant
moveit_setup_assistant::ConfigurationFilesWidget::showGenFiles
bool showGenFiles()
Show the list of files to be generated.
Definition: configuration_files_widget.cpp:1018
moveit_setup_assistant::GenerateFile::modified_
bool modified_
Definition: configuration_files_widget.h:67
moveit_setup_assistant::GenerateFile::description_
std::string description_
Definition: configuration_files_widget.h:64
moveit_setup_assistant::ConfigurationFilesWidget::setCheckSelected
void setCheckSelected(bool checked)
Set checked state of all selected items.
Definition: configuration_files_widget.cpp:220
moveit_setup_assistant::GenerateFile::GenerateFile
GenerateFile()
Definition: configuration_files_widget.h:59
moveit_setup_assistant::GenerateFile::rel_path_
std::string rel_path_
Definition: configuration_files_widget.h:63
moveit_setup_assistant::ConfigurationFilesWidget::addTemplateString
bool addTemplateString(const std::string &key, const std::string &value)
Insert a string pair into the template_strings_ datastructure.
Definition: configuration_files_widget.cpp:1382
moveit_setup_assistant::ConfigurationFilesWidget::generatePackage
bool generatePackage()
Generate the package.
Definition: configuration_files_widget.cpp:1093
moveit_setup_assistant::ConfigurationFilesWidget::gen_files_
std::vector< GenerateFile > gen_files_
Vector of all files to be generated.
Definition: configuration_files_widget.h:142
moveit_setup_assistant::GenerateFile
Definition: configuration_files_widget.h:57
moveit_setup_assistant::ConfigurationFilesWidget::action_num_
unsigned int action_num_
Track progress.
Definition: configuration_files_widget.h:136
moveit_setup_assistant::ConfigurationFilesWidget::loadGenFiles
bool loadGenFiles()
Populate the 'Files to be generated' list.
Definition: configuration_files_widget.cpp:229
moveit_setup_assistant::ConfigurationFilesWidget::updateProgress
void updateProgress()
A function for showing progress and user feedback about what happened.
Definition: configuration_files_widget.cpp:877
moveit_setup_assistant::ConfigurationFilesWidget::loadTemplateStrings
void loadTemplateStrings()
Load the strings that will be replaced in all templates.
Definition: configuration_files_widget.cpp:1271
moveit_config_data.h
moveit_setup_assistant::StringPairVector
std::vector< std::pair< std::string, std::string > > StringPairVector
Definition: configuration_files_widget.h:72
moveit_setup_assistant::ConfigurationFilesWidget::action_list_
QListWidget * action_list_
Definition: configuration_files_widget.h:95
moveit_setup_assistant::ConfigurationFilesWidget::progress_bar_
QProgressBar * progress_bar_
Definition: configuration_files_widget.h:94
moveit_setup_assistant::ConfigurationFilesWidget::ConfigurationFilesWidget
ConfigurationFilesWidget(QWidget *parent, const MoveItConfigDataPtr &config_data)
Definition: configuration_files_widget.cpp:105
moveit_setup_assistant::ConfigurationFilesWidget::config_data_
moveit_setup_assistant::MoveItConfigDataPtr config_data_
Contains all the configuration data for the setup assistant.
Definition: configuration_files_widget.h:130
moveit_setup_assistant::ConfigurationFilesWidget::action_label_
QLabel * action_label_
Definition: configuration_files_widget.h:96
moveit_setup_assistant::ConfigurationFilesWidget::getPackageName
const std::string getPackageName(std::string package_path)
Get the last folder name in a directory path.
Definition: configuration_files_widget.cpp:1216
moveit_setup_assistant::ConfigurationFilesWidget::btn_save_
QPushButton * btn_save_
Definition: configuration_files_widget.h:92
moveit_setup_assistant::GenerateFile::file_name_
std::string file_name_
Definition: configuration_files_widget.h:62
moveit_setup_assistant::GenerateFile::generate_
bool generate_
Definition: configuration_files_widget.h:66
moveit_setup_assistant::ConfigurationFilesWidget::checkGenFiles
bool checkGenFiles()
Definition: configuration_files_widget.cpp:961
moveit_setup_assistant::ConfigurationFilesWidget::success_label_
QLabel * success_label_
Definition: configuration_files_widget.h:97
SetupScreenWidget
Definition: setup_screen_widget.h:44
moveit_setup_assistant::GenerateFile::gen_func_
std::function< bool(std::string)> gen_func_
Definition: configuration_files_widget.h:68
moveit_setup_assistant::ConfigurationFilesWidget::new_package_name_
std::string new_package_name_
Name of the new package that is being (or going) to be generated, based on user specified save path.
Definition: configuration_files_widget.h:133
moveit_setup_assistant::ConfigurationFilesWidget::copyTemplate
bool copyTemplate(const std::string &template_path, const std::string &output_path)
Definition: configuration_files_widget.cpp:1392
moveit_setup_assistant::ConfigurationFilesWidget::savePackage
void savePackage()
Save package click event.
Definition: configuration_files_widget.cpp:1069
moveit_setup_assistant
Definition: compute_default_collisions.h:46
moveit_setup_assistant::ConfigurationFilesWidget::focusGiven
void focusGiven() override
Received when this widget is chosen from the navigation menu.
Definition: configuration_files_widget.cpp:923
moveit_setup_assistant::ConfigurationFilesWidget
Definition: configuration_files_widget.h:75
moveit_setup_assistant::ConfigurationFilesWidget::has_generated_pkg_
bool has_generated_pkg_
Has the package been generated yet this program execution? Used for popping up exit warning.
Definition: configuration_files_widget.h:139
moveit_setup_assistant::ConfigurationFilesWidget::changeCheckedState
void changeCheckedState(QListWidgetItem *item)
Disable or enable item in gen_files_ array.
Definition: configuration_files_widget.cpp:904
moveit_setup_assistant::ConfigurationFilesWidget::createFolder
bool createFolder(const std::string &output_path)
Create a folder.
Definition: configuration_files_widget.cpp:1440
moveit_setup_assistant::ConfigurationFilesWidget::noGroupsEmpty
bool noGroupsEmpty()
Check that no group is empty (without links/joints/etc)
Definition: configuration_files_widget.cpp:1240
setup_screen_widget.h
moveit_setup_assistant::ConfigurationFilesWidget::template_strings_
StringPairVector template_strings_
Vector of all strings to search for in templates, and their replacements.
Definition: configuration_files_widget.h:145
moveit_setup_assistant::GenerateFile::write_on_changes
unsigned long write_on_changes
Definition: configuration_files_widget.h:65
moveit_setup_assistant::ConfigurationFilesWidget::changeActionDesc
void changeActionDesc(int id)
Display the selected action in the desc box.
Definition: configuration_files_widget.cpp:891
moveit_setup_assistant::LoadPathWidget
Definition: header_widget.h:65
moveit_setup_assistant::ConfigurationFilesWidget::stack_path_
LoadPathWidget * stack_path_
Definition: configuration_files_widget.h:93
moveit_setup_assistant::ConfigurationFilesWidget::exitSetupAssistant
void exitSetupAssistant()
Quit the program because we are done.
Definition: configuration_files_widget.cpp:1203
moveit_setup_assistant::ConfigurationFilesWidget::action_desc_
QList< QString > action_desc_
Definition: configuration_files_widget.h:98
moveit_setup_assistant::ConfigurationFilesWidget::checkDependencies
bool checkDependencies()
Verify with user if certain screens have not been completed.
Definition: configuration_files_widget.cpp:787


moveit_setup_assistant
Author(s): Dave Coleman
autogenerated on Sat May 3 2025 02:28:04