From 470223c6fe3a156ce3ffea50da88dc4d2aba6115 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Mon, 6 Jan 2020 12:08:30 +0100 Subject: [PATCH] #3332 creaContours Bug New - Manual Paint UnDo ReDo with vtk update (working) --- bbtk/src/bbcreaMaracasVisuManualPaint.cxx | 15 ++-- bbtk/src/bbcreaMaracasVisuSetPosition.cxx | 6 +- .../widgets/imageUndoRedo/image3DDequeUR.cxx | 40 +++++---- .../widgets/imageUndoRedo/image3DDequeUR.h | 13 +-- .../widgets/imageUndoRedo/imageDequeUR.cxx | 35 +++++--- .../widgets/imageUndoRedo/imageDequeUR.h | 12 +-- .../widgets/imageUndoRedo/imageInfoUR.cxx | 50 ++++++++--- .../imageModificationManager.cxx | 62 ++++++------- .../imageUndoRedo/imageModificationManager.h | 3 +- .../widgets/imageUndoRedo/imageUndoRedo.cxx | 44 ++++++--- .../widgets/imageUndoRedo/imageUndoRedo.h | 6 +- .../widgets/imageUndoRedo/managerUR.cxx | 35 +++++--- .../widgets/manualPaint/BrushFilter.cpp | 44 +++------ .../widgets/manualPaint/FillFilter.cpp | 16 ++-- .../manualPaint/ManualPaintControler.cpp | 90 ++++++++++++++----- .../manualPaint/ManualPaintControler.h | 20 +++-- .../widgets/manualPaint/ManualPaintModel.cpp | 8 +- .../widgets/manualPaint/ManualPaintModel.h | 10 +-- .../widgets/manualPaint/ManualPaintPanel.cpp | 50 +++++------ .../widgets/manualPaint/ManualPaintPanel.h | 6 +- .../manualPaint/vtkInteractorManualPaint.cpp | 25 ++---- .../manualPaint/wxManualPaintPanel.cpp | 69 +++++++------- .../widgets/manualPaint/wxManualPaintPanel.h | 39 ++++---- 23 files changed, 379 insertions(+), 319 deletions(-) diff --git a/bbtk/src/bbcreaMaracasVisuManualPaint.cxx b/bbtk/src/bbcreaMaracasVisuManualPaint.cxx index d5373bf..ea86236 100644 --- a/bbtk/src/bbcreaMaracasVisuManualPaint.cxx +++ b/bbtk/src/bbcreaMaracasVisuManualPaint.cxx @@ -84,43 +84,46 @@ void ManualPaint::Process() ManualPaintModel *mpModel = new ManualPaintModel(); mpModel->SetImages( bbGetInputIn() , bbGetInputIn2() ); - wxManualPaintPanel *mpPanel = (wxManualPaintPanel*)bbGetOutputWidget(); - mpPanel->SetManualPaintModel(mpModel); + wxManualPaintPanel *mpPanel = (wxManualPaintPanel*)bbGetOutputWidget(); if (bbGetInputWxVtkBaseView1()!=NULL) { ManualPaintControler *mpControler = new ManualPaintControler(); mpControler->SetManualPaintModel(mpModel); - mpControler->SetManualPaintPanel(mpPanel); +// mpControler->SetManualPaintPanel(mpPanel); mpControler->SetWxVtk2DBaseView( (wxVtk2DBaseView*)bbGetInputWxVtkBaseView1() ); mpControler->Config(); + mpPanel->SetManualPaintControler(mpControler); } if (bbGetInputWxVtkBaseView2()!=NULL) { ManualPaintControler *mpControler = new ManualPaintControler(); mpControler->SetManualPaintModel(mpModel); - mpControler->SetManualPaintPanel(mpPanel); +// mpControler->SetManualPaintPanel(mpPanel); mpControler->SetWxVtk2DBaseView( (wxVtk2DBaseView*)bbGetInputWxVtkBaseView2() ); mpControler->Config(); + mpPanel->SetManualPaintControler(mpControler); } if (bbGetInputWxVtkBaseView3()!=NULL) { ManualPaintControler *mpControler = new ManualPaintControler(); mpControler->SetManualPaintModel(mpModel); - mpControler->SetManualPaintPanel(mpPanel); +// mpControler->SetManualPaintPanel(mpPanel); mpControler->SetWxVtk2DBaseView( (wxVtk2DBaseView*)bbGetInputWxVtkBaseView3() ); mpControler->Config(); + mpPanel->SetManualPaintControler(mpControler); } if (bbGetInputWxVtkBaseView4()!=NULL) { ManualPaintControler *mpControler = new ManualPaintControler(); mpControler->SetManualPaintModel(mpModel); - mpControler->SetManualPaintPanel(mpPanel); +// mpControler->SetManualPaintPanel(mpPanel); mpControler->SetWxVtk2DBaseView( (wxVtk2DBaseView*)bbGetInputWxVtkBaseView4() ); mpControler->Config(); + mpPanel->SetManualPaintControler(mpControler); } } // firsttime diff --git a/bbtk/src/bbcreaMaracasVisuSetPosition.cxx b/bbtk/src/bbcreaMaracasVisuSetPosition.cxx index d9a57e1..1a45b0c 100644 --- a/bbtk/src/bbcreaMaracasVisuSetPosition.cxx +++ b/bbtk/src/bbcreaMaracasVisuSetPosition.cxx @@ -41,15 +41,13 @@ void SetPosition::Process() vtkmprbasedata->SetX( bbGetInputPoint()[0] ); vtkmprbasedata->SetY( bbGetInputPoint()[1] ); vtkmprbasedata->SetZ( bbGetInputPoint()[2] ); - wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,12121); // Refres + wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 #if wxMAJOR_VERSION <= 2 bbGetInputwxVtkBaseView()->GetWxVTKRenderWindowInteractor ()->GetParent()->ProcessEvent( newevent ); #else bbGetInputwxVtkBaseView()->GetWxVTKRenderWindowInteractor ()->GetParent()->ProcessWindowEvent( newevent ); -#endif - - +#endif } // if bbGetInputPosition } // bbGetInputwxVtkBaseView } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.cxx index cac5bd6..ab6b614 100755 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.cxx @@ -34,12 +34,11 @@ #include "image3DDequeUR.h" #include #include +#include // ---------------------------------------------------------------------------------- Image3DDequeUR::Image3DDequeUR( ) { - - #ifdef _WIN32 this->m_GlobalPath = std::getenv("TEMP"); #endif @@ -51,12 +50,14 @@ Image3DDequeUR::Image3DDequeUR( ) #endif // MACOSX this->m_CurrentURPos = -1; } + // ---------------------------------------------------------------------------------- //virtual Image3DDequeUR::~Image3DDequeUR( ) { this->CleanHardDisk( ); } + // ---------------------------------------------------------------------------------- //virtual void Image3DDequeUR::AddImagesToURContainer( VTKImageDataPointerType imgUndo, @@ -74,6 +75,7 @@ void Image3DDequeUR::AddImagesToURContainer( VTKImageDataPointerType imgUndo, //Managing memory this->ManageMemory( ); } + // ---------------------------------------------------------------------------------- //virtual ImageInfoUR* Image3DDequeUR::Undo( ) @@ -88,6 +90,7 @@ ImageInfoUR* Image3DDequeUR::Undo( ) } //fi return ( imgRet ); } + // ---------------------------------------------------------------------------------- //virtual ImageInfoUR* Image3DDequeUR::Redo( ) @@ -99,13 +102,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 +124,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,11 +164,13 @@ 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 ) { @@ -189,4 +192,5 @@ Image3DDequeUR::StringType Image3DDequeUR::GetImageName( const int & pos ) StringType imageName = this->m_IDImages + ss.str( ); return ( imageName ); } + // ---------------------------------------------------------------------------------- diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.h index ddebb56..b013172 100755 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/image3DDequeUR.h @@ -34,8 +34,11 @@ #ifndef IMAGE3DDEQUEUR_H_ #define IMAGE3DDEQUEUR_H_ +#include + #include "imageDequeUR.h" -#include + + /*! @class Image3DDequeUR image3DDequeUR.h "image3DDequeUR.cxx" * @brief This class contains the management of the undo/redo deque - Concrete Class @@ -121,10 +124,10 @@ public: void CleanHardDisk(); // ---------------------------------------------------------------------------------- protected: - ImageInfoDeque m_ImgURDeque; //! -#include -#include -#include -#include #include "imageInfoUR.h" -#include "imageModificationManager.h" + +//#include +//#include +//#include +//#include +//#include "imageModificationManager.h" /*! @class ImageDequeUR imageDequeUR.h "imageDequeUR.cxx" * @brief This class contains the management of the undo/redo - Abstract Class diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageInfoUR.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageInfoUR.cxx index fd66857..ca2f435 100755 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageInfoUR.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageInfoUR.cxx @@ -36,53 +36,63 @@ // ---------------------------------------------------------------------------------- ImageInfoUR::ImageInfoUR() { - this->m_OnMemory = false; - this->m_OnDisk = false; + this->m_OnMemory = false; + this->m_OnDisk = false; } + // ---------------------------------------------------------------------------------- ImageInfoUR::~ImageInfoUR() { } + // ---------------------------------------------------------------------------------- void ImageInfoUR::SetImageName(const StringType &imgName) { - this->m_ImageName = imgName; + this->m_ImageName = imgName; } + // ---------------------------------------------------------------------------------- void ImageInfoUR::SetImageMManager(ImageMManagerType* imMManager) { - this->m_ImageMManager = imMManager; + this->m_ImageMManager = imMManager; } + // ---------------------------------------------------------------------------------- void ImageInfoUR::SetStatus(const bool& onMemory) { - this->m_OnMemory = onMemory; + this->m_OnMemory = onMemory; } + // ---------------------------------------------------------------------------------- ImageInfoUR::StringType ImageInfoUR::GetImageName() { return (this->m_ImageName); } + // ---------------------------------------------------------------------------------- ImageInfoUR::VTKImageDataPointerType ImageInfoUR::GetUndoImage() { return (this->m_UndoImage); } + // ---------------------------------------------------------------------------------- ImageInfoUR::VTKImageDataPointerType ImageInfoUR::GetRedoImage() { return (this->m_RedoImage); } + // ---------------------------------------------------------------------------------- ImageInfoUR::ImageMManagerType* ImageInfoUR::GetImageMManager() { return (this->m_ImageMManager); } + // ---------------------------------------------------------------------------------- bool ImageInfoUR::GetStatus() { return (this->m_OnMemory); } + // ---------------------------------------------------------------------------------- void ImageInfoUR::SetImages(VTKImageDataPointerType imgUndo, VTKImageDataPointerType imgRedo) { @@ -90,9 +100,11 @@ void ImageInfoUR::SetImages(VTKImageDataPointerType imgUndo, VTKImageDataPointer this->m_RedoImage = imgRedo; this->SetStatus(true); } + // ---------------------------------------------------------------------------------- void ImageInfoUR::LoadImagesToMemory(const StringType& gPath) { +printf("EED ImageInfoUR::LoadImagesToMemory Start\n"); //setting paths StringType filename = gPath + this->m_ImageName; StringType undoImagePath = filename + "_Undo.mhd"; @@ -100,12 +112,19 @@ void ImageInfoUR::LoadImagesToMemory(const StringType& gPath) //Loading Undo Image VTKMetaImageReaderPointerType readerUndo = VTKMetaImageReaderPointerType::New(); readerUndo->SetFileName(undoImagePath.c_str()); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 + // .. +#else + readerUndo->Update(); +#endif + this->m_UndoImage = readerUndo->GetOutput(); //EED 2017-01-01 Migration VTK7 #if VTK_MAJOR_VERSION <= 5 this->m_UndoImage->Update(); #else - // .. + this->m_UndoImage->Modified(); #endif //Loading Redo Image VTKMetaImageReaderPointerType readerRedo = VTKMetaImageReaderPointerType::New(); @@ -122,11 +141,15 @@ void ImageInfoUR::LoadImagesToMemory(const StringType& gPath) #if VTK_MAJOR_VERSION <= 5 this->m_RedoImage->Update(); #else - // ... + this->m_RedoImage->Modified(); #endif //Updating status this->m_OnMemory = true; + +printf("EED ImageInfoUR::LoadImagesToMemory End\n"); + } + // ---------------------------------------------------------------------------------- void ImageInfoUR::RemoveImagesFromMemory(const StringType& gPath) { @@ -138,22 +161,24 @@ void ImageInfoUR::RemoveImagesFromMemory(const StringType& gPath) this->m_RedoImage = NULL; this->SetStatus(false); } + // ---------------------------------------------------------------------------------- void ImageInfoUR::SaveImagesOnDisk(const StringType& gPath) { printf("EED ImageInfoUR::SaveImagesOnDisk Start \n"); - this->m_OnDisk = true; - StringType filename = gPath + this->m_ImageName; - StringType undoImagePath = filename + "_Undo.mhd"; - StringType redoImagePath = filename + "_Redo.mhd"; + this->m_OnDisk = true; + StringType filename = gPath + this->m_ImageName; + StringType undoImagePath = filename + "_Undo.mhd"; + StringType redoImagePath = filename + "_Redo.mhd"; this->SaveImageAsMHD(undoImagePath, this->m_UndoImage); this->SaveImageAsMHD(redoImagePath, this->m_RedoImage); printf("EED ImageInfoUR::SaveImagesOnDisk %s \n", undoImagePath.c_str() ); } + // ---------------------------------------------------------------------------------- void ImageInfoUR::RemoveImagesFromDisk(const StringType& gPath) { - StringType filename = gPath + this->m_ImageName; + StringType filename = gPath + this->m_ImageName; StringType undoImagePathMHD = filename + "_Undo.mhd"; StringType redoImagePathMHD = filename + "_Redo.mhd"; StringType undoImagePathRAW = filename + "_Undo.raw"; @@ -163,6 +188,7 @@ void ImageInfoUR::RemoveImagesFromDisk(const StringType& gPath) remove(undoImagePathRAW.c_str()); remove(redoImagePathRAW.c_str()); } + // ---------------------------------------------------------------------------------- void ImageInfoUR::SaveImageAsMHD(const StringType& filename, VTKImageDataPointerType image) { diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageModificationManager.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageModificationManager.cxx index 0bdcfde..32b0f69 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageModificationManager.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageModificationManager.cxx @@ -40,67 +40,57 @@ ImageMManager::ImageMManager() // ---------------------------------------------------------------------------------- ImageMManager::ImageMManager(ImageMManager* manager) { +printf("EED ImageMManager::ImageMManager Start\n"); this->m_RegionStruct = manager->GetModifiedRegion(); + this->m_ValidRegion = manager->ValidateRegion(); + +if (manager->ValidateRegion()==true) printf("EED ImageMManager::ImageMManager manager->ValidateRegion true \n"); +if (manager->ValidateRegion()==false) printf("EED ImageMManager::ImageMManager manager->ValidateRegion false \n"); +printf("EED ImageMManager::ImageMManager End\n"); } // ---------------------------------------------------------------------------------- ImageMManager::~ImageMManager() { } + // ---------------------------------------------------------------------------------- void ImageMManager::CleanModifiedRegion() { - int min = std::numeric_limits::min(); - int max = std::numeric_limits::max(); - this->m_RegionStruct.minX = max; - this->m_RegionStruct.maxX = min; - this->m_RegionStruct.minY = max; - this->m_RegionStruct.maxY = min; - this->m_RegionStruct.minZ = max; - this->m_RegionStruct.maxZ = min; - this->m_ValidRegion = false; + int min = std::numeric_limits::min(); + int max = std::numeric_limits::max(); + this->m_RegionStruct.minX = max; + this->m_RegionStruct.maxX = min; + this->m_RegionStruct.minY = max; + this->m_RegionStruct.maxY = min; + this->m_RegionStruct.minZ = max; + this->m_RegionStruct.maxZ = min; + this->m_ValidRegion = false; } + // ---------------------------------------------------------------------------------- void ImageMManager::CalculateMinMaxRegion(const int& i, const int& j, const int& k) { if (i >= 0 && j >= 0 && k >= 0) { - if (i <= this->m_RegionStruct.minX) - { - this->m_RegionStruct.minX = i; - } //fi - if (i > this->m_RegionStruct.maxX) - { - this->m_RegionStruct.maxX = i; - } //esle - if (j <= this->m_RegionStruct.minY) - { - this->m_RegionStruct.minY = j; - } //fi - if (j > this->m_RegionStruct.maxY) - { - this->m_RegionStruct.maxY = j; - } //esle - if (k <= this->m_RegionStruct.minZ) - { - this->m_RegionStruct.minZ = k; - } //fi - if (k > this->m_RegionStruct.maxZ) - { - this->m_RegionStruct.maxZ = k; - } //esle + if (i <= this->m_RegionStruct.minX) { this->m_RegionStruct.minX = i; } //fi + if (i > this->m_RegionStruct.maxX) { this->m_RegionStruct.maxX = i; } //esle + if (j <= this->m_RegionStruct.minY) { this->m_RegionStruct.minY = j; } //fi + if (j > this->m_RegionStruct.maxY) { this->m_RegionStruct.maxY = j; } //esle + if (k <= this->m_RegionStruct.minZ) { this->m_RegionStruct.minZ = k; } //fi + if (k > this->m_RegionStruct.maxZ) { this->m_RegionStruct.maxZ = k; } //esle this->m_ValidRegion = true; }else { this->m_ValidRegion = false; } // if i j k - if (m_ValidRegion ) printf(" ImageMManager::CalculateMinMaxRegion true \n"); - if (!m_ValidRegion ) printf(" ImageMManager::CalculateMinMaxRegion false \n"); +// if (m_ValidRegion ) printf(" ImageMManager::CalculateMinMaxRegion true \n"); +// if (!m_ValidRegion ) printf(" ImageMManager::CalculateMinMaxRegion false \n"); } // ---------------------------------------------------------------------------------- void ImageMManager::AddModifiedPixel(const int& i, const int& j, const int& k) { -printf("EED ImageMManager::AddModifiedPixel \n"); +//printf("EED ImageMManager::AddModifiedPixel \n"); this->CalculateMinMaxRegion(i, j, k); } // ---------------------------------------------------------------------------------- diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageModificationManager.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageModificationManager.h index 6ae156e..24ae8f7 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageModificationManager.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageModificationManager.h @@ -44,7 +44,8 @@ * @brief This class contains the modification manager of the undo/redo * @details This class contains the region and some information about the undo/redo */ -class ImageMManager { +class ImageMManager +{ public: // ---------------------------------------------------------------------------------- /*! @fn ImageMManager(); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.cxx index 698ac4f..0054735 100755 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.cxx @@ -48,12 +48,15 @@ ImageUndoRedo::~ImageUndoRedo( ) //virtual void ImageUndoRedo::Undo( ) { +printf("EED ImageUndoRedo::Undo Start\n"); ImageInfoUR* imageInfo = this->m_ImagesDeque->Undo( ); if( imageInfo != NULL) { this->DrawUR( imageInfo, true ); this->UpdateUndoImage( ); - } + } //if imageInfo +printf("EED ImageUndoRedo::Undo End\n"); + } // ---------------------------------------------------------------------------------- //virtual @@ -75,11 +78,12 @@ void ImageUndoRedo::SetImage( VTKImageDataPointerType image ) #if VTK_MAJOR_VERSION <= 5 this->m_CurrentImage->Update( ); #else - // .. + this->m_CurrentImage->Modified( ); #endif this->UpdateUndoImage( ); } + // ---------------------------------------------------------------------------------- //virtual void ImageUndoRedo::SetURImages( ImageMManagerType* imMManager ) @@ -96,6 +100,7 @@ void ImageUndoRedo::SetURImages( ImageMManagerType* imMManager ) std::cerr << "INVALID REGION" << std::endl; } } + // ---------------------------------------------------------------------------------- void ImageUndoRedo::UpdateUndoImage( ) { @@ -103,7 +108,7 @@ void ImageUndoRedo::UpdateUndoImage( ) #if VTK_MAJOR_VERSION <= 5 this->m_CurrentImage->Update( ); #else - // ... + this->m_CurrentImage->Modified( ); #endif this->m_UndoImage = VTKImageDataPointerType::New( ); this->m_UndoImage->DeepCopy( m_CurrentImage ); @@ -111,22 +116,26 @@ void ImageUndoRedo::UpdateUndoImage( ) #if VTK_MAJOR_VERSION <= 5 this->m_UndoImage->Update( ); #else - // .. + this->m_UndoImage->Modified( ); #endif } + // ---------------------------------------------------------------------------------- -ImageUndoRedo::VTKImageDataPointerType ImageUndoRedo::GetImageRegion( - const RegionSType& region, VTKImageDataPointerType img ) +ImageUndoRedo::VTKImageDataPointerType ImageUndoRedo::GetImageRegion( const RegionSType& region, VTKImageDataPointerType img ) { +printf("EED ImageUndoRedo::GetImageRegion Start\n"); VTKExtractVOIPointerType extract = VTKExtractVOIPointerType::New( ); - extract->SetVOI( region.minX, region.maxX, region.minY, region.maxY, - region.minZ, region.maxZ ); + extract->SetVOI( region.minX, region.maxX, region.minY, region.maxY,region.minZ, region.maxZ ); + +printf("EED ImageUndoRedo::GetImageRegion region %d %d %d %d %d %d\n", region.minX, region.maxX, region.minY, region.maxY,region.minZ, region.maxZ ); + extract->SetSampleRate( 1, 1, 1 ); //EED 2017-01-01 Migration VTK7 #if VTK_MAJOR_VERSION <= 5 extract->SetInput( img ); #else extract->SetInputData( img ); + extract->Update(); #endif VTKImageDataPointerType imgResult = extract->GetOutput( ); @@ -134,9 +143,10 @@ ImageUndoRedo::VTKImageDataPointerType ImageUndoRedo::GetImageRegion( #if VTK_MAJOR_VERSION <= 5 imgResult->Update( ); #else - // .. + imgResult->Modified( ); #endif +printf("EED ImageUndoRedo::GetImageRegion End\n"); return ( imgResult ); } // ---------------------------------------------------------------------------------- @@ -148,6 +158,7 @@ void ImageUndoRedo::SetCurrentImage( VTKImageDataPointerType img ) //virtual void ImageUndoRedo::DrawUR( ImageInfoUR* imageInfo, const bool& undo ) { +printf("EED ImageUndoRedo::DrawUR Start\n"); VTKImageDataPointerType img; if( undo ) { @@ -158,20 +169,25 @@ void ImageUndoRedo::DrawUR( ImageInfoUR* imageInfo, const bool& undo ) RegionSType region = imageInfo->GetImageMManager( )->GetModifiedRegion( ); if( img != NULL) { - int *dim = img->GetDimensions( ); - int sizeXImageIn = dim[ 0 ]; - size_t linesize = sizeXImageIn * sizeof(unsigned short); + int *dim = img->GetDimensions( ); +printf("EED ImageUndoRedo::DrawUR dim = %d %d %d\n", dim[0],dim[1],dim[2]); + int ext[6]; img->GetExtent( ext ); +printf("EED ImageUndoRedo::DrawUR ext = %d %d %d %d %d %d\n", ext[0],ext[1],ext[2],ext[3],ext[4],ext[5] ); + + int sizeXImageIn = dim[ 0 ]; + size_t linesize = sizeXImageIn * sizeof(unsigned short); for( int j = region.minY, y = 0; j <= region.maxY; j++, y++ ) { for( int k = region.minZ, z = 0; k <= region.maxZ; k++, z++ ) { - void* ptrsrc = img->GetScalarPointer( 0, y, z ); - void* ptrdest = this->m_CurrentImage->GetScalarPointer( region.minX, j, k ); + void* ptrsrc = img->GetScalarPointer( 0, y, z ); + void* ptrdest = this->m_CurrentImage->GetScalarPointer( region.minX, j, k ); memcpy( ptrdest, ptrsrc, linesize ); } // for k } // for j this->m_CurrentImage->Modified( ); } // if img this->m_ImagesDeque->ManageMemory( ); +printf("EED ImageUndoRedo::DrawUR End\n"); } // ---------------------------------------------------------------------------------- diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.h index 21f1a17..defc487 100755 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/imageUndoRedo/imageUndoRedo.h @@ -107,9 +107,9 @@ protected: // ---------------------------------------------------------------------------------- protected: - IDequeType* m_ImagesDeque; //! _maxX) { - maxX = _maxX; - } + if (_2D3D == 1) { } // 3D - if (maxY > _maxY) { - maxY = _maxY; - } + if (minX < _minX) { minX = _minX; } + if (minY < _minY) { minY = _minY; } - if (maxZ > _maxZ) { - maxZ = _maxZ; - } + if (minZ < _minZ) { minZ = _minZ; } + if (maxX > _maxX) { maxX = _maxX; } + if (maxY > _maxY) { maxY = _maxY; } + if (maxZ > _maxZ) { maxZ = _maxZ; } //-- SetGeneralMinMax(minX, maxX, minY, maxY, minZ, maxZ); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp index 476a235..d584e3a 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/FillFilter.cpp @@ -32,8 +32,8 @@ FillFilter::FillFilter() { - _tolerancefill = 50; - _distancefill = 500; + _tolerancefill = 125; + _distancefill = 5; /* _limitRecursionFill = 50000; */ @@ -77,7 +77,6 @@ void FillFilter::SetImages(vtkImageData *image,vtkImageData *image2) // virtual } unsigned char * ptrAuxImageFill = (unsigned char *)_auxImageFill->GetScalarPointer(); memset(ptrAuxImageFill, 0, (_maxX+1) * (_maxY+1) * (_maxZ+1) ); - _maxXback=_maxX; _maxYback=_maxY; _maxZback=_maxZ; @@ -199,6 +198,9 @@ void FillFilter::FillToolLoop(int px, int py, int pz,long int iviA) if (_auxGrayLevelValidationFill) { + + this->_IMManager->AddModifiedPixel(lstX[0], lstY[0], lstZ[0]); //DFCH + // Modifie image if (_image2!=NULL) { @@ -247,15 +249,7 @@ void FillFilter::FillToolLoop(int px, int py, int pz,long int iviA) lstX.push_back(lstX[0] ); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0]+1); lstivi.push_back( lstivi[0]+_OnePlane); lstX.push_back(lstX[0] ); lstY.push_back(lstY[0] ); lstZ.push_back(lstZ[0]-1); lstivi.push_back( lstivi[0]-_OnePlane); } // 2D 3D - - - - - - - } // if gray level valid _auxGrayLevelValidationFill - } // if point not visited // Add point to already visited SETVALUE2_VTK_CREA(1,p_auxImageFill,st_auxImageFill,lstivi[0]); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintControler.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintControler.cpp index b79b32d..4674d2d 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintControler.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintControler.cpp @@ -23,52 +23,63 @@ # knowledge of the CeCILL-B license and that you accept its terms. # ------------------------------------------------------------------------ */ +#include + #include "ManualPaintControler.h" #include "vtkInteractorManualPaint.h" #include "vtkImageActor.h" //--------------------------------------------------------------------------- -ManualPaintControler::ManualPaintControler() { - auxZ = 0; - _wxvtk2Dbaseview = NULL; +ManualPaintControler::ManualPaintControler() +{ + auxZ = 0; + _wxvtk2Dbaseview = NULL; } //--------------------------------------------------------------------------- -ManualPaintControler::~ManualPaintControler() { +ManualPaintControler::~ManualPaintControler() +{ } //--------------------------------------------------------------------------- -void ManualPaintControler::SetManualPaintModel( - ManualPaintModel* manualPaintModel) { - _manualPaintModel = manualPaintModel; +void ManualPaintControler::SetManualPaintModel( ManualPaintModel* manualPaintModel ) +{ + _manualPaintModel = manualPaintModel; } //--------------------------------------------------------------------------- -void ManualPaintControler::SetManualPaintPanel( - ManualPaintPanel* manualPaintPanel) { - _manualPaintPanel = manualPaintPanel; +ManualPaintModel* ManualPaintControler::GetManualPaintModel( ) +{ + return _manualPaintModel; } //--------------------------------------------------------------------------- -void ManualPaintControler::SetWxVtk2DBaseView( - wxVtk2DBaseView *wxvtk2Dbaseview) { - _wxvtk2Dbaseview = wxvtk2Dbaseview; +//void ManualPaintControler::SetManualPaintPanel( ManualPaintPanel* manualPaintPanel ) +//{ +// _manualPaintPanel = manualPaintPanel; +//} + +//--------------------------------------------------------------------------- +void ManualPaintControler::SetWxVtk2DBaseView( wxVtk2DBaseView *wxvtk2Dbaseview ) +{ + _wxvtk2Dbaseview = wxvtk2Dbaseview; } //--------------------------------------------------------------------------- -void ManualPaintControler::Config() { - if (_wxvtk2Dbaseview != NULL) { - vtkInteractorStyleBaseView *isbv = - (vtkInteractorStyleBaseView*) (_wxvtk2Dbaseview->GetInteractorStyleBaseView()); +void ManualPaintControler::Config() +{ + if (_wxvtk2Dbaseview != NULL) + { + vtkInteractorStyleBaseView *isbv = (vtkInteractorStyleBaseView*) (_wxvtk2Dbaseview->GetInteractorStyleBaseView()); isbv->AddInteractorStyleMaracas(new vtkInteractorManualPaint(this)); - } + } // if _wxvtk2Dbaseview } //--------------------------------------------------------------------------- -void ManualPaintControler::PaintImage(int px, int py, int pz) { +void ManualPaintControler::PaintImage(int px, int py, int pz) +{ _manualPaintModel->SetDirection(_wxvtk2Dbaseview->GetDirection()); _manualPaintModel->PaintImage(px, py, pz); - // The refresh mechanisme is made in the vtkInteractorManualPaint // RefreshView(); } @@ -78,3 +89,42 @@ void ManualPaintControler::SetImageUndo() { _manualPaintModel->SetUndoImage(); } + + + +//--------------------------------------------------------------------------- +void ManualPaintControler::Undo() +{ + _manualPaintModel->Undo(); + Refresh(); +} + +void ManualPaintControler::Redo() +{ + _manualPaintModel->Redo(); + Refresh(); +} + + +void ManualPaintControler::Refresh() +{ + if (_wxvtk2Dbaseview!=NULL) + { + vtkMPRBaseData* vtkmprbasedata = (vtkMPRBaseData*) (_wxvtk2Dbaseview->GetVtkBaseData()); +// if (bbGetInputPoint().size()==3) +// { +// vtkmprbasedata->SetX( bbGetInputPoint()[0] ); +// vtkmprbasedata->SetY( bbGetInputPoint()[1] ); +// vtkmprbasedata->SetZ( bbGetInputPoint()[2] ); + wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,12121); // Refresh +//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 +#if wxMAJOR_VERSION <= 2 + _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor ()->GetParent()->ProcessEvent( newevent ); +#else + _wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor ()->GetParent()->ProcessWindowEvent( newevent ); +#endif +// } // if Position + } // _wxvtk2Dbaseview +} + + diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintControler.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintControler.h index 0aa0ec9..9a9993b 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintControler.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintControler.h @@ -27,7 +27,7 @@ #define _MANUAL_PAINT_CONTROLER_H_ #include "ManualPaintModel.h" -#include "ManualPaintPanel.h" +//#include "ManualPaintPanel.h" #include "wxVtk2DBaseView.h" @@ -36,17 +36,21 @@ public: ManualPaintControler(); virtual ~ManualPaintControler(); - void SetManualPaintModel(ManualPaintModel* manualPaintModel); - void SetManualPaintPanel(ManualPaintPanel* manualPaintPanel); - void SetWxVtk2DBaseView(wxVtk2DBaseView *wxvtk2Dbaseview); - void Config(); - void PaintImage(int px,int py, int pz); - void SetImageUndo(); + void SetManualPaintModel(ManualPaintModel* manualPaintModel); + ManualPaintModel* GetManualPaintModel(); +// void SetManualPaintPanel(ManualPaintPanel* manualPaintPanel); + void SetWxVtk2DBaseView(wxVtk2DBaseView *wxvtk2Dbaseview); + void Config(); + void PaintImage(int px,int py, int pz); + void SetImageUndo(); + void Undo(); + void Redo(); + void Refresh(); private: int auxZ; ManualPaintModel *_manualPaintModel; - ManualPaintPanel *_manualPaintPanel; +// ManualPaintPanel *_manualPaintPanel; wxVtk2DBaseView *_wxvtk2Dbaseview; protected: diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp index 61c234e..8736b83 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.cpp @@ -27,8 +27,8 @@ ManualPaintModel::ManualPaintModel() { - _active = true; - _tool = 0; // 0 pencil , 1 fill + _active = true; + _tool = 0; // 0 pencil , 1 fill _brushfilter = new BrushFilter(); _fillfilter = new FillFilter(); _imageUndoRedo = new ImageUndoRedo(); @@ -53,13 +53,11 @@ void ManualPaintModel::PaintImage(int px, int py, int pz) { if (_active==true) { - if (_tool == 0) { _brushfilter->SetPoint(px, py, pz); _brushfilter->Run(); } // _tool 2 - if (_tool == 1) { _fillfilter->SetPoint(px, py, pz); @@ -155,7 +153,6 @@ void ManualPaintModel::GetScalarRange(double * range) //--------------------------------------------------------------------------- void ManualPaintModel::SetUndoImage() { - printf("EED ManualPaintModel::SetUndoImage \n"); ImageMManager* imMManager = NULL; if (_tool == 0) { @@ -173,7 +170,6 @@ void ManualPaintModel::SetUndoImage() void ManualPaintModel::Undo() { - printf("EED ManualPaintModel::Undo \n"); this->_imageUndoRedo->Undo(); } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.h index 1a552e7..eb6f10a 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintModel.h @@ -60,11 +60,11 @@ public: void Redo(); //DFCH private: - int _tool; - bool _active; - BrushFilter *_brushfilter; - FillFilter *_fillfilter; - ImageUndoRedo *_imageUndoRedo; + int _tool; + bool _active; + BrushFilter *_brushfilter; + FillFilter *_fillfilter; + ImageUndoRedo *_imageUndoRedo; protected: diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintPanel.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintPanel.cpp index d943678..0ff7e2a 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintPanel.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintPanel.cpp @@ -28,7 +28,7 @@ ManualPaintPanel::ManualPaintPanel() { - _manualPaintModel=NULL; + _manualPaintControler=NULL; } //--------------------------------------------------------------------------- @@ -37,18 +37,18 @@ ManualPaintPanel::~ManualPaintPanel() } //--------------------------------------------------------------------------- -void ManualPaintPanel::SetManualPaintModel(ManualPaintModel* manualPaintModel) +void ManualPaintPanel::SetManualPaintControler(ManualPaintControler* manualPaintControler) { - _manualPaintModel = manualPaintModel; + _manualPaintControler = manualPaintControler; } //--------------------------------------------------------------------------- void ManualPaintPanel::SetBrushSize( int brushsize ) { - if (_manualPaintModel!=NULL) + if (_manualPaintControler!=NULL) { - _manualPaintModel->SetBrushSize( brushsize ); + _manualPaintControler->GetManualPaintModel()->SetBrushSize( brushsize ); } else { printf("ERROR in ManualPaintPanel _manualPaintModel not set.\n"); } @@ -57,9 +57,9 @@ void ManualPaintPanel::SetBrushSize( int brushsize ) //--------------------------------------------------------------------------- void ManualPaintPanel::SetRangeMin( int min ) { - if (_manualPaintModel!=NULL) + if (_manualPaintControler!=NULL) { - _manualPaintModel->SetRangeMin( min ); + _manualPaintControler->GetManualPaintModel()->SetRangeMin( min ); } else { printf("ERROR in ManualPaintPanel _manualPaintModel not set.\n"); } @@ -68,9 +68,9 @@ void ManualPaintPanel::SetRangeMin( int min ) //--------------------------------------------------------------------------- void ManualPaintPanel::SetRangeMax( int max ) { - if (_manualPaintModel!=NULL) + if (_manualPaintControler!=NULL) { - _manualPaintModel->SetRangeMax( max ); + _manualPaintControler->GetManualPaintModel()->SetRangeMax( max ); } else { printf("ERROR in ManualPaintPanel _manualPaintModel not set.\n"); } @@ -79,9 +79,9 @@ void ManualPaintPanel::SetRangeMax( int max ) //--------------------------------------------------------------------------- void ManualPaintPanel::SetGrayLevel( double graylevel ) { - if (_manualPaintModel!=NULL) + if (_manualPaintControler!=NULL) { - _manualPaintModel->SetGrayLevel( graylevel ); + _manualPaintControler->GetManualPaintModel()->SetGrayLevel( graylevel ); } else { printf("ERROR in ManualPaintPanel _manualPaintModel not set.\n"); } @@ -90,9 +90,9 @@ void ManualPaintPanel::SetGrayLevel( double graylevel ) //--------------------------------------------------------------------------- void ManualPaintPanel::SetTool(int tool) { - if (_manualPaintModel!=NULL) + if (_manualPaintControler!=NULL) { - _manualPaintModel->SetTool( tool ); + _manualPaintControler->GetManualPaintModel()->SetTool( tool ); } else { printf("ERROR in ManualPaintPanel _manualPaintModel not set.\n"); } @@ -101,9 +101,9 @@ void ManualPaintPanel::SetTool(int tool) //--------------------------------------------------------------------------- void ManualPaintPanel::Set2D3D(int dim2D3D) { - if (_manualPaintModel!=NULL) + if (_manualPaintControler!=NULL) { - _manualPaintModel->Set2D3D( dim2D3D ); + _manualPaintControler->GetManualPaintModel()->Set2D3D( dim2D3D ); } else { printf("ERROR in ManualPaintPanel _manualPaintModel not set.\n"); } @@ -112,9 +112,9 @@ void ManualPaintPanel::Set2D3D(int dim2D3D) //--------------------------------------------------------------------------- void ManualPaintPanel::SetBrushForm(int brushform) { - if (_manualPaintModel!=NULL) + if (_manualPaintControler!=NULL) { - _manualPaintModel->SetBrushForm( brushform ); + _manualPaintControler->GetManualPaintModel()->SetBrushForm( brushform ); } else { printf("ERROR in ManualPaintPanel _manualPaintModel not set.\n"); } @@ -123,9 +123,9 @@ void ManualPaintPanel::SetBrushForm(int brushform) //--------------------------------------------------------------------------- void ManualPaintPanel::SetToleranceFill(double tolerancefill) { - if (_manualPaintModel!=NULL) + if (_manualPaintControler!=NULL) { - _manualPaintModel->SetToleranceFill( tolerancefill ); + _manualPaintControler->GetManualPaintModel()->SetToleranceFill( tolerancefill ); } else { printf("ERROR in ManualPaintPanel _manualPaintModel not set.\n"); } @@ -134,9 +134,9 @@ void ManualPaintPanel::SetToleranceFill(double tolerancefill) //--------------------------------------------------------------------------- void ManualPaintPanel::SetDistanceFill(int distancefill) { - if (_manualPaintModel!=NULL) + if (_manualPaintControler!=NULL) { - _manualPaintModel->SetDistanceFill( distancefill ); + _manualPaintControler->GetManualPaintModel()->SetDistanceFill( distancefill ); } else { printf("ERROR in ManualPaintPanel _manualPaintModel not set.\n"); } @@ -145,9 +145,9 @@ void ManualPaintPanel::SetDistanceFill(int distancefill) //--------------------------------------------------------------------------- void ManualPaintPanel::GetScalarRange( double * range ) { - if (_manualPaintModel!=NULL) + if (_manualPaintControler!=NULL) { - _manualPaintModel->GetScalarRange( range ); + _manualPaintControler->GetManualPaintModel()->GetScalarRange( range ); } else { printf("ERROR in ManualPaintPanel _manualPaintModel not set.\n"); } @@ -156,9 +156,9 @@ void ManualPaintPanel::GetScalarRange( double * range ) //--------------------------------------------------------------------------- void ManualPaintPanel::SetActive( bool active ) { - if (_manualPaintModel!=NULL) + if (_manualPaintControler!=NULL) { - _manualPaintModel->SetActive( active ); + _manualPaintControler->GetManualPaintModel()->SetActive( active ); } else { printf("ERROR in ManualPaintPanel _manualPaintModel not set.\n"); } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintPanel.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintPanel.h index e756fd3..8b75c96 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintPanel.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/ManualPaintPanel.h @@ -26,7 +26,7 @@ #ifndef _MANUAL_PAINT_PANEL_H_ #define _MANUAL_PAINT_PANEL_H_ -#include "ManualPaintModel.h" +#include "ManualPaintControler.h" class ManualPaintPanel { public: @@ -34,7 +34,7 @@ public: virtual ~ManualPaintPanel(); void SetActive( bool active ); - void SetManualPaintModel(ManualPaintModel* manualPaintModel); + void SetManualPaintControler(ManualPaintControler* manualPaintControler); void SetBrushSize( int brushsize ); void SetGrayLevel( double graylevel ); void SetTool(int tool); @@ -47,7 +47,7 @@ public: void GetScalarRange( double * range); protected: - ManualPaintModel *_manualPaintModel; + ManualPaintControler *_manualPaintControler; }; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/vtkInteractorManualPaint.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/vtkInteractorManualPaint.cpp index f327936..e7b081d 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/vtkInteractorManualPaint.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/vtkInteractorManualPaint.cpp @@ -71,7 +71,7 @@ bool vtkInteractorManualPaint::OnLeftButtonUp() printf("EED vtkInteractorManualPaint::OnLeftButtonUp \n"); if((_state == true) || (_stateKey == true)) { - _manualPaintControler->SetImageUndo(); +// _manualPaintControler->SetImageUndo(); } _state = false; return true; @@ -82,34 +82,19 @@ bool vtkInteractorManualPaint::OnMouseMove() { if ((_state == true) || (_stateKey == true)) { - wxVtk2DBaseView *wxvtk2Dbaseview = - (wxVtk2DBaseView*) _vtkInteractorStyleBaseView->GetWxVtk2DBaseView(); - crea::wxVTKRenderWindowInteractor *wxVTKiren = - wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor(); + wxVtk2DBaseView *wxvtk2Dbaseview = (wxVtk2DBaseView*) _vtkInteractorStyleBaseView->GetWxVtk2DBaseView(); + crea::wxVTKRenderWindowInteractor *wxVTKiren = wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor(); int px, py; wxVTKiren->GetEventPosition(px, py); - -// int typeView = 1; double X = (double) px; double Y = (double) py; double Z = wxvtk2Dbaseview->GetActualSlice(); -// wxvtk2Dbaseview->TransFromCoordScreenToWorld(X, Y, Z,true, typeView); wxvtk2Dbaseview->TransFromCoordScreenToWorld(X, Y, Z, true); - _manualPaintControler->PaintImage((int) X, (int) Y, (int) Z); this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting(); - /* - wxvtk2Dbaseview->_imageViewer2XYZ->GetVtkImageViewer2()->Modified(); - wxvtk2Dbaseview->_imageViewer2XYZ->GetVtkImageViewer2()->GetImageActor()->Modified(); - wxvtk2Dbaseview->_imageViewer2XYZ->GetVtkImageViewer2()->GetImageActor()->SetDisplayExtent(0, 50+_auxZ, 0, 50,_Z, _Z ); - wxvtk2Dbaseview->Refresh(); - wxvtk2Dbaseview->RefreshView(); - // wxvtk2Dbaseview->SetActualSlice(_Z+_auxZ); - _auxZ=(_auxZ+1)%2; - wxvtk2Dbaseview->_imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->Render(); - this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting(); - */ + _manualPaintControler->SetImageUndo(); + } // if _state return true; } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.cpp index 57fd497..0fb3c37 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.cpp @@ -30,15 +30,12 @@ wxManualPaintPanel::wxManualPaintPanel( wxWindow * parent ) : wxPanel( parent, -1 ) { wxSizer *sizer = new wxFlexGridSizer( 1 ); - // Widget interface - wxStaticText *tittleText = new wxStaticText( this, -1, - _T(" Manual Paint") ); + wxStaticText *tittleText = new wxStaticText( this, -1,_T(" Manual Paint") ); //Title sizer->Add( tittleText ); //giving some blank spaces sizer->Add( new wxStaticText( this, -1, _T(" key A : Enable/Disable ") ) ); - this->ConfigureActiveCBButton( ); this->ConfigureBrushToolRadioButton( ); this->Configure2D3DRadioButton( ); @@ -49,15 +46,12 @@ wxManualPaintPanel::wxManualPaintPanel( wxWindow * parent ) this->ConfigureDistanceFillSld( ); this->ConfigureTolFillSld( ); this->ConfigureEditButtons( ); - //Buttons - wxStaticText *editButtonsText = new wxStaticText( this, -1, - _T("Edit Buttons") ); - this->_buttonsSizer = new wxFlexGridSizer( 4 ); + wxStaticText *editButtonsText = new wxStaticText( this, -1,_T("Edit Buttons") ); + this->_buttonsSizer = new wxFlexGridSizer( 4 ); this->_buttonsSizer->Add( _btnUndo, 1, wxGROW ); this->_buttonsSizer->Add( _btnRedo, 1, wxGROW ); this->_buttonsSizer->Add( _btnCopy, 1, wxGROW ); - this->_gConfigSizer = new wxFlexGridSizer( 1 ); //BrushTool Radio Button //giving blank space @@ -67,8 +61,7 @@ wxManualPaintPanel::wxManualPaintPanel( wxWindow * parent ) //2D/3D Radio Button this->_gConfigSizer->Add( _rb2D3D, 1, wxGROW ); //RangeBar - this->_gConfigSizer->Add( - new wxStaticText( this, -1, _T( "Select Range" ) ), 1, wxGROW ); + this->_gConfigSizer->Add( new wxStaticText( this, -1, _T( "Select Range" ) ), 1, wxGROW ); this->_gConfigSizer->Add( _mBarSlices, 1, wxGROW ); //GrayLevel Slider this->_gConfigSizer->Add( _txtGrayLevel ); @@ -90,8 +83,7 @@ wxManualPaintPanel::wxManualPaintPanel( wxWindow * parent ) //giving blank space this->_brushSizer->Add( new wxStaticText( this, -1, _T(" ") ) ); //end of blank space - this->_brushSizer->Add( - new wxStaticText( this, -1, _T("Brush Settings") ) ); + this->_brushSizer->Add( new wxStaticText( this, -1, _T("Brush Settings") ) ); //BrushSize Slider this->_brushSizer->Add( _txtBrushSize ); @@ -118,31 +110,25 @@ wxManualPaintPanel::wxManualPaintPanel( wxWindow * parent ) this->_FillSizer->Add( _txtToleranceFill ); wxFlexGridSizer *sizerTolerance = new wxFlexGridSizer( 2 ); sizerTolerance->Add( _sldToleranceFill, 1, wxGROW ); - sizerTolerance->Add( _tolerancefillCtrl, 1, - wxALIGN_BOTTOM | wxALIGN_LEFT | wxALL, 5 ); + sizerTolerance->Add( _tolerancefillCtrl, 1, wxALIGN_BOTTOM | wxALIGN_LEFT | wxALL, 5 ); this->_FillSizer->Add( sizerTolerance, 1, wxGROW ); //Distance Fill this->_FillSizer->Add( _txtDistanceFill ); wxFlexGridSizer *sizerDistance = new wxFlexGridSizer( 2 ); sizerDistance->Add( _sldDistanceFill, 1, wxGROW ); - sizerDistance->Add( _distancefillCtrl, 1, - wxALIGN_BOTTOM | wxALIGN_LEFT | wxALL, 5 ); + sizerDistance->Add( _distancefillCtrl, 1, wxALIGN_BOTTOM | wxALIGN_LEFT | wxALL, 5 ); this->_FillSizer->Add( sizerDistance ); - sizer->Add( _activeCB ); sizer->Add( editButtonsText ); sizer->Add( _buttonsSizer ); sizer->Add( _gConfigSizer ); sizer->Add( _brushSizer ); sizer->Add( _FillSizer ); - this->ConnectComponents( ); //DFCH this->_FillSizer->Show( false ); - this->SetSizer( sizer ); this->SetAutoLayout( true ); this->Layout( ); - } //--------------------------------------------------------------------------- @@ -215,12 +201,11 @@ void wxManualPaintPanel::ConfigureRangeBar( ) _mBarSlices->SetStart( min ); _mBarSlices->SetEnd( max ); _mBarSlices->Update( ); - SetRangeMin( min ); SetRangeMax( max ); - //DFCH -- End BarSlices } + //-------------------------------------------------------------------------- void wxManualPaintPanel::ConfigureGrayLevelSld( ) { @@ -233,24 +218,26 @@ void wxManualPaintPanel::ConfigureGrayLevelSld( ) _graylevelCtrl = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 65535, 0 ); } + //-------------------------------------------------------------------------- void wxManualPaintPanel::ConfigureBrushSizeSld( ) { _txtBrushSize = new wxStaticText( this, -1, wxString( _T(" Brush size ") ) ); - _sldBrushSize = new wxSlider( this, -1, 1, 1, 50, wxDefaultPosition, + _sldBrushSize = new wxSlider( this, -1, 5, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS ); _BrushSizeCtrl = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 65535, 0 ); _sldBrushSize->SetMinSize( wxSize( 200, -1 ) ); _sldBrushSize->SetMaxSize( wxSize( 200, -1 ) ); } + //-------------------------------------------------------------------------- void wxManualPaintPanel::ConfigureDistanceFillSld( ) { _txtDistanceFill = new wxStaticText( this, -1, wxString( _T(" Distance fill ") ) ); - _sldDistanceFill = new wxSlider( this, -1, 50, 1, 500, wxDefaultPosition, + _sldDistanceFill = new wxSlider( this, -1, 5, 1, 500, wxDefaultPosition, wxDefaultSize, wxSL_LABELS ); _sldDistanceFill->SetMinSize( wxSize( 200, -1 ) ); _sldDistanceFill->SetMaxSize( wxSize( 200, -1 ) ); @@ -260,22 +247,20 @@ void wxManualPaintPanel::ConfigureDistanceFillSld( ) _sldDistanceFill->Disable( ); _distancefillCtrl->Disable( ); } + //-------------------------------------------------------------------------- void wxManualPaintPanel::ConfigureTolFillSld( ) { - _txtToleranceFill = new wxStaticText( this, -1, - wxString( _T(" Tolerance fill ") ) ); - _sldToleranceFill = new wxSlider( this, -1, 125, 0, 255, wxDefaultPosition, - wxDefaultSize, wxSL_LABELS ); + _txtToleranceFill = new wxStaticText( this, -1,wxString( _T(" Tolerance fill ") ) ); + _sldToleranceFill = new wxSlider( this, -1, 125, 0, 255, wxDefaultPosition,wxDefaultSize, wxSL_LABELS ); _sldToleranceFill->SetMinSize( wxSize( 200, -1 ) ); _sldToleranceFill->SetMaxSize( wxSize( 200, -1 ) ); - _tolerancefillCtrl = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, - wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 65535, 50 ); + _tolerancefillCtrl = new wxSpinCtrl( this, wxID_ANY, wxEmptyString,wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 65535, 50 ); _txtToleranceFill->Disable( ); _sldToleranceFill->Disable( ); _tolerancefillCtrl->Disable( ); - } + //-------------------------------------------------------------------------- void wxManualPaintPanel::ConfigureEditButtons( ) { @@ -340,7 +325,7 @@ void wxManualPaintPanel::ConnectComponents( ) //DFCH _rbBrushTool->GetId(), wxEVT_COMMAND_RADIOBOX_SELECTED, (wxObjectEventFunction) (void(wxPanel::*)( - wxCommandEvent&)) &wxManualPaintPanel::OnBrushTool);this->Connect + wxCommandEvent&)) &wxManualPaintPanel::OnTool);this->Connect ( _btnCopy->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, @@ -400,7 +385,6 @@ void wxManualPaintPanel::ConnectComponents( ) //DFCH //------------------------------------------------------------------------- void wxManualPaintPanel::OnActive(wxCommandEvent& event) { - printf("EED wxManualPaintPanel::OnActive \n"); SetActive( _activeCB->GetValue() ); } @@ -504,8 +488,9 @@ void wxManualPaintPanel::OnBrushForm( wxCommandEvent &event ) } //--------------------------------------------------------------------------- -void wxManualPaintPanel::OnBrushTool( wxCommandEvent &event ) +void wxManualPaintPanel::OnTool( wxCommandEvent &event ) { +printf("EED wxManualPaintPanel::OnTool Start\n"); DisableControls( ); SetTool( _rbBrushTool->GetSelection( ) ); @@ -521,16 +506,26 @@ void wxManualPaintPanel::OnBrushTool( wxCommandEvent &event ) if( _rbBrushTool->GetSelection( ) == 1 ) //Fill tool { +printf("EED wxManualPaintPanel::OnTool 1\n"); _txtToleranceFill->Enable( ); +printf("EED wxManualPaintPanel::OnTool 2\n"); _sldToleranceFill->Enable( ); +printf("EED wxManualPaintPanel::OnTool 3\n"); _tolerancefillCtrl->Enable( ); +printf("EED wxManualPaintPanel::OnTool 4\n"); _txtDistanceFill->Enable( ); +printf("EED wxManualPaintPanel::OnTool 5\n"); _sldDistanceFill->Enable( ); +printf("EED wxManualPaintPanel::OnTool 6\n"); _distancefillCtrl->Enable( ); +printf("EED wxManualPaintPanel::OnTool 7\n"); _FillSizer->Show( true ); +printf("EED wxManualPaintPanel::OnTool 8\n"); _brushSizer->Show( false ); +printf("EED wxManualPaintPanel::OnTool 9\n"); this->Layout( ); +printf("EED wxManualPaintPanel::OnTool 10\n"); } } @@ -542,13 +537,13 @@ void wxManualPaintPanel::OnCopy( wxCommandEvent &event ) //--------------------------------------------------------------------------- void wxManualPaintPanel::OnUndo( wxCommandEvent &event ) { - this->_manualPaintModel->Undo( ); + this->_manualPaintControler->Undo( ); } //--------------------------------------------------------------------------- void wxManualPaintPanel::OnRedo( wxCommandEvent &event ) { - this->_manualPaintModel->Redo( ); + this->_manualPaintControler->Redo( ); } //-------------------------------------------------------------------------------------------------------------------------------- diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.h index e16fe00..f2cf04e 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.h @@ -59,7 +59,7 @@ public: void OnCtrTxtGrayLevel( wxCommandEvent &event ); void On2D3D( wxCommandEvent &event ); void OnBrushForm( wxCommandEvent &event ); - void OnBrushTool( wxCommandEvent &event ); + void OnTool( wxCommandEvent &event ); void OnCopy( wxCommandEvent &event ); void OnUndo( wxCommandEvent &event ); void OnRedo( wxCommandEvent &event ); @@ -81,31 +81,26 @@ public: void onMovedBar( wxCommandEvent& event ); private: - wxCheckBox *_activeCB; + wxCheckBox *_activeCB; wxStaticText *_txtBrushSize; - wxSlider *_sldBrushSize; - wxSpinCtrl *_BrushSizeCtrl; - + wxSlider *_sldBrushSize; + wxSpinCtrl *_BrushSizeCtrl; wxStaticText *_txtGrayLevel; - wxSlider *_sldGrayLevel; - wxSpinCtrl *_graylevelCtrl; - wxRadioBox *_rbBrushForm; - wxRadioBox *_rb2D3D; - wxRadioBox *_rbBrushTool; - + wxSlider *_sldGrayLevel; + wxSpinCtrl *_graylevelCtrl; + wxRadioBox *_rbBrushForm; + wxRadioBox *_rb2D3D; + wxRadioBox *_rbBrushTool; wxStaticText *_txtToleranceFill; - wxSlider *_sldToleranceFill; - wxSpinCtrl *_tolerancefillCtrl; - + wxSlider *_sldToleranceFill; + wxSpinCtrl *_tolerancefillCtrl; wxStaticText *_txtDistanceFill; - wxSlider *_sldDistanceFill; - wxSpinCtrl *_distancefillCtrl; - - mBarRange *_mBarSlices; //DFCH - wxButton *_btnCopy; //DFCH - wxButton *_btnUndo; //DFCH - wxButton *_btnRedo; //DFCH - + wxSlider *_sldDistanceFill; + wxSpinCtrl *_distancefillCtrl; + mBarRange *_mBarSlices; //DFCH + wxButton *_btnCopy; //DFCH + wxButton *_btnUndo; //DFCH + wxButton *_btnRedo; //DFCH wxFlexGridSizer *_buttonsSizer; //DFCH wxFlexGridSizer *_FillSizer; //DFCH wxFlexGridSizer *_gConfigSizer; //DFCH -- 2.47.1