MeVisLabToolboxReference
|
00001 #ifndef __View2DSlice_H 00002 #define __View2DSlice_H 00003 //---------------------------------------------------------------------------------- 00004 // **InsertLicense** code 00005 //---------------------------------------------------------------------------------- 00008 00014 //---------------------------------------------------------------------------------- 00015 00016 #ifndef __SoView2DSystem_H 00017 #include "SoView2DSystem.h" 00018 #endif 00019 #ifndef __SoSFMLImage_H 00020 #include "SoSFMLImage.h" 00021 #endif 00022 #ifndef __SoView2DExtension_H 00023 #include "SoView2DExtension.h" 00024 #endif 00025 #ifndef __View2DTexture_H 00026 #include "View2DTexture.h" 00027 #endif 00028 00029 class View2DSliceList; 00030 class View2DShader; 00031 class SoNodeList; 00032 00033 // declare the LUTData 00034 ML_START_NAMESPACE 00035 00036 template <typename T> class LUTData; 00037 00038 ML_END_NAMESPACE 00039 00041 #define VIEW2D_MAX_OVERLAY_TEXTURES 8 00042 00043 enum { 00045 // (if the type for slice indices is changed to a bigger type 00046 // than int, change this constant, too!) 00047 NO_SLICE_ID = 0x80000000 00048 }; 00049 00050 #ifndef CACHING_MODE_DEFINED 00051 #define CACHING_MODE_DEFINED 00052 00053 enum SLICE_CACHING_MODE { 00054 SLICE_CACHING_OFF = 0x01, 00055 SLICE_CACHING_PARTIAL = 0x02, 00056 SLICE_CACHING_COMPLETE = 0x03 00057 }; 00058 #endif 00059 00061 enum sliceBlendModeType { 00062 BLEND_MAXIMUM = 0, 00063 BLEND_ADD, 00064 BLEND_MINIMUM, 00065 BLEND_REPLACE, 00066 BLEND_REVERSE_SUBTRACT, 00067 BLEND_SUBTRACT, 00068 BLEND_BLEND, 00069 BLEND_NUMENTRIES 00070 }; 00071 00073 enum sliceAlignXMode { 00074 SLICE_ALIGNX_CENTER=0, 00075 SLICE_ALIGNX_LEFT, 00076 SLICE_ALIGNX_RIGHT 00077 }; 00078 00080 enum sliceAlignYMode { 00081 SLICE_ALIGNY_CENTER=0, 00082 SLICE_ALIGNY_TOP, 00083 SLICE_ALIGNY_BOTTOM 00084 }; 00085 00086 //------------------------------------------------------------- 00088 class SOVIEW2D_API View2DSlice { 00089 public: 00091 View2DSlice(); 00093 ~View2DSlice(); 00094 00096 void destroy(); 00097 00099 void setInputImage(SoSFMLImage *img); 00101 SoSFMLImage *getInputImage(); 00102 00104 void setShaders(View2DShader* shader, View2DShader** overlayShaders); 00105 00107 View2DShader* getShader() { return _shader; } 00108 00110 void setSliceZ(int z); 00112 int getSliceZ(); 00113 00115 void setDrawsData(bool flag); 00116 00118 void setAspectRatio(float ratio) { _aspectRatio = ratio; } 00119 00121 float getAspectRatio() { return _aspectRatio; } 00122 00124 void setFilter(View2DTextureFilter filter = FILTER_LINEAR); 00126 View2DTextureFilter getFilter(); 00127 00129 void setSliceAlignment(sliceAlignXMode x, sliceAlignYMode y); 00130 00132 void setFixedInnerZoom(bool flag, float fixedZoom); 00133 00135 void setDrawSize(float sx, float sy); 00137 void getDrawSize(float &sx, float &sy); 00138 00140 void setDrawPosition(float x, float y); 00142 void getDrawPosition(float &x, float &y); 00143 00145 void setSliceOrigin(float x, float y); 00147 void getSliceOrigin(float &x, float &y); 00148 00150 void setSliceZoom(float zoom); 00152 float getSliceZoom(); 00153 00155 void setCachingMode(SLICE_CACHING_MODE mode); 00157 SLICE_CACHING_MODE getCachingMode(); 00158 00160 void getVoxelSize(float &vx,float &vy, float &vz); 00161 00163 void updateLayout(); 00164 00166 void setLut(ml::LUTData<MLuint8>* lut); 00167 00169 void setBlendMode(int blendMode, float* blendColor=NULL); 00170 00172 void setBackgroundColor(float* color); 00173 00175 void setTimePoint(int timepoint); 00177 int getTimePoint(); 00178 00180 void drawBackground(); 00181 00184 void drawSlice(View2DSliceList *dsl, int originX, int originY, int width, int height, 00185 SoNodeList* extensions, bool extensionsOnly, bool isSlabRendering); 00186 00188 void drawTexture(View2DTexture* texture, int blendMode); 00190 void drawTexture(View2DTexture* texture, int blendMode, float* blendColor); 00192 void drawTexture(View2DTexture* texture, int blendMode, float* blendColor,View2DTextureFilter filter); 00193 00195 void drawTexture(View2DTexture* texture, float vp1[3], float vp2[3], float vp3[3], 00196 int blendMode, float* blendColor); 00197 00199 void drawTexture(View2DTexture* texture, float vp1[3], float vp2[3], float vp3[3], 00200 int blendMode, float* blendColor, View2DTextureFilter filter); 00201 00202 00209 bool select(float x, float y, float &voxelX, float &voxelY, float &voxelZ); 00210 00212 bool select(float x, float y, SbVec3f &voxel); 00213 00215 bool select(const SbVec2f& d, SbVec3f &voxel); 00216 00219 bool isSliceHit(float x, float y); 00220 00222 bool isValidVoxel(float voxelX, float voxelY, float voxelZ); 00223 00225 bool isValidVoxel(const SbVec3f& voxel); 00226 00228 void invalidate(); 00229 00232 void invalidateView(); 00233 00236 float millimeterToPixel(float lengthMillimeter); 00237 00241 void mapVoxelToDevice(float voxelX, float voxelY, float voxelZ, 00242 float &rx, float &ry); 00243 00245 void mapVoxelToDevice(const SbVec3f &voxelCoord, 00246 float &rx, float &ry); 00247 00249 void mapVoxelToDevice(const SbVec3f &voxelCoord, 00250 SbVec2f& r); 00251 00254 void mapWorldToDevice(float worldX, float worldY, float worldZ, 00255 float &rx, float &ry); 00256 00258 void mapWorldToDevice(const SbVec3f &worldCoord, 00259 float &rx, float &ry); 00260 00262 void mapWorldToDevice(const SbVec3f &worldCoord, 00263 SbVec2f& r); 00264 00266 void getVisibleDeviceRect(float &dx1,float &dy1, float &dx2, float &dy2); 00267 00269 View2DTexture* getOverlayTexture(void* user = NULL, int id = 0); 00270 00272 int getLutSize(); 00273 00275 float getInnerZoom(); 00276 00278 void setDraw3D(bool flag, float devicePixelSize = 1); 00279 00281 bool is3D() { return _is3D; } 00282 00284 bool containsVoxel(const SbVec3f& voxelPos); 00285 00286 private: 00288 void* getImageSlice(int slice); 00289 00291 00292 int _sliceZ; 00294 int _timePoint; 00296 float _drawPosX; 00298 float _drawPosY; 00300 float _drawSizeX; 00302 float _drawSizeY; 00303 00304 View2DTextureFilter _filter; 00305 int _blendMode; 00306 float _blendColor[4]; 00307 float _bgColor[4]; 00308 float _zoom; 00309 float _sliceZoom; 00310 float _sliceOriginX; 00311 float _sliceOriginY; 00312 00313 float _fixedInnerZoom; 00314 bool _fixedInnerZoomOn; 00315 00317 00319 SoSFMLImage *_inp; 00320 00322 float _centerX; 00324 float _centerY; 00325 00327 int _imageX; 00329 int _imageY; 00330 00332 float _vx,_vy,_vz; 00334 00336 float _aspectRatio; 00337 00339 bool _drawData; 00341 bool _is3D; 00342 00344 sliceAlignXMode _sliceAlignX; 00346 sliceAlignYMode _sliceAlignY; 00347 00349 SLICE_CACHING_MODE _caching; 00350 00352 View2DTexture _sliceTexture; 00354 View2DTexture *_overlayTextures[VIEW2D_MAX_OVERLAY_TEXTURES]; 00355 00357 View2DShader* _shader; 00358 View2DShader** _overlayShaders; 00359 }; 00360 00361 #endif