X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FmaracasVisuLib%2Fsrc%2Finterface%2FwxWindows%2Fwidgets%2FimageUndoRedo%2FimageInfoUR.cxx;fp=lib%2FmaracasVisuLib%2Fsrc%2Finterface%2FwxWindows%2Fwidgets%2FimageUndoRedo%2FimageInfoUR.cxx;h=b45e21d920915b8e27a58880380875b090ab85c2;hb=8185e042f64574ca43bba733ec2158a2aa994220;hp=0000000000000000000000000000000000000000;hpb=dfc9348c40926b0c402e8b285749a24de5e567ce;p=creaMaracasVisu.git diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageInfoUR.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageInfoUR.cxx new file mode 100755 index 0000000..b45e21d --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageInfoUR.cxx @@ -0,0 +1,73 @@ +/* + * ImageInfo.cxx + * + * Created on: Sep 22, 2011 + * Author: caceres + */ +#include "imageInfoUR.h" + +ImageInfoUR::ImageInfoUR() { + this->m_Image = NULL; + this->m_OnMemory = false; + this->m_OnDisk = false; +} + +ImageInfoUR::~ImageInfoUR() { + this->m_Image->Delete(); +} + +void ImageInfoUR::SetImageName(const std::string &imgName) { + this->m_ImageName = imgName; +} +void ImageInfoUR::SetRegion(const RegionStructUR ®ion) { + this->m_Region = region; +} +void ImageInfoUR::SetStatus(const bool& onMemory) { + this->m_OnMemory = onMemory; +} +void ImageInfoUR::SetImage(vtkImageData* img) { + this->m_Image = img; + this->SetStatus(true); +} +std::string ImageInfoUR::GetImageName() { + return (this->m_ImageName); +} +RegionStructUR ImageInfoUR::GetRegion() { + return (this->m_Region); +} +bool ImageInfoUR::GetStatus() { + return (this->m_OnMemory); +} +void ImageInfoUR::RemoveImageFromMemory(const std::string& gPath) { + if (!this->m_OnDisk) { + this->SaveImageAsMHD(gPath); + } + this->m_Image->Delete(); + this->SetStatus(false); +} +void ImageInfoUR::LoadImageMHDToMemory(const std::string& gPath) { + std::string filename = gPath + this->m_ImageName; + vtkSmartPointer reader = vtkSmartPointer< + vtkMetaImageReader>::New(); + reader->SetFileName(filename.c_str()); + this->m_Image = reader->GetOutput(); + this->m_OnMemory = true; +} +void ImageInfoUR::SaveImageAsMHD(const std::string& gPath) { + this->m_OnDisk = true; + std::string filename = gPath + this->m_ImageName; + vtkSmartPointer w = + vtkSmartPointer::New(); + w->SetInput(this->m_Image); + w->SetCompression(false); + w->SetFileDimensionality(this->m_Image->GetDataDimension()); + w->SetFileName(filename.c_str()); + w->Update(); + w->Write(); + w->Delete(); +} + +void ImageInfoUR::RemoveImageFromDisk(const std::string& gPath) +{ + +}