]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotter.cxx
*** empty log message ***
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / pPlotter / pPlotter.cxx
1 //---------------------------------------------------------------------------------------------
2 // Class definition include
3 //---------------------------------------------------------------------------------------------
4 #include "pPlotter.h"
5
6 // --------------------------------------------------------------------------------------------
7 // WX headers inclusion.
8 // For compilers that support precompilation, includes <wx/wx.h>.
9 // --------------------------------------------------------------------------------------------
10
11 #ifndef WX_PRECOMP
12 #include <wx/wx.h>
13 #endif
14
15 //---------------------------------------------------------------------------------------------
16 // Class implementation
17 //---------------------------------------------------------------------------------------------
18
19 IMPLEMENT_CLASS(pPlotter, wxPanel)
20
21 //------------------------------------------------------------------------------------------------------------
22 // Generated events declaration and definition
23 //------------------------------------------------------------------------------------------------------------
24 BEGIN_DECLARE_EVENT_TYPES()
25         DECLARE_EVENT_TYPE( wxEVT_NW_TEXT_MESAGGE, -1 ) 
26 END_DECLARE_EVENT_TYPES()
27
28 DEFINE_EVENT_TYPE( wxEVT_NW_TEXT_MESAGGE )
29
30 // ----------------------------------------------------------------------------------------------------
31 // Handdled events from pColorBar
32 // ----------------------------------------------------------------------------------------------------
33 DECLARE_EVENT_TYPE(wxEVT_ADDED_POINT, -1)
34 DECLARE_EVENT_TYPE(wxEVT_REMOVED_POINT, -1)
35 DECLARE_EVENT_TYPE(wxEVT_MOVED_POINT, -1)
36 DECLARE_EVENT_TYPE(wxEVT_CHANGED_POINT, -1)
37 DECLARE_EVENT_TYPE(wxEVT_ON_COLOR_BAR, -1)
38
39 // ----------------------------------------------------------------------------------------------------
40 // Handdled events from plotter
41 // ----------------------------------------------------------------------------------------------------
42 DECLARE_EVENT_TYPE(wxEVT_PPLOTTER_CHANGED_FUNCTION, -1)
43 DECLARE_EVENT_TYPE(wxEVT_PPLOTTER_POINT_MOVE, -1)
44 DECLARE_EVENT_TYPE(wxEVT_PPLOTTER_POINT_ADD, -1)
45 DECLARE_EVENT_TYPE(wxEVT_PPLOTTER_POINT_DELETE, -1)
46 DECLARE_EVENT_TYPE(wxEVT_PPLOTTER_GUIDELINES, -1)
47
48 // ----------------------------------------------------------------------------------------------------
49 // Handdled events from max-min barrange
50 // ----------------------------------------------------------------------------------------------------
51 DECLARE_EVENT_TYPE(wxEVT_TSBAR, -1)
52 DECLARE_EVENT_TYPE(wxEVT_TSBAR_ACTUAL, -1)
53 DECLARE_EVENT_TYPE(wxEVT_TSBAR_START, -1)
54 DECLARE_EVENT_TYPE(wxEVT_TSBAR_END, -1)
55 DECLARE_EVENT_TYPE(wxEVT_TSBAR_MOVED, -1)
56 DECLARE_EVENT_TYPE(wxEVT_SELECTION_END, -1)
57
58
59 // ----------------------------------------------------------------------------------------------------
60 // EVENT TABLE (->Connect: analogous)
61 //-----------------------------------------------------------------------------------------------------
62 BEGIN_EVENT_TABLE(pPlotter, wxPanel)
63         //OnSize
64         //EVT_SIZE  (pPlotter::OnSize)
65         
66         // Connectting the handled envents for the plotter to the corresponding methods
67         EVT_COMMAND  (-1,wxEVT_PPLOTTER_CHANGED_FUNCTION, pPlotter::onChangeFunction)
68         EVT_COMMAND  (-1,wxEVT_PPLOTTER_POINT_MOVE, pPlotter::onMovePoint_Plotter)
69         EVT_COMMAND  (-1,wxEVT_PPLOTTER_POINT_ADD, pPlotter::onAddedPoint_Plotter)
70         EVT_COMMAND  (-1,wxEVT_PPLOTTER_POINT_DELETE, pPlotter::onRemovedPoint_Plotter)
71         EVT_COMMAND  (-1,wxEVT_PPLOTTER_GUIDELINES, pPlotter::onGuideLines)
72
73         // Connectting the handled envents for the color bar  to the corresponding methods
74     EVT_COMMAND  (-1,wxEVT_ADDED_POINT, pPlotter :: onAdded_ColorPoint )
75         EVT_COMMAND  (-1,wxEVT_REMOVED_POINT, pPlotter :: onRemoved_ColorPoint )
76         EVT_COMMAND  (-1,wxEVT_MOVED_POINT, pPlotter :: onMoved_ColorPoint )
77         EVT_COMMAND  (-1,wxEVT_CHANGED_POINT, pPlotter :: onChanged_ColorPoint )
78         EVT_COMMAND  (-1,wxEVT_ON_COLOR_BAR, pPlotter :: onColorBar )
79
80         // Connectting the handled envents from the max-min barrange  to the corresponding methods
81         EVT_COMMAND  (-1,wxEVT_TSBAR, pPlotter::onBarrange)
82         EVT_COMMAND  (-1,wxEVT_SELECTION_END, pPlotter::onSelectionEnd)
83         EVT_COMMAND  (-1,wxEVT_TSBAR_MOVED, pPlotter::onMovedBar)
84         EVT_COMMAND  (-1,wxEVT_TSBAR_ACTUAL, pPlotter:: onActualChange_Bar)
85         EVT_COMMAND  (-1,wxEVT_TSBAR_START, pPlotter::onStartChange_Bar)
86         EVT_COMMAND  (-1,wxEVT_TSBAR_END, pPlotter::onEndChange_Bar)
87
88 END_EVENT_TABLE()
89
90
91 //---------------------------------------------------------------------------------------------
92 // Constructors & Destructors
93 //---------------------------------------------------------------------------------------------
94         /*
95         * Creates an integrated plotter instance 
96         * @param *parent Container window
97         */
98         pPlotter :: pPlotter  (wxWindow *parent,int nWidth, int nHeight)
99         :wxPanel(parent,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL)
100         {
101                 SetBackgroundColour(wxColour(255,255,255));
102                 m_plot = new pPlotterWindow( this, -1, wxPoint(0,0), wxSize(nWidth,nHeight), wxSUNKEN_BORDER );
103                 
104                 // Adding the axis layers to the plotter
105                 m_plot->AddLayer( new pPlotterScaleX() );
106                 m_plot->AddLayer( new pPlotterScaleY() );  
107
108                 // Creating the log window
109         /*
110            
111                 m_log = new wxTextCtrl( panel, -1, wxT("This is the log window.\n"), wxPoint(0,0), wxSize(400,100), wxTE_MULTILINE );
112                 // Sharing the log window of the application with the plotter widget    
113                 m_plot->setmLog(m_log);
114                 
115                 */
116
117
118                 // Creating a function for the plotter with given points x-vector and y-vector
119
120                 /*
121                 double vectX_F1 [] = { 0, 20, 50, 80, 100, 115, 120, 210, 220,250 };
122
123                 
124 //              double vectX_F1 [] = { 0, 20, 50, 80, 100, 115, 120, 210, 220,250 };
125
126                 double vectY_F1 [] = { 0, 40, 70, 100, 200, 100, 40, 170, 0, 50  };
127                 pGraphicalFunction * f1 = m_plot ->getFunctionForVectors( vectX_F1, 10, vectY_F1, 10 ); 
128                 // Including and drawing the created function in the plotter
129                 if (f1)
130                 {
131                         m_plot->addFunction( f1 );
132                         m_plot->addFunctionToMove(f1);
133                         //m_plot->addFunctionToMove(f1);
134                         wxPen mypen1(*wxBLUE, 2, wxDOT_DASH );
135                         mypen1.SetWidth(2);
136                         f1->SetPen( mypen1 );
137                 }
138                 */
139                 
140                 //=================== lines to sychronyze the bars width with the drawed plotter--------------------------
141
142                 mpWindow* mplotWindow = ((mpWindow*)m_plot);
143                 float minReal_X = 0; //(float)mplotWindow->getMinScrX();
144                 float maxReal_X =(float)mplotWindow->getMaxScrX();
145                 //float scrX=(float)mplotWindow->GetScrX()-100; // JPRx
146                 //double scaleX=(scrX/(maxReal_X))* (mplotWindow->getZoomFactor()); // JPRx
147                         
148                 // Creating the color bar with values according to the plotter added widget
149                 color_bar = new pColorBar(this, (m_plot->GetSize()).GetWidth(),40, true);
150                 color_bar -> setRepresentedValues ((int)minReal_X, (int)maxReal_X);
151                 color_bar -> setDeviceBlitStart (70,0);
152                 color_bar -> setVisibleRange ((int)minReal_X,(int) maxReal_X);
153                 color_bar -> setDeviceEndMargin (50);
154                 
155                 
156                 // Creating the min-max barrange bar with values according to the plotter added widget
157                 barrange = new mBarRange(this, (m_plot->GetSize()).GetWidth(),30);
158                 barrange -> setVisibleLabels (false);
159                 barrange -> setRepresentedValues (minReal_X, maxReal_X);
160                 barrange -> setDeviceBlitStart (70,0);
161                 barrange -> setDeviceEndMargin (50);
162
163                 // Adding the components to the sizer 
164                 /*
165                 if(m_plot->getActualFunction())
166                         setAll();
167                 */      
168                 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
169                 sizer->Add( m_plot, 4, wxEXPAND);       
170                 sizer->Add( color_bar,0, wxEXPAND );
171                 sizer->Add( barrange, 0, wxEXPAND );
172
173                 // sizer->Add( m_log, 0, wxEXPAND);
174                 
175                 // Stablishing the layout and sizer of the panel
176                 /*panel->*/SetAutoLayout(true);
177                 /*panel->*/SetSizer(sizer);
178                 /*panel->*/Layout();
179
180                 /*panel->*/Refresh();
181         }
182
183
184         pPlotter :: ~pPlotter ()
185         {
186
187         }
188
189 //---------------------------------------------------------------------------------------------
190 // Methods
191 //---------------------------------------------------------------------------------------------
192 /*
193 Set the bars according to the actual function 
194 */
195
196         void pPlotter::setAll()
197 {
198         actualFunction = m_plot->getActualFunction();
199
200         if (actualFunction != NULL)
201         {
202                 barrange -> setActiveStateTo(true);
203                 color_bar -> setActiveStateTo(true);
204
205                 text.Clear();
206                 text = _T("minX=");
207                 double realMin_X = actualFunction->getMinX();
208                 text = text + realMin_X;        
209                 text = text + _T(" maxX=");
210                 double realMax_X = actualFunction->getMaxX();
211                 text = text + realMax_X;
212
213                 int minShowed = actualFunction->getMinXShowed();
214                 int maxShowed = actualFunction->getMaxXShowed();
215
216                 barrange -> setRepresentedValues (realMin_X, realMax_X);
217                 barrange->SetStart( minShowed );
218                 barrange->SetEnd( maxShowed );
219
220
221                 std::vector<pColorPoint *> actualColorPoints;
222                 actualFunction -> getColorPoints(actualColorPoints);
223                 if(actualColorPoints.empty())
224                         color_bar ->reinitiateColorBar (realMin_X, realMax_X);
225                 else
226                         color_bar ->reinitiateColorBarTo(actualColorPoints);
227
228                 color_bar -> setVisibleRange (minShowed, maxShowed);
229                 
230                 // Refresh
231                 color_bar -> RefreshForce();
232                 barrange -> RefreshForce();     
233                 
234                 sendTMessage(text);
235         }
236 }
237
238         
239 //*****************************************************************************************************
240 // Color bar control methods
241 //*****************************************************************************************************
242
243 //-----------------------------------------------------------------------------------------------------
244 // Updating methods for occured events in the color bar
245 //-----------------------------------------------------------------------------------------------------
246 void  pPlotter :: onAdded_ColorPoint(wxCommandEvent& event)
247 {
248         text.Clear();
249         text = _T( "Last event was on color bar: Color point added, total#");
250         
251         actualFunction = m_plot->getActualFunction();
252         if(actualFunction!=NULL)
253         {               
254                 std::vector<pColorPoint *> actualColorPoints;
255                 color_bar ->getAddedColorsPointsList(actualColorPoints);
256                 actualFunction -> setColorPoints(actualColorPoints);
257                 text << actualColorPoints.size();
258
259                 sendTMessage(text);
260         }
261 }
262 void  pPlotter :: onRemoved_ColorPoint(wxCommandEvent& event)
263 {       
264         text.Clear();
265         text = _T( "Last event on color bar: Color point removed total#");
266
267         actualFunction = m_plot->getActualFunction();
268         std::vector<pColorPoint *> actualColorPoints;
269         color_bar ->getAddedColorsPointsList(actualColorPoints);
270         actualFunction -> setColorPoints(actualColorPoints);
271         text << actualColorPoints.size();
272         
273         sendTMessage(text);
274 }
275 void  pPlotter :: onMoved_ColorPoint(wxCommandEvent& event)
276 {
277         text.Clear();
278         text = _T( "Last event was on color bar: Color point moved to: ");
279         int lastReal_X = (int)(color_bar->getLastMovedColorPoint())->getRealX();
280         text << lastReal_X;
281         
282         barrange ->setRealX_vertical_line (lastReal_X);
283         barrange -> RefreshForce();
284         
285         m_plot->setRealGuideX (lastReal_X);
286         m_plot->UpdateAll();
287         
288         sendTMessage(text);
289 }
290 void  pPlotter:: onChanged_ColorPoint(wxCommandEvent& event)
291 {
292     text.Clear();
293         sendTMessage(_T("Last event was on color bar: Color point changed color"));
294 }
295
296 void pPlotter :: onColorBar( wxCommandEvent& event )
297 {
298         if( (barrange->getRealX_vertical_line())!=-1)
299         {
300                 barrange ->setRealX_vertical_line (-1); 
301                 m_plot->setRealGuideX (-1);
302
303                 barrange -> RefreshForce();
304                 m_plot->UpdateAll();
305         }
306 }
307
308 //*****************************************************************************************************
309 // Plotter control methods
310 //*****************************************************************************************************
311
312
313 /*
314 * Method called when actual function is changed
315 */
316 void pPlotter :: onChangeFunction (wxCommandEvent& event)
317 {
318         actualFunction = m_plot->getActualFunction();
319         
320         if (actualFunction != NULL)
321         {
322                 if( !barrange->isActive() )
323                 {
324                         barrange -> setActiveStateTo(true);
325                         color_bar -> setActiveStateTo(true);
326                 }
327
328                 text.Clear();
329                 text = _T("Last event was on plotter: function changed, minX=");
330                 double realMin_X = actualFunction->getMinX();
331                 text << realMin_X;      
332                 text << _T(" maxX=");
333                 double realMax_X = actualFunction->getMaxX();
334                 text << realMax_X;
335
336                 int minShowed = actualFunction->getMinXShowed();
337                 int maxShowed = actualFunction->getMaxXShowed();
338
339                 barrange -> setRepresentedValues (realMin_X, realMax_X);
340                 barrange->SetStart( minShowed );
341                 barrange->SetEnd( maxShowed );
342                 
343                 std::vector<pColorPoint *> actualColorPoints;
344                 actualFunction -> getColorPoints(actualColorPoints);
345                 if(actualColorPoints.empty())
346                         color_bar ->reinitiateColorBar (realMin_X, realMax_X);
347                 else
348                         color_bar ->reinitiateColorBarTo(actualColorPoints);
349
350                 color_bar -> setVisibleRange ((int)realMin_X, maxShowed);
351                 
352                 // Refresh
353                 color_bar -> RefreshForce();
354                 barrange -> RefreshForce();     
355                 
356                 sendTMessage(text);
357         }
358 }
359
360
361 /*
362 * Method called when a point is added to the actual function on the plotter
363 */
364
365 void pPlotter :: onAddedPoint_Plotter (wxCommandEvent& event)
366 {
367         text.Clear();
368         m_plot->writeInText(text);
369         sendTMessage(text);
370 }
371
372 /*
373 * Method called when a point is removed to the actual function on the plotter
374 */
375 void pPlotter :: onRemovedPoint_Plotter (wxCommandEvent& event)
376 {
377         text.Clear();
378         m_plot->writeInText(text);
379         sendTMessage(text);     
380 }
381
382 /*
383 * Method called when a point is moved from the actual function on the plotter
384 */
385 void pPlotter :: onMovePoint_Plotter (wxCommandEvent& event)
386 {
387         text.Clear();
388         m_plot->writeInText(text);
389         sendTMessage(text);
390 }
391 /*
392 * Method called when turn off the guide line from the actual function on the plotter
393 */
394 void pPlotter::onGuideLines(wxCommandEvent& event)
395 {
396                 
397 }
398
399
400
401 //*****************************************************************************************************
402 // Max-Min Barrange control methods
403 //*****************************************************************************************************
404 /*
405 *
406 */
407 void  pPlotter::onBarrange(wxCommandEvent& event)
408 {
409                 
410 }
411 /*
412 *
413 */
414 void  pPlotter::onActualChange_Bar(wxCommandEvent& event)
415 {
416         text.Clear();
417         text = _T( "Last event was on min-max bar: Actual triangle moved to: " );
418         int lastActual_X = barrange->GetActual();
419
420         text << lastActual_X;
421         
422         color_bar ->setRealX_vertical_line (lastActual_X);
423         m_plot->setRealGuideX (lastActual_X);
424
425         color_bar -> RefreshForce();    
426         m_plot->UpdateAll();
427
428         sendTMessage(text);
429 }
430
431 /*
432 * Method called when the start triangle is moved. Adjusts the plotter and color bar view-range.
433 */
434 void  pPlotter::onStartChange_Bar(wxCommandEvent& event)
435 {
436         text.Clear();
437     
438         text = _T( "Last event was on min-max bar: Start triangle moved to: ");
439         int realMin_X = barrange->GetStart();
440         text += wxString::Format(_T("%d"), realMin_X);  
441         double realMax_X = m_plot->getMaxScrX();
442         
443         color_bar -> setVisibleRange (realMin_X, (int)realMax_X);
444         
445         m_plot->actualizeViewRange(realMin_X, (int)realMax_X);
446         
447         //setting the plotter for draw the functions that
448         //it has to move.
449         
450         float startP=(float)barrange->getStartShowPorcentage();
451         float endP=(float)barrange->getEndShowPorcentage();
452         m_plot->moveFunctions(startP,endP);
453         
454         //Updating
455         color_bar -> RefreshForce();
456         m_plot -> UpdateAll();
457         sendTMessage(text);
458 }
459
460 void  pPlotter::onEndChange_Bar(wxCommandEvent& event)
461 {
462         text.Clear();
463         text += _T("Last event was on min-max bar: End  triangle moved to: ");
464         int realMax_X = barrange->GetEnd();
465         text += wxString::Format(_T("%d"),realMax_X);   
466         double realMin_X = m_plot->getMinScrX();
467         color_bar -> setVisibleRange ((int)realMin_X, realMax_X);
468         m_plot->actualizeViewRange((int)realMin_X,realMax_X);
469         
470         float startP=(float)barrange->getStartShowPorcentage();
471         float endP=(float)barrange->getEndShowPorcentage();
472         m_plot->moveFunctions(startP,endP);
473         
474         color_bar -> RefreshForce();
475         m_plot -> UpdateAll();
476
477         sendTMessage(text);
478 }
479
480 void pPlotter :: onSelectionEnd(wxCommandEvent& event)
481 {
482         if( (color_bar->getRealX_vertical_line())!=-1)
483         {
484                 color_bar ->setRealX_vertical_line (-1);        
485                 m_plot->setRealGuideX (-1);
486
487                 color_bar -> RefreshForce();
488                 m_plot->UpdateAll();    
489         }
490 }
491 void  pPlotter :: onMovedBar(wxCommandEvent& event)
492 {
493         text.Clear();
494         text = _T( "Last event was on min-max bar: Moved bar to min:" );
495         
496         int realMin_X = barrange->GetStart();
497         text +=  wxString::Format(_T("%d"),realMin_X);  
498         text +=  _T(" max:");
499
500         int realMax_X = barrange->GetEnd();
501         text +=  wxString::Format(_T("%d"),realMax_X);
502
503         color_bar -> setVisibleRange (realMin_X, realMax_X);
504         
505         float startP=(float)barrange->getStartShowPorcentage();
506         float endP=(float)barrange->getEndShowPorcentage();
507         m_plot->moveFunctions(startP,endP);
508         
509         color_bar -> RefreshForce();
510         m_plot -> UpdateAll();
511
512         sendTMessage(text);
513 }
514
515 /*
516         * Method for sending a text message to the container window
517         * @param theText Is the text of the message
518         */
519 void pPlotter :: sendTMessage(wxString theText)
520 {
521         //Creating a message event 
522         wxCommandEvent puntualMSG_Event( wxEVT_NW_TEXT_MESAGGE, GetId() );
523         puntualMSG_Event.SetEventObject(this);
524         //Sending the event
525         GetEventHandler()->ProcessEvent( puntualMSG_Event );
526 }
527
528 /*
529         * Sets the text message
530         * @param nMessage Is the text message to set
531         */
532         void pPlotter :: setTextMessage(wxString nMessage)
533         {
534                 text = nMessage;
535         }
536
537         /*
538         * Gets the text message
539         * @param text Is the actual text message 
540         */
541         wxString pPlotter :: getTextMessage()
542         {
543                 return text;
544         }
545         /**
546         * Add a function to the plotter
547         * when the function doesnt come from window
548         */
549         int pPlotter:: addFunction(pGraphicalFunction * function)
550         {
551                 return m_plot->addFunction(function);  
552         }
553         /**
554         * Creates and returns a graphical funcion according to the indicated vectors.
555         */
556         pGraphicalFunction* pPlotter::getFunctionForVectors( double* vectorX, int sizeX,double * vectorY, int sizeY )
557         {
558                 return m_plot->getFunctionForVectors(vectorX,sizeX, vectorY, sizeY );
559         }
560                 /*
561          Set Type
562         */
563         void pPlotter::setType(int t)
564         {
565                 m_plot->setType(t);
566         }
567         /*
568          Get a function in the plotter given the index
569         */
570         pGraphicalFunction* pPlotter:: getFunction(int index)
571         {
572                 return m_plot->getFunction(index);
573         }
574         /*
575          Adds  function to move with the bar min max
576         */
577         int pPlotter::addFunctionToMove(pGraphicalFunction * function)
578         {
579                 return m_plot->addFunctionToMove(function);
580         }
581         
582         /*
583           move the functions that the user wants to move
584           and that were setted in functionsToMove
585           @param porcentageMinX:the porcentage that the minShowed
586           of the funcntions have to be move
587           @param porcentageMaxX:the porcentage that the maxShowed
588           of the funcntions have to be move
589
590         */
591         void pPlotter:: moveFunctions(float porcentageMinX,float porcentageMaxX)
592         {
593                 m_plot->moveFunctions(porcentageMinX,porcentageMaxX);
594         }
595         /*
596         * deletes the function from the plotter
597         */
598         /*
599         bool pPlotter::deleteFunction(pGraphicalFunction * function);
600                 {
601                         return m_plot->deleteFunction(function);
602
603                 }
604
605         */
606         //--------------------
607         // Color information
608         //---------------------
609         /**
610                 Returns the number of points that the bar color has
611         */
612         int pPlotter::getColorPointsSize()
613         {
614                 return color_bar->getColorPointsSize();
615         }
616         /*
617          Get the RGB values of the color point that is in the
618          index given
619         */
620         void pPlotter::getBarColorDataAt(int index,double& x, int& red,int& green,int& blue)
621         {
622                 color_bar->getDataAt(index,x,red,green,blue);
623         }
624         /*
625          add a color Point 
626          returns true if the point was succesfully added
627          PRE: 0<=red<=255 0<=green<=255 0<=blue<=255
628         */
629         bool pPlotter::addColorPoint(int x,int red,int green, int blue)
630         {
631                 wxColour color= wxColour(red,green,blue);
632                 return color_bar->addColorPoint((double)x, color);
633         }
634         void pPlotter::eraseColorPoints()
635         {
636                 int min=(int)color_bar->getMinValue();
637                 int max=(int)color_bar->getMaxValue();
638                 color_bar->reinitiateColorBar(min,max);
639         }
640
641         //--------------------
642         // bar Information
643         //---------------------
644         float pPlotter::getMaxShowedPorcentage()
645         {
646                 return barrange->getEndShowPorcentage();
647         }
648         float pPlotter::getMinShowedPorcentage()
649         {
650                 return barrange->getStartShowPorcentage();
651         }
652         float pPlotter::getActualShowedPorcentage()
653         {
654                 return barrange->getActualShowPorcentage();
655         }
656         
657         //--------------------
658         // plotter Information
659         //---------------------
660         void pPlotter::setActual(pGraphicalFunction* nActual)
661         {
662                 m_plot->setActualFunction(nActual);
663         }
664         void pPlotter::update()
665         {
666                 //if it is a plotter of histograms
667                 if(m_plot->getType()==2)
668                 {
669                         pGraphicalFunction* tf= m_plot->getActualFunction();
670                         if(tf->getType()==2)
671                         {
672                                 tf->clearSplineVectors();
673                                 tf->addSplinesPoints();
674                                 tf->initializeSplineVectors();
675                         }
676                 }
677
678                 m_plot->UpdateAll();
679         }
680         //----------------------------
681         //Handling Options Menu
682         //----------------------------
683         
684         void pPlotter::setPopUpMenu(bool startD,bool stopD,bool smooth,bool line, bool zoomIn,
685                                           bool zoomOut,bool showPoints,bool noShowPoints,bool changeColor, bool addP,
686                                           bool delPoint,bool load,bool save)
687         {
688                 m_plot->setPopUpMenu(startD, stopD, smooth, line,  zoomIn,
689                                            zoomOut, showPoints, noShowPoints, changeColor,  addP,
690                                            delPoint, load, save);
691         }
692
693
694         /*
695                 if the user resize the window   
696         */
697         
698         
699         
700         /*
701         void pPlotter::OnSize( wxSizeEvent &WXUNUSED(event) )
702         {
703                 int scrX,scrY;
704                 GetClientSize(&scrX,&scrY);
705                 m_plot->SetSize(scrX,scrY);
706                 
707                 
708                 pGraphicalFunction* actual=m_plot->getActualFunction();
709                 if(actual!=NULL)
710                 {               
711                         actual->setScreens(scrX,scrY);
712                         actual->setScales();
713                 }
714                 
715                 
716         }
717         */
718         
719
720 /**
721 **      Returns two vectors, the grey level of the point and its value, the value is between [0,1]
722 **/
723 void pPlotter::GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& value, int histogramsize)
724 {
725         if(actualFunction != NULL){
726                 double* xval = actualFunction->getX_RealValues();
727                 double* yval = actualFunction->getY_RealValues();
728
729                 actualFunction->getScaleY();
730                 for(int i = 0; i < actualFunction->getSizePoints();i++){
731                         greylevel.push_back(xval[i]);
732                         value.push_back(yval[i]/histogramsize);
733                 }
734         }
735 }
736
737 /**
738 **      Returns two vectors, the grey level of the point and its value, the red, green
739 **      and blue value is between [0,1]
740 **/
741 void pPlotter::GetValuesColorPointsFunction(std::vector<double>& greylevel,
742                                                                 std::vector<double>& red,
743                                                                 std::vector<double>& green,
744                                                                 std::vector<double>& blue)
745 {
746
747         if(color_bar != NULL){
748
749                 std::vector<pColorPoint*> colors;
750         color_bar->getAddedColorsPointsList(colors);
751
752                 for(int i = 0; i < colors.size();i++){
753                         pColorPoint* pcolor = colors[i];
754
755                         greylevel.push_back(pcolor->getRealX());
756                         wxColour colour = pcolor->getColor();
757                         
758                         double _red = (double)(colour.Red())/255.0;
759                         double _green = (double)(colour.Green())/255.0;
760                         double _blue = (double)(colour.Blue())/255.0;
761
762                         red.push_back(_red);
763                         green.push_back(_green);
764                         blue.push_back(_blue);
765                 }               
766         }
767 }
768
769
770
771