]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbmaracasvisuPlotterView.cxx
Support #1768 CREATIS Licence insertion
[creaMaracasVisu.git] / bbtk / src / bbmaracasvisuPlotterView.cxx
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26 #include "bbmaracasvisuPlotterView.h"
27 #include "bbcreaMaracasVisuPackage.h"
28
29 #include "pPlotterScaleX.h"
30 #include "pPlotterScaleY.h"
31
32
33 namespace bbcreaMaracasVisu
34 {
35
36 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,PlotterView)
37 BBTK_BLACK_BOX_IMPLEMENTATION(PlotterView,bbtk::WxBlackBox);
38
39 //---------------------------------------------------
40 void PlotterView::Process()
41 {
42 //      if (firsttime==true)
43 //      {
44 //              firsttime=false;
45                 
46         
47         printf("EED PlotterView::Process %d %d \n ", bbGetInputInY().size(),bbGetInputInY2().size());
48         
49         pGraphicalFunction *pGF = mwxwidget->getFunction(0);
50         pGraphicalFunction *pGF2 = mwxwidget->getFunction(1);
51
52            if ( (bbGetInputInY().size()!=0)  &&  (bbGetInputInY2().size()==0) )
53            {
54                    bbSetInputInY2( bbGetInputInY() );
55            } 
56         
57                 if ( (bbGetInputInY().size()!=0) && (pGF==NULL) )               
58                 {
59                         // avoid 'taking address of temporary '
60                         //pGraphicalFunction *pGF = mwxwidget->getFunctionForVectors( &(bbGetInputInX()), &(bbGetInputInY()) ); // taking address of temporary ! JPRx
61                 
62                         std::vector<double> inX;
63                         if (bbGetInputInX().size()==0)
64                         {
65                                 int i,size=bbGetInputInY().size();
66                                 for(i=0;i<size;i++)
67                                 {
68                                         inX.push_back((double)i);
69                                 } // for
70                         } else {
71                                 inX = bbGetInputInX();
72                         } // if bbGetInputInX
73                         std::vector<double> inY = bbGetInputInY();
74                  
75         /*
76                         std::vector<double> inX;
77                         std::vector<double> inY;
78                         inX.push_back(0);                       inX.push_back(200);
79                         inY.push_back(0);                       inY.push_back(1);
80          */
81                         pGF = mwxwidget->getFunctionForVectors( &inX, &inY ); 
82                         mwxwidget->addFunction(pGF);            
83                 } // if bbGetInputInY
84
85                 if ((bbGetInputInY2().size()!=0)&& (pGF2==NULL)         )
86                 {
87                         // avoid 'taking address of temporary '
88                         //pGraphicalFunction *pGF = mwxwidget->getFunctionForVectors( &(bbGetInputInX()), &(bbGetInputInY()) ); // taking address of temporary ! JPRx
89                 
90                         std::vector<double> inX2;
91                         if (bbGetInputInX().size()==0)
92                         {
93                                 int i,size=bbGetInputInY2().size();
94                                 for(i=0;i<size;i++)
95                                 {
96                                         inX2.push_back((double)i);
97                                 } // for
98                         } else {
99                                 inX2 = bbGetInputInX();
100                         } // if bbGetInputInX
101                         std::vector<double> inY2 = bbGetInputInY();
102                 /*
103                         std::vector<double> inX2;
104                         std::vector<double> inY2;
105                         inX2.push_back(0);                      inX2.push_back(200);
106                         inY2.push_back(0);                      inY2.push_back(1);
107                  */
108                         pGF2 = mwxwidget->getFunctionForVectors( &inX2, &inY2 ); 
109                         mwxwidget->addFunction(pGF2);           
110                 } // if bbGetInputInY
111                 
112 //      } // if firsttime
113         
114         if (pGF!=NULL)  
115         {
116                 // -Erasing  points-
117                 int i,sizePoints                = pGF->getSizePoints();
118                 for (i=1; i<sizePoints;i++)
119                 {
120                         pGF->deletePointAt(1);  //  EED here NOT 0 is 1
121                 } // for i
122                 // -Add Points-
123                 double px;
124                 sizePoints=bbGetInputInY().size();
125                 for (i=0; i<sizePoints;i++)
126                 {
127                         if (i<bbGetInputInX().size())
128                         {
129                                 px = bbGetInputInX()[i]; 
130                         } else {
131                                 px = i;
132                         }       
133                         pGF->AddNewPoint( px, bbGetInputInY()[i] );
134                 }               
135         }// if pGF
136
137
138         if (pGF2!=NULL) 
139         {
140                 // -Erasing  points-
141                 int i,sizePoints                = pGF2->getSizePoints();
142                 for (i=0; i<sizePoints;i++)
143                 {
144                         pGF2->deletePointAt(1);   //  EED here NOT 0 is 1
145                 } // for i
146                 // -Add Points-
147                 double px;
148                 sizePoints=bbGetInputInY2().size();
149                 for (i=0; i<sizePoints;i++)
150                 {
151                         if (i<bbGetInputInX().size())
152                         {
153                                 px = bbGetInputInX()[i]; 
154                         } else {
155                                 px = i;
156                         }       
157                         pGF2->AddNewPoint( px, bbGetInputInY2()[i] );
158                 }               
159         }// if pGF
160                 
161         mwxwidget->UpdateAll();
162         
163         
164 }
165
166         
167 //---------------------------------------------------
168 void PlotterView::CreateWidget(wxWindow* parent)
169 {
170    bbtkDebugMessageInc("Core",9,"PlotterView::CreateWxWindow()"<<std::endl);
171     
172    mwxwidget = new pPlotterWindow( parent , -1,wxDefaultPosition,  wxDefaultSize,  0 );
173    mwxwidget->AddLayer(new pPlotterScaleX());
174    mwxwidget->AddLayer(new pPlotterScaleY());
175
176         mwxwidget->setMinScrY(0);
177         mwxwidget->setMaxScrY(5000);
178
179         
180            bbtkDebugDecTab("Core",9);
181    bbSetOutputWidget( mwxwidget );
182 }
183
184 //---------------------------------------------------
185 void PlotterView::bbUserSetDefaultValues()
186 {
187         mwxwidget = NULL;
188         firsttime=true;
189 }
190         
191         //-----------------------------------------------------------------     
192         void PlotterView::bbUserInitializeProcessing()
193         {
194         }
195         
196         //-----------------------------------------------------------------     
197         void PlotterView::bbUserFinalizeProcessing()
198         {
199         }
200         
201         //-----------------------------------------------------------------     
202
203 }
204 // EO namespace bbcreaMaracasVisu
205
206