00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef SO_WX_VIEWER
00025 #define SO_WX_VIEWER
00026
00028
00029
00030
00032
00033 #include <Inventor/Wx/SoWxRenderArea.h>
00034
00035 #include <Inventor/Gui/viewers/SoGuiViewer.h>
00036 #include <Inventor/SoType.h>
00037 #include <Inventor/misc/SoCallbackList.h>
00038 #include <Inventor/SbElapsedTime.h>
00039
00040 #include <Inventor/components/stereo/SoStereoViewer.h>
00041
00042
00043 class SoNode;
00044 class SoDirectionalLight;
00045 class SoGroup;
00046 class SoRotation;
00047 class SoCamera;
00048 class SoDrawStyle;
00049 class SoLightModel;
00050 class SoFieldSensor;
00051 class SoWxViewer;
00052 class SoGetBoundingBoxAction;
00053 class SbPList;
00054 class SoSeparator;
00055 class SoSwitch;
00056 class SoComplexity;
00057 class SoPackedColor;
00058 class SoMaterialBinding;
00059 class SoSFTime;
00060 class SoAlarmSensor;
00061 class SoNodeSensor;
00062 class SoGetPrimitiveCountAction;
00063 class SoStereoViewer;
00064 class SoBaseStereo;
00065
00066 class SoGuiViewer;
00067
00068
00069 typedef void SoWxViewerCB(void* userData, SoWxViewer* viewer);
00070 typedef void SoWxViewerCameraTypeChangeCB(void* userData, SoCamera* camera, SoWxViewer* viewer);
00071
00072
00073
00074 typedef void SoWxViewerFPSCB(float fps, void* userData, SoWxViewer* viewer);
00075 typedef void SoWxViewerDecimationPercentageCB(float percentage, void* userData, SoWxViewer* viewer);
00076
00078
00079
00080
00081
00082
00083
00084
00086 class SoDEPRECATED SoWxViewer : public SoWxRenderArea, public SoStereoViewer
00156 {
00157 public:
00158
00169 enum Type
00170 {
00174 BROWSER,
00178 EDITOR
00179 };
00180
00187 enum DrawStyle
00188 {
00192 VIEW_AS_IS,
00196 VIEW_HIDDEN_LINE,
00200 VIEW_NO_TEXTURE,
00204 VIEW_LOW_COMPLEXITY,
00208 VIEW_LINE,
00212 VIEW_POINT,
00216 VIEW_BBOX,
00220 VIEW_LOW_RES_LINE,
00224 VIEW_LOW_RES_POINT,
00228 VIEW_SAME_AS_STILL
00229 };
00230
00232 enum DrawType
00233 {
00237 STILL,
00241 INTERACTIVE
00242 };
00243
00245 enum BufferType
00246 {
00250 BUFFER_SINGLE,
00254 BUFFER_DOUBLE,
00258 BUFFER_INTERACTIVE
00259 };
00260
00262 enum DecimationStrategy
00263 {
00267 NORMAL,
00271 FIXED_NUM_TRIANGLES,
00275 FRAMES_PER_SECOND,
00279 FIXED_PERCENTAGE
00280 };
00281
00287 enum CursorStyle
00288 {
00292 CLASSIC,
00296 XOR,
00300 SHADOW
00301 };
00302
00311 virtual void setSceneGraph( SoNode* newScene );
00312
00316 virtual SoNode* getSceneGraph();
00317
00323 virtual void setCamera( SoCamera* cam );
00324
00328 SoCamera* getCamera() { return m_guiViewer->getCamera(); }
00329
00338 virtual void setCameraType( SoType type );
00339
00344 SoType getCameraType() { return m_guiViewer->getCameraType(); }
00345
00351 virtual void setPreserveCameraHeightAngle( SbBool flag )
00352 { m_guiViewer->setPreserveCameraHeightAngle( flag ); }
00353
00359 virtual SbBool isCameraHeightAnglePreserved() const { return m_guiViewer->isCameraHeightAnglePreserved(); }
00360
00365 virtual void enableSeekWithOrtho(SbBool flag) { m_guiViewer->enableSeekWithOrtho( flag ); }
00366
00371 virtual SbBool isSeekWithOrthoEnabled() const { return m_guiViewer->isSeekWithOrthoEnabled(); }
00372
00391 virtual void viewAll();
00392
00396 virtual void saveHomePosition();
00397
00401 virtual void resetToHomePosition();
00402
00407 void setCameraTypeChangeCallback( SoWxViewerCameraTypeChangeCB* callback, void* userdata );
00408
00415 virtual void setHeadlight( SbBool onOrOff );
00416
00420 SbBool isHeadlight() { return m_guiViewer->isHeadlight(); }
00421
00425 SoDirectionalLight* getHeadlight() { return m_guiViewer->getHeadlight(); }
00426
00475 virtual void setDrawStyle( SoWxViewer::DrawType type, SoWxViewer::DrawStyle style );
00476
00480 SoWxViewer::DrawStyle getDrawStyle( SoWxViewer::DrawType type );
00481
00486 virtual void setBufferingType( SoWxViewer::BufferType type );
00487
00491 SoWxViewer::BufferType getBufferingType()
00492 { return (SoWxViewer::BufferType)m_guiViewer->getBufferingType(); }
00493
00506 virtual void setViewing( SbBool onOrOff );
00507
00511 SbBool isViewing() const { return m_guiViewer->isViewing(); }
00512
00523 virtual void setCursorEnabled( SbBool onOrOff );
00524
00529 SbBool isCursorEnabled() const { return m_guiViewer->isCursorEnabled(); }
00530
00541 void setAutoClipping( SbBool onOrOff );
00542
00546 SbBool isAutoClipping() const { return m_guiViewer->isAutoClipping(); }
00547
00555 virtual void setStereoViewing( SbBool onOrOff );
00556
00561 virtual SbBool isStereoViewing();
00562
00566 void setStereoOffset( float dist );
00567
00571 float getStereoOffset();
00572
00580 void setDetailSeek( SbBool onOrOff ) { m_guiViewer->setDetailSeek( onOrOff ); }
00581
00585 SbBool isDetailSeek() { return m_guiViewer->isDetailSeek(); }
00586
00599 void setSeekTime( float seconds ) { m_guiViewer->setSeekTime( seconds ); }
00600
00604 float getSeekTime() { return m_guiViewer->getSeekTime(); }
00605
00614 void addStartCallback( SoWxViewerCB* f, void* userData = NULL )
00615 { m_guiViewer->addStartCallback( (SoGuiViewerCB*)f, userData ); }
00616
00625 void addFinishCallback( SoWxViewerCB* f, void* userData = NULL )
00626 { m_guiViewer->addFinishCallback( (SoGuiViewerCB*)f, userData ); }
00627
00633 void removeStartCallback( SoWxViewerCB* f, void* userData = NULL )
00634 { m_guiViewer->removeStartCallback( (SoGuiViewerCB*)f, userData ); }
00635
00641 void removeFinishCallback( SoWxViewerCB* f, void* userData = NULL )
00642 { m_guiViewer->removeFinishCallback( (SoGuiViewerCB*)f, userData ); }
00643
00650 virtual void recomputeSceneSize();
00651
00652 #ifndef HIDDEN_FROM_DOC
00653 void saveSceneGraph( const char* fileName );
00654 #endif // HIDDEN_FROM_DOC
00655
00656
00657
00663 void setDecimationStrategy( SoWxViewer::DecimationStrategy strategy );
00664
00668 SoWxViewer::DecimationStrategy getDecimationStrategy()
00669 { return (SoWxViewer::DecimationStrategy)m_guiViewer->getDecimationStrategy(); }
00670
00678 void setGoalNumberOfTriangles( int32_t goal );
00679
00683 int32_t getGoalNumberOfTriangles() { return m_guiViewer->getGoalNumberOfTriangles(); }
00684
00692 void setGoalFramesPerSecond( float goal );
00693
00697 float getGoalFramesPerSecond() { return m_guiViewer->getGoalFramesPerSecond(); }
00698
00706 void setFixedPercentage( float percent );
00707
00711 float getFixedPercentage() { return m_guiViewer->getFixedPercentage(); }
00712
00721 void enableFullRenderingWhenStill( SbBool onOff );
00722
00727 SbBool isFullRenderingWhenStill() { return m_guiViewer->isFullRenderingWhenStill(); }
00728
00732 SbBool isStillNow() { return m_guiViewer->isStillNow(); }
00733
00737 void setFramesPerSecondCallback( SoWxViewerFPSCB* callback, void* userData = NULL );
00738
00743 void setNumSamples( int numFrames );
00744
00749 int getNumSamples() { return m_guiViewer->getNumSamples(); }
00750
00754 void setDecimationPercentageCallback( SoWxViewerDecimationPercentageCB* callback, void* userData = NULL );
00755
00759 float getCurrentDecimationPercentage();
00760
00761
00762
00763 virtual SoCamera* getViewerCamera();
00764 virtual SbBool isViewerDoubleBuffer();
00765 virtual void actualRendering();
00766 virtual const SbVec2s& getSize();
00767 virtual const SbVec2s& getTopLeft() ;
00768 virtual const SbVec2s& getBottomRight() ;
00769 void setStereoViewType( SoBaseStereo* stereo );
00770 SoBaseStereo* getStereoViewType();
00771 void reverseStereoView( SbBool reverse );
00772 SbBool isStereoViewReversed();
00773 virtual void setStereoAbsoluteAdjustments( SbBool absolute );
00774 virtual SbBool isStereoAbsoluteAdjustments() const { return m_guiViewer->isStereoAbsoluteAdjustments(); }
00775 virtual void setStereoBalance( float balance, SbBool nearFrac = false );
00776 virtual float getStereoBalance();
00777 virtual SbBool isStereoBalanceNearFrac();
00778 virtual void setStereoActive( SbBool activate ) ;
00779 virtual SbBool isStereoActive() ;
00780 void setViewport( short left, short bottom, short width, short height );
00781 void getViewport( short& left, short& bottom, short& width, short& height );
00782
00783 SoSeparator* getSceneRoot() { return m_guiViewer->getSceneRoot(); }
00784
00799 virtual void setCursorStyle( SoWxViewer::CursorStyle style );
00800
00804 SoWxViewer::CursorStyle getCursorStyle()
00805 { return (SoWxViewer::CursorStyle)m_guiViewer->getCursorStyle(); }
00806
00816 void setAutoClipTolerance ( float tolerance ) { m_guiViewer->setAutoClipTolerance( tolerance ); }
00817
00821 float getAutoClipTolerance () const { return m_guiViewer->getAutoClipTolerance(); }
00822
00847 virtual void setCameraSceneGraph( SoNode* cameraSceneGraph );
00848
00852 SoNode* getCameraSceneGraph();
00853
00858 void enableMouseWheelDolly( SbBool onOff ) { m_guiViewer->enableMouseWheelDolly( onOff ); }
00859
00868 virtual void setSeekMode( SbBool onOrOff );
00869 SbBool isSeekMode() { return m_guiViewer->isSeekMode(); }
00870
00880 virtual void toggleCameraType();
00881
00887 void setPickRadius( float radius );
00888
00892 float getPickRadius() const;
00893
00894 #if 1 SoDEPRECATED
00897 virtual void adjustClippingPlanes();
00898
00899 #endif
00906 SbBool getDepthValue(int x, int y, float &depth)
00907 {
00908 return m_guiViewer->getDepthValue(x, y, depth);
00909 }
00910
00911 private:
00912
00913 SoGuiViewer* getGuiViewer() const;
00914
00915 virtual ~SoWxViewer();
00916
00917
00918
00919 virtual void setNormalVisual( int* attribList );
00920
00921 SbBool isInteractive() const;
00922
00923 virtual SoGLContext* getViewerContext() { return getNormalSoContext(); }
00924 virtual SoSceneManager* getViewerSceneManager() { return getSceneManager(); }
00925
00926 private:
00927
00928
00929 SoWxViewer( wxWindow* parent,
00930 const char* name,
00931 SbBool buildInsideParent,
00932 SoWxViewer::Type type,
00933 SbBool buildNow,
00934 SbBool sync = true );
00935
00936 SoWxViewer( wxWindow* parent,
00937 const char* name,
00938 SbBool buildInsideParent,
00939 SoWxViewer::Type type,
00940 SbBool buildNow,
00941 SbBool sync,
00942 SoGuiViewer* guiViewer );
00943
00944
00945 SbBool altSwitchBack;
00946
00947
00948
00949
00950
00951
00952 wxCursor normalCursor, dollyCursor, panCursor, rollCursor, seekCursor,
00953 spinCursor, upCursor, flyCursor, walkCursor;
00954
00955
00956
00957
00958
00959 virtual void defineCursors();
00960
00961
00962
00963 virtual void updateCursor() {};
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974 SbBool processCommonEvents( wxEvent& xe );
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986
00987 void interactiveCountInc();
00988 void interactiveCountDec();
00989 int getInteractiveCount() { return m_guiViewer->getInteractiveCount(); }
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001 SbBool seekToPoint( const SbVec2s& mouseLocation );
01002
01003
01004
01005
01006
01007
01008
01009
01010 virtual void interpolateSeekAnimation( float t );
01011 virtual void computeSeekFinalOrientation();
01012
01013
01014
01015
01016 virtual void actualRedraw();
01017
01018
01019
01020
01021 virtual void changeCameraValues( SoCamera* newCamera );
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035 static void setFeedbackOrthoProjection(const SbVec2s& glxSize);
01036
01037
01038
01039 static void restoreGLStateAfterFeedback();
01040
01041
01042 static void drawViewerCrossFeedback(SbVec2s loc);
01043
01044
01045 static void drawViewerRollFeedback( SbVec2s center, SbVec2s loc );
01046
01047 virtual void widgetChanged( wxWindow* w );
01048
01049
01050 virtual void afterRealizeHook();
01051
01052
01053 virtual void adjustCameraClippingPlanes();
01054
01055
01056
01057 virtual void redraw();
01058
01059
01060
01061
01062
01063
01064
01065 virtual float decimationForFramesPerSecond( float fps, double timeTaken, float decimation );
01066
01067
01068
01069
01070
01071
01072 virtual float decimationForNumTriangles( uint32_t numTris );
01073
01074
01075 void* getViewer() { return (void*)this; }
01076
01077 void setCurrentDrawStyle(SoWxViewer::DrawStyle style);
01078
01079 private:
01080
01081 void constructorCommon( SoWxViewer::Type t, SbBool buildNow );
01082 void constructorCommon2( SoWxViewer::Type t, SbBool buildNow );
01083
01084 SoGuiViewer* m_guiViewer;
01085
01086
01087 void setZbufferState();
01088 SbBool isZbufferOff();
01089 void arrowKeyPressed( int rawKey );
01090
01091
01092 static SoGLRenderAction::AbortCode renderAbortCB( void* data );
01093 SoAlarmSensor* stillSensor;
01094 static void alarmCB( void* thisp, SoSensor* ) { ((SoWxViewer*)thisp)->stillSensorCalled(); }
01095 void stillSensorCalled();
01096
01097
01098 static void seekAnimationSensorCB( void* p, SoSensor* sensor );
01099
01100
01116 static SbBool viewingEventCB( SoWxViewer* viewer, wxEvent& anyEvent );
01117
01118 SoNode* m_cameraSceneGraph;
01119
01120
01121
01122 SoCamera* camera;
01123 SbBool createdCursors, viewingFlag;
01124 CursorStyle cursorStyle;
01125 SoSeparator* sceneRoot;
01126 float sceneSize;
01127 SoBaseStereo* stereoViewType;
01128 SbBool m_seekWithOrtho, m_preserveHeightAngle, cursorEnabledFlag, seekDistAsPercentage, computeSeekVariables;
01129 float m_previousHeightAngle, viewerSpeed, seekDistance;
01130 SoWxViewer::Type type;
01131 SoNode* sceneGraph;
01132 SbVec3f seekPoint, seekNormal, oldCamPosition, newCamPosition;
01133 SbRotation oldCamOrientation, newCamOrientation;
01134 };
01135
01136 #endif // SO_WX_VIEWER
01137
01138
01139