1 /*=========================================================================
3 Module: $RCSfile: bbqtSlider.cxx,v $
5 Date: $Date: 2009/05/14 16:21:19 $
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 "bbqtSlider.h"
43 #include "bbqtPackage.h"
44 #include "bbtkUtilities.h"
51 //--------------------------------------------------------------------------
52 //-------------------------------------------------------------------------
53 // QtBlackBox implementation
54 //--------------------------------------------------------------------------
55 //--------------------------------------------------------------------------
57 //--------------------------------------------------------------------------
58 BBTK_BLACK_BOX_IMPLEMENTATION(Slider,bbtk::QtBlackBox);
59 BBTK_ADD_BLACK_BOX_TO_PACKAGE(qt,Slider);
61 //--------------------------------------------------------------------------
62 void Slider::bbUserSetDefaultValues()
68 bbSetInputOrientation("HORIZONTAL");
69 bbSetInputChangeResolution(false);
70 bbSetInputLabel(true);
71 bbSetInputReactiveOnTrack(false);
73 //--------------------------------------------------------------------------
76 //--------------------------------------------------------------------------
77 void Slider::bbUserInitializeProcessing()
80 //--------------------------------------------------------------------------
83 //--------------------------------------------------------------------------
84 void Slider::bbUserFinalizeProcessing()
87 //--------------------------------------------------------------------------
91 //--------------------------------------------------------------------------
92 void Slider::Process()
94 bbtkDebugMessage("process",3,
95 "Slider "<<bbGetName()<<" input="
96 <<bbGetInputIn()<<std::endl);
98 bbSetOutputOut( bbGetInputIn() );
99 if (bbGetOutputWidget()!=0)
101 ((QSlider*)bbGetOutputWidget())->setValue(bbGetInputIn());
104 //--------------------------------------------------------------------------
106 //--------------------------------------------------------------------------
107 void Slider::CreateWidget(QWidget* parent)
110 Qt::Orientation orientation;
111 if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"0|H|HORIZONTAL")
113 { orientation = Qt::Horizontal; }
114 if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"1|V|VERTICAL")
116 { orientation = Qt::Vertical ; }
119 // std::cout << "bbGetQtParent = "<<bbGetQtParent()<<std::endl;
120 QSlider *w = new QSlider(parent);
121 w->setOrientation(orientation);
122 w->setMinimum( bbGetInputMin() );
123 w->setMaximum( bbGetInputMax() );
124 w->setSliderPosition ( bbGetInputIn() );
126 if (bbGetInputReactiveOnTrack())
127 w->setTracking(true);
129 w->setTracking(false);
131 connect(w,SIGNAL(valueChanged(int)),this,SLOT(OnValueChanged(int)));
134 bbSetOutputWidget( w );
136 //--------------------------------------------------------------------------
138 //--------------------------------------------------------------------------
139 void Slider::OnValueChanged(int v)
141 // std::cout << "OnValueChanged "<<v<<std::endl;
144 // and signal that the output has changed
145 bbSignalOutputModification(std::string("Out"));
148 //--------------------------------------------------------------------------