]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbcreaMaracasVisuColorLayerImageView2.cxx
#3555 ColorLayer box input Interpolation
[creaMaracasVisu.git] / bbtk / src / bbcreaMaracasVisuColorLayerImageView2.cxx
1 //===== 
2 // 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)
3 //===== 
4 #include "bbcreaMaracasVisuColorLayerImageView2.h"
5 #include "bbcreaMaracasVisuPackage.h"
6 namespace bbcreaMaracasVisu
7 {
8
9 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ColorLayerImageView2)
10 BBTK_BLACK_BOX_IMPLEMENTATION(ColorLayerImageView2,bbtk::AtomicBlackBox);
11
12
13
14
15
16 //===== 
17 // 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)
18 //===== 
19 void ColorLayerImageView2::Process()
20 {
21
22 // THE MAIN PROCESSING METHOD BODY
23 //   Here we simply set the input 'In' value to the output 'Out'
24 //   And print out the output value
25 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
26 //    void bbSet{Input|Output}NAME(const TYPE&)
27 //    const TYPE& bbGet{Input|Output}NAME() const 
28 //    Where :
29 //    * NAME is the name of the input/output
30 //      (the one provided in the attribute 'name' of the tag 'input')
31 //    * TYPE is the C++ type of the input/output
32 //      (the one provided in the attribute 'type' of the tag 'input')
33    //   bbSetOutputOut( bbGetInputIn() );
34    //   std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
35     
36     
37     if (bbGetInputActive()==true)
38     {
39         if (bbGetInputIn()!=NULL) {
40             if ( !( (bbGetInputWxVtkBaseView()==NULL) && (bbGetInputWxVtkBaseView1()==NULL) && (bbGetInputWxVtkBaseView2()==NULL))  )
41             {
42                 //            ColorLayerImageViewPanel_widgetBox *clivp = (ColorLayerImageViewPanel_widgetBox*)bbGetOutputWidget();
43                 //            if (clivp!=NULL) {
44                 
45                 //                if (firsttime==true)
46                 //                {
47                 //      firsttime=false;
48                 //                    clivp->SetActive( bbGetInputActive() );
49                 //                }
50                 
51                 
52                 std::vector<double> range                           = bbGetInputlstRangeForColorBar();
53                 std::vector<int>    colorbarposition                = bbGetInputColorBarPosition();
54                 std::vector<double> base_color                      = bbGetInputlstBaseColor();
55                 std::vector<double> grey_level_boundaries           = bbGetInputlstGreyLevelBoundaries();
56                 std::vector<double> transparence_level_boundaries   = bbGetInputlstTransparenceBoundaries();
57
58                 _colorLayerImageViewManager->SetwxVtkBaseView           ( 0 , bbGetInputWxVtkBaseView() );
59                 _colorLayerImageViewManager->SetwxVtkBaseView           ( 1 , bbGetInputWxVtkBaseView1() );
60                 _colorLayerImageViewManager->SetwxVtkBaseView           ( 2 , bbGetInputWxVtkBaseView2() );
61                 _colorLayerImageViewManager->SetRangeForColorBar        ( range );
62                 _colorLayerImageViewManager->SetColorBarPosition        ( colorbarposition );
63                 _colorLayerImageViewManager->SetBaseColors              ( base_color );
64                 _colorLayerImageViewManager->SetGreyLevelBoundaries     ( grey_level_boundaries );
65                 _colorLayerImageViewManager->SetBaseTransparence        ( transparence_level_boundaries );
66                 _colorLayerImageViewManager->SetPlainOrGradientColor    ( bbGetInputPlainOrGradientColor() );
67                 _colorLayerImageViewManager->onThresholdChangeOpacity   ( bbGetInputOpacity() );
68                 _colorLayerImageViewManager->onThresholdInterpolation   ( bbGetInputInterpolation() );
69                 _colorLayerImageViewManager->SetActive                  ( bbGetInputActive() );
70
71                 int fitting_mode=3;
72                 // CM Sets the fitting mode if an appropriate value is provided.
73                 if (bbGetInputFittingMode() == -1 || bbGetInputFittingMode() == 1 || bbGetInputFittingMode() == 2 || bbGetInputFittingMode() == 3)
74                   {
75                     fitting_mode = bbGetInputFittingMode();
76                   }
77                 //Otherwise, an exception should be thrown (value 0 is fine, it corresponds to an empty field i.e. the default value is kept).
78                 else if (bbGetInputFittingMode() != 0) {
79                     std::cout << "CM ERROR!!! The fitting mode provided has an inappropriate value. It should be an int between -1 ; 1 ; 2 ; 3, but its value is :" << bbGetInputFittingMode() << ". The default value will be set instead, i.e. Pixel transformation (3)." <<  std::endl;
80                     //EO CM
81                     fitting_mode=3;
82                 }
83                 
84 //                clivp->SetFittingMode( bbGetInputFittingMode() );
85 //                clivp->SetImage( bbGetInputIn() );
86                 _colorLayerImageViewManager->SetFittingMode( fitting_mode );
87                 _colorLayerImageViewManager->SetImageStep1( bbGetInputIn() );
88                 _colorLayerImageViewManager->SetImageStep2( bbGetInputIn() );
89
90                 bbSetOutputNewImage( _colorLayerImageViewManager->GetImageChangeInformation(0) );
91                 bbSetOutputLookupTable( _colorLayerImageViewManager->GetLookupTable(0) );
92 //                bbSetOutputOutOpacity( clivp->GetOpacity() );
93                 //              if (firsttime==true)
94                 //              {
95                 //                  firsttime=false;
96                 //                  clivp->ChangeOpacity();
97                 //                  clivp->SetBox(this);
98                 //              }
99                 //          }   // if clivp
100             } else {
101                 printf("EED Error!!!  ColorLayerImageView::Process   (%s)  Missing Inputs:  WxVtkBaseView , WxVtkBaseView1 , WxVtkBaseView2 \n", bbGetFullName().c_str() );
102             }// if xxVtkBaseView
103             
104         } // if In
105         
106     } // if Active
107     
108     
109     
110 }
111 //===== 
112 // 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)
113 //===== 
114 void ColorLayerImageView2::bbUserSetDefaultValues()
115 {
116 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
117 //    Here we initialize the input 'In' to 0
118     firsttime=true;
119     bbSetInputIn(NULL);
120     bbSetInputActive(true);
121     bbSetInputOpacity(100);
122     bbSetInputInterpolation(true);
123     bbSetInputPlainOrGradientColor(false);
124 //    bbSetInputTypeControlsInterface(1);
125     bbSetInputWxVtkBaseView(NULL);
126     bbSetInputWxVtkBaseView1(NULL);
127     bbSetInputWxVtkBaseView2(NULL);
128     std::vector<int> lstColorBarPosition;
129     lstColorBarPosition.push_back(10);
130     lstColorBarPosition.push_back(105);
131     bbSetInputColorBarPosition(lstColorBarPosition);
132 //    bbSetOutputWidget(NULL);
133 }
134 //===== 
135 // 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)
136 //===== 
137 void ColorLayerImageView2::bbUserInitializeProcessing()
138 {
139
140     _colorLayerImageViewManager    = new ColorLayerImageViewManager();
141
142 //  THE INITIALIZATION METHOD BODY :
143 //    Here does nothing 
144 //    but this is where you should allocate the internal/output pointers 
145 //    if any 
146
147   
148 }
149 //===== 
150 // 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)
151 //===== 
152 void ColorLayerImageView2::bbUserFinalizeProcessing()
153 {
154
155 //  THE FINALIZATION METHOD BODY :
156 //    Here does nothing 
157 //    but this is where you should desallocate the internal/output pointers 
158 //    if any
159   
160 }
161 }
162 // EO namespace bbcreaMaracasVisu
163
164