]> Creatis software - creaRigidRegistration.git/blob - PackRecalage/src/bbPackRecalageImageSwitcherBox.cxx
c5eee38fd2f570b769e6fc72512dd6737a57d11b
[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         }
18
19         
20
21 BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,ImageSwitcherBox)
22 BBTK_BLACK_BOX_IMPLEMENTATION(ImageSwitcherBox,bbtk::WxBlackBox);
23 void ImageSwitcherBox::Process()
24 {
25         time = bbGetInputTime();
26                 
27         if(myTimer == NULL)
28         {
29                 myTimer = new MyTimer(this);
30                 myTimer->Start(time);
31                 oldTime = time;
32         }
33         else if(oldTime != time)
34         {
35                 myTimer->Start(time);
36                 oldTime = time;
37         }
38
39         if(change == false)
40         {
41                 bbSetOutputOut(bbGetInputIn1());
42                 change = true;
43         }
44         else
45         {
46                 bbSetOutputOut(bbGetInputIn2());
47                 change = false;
48         }
49 }
50 void ImageSwitcherBox::CreateWidget(wxWindow* parent)
51 {
52         bbSetOutputWidget( new wxButton ( parent  , -1 , _T("Start/Stop Image Change") ) );  
53 }
54 void ImageSwitcherBox::bbUserSetDefaultValues()
55 {
56         myTimer = NULL;
57         change = false;
58         time = -1;
59         oldTime = -1;
60 }
61 void ImageSwitcherBox::bbUserInitializeProcessing()
62 {
63
64 }
65 void ImageSwitcherBox::bbUserFinalizeProcessing()
66 {
67         myTimer->Stop();
68         delete myTimer;
69 }
70 }
71 // EO namespace bbPackRecalage