diff --git a/rviz_common/CMakeLists.txt b/rviz_common/CMakeLists.txt index 9e5c5e385..e014953d2 100644 --- a/rviz_common/CMakeLists.txt +++ b/rviz_common/CMakeLists.txt @@ -63,11 +63,10 @@ configure_file(src/rviz_common/env_config.cpp.in ${ENV_CONFIG_CPP} @ONLY) set(rviz_common_headers_to_moc ${ENV_CONFIG_HPP} src/rviz_common/add_display_dialog.hpp - # src/rviz_common/help_panel.hpp + src/rviz_common/help_panel.hpp include/rviz_common/properties/enum_property.hpp include/rviz_common/properties/property_tree_widget.hpp include/rviz_common/properties/splitter_handle.hpp - # src/rviz_common/selection_panel.hpp include/rviz_common/display_group.hpp include/rviz_common/frame_position_tracking_view_controller.hpp include/rviz_common/properties/quaternion_property.hpp @@ -142,7 +141,7 @@ set(rviz_common_source_files src/rviz_common/failed_view_controller.cpp src/rviz_common/frame_manager.cpp src/rviz_common/frame_position_tracking_view_controller.cpp - # src/rviz_common/help_panel.cpp + src/rviz_common/help_panel.cpp src/rviz_common/load_resource.cpp src/rviz_common/loading_dialog.cpp src/rviz_common/logging.cpp @@ -288,6 +287,16 @@ install( DESTINATION "share/${PROJECT_NAME}" ) +install( + DIRECTORY "${CMAKE_SOURCE_DIR}/images" + DESTINATION "share/${PROJECT_NAME}" +) + +install( + DIRECTORY "${CMAKE_SOURCE_DIR}/help" + DESTINATION "share/${PROJECT_NAME}" +) + if(BUILD_TESTING) # TODO(wjwwood): replace this with ament_lint_auto() and/or add the copyright linter back find_package(ament_cmake_cppcheck REQUIRED) diff --git a/rviz_common/default.rviz b/rviz_common/default.rviz index a3574808a..1a80c1229 100644 --- a/rviz_common/default.rviz +++ b/rviz_common/default.rviz @@ -15,7 +15,7 @@ Panels: Expanded: # - /2D Pose Estimate1 # - /2D Nav Goal1 - # - /Publish Point1 + - /Publish Point1 Name: Tool Properties Splitter Ratio: 0.588679 - Class: rviz_common/Views @@ -60,14 +60,14 @@ Visualization Manager: - Class: rviz_default_plugins/MoveCamera - Class: rviz_default_plugins/Select # - Class: rviz/FocusCamera - # - Class: rviz/Measure + - Class: rviz_default_plugins/Measure # - Class: rviz/SetInitialPose # Topic: /initialpose # - Class: rviz/SetGoal # Topic: /move_base_simple/goal - # - Class: rviz/PublishPoint - # Single click: true - # Topic: /clicked_point + - Class: rviz_default_plugins/PublishPoint + Single click: true + Topic: /clicked_point Value: true Views: Current: diff --git a/rviz/help/help.html b/rviz_common/help/help.html similarity index 50% rename from rviz/help/help.html rename to rviz_common/help/help.html index 73cf9f0f3..6034bd24b 100644 --- a/rviz/help/help.html +++ b/rviz_common/help/help.html @@ -20,28 +20,28 @@

Key controls

Switching between tools

-These controls work in all modes. +These controls work in all modes, except for tools capturing all keys (Select tool). - - - - + + + + - - - - - - - - + + + + + + + +
M Switch to the Move-Camera tool.
ISwitch to the Interact tool.
S Switch to the Select tool.
GSwitch to the 2D Nav Goal tool.
PSwitch to the 2D Pose Estimate tool.

@@ -73,7 +73,7 @@

Modifying Displays list

- + @@ -138,81 +138,81 @@

Orbit view controller

Ctrl-ACtrl-N Add a display

-

XYOrbit view controller

-

- - Similar to the Orbit view controller, but the focal point is kept - on the Z=0 (ground) plane. - - - - - - - - - - - - - - - - - - -
LeftDrag to rotate around the focal point.
Middle
or
Shift-Left
Drag to move the focal point in the ground plane.
Scroll WheelRoll up or down to zoom towards or away from the focal point.
RightDrag up or down to zoom towards or away from the focal point.
-

+ + + + + + + + + + + + + + + + + + + + + + + + + -

FPS view controller

-

- - Inspired by first-person shooter games. Drag to point your head. - - - - - - - - - - - - - - - - - - -
LeftDragging rotates the viewpoint in the direction of the drag.
Middle
or
Shift-Left
Drag to strafe (translate) left/right and up/down.
Scroll WheelRoll up or down to move the viewpoint forwards or back.
RightDrag up or down to move the viewport forwards or back.
-

+ + + + + + + + + + + + + + + + + + + + + + + + -

TopDownOrtho view controller

-

- - Top-down orthographic view. - - - - - - - - - - - - - - - - - - -
LeftDragging left/right rotates the view.
Middle
or
Shift-Left
Drag to move the viewpoint in the XY plane.
Scroll WheelRoll up or down to zoom in or out.
RightDrag up or down to zoom in or out.
-

+ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/rviz_default_plugins/icons/classes/Help.svg b/rviz_common/icons/classes/Help.svg similarity index 100% rename from rviz_default_plugins/icons/classes/Help.svg rename to rviz_common/icons/classes/Help.svg diff --git a/rviz/images/splash.png b/rviz_common/images/splash.png similarity index 100% rename from rviz/images/splash.png rename to rviz_common/images/splash.png diff --git a/rviz/images/splash_overlay.png b/rviz_common/images/splash_overlay.png similarity index 100% rename from rviz/images/splash_overlay.png rename to rviz_common/images/splash_overlay.png diff --git a/rviz_common/include/rviz_common/display_context.hpp b/rviz_common/include/rviz_common/display_context.hpp index 3fda3a87b..b475f9101 100644 --- a/rviz_common/include/rviz_common/display_context.hpp +++ b/rviz_common/include/rviz_common/display_context.hpp @@ -201,6 +201,10 @@ class RVIZ_COMMON_PUBLIC DisplayContext : public QObject void setStatus(const QString & message) = 0; + virtual + QString + getHelpPath() const = 0; + virtual std::shared_ptr getClock() = 0; diff --git a/rviz_common/src/rviz_common/help_panel.cpp b/rviz_common/src/rviz_common/help_panel.cpp index 224832f5b..f52d0723d 100644 --- a/rviz_common/src/rviz_common/help_panel.cpp +++ b/rviz_common/src/rviz_common/help_panel.cpp @@ -27,48 +27,42 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "rviz_common/help_panel.hpp" +#include "./help_panel.hpp" #include -#include // NOLINT: cpplint is unable to handle the include order here +#include // NOLINT: cpplint is unable to handle the include order here #include // NOLINT: cpplint is unable to handle the include order here -#include // NOLINT: cpplint is unable to handle the include order here - -#include // NOLINT: cpplint is unable to handle the include order here - -#include "rviz_common/visualization_manager.hpp" +#include // NOLINT: cpplint is unable to handle the include order here -namespace fs = boost::filesystem; +#include "rviz_common/display_context.hpp" -namespace rviz +namespace rviz_common { HelpPanel::HelpPanel(QWidget * parent) : Panel(parent), - browser_(NULL) + browser_(nullptr) { - QVBoxLayout * layout = new QVBoxLayout(this); + const auto layout = new QVBoxLayout(this); browser_ = new QTextBrowser(); layout->addWidget(browser_); } -HelpPanel::~HelpPanel() -{ -} +HelpPanel::~HelpPanel() = default; void HelpPanel::onInitialize() { - setHelpFile(vis_manager_->getHelpPath() ); + setHelpFile(getDisplayContext()->getHelpPath()); } void HelpPanel::setHelpFile(const QString & qfile_path) { - std::string file_path = qfile_path.toStdString(); + QFileInfo path_info(qfile_path); - if (!fs::exists(file_path)) { + if (!path_info.exists()) { browser_->setText("Help file '" + qfile_path + "' does not exist."); - } else if (fs::is_directory(file_path)) { + } else if (path_info.isDir()) { browser_->setText("Help file '" + qfile_path + "' is a directory, not a file."); } else { QUrl url = QUrl::fromLocalFile(qfile_path); @@ -80,4 +74,4 @@ void HelpPanel::setHelpFile(const QString & qfile_path) } } -} // end namespace rviz +} // namespace rviz_common diff --git a/rviz_common/src/rviz_common/help_panel.hpp b/rviz_common/src/rviz_common/help_panel.hpp index 3f2d70881..d3f0c7009 100644 --- a/rviz_common/src/rviz_common/help_panel.hpp +++ b/rviz_common/src/rviz_common/help_panel.hpp @@ -35,7 +35,7 @@ class QTextBrowser; -namespace rviz +namespace rviz_common { class HelpPanel : public Panel @@ -44,9 +44,9 @@ class HelpPanel : public Panel public: explicit HelpPanel(QWidget * parent = 0); - virtual ~HelpPanel(); + ~HelpPanel() override; - virtual void onInitialize(); + void onInitialize() override; /** @brief Load the given html file. */ void setHelpFile(const QString & file_path); @@ -55,6 +55,6 @@ class HelpPanel : public Panel QTextBrowser * browser_; }; -} // end namespace rviz +} // namespace rviz_common #endif // RVIZ_COMMON__HELP_PANEL_HPP_ diff --git a/rviz_common/src/rviz_common/panel_factory.cpp b/rviz_common/src/rviz_common/panel_factory.cpp index f31e8a8f5..508d120f5 100644 --- a/rviz_common/src/rviz_common/panel_factory.cpp +++ b/rviz_common/src/rviz_common/panel_factory.cpp @@ -35,7 +35,7 @@ // TODO(wjwwood): reenable the remaining panels #include "./displays_panel.hpp" -// #include "./help_panel.hpp" +#include "./help_panel.hpp" #include "./selection_panel.hpp" // #include "./time_panel.hpp" #include "./tool_properties_panel.hpp" @@ -46,7 +46,7 @@ namespace rviz_common { -// static Panel * newHelpPanel() {return new HelpPanel();} +static Panel * newHelpPanel() {return new HelpPanel();} static Panel * newSelectionPanel() {return new SelectionPanel();} // static Panel * newTimePanel() {return new TimePanel();} static Panel * newToolPropertiesPanel() {return new ToolPropertiesPanel();} @@ -62,8 +62,8 @@ PanelFactory::PanelFactory( [rviz_ros_node, manager]() -> Panel * { return new DisplaysPanel(rviz_ros_node, manager, nullptr); }); - // addBuiltInClass("rviz_common", "Help", - // "Show the key and mouse bindings", &newHelpPanel); + addBuiltInClass("rviz_common", "Help", + "Show the key and mouse bindings", &newHelpPanel); addBuiltInClass("rviz_common", "Selection", "Show properties of selected objects", &newSelectionPanel); // addBuiltInClass("rviz", "Time", diff --git a/rviz_common/src/rviz_common/selection_panel.hpp b/rviz_common/src/rviz_common/selection_panel.hpp index 283b10624..07ca55b43 100644 --- a/rviz_common/src/rviz_common/selection_panel.hpp +++ b/rviz_common/src/rviz_common/selection_panel.hpp @@ -41,8 +41,6 @@ class PropertyTreeWidget; class SelectionPanel : public Panel { - Q_OBJECT - public: explicit SelectionPanel(QWidget * parent = nullptr); diff --git a/rviz_common/src/rviz_common/visualization_frame.cpp b/rviz_common/src/rviz_common/visualization_frame.cpp index 68544da28..8c09cafc3 100644 --- a/rviz_common/src/rviz_common/visualization_frame.cpp +++ b/rviz_common/src/rviz_common/visualization_frame.cpp @@ -85,7 +85,7 @@ #include "./yaml_config_writer.hpp" // #include "./displays_panel.hpp" -// #include "./help_panel.hpp" +#include "./help_panel.hpp" // #include "./interaction/selection_manager.hpp" // #include "./selection_panel.hpp" // #include "./time_panel.hpp" @@ -112,6 +112,7 @@ VisualizationFrame::VisualizationFrame( splash_(nullptr), toolbar_actions_(nullptr), show_choose_new_master_option_(false), + panel_factory_(nullptr), add_tool_action_(nullptr), remove_tool_menu_(nullptr), initialized_(false), @@ -131,7 +132,7 @@ VisualizationFrame::VisualizationFrame( package_path_ = ament_index_cpp::get_package_share_directory("rviz_common"); QDir help_path(QString::fromStdString(package_path_) + "/help/help.html"); help_path_ = help_path.absolutePath(); - QDir splash_path(QString::fromStdString(package_path_) + "images/splash.png"); + QDir splash_path(QString::fromStdString(package_path_) + "/images/splash.png"); splash_path_ = splash_path.absolutePath(); auto * reset_button = new QToolButton(); @@ -365,7 +366,7 @@ void VisualizationFrame::initialize( if (app_) {app_->processEvents();} delete splash_; - splash_ = 0; + splash_ = nullptr; manager_->startUpdate(); initialized_ = true; @@ -700,7 +701,7 @@ void VisualizationFrame::loadDisplayConfig(const QString & qpath) setWindowModified(false); loading_ = true; - LoadingDialog * dialog = NULL; + LoadingDialog * dialog = nullptr; if (initialized_) { dialog = new LoadingDialog(this); dialog->show(); @@ -1123,25 +1124,17 @@ void VisualizationFrame::indicateToolIsCurrent(Tool * tool) void VisualizationFrame::showHelpPanel() { if (!show_help_action_) { - // TODO(wjwwood): reenable this when plugin loading is fixed. -#if 0 - QDockWidget * dock = addPanelByName("Help", "rviz/Help"); + QDockWidget * dock = addPanelByName("Help", "rviz_common/Help"); show_help_action_ = dock->toggleViewAction(); connect(dock, SIGNAL(destroyed(QObject *)), this, SLOT(onHelpDestroyed())); -#endif } else { - // TODO(wjwwood): figure out if this is needed - // show_help_action_ is a toggle action, so trigger() changes its - // state. Therefore we must force it to the opposite state from - // what we want before we call trigger(). (I think.) - show_help_action_->setChecked(false); show_help_action_->trigger(); } } void VisualizationFrame::onHelpDestroyed() { - show_help_action_ = NULL; + show_help_action_ = nullptr; } void VisualizationFrame::onHelpWiki() diff --git a/rviz_common/src/rviz_common/visualization_manager.hpp b/rviz_common/src/rviz_common/visualization_manager.hpp index 14eed28ac..7a0716484 100644 --- a/rviz_common/src/rviz_common/visualization_manager.hpp +++ b/rviz_common/src/rviz_common/visualization_manager.hpp @@ -298,7 +298,7 @@ class VisualizationManager : public DisplayContext virtual void setHelpPath(const QString & help_path); - virtual QString getHelpPath() const; + QString getHelpPath() const override; rclcpp::Clock::SharedPtr getClock() override; diff --git a/rviz_common/src/rviz_common/visualizer_app.cpp b/rviz_common/src/rviz_common/visualizer_app.cpp index b375d27e4..532132f02 100644 --- a/rviz_common/src/rviz_common/visualizer_app.cpp +++ b/rviz_common/src/rviz_common/visualizer_app.cpp @@ -171,13 +171,12 @@ bool VisualizerApp::init(int argc, char ** argv) "Enable the Ogre.log file (output in cwd) and console output."); parser.addOption(ogre_log_option); - // TODO(botteroa-si): enable when possible -// QCommandLineOption splash_screen_option( -// QStringList() << "s" << "splash-screen", -// "A custom splash-screen image to display", -// "splash_path"); -// parser.addOption(splash_screen_option); -// + QCommandLineOption splash_screen_option( + QStringList() << "s" << "splash-screen", + "A custom splash-screen image to display", "splash_path"); + parser.addOption(splash_screen_option); + +// TODO(botteroa-si): enable when possible // QCommandLineOption help_file_option( // "help-file", "A custom html file to show as the help screen", "help_path"); // parser.addOption(help_file_option); @@ -222,16 +221,13 @@ bool VisualizerApp::init(int argc, char ** argv) fixed_frame = parser.value(fixed_frame_option); } - // TODO(botteroa-si): enable when possible -// if (parser.isSet(splash_screen_option)) { -// splash_path = parser.value(splash_screen_option); -// } + if (parser.isSet(splash_screen_option)) { + splash_path = parser.value(splash_screen_option); + } +// TODO(botteroa-si): enable when possible // if (parser.isSet(help_file_option)) { // help_path = parser.value(help_file_option); // } -// if (parser.isSet(splash_screen_option)) { -// splash_path = parser.value(splash_screen_option); -// } // if (parser.isSet(open_gl_option)) { // force_gl_version = parser.value(open_gl_option).toInt(); // } diff --git a/rviz_common/test/mock_display_context.hpp b/rviz_common/test/mock_display_context.hpp index 0c4068677..9864b1dfc 100644 --- a/rviz_common/test/mock_display_context.hpp +++ b/rviz_common/test/mock_display_context.hpp @@ -81,6 +81,7 @@ class MockDisplayContext : public rviz_common::DisplayContext MOCK_METHOD0(lockRender, void()); MOCK_METHOD0(unlockRender, void()); MOCK_CONST_METHOD0(getRenderPanel, rviz_common::RenderPanel * ()); + MOCK_CONST_METHOD0(getHelpPath, QString()); }; #endif // MOCK_DISPLAY_CONTEXT_HPP_ diff --git a/rviz_default_plugins/test/rviz_default_plugins/mock_display_context.hpp b/rviz_default_plugins/test/rviz_default_plugins/mock_display_context.hpp index d0055bd79..4b34ad8bb 100644 --- a/rviz_default_plugins/test/rviz_default_plugins/mock_display_context.hpp +++ b/rviz_default_plugins/test/rviz_default_plugins/mock_display_context.hpp @@ -77,6 +77,7 @@ class MockDisplayContext : public rviz_common::DisplayContext MOCK_METHOD0(lockRender, void()); MOCK_METHOD0(unlockRender, void()); + MOCK_CONST_METHOD0(getHelpPath, QString()); }; #endif // RVIZ_DEFAULT_PLUGINS__MOCK_DISPLAY_CONTEXT_HPP_