X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=PackRecalage%2Fsrc%2FbbPackRecalageImageSwitcherBox.cxx;h=bf4afe9c36f04ff79c5f6ba47b3e538de4034c8e;hb=8b1a19e083976bd9d80693030b7216704555a64f;hp=760207d26150f7b678715bd927014edbac8c9a70;hpb=74a3edf7daa058147c5308ff230a2c3d7658d9ef;p=creaRigidRegistration.git diff --git a/PackRecalage/src/bbPackRecalageImageSwitcherBox.cxx b/PackRecalage/src/bbPackRecalageImageSwitcherBox.cxx index 760207d..bf4afe9 100644 --- a/PackRecalage/src/bbPackRecalageImageSwitcherBox.cxx +++ b/PackRecalage/src/bbPackRecalageImageSwitcherBox.cxx @@ -4,27 +4,55 @@ namespace bbPackRecalage { MyTimer::MyTimer(ImageSwitcherBox *box): wxTimer() { - _box = box; + _box = box; } MyTimer::~MyTimer() { + //delete this; } void MyTimer::Notify() { - _box->Process(); + _box->Change(); _box->bbSignalOutputModification(std::string("Out")); - } - - - + } BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,ImageSwitcherBox) BBTK_BLACK_BOX_IMPLEMENTATION(ImageSwitcherBox,bbtk::WxBlackBox); + +void ImageSwitcherBox::Change() +{ + if(change == false) + { + bbSetOutputOut(bbGetInputIn2()); + change = true; + } + else + { + bbSetOutputOut(bbGetInputIn1()); + change = false; + } +} + void ImageSwitcherBox::Process() { time = bbGetInputTime(); + _on = bbGetInputOn(); + + if(firstTime == true) + { + if(bbGetInputIn1() != NULL) + { + bbSetOutputOut(bbGetInputIn1()); + firstTime = false; + } + else if(bbGetInputIn2() != NULL) + { + bbSetOutputOut(bbGetInputIn2()); + firstTime = false; + } + } if(myTimer == NULL) { @@ -32,27 +60,33 @@ void ImageSwitcherBox::Process() myTimer->Start(time); oldTime = time; } - else if(oldTime != time && myTimer != NULL) + /* + if(oldTime != time && myTimer !=NULL) { myTimer->Stop(); myTimer->Start(time); oldTime = time; - } + }*/ - if(change == false) + if(!_on) { - bbSetOutputOut(bbGetInputIn1()); - change = true; + myTimer->Stop(); } - else + else if(!myTimer->IsRunning()) { - bbSetOutputOut(bbGetInputIn2()); - change = false; + myTimer->Start(time); + oldTime = time; + } + else if(oldTime != time) + { + myTimer->Stop(); + myTimer->Start(time); + oldTime=time; } } void ImageSwitcherBox::CreateWidget(wxWindow* parent) { - bbSetOutputWidget( new wxButton ( parent , -1 , _T("Start/Stop Image Change") ) ); + bbSetOutputWidget( new wxStaticText(parent, -1, _T("Image Switcher")) ); } void ImageSwitcherBox::bbUserSetDefaultValues() { @@ -60,6 +94,8 @@ void ImageSwitcherBox::bbUserSetDefaultValues() change = false; time = 500; oldTime = 500; + firstTime = true; + _on=false; } void ImageSwitcherBox::bbUserInitializeProcessing() {