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