MeVisLabToolboxReference
MeVisLab/Standard/Sources/Inventor/SoCSO/SoView2DCSOEditor/SoView2DCSOExtensibleEditor/extensions/SoCSOImageStatistics/SoCSOImageStatistics.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //----------------------------------------------------------------------------------
00004 
00009 //----------------------------------------------------------------------------------
00010 
00011 
00012 #ifndef __SoCSOImageStatistics_H
00013 #define __SoCSOImageStatistics_H
00014 
00015 #include <SoView2DCSOEditor/SoView2DCSOExtensibleEditor/SoCSOEditorExtension.h>
00016 
00017 ML_START_NAMESPACE
00018 class BaseEvent;
00019 ML_END_NAMESPACE
00020 
00022 
00024 class SOCSO_EXPORT SoCSOImageStatistics : public SoCSOEditorExtension
00025 {
00026   SO_NODE_HEADER(SoCSOImageStatistics);
00027 
00028 public:
00029 
00031   SoCSOImageStatistics();
00032 
00034   SoSFInt32 currentCSOId;
00036   SoSFInt32 numVoxels;
00038   SoSFFloat imageMinValue;
00040   SoSFFloat imageMaxValue;
00042   SoSFFloat imageMeanValue;
00044   SoSFFloat imageAbsMeanValue;
00046   SoSFFloat imageVarianceValue;
00048   SoSFFloat imageStdDeviationValue;
00050   SoSFFloat imageAverageSquaredSumValue;
00052   SoSFString imageModality;
00054   SoSFFloat imageRescaleIntercept;
00056   SoSFFloat imageRescaleSlope;
00058   SoSFBool imageValuesValid;
00060   SoSFTrigger markAllCSOsForUpdate;
00062   SoSFMLImage inputImage;
00063 
00065   virtual void draw(const CSODrawCSOInfos& csoInfos, const CSODrawView2DInfos& view2DInfos, const CSODrawSliceInformation& drawSliceInfo, SoView2DCSOExtensibleEditor* editor);
00066 
00068   static void initClass();
00069 
00070   virtual void createStartPressAt(const SoPointerPosition& ) {}
00071   virtual void createDragMoveTo(const SoPointerPosition& ) {}
00072   virtual bool createEndPress(int ) { return false; }
00073 
00074   virtual void selectAndMoveStartPressAt(const SoPointerPosition& ) {}
00075   virtual void selectAndMoveDragMoveTo(const SoPointerPosition& ) {}
00076   virtual SoPointingAction* selectAndMoveEndPress(int ) { return NULL; }
00077 
00078   virtual int cursorShape() const { return SoViewerProxy::DEFAULT_CURSOR; }
00079 
00080   virtual bool shouldRenderGeneral(ml::CSO*) const { return true; }
00081  
00082 
00083 protected:
00084 
00085   ~SoCSOImageStatistics();
00086 
00087 private:
00088   
00089   SoFieldSensor* _inputImageSensor;
00090   static void _inputImageCB(void* data, SoSensor*);
00091 
00092   SoFieldSensor* _markAllCSOsForUpdateSensor;
00093   static void _markAllCSOsForUpdatePressedCB(void* data, SoSensor*);
00094   bool _allCSOsNeedUpdate;
00095 
00097   struct PathPointsSegment 
00098   {
00099     ml::Vector3 startPosition;
00100     ml::Vector3 endPosition;
00101   };
00102 
00104   struct vectorXSort 
00105   {
00106     bool operator ()(const ml::Vector2& a, const ml::Vector2& b) const
00107     {
00108       if (a[0] < b[0]) { return true; }
00109       return false;
00110     }
00111   };
00112 
00115   void fillCrossingsVector(std::vector< std::vector< ml::Vector2 > >& crossingsVector, 
00116                            const std::vector< ml::Vector3 >& pathPoints, 
00117                            const ml::Vector3& minBB, const ml::Vector3& maxBB);
00118   
00120   void retrieveDicomTagData(const CSODrawView2DInfos& view2DInfos, std::string& modality, float& rescaleIntercept, float& rescaleSlope);
00121 
00125   SoSFMLImage* getInputImage(const CSODrawView2DInfos& view2DInfos);
00127   bool haveSameSize(const XVImageSize& size1, const XVImageSize& size2) const;
00129   bool haveSameWorldToVoxelMatrix(SoSFMLImage* image1, SoSFMLImage* image2) const;
00131   void setAllCSOsNeedUpdate(ml::CSOList* csoList);
00132 
00134   static void baseEventCB(void* userData, ml::BaseEvent* event);
00137   bool needsUpdate(ml::CSO* cso);
00140   void attachAsListenerTo(ml::CSOList* csoList);
00142   ml::CSOListPtr _listenToCSOList;
00144   std::set<int> _needsUpdateCSOIds;
00145 };
00146 
00148 
00149 #endif // __SoCSOImageStatistics_H