]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pPlotter.cxx
TransferFunctionfinish
[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                 actualFunction =NULL;
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 //---------------------------------------------------------------------------------------------
191 // Methods
192 //---------------------------------------------------------------------------------------------
193 /*
194 Set the bars according to the actual function 
195 */
196
197         void pPlotter::setAll()
198 {
199         actualFunction = m_plot->getActualFunction();
200
201         if (actualFunction != NULL)
202         {
203                 barrange -> setActiveStateTo(true);
204                 color_bar -> setActiveStateTo(true);
205
206                 text.Clear();
207                 text = _T("minX=");
208                 double realMin_X = actualFunction->getMinX();
209                 text = text + realMin_X;        
210                 text = text + _T(" maxX=");
211                 double realMax_X = actualFunction->getMaxX();
212                 text = text + realMax_X;
213
214                 int minShowed = actualFunction->getMinXShowed();
215                 int maxShowed = actualFunction->getMaxXShowed();
216
217                 barrange -> setRepresentedValues (realMin_X, realMax_X);
218                 barrange->SetStart( minShowed );
219                 barrange->SetEnd( maxShowed );
220
221
222                 std::vector<pColorPoint *> actualColorPoints;
223                 actualFunction -> getColorPoints(actualColorPoints);
224                 if(actualColorPoints.empty())
225                         color_bar ->reinitiateColorBar (realMin_X, realMax_X);
226                 else
227                         color_bar ->reinitiateColorBarTo(actualColorPoints);
228
229                 color_bar -> setVisibleRange (minShowed, maxShowed);
230                 
231                 // Refresh
232                 color_bar -> RefreshForce();
233                 barrange -> RefreshForce();     
234                 
235                 sendTMessage(text);
236         }
237 }
238
239         
240 //*****************************************************************************************************
241 // Color bar control methods
242 //*****************************************************************************************************
243
244 //-----------------------------------------------------------------------------------------------------
245 // Updating methods for occured events in the color bar
246 //-----------------------------------------------------------------------------------------------------
247 void  pPlotter :: onAdded_ColorPoint(wxCommandEvent& event)
248 {
249         text.Clear();
250         text = _T( "Last event was on color bar: Color point added, total#");
251         
252         actualFunction = m_plot->getActualFunction();
253         if(actualFunction!=NULL)
254         {               
255                 std::vector<pColorPoint *> actualColorPoints;
256                 color_bar ->getAddedColorsPointsList(actualColorPoints);
257                 actualFunction -> setColorPoints(actualColorPoints);
258                 text << actualColorPoints.size();
259
260                 sendTMessage(text);
261         }
262 }
263 void  pPlotter :: onRemoved_ColorPoint(wxCommandEvent& event)
264 {       
265         text.Clear();
266         text = _T( "Last event on color bar: Color point removed total#");
267
268         actualFunction = m_plot->getActualFunction();
269         std::vector<pColorPoint *> actualColorPoints;
270         color_bar ->getAddedColorsPointsList(actualColorPoints);
271         actualFunction -> setColorPoints(actualColorPoints);
272         text << actualColorPoints.size();
273         
274         sendTMessage(text);
275 }
276 void  pPlotter :: onMoved_ColorPoint(wxCommandEvent& event)
277 {
278         text.Clear();
279         text = _T( "Last event was on color bar: Color point moved to: ");
280         int lastReal_X = (int)(color_bar->getLastMovedColorPoint())->getRealX();
281         text << lastReal_X;
282         
283         barrange ->setRealX_vertical_line (lastReal_X);
284         barrange -> RefreshForce();
285         
286         m_plot->setRealGuideX (lastReal_X);
287         m_plot->UpdateAll();
288         
289         sendTMessage(text);
290 }
291 void  pPlotter:: onChanged_ColorPoint(wxCommandEvent& event)
292 {
293     text.Clear();
294         sendTMessage(_T("Last event was on color bar: Color point changed color"));
295 }
296
297 void pPlotter :: onColorBar( wxCommandEvent& event )
298 {
299         if( (barrange->getRealX_vertical_line())!=-1)
300         {
301                 barrange ->setRealX_vertical_line (-1); 
302                 m_plot->setRealGuideX (-1);
303
304                 barrange -> RefreshForce();
305                 m_plot->UpdateAll();
306         }
307 }
308
309 //*****************************************************************************************************
310 // Plotter control methods
311 //*****************************************************************************************************
312
313
314 /*
315 * Method called when actual function is changed
316 */
317 void pPlotter :: onChangeFunction (wxCommandEvent& event)
318 {
319         actualFunction = m_plot->getActualFunction();
320         
321         if (actualFunction != NULL)
322         {
323                 if( !barrange->isActive() )
324                 {
325                         barrange -> setActiveStateTo(true);
326                         color_bar -> setActiveStateTo(true);
327                 }
328
329                 text.Clear();
330                 text = _T("Last event was on plotter: function changed, minX=");
331                 double realMin_X = actualFunction->getMinX();
332                 text << realMin_X;      
333                 text << _T(" maxX=");
334                 double realMax_X = actualFunction->getMaxX();
335                 text << realMax_X;
336
337                 int minShowed = actualFunction->getMinXShowed();
338                 int maxShowed = actualFunction->getMaxXShowed();
339
340                 barrange -> setRepresentedValues (realMin_X, realMax_X);
341                 barrange->SetStart( minShowed );
342                 barrange->SetEnd( maxShowed );
343                 
344                 std::vector<pColorPoint *> actualColorPoints;
345                 actualFunction -> getColorPoints(actualColorPoints);
346                 if(actualColorPoints.empty())
347                         color_bar ->reinitiateColorBar (realMin_X, realMax_X);
348                 else
349                         color_bar ->reinitiateColorBarTo(actualColorPoints);
350
351                 color_bar -> setVisibleRange ((int)realMin_X, maxShowed);
352                 
353                 // Refresh
354                 color_bar -> RefreshForce();
355                 barrange -> RefreshForce();     
356                 
357                 sendTMessage(text);
358         }
359 }
360
361
362 /*
363 * Method called when a point is added to the actual function on the plotter
364 */
365
366 void pPlotter :: onAddedPoint_Plotter (wxCommandEvent& event)
367 {
368         text.Clear();
369         m_plot->writeInText(text);
370         sendTMessage(text);
371 }
372
373 /*
374 * Method called when a point is removed to the actual function on the plotter
375 */
376 void pPlotter :: onRemovedPoint_Plotter (wxCommandEvent& event)
377 {
378         text.Clear();
379         m_plot->writeInText(text);
380         sendTMessage(text);     
381 }
382
383 /*
384 * Method called when a point is moved from the actual function on the plotter
385 */
386 void pPlotter :: onMovePoint_Plotter (wxCommandEvent& event)
387 {
388         text.Clear();
389         m_plot->writeInText(text);
390         sendTMessage(text);
391 }
392 /*
393 * Method called when turn off the guide line from the actual function on the plotter
394 */
395 void pPlotter::onGuideLines(wxCommandEvent& event)
396 {
397                 
398 }
399
400
401
402 //*****************************************************************************************************
403 // Max-Min Barrange control methods
404 //*****************************************************************************************************
405 /*
406 *
407 */
408 void  pPlotter::onBarrange(wxCommandEvent& event)
409 {
410                 
411 }
412 /*
413 *
414 */
415 void  pPlotter::onActualChange_Bar(wxCommandEvent& event)
416 {
417         text.Clear();
418         text = _T( "Last event was on min-max bar: Actual triangle moved to: " );
419         int lastActual_X = barrange->GetActual();
420
421         text << lastActual_X;
422         
423         color_bar ->setRealX_vertical_line (lastActual_X);
424         m_plot->setRealGuideX (lastActual_X);
425
426         color_bar -> RefreshForce();    
427         m_plot->UpdateAll();
428
429         sendTMessage(text);
430 }
431
432 /*
433 * Method called when the start triangle is moved. Adjusts the plotter and color bar view-range.
434 */
435 void  pPlotter::onStartChange_Bar(wxCommandEvent& event)
436 {
437         text.Clear();
438     
439         text = _T( "Last event was on min-max bar: Start triangle moved to: ");
440         int realMin_X = barrange->GetStart();
441         text += wxString::Format(_T("%d"), realMin_X);  
442         double realMax_X = m_plot->getMaxScrX();
443         
444         color_bar -> setVisibleRange (realMin_X, (int)realMax_X);
445         
446         m_plot->actualizeViewRange(realMin_X, (int)realMax_X);
447         
448         //setting the plotter for draw the functions that
449         //it has to move.
450         
451         float startP=(float)barrange->getStartShowPorcentage();
452         float endP=(float)barrange->getEndShowPorcentage();
453         m_plot->moveFunctions(startP,endP);
454         
455         //Updating
456         color_bar -> RefreshForce();
457         m_plot -> UpdateAll();
458         sendTMessage(text);
459 }
460
461 void  pPlotter::onEndChange_Bar(wxCommandEvent& event)
462 {
463         text.Clear();
464         text += _T("Last event was on min-max bar: End  triangle moved to: ");
465         int realMax_X = barrange->GetEnd();
466         text += wxString::Format(_T("%d"),realMax_X);   
467         double realMin_X = m_plot->getMinScrX();
468         color_bar -> setVisibleRange ((int)realMin_X, realMax_X);
469         m_plot->actualizeViewRange((int)realMin_X,realMax_X);
470         
471         float startP=(float)barrange->getStartShowPorcentage();
472         float endP=(float)barrange->getEndShowPorcentage();
473         m_plot->moveFunctions(startP,endP);
474         
475         color_bar -> RefreshForce();
476         m_plot -> UpdateAll();
477
478         sendTMessage(text);
479 }
480
481 void pPlotter :: onSelectionEnd(wxCommandEvent& event)
482 {
483         if( (color_bar->getRealX_vertical_line())!=-1)
484         {
485                 color_bar ->setRealX_vertical_line (-1);        
486                 m_plot->setRealGuideX (-1);
487
488                 color_bar -> RefreshForce();
489                 m_plot->UpdateAll();    
490         }
491 }
492 void  pPlotter :: onMovedBar(wxCommandEvent& event)
493 {
494         text.Clear();
495         text = _T( "Last event was on min-max bar: Moved bar to min:" );
496         
497         int realMin_X = barrange->GetStart();
498         text +=  wxString::Format(_T("%d"),realMin_X);  
499         text +=  _T(" max:");
500
501         int realMax_X = barrange->GetEnd();
502         text +=  wxString::Format(_T("%d"),realMax_X);
503
504         color_bar -> setVisibleRange (realMin_X, realMax_X);
505         
506         float startP=(float)barrange->getStartShowPorcentage();
507         float endP=(float)barrange->getEndShowPorcentage();
508         m_plot->moveFunctions(startP,endP);
509         
510         color_bar -> RefreshForce();
511         m_plot -> UpdateAll();
512
513         sendTMessage(text);
514 }
515
516 /*
517         * Method for sending a text message to the container window
518         * @param theText Is the text of the message
519         */
520 void pPlotter :: sendTMessage(wxString theText)
521 {
522         //Creating a message event 
523         wxCommandEvent puntualMSG_Event( wxEVT_NW_TEXT_MESAGGE, GetId() );
524         puntualMSG_Event.SetEventObject(this);
525         //Sending the event
526         GetEventHandler()->ProcessEvent( puntualMSG_Event );
527 }
528
529 /*
530         * Sets the text message
531         * @param nMessage Is the text message to set
532         */
533         void pPlotter :: setTextMessage(wxString nMessage)
534         {
535                 text = nMessage;
536         }
537
538         /*
539         * Gets the text message
540         * @param text Is the actual text message 
541         */
542         wxString pPlotter :: getTextMessage()
543         {
544                 return text;
545         }
546         /**
547         * Add a function to the plotter
548         * when the function doesnt come from window
549         */
550         int pPlotter:: addFunction(pGraphicalFunction * function)
551         {
552                 return m_plot->addFunction(function);  
553         }
554         /**
555         * Creates and returns a graphical funcion according to the indicated vectors.
556         */
557         pGraphicalFunction* pPlotter::getFunctionForVectors( double* vectorX, int sizeX,double * vectorY, int sizeY )
558         {
559                 return m_plot->getFunctionForVectors(vectorX,sizeX, vectorY, sizeY );
560         }
561                 /*
562          Set Type
563         */
564         void pPlotter::setType(int t)
565         {
566                 m_plot->setType(t);
567         }
568         /*
569          Get a function in the plotter given the index
570         */
571         pGraphicalFunction* pPlotter:: getFunction(int index)
572         {
573                 return m_plot->getFunction(index);
574         }
575         /*
576          Adds  function to move with the bar min max
577         */
578         int pPlotter::addFunctionToMove(pGraphicalFunction * function)
579         {
580                 return m_plot->addFunctionToMove(function);
581         }
582         
583         /*
584           move the functions that the user wants to move
585           and that were setted in functionsToMove
586           @param porcentageMinX:the porcentage that the minShowed
587           of the funcntions have to be move
588           @param porcentageMaxX:the porcentage that the maxShowed
589           of the funcntions have to be move
590
591         */
592         void pPlotter:: moveFunctions(float porcentageMinX,float porcentageMaxX)
593         {
594                 m_plot->moveFunctions(porcentageMinX,porcentageMaxX);
595         }
596         /*
597         * deletes the function from the plotter
598         */
599         /*
600         bool pPlotter::deleteFunction(pGraphicalFunction * function);
601                 {
602                         return m_plot->deleteFunction(function);
603
604                 }
605
606         */
607         //--------------------
608         // Color information
609         //---------------------
610         /**
611                 Returns the number of points that the bar color has
612         */
613         int pPlotter::getColorPointsSize()
614         {
615                 return color_bar->getColorPointsSize();
616         }
617         /*
618          Get the RGB values of the color point that is in the
619          index given
620         */
621         void pPlotter::getBarColorDataAt(int index,double& x, int& red,int& green,int& blue)
622         {
623                 color_bar->getDataAt(index,x,red,green,blue);
624         }
625         /*
626          add a color Point 
627          returns true if the point was succesfully added
628          PRE: 0<=red<=255 0<=green<=255 0<=blue<=255
629         */
630         bool pPlotter::addColorPoint(int x,int red,int green, int blue)
631         {
632                 wxColour color= wxColour(red,green,blue);
633                 return color_bar->addColorPoint((double)x, color);
634         }
635         void pPlotter::eraseColorPoints()
636         {
637                 int min=(int)color_bar->getMinValue();
638                 int max=(int)color_bar->getMaxValue();
639                 color_bar->reinitiateColorBar(min,max);
640         }
641
642         //--------------------
643         // bar Information
644         //---------------------
645         float pPlotter::getMaxShowedPorcentage()
646         {
647                 return barrange->getEndShowPorcentage();
648         }
649         float pPlotter::getMinShowedPorcentage()
650         {
651                 return barrange->getStartShowPorcentage();
652         }
653         float pPlotter::getActualShowedPorcentage()
654         {
655                 return barrange->getActualShowPorcentage();
656         }
657         
658         //--------------------
659         // plotter Information
660         //---------------------
661         void pPlotter::setActual(pGraphicalFunction* nActual)
662         {
663                 m_plot->setActualFunction(nActual);
664         }
665         void pPlotter::update()
666         {
667                 //if it is a plotter of histograms
668                 if(m_plot->getType()==2)
669                 {
670                         pGraphicalFunction* tf= m_plot->getActualFunction();
671                         if(tf->getType()==2)
672                         {
673                                 tf->clearSplineVectors();
674                                 tf->addSplinesPoints();
675                                 tf->initializeSplineVectors();
676                         }
677                 }
678
679                 m_plot->UpdateAll();
680         }
681         //----------------------------
682         //Handling Options Menu
683         //----------------------------
684         
685         void pPlotter::setPopUpMenu(bool startD,bool stopD,bool smooth,bool line, bool zoomIn,
686                                           bool zoomOut,bool showPoints,bool noShowPoints,bool changeColor, bool addP,
687                                           bool delPoint,bool load,bool save)
688         {
689                 m_plot->setPopUpMenu(startD, stopD, smooth, line,  zoomIn,
690                                            zoomOut, showPoints, noShowPoints, changeColor,  addP,
691                                            delPoint, load, save);
692         }
693
694
695         /*
696                 if the user resize the window   
697         */
698         
699         
700         
701         /*
702         void pPlotter::OnSize( wxSizeEvent &WXUNUSED(event) )
703         {
704                 int scrX,scrY;
705                 GetClientSize(&scrX,&scrY);
706                 m_plot->SetSize(scrX,scrY);
707                 
708                 
709                 pGraphicalFunction* actual=m_plot->getActualFunction();
710                 if(actual!=NULL)
711                 {               
712                         actual->setScreens(scrX,scrY);
713                         actual->setScales();
714                 }
715                 
716                 
717         }
718         */
719         
720
721 /**
722 **      Returns two vectors, the grey level of the point and its value, the value is between [0,1]
723 **/
724 void pPlotter::GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& value, int histogramsize)
725 {
726         if(actualFunction != NULL){
727                 double* xval = actualFunction->getX_RealValues();
728                 double* yval = actualFunction->getY_RealValues();
729
730                 actualFunction->getScaleY();
731                 for(int i = 0; i < actualFunction->getSizePoints();i++){
732                         greylevel.push_back(xval[i]);
733                         value.push_back(yval[i]/histogramsize);
734                 }
735         }
736 }
737
738 /**
739 **      Returns two vectors, the grey level of the point and its value, the red, green
740 **      and blue value is between [0,1]
741 **/
742 void pPlotter::GetValuesColorPointsFunction(std::vector<double>& greylevel,
743                                                                 std::vector<double>& red,
744                                                                 std::vector<double>& green,
745                                                                 std::vector<double>& blue)
746 {
747
748         if(color_bar != NULL){
749
750                 std::vector<pColorPoint*> colors;
751         color_bar->getAddedColorsPointsList(colors);
752
753                 for(int i = 0; i < colors.size();i++){
754                         pColorPoint* pcolor = colors[i];
755
756                         greylevel.push_back(pcolor->getRealX());
757                         wxColour colour = pcolor->getColor();
758                         
759                         double _red = (double)(colour.Red())/255.0;
760                         double _green = (double)(colour.Green())/255.0;
761                         double _blue = (double)(colour.Blue())/255.0;
762
763                         red.push_back(_red);
764                         green.push_back(_green);
765                         blue.push_back(_blue);
766                 }               
767         }
768 }
769
770
771
772