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: bbqtSlider.cxx,v $
32 Date: $Date: 2012/11/16 08:51:19 $
33 Version: $Revision: 1.3 $
34 =========================================================================*/
39 * \brief Short description in one line
48 #include "bbqtSlider.h"
49 #include "bbqtPackage.h"
50 #include "bbtkUtilities.h"
57 //--------------------------------------------------------------------------
58 //-------------------------------------------------------------------------
59 // QtBlackBox implementation
60 //--------------------------------------------------------------------------
61 //--------------------------------------------------------------------------
63 //--------------------------------------------------------------------------
64 BBTK_BLACK_BOX_IMPLEMENTATION(Slider,bbtk::QtBlackBox);
65 BBTK_ADD_BLACK_BOX_TO_PACKAGE(qt,Slider);
67 //--------------------------------------------------------------------------
68 void Slider::bbUserSetDefaultValues()
74 bbSetInputOrientation("HORIZONTAL");
75 bbSetInputChangeResolution(false);
76 bbSetInputLabel(true);
77 bbSetInputReactiveOnTrack(false);
79 //--------------------------------------------------------------------------
82 //--------------------------------------------------------------------------
83 void Slider::bbUserInitializeProcessing()
86 //--------------------------------------------------------------------------
89 //--------------------------------------------------------------------------
90 void Slider::bbUserFinalizeProcessing()
93 //--------------------------------------------------------------------------
97 //--------------------------------------------------------------------------
98 void Slider::Process()
100 bbtkDebugMessage("process",3,
101 "Slider "<<bbGetName()<<" input="
102 <<bbGetInputIn()<<std::endl);
104 bbSetOutputOut( bbGetInputIn() );
105 if (bbGetOutputWidget()!=0)
107 ((QSlider*)bbGetOutputWidget())->setValue(bbGetInputIn());
110 //--------------------------------------------------------------------------
112 //--------------------------------------------------------------------------
113 void Slider::CreateWidget(QWidget* parent)
116 Qt::Orientation orientation;
117 if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"0|H|HORIZONTAL")
119 { orientation = Qt::Horizontal; }
120 if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"1|V|VERTICAL")
122 { orientation = Qt::Vertical ; }
125 // std::cout << "bbGetQtParent = "<<bbGetQtParent()<<std::endl;
126 QSlider *w = new QSlider(parent);
127 w->setOrientation(orientation);
128 w->setMinimum( bbGetInputMin() );
129 w->setMaximum( bbGetInputMax() );
130 w->setSliderPosition ( bbGetInputIn() );
132 if (bbGetInputReactiveOnTrack())
133 w->setTracking(true);
135 w->setTracking(false);
137 connect(w,SIGNAL(valueChanged(int)),this,SLOT(OnValueChanged(int)));
140 bbSetOutputWidget( w );
142 //--------------------------------------------------------------------------
144 //--------------------------------------------------------------------------
145 void Slider::OnValueChanged(int v)
147 // std::cout << "OnValueChanged "<<v<<std::endl;
150 // and signal that the output has changed
151 bbSignalOutputModification(std::string("Out"));
154 //--------------------------------------------------------------------------