--- /dev/null
+ #----------------------------------------------------------------------------
+# USER! : SET THE NAME OF YOUR LIBRARY
+# (Replace 'MyLib' by your own library name)
+
+#############################
+SET ( LIBRARY_NAME BaseVolumeRenderer )
+#############################
+
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# CREATES A USER OPTION IN CMAKE
+OPTION ( BUILD_${LIBRARY_NAME} "Build ${LIBRARY_NAME} library ?" ON)
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+IF ( BUILD_${LIBRARY_NAME} )
+#----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # BUILD LIBRARY
+ #----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # LIBRARY HEADERS (TO BE INSTALLED)
+ # EITHER LIST ALL .h, *.txx IN CURRENT DIR USING NEXT LINE:
+
+ FILE(GLOB ${LIBRARY_NAME}_HEADERS *.h *.txx)
+
+ # OR MANUALLY LIST YOUR HEADERS WITH NEXT COMMAND
+ # SET ( ${LIBRARY_NAME}_HEADERS
+ #
+ # )
+ #----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # LIBRARY SOURCES (TO BE COMPILED)
+ # EITHER LIST ALL .cxx, *.cpp, *.cc IN CURRENT DIR USING NEXT LINE:
+
+ FILE(GLOB ${LIBRARY_NAME}_SOURCES *.cxx *.cpp *.cc ${${LIBRARY_NAME}_HEADERS})
+
+ # OR MANUALLY LIST YOUR FILES WITH NEXT COMMAND (WITHOUT EXTENSION)
+ # SET ( ${LIBRARY_NAME}_SOURCES
+ #
+ # )
+ #----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # LIBRARY DEPENDENCIES (LIBRARIES TO LINK WITH)
+ #
+ # USER! : Uncomment the Libraries you need
+ #
+ SET ( ${LIBRARY_NAME}_LINK_LIBRARIES
+ # ${crea_LIBRARIES}
+ # ${WXWIDGETS_LIBRARIES}
+ # ${KWWidgets_LIBRARIES}
+ # ${VTK_LIBRARIES}
+ # ${ITK_LIBRARIES}
+ # ${GDCM_LIBRARIES}
+ # ${BOOST_LIBRARIES}
+ KernelVolumeRenderer
+
+ # If this library must link against other libraries
+ # USER! : Add here any extra Library you need
+
+ )
+ #----------------------------------------------------------------------------
+
+ #----------------------------------------------------------------------------
+ # MACRO WHICH DOES ALL THE JOB : BUILD AND INSTALL
+
+ # USER! : The default is to create a Dynamic Library.
+ # if you need to create a static library
+ # comment out the following line :
+
+ CREA_ADD_LIBRARY( ${LIBRARY_NAME} )
+ #SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES LINKER_LANGUAGE C)
+
+ # and uncomment the 2 lines hereafter:
+
+ # ADD_LIBRARY(${LIBRARY_NAME} STATIC ${${LIBRARY_NAME}_SOURCES})
+ # TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${${LIBRARY_NAME}_LINK_LIBRARIES} )
+
+ #
+ #----------------------------------------------------------------------------
+
+ #---------------------------------------------------------------------------
+ENDIF ( BUILD_${LIBRARY_NAME} )
--- /dev/null
+#include "volumerendererdata.h"
+
+VolumeRendererData::VolumeRendererData()
+{
+ VolRendData = 0;
+ ImageData = 0;
+ Renderer = 0;
+ Interactor = 0;
+}
+
+
+void VolumeRendererData::ShowVolume(bool checked){
+ if(checked){
+ invariant();
+ VolRendData = new VolumeRendererManagerData(ImageData, true);
+ VolRendData->SetLookupTable(LookUpTable);
+ Renderer->AddActor(VolRendData->getProp3D());
+ }else{
+ Renderer->RemoveActor(VolRendData->getProp3D());
+ VolRendData->Delete();
+ VolRendData = 0;
+ }
+}
+
+void VolumeRendererData::invariant(){
+ if(!ImageData){
+ throw "Image data not set";
+ }
+ if(!Renderer){
+ throw "renderer not initialized";
+ }
+}
+void VolumeRendererData::OpacityChanged(vector<double> greyvalues, vector<double> values){
+ invariant();
+ if(VolRendData){
+ VolRendData->setVolumeOpacity(greyvalues,values);
+ }
+}
+void VolumeRendererData::BoundingBoxChanged(bool checked){
+ invariant();
+ if(VolRendData && Interactor){
+ if(checked){
+ VolRendData->EnableBoundingBox(Interactor);
+ }else{
+ VolRendData->DisableBoundingBox();
+ }
+ }
+}
--- /dev/null
+#ifndef VOLUMERENDERERDATA_H
+#define VOLUMERENDERERDATA_H
+
+
+#include "volumerenderermanagerdata.h"
+#include "vtkRenderWindowInteractor.h"
+#include "vtkObject.h"
+
+using namespace std;
+
+class VolumeRendererData : public vtkObject
+{
+public:
+ VolumeRendererData();
+
+ vtkSetObjectMacro(VolRendData, VolumeRendererManagerData)
+ vtkSetObjectMacro(ImageData, vtkImageData)
+ vtkSetObjectMacro(Renderer, vtkRenderer)
+ vtkSetObjectMacro(LookUpTable, vtkLookupTable)
+ vtkSetObjectMacro(Interactor, vtkRenderWindowInteractor)
+
+protected:
+ VolumeRendererManagerData* VolRendData;
+ vtkImageData* ImageData;
+ vtkRenderer* Renderer;
+ vtkLookupTable* LookUpTable;
+ vtkRenderWindowInteractor* Interactor;
+
+ void ShowVolume(bool enable);
+ void OpacityChanged(vector<double> greyvalues, vector<double> values);
+ void BoundingBoxChanged(bool checked);
+
+private:
+
+ void invariant();
+};
+
+#endif // VOLUMERENDERERDATA_H