]> Creatis software - creaRigidRegistration.git/blob - PackRecalage/src/bbPackRecalageImageSwitcherBox.cxx
760207d26150f7b678715bd927014edbac8c9a70
[creaRigidRegistration.git] / PackRecalage / src / bbPackRecalageImageSwitcherBox.cxx
1 #include "bbPackRecalageImageSwitcherBox.h"
2 #include "bbPackRecalagePackage.h"
3 namespace bbPackRecalage
4 {
5         MyTimer::MyTimer(ImageSwitcherBox *box): wxTimer()
6         {
7                 _box = box;
8         }
9
10         MyTimer::~MyTimer()
11         {
12         }
13
14         void MyTimer::Notify()
15         {
16                 _box->Process();
17                 _box->bbSignalOutputModification(std::string("Out")); 
18         }
19
20
21         
22
23 BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,ImageSwitcherBox)
24 BBTK_BLACK_BOX_IMPLEMENTATION(ImageSwitcherBox,bbtk::WxBlackBox);
25 void ImageSwitcherBox::Process()
26 {
27         time = bbGetInputTime();
28                 
29         if(myTimer == NULL)
30         {
31                 myTimer = new MyTimer(this);
32                 myTimer->Start(time);
33                 oldTime = time;
34         }
35         else if(oldTime != time && myTimer != NULL)
36         {
37                 myTimer->Stop();
38                 myTimer->Start(time);
39                 oldTime = time;
40         }
41
42         if(change == false)
43         {
44                 bbSetOutputOut(bbGetInputIn1());
45                 change = true;
46         }
47         else
48         {
49                 bbSetOutputOut(bbGetInputIn2());
50                 change = false;
51         }
52 }
53 void ImageSwitcherBox::CreateWidget(wxWindow* parent)
54 {
55         bbSetOutputWidget( new wxButton ( parent  , -1 , _T("Start/Stop Image Change") ) );  
56 }
57 void ImageSwitcherBox::bbUserSetDefaultValues()
58 {
59         myTimer = NULL;
60         change = false;
61         time = 500;
62         oldTime = 500;
63 }
64 void ImageSwitcherBox::bbUserInitializeProcessing()
65 {
66
67 }
68 void ImageSwitcherBox::bbUserFinalizeProcessing()
69 {
70         myTimer->Stop();
71         delete myTimer;
72 }
73 }
74 // EO namespace bbPackRecalage
75