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 
00057 class ViewController: public Property
00058 {
00059 Q_OBJECT
00060 public:
00061   ViewController();
00062   virtual ~ViewController();
00063 
00069   void initialize( DisplayContext* context );
00070 
00071   static QString formatClassId( const QString& class_id );
00072 
00075   virtual QVariant getViewData( int column, int role ) const;
00076 
00078   virtual Qt::ItemFlags getViewFlags( int column ) const;
00079 
00084   void activate();
00085 
00088   virtual void update(float dt, float ros_dt) {}
00089 
00090   virtual void handleMouseEvent(ViewportMouseEvent& evt) {}
00091 
00096   virtual void handleKeyEvent( QKeyEvent* event, RenderPanel* panel );
00097 
00099   void lookAt( float x, float y, float z );
00100 
00104   virtual void lookAt( const Ogre::Vector3& point ) {}
00105 
00108   virtual void reset() = 0;
00109 
00117   virtual void mimic( ViewController* source_view ) {}
00118 
00127   virtual void transitionFrom( ViewController* previous_view ) {}
00128 
00130   void emitConfigChanged();
00131 
00132   Ogre::Camera* getCamera() const { return camera_; }
00133 
00137   virtual QString getClassId() const { return class_id_; }
00138 
00141   virtual void setClassId( const QString& class_id ) { class_id_ = class_id; }
00142 
00143   virtual void load( const Config& config );
00144   virtual void save( Config config ) const;
00145 
00146   bool isActive() const { return is_active_; }
00147 
00149   virtual QCursor getCursor() { return cursor_; }
00150 
00151 Q_SIGNALS:
00152   void configChanged();
00153 
00154 private Q_SLOTS:
00155 
00156   void updateNearClipDistance();
00157 
00158 protected:
00162   virtual void onInitialize() {}
00163 
00168   virtual void onActivate() {}
00169 
00170   // choose a cursor from the standard set
00171   enum CursorType{ Default, Rotate2D, Rotate3D, MoveXY, MoveZ, Zoom, Crosshair };
00172   void setCursor( CursorType cursor_type );
00173 
00174   // set a custom cursor
00175   void setCursor( QCursor cursor ) { cursor_=cursor; }
00176 
00177   DisplayContext* context_;
00178   Ogre::Camera* camera_;
00179 
00180   bool is_active_;
00181 
00182   // this cursor will be displayed when the mouse is within the
00183   // window controlled by this view controller
00184   // use SetCursor to modify.
00185   QCursor cursor_;
00186 
00187   FloatProperty* near_clip_property_;
00188 
00189   void setStatus( const QString & message );
00190 
00191 private:
00192 
00193   EnumProperty* type_property_;
00194   QString class_id_;
00195 
00196   // Default cursors for the most common actions
00197   QMap<CursorType,QCursor> standard_cursors_;
00198 };
00199 
00200 } // end namespace rviz
00201 
00202 #endif // RVIZ_VIEW_CONTROLLER_H


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Mon Oct 6 2014 07:26:36