]> Creatis software - gdcm.git/commitdiff
Propagate Mathieu's modif from 1.2 to CVS version.
authorjpr <jpr>
Tue, 2 May 2006 10:09:43 +0000 (10:09 +0000)
committerjpr <jpr>
Tue, 2 May 2006 10:09:43 +0000 (10:09 +0000)
ENH: A few stuff:
Do not call ResetCameraClippingRange in VTK5 and above (fixed)
Update to new API for the ZSlicer stuff in vtkImageViewer2
Add a vtkMedicalImageProperties to the writer to pass in medical information from VTK context (pretty neat...)
Minor style, avoid including too many header files

URL : http://cvs.creatis.insa-lyon.fr/viewcvs/viewcvs.cgi/gdcm/?view=query&branch=&who=malaterre&date=explicit&mindate=2006-04-20%2021:20&maxdate=2006-04-20%2021:22

vtk/vtkGdcmWriter.cxx
vtk/vtkGdcmWriter.h
vtk/vtkgdcmViewer2.cxx

index 1ba93f890b117b04a75e635a81db1cf7e42d1218..9a17fa60feae44df8d59973869540e10e9a5571b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: vtkGdcmWriter.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/03/20 14:32:20 $
-  Version:   $Revision: 1.28 $
+  Date:      $Date: 2006/05/02 10:09:43 $
+  Version:   $Revision: 1.29 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #include <vtkImageData.h>
 #include <vtkPointData.h>
 #include <vtkLookupTable.h>
-
+#if (VTK_MAJOR_VERSION >= 5)
+#include <vtkMedicalImageProperties.h>
+#endif
 #ifndef vtkFloatingPointType
 #define vtkFloatingPointType float
 #endif
 
-vtkCxxRevisionMacro(vtkGdcmWriter, "$Revision: 1.28 $")
+vtkCxxRevisionMacro(vtkGdcmWriter, "$Revision: 1.29 $")
 vtkStandardNewMacro(vtkGdcmWriter)
 
+vtkCxxSetObjectMacro(vtkGdcmWriter,LookupTable,vtkLookupTable);
+#if (VTK_MAJOR_VERSION >= 5)
+vtkCxxSetObjectMacro(vtkGdcmWriter,MedicalImageProperties,vtkMedicalImageProperties);
+#endif
 //-----------------------------------------------------------------------------
 // Constructor / Destructor
 vtkGdcmWriter::vtkGdcmWriter()
 {
    this->LookupTable = NULL;
+   this->MedicalImageProperties = NULL;   
    this->FileDimensionality = 3;
    this->WriteType = VTK_GDCM_WRITE_TYPE_EXPLICIT_VR;
    this->GdcmFile = 0;
@@ -47,6 +54,8 @@ vtkGdcmWriter::vtkGdcmWriter()
 
 vtkGdcmWriter::~vtkGdcmWriter()
 {
+   this->SetMedicalImageProperties(NULL);
+   this->SetLookupTable(NULL);
 }
 
 //-----------------------------------------------------------------------------
@@ -124,6 +133,50 @@ size_t ReverseData(vtkImageData *image,unsigned char **data)
    return size;
 }
 
+ /**
+  * Set the medical informations in the file, based on the user passed
+  * vtkMedicalImageProperties
+  */
+#if (VTK_MAJOR_VERSION >= 5)  
+void SetMedicalImageInformation(gdcm::FileHelper *file, vtkMedicalImageProperties *medprop)
+{
+   // For now only do:
+   // PatientName, PatientID, PatientAge, PatientSex, PatientBirthDate, StudyID
+  std::ostringstream str;
+   if( medprop )
+   {
+      str.str("");
+      str << medprop->GetPatientName();
+      file->InsertValEntry(str.str(),0x0010,0x0010); // PN 1 Patient's Name
+
+      str.str("");
+      str << medprop->GetPatientID();
+      file->InsertValEntry(str.str(),0x0010,0x0020); // LO 1 Patient ID
+
+      str.str("");
+      str << medprop->GetPatientAge();
+      file->InsertValEntry(str.str(),0x0010,0x1010); // AS 1 Patient's Age
+      str.str("");
+      str << medprop->GetPatientSex();
+      file->InsertValEntry(str.str(),0x0010,0x0040); // CS 1 Patient's Sex
+      str.str("");
+      str << medprop->GetPatientBirthDate();
+      file->InsertValEntry(str.str(),0x0010,0x0030); // DA 1 Patient's Birth Date
+      str.str("");
+      str << medprop->GetStudyID();
+      file->InsertValEntry(str.str(),0x0020,0x0010); // SH 1 Study ID
+      }
+   }
+
+#else
+void SetMedicalImageInformation(gdcm::FileHelper *, vtkMedicalImageProperties *)
+{
+}
+#endif
+
 /**
  * Set the data informations in the file
  */
