]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbmaracasvisuPlotterView.cxx
#3144 creaMaracasVisu Bug New Normal - changeWx28to30
[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         pGraphicalFunction *pGF = mwxwidget->getFunction(0);
47         pGraphicalFunction *pGF2 = mwxwidget->getFunction(1);
48
49            if ( (bbGetInputInY().size()!=0)  &&  (bbGetInputInY2().size()==0) )
50            {
51                    bbSetInputInY2( bbGetInputInY() );
52            } 
53         
54                 if ( (bbGetInputInY().size()!=0) && (pGF==NULL) )               
55                 {
56                         // avoid 'taking address of temporary '
57                         //pGraphicalFunction *pGF = mwxwidget->getFunctionForVectors( &(bbGetInputInX()), &(bbGetInputInY()) ); // taking address of temporary ! JPRx
58                 
59                         std::vector<double> inX;
60                         if (bbGetInputInX().size()==0)
61                         {
62                                 int i,size=bbGetInputInY().size();
63                                 for(i=0;i<size;i++)
64                                 {
65                                         inX.push_back((double)i);
66                                 } // for
67                         } else {
68                                 inX = bbGetInputInX();
69                         } // if bbGetInputInX
70                         std::vector<double> inY = bbGetInputInY();
71                  
72         /*
73                         std::vector<double> inX;
74                         std::vector<double> inY;
75                         inX.push_back(0);                       inX.push_back(200);
76                         inY.push_back(0);                       inY.push_back(1);
77          */
78                         pGF = mwxwidget->getFunctionForVectors( &inX, &inY ); 
79                         mwxwidget->addFunction(pGF);            
80                 } // if bbGetInputInY
81
82                 if ((bbGetInputInY2().size()!=0)&& (pGF2==NULL)         )
83                 {
84                         // avoid 'taking address of temporary '
85                         //pGraphicalFunction *pGF = mwxwidget->getFunctionForVectors( &(bbGetInputInX()), &(bbGetInputInY()) ); // taking address of temporary ! JPRx
86                 
87                         std::vector<double> inX2;
88                         if (bbGetInputInX().size()==0)
89                         {
90                                 int i,size=bbGetInputInY2().size();
91                                 for(i=0;i<size;i++)
92                                 {
93                                         inX2.push_back((double)i);
94                                 } // for
95                         } else {
96                                 inX2 = bbGetInputInX();
97                         } // if bbGetInputInX
98                         std::vector<double> inY2 = bbGetInputInY();
99                 /*
100                         std::vector<double> inX2;
101                         std::vector<double> inY2;
102                         inX2.push_back(0);                      inX2.push_back(200);
103                         inY2.push_back(0);                      inY2.push_back(1);
104                  */
105                         pGF2 = mwxwidget->getFunctionForVectors( &inX2, &inY2 ); 
106                         mwxwidget->addFunction(pGF2);           
107                 } // if bbGetInputInY
108                 
109 //      } // if firsttime
110
111         
112         if (pGF!=NULL)  
113         {
114                 // -Erasing  points-
115                 int i,sizePoints                = pGF->getSizePoints();
116                 for (i=1; i<sizePoints;i++)
117                 {
118                         pGF->deletePointAt(1);  //  EED here NOT 0 is 1
119                 } // for i
120                 // -Add Points-
121                 double px;
122                 sizePoints=bbGetInputInY().size();
123                 for (i=0; i<sizePoints;i++)
124                 {
125                         if (i<bbGetInputInX().size())
126                         {
127                                 px = bbGetInputInX()[i]; 
128                         } else {
129                                 px = i;
130                         }       
131                         pGF->AddNewPoint( px, bbGetInputInY()[i] );
132                 }               
133         }// if pGF
134
135         if (pGF2!=NULL) 
136         {
137                 // -Erasing  points-
138                 int i,sizePoints                = pGF2->getSizePoints();
139                 for (i=0; i<sizePoints;i++)
140                 {
141 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
142 #if wxMAJOR_VERSION <= 2
143                         pGF2->deletePointAt(1);   //  EED here NOT 0 is 1
144 #else
145                         pGF2->deletePointAt(0);   //  EED here NOT 0 is 1
146 #endif
147                 } // for i
148                 // -Add Points-
149                 double px;
150                 sizePoints=bbGetInputInY2().size();
151                 for (i=0; i<sizePoints;i++)
152                 {
153                         if (i<bbGetInputInX().size())
154                         {
155                                 px = bbGetInputInX()[i]; 
156                         } else {
157                                 px = i;
158                         }       
159                         pGF2->AddNewPoint( px, bbGetInputInY2()[i] );
160                 }  // for       
161         }// if pGF
162         mwxwidget->UpdateAll();
163 }
164
165         
166 //---------------------------------------------------
167 void PlotterView::CreateWidget(wxWindow* parent)
168 {
169         bbtkDebugMessageInc("Core",9,"PlotterView::CreateWxWindow()"<<std::endl);
170         mwxwidget = new pPlotterWindow( parent , -1,wxDefaultPosition,  wxDefaultSize,  0 );
171         mwxwidget->AddLayer(new pPlotterScaleX());
172         mwxwidget->AddLayer(new pPlotterScaleY());
173         mwxwidget->setMinScrY(0);
174         mwxwidget->setMaxScrY(5000);
175         bbtkDebugDecTab("Core",9);
176         bbSetOutputWidget( mwxwidget );
177 }
178
179 //---------------------------------------------------
180 void PlotterView::bbUserSetDefaultValues()
181 {
182         mwxwidget = NULL;
183         firsttime=true;
184 }
185         
186         //-----------------------------------------------------------------     
187         void PlotterView::bbUserInitializeProcessing()
188         {
189         }
190         
191         //-----------------------------------------------------------------     
192         void PlotterView::bbUserFinalizeProcessing()
193         {
194         }
195         
196         //-----------------------------------------------------------------     
197
198 }
199 // EO namespace bbcreaMaracasVisu
200
201