From 6ceae7882128882a8d3085d8e7aa2d2079913b3f Mon Sep 17 00:00:00 2001 From: trillos Date: Wed, 13 Jan 2010 14:11:15 +0000 Subject: [PATCH] Added image duplication and file open save boxes --- .../src/bbPackRecalageDuplicateImageBox.cxx | 41 +++++++++++++++++ .../src/bbPackRecalageDuplicateImageBox.h | 35 +++++++++++++++ .../src/bbPackRecalageFileOpenSaveWidget.cxx | 44 +++++++++++++++++++ .../src/bbPackRecalageFileOpenSaveWidget.h | 36 +++++++++++++++ .../src/bbPackRecalageResampleBox.cxx | 44 +++++++++++++++++++ PackRecalage/src/bbPackRecalageResampleBox.h | 39 ++++++++++++++++ 6 files changed, 239 insertions(+) create mode 100644 PackRecalage/src/bbPackRecalageDuplicateImageBox.cxx create mode 100644 PackRecalage/src/bbPackRecalageDuplicateImageBox.h create mode 100644 PackRecalage/src/bbPackRecalageFileOpenSaveWidget.cxx create mode 100644 PackRecalage/src/bbPackRecalageFileOpenSaveWidget.h create mode 100644 PackRecalage/src/bbPackRecalageResampleBox.cxx create mode 100644 PackRecalage/src/bbPackRecalageResampleBox.h diff --git a/PackRecalage/src/bbPackRecalageDuplicateImageBox.cxx b/PackRecalage/src/bbPackRecalageDuplicateImageBox.cxx new file mode 100644 index 0000000..fe26625 --- /dev/null +++ b/PackRecalage/src/bbPackRecalageDuplicateImageBox.cxx @@ -0,0 +1,41 @@ +#include "bbPackRecalageDuplicateImageBox.h" +#include "bbPackRecalagePackage.h" +namespace bbPackRecalage +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,DuplicateImageBox) +BBTK_BLACK_BOX_IMPLEMENTATION(DuplicateImageBox,bbtk::AtomicBlackBox); +void DuplicateImageBox::Process() +{ + vtkImageData *duplicate = vtkImageData::New(); + bbGetInputIn()->ShallowCopy(duplicate); + bbSetOutputOut(duplicate); +} +void DuplicateImageBox::bbUserSetDefaultValues() +{ + bbSetInputIn(NULL); + bbSetOutputOut(NULL); +} +void DuplicateImageBox::bbUserInitializeProcessing() +{ + +// THE INITIALIZATION METHOD BODY : +// Here does nothing +// but this is where you should allocate the internal/output pointers +// if any + + +} +void DuplicateImageBox::bbUserFinalizeProcessing() +{ + +// THE FINALIZATION METHOD BODY : +// Here does nothing +// but this is where you should desallocate the internal/output pointers +// if any + +} +} +// EO namespace bbPackRecalage + + diff --git a/PackRecalage/src/bbPackRecalageDuplicateImageBox.h b/PackRecalage/src/bbPackRecalageDuplicateImageBox.h new file mode 100644 index 0000000..ec8e0b4 --- /dev/null +++ b/PackRecalage/src/bbPackRecalageDuplicateImageBox.h @@ -0,0 +1,35 @@ +#ifndef __bbPackRecalageDuplicateImageBox_h_INCLUDED__ +#define __bbPackRecalageDuplicateImageBox_h_INCLUDED__ +#include "bbPackRecalage_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include "vtkImageData.h" + +namespace bbPackRecalage +{ + +class bbPackRecalage_EXPORT DuplicateImageBox + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(DuplicateImageBox,bbtk::AtomicBlackBox); + BBTK_DECLARE_INPUT(In,vtkImageData*); + BBTK_DECLARE_OUTPUT(Out,vtkImageData*); + BBTK_PROCESS(Process); + void Process(); +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(DuplicateImageBox,bbtk::AtomicBlackBox); +BBTK_NAME("DuplicateImageBox"); +BBTK_AUTHOR("jn.trillos44@uniandes.edu.co"); +BBTK_DESCRIPTION("Creates a shallow copy of its image input"); +BBTK_CATEGORY("__CATEGORY__"); +BBTK_INPUT(DuplicateImageBox,In,"Original Image",vtkImageData*,""); +BBTK_OUTPUT(DuplicateImageBox,Out,"Duplicated Image",vtkImageData*,""); +BBTK_END_DESCRIBE_BLACK_BOX(DuplicateImageBox); +} +// EO namespace bbPackRecalage + +#endif // __bbPackRecalageDuplicateImageBox_h_INCLUDED__ + diff --git a/PackRecalage/src/bbPackRecalageFileOpenSaveWidget.cxx b/PackRecalage/src/bbPackRecalageFileOpenSaveWidget.cxx new file mode 100644 index 0000000..3c9fa79 --- /dev/null +++ b/PackRecalage/src/bbPackRecalageFileOpenSaveWidget.cxx @@ -0,0 +1,44 @@ +#include "bbPackRecalageFileOpenSaveWidget.h" +#include "bbPackRecalagePackage.h" +namespace bbPackRecalage +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,FileOpenSaveWidget) +BBTK_BLACK_BOX_IMPLEMENTATION(FileOpenSaveWidget,bbtk::WxBlackBox); +void FileOpenSaveWidget::Process() +{ + + std::string msg; + if (bbGetInputTitle()!="") + { + msg = bbGetInputTitle()+": " + bbGetInputIn(); + } + else + { + msg = bbGetInputIn(); + } + ((wxStaticText*)bbGetOutputWidget())->SetLabel( bbtk::std2wx( msg ) ); + +} +void FileOpenSaveWidget::CreateWidget(wxWindow* parent) +{ + + bbSetOutputWidget( new wxStaticText ( parent , -1 , _T("") ) ); + +} +void FileOpenSaveWidget::bbUserSetDefaultValues() +{ + +} +void FileOpenSaveWidget::bbUserInitializeProcessing() +{ + +} +void FileOpenSaveWidget::bbUserFinalizeProcessing() +{ + +} +} +// EO namespace bbPackRecalage + + diff --git a/PackRecalage/src/bbPackRecalageFileOpenSaveWidget.h b/PackRecalage/src/bbPackRecalageFileOpenSaveWidget.h new file mode 100644 index 0000000..a629478 --- /dev/null +++ b/PackRecalage/src/bbPackRecalageFileOpenSaveWidget.h @@ -0,0 +1,36 @@ +#ifdef _USE_WXWIDGETS_ +#ifndef __bbPackRecalageFileOpenSaveWidget_h_INCLUDED__ +#define __bbPackRecalageFileOpenSaveWidget_h_INCLUDED__ +#include "bbPackRecalage_EXPORT.h" +#include "bbtkWxBlackBox.h" + +namespace bbPackRecalage +{ + +class bbPackRecalage_EXPORT FileOpenSaveWidget + : + public bbtk::WxBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(FileOpenSaveWidget,bbtk::WxBlackBox); + BBTK_DECLARE_INPUT(Title,std::string); + BBTK_DECLARE_INPUT(In,std::string); + BBTK_PROCESS(Process); + void Process(); + BBTK_CREATE_WIDGET(CreateWidget); + void CreateWidget(wxWindow*); +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(FileOpenSaveWidget,bbtk::WxBlackBox); +BBTK_NAME("FileOpenSaveWidget"); +BBTK_AUTHOR("jn.trillos44@uniandes.edu.co"); +BBTK_DESCRIPTION("A general Open and Save Widget that uses a file selector and writes and opens .xls files"); +BBTK_CATEGORY("__CategoryBlackBox__"); +BBTK_INPUT(FileOpenSaveWidget,Title,"Title prepended to the text",std::string,""); +BBTK_INPUT(FileOpenSaveWidget,In,"Text",std::string,""); +BBTK_END_DESCRIBE_BLACK_BOX(FileOpenSaveWidget); +} +// EO namespace bbPackRecalage + +#endif // __bbPackRecalageFileOpenSaveWidget_h_INCLUDED__ +#endif // _USE_WXWIDGETS_ + diff --git a/PackRecalage/src/bbPackRecalageResampleBox.cxx b/PackRecalage/src/bbPackRecalageResampleBox.cxx new file mode 100644 index 0000000..3a5a7b8 --- /dev/null +++ b/PackRecalage/src/bbPackRecalageResampleBox.cxx @@ -0,0 +1,44 @@ +#include "bbPackRecalageResampleBox.h" +#include "bbPackRecalagePackage.h" +namespace bbPackRecalage +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,ResampleBox) +BBTK_BLACK_BOX_IMPLEMENTATION(ResampleBox,bbtk::AtomicBlackBox); +void ResampleBox::Process() +{ + if(bbGetInputIn() != NULL && bbGetInputFactor() != 0) + { + double factor = bbGetInputFactor(); + resample->SetInput(bbGetInputIn()); + resample->SetAxisMagnificationFactor(0, factor); + resample->SetAxisMagnificationFactor(1, factor); + resample->SetAxisMagnificationFactor(2, factor); + resample->Update(); + vtkImageData *image = resample->GetOutput(); + std::cout << "NTU: new spacing!" << image->GetExtent()[1] << " " << image->GetExtent()[3] << " " << image->GetExtent()[5] << " " << image->GetSpacing()[0] << " " << image->GetSpacing()[1] << " " << image->GetSpacing()[2] << std::endl; + bbSetOutputOut(resample->GetOutput()); + } + else + { + bbSetOutputOut(NULL); + } +} +void ResampleBox::bbUserSetDefaultValues() +{ + bbSetInputIn(NULL); + bbSetInputFactor(0); + bbSetOutputOut(NULL); +} +void ResampleBox::bbUserInitializeProcessing() +{ + resample = vtkImageResample::New(); +} +void ResampleBox::bbUserFinalizeProcessing() +{ + resample->Delete(); +} +} +// EO namespace bbPackRecalage + + diff --git a/PackRecalage/src/bbPackRecalageResampleBox.h b/PackRecalage/src/bbPackRecalageResampleBox.h new file mode 100644 index 0000000..8cf3b37 --- /dev/null +++ b/PackRecalage/src/bbPackRecalageResampleBox.h @@ -0,0 +1,39 @@ +#ifndef __bbPackRecalageResampleBox_h_INCLUDED__ +#define __bbPackRecalageResampleBox_h_INCLUDED__ +#include "bbPackRecalage_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" +#include "vtkImageResample.h" +#include "vtkImageData.h" + +namespace bbPackRecalage +{ + +class bbPackRecalage_EXPORT ResampleBox + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(ResampleBox,bbtk::AtomicBlackBox); + BBTK_DECLARE_INPUT(In,vtkImageData *); + BBTK_DECLARE_INPUT(Factor,double); + BBTK_DECLARE_OUTPUT(Out,vtkImageData *); + BBTK_PROCESS(Process); + void Process(); + + vtkImageResample *resample; +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(ResampleBox,bbtk::AtomicBlackBox); +BBTK_NAME("ResampleBox"); +BBTK_AUTHOR("jn.trillos44@uniandes.edu.co"); +BBTK_DESCRIPTION("Does resampling of an image, creating a copy of the original image with different extent and spacing"); +BBTK_CATEGORY("filter"); +BBTK_INPUT(ResampleBox,In,"Original image",vtkImageData *,""); +BBTK_INPUT(ResampleBox,Factor,"Resampling factor",double,""); +BBTK_OUTPUT(ResampleBox,Out,"Resampled image",vtkImageData *,""); +BBTK_END_DESCRIBE_BLACK_BOX(ResampleBox); +} +// EO namespace bbPackRecalage + +#endif // __bbPackRecalageResampleBox_h_INCLUDED__ + -- 2.47.1