Skip to content

Commit

Permalink
rviz: added help panel with basic key bindings and mouse controls.
Browse files Browse the repository at this point in the history
  • Loading branch information
hershwg committed Feb 17, 2012
1 parent 64324ec commit 43a1148
Show file tree
Hide file tree
Showing 6 changed files with 289 additions and 8 deletions.
218 changes: 218 additions & 0 deletions help/help.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
<!--
Please note: This HTML file is displayed by a QTextBrowser widget
in rviz. QTextBrowser supports only a SUBSET of HTML.
See http://developer.qt.nokia.com/doc/qt-4.8/richtext-html-subset.html
for the details.
-->
<html>
<head>
<style type="text/css">
.odd { background-color: #e0e0e0 }
.even { background-color: #f0f0f0 }
.key { font-weight: bold; color: #04597f }
p { margin-left: 10px }
</style>
</head>
<body>

<h2>Key controls</h2>

<h3>Switching between tools</h3>
<p>
<em>These controls work in all modes.</em>
<table border="0" cellspacing="0" cellpadding="3">
<tr class="odd">
<td class="key">M</td>
<td>Switch to the Move-Camera tool.</td>
</tr>
<tr class="even">
<td class="key">I</td>
<td>Switch to the Interact tool.</td>
</tr>
<tr class="odd">
<td class="key">S</td>
<td>Switch to the Select tool.</td>
</tr>
<tr class="even">
<td class="key">G</td>
<td>Switch to the 2D Nav Goal tool.</td>
</tr>
<tr class="odd">
<td class="key">P</td>
<td>Switch to the 2D Pose Estimate tool.</td>
</tr>
</table>
</p>

<h3>Controlling the viewpoint</h3>
<p>
<em>These controls only work while using the <b>Move Camera</b> and <b>Interact</b> tools.</em>
<table border="0" cellspacing="0" cellpadding="3">
<tr class="odd">
<td class="key">F</td>
<td>Move the focus to the 3D point under the mouse. This does not work for all display objects or all computers (yet).</td>
</tr>
<tr class="even">
<td class="key">Z</td>
<td>Jump back to looking at the origin, the default view position.</td>
</tr>
</table>
</p>
<p>
<em>This control only works while using the <b>Select</b> tool.</em>
<table border="0" cellspacing="0" cellpadding="3">
<tr class="odd">
<td class="key">F</td>
<td>Move the focus to the centroid of the currently-selected objects.</td>
</tr>
</table>
</p>

<h3>Modifying Displays list</h3>
<p>
<table border="0" cellspacing="0" cellpadding="3">
<tr class="odd">
<td class="key">Ctrl-A</td>
<td>Add a display</td>
</tr>
<tr class="even">
<td class="key">Ctrl-X</td>
<td>Remove a display</td>
</tr>
<tr class="odd">
<td class="key">Ctrl-R</td>
<td>Rename a display</td>
</tr>
</table>
</p>

<h3>File operations</h3>
<p>
<table border="0" cellspacing="0" cellpadding="3">
<tr class="odd">
<td class="key">Ctrl-O</td>
<td>Open a config file</td>
</tr>
<tr class="even">
<td class="key">Ctrl-S</td>
<td>Save to a config file (opens file chooser)</td>
</tr>
<tr class="odd">
<td class="key">Ctrl-Q</td>
<td>Quit RViz, saving current config into ~/.rviz/display_config first.</td>
</tr>
</table>
</p>

<h2>Mouse controls</h2>

<h3>Orbit view controller</h3>
<p>
<em>
In this view, the viewpoint is always aimed at a focal point. You
can move around the point (orbit it) or you can move the point
itself.
</em>
<table border="0" cellspacing="0" cellpadding="3">
<tr class="odd">
<td class="key">Left</td>
<td>Drag to rotate around the focal point.</td>
</tr>
<tr class="even">
<td><div class="key">Middle</div> or<div class="key">Shift-Left</div></td>
<td>Drag to move the focal point.</td>
</tr>
<tr class="odd">
<td class="key">Scroll Wheel</td>
<td>Roll up or down to zoom towards or away from the focal point.</td>
</tr>
<tr class="even">
<td class="key">Right</td>
<td>Drag up or down to zoom towards or away from the focal point.</td>
</tr>
<tr class="odd">
<td class="key">Shift-Right</td>
<td>Drag up or down to move the focal point forward or backward.</td>
</tr>
</table>
</p>

<h3>XYOrbit view controller</h3>
<p>
<em>
Similar to the Orbit view controller, but the focal point is kept
on the Z=0 (ground) plane.
</em>
<table border="0" cellspacing="0" cellpadding="3">
<tr class="odd">
<td class="key">Left</td>
<td>Drag to rotate around the focal point.</td>
</tr>
<tr class="even">
<td><div class="key">Middle</div> or<div class="key">Shift-Left</div></td>
<td>Drag to move the focal point in the ground plane.</td>
</tr>
<tr class="odd">
<td class="key">Scroll Wheel</td>
<td>Roll up or down to zoom towards or away from the focal point.</td>
</tr>
<tr class="even">
<td class="key">Right</td>
<td>Drag up or down to zoom towards or away from the focal point.</td>
</tr>
</table>
</p>

<h3>FPS view controller</h3>
<p>
<em>
Inspired by first-person shooter games. Drag to point your head.
</em>
<table border="0" cellspacing="0" cellpadding="3">
<tr class="odd">
<td class="key">Left</td>
<td>Dragging rotates the viewpoint in the direction of the drag.</td>
</tr>
<tr class="even">
<td><div class="key">Middle</div> or<div class="key">Shift-Left</div></td>
<td>Drag to strafe (translate) left/right and up/down.</td>
</tr>
<tr class="odd">
<td class="key">Scroll Wheel</td>
<td>Roll up or down to move the viewpoint forwards or back.</td>
</tr>
<tr class="even">
<td class="key">Right</td>
<td>Drag up or down to move the viewport forwards or back.</td>
</tr>
</table>
</p>

<h3>TopDownOrtho view controller</h3>
<p>
<em>
Top-down orthographic view.
</em>
<table border="0" cellspacing="0" cellpadding="3">
<tr class="odd">
<td class="key">Left</td>
<td>Dragging left/right rotates the view.</td>
</tr>
<tr class="even">
<td><div class="key">Middle</div> or<div class="key">Shift-Left</div></td>
<td>Drag to move the viewpoint in the XY plane.</td>
</tr>
<tr class="odd">
<td class="key">Scroll Wheel</td>
<td>Roll up or down to zoom in or out.</td>
</tr>
<tr class="even">
<td class="key">Right</td>
<td>Drag up or down to zoom in or out.</td>
</tr>
</table>
</p>

</body>
</html>
39 changes: 35 additions & 4 deletions src/rviz/help_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,52 @@
#include <QTextBrowser>
#include <QUrl>

#include <boost/filesystem.hpp>

#include "rviz/help_panel.h"

namespace fs = boost::filesystem;

namespace rviz
{

HelpPanel::HelpPanel( const std::string& file_path, QWidget* parent )
HelpPanel::HelpPanel( QWidget* parent )
: QWidget( parent )
, browser_( NULL )
{
QVBoxLayout* layout = new QVBoxLayout( this );
QTextBrowser* browser = new QTextBrowser();
layout->addWidget( browser );
browser->setSource( QUrl::fromLocalFile( QString::fromStdString( file_path )));
browser_ = new QTextBrowser();
layout->addWidget( browser_ );
}

HelpPanel::~HelpPanel()
{
}

void HelpPanel::setHelpFile( const std::string& file_path )
{
QString qfile_path = QString::fromStdString( file_path );

if( !fs::exists( file_path ))
{
browser_->setText( "Help file '" + qfile_path + "' does not exist." );
}
else if( fs::is_directory( file_path ))
{
browser_->setText( "Help file '" + qfile_path + "' is a directory, not a file." );
}
else
{
QUrl url = QUrl::fromLocalFile( qfile_path );
if( browser_->source() == url )
{
browser_->reload();
}
else
{
browser_->setSource( url );
}
}
}

} // end namespace rviz
10 changes: 9 additions & 1 deletion src/rviz/help_panel.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,23 @@

#include <QWidget>

class QTextBrowser;

namespace rviz
{

class HelpPanel: public QWidget
{
Q_OBJECT
public:
HelpPanel( const std::string& file_path, QWidget* parent = 0 );
HelpPanel( QWidget* parent = 0 );
virtual ~HelpPanel();

/** @brief Load the given html file. */
void setHelpFile( const std::string& file_path );

private:
QTextBrowser* browser_;
};

} // end namespace rviz
Expand Down
16 changes: 13 additions & 3 deletions src/rviz/visualization_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ VisualizationFrame::VisualizationFrame( QWidget* parent )
, time_panel_(NULL)
, selection_panel_(NULL)
, tool_properties_panel_(NULL)
, help_panel_(NULL)
, show_help_action_(NULL)
, file_menu_(NULL)
, recent_configs_menu_(NULL)
Expand Down Expand Up @@ -352,7 +353,7 @@ void VisualizationFrame::initMenus()

QMenu* help_menu = menuBar()->addMenu( "&Help" );
help_menu->addAction( "Show &Help panel", this, SLOT( showHelpPanel() ));
help_menu->addAction( "Wiki", this, SLOT( onHelpWiki() ));
help_menu->addAction( "Open rviz wiki in browser", this, SLOT( onHelpWiki() ));
}

void VisualizationFrame::openNewPanelDialog()
Expand Down Expand Up @@ -691,10 +692,19 @@ void VisualizationFrame::showHelpPanel()
{
if( !show_help_action_ )
{
QDockWidget* dock = addPane( "Help", new HelpPanel( help_path_, this ));
help_panel_ = new HelpPanel( this );
QDockWidget* dock = addPane( "Help", help_panel_ );
show_help_action_ = dock->toggleViewAction();
}
show_help_action_->setChecked( true );
else
{
// 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();
}
help_panel_->setHelpFile( help_path_ );
}

void VisualizationFrame::onHelpWiki()
Expand Down
2 changes: 2 additions & 0 deletions src/rviz/visualization_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class SelectionPanel;
class ToolPropertiesPanel;
class VisualizationManager;
class Tool;
class HelpPanel;

/** @brief The main rviz window.
*
Expand Down Expand Up @@ -179,6 +180,7 @@ protected Q_SLOTS:
SelectionPanel* selection_panel_;
ToolPropertiesPanel* tool_properties_panel_;

HelpPanel* help_panel_;
QAction* show_help_action_;

boost::shared_ptr<Config> general_config_;
Expand Down
12 changes: 12 additions & 0 deletions src/test/other-help.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!--
Please note: This HTML file is displayed by a QTextBrowser widget
in rviz. QTextBrowser supports only a SUBSET of HTML.
See http://developer.qt.nokia.com/doc/qt-4.8/richtext-html-subset.html
for the details.
-->
<html>
<body>
<h3>Custom help file</h3>
</body>
</html>

0 comments on commit 43a1148

Please sign in to comment.