| VRS - The Virtual Rendering System |
| version 3.3 |
00001 /****************************************************************************** 00002 * VRS - The Virtual Rendering System 00003 * Copyright (C) 2003 Computer Graphics Systems Group at the 00004 * Hasso-Plattner-Institute (HPI), Potsdam, Germany. 00005 * 00006 * This library is free software; you can redistribute it and/or modify it 00007 * under the terms of the GNU Lesser General Public License as published by 00008 * the Free Software Foundation; either version 2.1 of the License, or (at 00009 * your option) any later version. This library is distributed in the hope 00010 * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 00011 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU Lesser General Public License for more details. You should have received 00013 * a copy of the GNU Lesser+ General Public License along with this library; if 00014 * not, write to the FreeSoftware Foundation, Inc., 59 Temple Place, Suite 330, 00015 * Boston, MA, 02111-1307, USA. 00016 ******************************************************************************/ 00017 00018 // $Id: navigation.h 6014 2007-08-09 07:51:16Z Konstantin_Baumann $ 00019 // $Date: 2007-08-09 09:51:16 +0200 (Thu, 09 Aug 2007) $ 00020 // $Revision: 6014 $ 00021 // $State$ 00022 // $Author: Konstantin_Baumann $ 00023 // 00024 // $Log$ 00025 // Revision 1.25 2005/06/23 13:03:46 buchholz 00026 // activeNavigation can now be set from outside 00027 // 00028 // Revision 1.24 2005/01/03 01:43:10 klimetschek 00029 // - modified win32 project layout, splitted vrs.vcproj into vrs_container, vrs_core, vrs_sg, vrs_image, vrs_opengl and vrs_io 00030 // - removed vrs.vcproj 00031 // minor things: 00032 // - added all glutexamples to vrs4glut.sln 00033 // - fixed some problems in glutexamples 00034 // - removed all project references from all VS projects (using solution wide project dependencies instead) 00035 // 00036 // Revision 1.23 2004/12/02 11:25:54 baumann 00037 // serialization ctor fixed 00038 // 00039 // Revision 1.22 2004/10/28 14:16:01 basch 00040 // Class comment changed (Doxygen style) 00041 // 00042 // Revision 1.21 2004/05/27 12:53:07 bohnet 00043 // minor changes 00044 // 00045 // Revision 1.20 2004/03/31 14:45:59 bohnet 00046 // Smoothflyer added 00047 // 00048 // Revision 1.19 2004/03/25 13:48:08 baumann 00049 // static method activeNavigation() added 00050 // 00051 // Revision 1.18 2004/03/16 15:00:29 grabs 00052 // navigational rayrequests now ignore shapes with a Navigation::getIgnoreFilterTag() 00053 // 00054 // Revision 1.17 2004/03/12 16:28:41 baumann 00055 // macros VRS_NAMESPACE_BEGIN/_END expanded and removed 00056 // 00057 // Revision 1.16 2004/03/10 16:53:37 baumann 00058 // ignore filter added 00059 // 00060 // Revision 1.15 2004/03/10 09:49:49 bohnet 00061 // enum NavMode expanded by the navigation metaphor Ufo 00062 // 00063 // Revision 1.14 2004/03/06 16:22:48 kirsch 00064 // cleaned up CameraMemento 00065 // 00066 // Revision 1.13 2004/03/06 14:02:46 kirsch 00067 // cleaned up includes 00068 // 00069 // Revision 1.12 2004/01/22 13:53:29 buchholz 00070 // minor changes 00071 // 00072 // Revision 1.11 2004/01/19 11:43:59 baumann 00073 // serialization mechanism improved 00074 // 00075 // Revision 1.10 2004/01/19 07:28:03 baumann 00076 // serialization mechanism improved 00077 // 00078 // Revision 1.9 2003/12/15 12:58:56 baumgarten 00079 // removed static so's of navigation to cpp-file 00080 // 00081 // Revision 1.8 2003/11/26 15:05:11 buchholz 00082 // constraintchecker added 00083 // 00084 // Revision 1.7 2003/10/22 15:21:46 kirsch 00085 // iVRS fix 00086 // 00087 // Revision 1.6 2003/07/08 13:45:25 baumgarten 00088 // added clearActiveNavigation 00089 // neccessary to delete some objects outside of vrs correctly 00090 // 00091 // Revision 1.5 2003/07/04 13:01:03 baumann 00092 // made some methods virtual 00093 // 00094 // Revision 1.4 2003/07/04 09:50:32 baumgarten 00095 // it's now base class for all navigation incl. mapnavigation 00096 // 00097 // Revision 1.3 2003/04/09 15:11:09 buchholz 00098 // some comments added 00099 // 00100 // Revision 1.2 2003/02/24 19:34:02 buchholz 00101 // bugfix: made class info public 00102 // 00103 // Revision 1.1 2003/02/24 12:46:27 buchholz 00104 // common base class for conflict management 00105 // 00106 00107 #ifndef VRS_SG_NAVIGATION_H 00108 #define VRS_SG_NAVIGATION_H 00109 00110 #include <vrs/vector.h> 00111 #include <vrs/sg/inputevent.h> 00112 #include <vrs/sg/manipulator.h> 00113 00114 namespace VRS { 00115 00116 class FilterTag; 00117 class LookAt; 00118 class Filter; 00119 00120 class VRS_CORE_API CameraMemento : public SharedObj { 00121 public: 00122 CameraMemento(); 00123 CameraMemento(const LookAt* l); 00124 00125 void reactivate(LookAt* l); 00126 00127 Vector getFrom() const; 00128 Vector getTo() const; 00129 Vector getUp() const; 00130 00131 VRS_TYPEINFO(CameraMemento, SharedObj); 00132 VRS_SERIALIZABLE(CameraMemento); 00133 00134 private: 00135 Vector from_,to_,up_; 00136 }; 00137 00138 class ConstraintChecker; 00139 00150 class VRS_CORE_API Navigation : public Manipulator { 00151 00152 public: 00153 enum NavMode { Sphere, Cone, Zoom, Flyer, SmoothFlyer, ZoomTurn, ZoomShift, 00154 Pan, ElevateLookFixed, LookAround, MoveFocus, WheelZoom, Approach, Game, Jump, Plane, SmoothGlider, Ufo}; 00155 VRS_SERIALIZABLE_CLASS_ENUM(NavMode); 00157 00178 virtual void setNavMode(NavMode mode); 00180 NavMode getNavMode() const; 00182 00188 void clearActiveNavigation(); 00189 00190 void setLookAt(LookAt*); 00192 LookAt* getLookAt() const; 00194 00195 VRS::Vector getFocus() const; 00197 00198 virtual BehaviorNode::InvalidationHint handle(Event*); 00199 00200 virtual BehaviorNode::InvalidationHint dragStart(int x, int y, ButtonEvent*); 00201 virtual BehaviorNode::InvalidationHint dragMotion(int x, int y, MotionEvent*); 00202 virtual BehaviorNode::InvalidationHint dragEnd(int x, int y, ButtonEvent*); 00203 /*<!< Pure virtual event handling methods of the base class Manipulator. 00204 Since some navigation classes do not need them, Navigation contains empty implementations. 00205 So they can, but need not be overloaded. */ 00206 00207 virtual void storeCamera(const std::string& name); 00208 virtual void activateCamera(const std::string& name); 00209 virtual void removeCamera(const std::string& name); 00210 virtual void clearCameras(); 00211 virtual VRS::Iterator<std::string>* cameraNames() const; 00212 00213 virtual void setConstraintChecker(ConstraintChecker* checker); 00214 virtual ConstraintChecker* getConstraintChecker() const; 00215 00216 static SO<FilterTag> getIgnoreFilterTag(); 00217 00218 static SO<Navigation> activeNavigation(); 00219 static void setActiveNavigation(SO<Navigation> navigation); 00220 00221 VRS_TYPEINFO(Navigation, Manipulator); 00222 VRS_SERIALIZABLE(Navigation); 00223 00224 protected: 00225 00226 //Filter should be const, but const correctness is not supported by vrs :( 00227 //so please dont change or change at your own risk 00228 static SO<Filter> getIgnoreFilter(); 00229 00230 CameraMemento* findCamera(const std::string& name); 00231 void addCamera(const std::string& name, CameraMemento* cm); 00232 void addCamera(const std::string& name, LookAt* lookAt); 00233 00234 Navigation( 00235 LookAt* lookAt = NULL, 00236 InputEvent::Button button = InputEvent::MouseButton1, 00237 InputEvent::Modifier must_modifier = InputEvent::NoModifier, 00238 InputEvent::Modifier must_not_modifier = InputEvent::NoModifier, 00239 Callback* startCallback = NULL, 00240 Callback* motionCallback = NULL, 00241 Callback* endCallback = NULL 00242 ); 00243 00244 static SO<Navigation> activeNavigation_; 00245 00246 private: 00247 SO<LookAt> lookAt_; 00248 int navMode_; 00249 00250 SO<ConstraintChecker> constraintChecker_; 00251 }; 00252 00253 inline Navigation::NavMode Navigation::getNavMode() const { return (NavMode)navMode_; } 00254 00255 } // namespace VRS 00256 00257 #endif // VRS_SG_NAVIGATION_H