1 //----------------------------------------------------------------------------
2 // Class definition include
3 //----------------------------------------------------------------------------
4 #include "pPlotterWindow.h"
5 #include "MaximumsDialog.h"
10 // ----------------------------------------------------------------------------
11 // WX headers inclusion.
12 // For compilers that support precompilation, includes <wx/wx.h>.
13 // ----------------------------------------------------------------------------
19 #include "wx/colordlg.h"
20 //----------------------------------------------------------------------------
21 //DECLARING THE NEW EVENT
22 //wxEVT_TSBAR= event of the two side bar
23 //----------------------------------------------------------------------------
24 BEGIN_DECLARE_EVENT_TYPES()
25 DECLARE_EVENT_TYPE(wxEVT_PPLOTTER, -1)
26 DECLARE_EVENT_TYPE(wxEVT_PPLOTTER_CHANGED_FUNCTION, -1)
27 DECLARE_EVENT_TYPE(wxEVT_PPLOTTER_POINT_MOVE, -1)
28 DECLARE_EVENT_TYPE(wxEVT_PPLOTTER_POINT_ADD, -1)
29 DECLARE_EVENT_TYPE(wxEVT_PPLOTTER_POINT_DELETE, -1)
30 DECLARE_EVENT_TYPE(wxEVT_PPLOTTER_GUIDELINES, -1)
31 END_DECLARE_EVENT_TYPES()
34 DEFINE_EVENT_TYPE(wxEVT_PPLOTTER)
35 DEFINE_EVENT_TYPE(wxEVT_PPLOTTER_CHANGED_FUNCTION)
36 DEFINE_EVENT_TYPE(wxEVT_PPLOTTER_POINT_MOVE)
37 DEFINE_EVENT_TYPE(wxEVT_PPLOTTER_POINT_ADD)
38 DEFINE_EVENT_TYPE(wxEVT_PPLOTTER_POINT_DELETE)
39 DEFINE_EVENT_TYPE(wxEVT_PPLOTTER_GUIDELINES)
42 //----------------------------------------------------------------------------
43 // Class implementation
44 //----------------------------------------------------------------------------
46 IMPLEMENT_CLASS(pPlotterWindow, mpWindow)
48 //----------------------------------------------------------------------------
50 //----------------------------------------------------------------------------
52 BEGIN_EVENT_TABLE(pPlotterWindow,mpWindow)
53 EVT_MOTION (pPlotterWindow::onMouseMove)
54 EVT_LEFT_DCLICK(pPlotterWindow::onChangeActual)
55 EVT_LEFT_DOWN(pPlotterWindow::onAddPoint)
56 EVT_MENU(pwID_DELPOINT, pPlotterWindow::onDeletePoint)
57 EVT_MENU(pwID_SHOWPOINTS, pPlotterWindow::onShowPoints)
58 EVT_MENU(pwID_STARTDRAWING, pPlotterWindow::onStartDrawing)
59 //EVT_MENU(pwID_DELFUNCTION,pPlotterWindow::onDeleteFunction)
60 EVT_MENU(pwID_STOPDRAWING, pPlotterWindow::onStopDrawing)
61 EVT_MENU(pwID_ADDNEWPOINT, pPlotterWindow::onAddNewPoint)
62 EVT_MENU(pwID_NOSHOWPOINTS, pPlotterWindow::onNoShowPoints)
63 EVT_MENU(pwID_MYZOOMOUT,pPlotterWindow::onMyZoomOut)
64 EVT_MENU(pwID_MYZOOMIN,pPlotterWindow::onMyZoomIn)
65 EVT_MENU(pwID_SPLINE,pPlotterWindow::onSplinePoints)
66 EVT_MENU(pwID_LINE,pPlotterWindow::onLine)
67 EVT_MENU(pwID_SAVE,pPlotterWindow::onSave)
68 EVT_MENU(pwID_LOAD,pPlotterWindow::onLoad)
69 EVT_MENU(pwID_CHANGECOLOR,pPlotterWindow::onChangeColor)
70 EVT_MENU( mpID_LINE_GUIDES, pPlotterWindow::OnGuideLines)
71 EVT_MENU( pwID_TRASLATEACTUALFUNCTION, pPlotterWindow::onMoveFunction)
72 EVT_LEFT_UP(pPlotterWindow::onLeftUp)
75 //----------------------------------------------------------------------------
77 //----------------------------------------------------------------------------
79 pPlotterWindow::pPlotterWindow( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int flag )
80 : mpWindow( parent, id, pos, size, flag)
85 scaleWay=DEFAULT_SCALE;
87 //drawGuideLines=true;
91 initialMovingCLick=-1;
97 m_popmenu.Remove( mpID_ZOOM_IN);
98 m_popmenu.Remove( mpID_ZOOM_OUT);
99 m_popmenu.Remove( mpID_CENTER);
100 m_popmenu.Remove( mpID_FIT);
101 m_popmenu.Remove( mpID_LOCKASPECT);
103 m_popmenu.Append(pwID_STARTDRAWING , _("Start Drawing"), _("Starts to draw a new function"));//it changes the actual function
104 m_popmenu.Append(pwID_STOPDRAWING , _("Stop drawing"), _("Stops of drawing the new function"));
105 m_popmenu.Append(pwID_LOAD, _("Load"), _("Load the actual function from a plane file"));
106 m_popmenu.Append(pwID_SHOWPOINTS , _("Show Points"), _("shows the discrete points of the function"));
107 m_popmenu.Append(pwID_NOSHOWPOINTS, _("No show Points"), _("Dont show the points of the function"));
108 m_popmenu.Append(pwID_ADDNEWPOINT, _("Add point"), _("Add New point to the actual function"));
109 m_popmenu.Append(pwID_DELPOINT , _("Delete point"), _("Deletes a point from the actual function."));
110 m_popmenu.Append(pwID_MYZOOMIN, _("Zoom in"), _("Zoom in the points of the function"));
111 m_popmenu.Append(pwID_MYZOOMOUT, _("Zoom out"), _("Zoom out the points of the function"));
112 m_popmenu.Append(pwID_SPLINE, _("Smooth"), _("Splines the points ofthe actual curve"));
113 m_popmenu.Append(pwID_LINE, _("Line"), _("Piecewise the points ofthe actual curve"));
114 m_popmenu.Append(pwID_SAVE, _("Save"), _("Save the actual function in plane file"));
115 m_popmenu.Append(pwID_CHANGECOLOR, _("Change Color"), _("Change the color of the function"));
116 m_popmenu.Append(pwID_TRASLATEACTUALFUNCTION, _("Start Moving Function"), _("Move the actual Function"));
118 m_popmenu.Enable(pwID_NOSHOWPOINTS,false);
119 m_popmenu.Enable(pwID_ADDNEWPOINT,false);
120 m_popmenu.Enable(pwID_SHOWPOINTS,false);
121 m_popmenu.Enable(pwID_DELPOINT,false);
122 m_popmenu.Enable(pwID_STOPDRAWING,false);
123 m_popmenu.Enable(pwID_MYZOOMIN,false);
124 m_popmenu.Enable(pwID_MYZOOMOUT,false);
125 m_popmenu.Enable(pwID_SPLINE,false);
126 m_popmenu.Enable(pwID_LINE,false);
127 m_popmenu.Enable(pwID_SAVE,false);
128 m_popmenu.Enable(pwID_LOAD,true);
129 m_popmenu.Enable(pwID_CHANGECOLOR,false);
130 m_popmenu.Enable(pwID_STARTDRAWING,true);
131 m_popmenu.Enable(pwID_LOAD,true);
132 //m_popmenu.Enable(pwID_STARTDRAWING,false);
133 m_popmenu.Enable(mpID_LINE_GUIDES,false);
134 m_popmenu.Enable(pwID_TRASLATEACTUALFUNCTION,false);
140 pPlotterWindow::~pPlotterWindow()
143 //----------------------------------------------------------------------------
145 //----------------------------------------------------------------------------
148 * Sets the actual function
150 void pPlotterWindow::setActualFunction(pGraphicalFunction* newActual)
153 actual->setActual(false);
154 newActual->setActual(true);
159 * Gets the actual function
161 pGraphicalFunction* pPlotterWindow:: getActualFunction()
167 * Transform the point clicked from window
168 * to the real value,given by the scale
169 * Pre: m_scaleX and m_scaleY are already actualized
170 * with setActualScales() method
172 wxPoint pPlotterWindow:: getRealPoint(wxPoint pixelPoint)
177 //real point on the function
179 int xS=(x-offsetPixelX)/m_scaleX + offsetX + minScrX;
180 int yS=(y-offsetPixelY)/m_scaleY + offsetY + minScrY;
182 if(xS<=maxScrX && yS<=maxScrY )
196 Set the scales according to the size of the window
197 and the maximum given by the user
200 void pPlotterWindow::setActualScales()
202 // int maxX,maxY,minX,minY; // JPRx
203 int maxX,maxY;//,minX,minY; // JPRx //EED
205 if the function is drawed interactively the maxX and the
206 maxY in actual are sets by the user
209 maxX=actual->getMaxX();
210 maxY=actual->getMaxY();
216 int dx=actual->getMaxXShowed()-actual->getMinXShowed();
217 int dy=actual->getMaxYShowed()-actual->getMinYShowed();
221 m_scaleX= (((float)m_scrX-100)/dx)*zoomFactor;
222 m_scaleY= (((float)m_scrY-50)/dy)*zoomFactor;
224 //setting the maximums and minimums showed in the window
229 setMaxScrX(actual->getMaxXShowed());
230 setMinScrX(actual->getMinXShowed());
231 setMaxScrY(actual->getMaxYShowed());
232 setMinScrY(actual->getMinYShowed());
233 actual->setScreens(m_scrX,m_scrY);
236 //-------------------------
237 // Methods for interaction
238 //-------------------------
240 //------------------------------------
241 // Manipulating clicks on the plotter
242 //-------------------------------------
246 Manipulating clicks on the plotter
248 void pPlotterWindow::onLeftUp(wxMouseEvent& event)
256 //-------------------------------
257 //Traslating the actual function
258 //-------------------------------
260 Move the actual function when the user
263 void pPlotterWindow::onMoveFunction(wxCommandEvent& aEvent)
267 movingFunction=false;
268 m_popmenu.SetLabel(pwID_TRASLATEACTUALFUNCTION, _("Start Moving Function"));
273 m_popmenu.SetLabel(pwID_TRASLATEACTUALFUNCTION, _("Stop Moving Function"));
277 //-----------------------
279 //-----------------------
283 * Change the color of the function
285 void pPlotterWindow::onChangeColor(wxCommandEvent& aEvent)
290 wxColourDialog dialog(this, &data);
292 if ( dialog.ShowModal() == wxID_OK )
294 colour = dialog.GetColourData().GetColour();
299 actual->SetPen( mypen);
304 //----------------------
306 //----------------------
310 * Load the function from a .txt file
312 void pPlotterWindow::onLoad(wxCommandEvent& aEvent)
315 actual=new pGraphicalFunction(wxT("f(x) = function1(x)"),mpALIGN_NE);
316 actual->setActual(true);
317 actual->setFromWindow(false);
318 actual->SetDrawing(drawing);
319 actual->setFactorZoom(zoomFactor);
321 wxPen mypen(*wxRED, 5, wxSOLID);
323 actual->SetPen( mypen);
325 wxString nameF=wxFileSelector(_T("Save Function"));
329 functions.Append(actual);
330 addFunctionToMove(actual);
332 m_popmenu.Enable(pwID_STARTDRAWING,true);
336 //------------------------------------------
337 //Sending the paarticular event of changed actual function
338 //-------------------------------------------
339 wxCommandEvent cevent( wxEVT_PPLOTTER_CHANGED_FUNCTION, GetId() );
340 cevent.SetEventObject(this);
341 GetEventHandler()->ProcessEvent( cevent );
346 * Save the points of the function in a .txt file
348 void pPlotterWindow::onSave(wxCommandEvent& aEvent)
350 wxString nameF=wxFileSelector(_T("Save Function"));
354 //-----------------------
356 //----------------------
358 * Spline the points of the actual curve
361 void pPlotterWindow::onSplinePoints(wxCommandEvent& aEvent)
364 actual->initializeSplines();
365 actual->initializeSplineVectors();
367 m_popmenu.Enable(pwID_SPLINE,false);
368 m_popmenu.Enable(pwID_LINE,true);
372 * Change the type of drawing of the actual function
373 * to a piecewise function
375 void pPlotterWindow::onLine(wxCommandEvent& aEvent)
377 actual->clearSplineVectors();
380 m_popmenu.Enable(pwID_SPLINE,true);
381 m_popmenu.Enable(pwID_LINE,false);
385 //--------------------------
387 //---------------------------
390 * Zoom out the functions
392 void pPlotterWindow::onMyZoomOut(wxCommandEvent& aEvent)
394 wxNode* node=functions.GetFirst();
395 zoomFactor=zoomFactor*(float)(1/(float)ZOOM_FACTOR);
398 pGraphicalFunction* f= (pGraphicalFunction*)node->GetData();
400 f->setScreenX(m_scrX);
401 f->setScreenY(m_scrY);
406 f->setOffsets(m_clickedX-70,m_scrY-m_clickedY-40);
407 f->setFactorZoom(zoomFactor);
412 f->setOffsetPixelX(0);
413 f->setOffsetPixelY(0);
416 f->setFactorZoom(zoomFactor);
422 //TODO: send a event of resize
423 //setMinScrX(f->getMinXShowed());
424 //setMinScrY(f->getMinYShowed());
425 setOffsetPixelX(f->getOffsetPixelsX());
426 setOffsetPixelY(f->getOffsetPixelsY());
427 setOffsetX(f->getOffsetX());
428 setOffsetY(f->getOffsetY());
430 node=node->GetNext();
435 * Zoom in the functions
437 void pPlotterWindow::onMyZoomIn(wxCommandEvent& aEvent)
440 zoomFactor=zoomFactor*(float)ZOOM_FACTOR;
441 wxNode* node=functions.GetFirst();
444 pGraphicalFunction* f= (pGraphicalFunction*)node->GetData();
445 if(zoomFactor > 1.01)
447 f->setScreenX(m_scrX);
448 f->setScreenY(m_scrY);
449 f->setOffsets(m_clickedX-70,m_scrY-m_clickedY-40);
450 f->setFactorZoom(zoomFactor);
454 f->setOffsetPixelX(0);
455 f->setOffsetPixelY(0);
458 f->setFactorZoom(zoomFactor);
462 //TODO: send an event of resize
463 //setMinScrX(f->getMinXShowed());
464 //setMinScrY(f->getMinYShowed());
465 setOffsetPixelX(f->getOffsetPixelsX());
466 setOffsetPixelY(f->getOffsetPixelsY());
467 setOffsetX(f->getOffsetX());
468 setOffsetY(f->getOffsetY());
472 node=node->GetNext();
479 //-------------------------
481 //-------------------------
485 * Let to the user to start drawing
487 void pPlotterWindow::onStartDrawing(wxCommandEvent& aEvent)
492 actual->setActual(false);
493 if(actual->getShowPoints())
494 actual->SetShowPoints(false);
496 m_popmenu.Enable(pwID_NOSHOWPOINTS,false);
497 m_popmenu.Enable(pwID_ADDNEWPOINT,false);
498 m_popmenu.Enable(pwID_SHOWPOINTS,false);
499 m_popmenu.Enable(pwID_DELPOINT,false);
500 m_popmenu.Enable(pwID_MYZOOMIN,false);
501 m_popmenu.Enable(pwID_MYZOOMOUT,false);
502 m_popmenu.Enable(pwID_STARTDRAWING,false);
503 m_popmenu.Enable(pwID_SPLINE,false);
504 m_popmenu.Enable(pwID_LINE,false);
505 m_popmenu.Enable(pwID_STOPDRAWING,true);
506 m_popmenu.Enable(pwID_SAVE,false);
507 m_popmenu.Enable(pwID_LOAD,false);
508 m_popmenu.Enable(pwID_CHANGECOLOR,false);
509 m_popmenu.Enable(pwID_TRASLATEACTUALFUNCTION,false);
516 actual=new pGraphicalFunction(wxT("f(x) = function1(x)"),mpALIGN_NE);
517 actual->setActual(true);
518 actual->setFromWindow(true);
519 actual->setScaleWay(USER_SCALE);
520 actual->SetDrawing(drawing);
521 actual->setFactorZoom(zoomFactor);
523 //we change the offsets
524 setOffsetPixelX(actual->getOffsetPixelsX());
525 setOffsetPixelY(actual->getOffsetPixelsY());
526 setOffsetX(actual->getOffsetX());
527 setOffsetY(actual->getOffsetY());
530 wxPen mypen(*wxRED, 5, wxSOLID);
532 actual->SetPen( mypen);
535 int result = wxMessageBox("Do you Want a Smooth Curve?", "Spline Points", wxYES_NO | wxCANCEL);
542 /**************************************************************************/
544 /**************************************************************************/
546 //opening the dialog of maximums
548 MaximumsDialog *dlg=new MaximumsDialog(this,_T("Set Maximums"));
550 if(dlg->ShowModal()== wxID_OK )
552 maxX=dlg->getXValue();
553 maxY=dlg->getYValue();
554 if(maxX>0 && maxY>0 && actual->getFromWindow())
559 actual->setMaxX(maxScrX);
560 actual->setMinX(minScrX);
561 actual->setMaxY(maxY);
564 actual->setMinShowedX(0);
565 actual->setMinShowedY(0);
566 actual->setMaxShowedX(maxX);
567 actual->setMaxShowedY(maxY);
571 else if(maxX<0 || maxY<0)
573 wxMessageBox(_T("Both numbers have to be positive, please enter valid numbers"), _T("Error"),
579 m_popmenu.Enable(pwID_NOSHOWPOINTS,false);
580 m_popmenu.Enable(pwID_ADDNEWPOINT,false);
581 m_popmenu.Enable(pwID_SHOWPOINTS,false);
582 m_popmenu.Enable(pwID_DELPOINT,false);
583 m_popmenu.Enable(pwID_MYZOOMIN,false);
584 m_popmenu.Enable(pwID_MYZOOMOUT,false);
585 m_popmenu.Enable(pwID_STARTDRAWING,true);
586 m_popmenu.Enable(pwID_SPLINE,false);
587 m_popmenu.Enable(pwID_LINE,false);
588 m_popmenu.Enable(pwID_STOPDRAWING,false);
589 m_popmenu.Enable(pwID_SAVE,false);
590 m_popmenu.Enable(pwID_LOAD,true);
591 m_popmenu.Enable(pwID_CHANGECOLOR,false);
592 m_popmenu.Enable(pwID_TRASLATEACTUALFUNCTION,false);
594 //actual->SetDrawing(false);
598 else if(maxX==0 && maxY==0)
600 actual->setMaxX(100);
602 actual->setMaxY(100);
605 actual->setMinShowedX(0);
606 actual->setMinShowedY(0);
607 actual->setMaxShowedX(100);
608 actual->setMaxShowedY(100);
620 else if(dlg->ShowModal()== wxID_CANCEL)
625 m_popmenu.Enable(pwID_NOSHOWPOINTS,false);
626 m_popmenu.Enable(pwID_ADDNEWPOINT,false);
627 m_popmenu.Enable(pwID_SHOWPOINTS,false);
628 m_popmenu.Enable(pwID_DELPOINT,false);
629 m_popmenu.Enable(pwID_MYZOOMIN,false);
630 m_popmenu.Enable(pwID_MYZOOMOUT,false);
631 m_popmenu.Enable(pwID_STARTDRAWING,true);
632 m_popmenu.Enable(pwID_SPLINE,false);
633 m_popmenu.Enable(pwID_LINE,false);
634 m_popmenu.Enable(pwID_STOPDRAWING,false);
635 m_popmenu.Enable(pwID_SAVE,false);
636 m_popmenu.Enable(pwID_LOAD,true);
637 m_popmenu.Enable(pwID_CHANGECOLOR,false);
638 m_popmenu.Enable(pwID_TRASLATEACTUALFUNCTION,false);
640 //actual->SetDrawing(false);
646 //------------------------------------------
647 //Sending the paarticular event of changed actual function
648 //-------------------------------------------
649 wxCommandEvent cevent( wxEVT_PPLOTTER_CHANGED_FUNCTION, GetId() );
650 cevent.SetEventObject(this);
651 GetEventHandler()->ProcessEvent( cevent );
657 Stop the drawing of the actual function
659 void pPlotterWindow::onStopDrawing(wxCommandEvent& aEvent)
662 actual->SetDrawing(drawing);
663 functions.Append(actual);
664 addFunctionToMove(actual);
665 m_popmenu.Enable(pwID_ADDNEWPOINT,true);
666 m_popmenu.Enable(pwID_DELPOINT,true);
667 m_popmenu.Enable(pwID_SHOWPOINTS,true);
668 m_popmenu.Enable(pwID_MYZOOMIN,true);
669 m_popmenu.Enable(pwID_MYZOOMOUT,true);
670 m_popmenu.Enable(pwID_STARTDRAWING,true);
671 m_popmenu.Enable(pwID_SPLINE,true);
672 m_popmenu.Enable(pwID_STOPDRAWING,false);
673 m_popmenu.Enable(pwID_LINE,false);
674 m_popmenu.Enable(pwID_CHANGECOLOR,true);
675 m_popmenu.Enable(pwID_TRASLATEACTUALFUNCTION,true);
677 if(actual->getSizePoints()==0||actual->getSizePoints()==1)
680 m_popmenu.Enable(pwID_ADDNEWPOINT,false);
681 //functions.DeleteObject(actual);
690 * The user wants to see the points(given) of the function
692 void pPlotterWindow::onShowPoints(wxCommandEvent& aEvent)
694 actual->SetShowPoints(true);
695 m_popmenu.Enable(pwID_NOSHOWPOINTS,true);
696 m_popmenu.Enable(pwID_SHOWPOINTS,false);
700 * The user doesnt want see the points of the function
702 void pPlotterWindow::onNoShowPoints(wxCommandEvent& aEvent)
704 actual->SetShowPoints(false);
705 m_popmenu.Enable(pwID_NOSHOWPOINTS,false);
706 m_popmenu.Enable(pwID_SHOWPOINTS,true);
710 * if the user is going to add a point to the function
712 void pPlotterWindow::onAddPoint(wxMouseEvent& aEvent)
715 wxPoint point=aEvent.GetPosition();
717 point.y=m_scrY-point.y;
718 wxPoint realPoint=getRealPoint(point);
720 bool isAValidPoint=realPoint.x>=0 && realPoint.y>=0;
722 if(isAValidPoint && drawing)
724 if(actual->AddPoint(realPoint.x,realPoint.y))
726 text = wxString::Format(_T("added point ( %d, %d)\n"), realPoint.x, realPoint.y);
728 //m_log->AppendText(text);
730 //if the function is smooth
731 if(actual->getType()==2)
733 actual->clearSplineVectors();
734 actual->addSplinesPoints();
735 actual->initializeSplineVectors();
741 else if(isAValidPoint && !drawing && aEvent.m_shiftDown && actual!=NULL)
743 if(actual->AddNewPoint(realPoint.x,realPoint.y))
745 text = wxString::Format(_T("added point ( %d, %d)\n"), realPoint.x, realPoint.y);
746 //if the function is smooth
747 if(actual->getType()==2)
749 actual->clearSplineVectors();
750 actual->addSplinesPoints();
751 actual->initializeSplineVectors();
757 //made a click for moving the points
758 else if(!movingPoints)
761 movingPointIndex=actual->validPointOnFunction(realPoint);
762 if(movingPointIndex>=0)
766 //------------------------------------------
768 //-------------------------------------------
769 wxCommandEvent cevent( wxEVT_PPLOTTER_POINT_ADD, GetId() );
770 cevent.SetEventObject(this);
772 //------------------------------------------
773 //Sending the general event
774 //-------------------------------------------
775 wxCommandEvent pevent( wxEVT_PPLOTTER, GetId() );
776 pevent.SetEventObject(this);
778 GetEventHandler()->ProcessEvent( cevent );
779 GetEventHandler()->ProcessEvent( pevent );
783 * Adds a point to the function after the definition of the initial points of the function
784 * know this point is a point of the function
787 void pPlotterWindow::onAddNewPoint(wxCommandEvent& aEvent)
791 point.y=m_scrY-m_clickedY;
793 wxPoint realPoint=getRealPoint(point);
794 bool isAValidPoint=realPoint.x>=0 && realPoint.y>=0;
797 if(isAValidPoint && actual->AddNewPoint(realPoint.x,realPoint.y))
799 text = wxString::Format(_T("added point ( %d, %d)\n"), realPoint.x, realPoint.y);
800 //if the function is smooth
801 if(actual->getType()==2)
803 actual->clearSplineVectors();
804 actual->addSplinesPoints();
805 actual->initializeSplineVectors();
809 //------------------------------------------
811 //-------------------------------------------
812 wxCommandEvent cevent( wxEVT_PPLOTTER_POINT_ADD, GetId() );
813 cevent.SetEventObject(this);
815 //------------------------------------------
816 //Sending the general event
817 //-------------------------------------------
818 wxCommandEvent pevent( wxEVT_PPLOTTER, GetId() );
819 pevent.SetEventObject(this);
821 GetEventHandler()->ProcessEvent( cevent );
822 GetEventHandler()->ProcessEvent( pevent );
828 * if the user is going to delete a point of the function
830 void pPlotterWindow::onDeletePoint(wxCommandEvent& aEvent)
834 point.y=m_scrY-m_clickedY;
836 //actual->setScreenX(m_scrX);
837 //actual->setScreenY(m_scrY);
839 wxPoint realPoint=getRealPoint(point);
841 bool isAValidPoint=realPoint.x>=0 && realPoint.y>=0;
843 //this method verify a sensible region in every point of actual
844 int pointIndex=actual->validPointOnFunction(realPoint);
845 if(isAValidPoint && actual->deletePointAt(pointIndex))
848 if(actual->getSizePoints()==0)
850 //functions.DeleteObject(actual);
854 //if the function is smooth
855 if(actual->getType()==2)
857 actual->clearSplineVectors();
858 actual->addSplinesPoints();
859 actual->initializeSplineVectors();
862 text = wxString::Format(_T("deleted point ( %d, %d)\n"), realPoint.x, realPoint.y);
864 //------------------------------------------
866 //-------------------------------------------
867 wxCommandEvent cevent( wxEVT_PPLOTTER_POINT_DELETE, GetId() );
868 cevent.SetEventObject(this);
869 //------------------------------------------
870 //Sending the general event
871 //-------------------------------------------
872 wxCommandEvent pevent( wxEVT_PPLOTTER, GetId() );
873 pevent.SetEventObject(this);
875 GetEventHandler()->ProcessEvent( cevent );
876 GetEventHandler()->ProcessEvent( pevent );
882 * If the mouse is moving in the plot area
883 * is because the user is moving a point of the current curve
884 * the user has to call before show points, to see the points of the
888 void pPlotterWindow::onMouseMove(wxMouseEvent& event)
890 wxPoint point=event.GetPosition();
892 point.y=m_scrY-point.y;
894 wxPoint realPoint=getRealPoint(point);
895 bool isAValidPoint=realPoint.x>=0 && realPoint.y>=0;
897 if(isAValidPoint && !drawing && actual!=NULL && !movingFunction && movingPoints)
899 //never is going to get in
900 if(movingPointIndex==-1)
902 //this method verify a sensible region in every point of _actualFunction
903 movingPointIndex=actual->validPointOnFunction(realPoint);
906 else if(event.LeftIsDown())
909 /*if((movingPointIndex-1)>=0 && (movingPointIndex+1)<actual->getSizePoints() && actual->getEditable())
911 wxNode* next= actual->GetPointAt(movingPointIndex+1);
912 wxNode* before=actual->GetPointAt(movingPointIndex-1);
915 pFunctionPoint* np=(pFunctionPoint*)(next->GetData());
918 int n=np->getRealX();
922 p.x=np->getRealX()-1;
924 change=actual->changePoint(p,movingPointIndex);
929 //if the function is smooth
930 if(actual->getType()==2)
932 actual->clearSplineVectors();
933 actual->addSplinesPoints();
934 actual->initializeSplineVectors();
938 text = wxString::Format(_T("Moved point ( %d, %d)\n"), p.x, p.y);
940 //------------------------------------------
941 //Sending the particular event
942 //-------------------------------------------
943 wxCommandEvent cevent( wxEVT_PPLOTTER_POINT_MOVE, GetId() );
944 cevent.SetEventObject(this);
946 //------------------------------------------
947 //Sending the general event
948 //-------------------------------------------
949 wxCommandEvent pevent( wxEVT_PPLOTTER, GetId() );
950 pevent.SetEventObject(this);
953 GetEventHandler()->ProcessEvent( cevent );
954 GetEventHandler()->ProcessEvent( pevent );
961 pFunctionPoint* bp=(pFunctionPoint*)(before->GetData());
964 int b=bp->getRealX();
968 p.x=bp->getRealX()+1;
970 change=actual->changePoint(p,movingPointIndex);
974 //if the function is smooth
975 if(actual->getType()==2)
977 actual->clearSplineVectors();
978 actual->addSplinesPoints();
979 actual->initializeSplineVectors();
982 text = wxString::Format(_T("Moved point ( %d, %d)\n"), p.x, p.y);
984 //------------------------------------------
985 //Sending the particular event
986 //-------------------------------------------
987 wxCommandEvent cevent( wxEVT_PPLOTTER_POINT_MOVE, GetId() );
988 cevent.SetEventObject(this);
990 //------------------------------------------
991 //Sending the general event
992 //-------------------------------------------
993 wxCommandEvent pevent( wxEVT_PPLOTTER, GetId() );
994 pevent.SetEventObject(this);
997 GetEventHandler()->ProcessEvent( cevent );
998 GetEventHandler()->ProcessEvent( pevent );
1005 // SIL ******************************************************************* // SIL
1006 if((movingPointIndex-1)>=0 && (movingPointIndex+1)<actual->getSizePoints() && actual->getEditable())
1008 change=actual->changePoint(realPoint,movingPointIndex);
1013 //if the function is smooth
1014 if(actual->getType()==2)
1016 actual->clearSplineVectors();
1017 actual->addSplinesPoints();
1018 actual->initializeSplineVectors();
1020 text = wxString::Format(_T("Moved point ( %d, %d)\n"), realPoint.x, realPoint.y);
1022 //------------------------------------------
1023 //Sending the particular event
1024 //-------------------------------------------
1025 wxCommandEvent cevent( wxEVT_PPLOTTER_POINT_MOVE, GetId() );
1026 cevent.SetEventObject(this);
1028 //------------------------------------------
1029 //Sending the general event
1030 //-------------------------------------------
1031 wxCommandEvent pevent( wxEVT_PPLOTTER, GetId() );
1032 pevent.SetEventObject(this);
1035 GetEventHandler()->ProcessEvent( cevent );
1036 GetEventHandler()->ProcessEvent( pevent );
1038 // SIL ******************************************************************* // SIL
1040 //change the point that is in the index, returns true if could be changed.
1041 if(!change && actual->changePoint(realPoint,movingPointIndex)&& actual->getEditable())
1044 //if the function is smooth
1045 if(actual->getType()==2)
1047 actual->clearSplineVectors();
1048 actual->addSplinesPoints();
1049 actual->initializeSplineVectors();
1052 text = wxString::Format(_T("Moved point ( %d, %d)\n"), realPoint.x,realPoint.y);
1056 //------------------------------------------
1057 //Sending the particular event
1058 //-------------------------------------------
1059 wxCommandEvent cevent( wxEVT_PPLOTTER_POINT_MOVE, GetId() );
1060 cevent.SetEventObject(this);
1062 //------------------------------------------
1063 //Sending the general event
1064 //-------------------------------------------
1065 wxCommandEvent pevent( wxEVT_PPLOTTER, GetId() );
1066 pevent.SetEventObject(this);
1069 GetEventHandler()->ProcessEvent( cevent );
1070 GetEventHandler()->ProcessEvent( pevent );
1075 movingPointIndex=-1;
1079 //if the user is drawing
1080 else if(isAValidPoint && drawing)
1083 actual->SetMousePoint(realPoint);
1086 //is moving the function
1087 else if(isAValidPoint && movingFunction && actual!=NULL)
1089 actual->setScreenX(m_scrX);
1090 actual->setScreenY(m_scrY);
1092 if((initialMovingCLick==-1) && event.LeftIsDown() )
1094 if(actual->isInFunction(realPoint.x,realPoint.y))
1096 initialMovingCLick=event.GetPosition().x;
1097 int numPoints=actual->getSizePoints();
1099 backUpActualVector.clear();
1102 //if(i>0 && i< (numPoints-1))
1104 wxNode* pointNode=actual->GetPointAt(i);
1105 pFunctionPoint* point= (pFunctionPoint*)pointNode->GetData();
1106 backUpActualVector.push_back(point->getRealX());
1113 else if(event.LeftIsDown())
1115 wxPoint aux(initialMovingCLick,0);
1117 wxPoint p1r=getRealPoint(event.GetPosition());
1118 wxPoint p2r=getRealPoint(aux);
1120 double delta = p1r.x-p2r.x;
1121 int numPoints=actual->getSizePoints();
1128 if(i>0 && i<(numPoints-1))
1130 wxNode* pointNode=actual->GetPointAt(i);
1131 pFunctionPoint* point= (pFunctionPoint*)pointNode->GetData();
1132 int xNew=backUpActualVector[i]+delta;
1133 //it has to preserve the state of functin
1134 if(backUpActualVector[0]<xNew && backUpActualVector[numPoints-1]>xNew)
1135 point->setRealX(xNew);
1146 wxNode* pointNode=actual->GetPointAt(i);
1147 pFunctionPoint* point= (pFunctionPoint*)pointNode->GetData();
1148 int xNew=backUpActualVector[i]+delta;
1149 point->setRealX(xNew);
1154 if(actual->getType()==2)
1156 actual->clearSplineVectors();
1157 actual->addSplinesPoints();
1158 actual->initializeSplineVectors();
1166 initialMovingCLick=-1;
1172 * if the user give us a double click is because he wants to change
1173 * the actual function to the function that has that point
1175 void pPlotterWindow::onChangeActual(wxMouseEvent& event)
1177 wxString text = _T("\n points \n");
1182 //we have to call showpoints before changing the function
1183 wxPoint point=event.GetPosition();
1184 /*****************************/
1185 point.y=m_scrY-point.y;
1186 /*****************************/
1190 //real point on the function
1191 wxPoint realPoint;//=getRealPoint(point);
1192 bool isAValidPoint=realPoint.x>=0 && realPoint.y>=0;
1195 wxNode * node= functions.GetFirst();
1198 pGraphicalFunction* fnode=(pGraphicalFunction*)node->GetData();
1201 int maxX=fnode->getMaxXShowed();
1202 int maxY=fnode->getMaxYShowed();
1203 int minX=fnode->getMinXShowed();
1204 int minY=fnode->getMinYShowed();
1208 float sx=(((float)m_scrX-100)/(maxScrX-minScrX))*zoomFactor;
1209 float sy=(((float)m_scrY-50)/(maxScrY-minScrY))*zoomFactor;
1213 float sx=(((float)m_scrX-100)/(maxX-minX))*zoomFactor;
1214 float sy=(((float)m_scrY-50)/(maxY-minY))*zoomFactor;
1217 realPoint.x=((point.x-70-fnode->getOffsetPixelsX())/sx)+ fnode->getOffsetX()+ minX;
1218 realPoint.y=((point.y-40-fnode->getOffsetPixelsY())/sy)+ fnode->getOffsetY()+ minY;
1222 if(fnode->getActual())
1223 text = wxString::Format(_T("Selected point ( %d, %d)\n"), realPoint.x, realPoint.y);
1224 //m_log->AppendText(text);
1226 bool hasIt=fnode->isInFunction(realPoint.x,realPoint.y);
1228 if(fnode->getEditable())
1229 hasIt=fnode->isInFunction(realPoint.x,realPoint.y);
1237 setActualFunction(fnode);
1238 //we change the offsets
1239 setOffsetPixelX(fnode->getOffsetPixelsX());
1240 setOffsetPixelY(fnode->getOffsetPixelsY());
1241 setOffsetX(fnode->getOffsetX());
1242 setOffsetY(fnode->getOffsetY());
1246 if(!actual->getFromWindow() && actual->getEditable()||actual->getFromWindow() && actual->getEditable())
1248 m_popmenu.Enable(pwID_ADDNEWPOINT,true);
1249 m_popmenu.Enable(pwID_DELPOINT,true);
1250 if(actual->getShowPoints())
1252 m_popmenu.Enable(pwID_SHOWPOINTS,false);
1253 m_popmenu.Enable(pwID_NOSHOWPOINTS,true);
1257 m_popmenu.Enable(pwID_SHOWPOINTS,true);
1258 m_popmenu.Enable(pwID_NOSHOWPOINTS,false);
1260 m_popmenu.Enable(pwID_MYZOOMIN,true);
1261 m_popmenu.Enable(pwID_MYZOOMOUT,true);
1262 if(actual->getType()==2)//Smoothed function
1264 m_popmenu.Enable(pwID_SPLINE,false);
1265 m_popmenu.Enable(pwID_LINE,true);
1269 m_popmenu.Enable(pwID_SPLINE,true);
1270 m_popmenu.Enable(pwID_LINE,false);
1275 m_popmenu.Enable(pwID_LOAD,false);
1276 m_popmenu.Enable(pwID_STARTDRAWING,false);
1280 m_popmenu.Enable(pwID_LOAD,true);
1281 m_popmenu.Enable(pwID_STARTDRAWING,true);
1284 m_popmenu.Enable(pwID_SAVE,true);
1285 m_popmenu.Enable(pwID_LOAD,false);
1286 m_popmenu.Enable(pwID_STOPDRAWING,false);
1287 m_popmenu.Enable(pwID_CHANGECOLOR,true);
1288 m_popmenu.Enable(mpID_LINE_GUIDES,true);
1289 m_popmenu.Enable(pwID_TRASLATEACTUALFUNCTION,true);
1291 //for the functions that came from data and arent editables
1292 else if(!actual->getFromWindow() && !actual->getEditable()||actual->getFromWindow() && !actual->getEditable())
1294 if(actual->getShowPoints())
1296 m_popmenu.Enable(pwID_SHOWPOINTS,false);
1297 m_popmenu.Enable(pwID_NOSHOWPOINTS,true);
1301 m_popmenu.Enable(pwID_SHOWPOINTS,true);
1302 m_popmenu.Enable(pwID_NOSHOWPOINTS,false);
1304 if(actual->getType()==2)//Smoothed function
1306 m_popmenu.Enable(pwID_SPLINE,false);
1307 m_popmenu.Enable(pwID_LINE,true);
1311 m_popmenu.Enable(pwID_SPLINE,true);
1312 m_popmenu.Enable(pwID_LINE,false);
1317 m_popmenu.Enable(pwID_LOAD,false);
1318 m_popmenu.Enable(pwID_STARTDRAWING,false);
1320 m_popmenu.Enable(pwID_SAVE,false);
1321 m_popmenu.Enable(pwID_LOAD,false);
1322 m_popmenu.Enable(pwID_STOPDRAWING,false);
1323 m_popmenu.Enable(pwID_MYZOOMIN,true);
1324 m_popmenu.Enable(pwID_MYZOOMOUT,true);
1325 m_popmenu.Enable(pwID_CHANGECOLOR,true);
1326 m_popmenu.Enable(mpID_LINE_GUIDES,true);
1327 m_popmenu.Enable(pwID_SAVE,true);
1328 m_popmenu.Enable(pwID_TRASLATEACTUALFUNCTION,true);
1331 //if the function is smooth
1332 if(actual->getType()==2)
1334 actual->clearSplineVectors();
1335 actual->addSplinesPoints();
1336 actual->initializeSplineVectors();
1341 //------------------------------------------
1342 //Sending the particular event
1343 //-------------------------------------------
1344 wxCommandEvent cevent( wxEVT_PPLOTTER_CHANGED_FUNCTION, GetId() );
1345 cevent.SetEventObject(this);
1347 //------------------------------------------
1348 //Sending the general event
1349 //-------------------------------------------
1350 wxCommandEvent pevent( wxEVT_PPLOTTER, GetId() );
1351 pevent.SetEventObject(this);
1353 GetEventHandler()->ProcessEvent( cevent );
1354 GetEventHandler()->ProcessEvent( pevent );
1357 node=node->GetNext();
1361 //the user is finishing the drawing of the function
1365 functions.Append(actual);
1370 * The user wants to change the type of function: line, smooth
1371 * TODO is an extension
1373 void pPlotterWindow::changeFuntionType(int aTheType, bool aForAll)
1377 //------------------------------------------
1378 //If the data doesnt come from interaction
1379 //-------------------------------------------
1381 * Add a function to the window, given its points
1383 int pPlotterWindow:: addFunction(pGraphicalFunction * function)
1385 if(function->getType()==2)
1387 function->initializeSplines();
1388 function->initializeSplineVectors();
1392 // bool added1= functions.Append(function)!=NULL; // JPRx
1393 functions.Append(function); //EED
1395 int id=functions.IndexOf(function);
1397 // bool added2= AddLayer(function);// JPRx
1398 AddLayer(function); //EED
1401 return id;//added1 && added2;
1404 * Delete a point of a function
1405 * @param point: is the real value that the functon takes, and is gointg to be deleted
1408 bool pPlotterWindow::DeletePointFunction(pGraphicalFunction* function,wxPoint point)
1411 wxNode* node= functions.GetFirst();
1414 pGraphicalFunction* f= (pGraphicalFunction*)node->GetData();
1417 return function->DeletePoint(point.x,point.y);
1419 node=node->GetNext();
1424 * Delete a function of the plotter
1426 bool pPlotterWindow::deleteFunction(pGraphicalFunction * f)
1428 functions.DeleteObject(f);
1429 functionsToMove.DeleteObject(f);
1433 * Creates and returns a graphical funcion according to the indicated vectors.
1435 pGraphicalFunction * pPlotterWindow::getFunctionForVectors( std::vector<double> *vectorX, std::vector<double> *vectorY )
1437 double coordX = -1 ;
1440 pGraphicalFunction * ff = new pGraphicalFunction( _T(" "), 1);
1443 int sizeX = vectorX->size();
1444 int sizeY = vectorY->size();
1445 if( sizeX == sizeY )
1449 coordX = (*vectorX)[i];
1450 coordY = (*vectorY)[i];
1451 ff -> AddPoint( coordX, coordY);
1456 InitFunctionForVectors( ff );
1460 pGraphicalFunction * pPlotterWindow::getFunctionForVectors( double * vectorX, int sizeX, double * vectorY, int sizeY )
1462 double coordX = -1 ;
1465 pGraphicalFunction * ff = new pGraphicalFunction( _T(" "), 1);
1467 /*wxString text = "\n Including points from two vectors \n";
1468 m_log->AppendText(text);*/
1477 ff -> AddPoint( coordX, coordY);
1478 /* text = wxString::Format("Included point ( %d, %d)\n", coordX, coordY);
1479 m_log->AppendText(text);*/
1487 InitFunctionForVectors( ff );
1493 void pPlotterWindow::InitFunctionForVectors( pGraphicalFunction *ff )
1495 int maxX,maxY,minX,minY;
1497 if the function is not drawed interactively the maxX and the
1498 maxY are the from the points of the function
1502 minX= ff->getMinX();
1503 minY= ff->getMinY();
1506 ff->setMinShowedX(minX);
1507 ff->setMinShowedY(minY);
1508 ff->setMaxShowedX(maxX);
1509 ff->setMaxShowedY(maxY);
1511 GetClientSize(&m_scrX,&m_scrY);
1514 if((maxX-minX)!=0 && (maxY-minY)!=0)
1516 m_scaleX= ((float)m_scrX-100)/(maxX-minX);
1517 m_scaleY= ((float)m_scrY-50)/(maxY-minY);
1529 m_popmenu.Enable(pwID_NOSHOWPOINTS,true);
1530 m_popmenu.Enable(pwID_ADDNEWPOINT,true);
1531 m_popmenu.Enable(pwID_SHOWPOINTS,false);
1532 m_popmenu.Enable(pwID_DELPOINT,true);
1533 //m_popmenu.Enable(pwID_SPLINE,false);
1534 //m_popmenu.Enable(pwID_LINE,true);
1535 m_popmenu.Enable(pwID_SAVE,true);
1536 m_popmenu.Enable(pwID_LOAD,false);
1537 m_popmenu.Enable(pwID_CHANGECOLOR,true);
1538 //m_popmenu.Enable(pwID_STARTDRAWING,false);
1539 m_popmenu.Enable(mpID_LINE_GUIDES,true);
1540 m_popmenu.Enable(pwID_TRASLATEACTUALFUNCTION,true);
1541 //------------------------------------------
1542 //Sending the particular event of changed actual function
1543 //-------------------------------------------
1544 wxCommandEvent cevent( wxEVT_PPLOTTER_CHANGED_FUNCTION, GetId() );
1545 cevent.SetEventObject(this);
1546 GetEventHandler()->ProcessEvent( cevent );
1555 //actual->setScreens(scrX,scrY);
1556 //actual->setScales();
1557 //setActualScales();
1560 bool pPlotterWindow::AddFunction(wxPoint realPoints[],int numberOfPoints,wxString name,int flags)
1562 pGraphicalFunction* function= new pGraphicalFunction(name,flags);
1564 for(int i= 0; i<numberOfPoints;i++)
1566 int x=realPoints[i].x;
1567 int y=realPoints[i].y;
1568 bool added=function->AddPoint(x,y);
1572 functions.Append(function);
1573 bool addL=mpWindow::AddLayer(function);
1576 mpWindow::UpdateAll();
1583 * Actualizes the view range of the plotter and the actual function
1584 * @param newMinX Is the min-value to be shown in the x-scale
1585 * @param newMaxX Is the max-value to be shown in the x-scale
1590 void pPlotterWindow :: actualizeViewRange(int newMinX, int newMaxX)
1592 int minPixX,maxPixX/*, min, max*/; // JPRx
1597 int dx=newMaxX-newMinX;
1601 sx= (((float)m_scrX-100)/dx)*zoomFactor;
1607 //vx.at(i)-offsetX)*scaleX+offsetpx
1608 if(minScrX!=newMinX)
1610 setOffsetX(newMinX);
1611 setMinScrX(newMinX);
1612 actual->setOffsetX(newMinX);
1613 actual->setMinShowedX(newMinX);
1615 wxNode * node= functions.GetFirst();
1618 pGraphicalFunction* fnode=(pGraphicalFunction*)node->GetData();
1621 if(!fnode->getActual())
1623 fnode->setScreens(m_scrX,m_scrY);
1625 //max=minPixX/fnode->getScaleX();
1626 min=minPixX/fnode->getScaleX();
1627 fnode->setOffsetX(min);
1628 fnode->setMinShowedX(min);
1632 node=node->GetNext();
1637 if(maxScrX!=newMaxX)
1639 setMaxScrX(newMaxX);
1640 actual->setMaxShowedX(newMaxX);
1642 wxNode * node= functions.GetFirst();
1646 pGraphicalFunction* fnode=(pGraphicalFunction*)node->GetData();
1649 if(!fnode->getActual())
1651 fnode->setScreens(m_scrX,m_scrY);
1653 max=maxPixX/fnode->getScaleX();
1654 //min=maxPixX/fnode->getScaleX();
1655 //fnode->setOffsetX(max);
1656 //fnode->setMinShowedX(min);
1657 fnode->setMaxShowedX(max);
1661 node=node->GetNext();
1666 if(actual->getMinXShowed()!=actual->getMinX() || actual->getMinYShowed()!=actual->getMinY()||
1667 actual->getMaxXShowed()!=actual->getMaxX() || actual->getMaxYShowed()!=actual->getMaxY())
1669 m_popmenu.Enable(pwID_MYZOOMIN,false);
1670 m_popmenu.Enable(pwID_MYZOOMOUT,false);
1672 else if(actual->getMinXShowed()==actual->getMinX() && actual->getMaxXShowed()==actual->getMaxX())
1675 m_popmenu.Enable(pwID_MYZOOMIN,true);
1676 m_popmenu.Enable(pwID_MYZOOMOUT,true);
1683 * Guide lines menu handler method that reacts to the mpID_LINE_GUIDES command event
1684 * event The corresponding event to handle
1686 void pPlotterWindow :: OnGuideLines (wxCommandEvent &event)
1688 wxString nextAction_text;
1691 setLineGuidesCondition(false);
1692 // nextAction_text << "Turn on guide lines";
1693 nextAction_text = _T("Turn on guide lines");
1698 setLineGuidesCondition(true);
1699 // nextAction_text << "Turn off guide lines";
1700 nextAction_text = _T("Turn off guide lines");
1703 //------------------------------------------
1704 //Sending the paarticular event of changed actual function
1705 //-------------------------------------------
1706 wxCommandEvent cevent( wxEVT_PPLOTTER_GUIDELINES, GetId() );
1707 cevent.SetEventObject(this);
1708 GetEventHandler()->ProcessEvent( cevent );
1711 m_popmenu.SetLabel ( mpID_LINE_GUIDES, nextAction_text );
1714 Get a function in the plotter given the index
1716 pGraphicalFunction* pPlotterWindow::getFunction(int index)
1718 wxNode* node=functions.Item(index);
1722 return (pGraphicalFunction*)node->GetData();
1725 move the functions that the user wants to move
1726 and that were set in functionsToMove
1727 @param porcentageMinX:the percentage that the minShowed
1728 of the functions have to be move
1729 0<=porcentageMinX<=1
1730 @param porcentageMaxX:the percentage that the maxShowed
1731 of the functions have to be move
1732 0<=porcentageMaxX<=1
1736 void pPlotterWindow::moveFunctions( float porcentageMinX,float porcentageMaxX)
1738 //Adding the actual function
1740 //functionsToMove.Append(actual);
1743 //float minShowed,maxShowed,fMaxXShowed,fMinXShowed;
1747 int minShowed,maxShowed,fMaxXShowed,fMinXShowed;
1748 wxNode* fnode=functionsToMove.GetFirst();
1751 pGraphicalFunction* fg=(pGraphicalFunction*)fnode->GetData();
1752 x=porcentageMaxX*(fg->getMaxX()-fg->getMinX());
1753 y=porcentageMinX*(fg->getMaxX()-fg->getMinX());
1755 maxShowed=fg->getMinX()+ x;
1756 minShowed=fg->getMinX()+ y;
1758 fMinXShowed=fg->getMinXShowed();
1759 fMaxXShowed=fg->getMaxXShowed();
1761 if(fMinXShowed!=minShowed)
1765 setOffsetX(minShowed);
1766 setMinScrX(minShowed);
1768 fg->setOffsetX(minShowed);
1769 fg->setMinShowedX(minShowed);
1771 if(fMaxXShowed!=maxShowed)
1775 setMaxScrX(maxShowed);
1777 fg->setMaxShowedX(maxShowed);
1779 if(fg->getActual()&& (fg->getMinXShowed()!=fg->getMinX() || fg->getMinYShowed()!=fg->getMinY()||
1780 fg->getMaxXShowed()!=fg->getMaxX() || fg->getMaxYShowed()!=fg->getMaxY()))
1784 m_popmenu.Enable(pwID_MYZOOMIN,false);
1785 m_popmenu.Enable(pwID_MYZOOMOUT,false);
1788 else if(fg->getActual()&& fg->getMinXShowed()==fg->getMinX() && fg->getMaxXShowed()==fg->getMaxX())
1792 m_popmenu.Enable(pwID_MYZOOMIN,true);
1793 m_popmenu.Enable(pwID_MYZOOMOUT,true);
1798 fnode=fnode->GetNext();
1803 adds a function such that when the min or max of the bar
1804 changes it is going to that function
1806 int pPlotterWindow::addFunctionToMove(pGraphicalFunction *function)
1808 //bool added1= functionsToMove.Append(function)!=NULL; // JPRx
1809 functionsToMove.Append(function); // EED
1811 int id=functionsToMove.IndexOf(function);
1815 //----------------------------
1816 //Handling Options Menu
1817 //----------------------------
1818 void pPlotterWindow::setPopUpMenu(bool startD,bool stopD,bool smooth,bool line, bool zoomIn,
1819 bool zoomOut,bool showPoints,bool noShowPoints,bool changeColor, bool addP,
1820 bool delPoint,bool load,bool save)
1823 pwID_ADDPOINT = 2010, //!< add a point to the function
1824 pwID_DELPOINT, //!< delete a point of the function
1825 pwID_SHOWPOINTS, //!<shows the points that the function has
1826 pwID_STARTDRAWING, //!<let to the user to start drawing the curve
1827 pwID_DELFUNCTION, //!<delete a function that is in the plotter
1828 pwID_STOPDRAWING,//!<Stops the drawing of the function
1829 pwID_ADDNEWPOINT,//!<add a new point to the function.
1830 pwID_NOSHOWPOINTS, //!<No show the points of the function.
1831 pwID_MYZOOMIN,//!<Zoom in the function
1832 pwID_MYZOOMOUT,//!<Zoom out the points of the function.
1833 pwID_SPLINE,//!<Spline the actual curve.
1834 pwID_LINE,//!<Piecewise the actual curve.
1835 pwID_SAVE,//!<Save the function in a .txt file.
1836 pwID_LOAD, //!<Load the function from a .txt file.
1837 pwID_CHANGECOLOR, //!<Change the color of the function
1838 pwID_TRASLATEACTUALFUNCTION //!<move the actual function
1841 m_popmenu.Remove( pwID_STARTDRAWING);
1843 m_popmenu.Remove( pwID_STOPDRAWING);
1845 m_popmenu.Remove( pwID_LOAD);
1847 m_popmenu.Remove( pwID_SAVE);
1849 m_popmenu.Remove( pwID_SHOWPOINTS);
1851 m_popmenu.Remove( pwID_NOSHOWPOINTS);
1853 m_popmenu.Remove( pwID_SPLINE);
1855 m_popmenu.Remove( pwID_LINE);
1857 m_popmenu.Remove( pwID_MYZOOMIN);
1859 m_popmenu.Remove( pwID_MYZOOMOUT);
1861 m_popmenu.Remove( pwID_CHANGECOLOR);
1863 m_popmenu.Remove( pwID_ADDPOINT);
1865 m_popmenu.Remove( pwID_DELPOINT);