]> Creatis software - creaRigidRegistration.git/blob - PackRecalage/src/bbPackRecalageImageSwitcherBox.cxx
*** empty log message ***
[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         _on = bbGetInputOn();
29                 
30         if(myTimer == NULL)
31         {
32                 myTimer = new MyTimer(this);
33                 myTimer->Start(time);
34                 oldTime = time;
35         }
36         
37         if(oldTime != time && myTimer !=NULL)
38         {
39                 myTimer->Stop();
40                 myTimer->Start(time);
41                 oldTime = time;
42         }
43         
44         if(change == false)
45         {
46                 bbSetOutputOut(bbGetInputIn1());
47                 change = true;
48         }
49         else
50         {
51                 bbSetOutputOut(bbGetInputIn2());
52                 change = false;
53         }       
54 }
55 void ImageSwitcherBox::CreateWidget(wxWindow* parent)
56 {
57         bbSetOutputWidget( new wxButton ( parent  , -1 , _T("Start/Stop Image Change") ) );  
58 }
59 void ImageSwitcherBox::bbUserSetDefaultValues()
60 {
61         myTimer = NULL;
62         change = false;
63         time = 500;
64         oldTime = 500;
65         _on = false;
66 }
67 void ImageSwitcherBox::bbUserInitializeProcessing()
68 {
69
70 }
71 void ImageSwitcherBox::bbUserFinalizeProcessing()
72 {
73         myTimer->Stop();
74         delete myTimer;
75 }
76 }
77 // EO namespace bbPackRecalage
78