]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbcreaMaracasVisuColorLayerImageView2.cxx
aa0941f9765c591b11db147eb6f8f00e5aba9f7c
[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->SetActive                  ( bbGetInputActive() );
69
70                 int fitting_mode=3;
71                 // CM Sets the fitting mode if an appropriate value is provided.
72                 if (bbGetInputFittingMode() == -1 || bbGetInputFittingMode() == 1 || bbGetInputFittingMode() == 2 || bbGetInputFittingMode() == 3)
73                   {
74                     fitting_mode = bbGetInputFittingMode();
75                   }
76                 //Otherwise, an exception should be thrown (value 0 is fine, it corresponds to an empty field i.e. the default value is kept).
77                 else if (bbGetInputFittingMode() != 0) {
78                     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;
79                     //EO CM
80                     fitting_mode=3;
81                 }
82                 
83 //                clivp->SetFittingMode( bbGetInputFittingMode() );
84 //                clivp->SetImage( bbGetInputIn() );
85                 _colorLayerImageViewManager->SetFittingMode( fitting_mode );
86                 _colorLayerImageViewManager->SetImageStep1( bbGetInputIn() );
87                 _colorLayerImageViewManager->SetImageStep2( bbGetInputIn() );
88
89                 bbSetOutputNewImage( _colorLayerImageViewManager->GetImageChangeInformation(0) );
90                 bbSetOutputLookupTable( _colorLayerImageViewManager->GetLookupTable(0) );
91 //                bbSetOutputOutOpacity( clivp->GetOpacity() );
92                 //              if (firsttime==true)
93                 //              {
94                 //                  firsttime=false;
95                 //                  clivp->ChangeOpacity();
96                 //                  clivp->SetBox(this);
97                 //              }
98                 //          }   // if clivp
99             } else {
100                 printf("EED Error!!!  ColorLayerImageView::Process   (%s)  Missing Inputs:  WxVtkBaseView , WxVtkBaseView1 , WxVtkBaseView2 \n", bbGetFullName().c_str() );
101             }// if xxVtkBaseView
102             
103         } // if In
104         
105     } // if Active
106     
107     
108     
109 }
110 //===== 
111 // 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)
112 //===== 
113 void ColorLayerImageView2::bbUserSetDefaultValues()
114 {
115 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
116 //    Here we initialize the input 'In' to 0
117     firsttime=true;
118     bbSetInputIn(NULL);
119     bbSetInputActive(true);
120     bbSetInputOpacity(100);
121     bbSetInputPlainOrGradientColor(false);
122 //    bbSetInputTypeControlsInterface(1);
123     bbSetInputWxVtkBaseView(NULL);
124     bbSetInputWxVtkBaseView1(NULL);
125     bbSetInputWxVtkBaseView2(NULL);
126     std::vector<int> lstColorBarPosition;
127     lstColorBarPosition.push_back(10);
128     lstColorBarPosition.push_back(105);
129     bbSetInputColorBarPosition(lstColorBarPosition);
130 //    bbSetOutputWidget(NULL);
131 }
132 //===== 
133 // 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)
134 //===== 
135 void ColorLayerImageView2::bbUserInitializeProcessing()
136 {
137
138     _colorLayerImageViewManager    = new ColorLayerImageViewManager();
139
140 //  THE INITIALIZATION METHOD BODY :
141 //    Here does nothing 
142 //    but this is where you should allocate the internal/output pointers 
143 //    if any 
144
145   
146 }
147 //===== 
148 // 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)
149 //===== 
150 void ColorLayerImageView2::bbUserFinalizeProcessing()
151 {
152
153 //  THE FINALIZATION METHOD BODY :
154 //    Here does nothing 
155 //    but this is where you should desallocate the internal/output pointers 
156 //    if any
157   
158 }
159 }
160 // EO namespace bbcreaMaracasVisu
161
162