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()
42 // if (firsttime==true)
46 pGraphicalFunction *pGF = mwxwidget->getFunction(0);
47 pGraphicalFunction *pGF2 = mwxwidget->getFunction(1);
49 if ( (bbGetInputInY().size()!=0) && (bbGetInputInY2().size()==0) )
51 bbSetInputInY2( bbGetInputInY() );
54 if ( (bbGetInputInY().size()!=0) && (pGF==NULL) )
56 // avoid 'taking address of temporary '
57 //pGraphicalFunction *pGF = mwxwidget->getFunctionForVectors( &(bbGetInputInX()), &(bbGetInputInY()) ); // taking address of temporary ! JPRx
59 std::vector<double> inX;
60 if (bbGetInputInX().size()==0)
62 int i,size=bbGetInputInY().size();
65 inX.push_back((double)i);
68 inX = bbGetInputInX();
70 std::vector<double> inY = bbGetInputInY();
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);
78 pGF = mwxwidget->getFunctionForVectors( &inX, &inY );
79 mwxwidget->addFunction(pGF);
82 if ((bbGetInputInY2().size()!=0)&& (pGF2==NULL) )
84 // avoid 'taking address of temporary '
85 //pGraphicalFunction *pGF = mwxwidget->getFunctionForVectors( &(bbGetInputInX()), &(bbGetInputInY()) ); // taking address of temporary ! JPRx
87 std::vector<double> inX2;
88 if (bbGetInputInX().size()==0)
90 int i,size=bbGetInputInY2().size();
93 inX2.push_back((double)i);
96 inX2 = bbGetInputInX();
98 std::vector<double> inY2 = bbGetInputInY();
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);
105 pGF2 = mwxwidget->getFunctionForVectors( &inX2, &inY2 );
106 mwxwidget->addFunction(pGF2);
107 } // if bbGetInputInY
115 int i,sizePoints = pGF->getSizePoints();
116 for (i=1; i<sizePoints;i++)
118 pGF->deletePointAt(1); // EED here NOT 0 is 1
122 sizePoints=bbGetInputInY().size();
123 for (i=0; i<sizePoints;i++)
125 if (i<bbGetInputInX().size())
127 px = bbGetInputInX()[i];
131 pGF->AddNewPoint( px, bbGetInputInY()[i] );
138 int i,sizePoints = pGF2->getSizePoints();
139 for (i=0; i<sizePoints;i++)
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
145 pGF2->deletePointAt(0); // EED here NOT 0 is 1
150 sizePoints=bbGetInputInY2().size();
151 for (i=0; i<sizePoints;i++)
153 if (i<bbGetInputInX().size())
155 px = bbGetInputInX()[i];
159 pGF2->AddNewPoint( px, bbGetInputInY2()[i] );
162 mwxwidget->UpdateAll();
166 //---------------------------------------------------
167 void PlotterView::CreateWidget(wxWindow* parent)
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 );
179 //---------------------------------------------------
180 void PlotterView::bbUserSetDefaultValues()
186 //-----------------------------------------------------------------
187 void PlotterView::bbUserInitializeProcessing()
191 //-----------------------------------------------------------------
192 void PlotterView::bbUserFinalizeProcessing()
196 //-----------------------------------------------------------------
199 // EO namespace bbcreaMaracasVisu