From: davila Date: Fri, 9 Oct 2015 13:31:04 +0000 (+0200) Subject: #2712 creaVtk Feature New Normal - new ScalarBarActor ScalarToColors box X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?p=creaVtk.git;a=commitdiff_plain;h=d5304f54eeaf1ca78281d983986b69922439db04 #2712 creaVtk Feature New Normal - new ScalarBarActor ScalarToColors box --- diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkScalarBarActor.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkScalarBarActor.cxx new file mode 100644 index 0000000..9f19bc6 --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkScalarBarActor.cxx @@ -0,0 +1,98 @@ +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +#include "bbcreaVtkScalarBarActor.h" +#include "bbcreaVtkPackage.h" + +#include + +namespace bbcreaVtk +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ScalarBarActor) +BBTK_BLACK_BOX_IMPLEMENTATION(ScalarBarActor,bbtk::AtomicBlackBox); +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void ScalarBarActor::Process() +{ + +// THE MAIN PROCESSING METHOD BODY +// Here we simply set the input 'In' value to the output 'Out' +// And print out the output value +// INPUT/OUTPUT ACCESSORS ARE OF THE FORM : +// void bbSet{Input|Output}NAME(const TYPE&) +// const TYPE& bbGet{Input|Output}NAME() const +// Where : +// * NAME is the name of the input/output +// (the one provided in the attribute 'name' of the tag 'input') +// * TYPE is the C++ type of the input/output +// (the one provided in the attribute 'type' of the tag 'input') + + +// bbSetOutputOut( bbGetInputIn() ); +// std::cout << "Output value = " <SetLookupTable( bbGetInputLookupTable() ); + scalarbarActor->SetTitle("Value"); + scalarbarActor->SetNumberOfLabels(4); + int fontsize = scalarbarActor->GetLabelTextProperty()->GetFontSize(); + scalarbarActor->GetLabelTextProperty()->SetFontSize(fontsize/2); + if (bbGetInputRenderer()!=NULL) + { + bbGetInputRenderer()->AddActor2D( scalarbarActor ); + } + } // firsttime + +printf ("EED ScalarBarActor End\n"); + +} + +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void ScalarBarActor::bbUserSetDefaultValues() +{ + +// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX +// Here we initialize the input 'In' to 0 + bbSetInputLookupTable(NULL); + bbSetInputRenderer(NULL); + firsttime=true; + +} +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void ScalarBarActor::bbUserInitializeProcessing() +{ + +// THE INITIALIZATION METHOD BODY : +// Here does nothing +// but this is where you should allocate the internal/output pointers +// if any + + +} +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void ScalarBarActor::bbUserFinalizeProcessing() +{ + +// THE FINALIZATION METHOD BODY : +// Here does nothing +// but this is where you should desallocate the internal/output pointers +// if any + +} +} +// EO namespace bbcreaVtk + + diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkScalarBarActor.h b/bbtk_creaVtk_PKG/src/bbcreaVtkScalarBarActor.h new file mode 100644 index 0000000..9dc8403 --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkScalarBarActor.h @@ -0,0 +1,54 @@ +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +#ifndef __bbcreaVtkScalarBarActor_h_INCLUDED__ +#define __bbcreaVtkScalarBarActor_h_INCLUDED__ +#include "bbcreaVtk_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include +#include +#include + +namespace bbcreaVtk +{ + +class bbcreaVtk_EXPORT ScalarBarActor + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(ScalarBarActor,bbtk::AtomicBlackBox); +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== + BBTK_DECLARE_INPUT(LookupTable,vtkScalarsToColors*); + BBTK_DECLARE_INPUT(Renderer,vtkRenderer*); +// BBTK_DECLARE_OUTPUT(Out,double); + BBTK_PROCESS(Process); + void Process(); + + bool firsttime; + +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(ScalarBarActor,bbtk::AtomicBlackBox); + BBTK_NAME("ScalarBarActor"); + BBTK_AUTHOR("Info-Dev"); + BBTK_DESCRIPTION("No Description."); + BBTK_CATEGORY("empty"); + BBTK_INPUT(ScalarBarActor,LookupTable,"LookupTable",vtkScalarsToColors*,""); + BBTK_INPUT(ScalarBarActor,Renderer,"Renderer",vtkRenderer*,""); +// BBTK_OUTPUT(ScalarBarActor,Out,"First output",double,""); +BBTK_END_DESCRIBE_BLACK_BOX(ScalarBarActor); +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +} +// EO namespace bbcreaVtk + +#endif // __bbcreaVtkScalarBarActor_h_INCLUDED__ + diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkScalarsToColors.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkScalarsToColors.cxx new file mode 100644 index 0000000..e4524c6 --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkScalarsToColors.cxx @@ -0,0 +1,119 @@ +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +#include "bbcreaVtkScalarsToColors.h" +#include "bbcreaVtkPackage.h" + +namespace bbcreaVtk +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ScalarsToColors) +BBTK_BLACK_BOX_IMPLEMENTATION(ScalarsToColors,bbtk::AtomicBlackBox); +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void ScalarsToColors::Process() +{ + +// THE MAIN PROCESSING METHOD BODY +// Here we simply set the input 'In' value to the output 'Out' +// And print out the output value +// INPUT/OUTPUT ACCESSORS ARE OF THE FORM : +// void bbSet{Input|Output}NAME(const TYPE&) +// const TYPE& bbGet{Input|Output}NAME() const +// Where : +// * NAME is the name of the input/output +// (the one provided in the attribute 'name' of the tag 'input') +// * TYPE is the C++ type of the input/output +// (the one provided in the attribute 'type' of the tag 'input') + +// bbSetOutputOut( bbGetInputIn() ); +// std::cout << "Output value = " <Build(); + double rgba1[4]; + double rgba2[4]; + for (int iLookTable = 0; iLookTable<128; iLookTable++) + { + _colorLookupTable->GetTableValue( iLookTable, rgba1); + _colorLookupTable->GetTableValue(256-1-iLookTable, rgba2); + + _colorLookupTable->SetTableValue(256-1-iLookTable , rgba1[0],rgba1[1],rgba1[2],rgba1[3]); + _colorLookupTable->SetTableValue( iLookTable , rgba2[0],rgba2[1],rgba2[2],rgba2[3]); + } // for iLookTable + } // if + } // firsttime + + if (bbGetInputRange().size()==2) + { + _colorLookupTable->SetTableRange( bbGetInputRange()[0],bbGetInputRange()[1]); + } else { + _colorLookupTable->SetTableRange( 0,1 ); + } + + double rgb[3]; + _colorLookupTable->GetColor( bbGetInputScalarValue() , rgb ); + std::vectorcolorRGB; + colorRGB.push_back( rgb[0] ); + colorRGB.push_back( rgb[1] ); + colorRGB.push_back( rgb[2] ); + + bbSetOutputColor( colorRGB ); + bbSetOutputLookupTable(_colorLookupTable); + +} +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void ScalarsToColors::bbUserSetDefaultValues() +{ + +// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX +// Here we initialize the input 'In' to 0 + bbSetInputType(0); + std::vectorrange; + range.push_back( 0 ); + range.push_back( 1 ); + bbSetInputRange(range); + bbSetInputScalarValue(0); + firsttime=true; + + _colorLookupTable=NULL; +} +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void ScalarsToColors::bbUserInitializeProcessing() +{ + +// THE INITIALIZATION METHOD BODY : +// Here does nothing +// but this is where you should allocate the internal/output pointers +// if any + + +} +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void ScalarsToColors::bbUserFinalizeProcessing() +{ + +// THE FINALIZATION METHOD BODY : +// Here does nothing +// but this is where you should desallocate the internal/output pointers +// if any + +} +} +// EO namespace bbcreaVtk + + diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkScalarsToColors.h b/bbtk_creaVtk_PKG/src/bbcreaVtkScalarsToColors.h new file mode 100644 index 0000000..c3c2bd8 --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkScalarsToColors.h @@ -0,0 +1,59 @@ +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +#ifndef __bbcreaVtkScalarsToColors_h_INCLUDED__ +#define __bbcreaVtkScalarsToColors_h_INCLUDED__ +#include "bbcreaVtk_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include +#include + +namespace bbcreaVtk +{ + +class bbcreaVtk_EXPORT ScalarsToColors + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(ScalarsToColors,bbtk::AtomicBlackBox); +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== + BBTK_DECLARE_INPUT(Type,int); + BBTK_DECLARE_INPUT(ScalarValue,double); + BBTK_DECLARE_INPUT(Range,std::vector ); + BBTK_DECLARE_OUTPUT(Color, std::vector ); + BBTK_DECLARE_OUTPUT(LookupTable,vtkScalarsToColors*); + BBTK_PROCESS(Process); + void Process(); + + bool firsttime; + vtkLookupTable *_colorLookupTable; + + +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(ScalarsToColors,bbtk::AtomicBlackBox); + BBTK_NAME("ScalarsToColors"); + BBTK_AUTHOR("Info-Dev"); + BBTK_DESCRIPTION("No Description."); + BBTK_CATEGORY("empty"); + BBTK_INPUT(ScalarsToColors,Type,"Type of color table",int,""); + BBTK_INPUT(ScalarsToColors,ScalarValue,"Scalar value",double,""); + BBTK_INPUT(ScalarsToColors,Range,"Min Max range",std::vector,""); + BBTK_OUTPUT(ScalarsToColors,Color,"Color",std::vector,""); + BBTK_OUTPUT(ScalarsToColors,LookupTable,"LookupTable",vtkScalarsToColors*,""); +BBTK_END_DESCRIBE_BLACK_BOX(ScalarsToColors); +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +} +// EO namespace bbcreaVtk + +#endif // __bbcreaVtkScalarsToColors_h_INCLUDED__ +