]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/CutModule/kernel/CutModel2Manager.cxx
*** empty log message ***
[creaMaracasVisu.git] / lib / maracasVisuLib / src / CutModule / kernel / CutModel2Manager.cxx
index 0cbe88a55e951ad9fd6bc27464a5eecd9d425566..6e00b2f52fb8f7f78be8fa07b10ec5ca8ad56d28 100644 (file)
@@ -3,8 +3,8 @@
   Program:   wxMaracas
   Module:    $RCSfile: CutModel2Manager.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/11/23 13:00:30 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2009/12/08 13:42:39 $
+  Version:   $Revision: 1.4 $
 
   Copyright: (c) 2002, 2003
   License:
@@ -22,7 +22,7 @@
 CutModel2Manager::CutModel2Manager(std::string path){
        _path = path;
        _img = NULL;
-       _copyimg = NULL;
+       _img2 = NULL;
        _interactor = NULL;     
        _render = NULL;
        _currentaction=0;
@@ -31,20 +31,25 @@ CutModel2Manager::~CutModel2Manager(){
        std::string files = _path;
     files+="/infounrd_0_fig_0.info";   
        remove(files.c_str());
+       _vectordata.clear();
+       _img = NULL;
+       _img2 = NULL;
+       _interactor = NULL;     
+       _render = NULL;
 }
 
 
 void CutModel2Manager::setImageData(vtkImageData* img){
     _img = img;
-       if(_copyimg!=NULL){
-               _copyimg->Delete();
+       if(_img2!=NULL){
+               _img2->Delete();
        }
-       _copyimg = vtkImageData::New();
-       _copyimg->SetExtent(_img->GetExtent());
-       _copyimg->SetSpacing(_img->GetSpacing());
-       _copyimg->AllocateScalars();
+       _img2 = vtkImageData::New();
+       _img2->SetExtent(_img->GetExtent());
+       _img2->SetSpacing(_img->GetSpacing());
+       _img2->AllocateScalars();
 
-       _copyimg->DeepCopy(_img);
+       _img2->DeepCopy(_img);
 
 }
 
@@ -59,8 +64,7 @@ void CutModel2Manager::setRenderer(vtkRenderer* renderer){
 void CutModel2Manager::onAddCutModel2(int id, vtkCommand* observer) throw( CutModelException){
        checkInvariant();
 
-       
-       CutModelData* data = new CutModelData(id,_interactor, observer, _copyimg);
+       CutModelData* data = new CutModelData(id,_interactor, observer, _img2);
        _vectordata.push_back(data);
 
        _render->AddActor(data->getActor());
@@ -73,7 +77,7 @@ void CutModel2Manager::checkInvariant() throw( CutModelException){
        if(_img==NULL){
                throw CutModelException("The image is not set");
        }
-       if(_copyimg==NULL){
+       if(_img2==NULL){
                throw CutModelException("The copyimage is not set");
        }
        if(_interactor==NULL){
@@ -86,7 +90,7 @@ void CutModel2Manager::checkInvariant() throw( CutModelException){
 
 double* CutModel2Manager::getImageRange()throw( CutModelException){
        checkInvariant();
-       return _copyimg->GetScalarRange();
+       return _img2->GetScalarRange();
 }
 
 void CutModel2Manager::changeOpacity(int id,int opacity)throw( CutModelException){
@@ -178,7 +182,7 @@ void CutModel2Manager::ExecuteCut(int id, double* range, bool isinside)throw( Cu
 
 vtkImageData* CutModel2Manager::GetResultImage(){
         checkInvariant();
-     return _copyimg;
+     return _img2;
 }
 
 void CutModel2Manager::RefreshActor(int id){
@@ -246,7 +250,7 @@ int CutModel2Manager::Undo()        throw( CutModelException){
 
                        currentmodel->setCurrentShape(currentundo->getCurrentShape());
 
-                       currentmodel->ExecuteUnCut(currentundo->getIsInside(), _copyimg, _img);
+                       currentmodel->ExecuteUnCut(currentundo->getIsInside(), _img2, _img);
 
                }
                //Every thing ok
@@ -268,9 +272,9 @@ int CutModel2Manager::Redo()        throw( CutModelException){
                        //Redo the cut
                        vtkTransform* transform = currentundo->getTransformFromMatrixFile();
                        currentmodel = getCutModelData(currentundo->getId());
-                       currentmodel->setTransform(transform, _copyimg);
+                       currentmodel->setTransform(transform, _img2);
                        currentmodel->setCurrentShape(currentundo->getCurrentShape());
-                       currentmodel->ExecuteCut(currentundo->getRange(), currentundo->getIsInside(), _copyimg);
+                       currentmodel->ExecuteCut(currentundo->getRange(), currentundo->getIsInside(), _img2);
                }
 
                _currentaction++;