/usr/include/rviz/view_controller.h is in librviz-dev 1.12.4+dfsg-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | /*
* Copyright (c) 2012, Willow Garage, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef RVIZ_VIEW_CONTROLLER_H
#define RVIZ_VIEW_CONTROLLER_H
#include <string>
#include <QCursor>
#include "rviz/properties/property.h"
class QKeyEvent;
namespace Ogre
{
class Camera;
class SceneNode;
class Vector3;
class Quaternion;
}
namespace rviz
{
class DisplayContext;
class EnumProperty;
class RenderPanel;
class ViewportMouseEvent;
class FloatProperty;
class BoolProperty;
class ViewController: public Property
{
Q_OBJECT
public:
ViewController();
virtual ~ViewController();
/** @brief Do all setup that can't be done in the constructor.
*
* Creates camera_ and attaches it to the root scene node.
*
* Calls onInitialize() just before returning. */
void initialize( DisplayContext* context );
static QString formatClassId( const QString& class_id );
/** @brief Overridden from Property to give a different background
* color and bold font if this view is active. */
virtual QVariant getViewData( int column, int role ) const;
/** @brief Overridden from Property to make this draggable if it is not active. */
virtual Qt::ItemFlags getViewFlags( int column ) const;
/** @brief Called by RenderPanel when this view controller is about to be used.
*
* There is no deactivate() because ViewControllers leaving
* "current" are destroyed. Put any cleanup in the destructor. */
void activate();
/** @brief Called at 30Hz by ViewManager::update() while this view
* is active. Override with code that needs to run repeatedly. */
virtual void update(float dt, float ros_dt)
{
(void) dt;
(void) ros_dt;
}
virtual void handleMouseEvent(ViewportMouseEvent& evt)
{
(void) evt;
}
/** @brief Called by MoveTool and InteractionTool when keyboard events are passed to them.
*
* The default implementation here handles the "F" (focus on object)
* and "Z" (zero - reset) keys. */
virtual void handleKeyEvent( QKeyEvent* event, RenderPanel* panel );
/** @brief Convenience function which calls lookAt(Ogre::Vector3). */
void lookAt( float x, float y, float z );
/** @brief This should be implemented in each subclass to aim the
* camera at the given point in space (relative to the fixed
* frame). */
virtual void lookAt( const Ogre::Vector3& point )
{
(void) point;
}
/** Reset the view controller to some sane initial state, like
* looking at 0,0,0 from a few meters away. */
virtual void reset() = 0;
/** @brief Configure the settings of this view controller to give,
* as much as possible, a similar view as that given by the
* @a source_view.
*
* @a source_view must return a valid @c Ogre::Camera* from getCamera().
*
* This base class implementation does nothing. */
virtual void mimic( ViewController* source_view )
{
(void) source_view;
}
/** @brief Called by ViewManager when this ViewController is being made current.
* @param previous_view is the previous "current" view, and will not be NULL.
*
* This gives ViewController subclasses an opportunity to implement
* a smooth transition from a previous viewpoint to the new
* viewpoint.
*
* This base class implementation does nothing. */
virtual void transitionFrom( ViewController* previous_view )
{
(void) previous_view;
}
/** @brief Subclasses should call this whenever a change is made which would change the results of toString(). */
void emitConfigChanged();
Ogre::Camera* getCamera() const { return camera_; }
/** @brief Return the class identifier which was used to create this
* instance. This version just returns whatever was set with
* setClassId(). */
virtual QString getClassId() const { return class_id_; }
/** @brief Set the class identifier used to create this instance.
* Typically this will be set by the factory object which created it. */
virtual void setClassId( const QString& class_id ) { class_id_ = class_id; }
virtual void load( const Config& config );
virtual void save( Config config ) const;
bool isActive() const { return is_active_; }
/** @return A mouse cursor representing the current state */
virtual QCursor getCursor() { return cursor_; }
Q_SIGNALS:
void configChanged();
private Q_SLOTS:
void updateNearClipDistance();
void updateStereoProperties();
protected:
/** @brief Do subclass-specific initialization. Called by
* ViewController::initialize after context_ and camera_ are set.
* Default implementation does nothing. */
virtual void onInitialize() {}
/** @brief called by activate().
*
* Override to implement view-specific activation. This base
* implementation does nothing. */
virtual void onActivate() {}
// choose a cursor from the standard set
enum CursorType{ Default, Rotate2D, Rotate3D, MoveXY, MoveZ, Zoom, Crosshair };
void setCursor( CursorType cursor_type );
// set a custom cursor
void setCursor( QCursor cursor ) { cursor_=cursor; }
DisplayContext* context_;
Ogre::Camera* camera_;
bool is_active_;
// this cursor will be displayed when the mouse is within the
// window controlled by this view controller
// use SetCursor to modify.
QCursor cursor_;
FloatProperty* near_clip_property_;
BoolProperty* stereo_enable_;
BoolProperty* stereo_eye_swap_;
FloatProperty* stereo_eye_separation_;
FloatProperty* stereo_focal_distance_;
void setStatus( const QString & message );
private:
EnumProperty* type_property_;
QString class_id_;
// Default cursors for the most common actions
QMap<CursorType,QCursor> standard_cursors_;
};
} // end namespace rviz
#endif // RVIZ_VIEW_CONTROLLER_H
|