1 /*=========================================================================
3 Module: $RCSfile: bbkwTransferFunctionEditor.cxx,v $
5 Date: $Date: 2008/12/16 12:48:07 $
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 "bbkwTransferFunctionEditor.h"
43 #include "bbkwPackage.h"
44 //#include "bbtkUtilities.h"
46 #include "vtkKWPiecewiseFunctionEditor.h"
47 #include "vtkPointData.h"
49 //#include "vtkKWScale.h"
50 #include "vtkObjectFactory.h"
51 #include "vtkCommand.h"
56 //--------------------------------------------------------------------------
57 //-------------------------------------------------------------------------
58 // KwBlackBox implementation
59 //--------------------------------------------------------------------------
60 //--------------------------------------------------------------------------
62 //--------------------------------------------------------------------------
63 BBTK_BLACK_BOX_IMPLEMENTATION(TransferFunctionEditor,bbtk::KWBlackBox);
64 BBTK_ADD_BLACK_BOX_TO_PACKAGE(kw,TransferFunctionEditor);
66 //--------------------------------------------------------------------------
67 void TransferFunctionEditor::bbUserConstructor()
74 //--------------------------------------------------------------------------
75 void TransferFunctionEditor::Process()
77 // bbSetOutputOut( bbGetInputIn() );
78 vtkPiecewiseFunction* f = bbGetOutputOut();
81 f = vtkPiecewiseFunction::New();
85 //--------------------------------------------------------------------------
87 //--------------------------------------------------------------------------
88 void TransferFunctionEditor::CreateWidget(vtkKWFrame* parent)
90 vtkPiecewiseFunction* f = bbGetOutputOut();
93 f = vtkPiecewiseFunction::New();
97 vtkKWPiecewiseFunctionEditor *w = vtkKWPiecewiseFunctionEditor::New();
99 // w->SetWindowLevelModeChangedCommand((vtkObject*)this,(const char*)"OnChange");
100 //AddObserver(vtkKWPiecewiseFunctionEditor::FunctionChangedCommand,this);
101 w->SetParent((vtkKWWidget*)parent);
104 w->SetBorderWidth(2);
105 w->SetReliefToGroove();
108 // w->ExpandCanvasWidthOff();
109 // w->ExpandCanvasHeightOn();
110 // w->SetCanvasWidth(450);
111 w->SetCanvasHeight( parent->GetHeight() );
112 w->SetLabelText("");//Transfer Function Editor");
113 w->SetBalloonHelpString("Edit the transfer function");
114 w->LockEndPointsParameterOn();
116 w->PointIndexVisibilityOff();
117 w->SelectedPointIndexVisibilityOff();
118 w->MidPointVisibilityOff();
119 w->PointGuidelineVisibilityOff();
120 w->MidPointGuidelineVisibilityOff();
121 w->MidPointGuidelineValueVisibilityOff();
122 w->SetMidPointGuidelineValueFormat("%-#6.0f");
123 w->MidPointEntryVisibilityOff();
124 w->SharpnessEntryVisibilityOff();
125 w->SetLabelPositionToTop();
127 if ( bbGetInputIn()!=NULL )
129 vtkKWHistogram *h = vtkKWHistogram::New();
130 h->BuildHistogram( bbGetInputIn()->GetPointData()->GetScalars(), 0);
131 double *range = h->GetRange();
132 f->AddPoint(range[0], 0.0 );
133 f->AddPoint(range[1], 1.0 );
139 f->AddPoint(0.0, 0.0);
140 f->AddPoint(1.0, 1.0);
143 w->SetPiecewiseFunction(f);
145 w->ParameterTicksVisibilityOn();
146 w->ComputeValueTicksFromHistogramOn();
147 w->SetParameterTicksFormat( w->GetMidPointGuidelineValueFormat());
153 //--------------------------------------------------------------------------
155 //--------------------------------------------------------------------------
156 void TransferFunctionEditor::OnChange()
159 std::cout << "TransferFunctionEditor::OnChange()" << std::endl;
162 void TransferFunctionEditor::Execute(vtkObject* caller, unsigned long, void*)
164 std::cout << "$$$$$$$$$$$$ TransferFunctionEditor CB $$$$$$$$$$$$"<<std::endl;
166 vtkKWScale* scale = (vtkKWScale*)caller;
167 bbSetOutputOut( scale->GetValue() );
168 bbSetInputIn( scale->GetValue() );
169 // and signal that the output has changed
170 bbSignalOutputModification("Out");
173 //--------------------------------------------------------------------------
179 #endif // USE_KWWIDGETS