MeVisLabToolboxReference
MeVisLab/Standard/Sources/Inventor/SoUtils/SoViewportRegion.h
Go to the documentation of this file.
00001 //----------------------------------------------------------------------------------
00002 // **InsertLicense** code
00003 //----------------------------------------------------------------------------------
00006 
00011 //----------------------------------------------------------------------------------
00012 
00013 #ifndef  __SoViewportRegion_H
00014 #define  __SoViewportRegion_H
00015 
00016 
00017 #include <Inventor/fields/SoSFBool.h>
00018 //#include <Inventor/fields/SoSFInt32.h>
00019 //#include <Inventor/fields/SoSFTrigger.h>
00020 
00021 #include <Inventor/nodes/SoSeparator.h>
00022 #include <Inventor/nodes/SoSubNode.h>
00023 #include <Inventor/events/SoMouseButtonEvent.h>
00024 #include <Inventor/sensors/SoFieldSensor.h>
00025 #include <Inventor/sensors/SoNodeSensor.h>
00026 
00027 //#include <Inventor/SbLinear.h>
00028 #include <Inventor/fields/SoSFVec2f.h>
00029 #include <Inventor/fields/SoSFEnum.h>
00030 
00031 /*
00032 #ifdef WIN32
00033 # include <XVLeaveScope.h>
00034 #endif*/
00035 
00036 #ifndef __SoUtilsSystem_H
00037 #include "SoUtilsSystem.h"
00038 #endif
00039 
00040 class SoCamera;
00041 class SoGLRenderAction;
00042 class SoGetBoundingBoxAction;
00043 class SoRayPickAction;
00044 
00045 class SOUTILS_EXPORT SoViewportRegion : public SoSeparator
00046 {
00047 
00049   SO_NODE_HEADER(SoViewportRegion);
00050 
00051 public:
00053   SoViewportRegion();
00054 
00056   static void       initClass();
00057 
00058   // position mode for one dimension: position and size of the overlay can be defined using two scalar values per dimension
00059   // this enum defines how those two values have to be interpreted (position or size?)
00060   enum PositionMode {
00061     POSITION_MODE_MIN_AND_MAX,      //2 positions are defined:           left and right or lower and upper border  
00062     POSITION_MODE_CENTER_AND_SIZE,  //1 position and 1 size are defined: center and width or height                
00063     POSITION_MODE_MIN_AND_SIZE,     //1 position and 1 size are defined: left or lower border and width or height  
00064     POSITION_MODE_MAX_AND_SIZE      //1 position and 1 size are defined: right or upper border and width or height 
00065   };
00066 
00067   // defines for one (1D-) position if it is related to the minimum (left or lower) or maximum (right or upper) border or the center of the dimension
00068   enum ReferenceMode {
00069     REFERENCE_MODE_MIN,             //related to left or lower border
00070     REFERENCE_MODE_CENTER,          //related to center
00071     REFERENCE_MODE_MAX              //related to right or upper border
00072   };
00073 
00074   // defines for one scalar whether it is defined in pixels or relative to the size of one dimension
00075   enum DomainMode {
00076     DOMAIN_MODE_ABSOLUTE,           //value given in pixels
00077     DOMAIN_MODE_RELATIVE_TO_HEIGHT, //value given in percent (0-1) of the height
00078     DOMAIN_MODE_RELATIVE_TO_WIDTH,  //value given in percent (0-1) of the width
00079     DOMAIN_MODE_RELATIVE_TO_MIN,    //value given in percent (0-1) of the minimum of width and height
00080     DOMAIN_MODE_RELATIVE_TO_MAX,    //value given in percent (0-1) of the minimum of width and height
00081   };
00082 
00083   // defines, what camera is used for the rendering of the scene
00084   enum ProjectionType {
00085       ORTHOGRAPHIC,
00086       PERSPECTIVE,
00087       AUTO,                    
00088       UNMODIFIED               
00089   };
00090 
00092 
00094   SoSFBool  on;
00095 
00097   SoSFBool  modifyVP;
00098 
00100   SoSFBool  usePreviousVP;
00101 
00103   SoSFEnum  xPositionMode;
00104 
00106   SoSFFloat x1;
00107 
00109   SoSFEnum  x1ReferenceMode;
00110 
00112   SoSFEnum  x1DomainMode;
00113 
00115   SoSFFloat x2;
00116 
00118   SoSFEnum  x2ReferenceMode;
00119 
00121   SoSFEnum  x2DomainMode;
00122 
00124   SoSFEnum  yPositionMode;
00125 
00127   SoSFFloat y1;
00128 
00130   SoSFEnum  y1ReferenceMode;
00131 
00133   SoSFEnum  y1DomainMode;
00134 
00136   SoSFFloat y2;
00137 
00139   SoSFEnum  y2ReferenceMode;
00140 
00142   SoSFEnum  y2DomainMode;
00143 
00145   SoSFEnum  projectionType;
00146 
00148   SoSFBool  renderDelayedPaths;
00149 
00151   SoSFBool  detectMouseOver;
00152 
00154   SoSFBool  mouseOverViewport;
00155 
00157   SoSFBool  forwardEvents;
00158 
00160   SoSFBool  forwardEventsInViewportOnly;
00161 
00163   SoSFBool  mapEventToViewport;
00164 
00166   SoSFBool  consumeEventsInViewport;
00167   
00169   
00171   virtual void getBoundingBox(SoGetBoundingBoxAction *action);
00172 
00174   virtual void GLRenderBelowPath(SoGLRenderAction *action);
00175  
00177   virtual void handleEvent(SoHandleEventAction *action);
00178 
00179 
00180 protected:
00182   virtual ~SoViewportRegion();
00183 
00184   ProjectionType                _prevProjType;
00185   SbViewVolume::ProjectionType  _projType;
00186 
00187   SoCamera  *_insetCam;
00188 
00190   SbViewportRegion getViewportRegion(SoState *state);
00191 
00193   int getInterpretedPosition(float value, int width, int height, bool isY, ReferenceMode refMode, DomainMode domMode);
00194     
00196   int getInterpretedSize(float value, int width, int height, DomainMode domMode);
00197 
00198 
00199  private:
00200     SbBool  _calcBBoxIntern;
00201 };
00202 
00203 #endif  // __SoViewportRegion_H