//virtual
void Image3DDequeUR::AddImageToUndoContainer(VTKImageDataPointerType img,
ImageMManagerType* imMManager) {
+ this->CleanUndoContainerFromIndex(this->m_CurrentUndoPos + 1);
//Adding image
ImageInfoUR* imageInfo = new ImageInfoUR();
imageInfo->SetImageName(
this->m_CurrentUndoPos = this->m_ImgUndoDeque.size() - 1;
//Managing memory
this->ManageMemory();
+ //clean redo container
+ this->CleanRedoContainer();
}
//virtual
ImageInfoUR* Image3DDequeUR::Undo() {
//virtual
void Image3DDequeUR::AddImageToRedoContainer(VTKImageDataPointerType img,
ImageMManagerType* imMManager) {
+ //Adding image
+ ImageInfoUR* imageInfo = new ImageInfoUR();
+ imageInfo->SetImageName(
+ this->GetImageName(this->m_ImgRedoDeque.size(), false));
+ imageInfo->SetImage(img);
+ imageInfo->SetImageMManager(imMManager);
+ //Adding to deque
+ this->m_ImgRedoDeque.push_back(imageInfo);
+ this->m_CurrentRedoPos = this->m_ImgRedoDeque.size() - 1;
+ //Managing memory
+ this->ManageMemory();
+
}
//virtual
ImageInfoUR* Image3DDequeUR::Redo() {
-
- ImageInfoUR* imgRet = new ImageInfoUR();
+ ImageInfoUR* imgRet = NULL;
+ if ((this->m_ImgRedoDeque.size() > 0) && (this->m_CurrentRedoPos != -1)) {
+ imgRet = this->m_ImgRedoDeque[m_CurrentRedoPos];
+ this->m_CurrentRedoPos--;
+ this->m_CurrentUndoPos++;
+ } //fi
return (imgRet);
}
//virtual
for (int i = 0; i < count; i++) {
this->m_ImgUndoDeque.pop_back();
} //rof
-
}
//virtual
-void Image3DDequeUR::CleanRedoContainerFromIndex(const int& index) {
+void Image3DDequeUR::CleanRedoContainer() {
+ for (unsigned int i = 0; i < this->m_ImgRedoDeque.size(); i++) {
+ this->m_ImgRedoDeque[i]->RemoveImageFromMemory(this->m_GlobalPath);
+ this->m_ImgRedoDeque[i]->RemoveImageFromDisk(this->m_GlobalPath);
+ }
}
//virtual
void Image3DDequeUR::CleanContainers() {
this->m_GlobalPath);
}
//The same for the redo queue
+ for (int i = 0; (unsigned int) i < this->m_ImgRedoDeque.size(); i++) {
+ if (this->m_ImgRedoDeque[i]->GetStatus()) {
+ this->m_ImgRedoDeque[i]->RemoveImageFromMemory(this->m_GlobalPath);
+ } //fi
+ } //rof
+ //Adding CurrentUndoPos to memory
+ if ((this->m_CurrentRedoPos != -1)
+ && !(this->m_ImgRedoDeque[this->m_CurrentRedoPos]->GetStatus())) {
+ this->m_ImgRedoDeque[this->m_CurrentRedoPos]->LoadImageMHDToMemory(
+ this->m_GlobalPath);
+ }
}
void Image3DDequeUR::SetGlobalPath(const StringType& globalPath) {
imgType = "redo";
}
StringType imageName = this->m_IDImages + imgType + ss.str();
- imageName.append(".mhd");
return (imageName);
}
virtual void AddImageToRedoContainer(VTKImageDataPointerType img,
ImageMManagerType* imMManager);
virtual void CleanUndoContainerFromIndex(const int& index);
- virtual void CleanRedoContainerFromIndex(const int& index);
+ virtual void CleanRedoContainer( );
virtual void CleanContainers();
virtual void ManageMemory();
virtual ImageInfoUR* Undo();
void ImageDequeUR::CleanUndoContainerFromIndex(const int& index) {
}
-void ImageDequeUR::CleanRedoContainerFromIndex(const int& index) {
+void ImageDequeUR::CleanRedoContainer( ) {
}
void ImageDequeUR::CleanContainers() {
virtual void AddImageToRedoContainer(VTKImageDataPointerType img,
ImageMManager* imMManager);
virtual void CleanUndoContainerFromIndex(const int& index);
- virtual void CleanRedoContainerFromIndex(const int& index);
+ virtual void CleanRedoContainer();
virtual void CleanContainers();
virtual void ManageMemory();
virtual ImageInfoUR* Undo();
}
void ImageInfoUR::LoadImageMHDToMemory(const StringType& gPath) {
StringType filename = gPath + this->m_ImageName;
+ filename.append(".mhd");
VTKMetaImageReaderPointerType reader = VTKMetaImageReaderPointerType::New();
reader->SetFileName(filename.c_str());
this->m_Image = reader->GetOutput();
void ImageInfoUR::SaveImageAsMHD(const StringType& gPath) {
this->m_OnDisk = true;
StringType filename = gPath + this->m_ImageName;
+ filename.append(".mhd");
//managing temporary files
mkstemp((char*) filename.c_str());
VTKMetaImageWriterPointerType w = VTKMetaImageWriterPointerType::New();
}
void ImageInfoUR::RemoveImageFromDisk(const StringType& gPath) {
- std::cout << "Borrando archivo" << endl;
StringType filename = gPath + this->m_ImageName;
- std::cout << filename << std::endl;
+ filename.append(".mhd");
+ StringType filenameRaw = gPath + this->m_ImageName;
+ filenameRaw.append(".raw");
+ mkstemp((char*) filenameRaw.c_str());
unlink((char*) filename.c_str());
+ unlink((char*) filenameRaw.c_str());
}
ImageInfoUR* imageInfo = this->m_ImagesDeque->Undo();
if (imageInfo != NULL)
{
- //this->SetRedoImage(imageInfo->GetRegion());
+ //this->SetRedoImage(imageInfo->GetImageMManager());
this->DrawUR(imageInfo);
this->UpdateUndoImage();
}
}
//virtual
void ImageUndoRedo::Redo() {
-
+ /*ImageInfoUR* imageInfo = this->m_ImagesDeque->Redo();
+ if (imageInfo != NULL)
+ {
+ this->DrawUR(imageInfo);
+ }*/
}
void ImageUndoRedo::SetImage(VTKImageDataPointerType image) {
this->m_CurrentImage = image;
}
}
//virtual
-void ImageUndoRedo::SetRedoImage(const ImageMManagerType* imMManager) {
- /*RegionSType region = imMManager.GetModifiedRegion();
- VTKImageDataPointerType imgResult = this->ImageMManagerType(region,
- this->m_CurrentImage);
- this->m_ImagesDeque->AddImageToRedoContainer(imgResult, imMManager);*/
+void ImageUndoRedo::SetRedoImage(ImageMManagerType* imMManager) {
+ /*this->m_CurrentImage->Update();
+ ImageMManagerType* newImageManager = new ImageMManagerType(imMManager);
+ if (newImageManager->ValidateRegion()) {
+ RegionSType region = newImageManager->GetModifiedRegion();
+ VTKImageDataPointerType imgResult = this->GetImageRegion(region,
+ this->m_CurrentImage);
+ this->m_ImagesDeque->AddImageToRedoContainer(imgResult,
+ newImageManager);
+ imgResult->Update();
+ } else {
+ std::cerr << "INVALID REGION" << std::endl;
+ }*/
}
void ImageUndoRedo::UpdateUndoImage() {
virtual void Redo();
virtual void SetImage(VTKImageDataPointerType image);
virtual void SetUndoImage(ImageMManagerType* imMManager);
- virtual void SetRedoImage(const ImageMManagerType* imMManager);
+ virtual void SetRedoImage(ImageMManagerType* imMManager);
void UpdateUndoImage();
void SetCurrentImage(VTKImageDataPointerType img);
VTKImageDataPointerType GetImageRegion(const RegionSType& region,
void ManagerUR::SetUndoImage(ImageMManagerType* imMManager) {
}
-void ManagerUR::SetRedoImage(ImageMManagerType* imMManager) {
+void ManagerUR::SetRedoImage(ImageMManagerType* imMManager){
}
void ManagerUR::DrawUR(ImageInfoUR imageInfo) {
void ManualPaintModel::Undo() {
this->_imageUndoRedo->Undo();
}
+
+void ManualPaintModel::Redo() {
+ this->_imageUndoRedo->Redo();
+}
void GetScalarRange(double * range);
void SetUndoImage(); //DFCH
void Undo(); //DFCH
+ void Redo(); //DFCH
private:
int _tool;
wxButton *btnCopy = new wxButton(panel, -1, _T("Copy"));
btnCopy->Disable();
wxButton *btnUndo = new wxButton(panel, -1, _T("Undo"));
+ wxButton *btnRedo = new wxButton(panel, -1, _T("Redo"));
//btnUndo->Disable();
Connect(
btnCopy->GetId(),
wxEVT_COMMAND_BUTTON_CLICKED,
(wxObjectEventFunction) (void(wxPanel::*)(
- wxCommandEvent&)) &wxManualPaintPanel::OnCopy);Connect
- (
+ wxCommandEvent&)) &wxManualPaintPanel::OnCopy);
+
+Connect (
btnUndo->GetId(),
wxEVT_COMMAND_BUTTON_CLICKED,
(wxObjectEventFunction) (void(wxPanel::*)(
- wxCommandEvent&)) &wxManualPaintPanel::OnUndo);
+ wxCommandEvent&)) &wxManualPaintPanel::OnUndo);this
+ ->Connect(btnRedo->GetId(),
+ wxEVT_COMMAND_BUTTON_CLICKED,
+ (wxObjectEventFunction) (void(wxPanel::*)(
+ wxCommandEvent&)) &wxManualPaintPanel::OnRedo); //DFCH
-Connect (
+ Connect(
_mBarSlices->GetId(),
wxEVT_TSBAR,
(wxObjectEventFunction) (wxCommandEventFunction) &wxManualPaintPanel::onBarrange);
sizer1->Add(btnCopy, 1, wxGROW);
sizer1->Add(new wxStaticText(panel, -1, _T(" ")));
sizer1->Add(btnUndo, 1, wxGROW);
+ sizer1->Add(btnRedo, 1, wxGROW);
sizer = sizer1;
panel->SetSizer(sizer);
this->_manualPaintModel->Undo();
}
+//---------------------------------------------------------------------------
+void wxManualPaintPanel::OnRedo(wxCommandEvent &event) {
+ this->_manualPaintModel->Redo();
+}
+
//--------------------------------------------------------------------------------------------------------------------------------
// Min-Max Barrange received events
//--------------------------------------------------------------------------------------------------------------------------------
#include "ManualPaintPanel.h"
-
#include "mBarRange.h" //DFCH
#include "creaWx.h" //DFCH
-
#include <wx/wx.h>
#include <wx/panel.h>
-class wxManualPaintPanel : public wxPanel , public ManualPaintPanel {
+class wxManualPaintPanel: public wxPanel, public ManualPaintPanel {
public:
wxManualPaintPanel(wxWindow * parent);
virtual ~wxManualPaintPanel();
- void OnBrushSize(wxScrollEvent& event);
- void OnSldGrayLevel(wxScrollEvent& event);
- void OnCtrTxtGrayLevel(wxCommandEvent &event);
- void On2D3D(wxCommandEvent &event);
- void OnBrushForm(wxCommandEvent &event);
- void OnBrushTool(wxCommandEvent &event);
- void OnCopy(wxCommandEvent &event);
- void OnUndo(wxCommandEvent &event);
- void DisableControls();
- void OnSldToleranceFill(wxScrollEvent& event);
- void OnCtrTxtToleranceFill(wxCommandEvent &event);
- void OnSldDistanceFill(wxScrollEvent& event);
- void OnCtrTxtDistanceFill(wxCommandEvent &event);
- //This method changes the min/max in the Selected Range Widget
- //--------------------------------------------------------------------------------------------------------------------------------
- // Min-Max Barrange received events
- //--------------------------------------------------------------------------------------------------------------------------------
- void onBarrange(wxCommandEvent& event);
- void onActualChange_Bar(wxCommandEvent& event);
- void onStartChange_Bar(wxCommandEvent& event);
- void onEndChange_Bar(wxCommandEvent& event);
- void onSelectionEnd(wxCommandEvent& event);
- void onMovedBar(wxCommandEvent& event);
+ void OnBrushSize(wxScrollEvent& event);
+ void OnSldGrayLevel(wxScrollEvent& event);
+ void OnCtrTxtGrayLevel(wxCommandEvent &event);
+ void On2D3D(wxCommandEvent &event);
+ void OnBrushForm(wxCommandEvent &event);
+ void OnBrushTool(wxCommandEvent &event);
+ void OnCopy(wxCommandEvent &event);
+ void OnUndo(wxCommandEvent &event);
+ void OnRedo(wxCommandEvent &event);
+ void DisableControls();
+ void OnSldToleranceFill(wxScrollEvent& event);
+ void OnCtrTxtToleranceFill(wxCommandEvent &event);
+ void OnSldDistanceFill(wxScrollEvent& event);
+ void OnCtrTxtDistanceFill(wxCommandEvent &event);
+ //This method changes the min/max in the Selected Range Widget
+ //--------------------------------------------------------------------------------------------------------------------------------
+ // Min-Max Barrange received events
+ //--------------------------------------------------------------------------------------------------------------------------------
+ void onBarrange(wxCommandEvent& event);
+ void onActualChange_Bar(wxCommandEvent& event);
+ void onStartChange_Bar(wxCommandEvent& event);
+ void onEndChange_Bar(wxCommandEvent& event);
+ void onSelectionEnd(wxCommandEvent& event);
+ void onMovedBar(wxCommandEvent& event);
private:
- wxStaticText *_txtBrushSize;
- wxSlider *_sldBrushSize;
-
- wxSlider *_sldGrayLevel;
- wxTextCtrl *_graylevelCtrl;
- wxRadioBox *_rbBrushForm;
- wxRadioBox *_rb2D3D;
- wxRadioBox *_rbBrushTool;
-
- wxStaticText *_txtToleranceFill;
- wxSlider *_sldToleranceFill;
- wxTextCtrl *_tolerancefillCtrl;
-
- wxStaticText *_txtDistanceFill;
- wxSlider *_sldDistanceFill;
- wxTextCtrl *_distancefillCtrl;
-
- mBarRange * _mBarSlices; //DFCH
+ wxStaticText *_txtBrushSize;
+ wxSlider *_sldBrushSize;
+ wxSlider *_sldGrayLevel;
+ wxTextCtrl *_graylevelCtrl;
+ wxRadioBox *_rbBrushForm;
+ wxRadioBox *_rb2D3D;
+ wxRadioBox *_rbBrushTool;
+ wxStaticText *_txtToleranceFill;
+ wxSlider *_sldToleranceFill;
+ wxTextCtrl *_tolerancefillCtrl;
+ wxStaticText *_txtDistanceFill;
+ wxSlider *_sldDistanceFill;
+ wxTextCtrl *_distancefillCtrl;
+ mBarRange * _mBarSlices; //DFCH
protected:
};
-
#endif // _WX_MANUAL_PAINT_PANEL_H_