@@ -340,7 +393,11 @@ void vtkGdcmWriter::WriteDcmFile(char *fileName, vtkImageData *image)
       dcmFile = gdcm::FileHelper::New();
    
    // From here, the write of the file begins
-   
+
+
+   // Set the medical informations:
+   SetMedicalImageInformation(dcmFile, this->MedicalImageProperties);
+       
    // Set the image informations
    SetImageInformation(dcmFile, image);
 
index 548f8195fdc9a187a6d804332a6ace8baaf6d28b..305aede70d7bb13cb48d5c6bfb8cb63ae468746f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: vtkGdcmWriter.h,v $
   Language:  C++
-  Date:      $Date: 2006/03/17 14:46:18 $
-  Version:   $Revision: 1.7 $
+  Date:      $Date: 2006/05/02 10:09:43 $
+  Version:   $Revision: 1.8 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -39,6 +39,9 @@
 #define VTK_GDCM_WRITE_TYPE_UNMODIFIED_PIXELS_IMAGE 4
 
 //-----------------------------------------------------------------------------
+class vtkLookupTable;
+class vtkMedicalImageProperties;
+
 class VTK_EXPORT vtkGdcmWriter : public vtkImageWriter
 {
 public:
@@ -47,7 +50,8 @@ public:
 
    void PrintSelf(ostream &os, vtkIndent indent);
 
-   vtkSetObjectMacro(LookupTable, vtkLookupTable);
+   //vtkSetObjectMacro(LookupTable, vtkLookupTable);
+   virtual void SetLookupTable(vtkLookupTable*);
    vtkGetObjectMacro(LookupTable, vtkLookupTable);
 
    void SetWriteTypeToDcmImplVR(){SetWriteType(VTK_GDCM_WRITE_TYPE_EXPLICIT_VR);};
@@ -64,6 +68,7 @@ public:
    vtkGetMacro(WriteType, int);
    const char *GetWriteTypeAsString();
 
+
 //BTX
    vtkSetMacro(GdcmFile, gdcm::File *);
    vtkGetMacro(GdcmFile, gdcm::File *);
@@ -72,7 +77,15 @@ public:
    vtkSetMacro(ContentType, int);
    vtkGetMacro(ContentType, int);
 
-     
+   // Description:
+   // To pass in some extra information from a VTK context a user can pass a
+   // vtkMedicalImageProperties object
+#if (VTK_MAJOR_VERSION >= 5)   
+   void SetMedicalImageProperties(vtkMedicalImageProperties*);
+#else
+   void SetMedicalImageProperties(vtkMedicalImageProperties*) {}
+#endif
+        
 protected:
    vtkGdcmWriter();
    ~vtkGdcmWriter();
@@ -85,6 +98,7 @@ protected:
 private:
 // Variables
    vtkLookupTable *LookupTable;
+   vtkMedicalImageProperties *MedicalImageProperties;   
    int WriteType;
 //BTX
    gdcm::File *GdcmFile;
index ccac0d7c16ef68a8c8f2568845337cad84724d28..9898911124b04336b3d99f51d15db16be7e16144 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: vtkgdcmViewer2.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/03/17 14:46:18 $
-  Version:   $Revision: 1.6 $
+  Date:      $Date: 2006/05/02 10:09:43 $
+  Version:   $Revision: 1.7 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -68,10 +68,19 @@ public:
       {
          if ( event == vtkCommand::CharEvent )
          {
+ #if (VTK_MAJOR_VERSION >= 5)
+            int max = ImageViewer->GetSliceMax();
+            int slice = (ImageViewer->GetSlice() + 1 ) % ++max;
+            ImageViewer->SetSlice( slice );
+#else
             int max = ImageViewer->GetWholeZMax();
             int slice = (ImageViewer->GetZSlice() + 1 ) % ++max;
             ImageViewer->SetZSlice( slice );
+#endif
+#if !( (VTK_MAJOR_VERSION >= 5) || ( VTK_MAJOR_VERSION == 4 && VTK_MINOR_VERSION >= 5 ) )
+          // This used to be a bug in version VTK 4.4 and earlier    
             ImageViewer->GetRenderer()->ResetCameraClippingRange();
+#endif
             ImageViewer->Render();
          }
       }