1 /*=========================================================================
3 Module: $RCSfile: bbkwSlider.cxx,v $
5 Date: $Date: 2008/12/02 13:37:56 $
6 Version: $Revision: 1.2 $
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
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.
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
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 * ------------------------------------------------------------------------ */
33 * \brief Short description in one line
42 #include "bbkwSlider.h"
43 #include "bbkwPackage.h"
44 #include "bbtkUtilities.h"
46 #include "vtkKWScale.h"
47 #include "vtkObjectFactory.h"
48 #include "vtkCommand.h"
53 //--------------------------------------------------------------------------
54 class Callback : public vtkCommand
57 static Callback *New() { return new Callback; }
58 virtual void Execute(vtkObject* caller, unsigned long, void*)
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");
69 //--------------------------------------------------------------------------
72 //--------------------------------------------------------------------------
73 //-------------------------------------------------------------------------
74 // KwBlackBox implementation
75 //--------------------------------------------------------------------------
76 //--------------------------------------------------------------------------
78 //--------------------------------------------------------------------------
79 BBTK_BLACK_BOX_IMPLEMENTATION(Slider,bbtk::KWBlackBox);
80 BBTK_ADD_BLACK_BOX_TO_PACKAGE(kw,Slider);
82 //--------------------------------------------------------------------------
83 void Slider::bbUserConstructor()
90 bbSetInputOrientation("HORIZONTAL");
91 bbSetInputChangeResolution(false);
92 bbSetInputLabel(true);
94 bbSetInputReactiveOnTrack(0);
97 //--------------------------------------------------------------------------
98 void Slider::Process()
100 bbSetOutputOut( bbGetInputIn() );
102 //--------------------------------------------------------------------------
104 //--------------------------------------------------------------------------
105 void Slider::CreateWidget(vtkKWFrame* parent)
107 vtkKWScale* s = vtkKWScale::New();
108 bbSetOutputWidget(s);
109 s->AddObserver(vtkKWScale::ScaleValueChangingEvent,this);
110 s->SetParent((vtkKWWidget*)parent);
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)
119 s->SetOrientationToHorizontal();
121 else if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"1|V|VERTICAL")==true)
123 s->SetOrientationToVertical();
127 bbtkWarning("Unrecognized value for input 'Orientation' of "<<bbGetFullName());
130 bbSetOutputOut( bbGetInputIn() );
132 //--------------------------------------------------------------------------
134 //--------------------------------------------------------------------------
136 void Slider::Execute(vtkObject* caller, unsigned long, void*)
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("Out");
145 //--------------------------------------------------------------------------
151 #endif // USE_KWWIDGETS