view_controller.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2012, Willow Garage, Inc.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the Willow Garage, Inc. nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 #ifndef RVIZ_VIEW_CONTROLLER_H
00031 #define RVIZ_VIEW_CONTROLLER_H
00032 
00033 #include <string>
00034 
00035 #include <QCursor>
00036 
00037 #include "rviz/properties/property.h"
00038 
00039 class QKeyEvent;
00040 
00041 namespace Ogre
00042 {
00043 class Camera;
00044 class SceneNode;
00045 class Vector3;
00046 class Quaternion;
00047 }
00048 
00049 namespace rviz
00050 {
00051 class DisplayContext;
00052 class EnumProperty;
00053 class RenderPanel;
00054 class ViewportMouseEvent;
00055 class FloatProperty;
00056 class BoolProperty;
00057 
00058 class ViewController: public Property
00059 {
00060 Q_OBJECT
00061 public:
00062   ViewController();
00063   virtual ~ViewController();
00064 
00070   void initialize( DisplayContext* context );
00071 
00072   static QString formatClassId( const QString& class_id );
00073 
00076   virtual QVariant getViewData( int column, int role ) const;
00077 
00079   virtual Qt::ItemFlags getViewFlags( int column ) const;
00080 
00085   void activate();
00086 
00089   virtual void update(float dt, float ros_dt) {}
00090 
00091   virtual void handleMouseEvent(ViewportMouseEvent& evt) {}
00092 
00097   virtual void handleKeyEvent( QKeyEvent* event, RenderPanel* panel );
00098 
00100   void lookAt( float x, float y, float z );
00101 
00105   virtual void lookAt( const Ogre::Vector3& point ) {}
00106 
00109   virtual void reset() = 0;
00110 
00118   virtual void mimic( ViewController* source_view ) {}
00119 
00128   virtual void transitionFrom( ViewController* previous_view ) {}
00129 
00131   void emitConfigChanged();
00132 
00133   Ogre::Camera* getCamera() const { return camera_; }
00134 
00138   virtual QString getClassId() const { return class_id_; }
00139 
00142   virtual void setClassId( const QString& class_id ) { class_id_ = class_id; }
00143 
00144   virtual void load( const Config& config );
00145   virtual void save( Config config ) const;
00146 
00147   bool isActive() const { return is_active_; }
00148 
00150   virtual QCursor getCursor() { return cursor_; }
00151 
00152 Q_SIGNALS:
00153   void configChanged();
00154 
00155 private Q_SLOTS:
00156 
00157   void updateNearClipDistance();
00158   void updateStereoProperties();
00159 
00160 protected:
00164   virtual void onInitialize() {}
00165 
00170   virtual void onActivate() {}
00171 
00172   // choose a cursor from the standard set
00173   enum CursorType{ Default, Rotate2D, Rotate3D, MoveXY, MoveZ, Zoom, Crosshair };
00174   void setCursor( CursorType cursor_type );
00175 
00176   // set a custom cursor
00177   void setCursor( QCursor cursor ) { cursor_=cursor; }
00178 
00179   DisplayContext* context_;
00180   Ogre::Camera* camera_;
00181 
00182   bool is_active_;
00183 
00184   // this cursor will be displayed when the mouse is within the
00185   // window controlled by this view controller
00186   // use SetCursor to modify.
00187   QCursor cursor_;
00188 
00189   FloatProperty* near_clip_property_;
00190   BoolProperty* stereo_enable_;
00191   BoolProperty* stereo_eye_swap_;
00192   FloatProperty* stereo_eye_separation_;
00193   FloatProperty* stereo_focal_distance_;
00194 
00195   void setStatus( const QString & message );
00196 
00197 private:
00198 
00199   EnumProperty* type_property_;
00200   QString class_id_;
00201 
00202   // Default cursors for the most common actions
00203   QMap<CursorType,QCursor> standard_cursors_;
00204 };
00205 
00206 } // end namespace rviz
00207 
00208 #endif // RVIZ_VIEW_CONTROLLER_H


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Thu Jun 6 2019 18:02:16