pPlotter.cxx

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------------------------
00002 // Class definition include
00003 //---------------------------------------------------------------------------------------------
00004 #include "pPlotter.h"
00005 
00006 // --------------------------------------------------------------------------------------------
00007 // WX headers inclusion.
00008 // For compilers that support precompilation, includes <wx/wx.h>.
00009 // --------------------------------------------------------------------------------------------
00010 
00011 #ifndef WX_PRECOMP
00012 #include <wx/wx.h>
00013 #endif
00014 
00015 //---------------------------------------------------------------------------------------------
00016 // Class implementation
00017 //---------------------------------------------------------------------------------------------
00018 
00019 IMPLEMENT_CLASS(pPlotter, wxPanel)
00020 
00021 //------------------------------------------------------------------------------------------------------------
00022 // Generated events declaration and definition
00023 //------------------------------------------------------------------------------------------------------------
00024 BEGIN_DECLARE_EVENT_TYPES()
00025         DECLARE_EVENT_TYPE( wxEVT_NW_TEXT_MESAGGE, -1 ) 
00026 END_DECLARE_EVENT_TYPES()
00027 
00028 DEFINE_EVENT_TYPE( wxEVT_NW_TEXT_MESAGGE )
00029 
00030 // ----------------------------------------------------------------------------------------------------
00031 // Handdled events from pColorBar
00032 // ----------------------------------------------------------------------------------------------------
00033 DECLARE_EVENT_TYPE(wxEVT_ADDED_POINT, -1)
00034 DECLARE_EVENT_TYPE(wxEVT_REMOVED_POINT, -1)
00035 DECLARE_EVENT_TYPE(wxEVT_MOVED_POINT, -1)
00036 DECLARE_EVENT_TYPE(wxEVT_CHANGED_POINT, -1)
00037 DECLARE_EVENT_TYPE(wxEVT_ON_COLOR_BAR, -1)
00038 
00039 // ----------------------------------------------------------------------------------------------------
00040 // Handdled events from plotter
00041 // ----------------------------------------------------------------------------------------------------
00042 DECLARE_EVENT_TYPE(wxEVT_PPLOTTER_CHANGED_FUNCTION, -1)
00043 DECLARE_EVENT_TYPE(wxEVT_PPLOTTER_POINT_MOVE, -1)
00044 DECLARE_EVENT_TYPE(wxEVT_PPLOTTER_POINT_ADD, -1)
00045 DECLARE_EVENT_TYPE(wxEVT_PPLOTTER_POINT_DELETE, -1)
00046 DECLARE_EVENT_TYPE(wxEVT_PPLOTTER_GUIDELINES, -1)
00047 
00048 // ----------------------------------------------------------------------------------------------------
00049 // Handdled events from max-min barrange
00050 // ----------------------------------------------------------------------------------------------------
00051 DECLARE_EVENT_TYPE(wxEVT_TSBAR, -1)
00052 DECLARE_EVENT_TYPE(wxEVT_TSBAR_ACTUAL, -1)
00053 DECLARE_EVENT_TYPE(wxEVT_TSBAR_START, -1)
00054 DECLARE_EVENT_TYPE(wxEVT_TSBAR_END, -1)
00055 DECLARE_EVENT_TYPE(wxEVT_TSBAR_MOVED, -1)
00056 DECLARE_EVENT_TYPE(wxEVT_SELECTION_END, -1)
00057 
00058 
00059 // ----------------------------------------------------------------------------------------------------
00060 // EVENT TABLE (->Connect: analogous)
00061 //-----------------------------------------------------------------------------------------------------
00062 BEGIN_EVENT_TABLE(pPlotter, wxPanel)
00063         //OnSize
00064         //EVT_SIZE  (pPlotter::OnSize)
00065         
00066         // Connectting the handled envents for the plotter to the corresponding methods
00067         EVT_COMMAND  (-1,wxEVT_PPLOTTER_CHANGED_FUNCTION, pPlotter::onChangeFunction)
00068         EVT_COMMAND  (-1,wxEVT_PPLOTTER_POINT_MOVE, pPlotter::onMovePoint_Plotter)
00069         EVT_COMMAND  (-1,wxEVT_PPLOTTER_POINT_ADD, pPlotter::onAddedPoint_Plotter)
00070         EVT_COMMAND  (-1,wxEVT_PPLOTTER_POINT_DELETE, pPlotter::onRemovedPoint_Plotter)
00071         EVT_COMMAND  (-1,wxEVT_PPLOTTER_GUIDELINES, pPlotter::onGuideLines)
00072 
00073         // Connectting the handled envents for the color bar  to the corresponding methods
00074     EVT_COMMAND  (-1,wxEVT_ADDED_POINT, pPlotter :: onAdded_ColorPoint )
00075         EVT_COMMAND  (-1,wxEVT_REMOVED_POINT, pPlotter :: onRemoved_ColorPoint )
00076         EVT_COMMAND  (-1,wxEVT_MOVED_POINT, pPlotter :: onMoved_ColorPoint )
00077         EVT_COMMAND  (-1,wxEVT_CHANGED_POINT, pPlotter :: onChanged_ColorPoint )
00078         EVT_COMMAND  (-1,wxEVT_ON_COLOR_BAR, pPlotter :: onColorBar )
00079 
00080         // Connectting the handled envents from the max-min barrange  to the corresponding methods
00081         EVT_COMMAND  (-1,wxEVT_TSBAR, pPlotter::onBarrange)
00082         EVT_COMMAND  (-1,wxEVT_SELECTION_END, pPlotter::onSelectionEnd)
00083         EVT_COMMAND  (-1,wxEVT_TSBAR_MOVED, pPlotter::onMovedBar)
00084         EVT_COMMAND  (-1,wxEVT_TSBAR_ACTUAL, pPlotter:: onActualChange_Bar)
00085         EVT_COMMAND  (-1,wxEVT_TSBAR_START, pPlotter::onStartChange_Bar)
00086         EVT_COMMAND  (-1,wxEVT_TSBAR_END, pPlotter::onEndChange_Bar)
00087 
00088 END_EVENT_TABLE()
00089 
00090 
00091 //---------------------------------------------------------------------------------------------
00092 // Constructors & Destructors
00093 //---------------------------------------------------------------------------------------------
00094         /*
00095         * Creates an integrated plotter instance 
00096         * @param *parent Container window
00097         */
00098         pPlotter :: pPlotter  (wxWindow *parent,int nWidth, int nHeight)
00099         :wxPanel(parent,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL)
00100         {
00101                 SetBackgroundColour(wxColour(255,255,255));
00102                 m_plot = new pPlotterWindow( this, -1, wxPoint(0,0), wxSize(nWidth,nHeight), wxSUNKEN_BORDER );
00103                 actualFunction =NULL;
00104                 // Adding the axis layers to the plotter
00105                 m_plot->AddLayer( new pPlotterScaleX() );
00106                 m_plot->AddLayer( new pPlotterScaleY() );  
00107 
00108                 // Creating the log window
00109         /*
00110            
00111                 m_log = new wxTextCtrl( panel, -1, wxT("This is the log window.\n"), wxPoint(0,0), wxSize(400,100), wxTE_MULTILINE );
00112                 // Sharing the log window of the application with the plotter widget    
00113                 m_plot->setmLog(m_log);
00114                 
00115                 */
00116 
00117 
00118                 // Creating a function for the plotter with given points x-vector and y-vector
00119 
00120                 /*
00121                 double vectX_F1 [] = { 0, 20, 50, 80, 100, 115, 120, 210, 220,250 };
00122 
00123                 
00124 //              double vectX_F1 [] = { 0, 20, 50, 80, 100, 115, 120, 210, 220,250 };
00125 
00126                 double vectY_F1 [] = { 0, 40, 70, 100, 200, 100, 40, 170, 0, 50  };
00127                 pGraphicalFunction * f1 = m_plot ->getFunctionForVectors( vectX_F1, 10, vectY_F1, 10 ); 
00128                 // Including and drawing the created function in the plotter
00129                 if (f1)
00130                 {
00131                         m_plot->addFunction( f1 );
00132                         m_plot->addFunctionToMove(f1);
00133                         //m_plot->addFunctionToMove(f1);
00134                         wxPen mypen1(*wxBLUE, 2, wxDOT_DASH );
00135                         mypen1.SetWidth(2);
00136                         f1->SetPen( mypen1 );
00137                 }
00138                 */
00139                 
00140                 //=================== lines to sychronyze the bars width with the drawed plotter--------------------------
00141 
00142                 mpWindow* mplotWindow = ((mpWindow*)m_plot);
00143                 float minReal_X = 0; //(float)mplotWindow->getMinScrX();
00144                 float maxReal_X =(float)mplotWindow->getMaxScrX();
00145                 //float scrX=(float)mplotWindow->GetScrX()-100; // JPRx
00146                 //double scaleX=(scrX/(maxReal_X))* (mplotWindow->getZoomFactor()); // JPRx
00147                         
00148                 // Creating the color bar with values according to the plotter added widget
00149                 color_bar = new pColorBar(this, (m_plot->GetSize()).GetWidth(),40, true);
00150                 color_bar -> setRepresentedValues ((int)minReal_X, (int)maxReal_X);
00151                 color_bar -> setDeviceBlitStart (70,0);
00152                 color_bar -> setVisibleRange ((int)minReal_X,(int) maxReal_X);
00153                 color_bar -> setDeviceEndMargin (50);
00154                 
00155                 
00156                 // Creating the min-max barrange bar with values according to the plotter added widget
00157                 barrange = new mBarRange(this, (m_plot->GetSize()).GetWidth(),30);
00158                 barrange -> setVisibleLabels (false);
00159                 barrange -> setRepresentedValues (minReal_X, maxReal_X);
00160                 barrange -> setDeviceBlitStart (70,0);
00161                 barrange -> setDeviceEndMargin (50);
00162 
00163                 // Adding the components to the sizer 
00164                 /*
00165                 if(m_plot->getActualFunction())
00166                         setAll();
00167                 */      
00168                 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
00169                 sizer->Add( m_plot, 4, wxEXPAND);       
00170                 sizer->Add( color_bar,0, wxEXPAND );
00171                 sizer->Add( barrange, 0, wxEXPAND );
00172 
00173                 // sizer->Add( m_log, 0, wxEXPAND);
00174                 
00175                 // Stablishing the layout and sizer of the panel
00176                 /*panel->*/SetAutoLayout(true);
00177                 /*panel->*/SetSizer(sizer);
00178                 /*panel->*/Layout();
00179 
00180                 /*panel->*/Refresh();
00181         }
00182 
00183 
00184         pPlotter :: ~pPlotter ()
00185         {       
00186                 
00187                 
00188         }
00189 
00190 //---------------------------------------------------------------------------------------------
00191 // Methods
00192 //---------------------------------------------------------------------------------------------
00193 /*
00194 Set the bars according to the actual function 
00195 */
00196 
00197         void pPlotter::setAll()
00198 {
00199         actualFunction = m_plot->getActualFunction();
00200 
00201         if (actualFunction != NULL)
00202         {
00203                 barrange -> setActiveStateTo(true);
00204                 color_bar -> setActiveStateTo(true);
00205 
00206                 text.Clear();
00207                 text = _T("minX=");
00208                 double realMin_X = actualFunction->getMinX();
00209                 text = text + realMin_X;        
00210                 text = text + _T(" maxX=");
00211                 double realMax_X = actualFunction->getMaxX();
00212                 text = text + realMax_X;
00213 
00214                 int minShowed = actualFunction->getMinXShowed();
00215                 int maxShowed = actualFunction->getMaxXShowed();
00216 
00217                 barrange -> setRepresentedValues (realMin_X, realMax_X);
00218                 barrange->SetStart( minShowed );
00219                 barrange->SetEnd( maxShowed );
00220 
00221 
00222                 std::vector<pColorPoint *> actualColorPoints;
00223                 actualFunction -> getColorPoints(actualColorPoints);
00224                 if(actualColorPoints.empty())
00225                         color_bar ->reinitiateColorBar (realMin_X, realMax_X);
00226                 else
00227                         color_bar ->reinitiateColorBarTo(actualColorPoints);
00228 
00229                 color_bar -> setVisibleRange (minShowed, maxShowed);
00230                 
00231                 // Refresh
00232                 color_bar -> RefreshForce();
00233                 barrange -> RefreshForce();     
00234                 
00235                 sendTMessage(text);
00236         }
00237 }
00238 
00239         
00240 //*****************************************************************************************************
00241 // Color bar control methods
00242 //*****************************************************************************************************
00243 
00244 //-----------------------------------------------------------------------------------------------------
00245 // Updating methods for occured events in the color bar
00246 //-----------------------------------------------------------------------------------------------------
00247 void  pPlotter :: onAdded_ColorPoint(wxCommandEvent& event)
00248 {
00249         text.Clear();
00250         text = _T( "Last event was on color bar: Color point added, total#");
00251         
00252         actualFunction = m_plot->getActualFunction();
00253         if(actualFunction!=NULL)
00254         {               
00255                 std::vector<pColorPoint *> actualColorPoints;
00256                 color_bar ->getAddedColorsPointsList(actualColorPoints);
00257                 actualFunction -> setColorPoints(actualColorPoints);
00258                 text << actualColorPoints.size();
00259 
00260                 sendTMessage(text);
00261         }
00262 }
00263 void  pPlotter :: onRemoved_ColorPoint(wxCommandEvent& event)
00264 {       
00265         text.Clear();
00266         text = _T( "Last event on color bar: Color point removed total#");
00267 
00268         actualFunction = m_plot->getActualFunction();
00269         std::vector<pColorPoint *> actualColorPoints;
00270         color_bar ->getAddedColorsPointsList(actualColorPoints);
00271         actualFunction -> setColorPoints(actualColorPoints);
00272         text << actualColorPoints.size();
00273         
00274         sendTMessage(text);
00275 }
00276 void  pPlotter :: onMoved_ColorPoint(wxCommandEvent& event)
00277 {
00278         text.Clear();
00279         text = _T( "Last event was on color bar: Color point moved to: ");
00280         int lastReal_X = (int)(color_bar->getLastMovedColorPoint())->getRealX();
00281         text << lastReal_X;
00282         
00283         barrange ->setRealX_vertical_line (lastReal_X);
00284         barrange -> RefreshForce();
00285         
00286         m_plot->setRealGuideX (lastReal_X);
00287         m_plot->UpdateAll();
00288         
00289         sendTMessage(text);
00290 }
00291 void  pPlotter:: onChanged_ColorPoint(wxCommandEvent& event)
00292 {
00293     text.Clear();
00294         sendTMessage(_T("Last event was on color bar: Color point changed color"));
00295 }
00296 
00297 void pPlotter :: onColorBar( wxCommandEvent& event )
00298 {
00299         if( (barrange->getRealX_vertical_line())!=-1)
00300         {
00301                 barrange ->setRealX_vertical_line (-1); 
00302                 m_plot->setRealGuideX (-1);
00303 
00304                 barrange -> RefreshForce();
00305                 m_plot->UpdateAll();
00306         }
00307 }
00308 
00309 //*****************************************************************************************************
00310 // Plotter control methods
00311 //*****************************************************************************************************
00312 
00313 
00314 /*
00315 * Method called when actual function is changed
00316 */
00317 void pPlotter :: onChangeFunction (wxCommandEvent& event)
00318 {
00319         actualFunction = m_plot->getActualFunction();
00320         
00321         if (actualFunction != NULL)
00322         {
00323                 if( !barrange->isActive() )
00324                 {
00325                         barrange -> setActiveStateTo(true);
00326                         color_bar -> setActiveStateTo(true);
00327                 }
00328 
00329                 text.Clear();
00330                 text = _T("Last event was on plotter: function changed, minX=");
00331                 double realMin_X = actualFunction->getMinX();
00332                 text << realMin_X;      
00333                 text << _T(" maxX=");
00334                 double realMax_X = actualFunction->getMaxX();
00335                 text << realMax_X;
00336 
00337                 int minShowed = actualFunction->getMinXShowed();
00338                 int maxShowed = actualFunction->getMaxXShowed();
00339 
00340                 barrange -> setRepresentedValues (realMin_X, realMax_X);
00341                 barrange->SetStart( minShowed );
00342                 barrange->SetEnd( maxShowed );
00343                 
00344                 std::vector<pColorPoint *> actualColorPoints;
00345                 actualFunction -> getColorPoints(actualColorPoints);
00346                 if(actualColorPoints.empty())
00347                         color_bar ->reinitiateColorBar (realMin_X, realMax_X);
00348                 else
00349                         color_bar ->reinitiateColorBarTo(actualColorPoints);
00350 
00351                 color_bar -> setVisibleRange ((int)realMin_X, maxShowed);
00352                 
00353                 // Refresh
00354                 color_bar -> RefreshForce();
00355                 barrange -> RefreshForce();     
00356                 
00357                 sendTMessage(text);
00358         }
00359 }
00360 
00361 
00362 /*
00363 * Method called when a point is added to the actual function on the plotter
00364 */
00365 
00366 void pPlotter :: onAddedPoint_Plotter (wxCommandEvent& event)
00367 {
00368         text.Clear();
00369         m_plot->writeInText(text);
00370         sendTMessage(text);
00371 }
00372 
00373 /*
00374 * Method called when a point is removed to the actual function on the plotter
00375 */
00376 void pPlotter :: onRemovedPoint_Plotter (wxCommandEvent& event)
00377 {
00378         text.Clear();
00379         m_plot->writeInText(text);
00380         sendTMessage(text);     
00381 }
00382 
00383 /*
00384 * Method called when a point is moved from the actual function on the plotter
00385 */
00386 void pPlotter :: onMovePoint_Plotter (wxCommandEvent& event)
00387 {
00388         text.Clear();
00389         m_plot->writeInText(text);
00390         sendTMessage(text);
00391 }
00392 /*
00393 * Method called when turn off the guide line from the actual function on the plotter
00394 */
00395 void pPlotter::onGuideLines(wxCommandEvent& event)
00396 {
00397                 
00398 }
00399 
00400 
00401 
00402 //*****************************************************************************************************
00403 // Max-Min Barrange control methods
00404 //*****************************************************************************************************
00405 /*
00406 *
00407 */
00408 void  pPlotter::onBarrange(wxCommandEvent& event)
00409 {
00410                 
00411 }
00412 /*
00413 *
00414 */
00415 void  pPlotter::onActualChange_Bar(wxCommandEvent& event)
00416 {
00417         text.Clear();
00418         text = _T( "Last event was on min-max bar: Actual triangle moved to: " );
00419         int lastActual_X = barrange->GetActual();
00420 
00421         text << lastActual_X;
00422         
00423         color_bar ->setRealX_vertical_line (lastActual_X);
00424         m_plot->setRealGuideX (lastActual_X);
00425 
00426         color_bar -> RefreshForce();    
00427         m_plot->UpdateAll();
00428 
00429         sendTMessage(text);
00430 }
00431 
00432 /*
00433 * Method called when the start triangle is moved. Adjusts the plotter and color bar view-range.
00434 */
00435 void  pPlotter::onStartChange_Bar(wxCommandEvent& event)
00436 {
00437         text.Clear();
00438     
00439         text = _T( "Last event was on min-max bar: Start triangle moved to: ");
00440         int realMin_X = barrange->GetStart();
00441         text += wxString::Format(_T("%d"), realMin_X);  
00442         double realMax_X = m_plot->getMaxScrX();
00443         
00444         color_bar -> setVisibleRange (realMin_X, (int)realMax_X);
00445         
00446         m_plot->actualizeViewRange(realMin_X, (int)realMax_X);
00447         
00448         //setting the plotter for draw the functions that
00449         //it has to move.
00450         
00451         float startP=(float)barrange->getStartShowPorcentage();
00452         float endP=(float)barrange->getEndShowPorcentage();
00453         m_plot->moveFunctions(startP,endP);
00454         
00455         //Updating
00456         color_bar -> RefreshForce();
00457         m_plot -> UpdateAll();
00458         sendTMessage(text);
00459 }
00460 
00461 void  pPlotter::onEndChange_Bar(wxCommandEvent& event)
00462 {
00463         text.Clear();
00464         text += _T("Last event was on min-max bar: End  triangle moved to: ");
00465         int realMax_X = barrange->GetEnd();
00466         text += wxString::Format(_T("%d"),realMax_X);   
00467         double realMin_X = m_plot->getMinScrX();
00468         color_bar -> setVisibleRange ((int)realMin_X, realMax_X);
00469         m_plot->actualizeViewRange((int)realMin_X,realMax_X);
00470         
00471         float startP=(float)barrange->getStartShowPorcentage();
00472         float endP=(float)barrange->getEndShowPorcentage();
00473         m_plot->moveFunctions(startP,endP);
00474         
00475         color_bar -> RefreshForce();
00476         m_plot -> UpdateAll();
00477 
00478         sendTMessage(text);
00479 }
00480 
00481 void pPlotter :: onSelectionEnd(wxCommandEvent& event)
00482 {
00483         if( (color_bar->getRealX_vertical_line())!=-1)
00484         {
00485                 color_bar ->setRealX_vertical_line (-1);        
00486                 m_plot->setRealGuideX (-1);
00487 
00488                 color_bar -> RefreshForce();
00489                 m_plot->UpdateAll();    
00490         }
00491 }
00492 void  pPlotter :: onMovedBar(wxCommandEvent& event)
00493 {
00494         text.Clear();
00495         text = _T( "Last event was on min-max bar: Moved bar to min:" );
00496         
00497         int realMin_X = barrange->GetStart();
00498         text +=  wxString::Format(_T("%d"),realMin_X);  
00499         text +=  _T(" max:");
00500 
00501         int realMax_X = barrange->GetEnd();
00502         text +=  wxString::Format(_T("%d"),realMax_X);
00503 
00504         color_bar -> setVisibleRange (realMin_X, realMax_X);
00505         
00506         float startP=(float)barrange->getStartShowPorcentage();
00507         float endP=(float)barrange->getEndShowPorcentage();
00508         m_plot->moveFunctions(startP,endP);
00509         
00510         color_bar -> RefreshForce();
00511         m_plot -> UpdateAll();
00512 
00513         sendTMessage(text);
00514 }
00515 
00516 /*
00517         * Method for sending a text message to the container window
00518         * @param theText Is the text of the message
00519         */
00520 void pPlotter :: sendTMessage(wxString theText)
00521 {
00522         //Creating a message event 
00523         wxCommandEvent puntualMSG_Event( wxEVT_NW_TEXT_MESAGGE, GetId() );
00524         puntualMSG_Event.SetEventObject(this);
00525         //Sending the event
00526         GetEventHandler()->ProcessEvent( puntualMSG_Event );
00527 }
00528 
00529 /*
00530         * Sets the text message
00531         * @param nMessage Is the text message to set
00532         */
00533         void pPlotter :: setTextMessage(wxString nMessage)
00534         {
00535                 text = nMessage;
00536         }
00537 
00538         /*
00539         * Gets the text message
00540         * @param text Is the actual text message 
00541         */
00542         wxString pPlotter :: getTextMessage()
00543         {
00544                 return text;
00545         }
00550         int pPlotter:: addFunction(pGraphicalFunction * function)
00551         {
00552                 return m_plot->addFunction(function);  
00553         }
00557         pGraphicalFunction* pPlotter::getFunctionForVectors( double* vectorX, int sizeX,double * vectorY, int sizeY )
00558         {
00559                 return m_plot->getFunctionForVectors(vectorX,sizeX, vectorY, sizeY );
00560         }
00561                 /*
00562          Set Type
00563         */
00564         void pPlotter::setType(int t)
00565         {
00566                 m_plot->setType(t);
00567         }
00568         /*
00569          Get a function in the plotter given the index
00570         */
00571         pGraphicalFunction* pPlotter:: getFunction(int index)
00572         {
00573                 return m_plot->getFunction(index);
00574         }
00575         /*
00576          Adds  function to move with the bar min max
00577         */
00578         int pPlotter::addFunctionToMove(pGraphicalFunction * function)
00579         {
00580                 return m_plot->addFunctionToMove(function);
00581         }
00582         
00583         /*
00584           move the functions that the user wants to move
00585           and that were setted in functionsToMove
00586           @param porcentageMinX:the porcentage that the minShowed
00587           of the funcntions have to be move
00588           @param porcentageMaxX:the porcentage that the maxShowed
00589           of the funcntions have to be move
00590 
00591         */
00592         void pPlotter:: moveFunctions(float porcentageMinX,float porcentageMaxX)
00593         {
00594                 m_plot->moveFunctions(porcentageMinX,porcentageMaxX);
00595         }
00596         /*
00597         * deletes the function from the plotter
00598         */
00599         /*
00600         bool pPlotter::deleteFunction(pGraphicalFunction * function);
00601                 {
00602                         return m_plot->deleteFunction(function);
00603 
00604                 }
00605 
00606         */
00607         //--------------------
00608         // Color information
00609         //---------------------
00613         int pPlotter::getColorPointsSize()
00614         {
00615                 return color_bar->getColorPointsSize();
00616         }
00617         /*
00618          Get the RGB values of the color point that is in the
00619          index given
00620         */
00621         void pPlotter::getBarColorDataAt(int index,double& x, int& red,int& green,int& blue)
00622         {
00623                 color_bar->getDataAt(index,x,red,green,blue);
00624         }
00625         /*
00626          add a color Point 
00627          returns true if the point was succesfully added
00628          PRE: 0<=red<=255 0<=green<=255 0<=blue<=255
00629         */
00630         bool pPlotter::addColorPoint(int x,int red,int green, int blue)
00631         {
00632                 wxColour color= wxColour(red,green,blue);
00633                 return color_bar->addColorPoint((double)x, color);
00634         }
00635         void pPlotter::eraseColorPoints()
00636         {
00637                 int min=(int)color_bar->getMinValue();
00638                 int max=(int)color_bar->getMaxValue();
00639                 color_bar->reinitiateColorBar(min,max);
00640         }
00641 
00642         //--------------------
00643         // bar Information
00644         //---------------------
00645         float pPlotter::getMaxShowedPorcentage()
00646         {
00647                 return barrange->getEndShowPorcentage();
00648         }
00649         float pPlotter::getMinShowedPorcentage()
00650         {
00651                 return barrange->getStartShowPorcentage();
00652         }
00653         float pPlotter::getActualShowedPorcentage()
00654         {
00655                 return barrange->getActualShowPorcentage();
00656         }
00657         
00658         //--------------------
00659         // plotter Information
00660         //---------------------
00661         void pPlotter::setActual(pGraphicalFunction* nActual)
00662         {
00663                 m_plot->setActualFunction(nActual);
00664         }
00665         void pPlotter::update()
00666         {
00667                 //if it is a plotter of histograms
00668                 if(m_plot->getType()==2)
00669                 {
00670                         pGraphicalFunction* tf= m_plot->getActualFunction();
00671                         if(tf->getType()==2)
00672                         {
00673                                 tf->clearSplineVectors();
00674                                 tf->addSplinesPoints();
00675                                 tf->initializeSplineVectors();
00676                         }
00677                 }
00678 
00679                 m_plot->UpdateAll();
00680         }
00681         //----------------------------
00682         //Handling Options Menu
00683         //----------------------------
00684         
00685         void pPlotter::setPopUpMenu(bool startD,bool stopD,bool smooth,bool line, bool zoomIn,
00686                                           bool zoomOut,bool showPoints,bool noShowPoints,bool changeColor, bool addP,
00687                                           bool delPoint,bool load,bool save)
00688         {
00689                 m_plot->setPopUpMenu(startD, stopD, smooth, line,  zoomIn,
00690                                            zoomOut, showPoints, noShowPoints, changeColor,  addP,
00691                                            delPoint, load, save);
00692         }
00693 
00694 
00695         /*
00696                 if the user resize the window   
00697         */
00698         
00699         
00700         
00701         /*
00702         void pPlotter::OnSize( wxSizeEvent &WXUNUSED(event) )
00703         {
00704                 int scrX,scrY;
00705                 GetClientSize(&scrX,&scrY);
00706                 m_plot->SetSize(scrX,scrY);
00707                 
00708                 
00709                 pGraphicalFunction* actual=m_plot->getActualFunction();
00710                 if(actual!=NULL)
00711                 {               
00712                         actual->setScreens(scrX,scrY);
00713                         actual->setScales();
00714                 }
00715                 
00716                 
00717         }
00718         */
00719         
00720 
00724 void pPlotter::GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& value, int histogramsize)
00725 {
00726         if(actualFunction != NULL){
00727                 double* xval = actualFunction->getX_RealValues();
00728                 double* yval = actualFunction->getY_RealValues();
00729 
00730                 actualFunction->getScaleY();
00731                 for(int i = 0; i < actualFunction->getSizePoints();i++){
00732                         greylevel.push_back(xval[i]);
00733                         value.push_back(yval[i]/histogramsize);
00734                 }
00735         }
00736 }
00737 
00742 void pPlotter::GetValuesColorPointsFunction(std::vector<double>& greylevel,
00743                                                                 std::vector<double>& red,
00744                                                                 std::vector<double>& green,
00745                                                                 std::vector<double>& blue)
00746 {
00747 
00748         if(color_bar != NULL){
00749 
00750                 std::vector<pColorPoint*> colors;
00751         color_bar->getAddedColorsPointsList(colors);
00752 
00753                 for(int i = 0; i < colors.size();i++){
00754                         pColorPoint* pcolor = colors[i];
00755 
00756                         greylevel.push_back(pcolor->getRealX());
00757                         wxColour colour = pcolor->getColor();
00758                         
00759                         double _red = (double)(colour.Red())/255.0;
00760                         double _green = (double)(colour.Green())/255.0;
00761                         double _blue = (double)(colour.Blue())/255.0;
00762 
00763                         red.push_back(_red);
00764                         green.push_back(_green);
00765                         blue.push_back(_blue);
00766                 }               
00767         }
00768 }
00769 
00770 
00771 
00772 

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1