PluginFunctionsViewControls.hh 11.5 KB
Newer Older
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
/*===========================================================================*\
 *                                                                           *
 *                              OpenFlipper                                  *
 *      Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen      *
 *                           www.openflipper.org                             *
 *                                                                           *
 *---------------------------------------------------------------------------*
 *  This file is part of OpenFlipper.                                        *
 *                                                                           *
 *  OpenFlipper is free software: you can redistribute it and/or modify      *
 *  it under the terms of the GNU Lesser General Public License as           *
 *  published by the Free Software Foundation, either version 3 of           *
 *  the License, or (at your option) any later version with the              *
 *  following exceptions:                                                    *
 *                                                                           *
 *  If other files instantiate templates or use macros                       *
 *  or inline functions from this file, or you compile this file and         *
 *  link it with other files to produce an executable, this file does        *
 *  not by itself cause the resulting executable to be covered by the        *
 *  GNU Lesser General Public License. This exception does not however       *
 *  invalidate any other reasons why the executable file might be            *
 *  covered by the GNU Lesser General Public License.                        *
 *                                                                           *
 *  OpenFlipper is distributed in the hope that it will be useful,           *
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
 *  GNU Lesser General Public License for more details.                      *
 *                                                                           *
 *  You should have received a copy of the GNU LesserGeneral Public          *
 *  License along with OpenFlipper. If not,                                  *
 *  see <http://www.gnu.org/licenses/>.                                      *
 *                                                                           *
\*===========================================================================*/

/*===========================================================================*\
 *                                                                           *
 *   $Revision$                                                         *
 *   $Author$                                                      *
 *   $Date$                   *
 *                                                                           *
\*===========================================================================*/
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




//=============================================================================
//
//  Standard Functions
//
//=============================================================================

/**
 * \file PluginFunctions.hh
 * This file contains functions which can be used by plugins to access data in the framework.
 */

//
#ifndef PLUGINFUNCTIONS_VIEWCONTROL_HH
#define PLUGINFUNCTIONS_VIEWCONTROL_HH

#include <OpenFlipper/common/Types.hh>

#include <ACG/Scenegraph/SceneGraph.hh>
#include <ACG/GL/GLState.hh>
#include <OpenFlipper/common/ViewerProperties.hh>

/** The Namespace PluginFunctions contains functions for all plugins. These functions should be used to get the
 *  objects to work on or to set modes in the examiner widget. */
