2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
28 /*=========================================================================
30 Module: $RCSfile: bbkwSlider.cxx,v $
32 Date: $Date: 2012/11/16 08:51:05 $
33 Version: $Revision: 1.4 $
34 =========================================================================*/
40 * \brief Short description in one line
49 #include "bbkwSlider.h"
50 #include "bbkwPackage.h"
51 #include "bbtkUtilities.h"
53 #include "vtkKWScale.h"
54 #include "vtkObjectFactory.h"
55 #include "vtkCommand.h"
60 //--------------------------------------------------------------------------
61 class Callback : public vtkCommand
64 static Callback *New() { return new Callback; }
65 virtual void Execute(vtkObject* caller, unsigned long, void*)
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");
76 //--------------------------------------------------------------------------
79 //--------------------------------------------------------------------------
80 //-------------------------------------------------------------------------
81 // KwBlackBox implementation
82 //--------------------------------------------------------------------------
83 //--------------------------------------------------------------------------
85 //--------------------------------------------------------------------------
86 BBTK_BLACK_BOX_IMPLEMENTATION(Slider,bbtk::KWBlackBox);
87 BBTK_ADD_BLACK_BOX_TO_PACKAGE(kw,Slider);
89 //--------------------------------------------------------------------------
90 void Slider::bbUserConstructor()
97 bbSetInputOrientation("HORIZONTAL");
98 bbSetInputChangeResolution(false);
99 bbSetInputLabel(true);
101 bbSetInputReactiveOnTrack(0);
104 //--------------------------------------------------------------------------
105 void Slider::Process()
107 bbSetOutputOut( bbGetInputIn() );
109 //--------------------------------------------------------------------------
111 //--------------------------------------------------------------------------
112 void Slider::CreateWidget(vtkKWFrame* parent)
114 vtkKWScale* s = vtkKWScale::New();
115 bbSetOutputWidget(s);
116 s->AddObserver(vtkKWScale::ScaleValueChangingEvent,this);
117 s->SetParent((vtkKWWidget*)parent);
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)
126 s->SetOrientationToHorizontal();
128 else if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"1|V|VERTICAL")==true)
130 s->SetOrientationToVertical();
134 bbtkWarning("Unrecognized value for input 'Orientation' of "<<bbGetFullName());
137 bbSetOutputOut( bbGetInputIn() );
139 //--------------------------------------------------------------------------
141 //--------------------------------------------------------------------------
143 void Slider::Execute(vtkObject* caller, unsigned long, void*)
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"));
152 //--------------------------------------------------------------------------
158 #endif // USE_KWWIDGETS