From deb98a98f9b2006b9f21f2bd953efa369ce31939 Mon Sep 17 00:00:00 2001 From: trillos Date: Mon, 12 Oct 2009 16:26:17 +0000 Subject: [PATCH] Added checkbox, transparency and switcher --- .../src/bbPackRecalageCheckBoardBox.cxx | 53 ++++++++++++++ .../src/bbPackRecalageCheckBoardBox.h | 44 ++++++++++++ .../src/bbPackRecalageImageSwitcherBox.cxx | 71 +++++++++++++++++++ .../src/bbPackRecalageImageSwitcherBox.h | 63 ++++++++++++++++ .../src/bbPackRecalageTransparencyV2.cxx | 40 +++++++++++ .../src/bbPackRecalageTransparencyV2.h | 43 +++++++++++ 6 files changed, 314 insertions(+) create mode 100644 PackRecalage/src/bbPackRecalageCheckBoardBox.cxx create mode 100644 PackRecalage/src/bbPackRecalageCheckBoardBox.h create mode 100644 PackRecalage/src/bbPackRecalageImageSwitcherBox.cxx create mode 100644 PackRecalage/src/bbPackRecalageImageSwitcherBox.h create mode 100644 PackRecalage/src/bbPackRecalageTransparencyV2.cxx create mode 100644 PackRecalage/src/bbPackRecalageTransparencyV2.h diff --git a/PackRecalage/src/bbPackRecalageCheckBoardBox.cxx b/PackRecalage/src/bbPackRecalageCheckBoardBox.cxx new file mode 100644 index 0000000..10e6b0e --- /dev/null +++ b/PackRecalage/src/bbPackRecalageCheckBoardBox.cxx @@ -0,0 +1,53 @@ +#include "bbPackRecalageCheckBoardBox.h" +#include "bbPackRecalagePackage.h" +namespace bbPackRecalage +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,CheckBoardBox) +BBTK_BLACK_BOX_IMPLEMENTATION(CheckBoardBox,bbtk::AtomicBlackBox); +void CheckBoardBox::Process() +{ + +// THE MAIN PROCESSING METHOD BODY + checkboard->setInputImage1(bbGetInputIn1()); + checkboard->setInputImage2(bbGetInputIn2()); + checkboard->setRows(bbGetInputRows()); + checkboard->setCols(bbGetInputCols()); + checkboard->calculateImage(); + bbSetOutputOut(checkboard->getFilteredImage()); + +} +void CheckBoardBox::bbUserSetDefaultValues() +{ + +// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX +// Here we initialize the input 'In' to 0 + bbSetInputIn1(NULL); + bbSetInputIn2(NULL); + bbSetInputRows(0); + bbSetInputCols(0); + checkboard=NULL; + +} +void CheckBoardBox::bbUserInitializeProcessing() +{ +// THE INITIALIZATION METHOD BODY : +// Here does nothing +// but this is where you should allocate the internal/output pointers +// if any + checkboard = new CheckBoard(); + +} +void CheckBoardBox::bbUserFinalizeProcessing() +{ + +// THE FINALIZATION METHOD BODY : +// Here does nothing +// but this is where you should desallocate the internal/output pointers +// if any + //delete checkboard; +} +} +// EO namespace bbPackVisuImages + + diff --git a/PackRecalage/src/bbPackRecalageCheckBoardBox.h b/PackRecalage/src/bbPackRecalageCheckBoardBox.h new file mode 100644 index 0000000..bc4a91b --- /dev/null +++ b/PackRecalage/src/bbPackRecalageCheckBoardBox.h @@ -0,0 +1,44 @@ +#ifndef __bbPackRecalageCheckBoardBox_h_INCLUDED__ +#define __bbPackRecalageCheckBoardBox_h_INCLUDED__ +#include "bbPackRecalage_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "vtkImageData.h" +#include "CheckBoard.h" +#include "iostream" + +namespace bbPackRecalage +{ + +class bbPackRecalage_EXPORT CheckBoardBox + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(CheckBoardBox,bbtk::AtomicBlackBox); + BBTK_DECLARE_INPUT(In1, vtkImageData*); + BBTK_DECLARE_INPUT(In2, vtkImageData*); + BBTK_DECLARE_INPUT(Cols, int); + BBTK_DECLARE_INPUT(Rows, int); + BBTK_DECLARE_OUTPUT(Out, vtkImageData*); + BBTK_PROCESS(Process); + void Process(); + + private: + CheckBoard *checkboard; +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(CheckBoardBox,bbtk::AtomicBlackBox); +BBTK_NAME("CheckBoardBox"); +BBTK_AUTHOR("Carolina Perez/Ricardo A Corredor"); +BBTK_DESCRIPTION("Produces a checkboard effect using the two images and thenumber of rows and columns."); +BBTK_CATEGORY("__CATEGORY__"); +BBTK_INPUT(CheckBoardBox, In1, "Input Image1", vtkImageData*, ""); +BBTK_INPUT(CheckBoardBox, In2, "Input Image2", vtkImageData*, ""); +BBTK_INPUT(CheckBoardBox, Cols, "Number of partitions for the X axis (columns)", int, ""); +BBTK_INPUT(CheckBoardBox, Rows, "Number of partitions for the Y axis (rows)", int, ""); +BBTK_OUTPUT(CheckBoardBox, Out, "Output Image", vtkImageData*, ""); +BBTK_END_DESCRIBE_BLACK_BOX(CheckBoardBox); +} +// EO namespace bbPackVisuImages + +#endif // __bbPackVisuImagesCheckBoardBox_h_INCLUDED__ + diff --git a/PackRecalage/src/bbPackRecalageImageSwitcherBox.cxx b/PackRecalage/src/bbPackRecalageImageSwitcherBox.cxx new file mode 100644 index 0000000..c5eee38 --- /dev/null +++ b/PackRecalage/src/bbPackRecalageImageSwitcherBox.cxx @@ -0,0 +1,71 @@ +#include "bbPackRecalageImageSwitcherBox.h" +#include "bbPackRecalagePackage.h" +namespace bbPackRecalage +{ + MyTimer::MyTimer(ImageSwitcherBox *box): wxTimer() + { + _box = box; + } + + MyTimer::~MyTimer() + { + } + + void MyTimer::Notify() + { + _box->Process(); + } + + + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,ImageSwitcherBox) +BBTK_BLACK_BOX_IMPLEMENTATION(ImageSwitcherBox,bbtk::WxBlackBox); +void ImageSwitcherBox::Process() +{ + time = bbGetInputTime(); + + if(myTimer == NULL) + { + myTimer = new MyTimer(this); + myTimer->Start(time); + oldTime = time; + } + else if(oldTime != time) + { + myTimer->Start(time); + oldTime = time; + } + + if(change == false) + { + bbSetOutputOut(bbGetInputIn1()); + change = true; + } + else + { + bbSetOutputOut(bbGetInputIn2()); + change = false; + } +} +void ImageSwitcherBox::CreateWidget(wxWindow* parent) +{ + bbSetOutputWidget( new wxButton ( parent , -1 , _T("Start/Stop Image Change") ) ); +} +void ImageSwitcherBox::bbUserSetDefaultValues() +{ + myTimer = NULL; + change = false; + time = -1; + oldTime = -1; +} +void ImageSwitcherBox::bbUserInitializeProcessing() +{ + +} +void ImageSwitcherBox::bbUserFinalizeProcessing() +{ + myTimer->Stop(); + delete myTimer; +} +} +// EO namespace bbPackRecalage \ No newline at end of file diff --git a/PackRecalage/src/bbPackRecalageImageSwitcherBox.h b/PackRecalage/src/bbPackRecalageImageSwitcherBox.h new file mode 100644 index 0000000..364775c --- /dev/null +++ b/PackRecalage/src/bbPackRecalageImageSwitcherBox.h @@ -0,0 +1,63 @@ +#ifdef _USE_WXWIDGETS_ +#ifndef __bbPackRecalageImageSwitcherBox_h_INCLUDED__ +#define __bbPackRecalageImageSwitcherBox_h_INCLUDED__ +#include "bbPackRecalage_EXPORT.h" +#include "bbtkWxBlackBox.h" + +#include "vtkImageData.h" + +#include + +namespace bbPackRecalage +{ + class ImageSwitcherBox; + + class MyTimer: public wxTimer + { + public: + MyTimer(ImageSwitcherBox *box); + ~MyTimer(); + virtual void Notify(); + + ImageSwitcherBox *_box; + }; + +class bbPackRecalage_EXPORT ImageSwitcherBox + : + public bbtk::WxBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(ImageSwitcherBox,bbtk::WxBlackBox); + BBTK_DECLARE_INPUT(Title,std::string); + BBTK_DECLARE_INPUT(In1,vtkImageData*); + BBTK_DECLARE_INPUT(In2,vtkImageData*); + BBTK_DECLARE_INPUT(Time,int); + BBTK_PROCESS(Process); + BBTK_DECLARE_OUTPUT(Out,vtkImageData*); + void Process(); + BBTK_CREATE_WIDGET(CreateWidget); + void CreateWidget(wxWindow*); + + private: + bool change; + MyTimer *myTimer; + int time; + int oldTime; +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(ImageSwitcherBox,bbtk::WxBlackBox); +BBTK_NAME("ImageSwitcherBox"); +BBTK_AUTHOR("jn.trillos44@uniandes.edu.co"); +BBTK_DESCRIPTION("Switches between 2 images for comparison"); +BBTK_CATEGORY("__CategoryBlackBox__"); +BBTK_INPUT(ImageSwitcherBox,Title,"Title prepended to the Widget",std::string,""); +BBTK_INPUT(ImageSwitcherBox,In1,"First Image",vtkImageData*,""); +BBTK_INPUT(ImageSwitcherBox,In2,"Second Image",vtkImageData*,""); +BBTK_INPUT(ImageSwitcherBox,Time,"Time between image change",int,""); +BBTK_OUTPUT(ImageSwitcherBox,Out,"Image to be placed",vtkImageData*,""); +BBTK_END_DESCRIBE_BLACK_BOX(ImageSwitcherBox); +} +// EO namespace bbPackRecalage + +#endif // __bbPackRecalageImageSwitcherBox_h_INCLUDED__ +#endif // _USE_WXWIDGETS_ + diff --git a/PackRecalage/src/bbPackRecalageTransparencyV2.cxx b/PackRecalage/src/bbPackRecalageTransparencyV2.cxx new file mode 100644 index 0000000..e380128 --- /dev/null +++ b/PackRecalage/src/bbPackRecalageTransparencyV2.cxx @@ -0,0 +1,40 @@ +#include "bbPackRecalageTransparencyV2.h" +#include "bbPackRecalagePackage.h" +namespace bbPackRecalage +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,TransparencyV2) +BBTK_BLACK_BOX_IMPLEMENTATION(TransparencyV2,bbtk::AtomicBlackBox); +void TransparencyV2::Process() +{ + transparency->setImage1(bbGetInputIn1()); + transparency->setImage2(bbGetInputIn2()); + transparency->setPercent(bbGetInputPercent()); + transparency->calculateImage(); + + bbSetOutputOut(transparency->getImage()); +} +void TransparencyV2::bbUserSetDefaultValues() +{ + bbSetInputIn1(NULL); + bbSetInputIn2(NULL); + bbSetInputPercent(-1); + bbSetOutputOut(NULL); +} +void TransparencyV2::bbUserInitializeProcessing() +{ + transparency = new Transparency(); +} +void TransparencyV2::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/bbPackRecalageTransparencyV2.h b/PackRecalage/src/bbPackRecalageTransparencyV2.h new file mode 100644 index 0000000..1d4c751 --- /dev/null +++ b/PackRecalage/src/bbPackRecalageTransparencyV2.h @@ -0,0 +1,43 @@ +#ifndef __bbPackRecalageTransparencyV2_h_INCLUDED__ +#define __bbPackRecalageTransparencyV2_h_INCLUDED__ +#include "bbPackRecalage_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include "vtkImageData.h" +#include "Transparency.h" + +namespace bbPackRecalage +{ + +class bbPackRecalage_EXPORT TransparencyV2 + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(TransparencyV2,bbtk::AtomicBlackBox); + BBTK_DECLARE_INPUT(In1,vtkImageData*); + BBTK_DECLARE_INPUT(In2,vtkImageData*); + BBTK_DECLARE_INPUT(Percent,int); + BBTK_DECLARE_OUTPUT(Out,vtkImageData*); + BBTK_PROCESS(Process); + void Process(); + + private: + Transparency *transparency; +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(TransparencyV2,bbtk::AtomicBlackBox); +BBTK_NAME("TransparencyV2"); +BBTK_AUTHOR("jn.trillos44@uniandes.edu.co"); +BBTK_DESCRIPTION("Second version of a transparency algorithm"); +BBTK_CATEGORY("__CATEGORY__"); +BBTK_INPUT(TransparencyV2,In1,"First image for transparency",vtkImageData*,""); +BBTK_INPUT(TransparencyV2,In2,"Second image for transparency",vtkImageData*,""); +BBTK_INPUT(TransparencyV2,Percent,"Percent of transparency for the second image",int,""); +BBTK_OUTPUT(TransparencyV2,Out,"First output",vtkImageData*,""); +BBTK_END_DESCRIBE_BLACK_BOX(TransparencyV2); +} +// EO namespace bbPackRecalage + +#endif // __bbPackRecalageTransparencyV2_h_INCLUDED__ + -- 2.47.1