]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbmaracasvisuPlotterView.cxx
1495 PlotterViewer , Refresh data
[creaMaracasVisu.git] / bbtk / src / bbmaracasvisuPlotterView.cxx
1 #include "bbmaracasvisuPlotterView.h"
2 #include "bbcreaMaracasVisuPackage.h"
3
4 #include "pPlotterScaleX.h"
5 #include "pPlotterScaleY.h"
6
7
8 namespace bbcreaMaracasVisu
9 {
10
11 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,PlotterView)
12 BBTK_BLACK_BOX_IMPLEMENTATION(PlotterView,bbtk::WxBlackBox);
13
14 //---------------------------------------------------
15 void PlotterView::Process()
16 {
17         
18         if (firsttime==true)
19         {
20                 firsttime=false;
21                 std::vector<double> inX;
22                 
23                 // avoid 'taking address of temporary '
24                 //pGraphicalFunction *pGF = mwxwidget->getFunctionForVectors( &(bbGetInputInX()), &(bbGetInputInY()) ); // taking address of temporary ! JPRx
25                 if (bbGetInputInX().size()==0)
26                 {
27                         int i,size=bbGetInputInY().size();
28                         for(i=0;i<size;i++)
29                         {
30                                 inX.push_back((double)i);
31                         }
32                 } else {
33                         
34                         inX = bbGetInputInX();
35                 }
36                 std::vector<double> inY = bbGetInputInY();
37                 pGraphicalFunction *pGF = mwxwidget->getFunctionForVectors( &inX, &inY ); 
38                 mwxwidget->addFunction(pGF);            
39         }
40         
41         
42         
43         pGraphicalFunction *pGF = mwxwidget->getFunction(0);
44         int i,sizePoints = pGF->getSizePoints();
45         for (i=0; i<sizePoints;i++)
46         {
47                 pGF->deletePointAt(i);
48         }
49         
50         double px;
51         sizePoints=bbGetInputInY().size();
52         for (i=0; i<sizePoints;i++)
53         {
54                 if (i<bbGetInputInX().size())
55                 {
56                         px=bbGetInputInX()[i]; 
57                 } else {
58                         px=i;
59                 }       
60                 pGF->AddNewPoint( px, bbGetInputInY()[i] );
61                 printf ("EED PlotterView::Process %f %f\n", px, bbGetInputInY()[i]);
62         }
63 }
64
65         
66 //---------------------------------------------------
67 void PlotterView::CreateWidget(wxWindow* parent)
68 {
69    bbtkDebugMessageInc("Core",9,"PlotterView::CreateWxWindow()"<<std::endl);
70     
71    mwxwidget = new pPlotterWindow( parent , -1,wxDefaultPosition,  wxDefaultSize,  0 );
72    mwxwidget->AddLayer(new pPlotterScaleX());
73    mwxwidget->AddLayer(new pPlotterScaleY());
74    
75            bbtkDebugDecTab("Core",9);
76    bbSetOutputWidget( mwxwidget );
77 }
78
79 //---------------------------------------------------
80 void PlotterView::bbUserSetDefaultValues()
81 {
82         mwxwidget = NULL;
83         firsttime=true;
84 }
85         
86         //-----------------------------------------------------------------     
87         void PlotterView::bbUserInitializeProcessing()
88         {
89         }
90         
91         //-----------------------------------------------------------------     
92         void PlotterView::bbUserFinalizeProcessing()
93         {
94         }
95         
96         //-----------------------------------------------------------------     
97
98 }
99 // EO namespace bbcreaMaracasVisu
100
101