1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
26 #include "bbmaracasvisuPlotterView.h"
27 #include "bbcreaMaracasVisuPackage.h"
29 #include "pPlotterScaleX.h"
30 #include "pPlotterScaleY.h"
33 namespace bbcreaMaracasVisu
36 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,PlotterView)
37 BBTK_BLACK_BOX_IMPLEMENTATION(PlotterView,bbtk::WxBlackBox);
39 //---------------------------------------------------
40 void PlotterView::Process()
43 if (bbGetInputInX().size()==bbGetInputInY().size() ) {
45 pGraphicalFunction *pGF = mwxwidget->getFunction(0);
46 pGraphicalFunction *pGF2 = mwxwidget->getFunction(1);
53 int i,sizePoints = pGF->getSizePoints();
54 for (i=1; i<sizePoints;i++)
56 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
57 #if wxMAJOR_VERSION <= 2
58 pGF->deletePointAt(1); // EED here NOT 0 is 1
60 pGF->deletePointAt(0); // EED here NOT 0 is 1
63 mwxwidget->deleteFunction(pGF);
70 int i,sizePoints = pGF2->getSizePoints();
71 for (i=0; i<sizePoints;i++)
73 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
74 #if wxMAJOR_VERSION <= 2
75 pGF2->deletePointAt(1); // EED here NOT 0 is 1
77 pGF2->deletePointAt(0); // EED here NOT 0 is 1
80 mwxwidget->deleteFunction(pGF2);
86 if ( (bbGetInputInY().size()!=0) && (pGF==NULL) )
88 // avoid 'taking address of temporary '
89 //pGraphicalFunction *pGF = mwxwidget->getFunctionForVectors( &(bbGetInputInX()), &(bbGetInputInY()) ); // taking address of temporary ! JPRx
91 std::vector<double> inX;
92 if (bbGetInputInX().size()==0)
94 int i,size=bbGetInputInY().size();
97 inX.push_back((double)i);
100 inX = bbGetInputInX();
101 } // if bbGetInputInX
102 std::vector<double> inY = bbGetInputInY();
104 pGF = mwxwidget->getFunctionForVectors( &inX, &inY );
105 mwxwidget->addFunction(pGF);
106 } // if bbGetInputInY
108 if ((bbGetInputInY2().size()!=0)&& (pGF2==NULL) )
110 // avoid 'taking address of temporary '
111 //pGraphicalFunction *pGF = mwxwidget->getFunctionForVectors( &(bbGetInputInX()), &(bbGetInputInY()) ); // taking address of temporary ! JPRx
113 std::vector<double> inX2;
114 if (bbGetInputInX().size()==0)
116 int i,size=bbGetInputInY2().size();
119 inX2.push_back((double)i);
122 inX2 = bbGetInputInX();
123 } // if bbGetInputInX
124 std::vector<double> inY2 = bbGetInputInY();
125 pGF2 = mwxwidget->getFunctionForVectors( &inX2, &inY2 );
126 mwxwidget->addFunction(pGF2);
127 } // if bbGetInputInY
135 int i,sizePoints = pGF->getSizePoints();
136 for (i=1; i<sizePoints;i++)
138 pGF->deletePointAt(1); // EED here NOT 0 is 1
142 sizePoints=bbGetInputInY().size();
143 for (i=0; i<sizePoints;i++)
145 if (i<bbGetInputInX().size())
147 px = bbGetInputInX()[i];
151 pGF->AddNewPoint( px, bbGetInputInY()[i] );
158 int i,sizePoints = pGF2->getSizePoints();
159 for (i=0; i<sizePoints;i++)
161 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
162 #if wxMAJOR_VERSION <= 2
163 pGF2->deletePointAt(1); // EED here NOT 0 is 1
165 pGF2->deletePointAt(0); // EED here NOT 0 is 1
170 sizePoints=bbGetInputInY2().size();
171 for (i=0; i<sizePoints;i++)
173 if (i<bbGetInputInX().size())
175 px = bbGetInputInX()[i];
179 pGF2->AddNewPoint( px, bbGetInputInY2()[i] );
184 mwxwidget->UpdateAll();
187 printf("EED Warnning... PlotterView::Process() Size of vecto X and Y is not coherent.\n");
188 } // InX.size InY.size
193 //---------------------------------------------------
194 void PlotterView::CreateWidget(wxWindow* parent)
196 bbtkDebugMessageInc("Core",9,"PlotterView::CreateWxWindow()"<<std::endl);
197 mwxwidget = new pPlotterWindow( parent , -1,wxDefaultPosition, wxDefaultSize, 0 );
198 mwxwidget->AddLayer(new pPlotterScaleX());
199 mwxwidget->AddLayer(new pPlotterScaleY());
200 mwxwidget->setMinScrY(0);
201 mwxwidget->setMaxScrY(5000);
202 bbtkDebugDecTab("Core",9);
203 bbSetOutputWidget( mwxwidget );
206 //---------------------------------------------------
207 void PlotterView::bbUserSetDefaultValues()
212 //-----------------------------------------------------------------
213 void PlotterView::bbUserInitializeProcessing()
217 //-----------------------------------------------------------------
218 void PlotterView::bbUserFinalizeProcessing()
222 //-----------------------------------------------------------------
225 // EO namespace bbcreaMaracasVisu