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: bbkwTransferFunctionEditor.cxx,v $
32 Date: $Date: 2012/11/16 08:51:05 $
33 Version: $Revision: 1.4 $
34 =========================================================================*/
39 * \brief Short description in one line
48 #include "bbkwTransferFunctionEditor.h"
49 #include "bbkwPackage.h"
50 //#include "bbtkUtilities.h"
52 #include "vtkKWPiecewiseFunctionEditor.h"
53 #include "vtkPointData.h"
55 //#include "vtkKWScale.h"
56 #include "vtkObjectFactory.h"
57 #include "vtkCommand.h"
62 //--------------------------------------------------------------------------
63 //-------------------------------------------------------------------------
64 // KwBlackBox implementation
65 //--------------------------------------------------------------------------
66 //--------------------------------------------------------------------------
68 //--------------------------------------------------------------------------
69 BBTK_BLACK_BOX_IMPLEMENTATION(TransferFunctionEditor,bbtk::KWBlackBox);
70 BBTK_ADD_BLACK_BOX_TO_PACKAGE(kw,TransferFunctionEditor);
72 //--------------------------------------------------------------------------
73 void TransferFunctionEditor::bbUserConstructor()
77 bbSetInputTitle("Transfer function");
81 //--------------------------------------------------------------------------
82 void TransferFunctionEditor::Process()
84 // bbSetOutputOut( bbGetInputIn() );
85 vtkPiecewiseFunction* f = bbGetOutputOut();
88 f = vtkPiecewiseFunction::New();
92 //--------------------------------------------------------------------------
94 //--------------------------------------------------------------------------
95 void TransferFunctionEditor::CreateWidget(vtkKWFrame* parent)
97 vtkPiecewiseFunction* f = bbGetOutputOut();
100 f = vtkPiecewiseFunction::New();
104 vtkKWPiecewiseFunctionEditor *w = vtkKWPiecewiseFunctionEditor::New();
105 bbSetOutputWidget(w);
106 w->AddObserver(vtkKWPiecewiseFunctionEditor::FunctionChangedEvent,this);
107 w->SetParent((vtkKWWidget*)parent);
110 w->SetBorderWidth(2);
111 w->SetReliefToGroove();
114 // w->ExpandCanvasWidthOff();
115 // w->ExpandCanvasHeightOn();
116 // w->SetCanvasWidth(450);
117 w->SetCanvasHeight( parent->GetHeight() - 100 );
118 w->SetLabelText(bbGetInputTitle().c_str());
119 w->SetBalloonHelpString("Edit the transfer function");
120 w->LockEndPointsParameterOn();
122 w->PointIndexVisibilityOff();
123 w->SelectedPointIndexVisibilityOff();
124 w->MidPointVisibilityOff();
125 w->PointGuidelineVisibilityOff();
126 w->MidPointGuidelineVisibilityOff();
127 w->MidPointGuidelineValueVisibilityOff();
128 w->SetMidPointGuidelineValueFormat("%-#6.0f");
129 w->MidPointEntryVisibilityOff();
130 w->SharpnessEntryVisibilityOff();
131 w->SetLabelPositionToTop();
133 if ( bbGetInputIn()!=NULL )
135 vtkKWHistogram *h = vtkKWHistogram::New();
136 h->BuildHistogram( bbGetInputIn()->GetPointData()->GetScalars(), 0);
137 double *range = h->GetRange();
138 f->AddPoint(range[0], 0.0 );
139 f->AddPoint(range[1], 1.0 );
145 f->AddPoint(0.0, 0.0);
146 f->AddPoint(1.0, 1.0);
149 w->SetPiecewiseFunction(f);
151 w->ParameterTicksVisibilityOn();
152 w->ComputeValueTicksFromHistogramOn();
153 w->SetParameterTicksFormat( w->GetMidPointGuidelineValueFormat());
159 //--------------------------------------------------------------------------
161 //--------------------------------------------------------------------------
162 void TransferFunctionEditor::OnChange()
165 std::cout << "TransferFunctionEditor::OnChange()" << std::endl;
168 void TransferFunctionEditor::Execute(vtkObject* caller, unsigned long , void*)
170 bbSignalOutputModification("Out");
171 // std::cout << "$$$$$$$$$$$$ TransferFunctionEditor CB $$$$$$$$$$$$"<<std::endl;
174 vtkKWScale* scale = (vtkKWScale*)caller;
175 bbSetOutputOut( scale->GetValue() );
176 bbSetInputIn( scale->GetValue() );
177 // and signal that the output has changed
178 bbSignalOutputModification("Out");
181 //--------------------------------------------------------------------------
187 #endif // USE_KWWIDGETS