]> Creatis software - bbtk.git/blob - packages/kw/src/bbkwSlider.cxx
Feature #1774
[bbtk.git] / packages / kw / src / bbkwSlider.cxx
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 #                        pour la SantÈ)
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 #
10 #  This software is governed by the CeCILL-B license under French law and
11 #  abiding by the rules of distribution of free software. You can  use,
12 #  modify and/ or redistribute the software under the terms of the CeCILL-B
13 #  license as circulated by CEA, CNRS and INRIA at the following URL
14 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 #  or in the file LICENSE.txt.
16 #
17 #  As a counterpart to the access to the source code and  rights to copy,
18 #  modify and redistribute granted by the license, users are provided only
19 #  with a limited warranty  and the software's author,  the holder of the
20 #  economic rights,  and the successive licensors  have only  limited
21 #  liability.
22 #
23 #  The fact that you are presently reading this means that you have had
24 #  knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
26
27
28 /*=========================================================================
29   Program:   bbtk
30   Module:    $RCSfile: bbkwSlider.cxx,v $
31   Language:  C++
32   Date:      $Date: 2012/11/16 08:51:05 $
33   Version:   $Revision: 1.4 $
34 =========================================================================*/
35
36
37
38 /**
39  * \file 
40  * \brief Short description in one line
41  *
42  * Long 
43  * description
44  *  
45  */
46
47 #ifdef USE_KWWIDGETS
48
49 #include "bbkwSlider.h"
50 #include "bbkwPackage.h"
51 #include "bbtkUtilities.h"
52
53 #include "vtkKWScale.h"
54 #include "vtkObjectFactory.h"
55 #include "vtkCommand.h"
56
57 namespace bbkw
58 {
59   /*
60   //--------------------------------------------------------------------------
61   class Callback : public vtkCommand
62   {
63   public:
64     static Callback *New() { return new Callback; }
65     virtual void Execute(vtkObject* caller, unsigned long, void*)
66     {
67       //      std::cout << "$$$$$$$$$$$$ Slider CB $$$$$$$$$$$$"<<std::endl;
68       vtkKWScale* scale = (vtkKWScale*)caller;
69       mBox->bbSetOutputOut( scale->GetValue() );
70       mBox->bbSetInputIn( scale->GetValue() );
71       // and signal that the output has changed
72       mBox->bbSignalOutputModification("Out");    
73     }
74     Slider* mBox;
75   };
76   //--------------------------------------------------------------------------
77   */
78
79   //--------------------------------------------------------------------------
80   //-------------------------------------------------------------------------
81   // KwBlackBox implementation
82   //--------------------------------------------------------------------------
83   //--------------------------------------------------------------------------
84
85    //--------------------------------------------------------------------------
86   BBTK_BLACK_BOX_IMPLEMENTATION(Slider,bbtk::KWBlackBox);
87   BBTK_ADD_BLACK_BOX_TO_PACKAGE(kw,Slider);
88   
89   //--------------------------------------------------------------------------
90   void Slider::bbUserConstructor() 
91   { 
92     bbSetInputIn(0);
93     bbSetInputMin(0);
94     bbSetInputMax(500);
95     bbSetOutputOut(0);
96     bbSetOutputWidget(0);
97     bbSetInputOrientation("HORIZONTAL");
98     bbSetInputChangeResolution(false);
99     bbSetInputLabel(true);
100     bbSetInputTitle("");
101     bbSetInputReactiveOnTrack(0);    
102   }
103   
104  //--------------------------------------------------------------------------
105   void Slider::Process() 
106   {
107     bbSetOutputOut( bbGetInputIn() );
108   }
109   //--------------------------------------------------------------------------
110
111   //--------------------------------------------------------------------------
112   void Slider::CreateWidget(vtkKWFrame* parent) 
113   {
114     vtkKWScale* s = vtkKWScale::New();
115     bbSetOutputWidget(s);
116     s->AddObserver(vtkKWScale::ScaleValueChangingEvent,this);
117     s->SetParent((vtkKWWidget*)parent);
118     s->Create();
119
120     s->SetRange(bbGetInputMin(),bbGetInputMax());
121     // s->SetResolution(1.0);
122     // s->SetLength(150);
123     s->SetLabelText(bbGetInputTitle().c_str());
124     if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"0|H|HORIZONTAL")==true) 
125       {
126         s->SetOrientationToHorizontal();
127       }
128     else if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"1|V|VERTICAL")==true)  
129       {
130         s->SetOrientationToVertical();
131       }
132     else 
133       {
134         bbtkWarning("Unrecognized value for input 'Orientation' of "<<bbGetFullName());
135       }
136
137     bbSetOutputOut( bbGetInputIn() );
138   }
139   //--------------------------------------------------------------------------
140
141   //--------------------------------------------------------------------------
142   
143   void Slider::Execute(vtkObject* caller, unsigned long, void*)
144   {
145     //    std::cout << "$$$$$$$$$$$$ Slider CB $$$$$$$$$$$$"<<std::endl;
146     vtkKWScale* scale = (vtkKWScale*)caller;
147     bbSetOutputOut( scale->GetValue() );
148     bbSetInputIn( scale->GetValue() );
149     // and signal that the output has changed
150         bbSignalOutputModification(std::string("Out"));    
151   } 
152   //--------------------------------------------------------------------------
153   
154
155
156 } //namespace bbkw
157
158 #endif // USE_KWWIDGETS
159
160