Open Inventor Reference
|
00001 /* 00002 * 00003 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved. 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * Further, this software is distributed without any warranty that it is 00016 * free of the rightful claim of any third person regarding infringement 00017 * or the like. Any license provided herein, whether implied or 00018 * otherwise, applies only to this software file. Patent licenses, if 00019 * any, provided herein do not apply to combinations of this program with 00020 * other software, or any other product whatsoever. 00021 * 00022 * You should have received a copy of the GNU Lesser General Public 00023 * License along with this library; if not, write to the Free Software 00024 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00025 * 00026 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 00027 * Mountain View, CA 94043, or: 00028 * 00029 * http://www.sgi.com 00030 * 00031 * For further information regarding this notice, see: 00032 * 00033 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ 00034 * 00035 */ 00036 00037 00055 00056 #ifndef _SO_SCENE_MANAGER_ 00057 #define _SO_SCENE_MANAGER_ 00058 00059 #include <Inventor/SbColor.h> 00060 #include <Inventor/actions/SoGLRenderAction.h> 00061 00062 class SoNodeSensor; 00063 class SoEvent; 00064 class SoHandleEventAction; 00065 class SoNode; 00066 class SoSceneManager; 00067 class SoSensor; 00068 class SoSFTime; 00069 class SoOneShotSensor; 00070 00072 typedef void SoSceneManagerRenderCB(void *userData, SoSceneManager *mgr); 00073 00074 00077 00095 00096 00097 class INVENTOR_API SoSceneManager { 00098 public: 00099 00101 SoSceneManager(); 00102 00104 ~SoSceneManager(); 00105 00110 virtual void render(SbBool clearWindow = TRUE, SbBool clearZbuffer = TRUE); 00114 virtual SbBool processEvent(const SoEvent *event); 00117 void reinitialize(); 00118 00122 void scheduleRedraw(); 00123 00127 virtual void setSceneGraph(SoNode *newScene); 00129 virtual SoNode * getSceneGraph() const; 00130 00135 void setWindowSize(const SbVec2s &newSize); 00137 const SbVec2s & getWindowSize() const; 00138 00141 void setSize(const SbVec2s &newSize); 00143 const SbVec2s & getSize() const; 00147 void setOrigin(const SbVec2s &newOrigin); 00149 const SbVec2s & getOrigin() const; 00150 00153 void setViewportRegion(const SbViewportRegion &newRegion); 00155 const SbViewportRegion &getViewportRegion() const; 00156 00162 void setBackgroundColor(const SbColor &c); 00164 const SbColor & getBackgroundColor() const { return bkgColor; } 00165 00171 void setBackgroundIndex(int index); 00173 int getBackgroundIndex() const { return bkgIndex; } 00174 00181 void setRGBMode(SbBool onOrOff); 00183 SbBool isRGBMode() const { return rgbMode; } 00184 00190 virtual void activate(); 00192 virtual void deactivate(); 00193 00203 void setRenderCallback( 00204 SoSceneManagerRenderCB *f, 00205 void *userData = NULL); 00207 SbBool isAutoRedraw() const { return (renderCB != NULL); } 00208 00213 void setRedrawPriority(uint32_t priority); 00215 uint32_t getRedrawPriority() const; 00216 00218 static uint32_t getDefaultRedrawPriority() { return 10000; } 00219 00222 static void enableRealTimeUpdate(SbBool flag); 00225 static SbBool isRealTimeUpdateEnabled() { return updateRealTime; } 00226 00239 void setAntialiasing(SbBool smoothing, int numPasses); 00241 void getAntialiasing(SbBool &smoothing, int &numPasses) const; 00242 00243 SoEXTENDER public: 00246 void setGLRenderAction(SoGLRenderAction *ra); 00247 SoGLRenderAction *getGLRenderAction() const { return renderAction; } 00248 00253 void setHandleEventAction(SoHandleEventAction *hea); 00254 SoHandleEventAction *getHandleEventAction() const { return handleEventAction; } 00255 00256 protected: 00257 SoSceneManagerRenderCB *renderCB; 00258 void *renderCBData; 00259 SbBool isActive() const { return active; } 00260 00262 void redraw(); 00263 00264 private: 00265 SbBool raCreatedHere; 00266 SbBool heaCreatedHere; 00267 SoGLRenderAction *renderAction; 00268 SoHandleEventAction *handleEventAction; 00269 SoNode *scene; 00270 SoNodeSensor *sceneSensor; 00271 uint32_t redrawPriority; 00272 SbBool active; 00273 SbBool needZbuffer; 00274 SbBool needToSendVP; 00275 00276 SbColor bkgColor; 00277 int bkgIndex; 00278 SbBool graphicsInitNeeded; 00279 SbBool rgbMode; 00280 00282 static void antialiasingCallback(void *); 00283 static void sceneSensorCallback(SoSceneManager *, SoSensor *); 00284 00286 static SbBool updateRealTime; 00287 static SoSFTime *realTime; 00288 static SoOneShotSensor *realTimeSensor; 00289 static void realTimeSensorCB(); 00290 }; 00291 00292 00293 #endif // _SO_SCENE_MANAGER_