1 /*=========================================================================
3 Module: $RCSfile: bbqtQSlider.cxx,v $
5 Date: $Date: 2009/04/08 07:56:33 $
6 Version: $Revision: 1.1 $
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 "bbqtQSlider.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::bbUserConstructor()
68 bbSetInputOrientation("HORIZONTAL");
69 bbSetInputChangeResolution(false);
70 bbSetInputLabel(true);
71 bbSetInputReactiveOnTrack(false);
73 //--------------------------------------------------------------------------
75 //--------------------------------------------------------------------------
76 void Slider::Process()
78 bbtkDebugMessage("process",3,
79 "Slider "<<bbGetName()<<" input="
80 <<bbGetInputIn()<<std::endl);
82 bbSetOutputOut( bbGetInputIn() );
83 if (bbGetOutputWidget()!=0)
85 ((QSlider*)bbGetOutputWidget())->setValue(bbGetInputIn());
88 //--------------------------------------------------------------------------
90 //--------------------------------------------------------------------------
91 void Slider::CreateWidget(QWidget* parent)
94 Qt::Orientation orientation;
95 if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"0|H|HORIZONTAL")
97 { orientation = Qt::Horizontal; }
98 if (bbtk::Utilities::loosematch(bbGetInputOrientation(),"1|V|VERTICAL")
100 { orientation = Qt::Vertical ; }
103 // std::cout << "bbGetQtParent = "<<bbGetQtParent()<<std::endl;
104 QSlider *w = new QSlider(parent);
105 w->setOrientation(orientation);
106 w->setMinimum( bbGetInputMin() );
107 w->setMaximum( bbGetInputMax() );
108 w->setSliderPosition ( bbGetInputIn() );
110 if (bbGetInputReactiveOnTrack())
111 w->setTracking(true);
113 w->setTracking(false);
115 connect(w,SIGNAL(valueChanged(int)),this,SLOT(OnValueChanged(int)));
118 bbSetOutputWidget( w );
120 //--------------------------------------------------------------------------
122 //--------------------------------------------------------------------------
123 void Slider::OnValueChanged(int v)
125 // std::cout << "OnValueChanged "<<v<<std::endl;
128 // and signal that the output has changed
129 bbSignalOutputModification(std::string("Out"));
132 //--------------------------------------------------------------------------