namespace PluginFunctions {

const int ALL_VIEWERS   = -2;
const int ACTIVE_VIEWER = -1;

74 75 76 77 78 79 80 81
const int VIEW_FREE   = 0;
const int VIEW_TOP    = 1;
const int VIEW_BOTTOM = 2;
const int VIEW_LEFT   = 3;
const int VIEW_RIGHT  = 4;
const int VIEW_FRONT  = 5;
const int VIEW_BACK   = 6;

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
//=======================================
// Get/set status of viewers
    /** @name Viewer Status and properties
    * @{ */
//=======================================

/** Get the viewer properties
 * -1 will get the properties of the active Viewer which is the default
 */
DLLEXPORT
Viewer::ViewerProperties& viewerProperties(int _id = -1);



/** @} */


//=======================================
// View settings
    /** @name View settings
    * @{ */
//=======================================

/** Lock scene rotation via mouse
 *
 * @param _mode allow or disallow rotation
108 109 110 111
 * @param _viewer Id of the viewer to use.
 *                ALL_VIEWERS    will set all viewers (Default)
 *                ACTIVE_VIEWER active viewer
 *                0..3 Choose viewer explicitly
112 113
 */
DLLEXPORT
114 115 116 117 118 119 120 121 122 123 124
void allowRotation(bool _mode, int _viewer = ACTIVE_VIEWER);

/** is scene rotation locked
 *
 * @param _viewer Id of the viewer to use.
 *                ALL_VIEWERS    will set all viewers (Default)
 *                ACTIVE_VIEWER active viewer
 *                0..3 Choose viewer explicitly
 */
DLLEXPORT
bool allowRotation(int _viewer = ACTIVE_VIEWER);
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140

/** \brief Set current GL Context to main context
 */
DLLEXPORT
void setMainGLContext();


/** \brief Set the viewing direction
 * @param _dir direction
 * @param _up up vector
 * @param _viewer Id of the viewer to use.
 *                ALL_VIEWERS    will set all viewers (Default)
 *                ACTIVE_VIEWER active viewer
 *                0..3 Choose viewer explicitly
 */
DLLEXPORT
Ellen Dekkers's avatar
 
Ellen Dekkers committed
141
void viewingDirection(const ACG::Vec3d &_dir, const ACG::Vec3d &_up  , int _viewer = ACTIVE_VIEWER);
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

/** \brief Set the Scene position
 * @param _center Center of the current scene
 * @param _radius Radius of the scene ( Use scene_radius to get the current radius )
 * @param _viewer Id of the viewer to use.
 *                ALL_VIEWERS    will set all viewers (Default)
 *                ACTIVE_VIEWER active viewer
 *                0..3 Choose viewer explicitly
 */
DLLEXPORT
void setScenePos(const ACG::Vec3d& _center, const double _radius  , int _viewer = ALL_VIEWERS);

/** \brief Set the scene position
 *
 * Same as  setScenePos(const ACG::Vec3d& _center, double _radius) but reuses the current radius
 *
 * @param _viewer Id of the viewer to use.
 *                ALL_VIEWERS    will set all viewers (Default)
 *                ACTIVE_VIEWER active viewer
 *                0..3 Choose viewer explicitly
 */
DLLEXPORT
void setScenePos(const ACG::Vec3d& _center  , int _viewer = ALL_VIEWERS);

/** \brief Get the current scene center
 *
 */
DLLEXPORT
Jan Möbius's avatar
Jan Möbius committed
170
const ACG::Vec3d& sceneCenter( int _viewer = ALL_VIEWERS );
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 225 226 227 228 229 230 231 232 233 234 235 236

/** \brief Returns the current scene radius from the examiner widget
 *
 * Returns the Radius of the scene
 */
DLLEXPORT
double sceneRadius();

/** \brief Translate viewer pos by given vector
 *
 * Translates the scene by a given vector. ( This is only a view transformation and does not
 * effect the scene center. To really translate the scene, use setScenePos );
 * @param _vector translation
 * @param _viewer Id of the viewer to use.
 *                ALL_VIEWERS    will set all viewers (Default)
 *                ACTIVE_VIEWER active viewer
 *                0..3 Choose viewer explicitly
 */
DLLEXPORT
void translate( const ACG::Vec3d &_vector  , int _viewer = ALL_VIEWERS);

/** \brief Rotate Scene around axis
 *
 * Rotates the current scene.
 * @param _axis   Rotation axis
 * @param _angle  Rotation Angle
 * @param _center Rotation Center
 * @param _viewer Id of the viewer to use.
 *                ALL_VIEWERS    will set all viewers (Default)
 *                ACTIVE_VIEWER active viewer
 *                0..3 Choose viewer explicitly
 */
DLLEXPORT
void rotate(const ACG::Vec3d&  _axis,
            const double       _angle,
            const ACG::Vec3d&  _center,
            int                _viewer = ALL_VIEWERS);


/** \brief Go to home position
 *
 * @param _viewer Id of the viewer to use.
 *                ALL_VIEWERS    will set all viewers (Default)
 *                ACTIVE_VIEWER active viewer
 *                0..3 Choose viewer explicitly
 */
DLLEXPORT
void viewHome(int _viewer = ALL_VIEWERS);

/** \brief View the whole scene
 *
 * @param _viewer Id of the viewer to use.
 *                ALL_VIEWERS    will set all viewers (Default)
 *                ACTIVE_VIEWER active viewer
 *                0..3 Choose viewer explicitly
 */
DLLEXPORT
void viewAll(int _viewer = ALL_VIEWERS);

/** \brief Get the current viewing Direction
 *
 * @param _viewer Id of the viewer to use.
 *                ACTIVE_VIEWER active viewer
 *                0..3 Choose viewer explicitly
 */
DLLEXPORT
Jan Möbius's avatar
Jan Möbius committed
237
ACG::Vec3d viewingDirection(int _viewer = ALL_VIEWERS);
238

239 240 241 242 243 244 245 246 247
/** \brief Check if the projection is orthographic
 * @param _viewer Id of the viewer to use.
 *                ALL_VIEWERS    will set all viewers (Default)
 *                ACTIVE_VIEWER active viewer
 *                0..3 Choose viewer explicitly
 */
DLLEXPORT
bool isProjectionOrthographic( int _viewer = ACTIVE_VIEWER );

248 249 250 251 252 253 254
/** \brief Get the current viewer position
 *
 * @param _viewer Id of the viewer to use.
 *                ACTIVE_VIEWER active viewer
 *                0..3 Choose viewer explicitly
 */
DLLEXPORT
Ellen Dekkers's avatar
 
Ellen Dekkers committed
255
ACG::Vec3d eyePos(int _viewer = ACTIVE_VIEWER);
256 257 258 259 260 261 262 263

/** \brief Get the current up vector
 *
 * @param _viewer Id of the viewer to use.
 *                ACTIVE_VIEWER active viewer
 *                0..3 Choose viewer explicitly
 */
DLLEXPORT
Jan Möbius's avatar
Jan Möbius committed
264
ACG::Vec3d upVector(int _viewer = ALL_VIEWERS);
265 266 267

/** \brief Switch to orthographic Projection
 *
Jan Möbius's avatar
Jan Möbius committed
268 269 270
 * @param _viewer Id of the viewer to use.
 *                ACTIVE_VIEWER active viewer
 *                0..3 Choose viewer explicitly
271 272
 */
DLLEXPORT
Jan Möbius's avatar
Jan Möbius committed
273
void orthographicProjection( int _viewer = ALL_VIEWERS );
274 275 276

/** \brief Switch to perspective Projection
 *
Jan Möbius's avatar
Jan Möbius committed
277 278 279
 * @param _viewer Id of the viewer to use.
 *                ACTIVE_VIEWER active viewer
 *                0..3 Choose viewer explicitly
280 281
 */
DLLEXPORT
Jan Möbius's avatar
Jan Möbius committed
282
void perspectiveProjection( int _viewer = ALL_VIEWERS );
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303

/** \brief Set the draw Mode of a Viewer.\n
 *
 * The DrawModes are defined at ACG/Scenegraph/DrawModes.hh \n
 * They can be combined.
 *
 * @param _viewer Id of the viewer to use.
 *                ACTIVE_VIEWER active viewer
 *                0..3 Choose viewer explicitly
 */
DLLEXPORT
void setDrawMode( const unsigned int _mode , int _viewer = ALL_VIEWERS);

/** \brief Get the current draw Mode of a Viewer
 *
 *
 * @param _viewer Id of the viewer to use.
 *                ACTIVE_VIEWER active viewer
 *                0..3 Choose viewer explicitly
 */
DLLEXPORT
Ellen Dekkers's avatar
 
Ellen Dekkers committed
304
unsigned int drawMode( int _viewer = ACTIVE_VIEWER );
305 306 307 308 309 310 311 312


/** \brief Set the background color of the examiner widget.
 *
 */
DLLEXPORT
void setBackColor( OpenMesh::Vec4f _color);

313 314 315 316 317 318 319 320 321 322 323 324
/** \brief Set a fixed View for a viewer
 *
 *
 * @param _mode id for the mode
 * @param _viewer Id of the viewer to use.
 *                ACTIVE_VIEWER active viewer
 *                0..3 Choose viewer explicitly
 */
DLLEXPORT
void setFixedView(int _mode, int _viewer = ACTIVE_VIEWER );


325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346
/** @} */


//=======================================
// Do animations in examiner viewer
    /** @name Animations
    * @{ */
//=======================================

/**  Fly to point and set new viewing direction (animated).
 * @param _position New viewer position ( the new eye point of the viewer )
 * @param _center   The new scene center ( the point we are looking at )
 * @param _time     Animation time in ms
 */
DLLEXPORT
void flyTo (const ACG::Vec3d &_position, const ACG::Vec3d &_center, double _time=1000.0);

/** @} */

}

#endif //PLUGINFUNCTIONS_HH