#include <pPlotterWindow.h>
Public Member Functions | |
pPlotterWindow (wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, int flags=0) | |
~pPlotterWindow () | |
void | setPopUpMenu (bool startD, bool stopD, bool smooth, bool line, bool zoomIn, bool zoomOut, bool showPoints, bool noShowPoints, bool changeColor, bool addP, bool delPoint, bool load, bool save) |
void | onLeftUp (wxMouseEvent &event) |
void | onMoveFunction (wxCommandEvent &aEvent) |
void | onChangeColor (wxCommandEvent &aEvent) |
void | onLoad (wxCommandEvent &aEvent) |
void | onSave (wxCommandEvent &aEvent) |
void | onLine (wxCommandEvent &aEvent) |
void | onSplinePoints (wxCommandEvent &aEvent) |
void | onMyZoomOut (wxCommandEvent &aEvent) |
void | onMyZoomIn (wxCommandEvent &aEvent) |
wxPoint | getRealPoint (wxPoint pixelPoint) |
void | onNoShowPoints (wxCommandEvent &aEvent) |
void | onStopDrawing (wxCommandEvent &aEvent) |
void | onAddNewPoint (wxCommandEvent &aEvent) |
void | onStartDrawing (wxCommandEvent &aEvent) |
void | onMouseMove (wxMouseEvent &event) |
void | onChangeActual (wxMouseEvent &event) |
void | onAddPoint (wxMouseEvent &aEvent) |
void | onDeletePoint (wxCommandEvent &aEvent) |
void | onShowPoints (wxCommandEvent &aEvent) |
void | changeFuntionType (int aTheType, bool aForAll) |
int | addFunction (pGraphicalFunction *function) |
bool | DeletePointFunction (pGraphicalFunction *function, wxPoint point) |
bool | deleteFunction (pGraphicalFunction *f) |
void | setActualFunction (pGraphicalFunction *newActual) |
pGraphicalFunction * | getActualFunction () |
void | InitFunctionForVectors (pGraphicalFunction *ff) |
pGraphicalFunction * | getFunctionForVectors (double *vectorX, int sizeX, double *vectorY, int sizeY) |
pGraphicalFunction * | getFunctionForVectors (std::vector< double > *vectorX, std::vector< double > *vectorY) |
void | setActualScales () |
void | setmLog (wxTextCtrl *m_log1) |
void | actualizeViewRange (int newMinX, int newMaxX) |
void | setLineGuidesCondition (bool ifDrawing) |
bool | drawGuideLines () |
void | OnGuideLines (wxCommandEvent &event) |
void | writeInText (wxString &t) |
pGraphicalFunction * | getFunction (int index) |
void | moveFunctions (float porcentageMinX, float porcentageMaxX) |
int | addFunctionToMove (pGraphicalFunction *function) |
wxMenu * | GetPopupMenu () |
void | setType (int t) |
int | getType () |
void | setMaxScrX (int maxX) |
void | setMaxScrY (int maxY) |
double | getMaxScrX () |
double | getMaxScrY () |
float | getZoomFactor () |
void | setMinScrX (int minX) |
void | setMinScrY (int minY) |
double | getMinScrX () |
double | getMinScrY () |
int | getClickedX () |
int | getClickedY () |
int | getOffsetPixelsX () |
int | getOffsetPixelsY () |
void | setOffsetPixelX (int offX) |
void | setOffsetPixelY (int offY) |
int | getOffsetX () |
int | getOffsetY () |
void | setOffsetX (int offX) |
void | setOffsetY (int offY) |
void | setRealGuideX (int newX_realGuide) |
int | getRealGuideX () |
void | setRealGuideY (int newY_realGuide) |
int | getRealGuideY () |
bool | AddLayer (mpLayer *layer) |
void | DelLayer (mpLayer *layer) |
double | GetScaleX (void) const |
double | GetScaleY (void) const |
double | GetPosX (void) const |
double | GetPosY (void) const |
int | GetScrX (void) const |
int | GetScrY (void) const |
void | SetScaleX (double scaleX) |
void | SetScaleY (double scaleY) |
void | SetPosX (double posX) |
void | SetPosY (double posY) |
void | SetPos (double posX, double posY) |
void | LockAspect (bool enable=TRUE) |
bool | IsAspectLocked () |
void | Fit () |
void | ZoomIn () |
void | ZoomOut () |
void | UpdateAll () |
int | GetYTranslated (wxSize size, double y) |
Protected Member Functions | |
void | Refresh (bool eraseBackground=true, const wxRect *rect=NULL) |
void | OnPaint (wxPaintEvent &event) |
Paint handler, will plot all attached layers. | |
void | OnSize (wxSizeEvent &event) |
Size handler, will update scroll bar sizes. | |
void | OnScroll2 (wxScrollWinEvent &event) |
Scroll handler, will move canvas. | |
void | OnShowPopupMenu (wxMouseEvent &event) |
Mouse handler, will show context menu. | |
void | OnCenter (wxCommandEvent &event) |
Context menu handler. | |
void | OnFit (wxCommandEvent &event) |
Context menu handler. | |
void | OnZoomIn (wxCommandEvent &event) |
Context menu handler. | |
void | OnZoomOut (wxCommandEvent &event) |
Context menu handler. | |
void | OnLockAspect (wxCommandEvent &event) |
Context menu handler. | |
bool | UpdateBBox () |
Recalculate global layer bounding box. | |
Protected Attributes | |
wxList | m_layers |
List of attached plot layers. | |
wxMenu | m_popmenu |
Canvas' context menu. | |
bool | m_lockaspect |
Scale aspect is locked or not. | |
double | m_minX |
Global layer bounding box, left border incl. | |
double | m_maxX |
Global layer bounding box, right border incl. | |
double | m_minY |
Global layer bounding box, bottom border incl. | |
double | m_maxY |
Global layer bounding box, top border incl. | |
double | m_scaleX |
Current view's X scale. | |
double | m_scaleY |
Current view's Y scale. | |
double | m_posX |
Current view's X position. | |
double | m_posY |
Current view's Y position. | |
int | m_scrX |
Current view's X dimension. | |
int | m_scrY |
Current view's Y dimension. | |
int | m_clickedX |
Last mouse click X position, for centering and zooming the view. | |
int | m_clickedY |
Last mouse click Y position, for centering and zooming the view. | |
int | maxScrX |
int | maxScrY |
int | minScrX |
int | minScrY |
float | zoomFactor |
int | offsetPixelX |
int | offsetPixelY |
int | offsetX |
int | offsetY |
int | real_guideLine_X |
int | real_guideLine_Y |
bool | drawGuides |
int | type |
Private Attributes | |
pGraphicalFunction * | actual |
wxList | functions |
bool | drawing |
int | movingPointIndex |
int | scaleWay |
wxTextCtrl * | m_log |
wxString | text |
wxList | functionsToMove |
bool | movingFunction |
int | initialMovingCLick |
std::vector< double > | backUpActualVector |
bool | movingPoints |
THE FACTOR TO ZOOM (IN,OUT)
Definition at line 89 of file pPlotterWindow.h.
pPlotterWindow::pPlotterWindow | ( | wxWindow * | parent, | |
wxWindowID | id, | |||
const wxPoint & | pos = wxDefaultPosition , |
|||
const wxSize & | size = wxDefaultSize , |
|||
int | flags = 0 | |||
) |
Constructors and destructor
Definition at line 79 of file pPlotterWindow.cxx.
References DEFAULT_PLOTTER, DEFAULT_SCALE, mpID_CENTER, mpID_FIT, mpID_LOCKASPECT, mpID_ZOOM_IN, and mpID_ZOOM_OUT.
00080 : mpWindow( parent, id, pos, size, flag) 00081 { 00082 drawing=false; 00083 movingPointIndex=-1; 00084 actual=NULL; 00085 scaleWay=DEFAULT_SCALE; 00086 zoomFactor=1; 00087 //drawGuideLines=true; 00088 type=DEFAULT_PLOTTER; 00089 drawGuides=false; 00090 movingFunction=false; 00091 initialMovingCLick=-1; 00092 movingPoints=false; 00093 00094 /* 00095 PopMenu options 00096 */ 00097 m_popmenu.Remove( mpID_ZOOM_IN); 00098 m_popmenu.Remove( mpID_ZOOM_OUT); 00099 m_popmenu.Remove( mpID_CENTER); 00100 m_popmenu.Remove( mpID_FIT); 00101 m_popmenu.Remove( mpID_LOCKASPECT); 00102 00103 m_popmenu.Append(pwID_STARTDRAWING , _("Start Drawing"), _("Starts to draw a new function"));//it changes the actual function 00104 m_popmenu.Append(pwID_STOPDRAWING , _("Stop drawing"), _("Stops of drawing the new function")); 00105 m_popmenu.Append(pwID_LOAD, _("Load"), _("Load the actual function from a plane file")); 00106 m_popmenu.Append(pwID_SHOWPOINTS , _("Show Points"), _("shows the discrete points of the function")); 00107 m_popmenu.Append(pwID_NOSHOWPOINTS, _("No show Points"), _("Dont show the points of the function")); 00108 m_popmenu.Append(pwID_ADDNEWPOINT, _("Add point"), _("Add New point to the actual function")); 00109 m_popmenu.Append(pwID_DELPOINT , _("Delete point"), _("Deletes a point from the actual function.")); 00110 m_popmenu.Append(pwID_MYZOOMIN, _("Zoom in"), _("Zoom in the points of the function")); 00111 m_popmenu.Append(pwID_MYZOOMOUT, _("Zoom out"), _("Zoom out the points of the function")); 00112 m_popmenu.Append(pwID_SPLINE, _("Smooth"), _("Splines the points ofthe actual curve")); 00113 m_popmenu.Append(pwID_LINE, _("Line"), _("Piecewise the points ofthe actual curve")); 00114 m_popmenu.Append(pwID_SAVE, _("Save"), _("Save the actual function in plane file")); 00115 m_popmenu.Append(pwID_CHANGECOLOR, _("Change Color"), _("Change the color of the function")); 00116 m_popmenu.Append(pwID_TRASLATEACTUALFUNCTION, _("Start Moving Function"), _("Move the actual Function")); 00117 00118 m_popmenu.Enable(pwID_NOSHOWPOINTS,false); 00119 m_popmenu.Enable(pwID_ADDNEWPOINT,false); 00120 m_popmenu.Enable(pwID_SHOWPOINTS,false); 00121 m_popmenu.Enable(pwID_DELPOINT,false); 00122 m_popmenu.Enable(pwID_STOPDRAWING,false); 00123 m_popmenu.Enable(pwID_MYZOOMIN,false); 00124 m_popmenu.Enable(pwID_MYZOOMOUT,false); 00125 m_popmenu.Enable(pwID_SPLINE,false); 00126 m_popmenu.Enable(pwID_LINE,false); 00127 m_popmenu.Enable(pwID_SAVE,false); 00128 m_popmenu.Enable(pwID_LOAD,true); 00129 m_popmenu.Enable(pwID_CHANGECOLOR,false); 00130 m_popmenu.Enable(pwID_STARTDRAWING,true); 00131 m_popmenu.Enable(pwID_LOAD,true); 00132 //m_popmenu.Enable(pwID_STARTDRAWING,false); 00133 m_popmenu.Enable(mpID_LINE_GUIDES,false); 00134 m_popmenu.Enable(pwID_TRASLATEACTUALFUNCTION,false); 00135 00136 00137 }
pPlotterWindow::~pPlotterWindow | ( | ) |
Definition at line 140 of file pPlotterWindow.cxx.
void pPlotterWindow::actualizeViewRange | ( | int | newMinX, | |
int | newMaxX | |||
) |
Definition at line 1590 of file pPlotterWindow.cxx.
References actual, mpWindow::m_scrX, mpWindow::maxScrX, mpWindow::minScrX, mpWindow::setMaxScrX(), pGraphicalFunction::setMaxShowedX(), mpWindow::setMinScrX(), pGraphicalFunction::setMinShowedX(), pGraphicalFunction::setOffsetX(), mpWindow::setOffsetX(), mpWindow::UpdateAll(), and mpWindow::zoomFactor.
Referenced by pPlotter::onEndChange_Bar(), and pPlotter::onStartChange_Bar().
01591 { 01592 int minPixX,maxPixX/*, min, max*/; // JPRx 01593 double sx; 01594 /* 01595 getiing pixels 01596 */ 01597 int dx=newMaxX-newMinX; 01598 01599 if(dx!=0) 01600 { 01601 sx= (((float)m_scrX-100)/dx)*zoomFactor; 01602 } 01603 01604 minPixX=newMinX*sx; 01605 maxPixX=newMaxX*sx; 01606 01607 //vx.at(i)-offsetX)*scaleX+offsetpx 01608 if(minScrX!=newMinX) 01609 { 01610 setOffsetX(newMinX); 01611 setMinScrX(newMinX); 01612 actual->setOffsetX(newMinX); 01613 actual->setMinShowedX(newMinX); 01614 /* 01615 wxNode * node= functions.GetFirst(); 01616 while (node) 01617 { 01618 pGraphicalFunction* fnode=(pGraphicalFunction*)node->GetData(); 01619 if(fnode) 01620 { 01621 if(!fnode->getActual()) 01622 { 01623 fnode->setScreens(m_scrX,m_scrY); 01624 fnode->setScales(); 01625 //max=minPixX/fnode->getScaleX(); 01626 min=minPixX/fnode->getScaleX(); 01627 fnode->setOffsetX(min); 01628 fnode->setMinShowedX(min); 01629 01630 } 01631 } 01632 node=node->GetNext(); 01633 } 01634 */ 01635 01636 } 01637 if(maxScrX!=newMaxX) 01638 { 01639 setMaxScrX(newMaxX); 01640 actual->setMaxShowedX(newMaxX); 01641 /* 01642 wxNode * node= functions.GetFirst(); 01643 while (node) 01644 { 01645 01646 pGraphicalFunction* fnode=(pGraphicalFunction*)node->GetData(); 01647 if(fnode) 01648 { 01649 if(!fnode->getActual()) 01650 { 01651 fnode->setScreens(m_scrX,m_scrY); 01652 fnode->setScales(); 01653 max=maxPixX/fnode->getScaleX(); 01654 //min=maxPixX/fnode->getScaleX(); 01655 //fnode->setOffsetX(max); 01656 //fnode->setMinShowedX(min); 01657 fnode->setMaxShowedX(max); 01658 } 01659 } 01660 01661 node=node->GetNext(); 01662 } 01663 */ 01664 } 01665 /* 01666 if(actual->getMinXShowed()!=actual->getMinX() || actual->getMinYShowed()!=actual->getMinY()|| 01667 actual->getMaxXShowed()!=actual->getMaxX() || actual->getMaxYShowed()!=actual->getMaxY()) 01668 { 01669 m_popmenu.Enable(pwID_MYZOOMIN,false); 01670 m_popmenu.Enable(pwID_MYZOOMOUT,false); 01671 } 01672 else if(actual->getMinXShowed()==actual->getMinX() && actual->getMaxXShowed()==actual->getMaxX()) 01673 { 01674 01675 m_popmenu.Enable(pwID_MYZOOMIN,true); 01676 m_popmenu.Enable(pwID_MYZOOMOUT,true); 01677 } 01678 */ 01679 01680 UpdateAll(); 01681 }
int pPlotterWindow::addFunction | ( | pGraphicalFunction * | function | ) |
Add a function to the plotter when the function doesnt come from window
Add a function to the window, given its points
Definition at line 1383 of file pPlotterWindow.cxx.
References mpWindow::AddLayer(), functions, pGraphicalFunction::getType(), pGraphicalFunction::initializeSplines(), pGraphicalFunction::initializeSplineVectors(), and mpWindow::UpdateAll().
Referenced by pPlotter::addFunction(), and Histogram::drawHistogram().
01384 { 01385 if(function->getType()==2) 01386 { 01387 function->initializeSplines(); 01388 function->initializeSplineVectors(); 01389 UpdateAll(); 01390 } 01391 01392 // bool added1= functions.Append(function)!=NULL; // JPRx 01393 functions.Append(function); //EED 01394 01395 int id=functions.IndexOf(function); 01396 01397 // bool added2= AddLayer(function);// JPRx 01398 AddLayer(function); //EED 01399 01400 UpdateAll(); 01401 return id;//added1 && added2; 01402 }
int pPlotterWindow::addFunctionToMove | ( | pGraphicalFunction * | function | ) |
Add a function to the plotter when the function doesnt come from window
Definition at line 1806 of file pPlotterWindow.cxx.
References functionsToMove, and mpWindow::UpdateAll().
Referenced by pPlotter::addFunctionToMove(), Histogram::drawHistogram(), onLoad(), and onStopDrawing().
01807 { 01808 //bool added1= functionsToMove.Append(function)!=NULL; // JPRx 01809 functionsToMove.Append(function); // EED 01810 01811 int id=functionsToMove.IndexOf(function); 01812 UpdateAll(); 01813 return id; 01814 }
bool mpWindow::AddLayer | ( | mpLayer * | layer | ) | [inherited] |
Add a plot layer to the canvas.
layer | Pointer to layer. The mpLayer object will get under control of mpWindow, i.e. it will be delete'd on mpWindow destruction |
TRUE | Success | |
FALSE | Failure due to out of memory. |
Definition at line 545 of file mathplot.cxx.
References mpWindow::m_layers, and mpWindow::UpdateAll().
Referenced by addFunction(), onLoad(), and onStartDrawing().
00546 { 00547 bool ret = m_layers.Append( layer) != NULL; 00548 UpdateAll(); 00549 return ret; 00550 }
void pPlotterWindow::changeFuntionType | ( | int | aTheType, | |
bool | aForAll | |||
) |
Changes the type according to the specified number of the type. If the second parameter, the boolean one is true indicates that this action must be done in all the funtion, if not it will be applied only to the actual selected function. IS NOT IMPLEMENTED
The user wants to change the type of function: line, smooth TODO is an extension
Definition at line 1373 of file pPlotterWindow.cxx.
bool pPlotterWindow::deleteFunction | ( | pGraphicalFunction * | f | ) |
Delete a function of the plotter
Definition at line 1426 of file pPlotterWindow.cxx.
References functions, and functionsToMove.
01427 { 01428 functions.DeleteObject(f); 01429 functionsToMove.DeleteObject(f); 01430 return true; 01431 }
bool pPlotterWindow::DeletePointFunction | ( | pGraphicalFunction * | function, | |
wxPoint | point | |||
) |
Delete a point of a function
point,: | is the real value that the functon takes, and is gointg to be deleted |
Definition at line 1408 of file pPlotterWindow.cxx.
References pGraphicalFunction::DeletePoint(), and functions.
01409 { 01410 01411 wxNode* node= functions.GetFirst(); 01412 while(node) 01413 { 01414 pGraphicalFunction* f= (pGraphicalFunction*)node->GetData(); 01415 if(f==function) 01416 { 01417 return function->DeletePoint(point.x,point.y); 01418 } 01419 node=node->GetNext(); 01420 } 01421 return false; 01422 }
void mpWindow::DelLayer | ( | mpLayer * | layer | ) | [inherited] |
Remove a plot layer from the canvas.
layer | Pointer to layer. The mpLayer object will be destructed using delete. |
Definition at line 552 of file mathplot.cxx.
References mpWindow::m_layers, and mpWindow::UpdateAll().
Referenced by onStartDrawing(), and onStopDrawing().
bool pPlotterWindow::drawGuideLines | ( | ) | [inline] |
Reimplemented from mpWindow.
Definition at line 298 of file pPlotterWindow.h.
00299 { 00300 return drawGuides; 00301 }
void mpWindow::Fit | ( | ) | [inherited] |
Set view to fit global bounding box of all plot layers and refresh display. Scale and position will be set to a show all attached mpLayers. The X/Y scale aspect lock is taken into account.
Definition at line 440 of file mathplot.cxx.
References mpWindow::m_lockaspect, mpWindow::m_maxX, mpWindow::m_maxY, mpWindow::m_minX, mpWindow::m_minY, mpWindow::m_posX, mpWindow::m_posY, mpWindow::m_scaleX, mpWindow::m_scaleY, mpWindow::UpdateAll(), and mpWindow::UpdateBBox().
Referenced by mpWindow::OnFit().
00441 { 00442 if (UpdateBBox()) 00443 { 00444 int cx, cy; 00445 GetClientSize( &cx, &cy); 00446 00447 double d; 00448 d = m_maxX - m_minX; 00449 if (d!=0) 00450 { 00451 m_scaleX = cx/d; 00452 m_posX = m_minX + d/2; 00453 } 00454 d = m_maxY - m_minY; 00455 if (d!=0) 00456 { 00457 m_scaleY = cy/d; 00458 m_posY = m_minY + d/2; 00459 } 00460 00461 if (m_lockaspect) 00462 { 00463 double s = (m_scaleX + m_scaleY)/2; 00464 m_scaleX = s; 00465 m_scaleY = s; 00466 } 00467 00468 UpdateAll(); 00469 } 00470 }
pGraphicalFunction * pPlotterWindow::getActualFunction | ( | ) |
Get the actual function
Gets the actual function
Definition at line 161 of file pPlotterWindow.cxx.
References actual.
Referenced by pPlotter::onAdded_ColorPoint(), pPlotter::onChangeFunction(), pPlotter::onRemoved_ColorPoint(), pPlotter::setAll(), and pPlotter::update().
00162 { 00163 return actual; 00164 }
int mpWindow::getClickedX | ( | ) | [inline, inherited] |
Get the x-clicked by the user
Definition at line 543 of file mathplot.h.
00544 { 00545 return m_clickedX; 00546 }
int mpWindow::getClickedY | ( | ) | [inline, inherited] |
Get the y-clicked by the user
Definition at line 552 of file mathplot.h.
00553 { 00554 return m_clickedY; 00555 }
pGraphicalFunction * pPlotterWindow::getFunction | ( | int | index | ) |
Definition at line 1716 of file pPlotterWindow.cxx.
References functions.
Referenced by pPlotter::getFunction().
01717 { 01718 wxNode* node=functions.Item(index); 01719 if(node==NULL){ 01720 return NULL; 01721 } 01722 return (pGraphicalFunction*)node->GetData(); 01723 }
pGraphicalFunction * pPlotterWindow::getFunctionForVectors | ( | std::vector< double > * | vectorX, | |
std::vector< double > * | vectorY | |||
) |
Creates and returns a graphical funcion according to the indicated vectors.
Definition at line 1435 of file pPlotterWindow.cxx.
References InitFunctionForVectors().
01436 { 01437 double coordX = -1 ; 01438 double coordY = -1; 01439 01440 pGraphicalFunction * ff = new pGraphicalFunction( _T(" "), 1); 01441 01442 int i=0; 01443 int sizeX = vectorX->size(); 01444 int sizeY = vectorY->size(); 01445 if( sizeX == sizeY ) 01446 { 01447 while ( i < sizeX ) 01448 { 01449 coordX = (*vectorX)[i]; 01450 coordY = (*vectorY)[i]; 01451 ff -> AddPoint( coordX, coordY); 01452 i++; 01453 } 01454 } 01455 01456 InitFunctionForVectors( ff ); 01457 return ff; 01458 }
pGraphicalFunction * pPlotterWindow::getFunctionForVectors | ( | double * | vectorX, | |
int | sizeX, | |||
double * | vectorY, | |||
int | sizeY | |||
) |
Definition at line 1460 of file pPlotterWindow.cxx.
References InitFunctionForVectors().
Referenced by Histogram::drawHistogram(), and pPlotter::getFunctionForVectors().
01461 { 01462 double coordX = -1 ; 01463 double coordY = -1; 01464 01465 pGraphicalFunction * ff = new pGraphicalFunction( _T(" "), 1); 01466 01467 /*wxString text = "\n Including points from two vectors \n"; 01468 m_log->AppendText(text);*/ 01469 01470 int i=0; 01471 if(sizeX == sizeY) 01472 { 01473 while ( i < sizeX ) 01474 { 01475 coordX = *vectorX; 01476 coordY = *vectorY; 01477 ff -> AddPoint( coordX, coordY); 01478 /* text = wxString::Format("Included point ( %d, %d)\n", coordX, coordY); 01479 m_log->AppendText(text);*/ 01480 01481 vectorX++; 01482 vectorY++; 01483 i++; 01484 } 01485 } 01486 01487 InitFunctionForVectors( ff ); 01488 return ff; 01489 }
double mpWindow::getMaxScrX | ( | ) | [inline, inherited] |
Get maximum value in x
Definition at line 488 of file mathplot.h.
Referenced by pPlotter::onStartChange_Bar(), pPlotterScaleX::Plot(), and pPlotter::pPlotter().
00489 { 00490 return maxScrX; 00491 }
double mpWindow::getMaxScrY | ( | ) | [inline, inherited] |
Get maximum value in y
Definition at line 495 of file mathplot.h.
Referenced by pPlotterScaleY::Plot().
00496 { 00497 return maxScrY; 00498 }
double mpWindow::getMinScrX | ( | ) | [inline, inherited] |
Get miniimum value in x
Definition at line 527 of file mathplot.h.
Referenced by pPlotter::onEndChange_Bar(), and pPlotterScaleX::Plot().
00528 { 00529 return minScrX; 00530 }
double mpWindow::getMinScrY | ( | ) | [inline, inherited] |
Get minimum value in y
Definition at line 534 of file mathplot.h.
Referenced by pPlotterScaleY::Plot().
00535 { 00536 return minScrY; 00537 }
int mpWindow::getOffsetPixelsX | ( | ) | [inline, inherited] |
Gets the x-offset of the zoom in pixels
Definition at line 561 of file mathplot.h.
Referenced by pPlotterScaleX::Plot().
00562 { 00563 return offsetPixelX; 00564 }
int mpWindow::getOffsetPixelsY | ( | ) | [inline, inherited] |
Gets the offset of the zoom in pixels
Definition at line 570 of file mathplot.h.
Referenced by pPlotterScaleY::Plot().
00571 { 00572 return offsetPixelY; 00573 }
int mpWindow::getOffsetX | ( | ) | [inline, inherited] |
Gets the x-offset of the zoom
Definition at line 592 of file mathplot.h.
Referenced by pPlotterScaleX::Plot().
00593 { 00594 return offsetX; 00595 }
int mpWindow::getOffsetY | ( | ) | [inline, inherited] |
Gets the offset of the zoom
Definition at line 600 of file mathplot.h.
Referenced by pPlotterScaleY::Plot().
00601 { 00602 return offsetY; 00603 }
wxMenu* mpWindow::GetPopupMenu | ( | ) | [inline, inherited] |
Get reference to context menu of the plot canvas.
Definition at line 446 of file mathplot.h.
00446 { return &m_popmenu; }
double mpWindow::GetPosX | ( | void | ) | const [inline, inherited] |
Get current view's X position. See rules for coordinate transformation
Definition at line 716 of file mathplot.h.
Referenced by mpScaleY::Plot(), mpScaleX::Plot(), mpFXY::Plot(), mpFY::Plot(), and mpFX::Plot().
00716 { return m_posX; }
double mpWindow::GetPosY | ( | void | ) | const [inline, inherited] |
Get current view's Y position. See rules for coordinate transformation
Definition at line 722 of file mathplot.h.
Referenced by mpScaleY::Plot(), mpScaleX::Plot(), mpFXY::Plot(), mpFY::Plot(), and mpFX::Plot().
00722 { return m_posY; }
int mpWindow::getRealGuideX | ( | ) | [inline, inherited] |
Definition at line 634 of file mathplot.h.
Referenced by pPlotterLayer::Plot().
00635 { 00636 return real_guideLine_X; 00637 }
int mpWindow::getRealGuideY | ( | ) | [inline, inherited] |
Definition at line 654 of file mathplot.h.
Referenced by pPlotterLayer::Plot().
00655 { 00656 return real_guideLine_Y; 00657 }
wxPoint pPlotterWindow::getRealPoint | ( | wxPoint | pixelPoint | ) |
Transform the point clicked from window to the real value,given by the scale
Transform the point clicked from window to the real value,given by the scale Pre: m_scaleX and m_scaleY are already actualized with setActualScales() method
Definition at line 172 of file pPlotterWindow.cxx.
References mpWindow::m_scaleX, mpWindow::m_scaleY, mpWindow::maxScrX, mpWindow::maxScrY, mpWindow::minScrX, mpWindow::minScrY, mpWindow::offsetPixelX, mpWindow::offsetPixelY, mpWindow::offsetX, and mpWindow::offsetY.
Referenced by onAddNewPoint(), onAddPoint(), onDeletePoint(), and onMouseMove().
00173 { 00174 int x,y; 00175 x=pixelPoint.x-70; 00176 y=pixelPoint.y-40; 00177 //real point on the function 00178 wxPoint realPoint; 00179 int xS=(x-offsetPixelX)/m_scaleX + offsetX + minScrX; 00180 int yS=(y-offsetPixelY)/m_scaleY + offsetY + minScrY; 00181 00182 if(xS<=maxScrX && yS<=maxScrY ) 00183 { 00184 //setActualScales(); 00185 realPoint.x= xS; 00186 realPoint.y= yS; 00187 } 00188 else 00189 { 00190 realPoint.x= -1; 00191 realPoint.y= -1; 00192 } 00193 return realPoint; 00194 }
double mpWindow::GetScaleX | ( | void | ) | const [inline, inherited] |
Get current view's X scale. See rules for coordinate transformation
Definition at line 704 of file mathplot.h.
Referenced by mpWindow::OnScroll2(), mpScaleY::Plot(), mpScaleX::Plot(), mpFXY::Plot(), mpFY::Plot(), and mpFX::Plot().
00704 { return m_scaleX; }
double mpWindow::GetScaleY | ( | void | ) | const [inline, inherited] |
Get current view's Y scale. See rules for coordinate transformation
Definition at line 710 of file mathplot.h.
Referenced by mpWindow::OnScroll2(), mpScaleY::Plot(), mpScaleX::Plot(), mpFXY::Plot(), mpFY::Plot(), and mpFX::Plot().
00710 { return m_scaleY; }
int mpWindow::GetScrX | ( | void | ) | const [inline, inherited] |
Get current view's X dimension in device context units. Usually this is equal to wxDC::GetSize, but it might differ thus mpLayer implementations should rely on the value returned by the function. See rules for coordinate transformation
Definition at line 730 of file mathplot.h.
Referenced by pPlotterScaleX::Plot(), mpScaleX::Plot(), mpFXY::Plot(), and mpFX::Plot().
00730 { return m_scrX; }
int mpWindow::GetScrY | ( | void | ) | const [inline, inherited] |
Get current view's Y dimension in device context units. Usually this is equal to wxDC::GetSize, but it might differ thus mpLayer implementations should rely on the value returned by the function. See rules for coordinate transformation
Definition at line 738 of file mathplot.h.
Referenced by pPlotterScaleY::Plot(), mpScaleY::Plot(), mpFXY::Plot(), and mpFY::Plot().
00738 { return m_scrY; }
int mpWindow::getType | ( | ) | [inline, inherited] |
Definition at line 461 of file mathplot.h.
Referenced by pPlotter::update().
00462 { 00463 return type; 00464 }
int mpWindow::GetYTranslated | ( | wxSize | size, | |
double | y | |||
) | [inline, inherited] |
Get the translation of the Y coordinate
Definition at line 798 of file mathplot.h.
float mpWindow::getZoomFactor | ( | ) | [inline, inherited] |
Definition at line 502 of file mathplot.h.
Referenced by pPlotterScaleY::Plot(), and pPlotterScaleX::Plot().
00503 { 00504 return zoomFactor; 00505 }
void pPlotterWindow::InitFunctionForVectors | ( | pGraphicalFunction * | ff | ) |
Creates and returns a graphical funcion according to the indicated vectors.
Definition at line 1493 of file pPlotterWindow.cxx.
References actual, pGraphicalFunction::getMaxX(), pGraphicalFunction::getMaxY(), pGraphicalFunction::getMinX(), pGraphicalFunction::getMinY(), HISTOGRAM, mpWindow::m_popmenu, mpWindow::m_scaleX, mpWindow::m_scaleY, mpWindow::m_scrX, mpWindow::m_scrY, mpWindow::maxScrX, mpWindow::maxScrY, mpWindow::minScrX, mpWindow::minScrY, mpID_LINE_GUIDES, pwID_ADDNEWPOINT, pwID_CHANGECOLOR, pwID_DELPOINT, pwID_LOAD, pwID_NOSHOWPOINTS, pwID_SAVE, pwID_SHOWPOINTS, pwID_TRASLATEACTUALFUNCTION, setActualScales(), pGraphicalFunction::setMaxShowedX(), pGraphicalFunction::setMaxShowedY(), pGraphicalFunction::setMinShowedX(), pGraphicalFunction::setMinShowedY(), and mpWindow::type.
Referenced by getFunctionForVectors().
01494 { 01495 int maxX,maxY,minX,minY; 01496 /* 01497 if the function is not drawed interactively the maxX and the 01498 maxY are the from the points of the function 01499 */ 01500 maxX=ff->getMaxX(); 01501 maxY=ff->getMaxY(); 01502 minX= ff->getMinX(); 01503 minY= ff->getMinY(); 01504 01505 01506 ff->setMinShowedX(minX); 01507 ff->setMinShowedY(minY); 01508 ff->setMaxShowedX(maxX); 01509 ff->setMaxShowedY(maxY); 01510 01511 GetClientSize(&m_scrX,&m_scrY); 01512 //set 01513 01514 if((maxX-minX)!=0 && (maxY-minY)!=0) 01515 { 01516 m_scaleX= ((float)m_scrX-100)/(maxX-minX); 01517 m_scaleY= ((float)m_scrY-50)/(maxY-minY); 01518 } 01519 maxScrX=maxX; 01520 maxScrY=maxY; 01521 minScrX=minX; 01522 minScrY=minY; 01523 01524 01525 if(type==HISTOGRAM) 01526 { 01527 actual=ff; 01528 setActualScales(); 01529 m_popmenu.Enable(pwID_NOSHOWPOINTS,true); 01530 m_popmenu.Enable(pwID_ADDNEWPOINT,true); 01531 m_popmenu.Enable(pwID_SHOWPOINTS,false); 01532 m_popmenu.Enable(pwID_DELPOINT,true); 01533 //m_popmenu.Enable(pwID_SPLINE,false); 01534 //m_popmenu.Enable(pwID_LINE,true); 01535 m_popmenu.Enable(pwID_SAVE,true); 01536 m_popmenu.Enable(pwID_LOAD,false); 01537 m_popmenu.Enable(pwID_CHANGECOLOR,true); 01538 //m_popmenu.Enable(pwID_STARTDRAWING,false); 01539 m_popmenu.Enable(mpID_LINE_GUIDES,true); 01540 m_popmenu.Enable(pwID_TRASLATEACTUALFUNCTION,true); 01541 //------------------------------------------ 01542 //Sending the particular event of changed actual function 01543 //------------------------------------------- 01544 wxCommandEvent cevent( wxEVT_PPLOTTER_CHANGED_FUNCTION, GetId() ); 01545 cevent.SetEventObject(this); 01546 GetEventHandler()->ProcessEvent( cevent ); 01547 } 01548 01549 /* 01550 maxScrX=100; 01551 minScrX=50; 01552 offsetX=50; 01553 ff->setOffsetX(50); 01554 */ 01555 //actual->setScreens(scrX,scrY); 01556 //actual->setScales(); 01557 //setActualScales(); 01558 }
bool mpWindow::IsAspectLocked | ( | ) | [inline, inherited] |
Checks whether the X/Y scale aspect is locked.
TRUE | Locked | |
FALSE | Unlocked |
Definition at line 778 of file mathplot.h.
00778 { return m_lockaspect; }
void mpWindow::LockAspect | ( | bool | enable = TRUE |
) | [inherited] |
Enable or disable X/Y scale aspect locking for the view.
Definition at line 486 of file mathplot.cxx.
References mpWindow::m_lockaspect, mpWindow::m_popmenu, mpWindow::m_scaleX, mpWindow::m_scaleY, mpID_LOCKASPECT, and mpWindow::UpdateAll().
Referenced by mpWindow::OnLockAspect().
00487 { 00488 m_lockaspect = enable; 00489 00490 m_popmenu.Check(mpID_LOCKASPECT, enable); 00491 00492 if (m_lockaspect) 00493 { 00494 double s = (m_scaleX + m_scaleY)/2; 00495 m_scaleX = s; 00496 m_scaleY = s; 00497 } 00498 00499 UpdateAll(); 00500 }
void pPlotterWindow::moveFunctions | ( | float | porcentageMinX, | |
float | porcentageMaxX | |||
) |
Definition at line 1736 of file pPlotterWindow.cxx.
References functionsToMove, pGraphicalFunction::getActual(), pGraphicalFunction::getMaxX(), pGraphicalFunction::getMaxXShowed(), pGraphicalFunction::getMaxY(), pGraphicalFunction::getMaxYShowed(), pGraphicalFunction::getMinX(), pGraphicalFunction::getMinXShowed(), pGraphicalFunction::getMinY(), pGraphicalFunction::getMinYShowed(), HISTOGRAM, mpWindow::m_popmenu, pwID_MYZOOMIN, pwID_MYZOOMOUT, mpWindow::setMaxScrX(), pGraphicalFunction::setMaxShowedX(), mpWindow::setMinScrX(), pGraphicalFunction::setMinShowedX(), pGraphicalFunction::setOffsetX(), mpWindow::setOffsetX(), and mpWindow::type.
Referenced by pPlotter::moveFunctions(), pPlotter::onEndChange_Bar(), pPlotter::onMovedBar(), and pPlotter::onStartChange_Bar().
01737 { 01738 //Adding the actual function 01739 01740 //functionsToMove.Append(actual); 01741 01742 // 01743 //float minShowed,maxShowed,fMaxXShowed,fMinXShowed; 01744 float x,y; 01745 01746 01747 int minShowed,maxShowed,fMaxXShowed,fMinXShowed; 01748 wxNode* fnode=functionsToMove.GetFirst(); 01749 while(fnode) 01750 { 01751 pGraphicalFunction* fg=(pGraphicalFunction*)fnode->GetData(); 01752 x=porcentageMaxX*(fg->getMaxX()-fg->getMinX()); 01753 y=porcentageMinX*(fg->getMaxX()-fg->getMinX()); 01754 01755 maxShowed=fg->getMinX()+ x; 01756 minShowed=fg->getMinX()+ y; 01757 01758 fMinXShowed=fg->getMinXShowed(); 01759 fMaxXShowed=fg->getMaxXShowed(); 01760 01761 if(fMinXShowed!=minShowed) 01762 { 01763 if(fg->getActual()) 01764 { 01765 setOffsetX(minShowed); 01766 setMinScrX(minShowed); 01767 } 01768 fg->setOffsetX(minShowed); 01769 fg->setMinShowedX(minShowed); 01770 } 01771 if(fMaxXShowed!=maxShowed) 01772 { 01773 if(fg->getActual()) 01774 { 01775 setMaxScrX(maxShowed); 01776 } 01777 fg->setMaxShowedX(maxShowed); 01778 } 01779 if(fg->getActual()&& (fg->getMinXShowed()!=fg->getMinX() || fg->getMinYShowed()!=fg->getMinY()|| 01780 fg->getMaxXShowed()!=fg->getMaxX() || fg->getMaxYShowed()!=fg->getMaxY())) 01781 { 01782 if(type!=HISTOGRAM) 01783 { 01784 m_popmenu.Enable(pwID_MYZOOMIN,false); 01785 m_popmenu.Enable(pwID_MYZOOMOUT,false); 01786 } 01787 } 01788 else if(fg->getActual()&& fg->getMinXShowed()==fg->getMinX() && fg->getMaxXShowed()==fg->getMaxX()) 01789 { 01790 if(type!=HISTOGRAM) 01791 { 01792 m_popmenu.Enable(pwID_MYZOOMIN,true); 01793 m_popmenu.Enable(pwID_MYZOOMOUT,true); 01794 } 01795 } 01796 01797 01798 fnode=fnode->GetNext(); 01799 } 01800 }
void pPlotterWindow::onAddNewPoint | ( | wxCommandEvent & | aEvent | ) |
Adds a point to the function after the definition of the initial points of the function know this point is a point of the function
Definition at line 787 of file pPlotterWindow.cxx.
References actual, pGraphicalFunction::AddNewPoint(), pGraphicalFunction::addSplinesPoints(), pGraphicalFunction::clearSplineVectors(), getRealPoint(), pGraphicalFunction::getType(), pGraphicalFunction::initializeSplineVectors(), mpWindow::m_clickedX, mpWindow::m_clickedY, mpWindow::m_scrY, text, and mpWindow::UpdateAll().
00788 { 00789 wxPoint point; 00790 point.x=m_clickedX; 00791 point.y=m_scrY-m_clickedY; 00792 00793 wxPoint realPoint=getRealPoint(point); 00794 bool isAValidPoint=realPoint.x>=0 && realPoint.y>=0; 00795 00796 00797 if(isAValidPoint && actual->AddNewPoint(realPoint.x,realPoint.y)) 00798 { 00799 text = wxString::Format(_T("added point ( %d, %d)\n"), realPoint.x, realPoint.y); 00800 //if the function is smooth 00801 if(actual->getType()==2) 00802 { 00803 actual->clearSplineVectors(); 00804 actual->addSplinesPoints(); 00805 actual->initializeSplineVectors(); 00806 00807 } 00808 UpdateAll(); 00809 //------------------------------------------ 00810 //Sending the event 00811 //------------------------------------------- 00812 wxCommandEvent cevent( wxEVT_PPLOTTER_POINT_ADD, GetId() ); 00813 cevent.SetEventObject(this); 00814 00815 //------------------------------------------ 00816 //Sending the general event 00817 //------------------------------------------- 00818 wxCommandEvent pevent( wxEVT_PPLOTTER, GetId() ); 00819 pevent.SetEventObject(this); 00820 //send the events 00821 GetEventHandler()->ProcessEvent( cevent ); 00822 GetEventHandler()->ProcessEvent( pevent ); 00823 00824 } 00825 }
void pPlotterWindow::onAddPoint | ( | wxMouseEvent & | aEvent | ) |
Add a new point to the function and then repaint
if the user is going to add a point to the function
Definition at line 712 of file pPlotterWindow.cxx.
References actual, pGraphicalFunction::AddNewPoint(), pGraphicalFunction::AddPoint(), pGraphicalFunction::addSplinesPoints(), pGraphicalFunction::clearSplineVectors(), drawing, getRealPoint(), pGraphicalFunction::getType(), pGraphicalFunction::initializeSplineVectors(), mpWindow::m_scrY, movingPointIndex, movingPoints, text, mpWindow::UpdateAll(), and pGraphicalFunction::validPointOnFunction().
00713 { 00714 00715 wxPoint point=aEvent.GetPosition(); 00716 00717 point.y=m_scrY-point.y; 00718 wxPoint realPoint=getRealPoint(point); 00719 00720 bool isAValidPoint=realPoint.x>=0 && realPoint.y>=0; 00721 00722 if(isAValidPoint && drawing) 00723 { 00724 if(actual->AddPoint(realPoint.x,realPoint.y)) 00725 { 00726 text = wxString::Format(_T("added point ( %d, %d)\n"), realPoint.x, realPoint.y); 00727 00728 //m_log->AppendText(text); 00729 00730 //if the function is smooth 00731 if(actual->getType()==2) 00732 { 00733 actual->clearSplineVectors(); 00734 actual->addSplinesPoints(); 00735 actual->initializeSplineVectors(); 00736 } 00737 00738 UpdateAll(); 00739 } 00740 } 00741 else if(isAValidPoint && !drawing && aEvent.m_shiftDown && actual!=NULL) 00742 { 00743 if(actual->AddNewPoint(realPoint.x,realPoint.y)) 00744 { 00745 text = wxString::Format(_T("added point ( %d, %d)\n"), realPoint.x, realPoint.y); 00746 //if the function is smooth 00747 if(actual->getType()==2) 00748 { 00749 actual->clearSplineVectors(); 00750 actual->addSplinesPoints(); 00751 actual->initializeSplineVectors(); 00752 } 00753 00754 UpdateAll(); 00755 } 00756 } 00757 //made a click for moving the points 00758 else if(!movingPoints) 00759 { 00760 if(actual) 00761 movingPointIndex=actual->validPointOnFunction(realPoint); 00762 if(movingPointIndex>=0) 00763 movingPoints=true; 00764 } 00765 00766 //------------------------------------------ 00767 //Sending the event 00768 //------------------------------------------- 00769 wxCommandEvent cevent( wxEVT_PPLOTTER_POINT_ADD, GetId() ); 00770 cevent.SetEventObject(this); 00771 00772 //------------------------------------------ 00773 //Sending the general event 00774 //------------------------------------------- 00775 wxCommandEvent pevent( wxEVT_PPLOTTER, GetId() ); 00776 pevent.SetEventObject(this); 00777 //send the events 00778 GetEventHandler()->ProcessEvent( cevent ); 00779 GetEventHandler()->ProcessEvent( pevent ); 00780 }
void mpWindow::OnCenter | ( | wxCommandEvent & | event | ) | [protected, inherited] |
Context menu handler.
Definition at line 519 of file mathplot.cxx.
References mpWindow::m_clickedX, mpWindow::m_clickedY, mpWindow::m_posX, mpWindow::m_posY, mpWindow::m_scaleX, mpWindow::m_scaleY, and mpWindow::SetPos().
00520 { 00521 int cx, cy; 00522 GetClientSize(&cx, &cy); 00523 SetPos( (double)(m_clickedX-cx/2) / m_scaleX + m_posX, (double)(cy/2-m_clickedY) / m_scaleY + m_posY); 00524 }
void pPlotterWindow::onChangeActual | ( | wxMouseEvent & | event | ) |
Listens the event mouse left button double click. if the user give us a double click is because he wants to change the actual function to the function that has that point
if the user give us a double click is because he wants to change the actual function to the function that has that point
Definition at line 1175 of file pPlotterWindow.cxx.
References actual, pGraphicalFunction::addSplinesPoints(), pGraphicalFunction::clearSplineVectors(), drawing, functions, pGraphicalFunction::getActual(), pGraphicalFunction::getEditable(), pGraphicalFunction::getFromWindow(), pGraphicalFunction::getMaxXShowed(), pGraphicalFunction::getMaxYShowed(), pGraphicalFunction::getMinXShowed(), pGraphicalFunction::getMinYShowed(), pGraphicalFunction::getOffsetPixelsX(), pGraphicalFunction::getOffsetPixelsY(), pGraphicalFunction::getOffsetX(), pGraphicalFunction::getOffsetY(), pGraphicalFunction::getShowPoints(), pGraphicalFunction::getType(), pGraphicalFunction::initializeSplineVectors(), pGraphicalFunction::isInFunction(), mpWindow::m_popmenu, mpWindow::m_scrX, mpWindow::m_scrY, mpID_LINE_GUIDES, pwID_ADDNEWPOINT, pwID_CHANGECOLOR, pwID_DELPOINT, pwID_LINE, pwID_LOAD, pwID_MYZOOMIN, pwID_MYZOOMOUT, pwID_NOSHOWPOINTS, pwID_SAVE, pwID_SHOWPOINTS, pwID_SPLINE, pwID_STARTDRAWING, pwID_STOPDRAWING, pwID_TRASLATEACTUALFUNCTION, setActualFunction(), setActualScales(), mpWindow::setOffsetPixelX(), mpWindow::setOffsetPixelY(), mpWindow::setOffsetX(), mpWindow::setOffsetY(), text, mpWindow::type, mpWindow::UpdateAll(), and mpWindow::zoomFactor.
01176 { 01177 wxString text = _T("\n points \n"); 01178 01179 01180 if(!drawing) 01181 { 01182 //we have to call showpoints before changing the function 01183 wxPoint point=event.GetPosition(); 01184 /*****************************/ 01185 point.y=m_scrY-point.y; 01186 /*****************************/ 01187 01188 01189 01190 //real point on the function 01191 wxPoint realPoint;//=getRealPoint(point); 01192 bool isAValidPoint=realPoint.x>=0 && realPoint.y>=0; 01193 if(isAValidPoint) 01194 { 01195 wxNode * node= functions.GetFirst(); 01196 while (node) 01197 { 01198 pGraphicalFunction* fnode=(pGraphicalFunction*)node->GetData(); 01199 01200 01201 int maxX=fnode->getMaxXShowed(); 01202 int maxY=fnode->getMaxYShowed(); 01203 int minX=fnode->getMinXShowed(); 01204 int minY=fnode->getMinYShowed(); 01205 01206 01207 /* 01208 float sx=(((float)m_scrX-100)/(maxScrX-minScrX))*zoomFactor; 01209 float sy=(((float)m_scrY-50)/(maxScrY-minScrY))*zoomFactor; 01210 */ 01211 01212 01213 float sx=(((float)m_scrX-100)/(maxX-minX))*zoomFactor; 01214 float sy=(((float)m_scrY-50)/(maxY-minY))*zoomFactor; 01215 01216 01217 realPoint.x=((point.x-70-fnode->getOffsetPixelsX())/sx)+ fnode->getOffsetX()+ minX; 01218 realPoint.y=((point.y-40-fnode->getOffsetPixelsY())/sy)+ fnode->getOffsetY()+ minY; 01219 /* 01220 LOG 01221 */ 01222 if(fnode->getActual()) 01223 text = wxString::Format(_T("Selected point ( %d, %d)\n"), realPoint.x, realPoint.y); 01224 //m_log->AppendText(text); 01225 01226 bool hasIt=fnode->isInFunction(realPoint.x,realPoint.y); 01227 /* 01228 if(fnode->getEditable()) 01229 hasIt=fnode->isInFunction(realPoint.x,realPoint.y); 01230 else 01231 hasIt=false; 01232 */ 01233 if(hasIt) 01234 { 01235 if(actual!=fnode) 01236 { 01237 setActualFunction(fnode); 01238 //we change the offsets 01239 setOffsetPixelX(fnode->getOffsetPixelsX()); 01240 setOffsetPixelY(fnode->getOffsetPixelsY()); 01241 setOffsetX(fnode->getOffsetX()); 01242 setOffsetY(fnode->getOffsetY()); 01243 01244 01245 setActualScales(); 01246 if(!actual->getFromWindow() && actual->getEditable()||actual->getFromWindow() && actual->getEditable()) 01247 { 01248 m_popmenu.Enable(pwID_ADDNEWPOINT,true); 01249 m_popmenu.Enable(pwID_DELPOINT,true); 01250 if(actual->getShowPoints()) 01251 { 01252 m_popmenu.Enable(pwID_SHOWPOINTS,false); 01253 m_popmenu.Enable(pwID_NOSHOWPOINTS,true); 01254 } 01255 else 01256 { 01257 m_popmenu.Enable(pwID_SHOWPOINTS,true); 01258 m_popmenu.Enable(pwID_NOSHOWPOINTS,false); 01259 } 01260 m_popmenu.Enable(pwID_MYZOOMIN,true); 01261 m_popmenu.Enable(pwID_MYZOOMOUT,true); 01262 if(actual->getType()==2)//Smoothed function 01263 { 01264 m_popmenu.Enable(pwID_SPLINE,false); 01265 m_popmenu.Enable(pwID_LINE,true); 01266 } 01267 else 01268 { 01269 m_popmenu.Enable(pwID_SPLINE,true); 01270 m_popmenu.Enable(pwID_LINE,false); 01271 01272 } 01273 if(type==2) 01274 { 01275 m_popmenu.Enable(pwID_LOAD,false); 01276 m_popmenu.Enable(pwID_STARTDRAWING,false); 01277 } 01278 else 01279 { 01280 m_popmenu.Enable(pwID_LOAD,true); 01281 m_popmenu.Enable(pwID_STARTDRAWING,true); 01282 } 01283 01284 m_popmenu.Enable(pwID_SAVE,true); 01285 m_popmenu.Enable(pwID_LOAD,false); 01286 m_popmenu.Enable(pwID_STOPDRAWING,false); 01287 m_popmenu.Enable(pwID_CHANGECOLOR,true); 01288 m_popmenu.Enable(mpID_LINE_GUIDES,true); 01289 m_popmenu.Enable(pwID_TRASLATEACTUALFUNCTION,true); 01290 } 01291 //for the functions that came from data and arent editables 01292 else if(!actual->getFromWindow() && !actual->getEditable()||actual->getFromWindow() && !actual->getEditable()) 01293 { 01294 if(actual->getShowPoints()) 01295 { 01296 m_popmenu.Enable(pwID_SHOWPOINTS,false); 01297 m_popmenu.Enable(pwID_NOSHOWPOINTS,true); 01298 } 01299 else 01300 { 01301 m_popmenu.Enable(pwID_SHOWPOINTS,true); 01302 m_popmenu.Enable(pwID_NOSHOWPOINTS,false); 01303 } 01304 if(actual->getType()==2)//Smoothed function 01305 { 01306 m_popmenu.Enable(pwID_SPLINE,false); 01307 m_popmenu.Enable(pwID_LINE,true); 01308 } 01309 else 01310 { 01311 m_popmenu.Enable(pwID_SPLINE,true); 01312 m_popmenu.Enable(pwID_LINE,false); 01313 01314 } 01315 if(type==2) 01316 { 01317 m_popmenu.Enable(pwID_LOAD,false); 01318 m_popmenu.Enable(pwID_STARTDRAWING,false); 01319 } 01320 m_popmenu.Enable(pwID_SAVE,false); 01321 m_popmenu.Enable(pwID_LOAD,false); 01322 m_popmenu.Enable(pwID_STOPDRAWING,false); 01323 m_popmenu.Enable(pwID_MYZOOMIN,true); 01324 m_popmenu.Enable(pwID_MYZOOMOUT,true); 01325 m_popmenu.Enable(pwID_CHANGECOLOR,true); 01326 m_popmenu.Enable(mpID_LINE_GUIDES,true); 01327 m_popmenu.Enable(pwID_SAVE,true); 01328 m_popmenu.Enable(pwID_TRASLATEACTUALFUNCTION,true); 01329 01330 } 01331 //if the function is smooth 01332 if(actual->getType()==2) 01333 { 01334 actual->clearSplineVectors(); 01335 actual->addSplinesPoints(); 01336 actual->initializeSplineVectors(); 01337 01338 } 01339 01340 UpdateAll(); 01341 //------------------------------------------ 01342 //Sending the particular event 01343 //------------------------------------------- 01344 wxCommandEvent cevent( wxEVT_PPLOTTER_CHANGED_FUNCTION, GetId() ); 01345 cevent.SetEventObject(this); 01346 01347 //------------------------------------------ 01348 //Sending the general event 01349 //------------------------------------------- 01350 wxCommandEvent pevent( wxEVT_PPLOTTER, GetId() ); 01351 pevent.SetEventObject(this); 01352 //send the events 01353 GetEventHandler()->ProcessEvent( cevent ); 01354 GetEventHandler()->ProcessEvent( pevent ); 01355 } 01356 } 01357 node=node->GetNext(); 01358 } 01359 } 01360 } 01361 //the user is finishing the drawing of the function 01362 else 01363 { 01364 drawing=false; 01365 functions.Append(actual); 01366 } 01367 }
void pPlotterWindow::onChangeColor | ( | wxCommandEvent & | aEvent | ) |
Change the color of the function
Definition at line 285 of file pPlotterWindow.cxx.
References actual, mpLayer::SetPen(), and mpWindow::UpdateAll().
00286 { 00287 00288 wxColour colour; 00289 wxColourData data; 00290 wxColourDialog dialog(this, &data); 00291 00292 if ( dialog.ShowModal() == wxID_OK ) 00293 { 00294 colour = dialog.GetColourData().GetColour(); 00295 } 00296 00297 wxPen mypen(colour); 00298 mypen.SetWidth(2); 00299 actual->SetPen( mypen); 00300 UpdateAll(); 00301 }
void pPlotterWindow::onDeletePoint | ( | wxCommandEvent & | aEvent | ) |
Deletes a point of the function and then repaint
if the user is going to delete a point of the function
Definition at line 830 of file pPlotterWindow.cxx.
References actual, pGraphicalFunction::addSplinesPoints(), pGraphicalFunction::clearSplineVectors(), pGraphicalFunction::deletePointAt(), getRealPoint(), pGraphicalFunction::getSizePoints(), pGraphicalFunction::getType(), pGraphicalFunction::initializeSplineVectors(), mpWindow::m_clickedX, mpWindow::m_clickedY, mpWindow::m_scrY, setActualScales(), text, mpWindow::UpdateAll(), and pGraphicalFunction::validPointOnFunction().
00831 { 00832 wxPoint point; 00833 point.x=m_clickedX; 00834 point.y=m_scrY-m_clickedY; 00835 00836 //actual->setScreenX(m_scrX); 00837 //actual->setScreenY(m_scrY); 00838 00839 wxPoint realPoint=getRealPoint(point); 00840 00841 bool isAValidPoint=realPoint.x>=0 && realPoint.y>=0; 00842 00843 //this method verify a sensible region in every point of actual 00844 int pointIndex=actual->validPointOnFunction(realPoint); 00845 if(isAValidPoint && actual->deletePointAt(pointIndex)) 00846 { 00847 setActualScales(); 00848 if(actual->getSizePoints()==0) 00849 { 00850 //functions.DeleteObject(actual); 00851 //DelLayer(actual); 00852 //actual=NULL; 00853 } 00854 //if the function is smooth 00855 if(actual->getType()==2) 00856 { 00857 actual->clearSplineVectors(); 00858 actual->addSplinesPoints(); 00859 actual->initializeSplineVectors(); 00860 00861 } 00862 text = wxString::Format(_T("deleted point ( %d, %d)\n"), realPoint.x, realPoint.y); 00863 UpdateAll(); 00864 //------------------------------------------ 00865 //Sending the event 00866 //------------------------------------------- 00867 wxCommandEvent cevent( wxEVT_PPLOTTER_POINT_DELETE, GetId() ); 00868 cevent.SetEventObject(this); 00869 //------------------------------------------ 00870 //Sending the general event 00871 //------------------------------------------- 00872 wxCommandEvent pevent( wxEVT_PPLOTTER, GetId() ); 00873 pevent.SetEventObject(this); 00874 //send the events 00875 GetEventHandler()->ProcessEvent( cevent ); 00876 GetEventHandler()->ProcessEvent( pevent ); 00877 } 00878 }
void mpWindow::OnFit | ( | wxCommandEvent & | event | ) | [protected, inherited] |
Context menu handler.
Definition at line 514 of file mathplot.cxx.
References mpWindow::Fit().
00515 { 00516 Fit(); 00517 }
void pPlotterWindow::OnGuideLines | ( | wxCommandEvent & | event | ) |
Definition at line 1686 of file pPlotterWindow.cxx.
References mpWindow::drawGuides, mpWindow::m_popmenu, mpID_LINE_GUIDES, setLineGuidesCondition(), and mpWindow::UpdateAll().
01687 { 01688 wxString nextAction_text; 01689 if( drawGuides ) 01690 { 01691 setLineGuidesCondition(false); 01692 // nextAction_text << "Turn on guide lines"; 01693 nextAction_text = _T("Turn on guide lines"); 01694 UpdateAll(); 01695 } 01696 else 01697 { 01698 setLineGuidesCondition(true); 01699 // nextAction_text << "Turn off guide lines"; 01700 nextAction_text = _T("Turn off guide lines"); 01701 UpdateAll(); 01702 } 01703 //------------------------------------------ 01704 //Sending the paarticular event of changed actual function 01705 //------------------------------------------- 01706 wxCommandEvent cevent( wxEVT_PPLOTTER_GUIDELINES, GetId() ); 01707 cevent.SetEventObject(this); 01708 GetEventHandler()->ProcessEvent( cevent ); 01709 01710 //SETTING LABEL 01711 m_popmenu.SetLabel ( mpID_LINE_GUIDES, nextAction_text ); 01712 }
void pPlotterWindow::onLeftUp | ( | wxMouseEvent & | event | ) |
Definition at line 248 of file pPlotterWindow.cxx.
References movingPointIndex, and movingPoints.
00249 { 00250 movingPoints=false; 00251 movingPointIndex=-1; 00252 }
void pPlotterWindow::onLine | ( | wxCommandEvent & | aEvent | ) |
Change the type of drawing of the actual function to a piecewise function
Definition at line 375 of file pPlotterWindow.cxx.
References actual, pGraphicalFunction::clearSplineVectors(), mpWindow::m_popmenu, pwID_LINE, pwID_SPLINE, pGraphicalFunction::setType(), and mpWindow::UpdateAll().
00376 { 00377 actual->clearSplineVectors(); 00378 actual->setType(1); 00379 UpdateAll(); 00380 m_popmenu.Enable(pwID_SPLINE,true); 00381 m_popmenu.Enable(pwID_LINE,false); 00382 00383 }
void pPlotterWindow::onLoad | ( | wxCommandEvent & | aEvent | ) |
Load the function from a .txt file
Definition at line 312 of file pPlotterWindow.cxx.
References actual, addFunctionToMove(), mpWindow::AddLayer(), drawing, functions, pGraphicalFunction::load(), mpWindow::m_popmenu, mpALIGN_NE, pwID_STARTDRAWING, pGraphicalFunction::setActual(), pGraphicalFunction::SetDrawing(), pGraphicalFunction::setFactorZoom(), pGraphicalFunction::setFromWindow(), mpLayer::SetPen(), mpWindow::UpdateAll(), and mpWindow::zoomFactor.
00313 { 00314 00315 actual=new pGraphicalFunction(wxT("f(x) = function1(x)"),mpALIGN_NE); 00316 actual->setActual(true); 00317 actual->setFromWindow(false); 00318 actual->SetDrawing(drawing); 00319 actual->setFactorZoom(zoomFactor); 00320 00321 wxPen mypen(*wxRED, 5, wxSOLID); 00322 mypen.SetWidth(2); 00323 actual->SetPen( mypen); 00324 00325 wxString nameF=wxFileSelector(_T("Save Function")); 00326 actual->load(nameF); 00327 AddLayer(actual); 00328 00329 functions.Append(actual); 00330 addFunctionToMove(actual); 00331 00332 m_popmenu.Enable(pwID_STARTDRAWING,true); 00333 00334 UpdateAll(); 00335 00336 //------------------------------------------ 00337 //Sending the paarticular event of changed actual function 00338 //------------------------------------------- 00339 wxCommandEvent cevent( wxEVT_PPLOTTER_CHANGED_FUNCTION, GetId() ); 00340 cevent.SetEventObject(this); 00341 GetEventHandler()->ProcessEvent( cevent ); 00342 }
void mpWindow::OnLockAspect | ( | wxCommandEvent & | event | ) | [protected, inherited] |
Context menu handler.
Definition at line 509 of file mathplot.cxx.
References mpWindow::LockAspect(), mpWindow::m_popmenu, and mpID_LOCKASPECT.
00510 { 00511 LockAspect( !m_popmenu.IsChecked(mpID_LOCKASPECT) ); 00512 }
void pPlotterWindow::onMouseMove | ( | wxMouseEvent & | event | ) |
Listens the event of the mouse when it is moving, this is use to know if the user is moving a pont of the function and in tha way to know when repainting.
If the mouse is moving in the plot area is because the user is moving a point of the current curve the user has to call before show points, to see the points of the function
Definition at line 888 of file pPlotterWindow.cxx.
References actual, pGraphicalFunction::addSplinesPoints(), backUpActualVector, pGraphicalFunction::changePoint(), pGraphicalFunction::clearSplineVectors(), drawing, pGraphicalFunction::getEditable(), pGraphicalFunction::GetPointAt(), getRealPoint(), pFunctionPoint::getRealX(), pGraphicalFunction::getSizePoints(), pGraphicalFunction::getType(), HISTOGRAM, pGraphicalFunction::initializeSplineVectors(), initialMovingCLick, pGraphicalFunction::isInFunction(), mpWindow::m_scrX, mpWindow::m_scrY, movingFunction, movingPointIndex, movingPoints, setActualScales(), pGraphicalFunction::SetMousePoint(), pFunctionPoint::setRealX(), pGraphicalFunction::setScreenX(), pGraphicalFunction::setScreenY(), text, mpWindow::type, mpWindow::UpdateAll(), and pGraphicalFunction::validPointOnFunction().
00889 { 00890 wxPoint point=event.GetPosition(); 00891 bool change=false; 00892 point.y=m_scrY-point.y; 00893 00894 wxPoint realPoint=getRealPoint(point); 00895 bool isAValidPoint=realPoint.x>=0 && realPoint.y>=0; 00896 00897 if(isAValidPoint && !drawing && actual!=NULL && !movingFunction && movingPoints) 00898 { 00899 //never is going to get in 00900 if(movingPointIndex==-1) 00901 { 00902 //this method verify a sensible region in every point of _actualFunction 00903 movingPointIndex=actual->validPointOnFunction(realPoint); 00904 00905 } 00906 else if(event.LeftIsDown()) 00907 { 00908 00909 /*if((movingPointIndex-1)>=0 && (movingPointIndex+1)<actual->getSizePoints() && actual->getEditable()) 00910 { 00911 wxNode* next= actual->GetPointAt(movingPointIndex+1); 00912 wxNode* before=actual->GetPointAt(movingPointIndex-1); 00913 if(next) 00914 { 00915 pFunctionPoint* np=(pFunctionPoint*)(next->GetData()); 00916 if(np) 00917 { 00918 int n=np->getRealX(); 00919 if(realPoint.x>n) 00920 { 00921 wxPoint p; 00922 p.x=np->getRealX()-1; 00923 p.y=realPoint.y; 00924 change=actual->changePoint(p,movingPointIndex); 00925 if(change) 00926 { 00927 setActualScales(); 00928 00929 //if the function is smooth 00930 if(actual->getType()==2) 00931 { 00932 actual->clearSplineVectors(); 00933 actual->addSplinesPoints(); 00934 actual->initializeSplineVectors(); 00935 00936 } 00937 00938 text = wxString::Format(_T("Moved point ( %d, %d)\n"), p.x, p.y); 00939 UpdateAll(); 00940 //------------------------------------------ 00941 //Sending the particular event 00942 //------------------------------------------- 00943 wxCommandEvent cevent( wxEVT_PPLOTTER_POINT_MOVE, GetId() ); 00944 cevent.SetEventObject(this); 00945 00946 //------------------------------------------ 00947 //Sending the general event 00948 //------------------------------------------- 00949 wxCommandEvent pevent( wxEVT_PPLOTTER, GetId() ); 00950 pevent.SetEventObject(this); 00951 00952 //send the events 00953 GetEventHandler()->ProcessEvent( cevent ); 00954 GetEventHandler()->ProcessEvent( pevent ); 00955 } 00956 } 00957 } 00958 } 00959 if(before) 00960 { 00961 pFunctionPoint* bp=(pFunctionPoint*)(before->GetData()); 00962 if(bp) 00963 { 00964 int b=bp->getRealX(); 00965 if(realPoint.x<b) 00966 { 00967 wxPoint p; 00968 p.x=bp->getRealX()+1; 00969 p.y=realPoint.y; 00970 change=actual->changePoint(p,movingPointIndex); 00971 if(change) 00972 { 00973 setActualScales(); 00974 //if the function is smooth 00975 if(actual->getType()==2) 00976 { 00977 actual->clearSplineVectors(); 00978 actual->addSplinesPoints(); 00979 actual->initializeSplineVectors(); 00980 00981 } 00982 text = wxString::Format(_T("Moved point ( %d, %d)\n"), p.x, p.y); 00983 UpdateAll(); 00984 //------------------------------------------ 00985 //Sending the particular event 00986 //------------------------------------------- 00987 wxCommandEvent cevent( wxEVT_PPLOTTER_POINT_MOVE, GetId() ); 00988 cevent.SetEventObject(this); 00989 00990 //------------------------------------------ 00991 //Sending the general event 00992 //------------------------------------------- 00993 wxCommandEvent pevent( wxEVT_PPLOTTER, GetId() ); 00994 pevent.SetEventObject(this); 00995 00996 //send the events 00997 GetEventHandler()->ProcessEvent( cevent ); 00998 GetEventHandler()->ProcessEvent( pevent ); 00999 } 01000 01001 } 01002 } 01003 } 01004 } */ 01005 // SIL ******************************************************************* // SIL 01006 if((movingPointIndex-1)>=0 && (movingPointIndex+1)<actual->getSizePoints() && actual->getEditable()) 01007 { 01008 change=actual->changePoint(realPoint,movingPointIndex); 01009 } 01010 if(change) 01011 { 01012 setActualScales(); 01013 //if the function is smooth 01014 if(actual->getType()==2) 01015 { 01016 actual->clearSplineVectors(); 01017 actual->addSplinesPoints(); 01018 actual->initializeSplineVectors(); 01019 } 01020 text = wxString::Format(_T("Moved point ( %d, %d)\n"), realPoint.x, realPoint.y); 01021 UpdateAll(); 01022 //------------------------------------------ 01023 //Sending the particular event 01024 //------------------------------------------- 01025 wxCommandEvent cevent( wxEVT_PPLOTTER_POINT_MOVE, GetId() ); 01026 cevent.SetEventObject(this); 01027 01028 //------------------------------------------ 01029 //Sending the general event 01030 //------------------------------------------- 01031 wxCommandEvent pevent( wxEVT_PPLOTTER, GetId() ); 01032 pevent.SetEventObject(this); 01033 01034 //send the events 01035 GetEventHandler()->ProcessEvent( cevent ); 01036 GetEventHandler()->ProcessEvent( pevent ); 01037 } 01038 // SIL ******************************************************************* // SIL 01039 01040 //change the point that is in the index, returns true if could be changed. 01041 if(!change && actual->changePoint(realPoint,movingPointIndex)&& actual->getEditable()) 01042 { 01043 setActualScales(); 01044 //if the function is smooth 01045 if(actual->getType()==2) 01046 { 01047 actual->clearSplineVectors(); 01048 actual->addSplinesPoints(); 01049 actual->initializeSplineVectors(); 01050 01051 } 01052 text = wxString::Format(_T("Moved point ( %d, %d)\n"), realPoint.x,realPoint.y); 01053 01054 UpdateAll(); 01055 01056 //------------------------------------------ 01057 //Sending the particular event 01058 //------------------------------------------- 01059 wxCommandEvent cevent( wxEVT_PPLOTTER_POINT_MOVE, GetId() ); 01060 cevent.SetEventObject(this); 01061 01062 //------------------------------------------ 01063 //Sending the general event 01064 //------------------------------------------- 01065 wxCommandEvent pevent( wxEVT_PPLOTTER, GetId() ); 01066 pevent.SetEventObject(this); 01067 01068 //send the events 01069 GetEventHandler()->ProcessEvent( cevent ); 01070 GetEventHandler()->ProcessEvent( pevent ); 01071 } 01072 } 01073 else 01074 { 01075 movingPointIndex=-1; 01076 movingPoints=false; 01077 } 01078 } 01079 //if the user is drawing 01080 else if(isAValidPoint && drawing) 01081 { 01082 01083 actual->SetMousePoint(realPoint); 01084 UpdateAll(); 01085 } 01086 //is moving the function 01087 else if(isAValidPoint && movingFunction && actual!=NULL) 01088 { 01089 actual->setScreenX(m_scrX); 01090 actual->setScreenY(m_scrY); 01091 //int j=0; // JPRx 01092 if((initialMovingCLick==-1) && event.LeftIsDown() ) 01093 { 01094 if(actual->isInFunction(realPoint.x,realPoint.y)) 01095 { 01096 initialMovingCLick=event.GetPosition().x; 01097 int numPoints=actual->getSizePoints(); 01098 int i=0; 01099 backUpActualVector.clear(); 01100 while(i<numPoints) 01101 { 01102 //if(i>0 && i< (numPoints-1)) 01103 //{ 01104 wxNode* pointNode=actual->GetPointAt(i); 01105 pFunctionPoint* point= (pFunctionPoint*)pointNode->GetData(); 01106 backUpActualVector.push_back(point->getRealX()); 01107 01108 //} 01109 i++; 01110 } 01111 } 01112 } 01113 else if(event.LeftIsDown()) 01114 { 01115 wxPoint aux(initialMovingCLick,0); 01116 01117 wxPoint p1r=getRealPoint(event.GetPosition()); 01118 wxPoint p2r=getRealPoint(aux); 01119 01120 double delta = p1r.x-p2r.x; 01121 int numPoints=actual->getSizePoints(); 01122 int i=0; 01123 wxPoint p; 01124 if(type==HISTOGRAM) 01125 { 01126 while(i<numPoints) 01127 { 01128 if(i>0 && i<(numPoints-1)) 01129 { 01130 wxNode* pointNode=actual->GetPointAt(i); 01131 pFunctionPoint* point= (pFunctionPoint*)pointNode->GetData(); 01132 int xNew=backUpActualVector[i]+delta; 01133 //it has to preserve the state of functin 01134 if(backUpActualVector[0]<xNew && backUpActualVector[numPoints-1]>xNew) 01135 point->setRealX(xNew); 01136 } 01137 i++; 01138 } 01139 } 01140 else 01141 { 01142 i=0; 01143 while(i<numPoints) 01144 { 01145 01146 wxNode* pointNode=actual->GetPointAt(i); 01147 pFunctionPoint* point= (pFunctionPoint*)pointNode->GetData(); 01148 int xNew=backUpActualVector[i]+delta; 01149 point->setRealX(xNew); 01150 i++; 01151 } 01152 } 01153 //If is a spline 01154 if(actual->getType()==2) 01155 { 01156 actual->clearSplineVectors(); 01157 actual->addSplinesPoints(); 01158 actual->initializeSplineVectors(); 01159 01160 } 01161 UpdateAll(); 01162 01163 } 01164 else 01165 { 01166 initialMovingCLick=-1; 01167 } 01168 01169 } 01170 }
void pPlotterWindow::onMoveFunction | ( | wxCommandEvent & | aEvent | ) |
Definition at line 263 of file pPlotterWindow.cxx.
References mpWindow::m_popmenu, movingFunction, and pwID_TRASLATEACTUALFUNCTION.
00264 { 00265 if(movingFunction) 00266 { 00267 movingFunction=false; 00268 m_popmenu.SetLabel(pwID_TRASLATEACTUALFUNCTION, _("Start Moving Function")); 00269 } 00270 else 00271 { 00272 movingFunction=true; 00273 m_popmenu.SetLabel(pwID_TRASLATEACTUALFUNCTION, _("Stop Moving Function")); 00274 } 00275 }
void pPlotterWindow::onMyZoomIn | ( | wxCommandEvent & | aEvent | ) |
Zoom in the functions
Definition at line 437 of file pPlotterWindow.cxx.
References functions, pGraphicalFunction::getActual(), pGraphicalFunction::getOffsetPixelsX(), pGraphicalFunction::getOffsetPixelsY(), pGraphicalFunction::getOffsetX(), pGraphicalFunction::getOffsetY(), mpWindow::m_clickedX, mpWindow::m_clickedY, mpWindow::m_scrX, mpWindow::m_scrY, pGraphicalFunction::setFactorZoom(), mpWindow::setOffsetPixelX(), pGraphicalFunction::setOffsetPixelX(), mpWindow::setOffsetPixelY(), pGraphicalFunction::setOffsetPixelY(), pGraphicalFunction::setOffsets(), mpWindow::setOffsetX(), pGraphicalFunction::setOffsetX(), mpWindow::setOffsetY(), pGraphicalFunction::setOffsetY(), pGraphicalFunction::setScreenX(), pGraphicalFunction::setScreenY(), mpWindow::UpdateAll(), ZOOM_FACTOR, and mpWindow::zoomFactor.
00438 { 00439 00440 zoomFactor=zoomFactor*(float)ZOOM_FACTOR; 00441 wxNode* node=functions.GetFirst(); 00442 while(node) 00443 { 00444 pGraphicalFunction* f= (pGraphicalFunction*)node->GetData(); 00445 if(zoomFactor > 1.01) 00446 { 00447 f->setScreenX(m_scrX); 00448 f->setScreenY(m_scrY); 00449 f->setOffsets(m_clickedX-70,m_scrY-m_clickedY-40); 00450 f->setFactorZoom(zoomFactor); 00451 } 00452 else 00453 { 00454 f->setOffsetPixelX(0); 00455 f->setOffsetPixelY(0); 00456 f->setOffsetX(0); 00457 f->setOffsetY(0); 00458 f->setFactorZoom(zoomFactor); 00459 } 00460 if(f->getActual()) 00461 { 00462 //TODO: send an event of resize 00463 //setMinScrX(f->getMinXShowed()); 00464 //setMinScrY(f->getMinYShowed()); 00465 setOffsetPixelX(f->getOffsetPixelsX()); 00466 setOffsetPixelY(f->getOffsetPixelsY()); 00467 setOffsetX(f->getOffsetX()); 00468 setOffsetY(f->getOffsetY()); 00469 00470 } 00471 00472 node=node->GetNext(); 00473 } 00474 00475 UpdateAll(); 00476 }
void pPlotterWindow::onMyZoomOut | ( | wxCommandEvent & | aEvent | ) |
Zoom out the functions
Definition at line 392 of file pPlotterWindow.cxx.
References functions, pGraphicalFunction::getActual(), pGraphicalFunction::getOffsetPixelsX(), pGraphicalFunction::getOffsetPixelsY(), pGraphicalFunction::getOffsetX(), pGraphicalFunction::getOffsetY(), mpWindow::m_clickedX, mpWindow::m_clickedY, mpWindow::m_scrX, mpWindow::m_scrY, pGraphicalFunction::setFactorZoom(), mpWindow::setOffsetPixelX(), pGraphicalFunction::setOffsetPixelX(), mpWindow::setOffsetPixelY(), pGraphicalFunction::setOffsetPixelY(), pGraphicalFunction::setOffsets(), mpWindow::setOffsetX(), pGraphicalFunction::setOffsetX(), mpWindow::setOffsetY(), pGraphicalFunction::setOffsetY(), pGraphicalFunction::setScreenX(), pGraphicalFunction::setScreenY(), mpWindow::UpdateAll(), ZOOM_FACTOR, and mpWindow::zoomFactor.
00393 { 00394 wxNode* node=functions.GetFirst(); 00395 zoomFactor=zoomFactor*(float)(1/(float)ZOOM_FACTOR); 00396 while(node) 00397 { 00398 pGraphicalFunction* f= (pGraphicalFunction*)node->GetData(); 00399 00400 f->setScreenX(m_scrX); 00401 f->setScreenY(m_scrY); 00402 00403 00404 if(zoomFactor>1.01) 00405 { 00406 f->setOffsets(m_clickedX-70,m_scrY-m_clickedY-40); 00407 f->setFactorZoom(zoomFactor); 00408 } 00409 00410 else 00411 { 00412 f->setOffsetPixelX(0); 00413 f->setOffsetPixelY(0); 00414 f->setOffsetX(0); 00415 f->setOffsetY(0); 00416 f->setFactorZoom(zoomFactor); 00417 } 00418 00419 00420 if(f->getActual()) 00421 { 00422 //TODO: send a event of resize 00423 //setMinScrX(f->getMinXShowed()); 00424 //setMinScrY(f->getMinYShowed()); 00425 setOffsetPixelX(f->getOffsetPixelsX()); 00426 setOffsetPixelY(f->getOffsetPixelsY()); 00427 setOffsetX(f->getOffsetX()); 00428 setOffsetY(f->getOffsetY()); 00429 } 00430 node=node->GetNext(); 00431 } 00432 UpdateAll(); 00433 }
void pPlotterWindow::onNoShowPoints | ( | wxCommandEvent & | aEvent | ) |
The user doesnt want see the points of the function
Definition at line 702 of file pPlotterWindow.cxx.
References actual, mpWindow::m_popmenu, pwID_NOSHOWPOINTS, pwID_SHOWPOINTS, pGraphicalFunction::SetShowPoints(), and mpWindow::UpdateAll().
00703 { 00704 actual->SetShowPoints(false); 00705 m_popmenu.Enable(pwID_NOSHOWPOINTS,false); 00706 m_popmenu.Enable(pwID_SHOWPOINTS,true); 00707 UpdateAll(); 00708 }
void mpWindow::OnPaint | ( | wxPaintEvent & | event | ) | [protected, inherited] |
Paint handler, will plot all attached layers.
Definition at line 564 of file mathplot.cxx.
References mpWindow::_bitmap_functions, mpWindow::m_layers, mpWindow::m_scrX, and mpWindow::m_scrY.
00565 { 00566 wxPaintDC dc(this); 00567 dc.GetSize(&m_scrX, &m_scrY); 00568 printf("EED mpWindow::OnPaint %d %d\n",m_scrX,m_scrY); 00569 00570 //m_scrX=200; 00571 //m_scrY=200; 00572 00573 wxMemoryDC temp_dc; 00574 //_bitmap_functions->SetWidth(m_scrX); 00575 //_bitmap_functions->SetHeight(m_scrY); 00576 _bitmap_functions=new wxBitmap(m_scrX,m_scrY); 00577 temp_dc.SelectObject(*_bitmap_functions); 00578 00579 // Background 00580 // wxColour colourParent = wxColour(255,0,0); 00581 temp_dc.SetBrush(wxBrush( *wxWHITE_BRUSH ) ); 00582 temp_dc.SetPen(wxPen( *wxBLACK_PEN )); 00583 temp_dc.DrawRectangle(0,0,m_scrX,m_scrY); 00584 00585 00586 wxNode *node = m_layers.GetFirst(); 00587 while (node) 00588 { 00589 ((mpLayer*)node->GetData())->Plot( temp_dc, *this); 00590 node = node->GetNext(); 00591 } 00592 00593 //dc.SetDeviceOrigin(70,40); 00594 //dc.SetAxisOrientation(false,true); 00595 //temp_dc.SetAxisOrientation(true,false); 00596 00597 //EED 14mai2009 00598 //dc.Blit(0,0, m_scrX, m_scrY, &temp_dc,-70,-m_scrY+40); 00599 00600 temp_dc.SetDeviceOrigin(0,0); 00601 dc.Blit(0,0, m_scrX, m_scrY, &temp_dc,0,0); 00602 00603 00604 delete _bitmap_functions; 00605 //_bitmap_functions 00606 //dc.SetAxisOrientation(false,true); 00607 00608 00609 }
void pPlotterWindow::onSave | ( | wxCommandEvent & | aEvent | ) |
Save the points of the function in a .txt file
Definition at line 348 of file pPlotterWindow.cxx.
References actual, and pGraphicalFunction::save().
00349 { 00350 wxString nameF=wxFileSelector(_T("Save Function")); 00351 actual->save(nameF); 00352 }
void mpWindow::OnScroll2 | ( | wxScrollWinEvent & | event | ) | [protected, inherited] |
Scroll handler, will move canvas.
Definition at line 654 of file mathplot.cxx.
References mpWindow::GetScaleX(), mpWindow::GetScaleY(), mpWindow::m_maxY, mpWindow::m_minX, mpWindow::SetPosX(), and mpWindow::SetPosY().
00655 { 00656 int width, height; 00657 GetClientSize( &width, &height); 00658 int px, py; 00659 GetViewStart( &px, &py); 00660 00661 if (event.GetOrientation() == wxHORIZONTAL) 00662 { 00663 SetPosX( (double)px / GetScaleX() + m_minX + (double)(width>>1)/GetScaleX()); 00664 } 00665 else 00666 { 00667 SetPosY( m_maxY - (double)py / GetScaleY() - (double)(height>>1)/GetScaleY()); 00668 } 00669 event.Skip(); 00670 }
void pPlotterWindow::onShowPoints | ( | wxCommandEvent & | aEvent | ) |
Shows graphicly the discrete points that the function has
The user wants to see the points(given) of the function
Definition at line 692 of file pPlotterWindow.cxx.
References actual, mpWindow::m_popmenu, pwID_NOSHOWPOINTS, pwID_SHOWPOINTS, pGraphicalFunction::SetShowPoints(), and mpWindow::UpdateAll().
00693 { 00694 actual->SetShowPoints(true); 00695 m_popmenu.Enable(pwID_NOSHOWPOINTS,true); 00696 m_popmenu.Enable(pwID_SHOWPOINTS,false); 00697 UpdateAll(); 00698 }
void mpWindow::OnShowPopupMenu | ( | wxMouseEvent & | event | ) | [protected, inherited] |
Mouse handler, will show context menu.
Definition at line 502 of file mathplot.cxx.
References mpWindow::m_clickedX, mpWindow::m_clickedY, and mpWindow::m_popmenu.
00503 { 00504 m_clickedX = event.GetX(); 00505 m_clickedY = event.GetY(); 00506 PopupMenu( &m_popmenu, event.GetX(), event.GetY()); 00507 }
void mpWindow::OnSize | ( | wxSizeEvent & | event | ) | [protected, inherited] |
Size handler, will update scroll bar sizes.
Definition at line 540 of file mathplot.cxx.
References mpWindow::UpdateAll().
00541 { 00542 UpdateAll(); 00543 }
void pPlotterWindow::onSplinePoints | ( | wxCommandEvent & | aEvent | ) |
Spline the points of the actual curve
Definition at line 361 of file pPlotterWindow.cxx.
References actual, pGraphicalFunction::initializeSplines(), pGraphicalFunction::initializeSplineVectors(), mpWindow::m_popmenu, pwID_LINE, pwID_SPLINE, pGraphicalFunction::setType(), and mpWindow::UpdateAll().
00362 { 00363 actual->setType(2); 00364 actual->initializeSplines(); 00365 actual->initializeSplineVectors(); 00366 UpdateAll(); 00367 m_popmenu.Enable(pwID_SPLINE,false); 00368 m_popmenu.Enable(pwID_LINE,true); 00369 }
void pPlotterWindow::onStartDrawing | ( | wxCommandEvent & | aEvent | ) |
Let to the user to start drawing
Definition at line 487 of file pPlotterWindow.cxx.
References actual, mpWindow::AddLayer(), mpWindow::DelLayer(), drawing, pGraphicalFunction::getFromWindow(), pGraphicalFunction::getOffsetPixelsX(), pGraphicalFunction::getOffsetPixelsY(), pGraphicalFunction::getOffsetX(), pGraphicalFunction::getOffsetY(), pGraphicalFunction::getShowPoints(), MaximumsDialog::getXValue(), MaximumsDialog::getYValue(), mpWindow::m_popmenu, mpWindow::maxScrX, mpWindow::maxScrY, mpWindow::minScrX, mpWindow::minScrY, mpALIGN_NE, pwID_ADDNEWPOINT, pwID_CHANGECOLOR, pwID_DELPOINT, pwID_LINE, pwID_LOAD, pwID_MYZOOMIN, pwID_MYZOOMOUT, pwID_NOSHOWPOINTS, pwID_SAVE, pwID_SHOWPOINTS, pwID_SPLINE, pwID_STARTDRAWING, pwID_STOPDRAWING, pwID_TRASLATEACTUALFUNCTION, pGraphicalFunction::setActual(), setActualScales(), pGraphicalFunction::SetDrawing(), pGraphicalFunction::setFactorZoom(), pGraphicalFunction::setFromWindow(), mpWindow::setMaxScrX(), mpWindow::setMaxScrY(), pGraphicalFunction::setMaxShowedX(), pGraphicalFunction::setMaxShowedY(), pGraphicalFunction::setMaxX(), pGraphicalFunction::setMaxY(), pGraphicalFunction::setMinShowedX(), pGraphicalFunction::setMinShowedY(), pGraphicalFunction::setMinX(), pGraphicalFunction::setMinY(), mpWindow::setOffsetPixelX(), mpWindow::setOffsetPixelY(), mpWindow::setOffsetX(), mpWindow::setOffsetY(), mpLayer::SetPen(), pGraphicalFunction::setScaleWay(), pGraphicalFunction::SetShowPoints(), USER_SCALE, and mpWindow::zoomFactor.
00488 { 00489 00490 if(actual!=NULL) 00491 { 00492 actual->setActual(false); 00493 if(actual->getShowPoints()) 00494 actual->SetShowPoints(false); 00495 } 00496 m_popmenu.Enable(pwID_NOSHOWPOINTS,false); 00497 m_popmenu.Enable(pwID_ADDNEWPOINT,false); 00498 m_popmenu.Enable(pwID_SHOWPOINTS,false); 00499 m_popmenu.Enable(pwID_DELPOINT,false); 00500 m_popmenu.Enable(pwID_MYZOOMIN,false); 00501 m_popmenu.Enable(pwID_MYZOOMOUT,false); 00502 m_popmenu.Enable(pwID_STARTDRAWING,false); 00503 m_popmenu.Enable(pwID_SPLINE,false); 00504 m_popmenu.Enable(pwID_LINE,false); 00505 m_popmenu.Enable(pwID_STOPDRAWING,true); 00506 m_popmenu.Enable(pwID_SAVE,false); 00507 m_popmenu.Enable(pwID_LOAD,false); 00508 m_popmenu.Enable(pwID_CHANGECOLOR,false); 00509 m_popmenu.Enable(pwID_TRASLATEACTUALFUNCTION,false); 00510 00511 if(!drawing) 00512 { 00513 drawing=true; 00514 00515 00516 actual=new pGraphicalFunction(wxT("f(x) = function1(x)"),mpALIGN_NE); 00517 actual->setActual(true); 00518 actual->setFromWindow(true); 00519 actual->setScaleWay(USER_SCALE); 00520 actual->SetDrawing(drawing); 00521 actual->setFactorZoom(zoomFactor); 00522 00523 //we change the offsets 00524 setOffsetPixelX(actual->getOffsetPixelsX()); 00525 setOffsetPixelY(actual->getOffsetPixelsY()); 00526 setOffsetX(actual->getOffsetX()); 00527 setOffsetY(actual->getOffsetY()); 00528 00529 AddLayer(actual); 00530 wxPen mypen(*wxRED, 5, wxSOLID); 00531 mypen.SetWidth(2); 00532 actual->SetPen( mypen); 00533 00534 /* 00535 int result = wxMessageBox("Do you Want a Smooth Curve?", "Spline Points", wxYES_NO | wxCANCEL); 00536 if(result==wxYES) 00537 { 00538 actual->setType(2); 00539 } 00540 */ 00541 00542 /**************************************************************************/ 00543 // Setting Maximums 00544 /**************************************************************************/ 00545 00546 //opening the dialog of maximums 00547 float maxX=0,maxY=0; 00548 MaximumsDialog *dlg=new MaximumsDialog(this,_T("Set Maximums")); 00549 00550 if(dlg->ShowModal()== wxID_OK ) 00551 { 00552 maxX=dlg->getXValue(); 00553 maxY=dlg->getYValue(); 00554 if(maxX>0 && maxY>0 && actual->getFromWindow()) 00555 { 00556 setMaxScrX(maxX); 00557 setMaxScrY(maxY); 00558 00559 actual->setMaxX(maxScrX); 00560 actual->setMinX(minScrX); 00561 actual->setMaxY(maxY); 00562 actual->setMinY(0); 00563 00564 actual->setMinShowedX(0); 00565 actual->setMinShowedY(0); 00566 actual->setMaxShowedX(maxX); 00567 actual->setMaxShowedY(maxY); 00568 00569 setActualScales(); 00570 } 00571 else if(maxX<0 || maxY<0) 00572 { 00573 wxMessageBox(_T("Both numbers have to be positive, please enter valid numbers"), _T("Error"), 00574 wxOK); 00575 00576 DelLayer(actual); 00577 actual=NULL; 00578 00579 m_popmenu.Enable(pwID_NOSHOWPOINTS,false); 00580 m_popmenu.Enable(pwID_ADDNEWPOINT,false); 00581 m_popmenu.Enable(pwID_SHOWPOINTS,false); 00582 m_popmenu.Enable(pwID_DELPOINT,false); 00583 m_popmenu.Enable(pwID_MYZOOMIN,false); 00584 m_popmenu.Enable(pwID_MYZOOMOUT,false); 00585 m_popmenu.Enable(pwID_STARTDRAWING,true); 00586 m_popmenu.Enable(pwID_SPLINE,false); 00587 m_popmenu.Enable(pwID_LINE,false); 00588 m_popmenu.Enable(pwID_STOPDRAWING,false); 00589 m_popmenu.Enable(pwID_SAVE,false); 00590 m_popmenu.Enable(pwID_LOAD,true); 00591 m_popmenu.Enable(pwID_CHANGECOLOR,false); 00592 m_popmenu.Enable(pwID_TRASLATEACTUALFUNCTION,false); 00593 drawing=false; 00594 //actual->SetDrawing(false); 00595 00596 } 00597 00598 else if(maxX==0 && maxY==0) 00599 { 00600 actual->setMaxX(100); 00601 actual->setMinX(0); 00602 actual->setMaxY(100); 00603 actual->setMinY(0); 00604 00605 actual->setMinShowedX(0); 00606 actual->setMinShowedY(0); 00607 actual->setMaxShowedX(100); 00608 actual->setMaxShowedY(100); 00609 00610 maxScrX=100; 00611 maxScrY=100; 00612 minScrX=0; 00613 minScrY=0; 00614 00615 setActualScales(); 00616 } 00617 00618 } 00619 00620 else if(dlg->ShowModal()== wxID_CANCEL) 00621 { 00622 DelLayer(actual); 00623 actual=NULL; 00624 00625 m_popmenu.Enable(pwID_NOSHOWPOINTS,false); 00626 m_popmenu.Enable(pwID_ADDNEWPOINT,false); 00627 m_popmenu.Enable(pwID_SHOWPOINTS,false); 00628 m_popmenu.Enable(pwID_DELPOINT,false); 00629 m_popmenu.Enable(pwID_MYZOOMIN,false); 00630 m_popmenu.Enable(pwID_MYZOOMOUT,false); 00631 m_popmenu.Enable(pwID_STARTDRAWING,true); 00632 m_popmenu.Enable(pwID_SPLINE,false); 00633 m_popmenu.Enable(pwID_LINE,false); 00634 m_popmenu.Enable(pwID_STOPDRAWING,false); 00635 m_popmenu.Enable(pwID_SAVE,false); 00636 m_popmenu.Enable(pwID_LOAD,true); 00637 m_popmenu.Enable(pwID_CHANGECOLOR,false); 00638 m_popmenu.Enable(pwID_TRASLATEACTUALFUNCTION,false); 00639 drawing=false; 00640 //actual->SetDrawing(false); 00641 00642 } 00643 dlg->Destroy(); 00644 if(drawing) 00645 { 00646 //------------------------------------------ 00647 //Sending the paarticular event of changed actual function 00648 //------------------------------------------- 00649 wxCommandEvent cevent( wxEVT_PPLOTTER_CHANGED_FUNCTION, GetId() ); 00650 cevent.SetEventObject(this); 00651 GetEventHandler()->ProcessEvent( cevent ); 00652 } 00653 } 00654 00655 }
void pPlotterWindow::onStopDrawing | ( | wxCommandEvent & | aEvent | ) |
Stop the drawing of the actual function
Definition at line 659 of file pPlotterWindow.cxx.
References actual, addFunctionToMove(), mpWindow::DelLayer(), drawing, functions, pGraphicalFunction::getSizePoints(), mpWindow::m_popmenu, pwID_ADDNEWPOINT, pwID_CHANGECOLOR, pwID_DELPOINT, pwID_LINE, pwID_MYZOOMIN, pwID_MYZOOMOUT, pwID_SHOWPOINTS, pwID_SPLINE, pwID_STARTDRAWING, pwID_STOPDRAWING, pwID_TRASLATEACTUALFUNCTION, pGraphicalFunction::SetDrawing(), and mpWindow::UpdateAll().
00660 { 00661 drawing=false; 00662 actual->SetDrawing(drawing); 00663 functions.Append(actual); 00664 addFunctionToMove(actual); 00665 m_popmenu.Enable(pwID_ADDNEWPOINT,true); 00666 m_popmenu.Enable(pwID_DELPOINT,true); 00667 m_popmenu.Enable(pwID_SHOWPOINTS,true); 00668 m_popmenu.Enable(pwID_MYZOOMIN,true); 00669 m_popmenu.Enable(pwID_MYZOOMOUT,true); 00670 m_popmenu.Enable(pwID_STARTDRAWING,true); 00671 m_popmenu.Enable(pwID_SPLINE,true); 00672 m_popmenu.Enable(pwID_STOPDRAWING,false); 00673 m_popmenu.Enable(pwID_LINE,false); 00674 m_popmenu.Enable(pwID_CHANGECOLOR,true); 00675 m_popmenu.Enable(pwID_TRASLATEACTUALFUNCTION,true); 00676 00677 if(actual->getSizePoints()==0||actual->getSizePoints()==1) 00678 { 00679 00680 m_popmenu.Enable(pwID_ADDNEWPOINT,false); 00681 //functions.DeleteObject(actual); 00682 DelLayer(actual); 00683 actual=NULL; 00684 00685 } 00686 00687 UpdateAll(); 00688 }
void mpWindow::OnZoomIn | ( | wxCommandEvent & | event | ) | [protected, inherited] |
Context menu handler.
Definition at line 526 of file mathplot.cxx.
References mpWindow::m_clickedX, mpWindow::m_clickedY, mpWindow::m_posX, mpWindow::m_posY, mpWindow::m_scaleX, mpWindow::m_scaleY, and mpWindow::ZoomIn().
00527 { 00528 int cx, cy; 00529 GetClientSize(&cx, &cy); 00530 m_posX = (double)(m_clickedX-cx/2) / m_scaleX + m_posX; 00531 m_posY = (double)(cy/2-m_clickedY) / m_scaleY + m_posY; 00532 ZoomIn(); 00533 }
void mpWindow::OnZoomOut | ( | wxCommandEvent & | event | ) | [protected, inherited] |
Context menu handler.
Definition at line 535 of file mathplot.cxx.
References mpWindow::ZoomOut().
00536 { 00537 ZoomOut(); 00538 }
void mpWindow::Refresh | ( | bool | eraseBackground = true , |
|
const wxRect * | rect = NULL | |||
) | [protected, inherited] |
Definition at line 558 of file mathplot.cxx.
Referenced by mpWindow::UpdateAll().
00559 { 00560 wxScrolledWindow::Refresh(false); 00561 }
void pPlotterWindow::setActualFunction | ( | pGraphicalFunction * | newActual | ) |
Sets the actual function
newActual,: | new function |
Sets the actual function
Definition at line 150 of file pPlotterWindow.cxx.
References actual, and pGraphicalFunction::setActual().
Referenced by onChangeActual(), and pPlotter::setActual().
00151 { 00152 if(actual!=NULL) 00153 actual->setActual(false); 00154 newActual->setActual(true); 00155 actual=newActual; 00156 }
void pPlotterWindow::setActualScales | ( | ) |
Definition at line 200 of file pPlotterWindow.cxx.
References actual, pGraphicalFunction::getMaxXShowed(), pGraphicalFunction::getMaxYShowed(), pGraphicalFunction::getMinXShowed(), pGraphicalFunction::getMinYShowed(), mpWindow::m_scaleX, mpWindow::m_scaleY, mpWindow::m_scrX, mpWindow::m_scrY, mpWindow::setMaxScrX(), mpWindow::setMaxScrY(), mpWindow::setMinScrX(), mpWindow::setMinScrY(), pGraphicalFunction::setScales(), pGraphicalFunction::setScreens(), and mpWindow::zoomFactor.
Referenced by InitFunctionForVectors(), onChangeActual(), onDeletePoint(), onMouseMove(), and onStartDrawing().
00201 { 00202 // int maxX,maxY,minX,minY; // JPRx 00203 int maxX,maxY;//,minX,minY; // JPRx //EED 00204 /* 00205 if the function is drawed interactively the maxX and the 00206 maxY in actual are sets by the user 00207 */ 00208 /* 00209 maxX=actual->getMaxX(); 00210 maxY=actual->getMaxY(); 00211 00212 int dx=maxX; 00213 int dy=maxY; 00214 00215 */ 00216 int dx=actual->getMaxXShowed()-actual->getMinXShowed(); 00217 int dy=actual->getMaxYShowed()-actual->getMinYShowed(); 00218 00219 if(dx!=0 && dy!=0) 00220 { 00221 m_scaleX= (((float)m_scrX-100)/dx)*zoomFactor; 00222 m_scaleY= (((float)m_scrY-50)/dy)*zoomFactor; 00223 } 00224 //setting the maximums and minimums showed in the window 00225 /* 00226 setMaxScrX(maxX); 00227 setMaxScrY(maxY); 00228 */ 00229 setMaxScrX(actual->getMaxXShowed()); 00230 setMinScrX(actual->getMinXShowed()); 00231 setMaxScrY(actual->getMaxYShowed()); 00232 setMinScrY(actual->getMinYShowed()); 00233 actual->setScreens(m_scrX,m_scrY); 00234 actual->setScales(); 00235 }
void pPlotterWindow::setLineGuidesCondition | ( | bool | ifDrawing | ) | [inline] |
Definition at line 288 of file pPlotterWindow.h.
Referenced by OnGuideLines().
00289 { 00290 drawGuides = ifDrawing; 00291 }
void mpWindow::setMaxScrX | ( | int | maxX | ) | [inline, inherited] |
set the max value in the x axis
maxX |
Definition at line 471 of file mathplot.h.
Referenced by actualizeViewRange(), moveFunctions(), onStartDrawing(), and setActualScales().
00472 { 00473 maxScrX=maxX; 00474 }
void mpWindow::setMaxScrY | ( | int | maxY | ) | [inline, inherited] |
set the max value in the y axis
maxY |
Definition at line 479 of file mathplot.h.
Referenced by onStartDrawing(), and setActualScales().
00480 { 00481 maxScrY=maxY; 00482 }
void mpWindow::setMinScrX | ( | int | minX | ) | [inline, inherited] |
set the min value in the x axis
minX |
Definition at line 510 of file mathplot.h.
Referenced by actualizeViewRange(), moveFunctions(), and setActualScales().
00511 { 00512 minScrX=minX; 00513 }
void mpWindow::setMinScrY | ( | int | minY | ) | [inline, inherited] |
set the min value in the y axis
minY |
Definition at line 518 of file mathplot.h.
Referenced by setActualScales().
00519 { 00520 minScrY=minY; 00521 }
void pPlotterWindow::setmLog | ( | wxTextCtrl * | m_log1 | ) | [inline] |
Definition at line 272 of file pPlotterWindow.h.
00273 { 00274 m_log=m_log1; 00275 }
void mpWindow::setOffsetPixelX | ( | int | offX | ) | [inline, inherited] |
Set the x-offset of the zoom
Definition at line 577 of file mathplot.h.
Referenced by onChangeActual(), onMyZoomIn(), onMyZoomOut(), and onStartDrawing().
00578 { 00579 offsetPixelX=offX; 00580 }
void mpWindow::setOffsetPixelY | ( | int | offY | ) | [inline, inherited] |
Set the y-offset of the zoom
Definition at line 584 of file mathplot.h.
Referenced by onChangeActual(), onMyZoomIn(), onMyZoomOut(), and onStartDrawing().
00585 { 00586 offsetPixelY=offY; 00587 }
void mpWindow::setOffsetX | ( | int | offX | ) | [inline, inherited] |
Set the x-offset of the zoom
Definition at line 607 of file mathplot.h.
Referenced by actualizeViewRange(), moveFunctions(), onChangeActual(), onMyZoomIn(), onMyZoomOut(), and onStartDrawing().
00608 { 00609 offsetX=offX; 00610 }
void mpWindow::setOffsetY | ( | int | offY | ) | [inline, inherited] |
Set the y-offset of the zoom
Definition at line 614 of file mathplot.h.
Referenced by onChangeActual(), onMyZoomIn(), onMyZoomOut(), and onStartDrawing().
00615 { 00616 offsetY=offY; 00617 }
void pPlotterWindow::setPopUpMenu | ( | bool | startD, | |
bool | stopD, | |||
bool | smooth, | |||
bool | line, | |||
bool | zoomIn, | |||
bool | zoomOut, | |||
bool | showPoints, | |||
bool | noShowPoints, | |||
bool | changeColor, | |||
bool | addP, | |||
bool | delPoint, | |||
bool | load, | |||
bool | save | |||
) |
Definition at line 1818 of file pPlotterWindow.cxx.
References mpWindow::m_popmenu, pwID_ADDPOINT, pwID_CHANGECOLOR, pwID_DELPOINT, pwID_LINE, pwID_LOAD, pwID_MYZOOMIN, pwID_MYZOOMOUT, pwID_NOSHOWPOINTS, pwID_SAVE, pwID_SHOWPOINTS, pwID_SPLINE, pwID_STARTDRAWING, and pwID_STOPDRAWING.
Referenced by pPlotter::setPopUpMenu().
01821 { 01822 /* 01823 pwID_ADDPOINT = 2010, //!< add a point to the function 01824 pwID_DELPOINT, //!< delete a point of the function 01825 pwID_SHOWPOINTS, //!<shows the points that the function has 01826 pwID_STARTDRAWING, //!<let to the user to start drawing the curve 01827 pwID_DELFUNCTION, //!<delete a function that is in the plotter 01828 pwID_STOPDRAWING,//!<Stops the drawing of the function 01829 pwID_ADDNEWPOINT,//!<add a new point to the function. 01830 pwID_NOSHOWPOINTS, //!<No show the points of the function. 01831 pwID_MYZOOMIN,//!<Zoom in the function 01832 pwID_MYZOOMOUT,//!<Zoom out the points of the function. 01833 pwID_SPLINE,//!<Spline the actual curve. 01834 pwID_LINE,//!<Piecewise the actual curve. 01835 pwID_SAVE,//!<Save the function in a .txt file. 01836 pwID_LOAD, //!<Load the function from a .txt file. 01837 pwID_CHANGECOLOR, //!<Change the color of the function 01838 pwID_TRASLATEACTUALFUNCTION //!<move the actual function 01839 */ 01840 if(startD) 01841 m_popmenu.Remove( pwID_STARTDRAWING); 01842 if(stopD) 01843 m_popmenu.Remove( pwID_STOPDRAWING); 01844 if(load) 01845 m_popmenu.Remove( pwID_LOAD); 01846 if(save) 01847 m_popmenu.Remove( pwID_SAVE); 01848 if(showPoints) 01849 m_popmenu.Remove( pwID_SHOWPOINTS); 01850 if(noShowPoints) 01851 m_popmenu.Remove( pwID_NOSHOWPOINTS); 01852 if(smooth) 01853 m_popmenu.Remove( pwID_SPLINE); 01854 if(line) 01855 m_popmenu.Remove( pwID_LINE); 01856 if(zoomIn) 01857 m_popmenu.Remove( pwID_MYZOOMIN); 01858 if(zoomOut) 01859 m_popmenu.Remove( pwID_MYZOOMOUT); 01860 if(changeColor) 01861 m_popmenu.Remove( pwID_CHANGECOLOR); 01862 if(addP) 01863 m_popmenu.Remove( pwID_ADDPOINT); 01864 if(delPoint) 01865 m_popmenu.Remove( pwID_DELPOINT); 01866 }
void mpWindow::SetPos | ( | double | posX, | |
double | posY | |||
) | [inline, inherited] |
Set current view's X and Y position and refresh display.
posX | New position that corresponds to the center point of the view. | |
posY | New position that corresponds to the center point of the view. |
Definition at line 765 of file mathplot.h.
Referenced by mpWindow::OnCenter().
void mpWindow::SetPosX | ( | double | posX | ) | [inline, inherited] |
Set current view's X position and refresh display.
posX | New position that corresponds to the center point of the view. |
Definition at line 754 of file mathplot.h.
Referenced by mpWindow::OnScroll2().
void mpWindow::SetPosY | ( | double | posY | ) | [inline, inherited] |
Set current view's Y position and refresh display.
posY | New position that corresponds to the center point of the view. |
Definition at line 759 of file mathplot.h.
Referenced by mpWindow::OnScroll2().
void mpWindow::setRealGuideX | ( | int | newX_realGuide | ) | [inline, inherited] |
Definition at line 623 of file mathplot.h.
Referenced by pPlotter::onActualChange_Bar(), pPlotter::onColorBar(), pPlotter::onMoved_ColorPoint(), and pPlotter::onSelectionEnd().
00624 { 00625 real_guideLine_X = newX_realGuide; 00626 if(real_guideLine_X!=-1) 00627 UpdateAll(); 00628 }
void mpWindow::setRealGuideY | ( | int | newY_realGuide | ) | [inline, inherited] |
Definition at line 643 of file mathplot.h.
00644 { 00645 real_guideLine_Y = newY_realGuide; 00646 if(real_guideLine_Y!=-1) 00647 UpdateAll(); 00648 }
void mpWindow::SetScaleX | ( | double | scaleX | ) | [inline, inherited] |
Set current view's X scale and refresh display.
scaleX | New scale, must not be 0. |
Definition at line 744 of file mathplot.h.
Referenced by pPlotterLayer::Plot().
00744 { if (scaleX!=0) m_scaleX=scaleX; /*UpdateAll();*/ }
void mpWindow::SetScaleY | ( | double | scaleY | ) | [inline, inherited] |
Set current view's Y scale and refresh display.
scaleY | New scale, must not be 0. |
Definition at line 749 of file mathplot.h.
Referenced by pPlotterLayer::Plot().
00749 { if (scaleY!=0) m_scaleY=scaleY; /*UpdateAll();*/ }
void mpWindow::setType | ( | int | t | ) | [inline, inherited] |
Definition at line 454 of file mathplot.h.
Referenced by pPlotter::setType().
00455 { 00456 type=t; 00457 }
void mpWindow::UpdateAll | ( | ) | [inherited] |
Refresh display
Definition at line 702 of file mathplot.cxx.
References mpWindow::Refresh(), and mpWindow::UpdateBBox().
Referenced by actualizeViewRange(), addFunction(), addFunctionToMove(), mpWindow::AddLayer(), mpWindow::DelLayer(), mpWindow::Fit(), mpWindow::LockAspect(), pPlotter::onActualChange_Bar(), onAddNewPoint(), onAddPoint(), onChangeActual(), onChangeColor(), pPlotter::onColorBar(), onDeletePoint(), OnGuideLines(), onLine(), onLoad(), onMouseMove(), pPlotter::onMoved_ColorPoint(), onMyZoomIn(), onMyZoomOut(), onNoShowPoints(), pPlotter::onSelectionEnd(), onShowPoints(), mpWindow::OnSize(), onSplinePoints(), onStopDrawing(), pPlotter::update(), mpWindow::ZoomIn(), and mpWindow::ZoomOut().
00703 { 00704 if (UpdateBBox()) 00705 { 00706 int cx, cy; 00707 GetClientSize( &cx, &cy); 00708 printf("EED mpWindow::UpdateAll %d %d\n",cx,cy); 00709 00710 //const int sx = (int)((m_maxX - m_minX) * GetScaleX()); // JPRx 00711 //const int sy = (int)((m_maxY - m_minY) * GetScaleY()); // JPRx 00712 //const int px = (int)((GetPosX() - m_minX) * GetScaleX() - (cx>>1)); // JPRx 00713 //const int py = (int)((GetPosY() - m_minY) * GetScaleY() - (cy>>1)); // JPRx 00714 //SetScrollbars( 1, 1, sx, sy, px, py); 00715 } 00716 00717 FitInside(); 00718 Refresh( false ); 00719 }
bool mpWindow::UpdateBBox | ( | ) | [protected, inherited] |
Recalculate global layer bounding box.
Definition at line 672 of file mathplot.cxx.
References mpLayer::GetMaxX(), mpLayer::GetMaxY(), mpLayer::GetMinX(), mpLayer::GetMinY(), mpLayer::HasBBox(), mpWindow::m_layers, mpWindow::m_maxX, mpWindow::m_maxY, mpWindow::m_minX, and mpWindow::m_minY.
Referenced by mpWindow::Fit(), and mpWindow::UpdateAll().
00673 { 00674 bool first = TRUE; 00675 00676 wxNode *node = m_layers.GetFirst(); 00677 00678 while(node) 00679 { 00680 mpLayer* f = (mpLayer*)node->GetData(); 00681 00682 if (f->HasBBox()) 00683 { 00684 if (first) 00685 { 00686 first = FALSE; 00687 m_minX = f->GetMinX(); m_maxX=f->GetMaxX(); 00688 m_minY = f->GetMinY(); m_maxY=f->GetMaxY(); 00689 } 00690 else 00691 { 00692 if (f->GetMinX()<m_minX) m_minX=f->GetMinX(); if (f->GetMaxX()>m_maxX) m_maxX=f->GetMaxX(); 00693 if (f->GetMinY()<m_minY) m_minY=f->GetMinY(); if (f->GetMaxY()>m_maxY) m_maxY=f->GetMaxY(); 00694 } 00695 } 00696 node = node->GetNext(); 00697 } 00698 00699 return first == FALSE; 00700 }
void pPlotterWindow::writeInText | ( | wxString & | t | ) | [inline] |
Definition at line 311 of file pPlotterWindow.h.
Referenced by pPlotter::onAddedPoint_Plotter(), pPlotter::onMovePoint_Plotter(), and pPlotter::onRemovedPoint_Plotter().
00312 { 00313 t=text; 00314 }
void mpWindow::ZoomIn | ( | ) | [inherited] |
Zoom into current view and refresh display
Definition at line 472 of file mathplot.cxx.
References mpWindow::m_scaleX, mpWindow::m_scaleY, and mpWindow::UpdateAll().
Referenced by mpWindow::OnZoomIn().
void mpWindow::ZoomOut | ( | ) | [inherited] |
Zoom out current view and refresh display
Definition at line 479 of file mathplot.cxx.
References mpWindow::m_scaleX, mpWindow::m_scaleY, and mpWindow::UpdateAll().
Referenced by mpWindow::OnZoomOut().
pGraphicalFunction* pPlotterWindow::actual [private] |
Actual Function
Definition at line 343 of file pPlotterWindow.h.
Referenced by actualizeViewRange(), getActualFunction(), InitFunctionForVectors(), onAddNewPoint(), onAddPoint(), onChangeActual(), onChangeColor(), onDeletePoint(), onLine(), onLoad(), onMouseMove(), onNoShowPoints(), onSave(), onShowPoints(), onSplinePoints(), onStartDrawing(), onStopDrawing(), setActualFunction(), and setActualScales().
std::vector<double> pPlotterWindow::backUpActualVector [private] |
Definition at line 390 of file pPlotterWindow.h.
Referenced by onMouseMove().
bool mpWindow::drawGuides [protected, inherited] |
Definition at line 887 of file mathplot.h.
Referenced by mpWindow::drawGuideLines(), and OnGuideLines().
bool pPlotterWindow::drawing [private] |
If is drawing the function
Definition at line 352 of file pPlotterWindow.h.
Referenced by onAddPoint(), onChangeActual(), onLoad(), onMouseMove(), onStartDrawing(), and onStopDrawing().
wxList pPlotterWindow::functions [private] |
layers
Definition at line 347 of file pPlotterWindow.h.
Referenced by addFunction(), deleteFunction(), DeletePointFunction(), getFunction(), onChangeActual(), onLoad(), onMyZoomIn(), onMyZoomOut(), and onStopDrawing().
wxList pPlotterWindow::functionsToMove [private] |
Definition at line 378 of file pPlotterWindow.h.
Referenced by addFunctionToMove(), deleteFunction(), and moveFunctions().
int pPlotterWindow::initialMovingCLick [private] |
Definition at line 385 of file pPlotterWindow.h.
Referenced by onMouseMove().
int mpWindow::m_clickedX [protected, inherited] |
Last mouse click X position, for centering and zooming the view.
Definition at line 832 of file mathplot.h.
Referenced by onAddNewPoint(), mpWindow::OnCenter(), onDeletePoint(), onMyZoomIn(), onMyZoomOut(), mpWindow::OnShowPopupMenu(), and mpWindow::OnZoomIn().
int mpWindow::m_clickedY [protected, inherited] |
Last mouse click Y position, for centering and zooming the view.
Definition at line 833 of file mathplot.h.
Referenced by onAddNewPoint(), mpWindow::OnCenter(), onDeletePoint(), onMyZoomIn(), onMyZoomOut(), mpWindow::OnShowPopupMenu(), and mpWindow::OnZoomIn().
wxList mpWindow::m_layers [protected, inherited] |
List of attached plot layers.
Definition at line 818 of file mathplot.h.
Referenced by mpWindow::AddLayer(), mpWindow::DelLayer(), mpWindow::OnPaint(), and mpWindow::UpdateBBox().
bool mpWindow::m_lockaspect [protected, inherited] |
Scale aspect is locked or not.
Definition at line 820 of file mathplot.h.
Referenced by mpWindow::Fit(), and mpWindow::LockAspect().
wxTextCtrl* pPlotterWindow::m_log [private] |
Definition at line 372 of file pPlotterWindow.h.
double mpWindow::m_maxX [protected, inherited] |
Global layer bounding box, right border incl.
Definition at line 823 of file mathplot.h.
Referenced by mpWindow::Fit(), and mpWindow::UpdateBBox().
double mpWindow::m_maxY [protected, inherited] |
Global layer bounding box, top border incl.
Definition at line 825 of file mathplot.h.
Referenced by mpWindow::Fit(), mpWindow::OnScroll2(), and mpWindow::UpdateBBox().
double mpWindow::m_minX [protected, inherited] |
Global layer bounding box, left border incl.
Definition at line 822 of file mathplot.h.
Referenced by mpWindow::Fit(), mpWindow::OnScroll2(), and mpWindow::UpdateBBox().
double mpWindow::m_minY [protected, inherited] |
Global layer bounding box, bottom border incl.
Definition at line 824 of file mathplot.h.
Referenced by mpWindow::Fit(), and mpWindow::UpdateBBox().
wxMenu mpWindow::m_popmenu [protected, inherited] |
Canvas' context menu.
Definition at line 819 of file mathplot.h.
Referenced by InitFunctionForVectors(), mpWindow::LockAspect(), moveFunctions(), onChangeActual(), OnGuideLines(), onLine(), onLoad(), mpWindow::OnLockAspect(), onMoveFunction(), onNoShowPoints(), onShowPoints(), mpWindow::OnShowPopupMenu(), onSplinePoints(), onStartDrawing(), onStopDrawing(), and setPopUpMenu().
double mpWindow::m_posX [protected, inherited] |
Current view's X position.
Definition at line 828 of file mathplot.h.
Referenced by mpWindow::Fit(), mpWindow::OnCenter(), and mpWindow::OnZoomIn().
double mpWindow::m_posY [protected, inherited] |
Current view's Y position.
Definition at line 829 of file mathplot.h.
Referenced by mpWindow::Fit(), mpWindow::OnCenter(), and mpWindow::OnZoomIn().
double mpWindow::m_scaleX [protected, inherited] |
Current view's X scale.
Definition at line 826 of file mathplot.h.
Referenced by mpWindow::Fit(), getRealPoint(), InitFunctionForVectors(), mpWindow::LockAspect(), mpWindow::OnCenter(), mpWindow::OnZoomIn(), setActualScales(), mpWindow::ZoomIn(), and mpWindow::ZoomOut().
double mpWindow::m_scaleY [protected, inherited] |
Current view's Y scale.
Definition at line 827 of file mathplot.h.
Referenced by mpWindow::Fit(), getRealPoint(), InitFunctionForVectors(), mpWindow::LockAspect(), mpWindow::OnCenter(), mpWindow::OnZoomIn(), setActualScales(), mpWindow::ZoomIn(), and mpWindow::ZoomOut().
int mpWindow::m_scrX [protected, inherited] |
Current view's X dimension.
Definition at line 830 of file mathplot.h.
Referenced by actualizeViewRange(), InitFunctionForVectors(), onChangeActual(), onMouseMove(), onMyZoomIn(), onMyZoomOut(), mpWindow::OnPaint(), and setActualScales().
int mpWindow::m_scrY [protected, inherited] |
Current view's Y dimension.
Definition at line 831 of file mathplot.h.
Referenced by InitFunctionForVectors(), onAddNewPoint(), onAddPoint(), onChangeActual(), onDeletePoint(), onMouseMove(), onMyZoomIn(), onMyZoomOut(), mpWindow::OnPaint(), and setActualScales().
int mpWindow::maxScrX [protected, inherited] |
the max value in the x axis
Definition at line 841 of file mathplot.h.
Referenced by actualizeViewRange(), getRealPoint(), InitFunctionForVectors(), and onStartDrawing().
int mpWindow::maxScrY [protected, inherited] |
the max value in the y axis
Definition at line 846 of file mathplot.h.
Referenced by getRealPoint(), InitFunctionForVectors(), and onStartDrawing().
int mpWindow::minScrX [protected, inherited] |
the min value in the x axis
Definition at line 850 of file mathplot.h.
Referenced by actualizeViewRange(), getRealPoint(), InitFunctionForVectors(), and onStartDrawing().
int mpWindow::minScrY [protected, inherited] |
the min value in the y axis
Definition at line 855 of file mathplot.h.
Referenced by getRealPoint(), InitFunctionForVectors(), and onStartDrawing().
bool pPlotterWindow::movingFunction [private] |
Definition at line 382 of file pPlotterWindow.h.
Referenced by onMouseMove(), and onMoveFunction().
int pPlotterWindow::movingPointIndex [private] |
Index of the movig point, if the user is moving a poit
Definition at line 357 of file pPlotterWindow.h.
Referenced by onAddPoint(), onLeftUp(), and onMouseMove().
bool pPlotterWindow::movingPoints [private] |
Definition at line 394 of file pPlotterWindow.h.
Referenced by onAddPoint(), onLeftUp(), and onMouseMove().
int mpWindow::offsetPixelX [protected, inherited] |
offset in pixels where the user has clicked before changing the scale (in the actual function)
Definition at line 867 of file mathplot.h.
Referenced by getRealPoint().
int mpWindow::offsetPixelY [protected, inherited] |
Definition at line 868 of file mathplot.h.
Referenced by getRealPoint().
int mpWindow::offsetX [protected, inherited] |
Definition at line 872 of file mathplot.h.
Referenced by getRealPoint().
int mpWindow::offsetY [protected, inherited] |
Definition at line 873 of file mathplot.h.
Referenced by getRealPoint().
int mpWindow::real_guideLine_X [protected, inherited] |
Definition at line 878 of file mathplot.h.
int mpWindow::real_guideLine_Y [protected, inherited] |
Definition at line 882 of file mathplot.h.
int pPlotterWindow::scaleWay [private] |
the way we scale DEFAULT_SCALE 1 MAX_SCALE 2 USER_SCALE 3
Definition at line 365 of file pPlotterWindow.h.
wxString pPlotterWindow::text [private] |
Definition at line 373 of file pPlotterWindow.h.
Referenced by onAddNewPoint(), onAddPoint(), onChangeActual(), onDeletePoint(), and onMouseMove().
int mpWindow::type [protected, inherited] |
Definition at line 893 of file mathplot.h.
Referenced by InitFunctionForVectors(), moveFunctions(), onChangeActual(), and onMouseMove().
float mpWindow::zoomFactor [protected, inherited] |
Definition at line 860 of file mathplot.h.
Referenced by actualizeViewRange(), onChangeActual(), onLoad(), onMyZoomIn(), onMyZoomOut(), onStartDrawing(), and setActualScales().