]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.cxx
#3358 creaMaracasVisu Feature New Normal - Box::ColorLayerImageView Change informat...
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / imageUndoRedo / image3DDequeUR.cxx
index cac5bd6507bd95ee5c44149bbddaeee6cf3a9268..a9bc413c4316e51546da57dc58c730845cd2238a 100755 (executable)
 #include "image3DDequeUR.h"
 #include <iostream>
 #include <sstream>
+#include <ctime>
 
 // ----------------------------------------------------------------------------------
 Image3DDequeUR::Image3DDequeUR( )
 {
-
+       const void * address = static_cast<const void*>(this);
+       std::stringstream ss;
+       ss << address;  
+       m_PrivateID = ss.str(); 
 
 #ifdef _WIN32
        this->m_GlobalPath = std::getenv("TEMP");
@@ -51,12 +55,14 @@ Image3DDequeUR::Image3DDequeUR( )
 #endif // MACOSX
        this->m_CurrentURPos = -1;
 }
+
 // ----------------------------------------------------------------------------------
 //virtual
 Image3DDequeUR::~Image3DDequeUR( )
 {
        this->CleanHardDisk( );
 }
+
 // ----------------------------------------------------------------------------------
 //virtual
 void Image3DDequeUR::AddImagesToURContainer( VTKImageDataPointerType imgUndo,
@@ -68,12 +74,14 @@ void Image3DDequeUR::AddImagesToURContainer( VTKImageDataPointerType imgUndo,
        imageInfo->SetImageName( this->GetImageName( this->m_ImgURDeque.size( ) ) );
        imageInfo->SetImages( imgUndo, imgRedo );
        imageInfo->SetImageMManager( imMManager );
+       
        //Adding to deque
        this->m_ImgURDeque.push_back( imageInfo );
        this->m_CurrentURPos = this->m_ImgURDeque.size( ) - 1;
        //Managing memory
        this->ManageMemory( );
 }
+
 // ----------------------------------------------------------------------------------
 //virtual
 ImageInfoUR* Image3DDequeUR::Undo( )
@@ -88,6 +96,7 @@ ImageInfoUR* Image3DDequeUR::Undo( )
        } //fi
        return ( imgRet );
 }
+
 // ----------------------------------------------------------------------------------
 //virtual
 ImageInfoUR* Image3DDequeUR::Redo( )
@@ -99,13 +108,12 @@ ImageInfoUR* Image3DDequeUR::Redo( )
                && ( this->m_CurrentURPos < imgURDequeSize ) )
        {
                imgRet = this->m_ImgURDeque[ m_CurrentURPos ];
-       } //fi
-       else
-       {
+       } else {
                this->m_CurrentURPos--;
        }
        return ( imgRet );
 }
+
 // ----------------------------------------------------------------------------------
 //virtual
 void Image3DDequeUR::CleanURContainerFromIndex( const int& index )
@@ -122,39 +130,38 @@ void Image3DDequeUR::CleanURContainerFromIndex( const int& index )
                this->m_ImgURDeque.pop_back( );
        } //rof
 }
+
 // ----------------------------------------------------------------------------------
 //virtual
 void Image3DDequeUR::ManageMemory( )
 {
        int imgURDequeSize = this->m_ImgURDeque.size( );
-       for( int i = 0; i < imgURDequeSize; i++ )
+       int i;
+       for( i = 0; i < imgURDequeSize; i++ )
        {
                if( this->m_ImgURDeque[ i ]->GetStatus( ) )
                {
-                       this->m_ImgURDeque[ i ]->RemoveImagesFromMemory(
-                               this->m_GlobalPath );
-               } //fi
-       } //rof
+                       this->m_ImgURDeque[ i ]->RemoveImagesFromMemory( this->m_GlobalPath );
+               } // if Status
+       } // for i
          //Adding CurrentUndoPos to memory
-       if( ( this->m_CurrentURPos != -1 )
-               && !( this->m_ImgURDeque[ this->m_CurrentURPos ]->GetStatus( ) ) )
+       if( ( this->m_CurrentURPos != -1 ) && !( this->m_ImgURDeque[ this->m_CurrentURPos ]->GetStatus( ) ) )
        {
-               this->m_ImgURDeque[ this->m_CurrentURPos ]->LoadImagesToMemory(
-                       this->m_GlobalPath );
+               this->m_ImgURDeque[ this->m_CurrentURPos ]->LoadImagesToMemory( this->m_GlobalPath );
        }
        int currentRedoPos = this->m_CurrentURPos + 1;
-       if( ( currentRedoPos < imgURDequeSize )
-               && !( this->m_ImgURDeque[ currentRedoPos ]->GetStatus( ) ) )
+       if( ( currentRedoPos < imgURDequeSize ) && !( this->m_ImgURDeque[ currentRedoPos ]->GetStatus( ) ) )
        {
-               this->m_ImgURDeque[ currentRedoPos ]->LoadImagesToMemory(
-                       this->m_GlobalPath );
+               this->m_ImgURDeque[ currentRedoPos ]->LoadImagesToMemory( this->m_GlobalPath );
        }
 }
+
 // ----------------------------------------------------------------------------------
 void Image3DDequeUR::SetGlobalPath( const StringType& globalPath )
 {
        this->m_GlobalPath = globalPath;
 }
+
 // ----------------------------------------------------------------------------------
 void Image3DDequeUR::CleanHardDisk( )
 {
@@ -163,20 +170,22 @@ void Image3DDequeUR::CleanHardDisk( )
                this->m_ImgURDeque[ i ]->RemoveImagesFromDisk( this->m_GlobalPath );
        }
 }
+
 // ----------------------------------------------------------------------------------
 Image3DDequeUR::StringType Image3DDequeUR::GetGlobalPath( )
 {
        return ( this->m_GlobalPath );
 }
+
 // ----------------------------------------------------------------------------------
 Image3DDequeUR::StringType Image3DDequeUR::GetImageName( const int & pos )
 {
 //Giving a name to an image using the date and time
        if( this->m_IDImages.empty( ) )
        {
-               time_t rawtime;
-               struct tm timeinfo;
-               char buffer[ 80 ];
+               time_t          rawtime;
+               struct tm       *timeinfo;
+               char            buffer[ 80 ];
                time( &rawtime );
                timeinfo = localtime( &rawtime );
                strftime( buffer, 80, "%H%M%S_%a_%d_%b_%y_", timeinfo );
@@ -186,7 +195,8 @@ Image3DDequeUR::StringType Image3DDequeUR::GetImageName( const int & pos )
        }
        std::stringstream ss; //create a stringstream
        ss << pos; //add number to the stream
-       StringType imageName = this->m_IDImages + ss.str( );
+       StringType imageName = this->m_IDImages + ss.str( )+ "_"+m_PrivateID;
        return ( imageName );
 }
+
 // ----------------------------------------------------------------------------------