#include <mathplot.h>
Public Member Functions | |
mpWindow () | |
mpWindow (wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, int flags=0) | |
~mpWindow () | |
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 | drawGuideLines () |
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 | |
wxBitmap * | _bitmap_functions |
This class defines a zoomable and moveable 2D plot canvas. Any number of mpLayer implementations (scale rulers, function plots, ...) can be attached using mpWindow::AddLayer.
The canvas window provides a context menu with actions for navigating the view. The context menu can be retrieved with mpWindow::GetPopupMenu, e.g. for extending it externally.
Definition at line 433 of file mathplot.h.
mpWindow::mpWindow | ( | ) | [inline] |
mpWindow::mpWindow | ( | wxWindow * | parent, | |
wxWindowID | id, | |||
const wxPoint & | pos = wxDefaultPosition , |
|||
const wxSize & | size = wxDefaultSize , |
|||
int | flags = 0 | |||
) |
Definition at line 396 of file mathplot.cxx.
References mpID_LINE_GUIDES.
00397 : wxScrolledWindow( parent, id, pos, size, flag, wxT("wxPlotter") ) 00398 { 00399 m_scaleX = m_scaleY = 1.0; 00400 m_posX = m_posY = 0; 00401 m_scrX = m_scrY = 64; 00402 m_minX = m_minY = 0; 00403 m_maxX = m_maxY = 0; 00404 maxScrX = maxScrY = 200; 00405 minScrX = minScrY = 0; 00406 m_clickedX = 0; 00407 m_clickedY = 5000; 00408 m_lockaspect = FALSE; 00409 offsetX = offsetY = 0; 00410 offsetPixelX = offsetPixelY= 0; 00411 00412 real_guideLine_X = -1; 00413 real_guideLine_Y = -1; 00414 drawGuides = true; 00415 type=1; 00416 00417 m_popmenu.Append( mpID_CENTER, _("Center"), _("Center plot view to this position")); 00418 m_popmenu.Append( mpID_FIT, _("Fit"), _("Set plot view to show all items")); 00419 m_popmenu.Append( mpID_ZOOM_IN, _("Zoom in"), _("Zoom in plot view.")); 00420 m_popmenu.Append( mpID_ZOOM_OUT, _("Zoom out"), _("Zoom out plot view.")); 00421 m_popmenu.AppendCheckItem( mpID_LOCKASPECT, _("Lock aspect"), _("Lock horizontal and vertical zoom aspect.")); 00422 00423 m_popmenu.AppendCheckItem( mpID_LINE_GUIDES, _("Turn off guide lines"), _("Enables/Disables the guide lines")); 00424 00425 m_layers.DeleteContents(TRUE); 00426 SetBackgroundColour( *wxWHITE ); 00427 EnableScrolling(FALSE, FALSE); 00428 SetSizeHints(128, 128); 00429 00430 //_bitmap_functions= new wxBitmap(700,800); 00431 00432 UpdateAll(); 00433 }
mpWindow::~mpWindow | ( | ) |
wxMenu* mpWindow::GetPopupMenu | ( | ) | [inline] |
Get reference to context menu of the plot canvas.
Definition at line 446 of file mathplot.h.
00446 { return &m_popmenu; }
void mpWindow::setType | ( | int | t | ) | [inline] |
Definition at line 454 of file mathplot.h.
Referenced by pPlotter::setType().
00455 { 00456 type=t; 00457 }
int mpWindow::getType | ( | ) | [inline] |
Definition at line 461 of file mathplot.h.
Referenced by pPlotter::update().
00462 { 00463 return type; 00464 }
void mpWindow::setMaxScrX | ( | int | maxX | ) | [inline] |
set the max value in the x axis
maxX |
Definition at line 471 of file mathplot.h.
Referenced by pPlotterWindow::actualizeViewRange(), pPlotterWindow::moveFunctions(), pPlotterWindow::onStartDrawing(), and pPlotterWindow::setActualScales().
00472 { 00473 maxScrX=maxX; 00474 }
void mpWindow::setMaxScrY | ( | int | maxY | ) | [inline] |
set the max value in the y axis
maxY |
Definition at line 479 of file mathplot.h.
Referenced by pPlotterWindow::onStartDrawing(), and pPlotterWindow::setActualScales().
00480 { 00481 maxScrY=maxY; 00482 }
double mpWindow::getMaxScrX | ( | ) | [inline] |
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] |
Get maximum value in y
Definition at line 495 of file mathplot.h.
Referenced by pPlotterScaleY::Plot().
00496 { 00497 return maxScrY; 00498 }
float mpWindow::getZoomFactor | ( | ) | [inline] |
Definition at line 502 of file mathplot.h.
Referenced by pPlotterScaleY::Plot(), and pPlotterScaleX::Plot().
00503 { 00504 return zoomFactor; 00505 }
void mpWindow::setMinScrX | ( | int | minX | ) | [inline] |
set the min value in the x axis
minX |
Definition at line 510 of file mathplot.h.
Referenced by pPlotterWindow::actualizeViewRange(), pPlotterWindow::moveFunctions(), and pPlotterWindow::setActualScales().
00511 { 00512 minScrX=minX; 00513 }
void mpWindow::setMinScrY | ( | int | minY | ) | [inline] |
set the min value in the y axis
minY |
Definition at line 518 of file mathplot.h.
Referenced by pPlotterWindow::setActualScales().
00519 { 00520 minScrY=minY; 00521 }
double mpWindow::getMinScrX | ( | ) | [inline] |
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] |
Get minimum value in y
Definition at line 534 of file mathplot.h.
Referenced by pPlotterScaleY::Plot().
00535 { 00536 return minScrY; 00537 }
int mpWindow::getClickedX | ( | ) | [inline] |
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] |
Get the y-clicked by the user
Definition at line 552 of file mathplot.h.
00553 { 00554 return m_clickedY; 00555 }
int mpWindow::getOffsetPixelsX | ( | ) | [inline] |
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] |
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 }
void mpWindow::setOffsetPixelX | ( | int | offX | ) | [inline] |
Set the x-offset of the zoom
Definition at line 577 of file mathplot.h.
Referenced by pPlotterWindow::onChangeActual(), pPlotterWindow::onMyZoomIn(), pPlotterWindow::onMyZoomOut(), and pPlotterWindow::onStartDrawing().
00578 { 00579 offsetPixelX=offX; 00580 }
void mpWindow::setOffsetPixelY | ( | int | offY | ) | [inline] |
Set the y-offset of the zoom
Definition at line 584 of file mathplot.h.
Referenced by pPlotterWindow::onChangeActual(), pPlotterWindow::onMyZoomIn(), pPlotterWindow::onMyZoomOut(), and pPlotterWindow::onStartDrawing().
00585 { 00586 offsetPixelY=offY; 00587 }
int mpWindow::getOffsetX | ( | ) | [inline] |
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] |
Gets the offset of the zoom
Definition at line 600 of file mathplot.h.
Referenced by pPlotterScaleY::Plot().
00601 { 00602 return offsetY; 00603 }
void mpWindow::setOffsetX | ( | int | offX | ) | [inline] |
Set the x-offset of the zoom
Definition at line 607 of file mathplot.h.
Referenced by pPlotterWindow::actualizeViewRange(), pPlotterWindow::moveFunctions(), pPlotterWindow::onChangeActual(), pPlotterWindow::onMyZoomIn(), pPlotterWindow::onMyZoomOut(), and pPlotterWindow::onStartDrawing().
00608 { 00609 offsetX=offX; 00610 }
void mpWindow::setOffsetY | ( | int | offY | ) | [inline] |
Set the y-offset of the zoom
Definition at line 614 of file mathplot.h.
Referenced by pPlotterWindow::onChangeActual(), pPlotterWindow::onMyZoomIn(), pPlotterWindow::onMyZoomOut(), and pPlotterWindow::onStartDrawing().
00615 { 00616 offsetY=offY; 00617 }
void mpWindow::setRealGuideX | ( | int | newX_realGuide | ) | [inline] |
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 }
int mpWindow::getRealGuideX | ( | ) | [inline] |
Definition at line 634 of file mathplot.h.
Referenced by pPlotterLayer::Plot().
00635 { 00636 return real_guideLine_X; 00637 }
void mpWindow::setRealGuideY | ( | int | newY_realGuide | ) | [inline] |
Definition at line 643 of file mathplot.h.
00644 { 00645 real_guideLine_Y = newY_realGuide; 00646 if(real_guideLine_Y!=-1) 00647 UpdateAll(); 00648 }
int mpWindow::getRealGuideY | ( | ) | [inline] |
Definition at line 654 of file mathplot.h.
Referenced by pPlotterLayer::Plot().
00655 { 00656 return real_guideLine_Y; 00657 }
bool mpWindow::drawGuideLines | ( | ) |
Reimplemented in pPlotterWindow.
Definition at line 746 of file mathplot.cxx.
References drawGuides.
Referenced by pPlotterLayer::drawLineToMousePoint().
00747 { 00748 return drawGuides; 00749 }
bool mpWindow::AddLayer | ( | mpLayer * | layer | ) |
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 544 of file mathplot.cxx.
References m_layers, and UpdateAll().
Referenced by pPlotterWindow::addFunction(), pPlotterWindow::onLoad(), and pPlotterWindow::onStartDrawing().
00545 { 00546 bool ret = m_layers.Append( layer) != NULL; 00547 UpdateAll(); 00548 return ret; 00549 }
void mpWindow::DelLayer | ( | mpLayer * | layer | ) |
Remove a plot layer from the canvas.
layer | Pointer to layer. The mpLayer object will be destructed using delete. |
Definition at line 551 of file mathplot.cxx.
References m_layers, and UpdateAll().
Referenced by pPlotterWindow::onStartDrawing(), and pPlotterWindow::onStopDrawing().
double mpWindow::GetScaleX | ( | void | ) | const [inline] |
Get current view's X scale. See rules for coordinate transformation
Definition at line 704 of file mathplot.h.
Referenced by OnScroll2(), mpScaleY::Plot(), mpScaleX::Plot(), mpFXY::Plot(), mpFY::Plot(), and mpFX::Plot().
00704 { return m_scaleX; }
double mpWindow::GetScaleY | ( | void | ) | const [inline] |
Get current view's Y scale. See rules for coordinate transformation
Definition at line 710 of file mathplot.h.
Referenced by OnScroll2(), mpScaleY::Plot(), mpScaleX::Plot(), mpFXY::Plot(), mpFY::Plot(), and mpFX::Plot().
00710 { return m_scaleY; }
double mpWindow::GetPosX | ( | void | ) | const [inline] |
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] |
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::GetScrX | ( | void | ) | const [inline] |
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] |
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; }
void mpWindow::SetScaleX | ( | double | scaleX | ) | [inline] |
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] |
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::SetPosX | ( | double | posX | ) | [inline] |
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 OnScroll2().
void mpWindow::SetPosY | ( | double | posY | ) | [inline] |
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 OnScroll2().
void mpWindow::SetPos | ( | double | posX, | |
double | posY | |||
) | [inline] |
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 OnCenter().
void mpWindow::LockAspect | ( | bool | enable = TRUE |
) |
Enable or disable X/Y scale aspect locking for the view.
Definition at line 485 of file mathplot.cxx.
References m_lockaspect, m_popmenu, m_scaleX, m_scaleY, mpID_LOCKASPECT, and UpdateAll().
Referenced by OnLockAspect().
00486 { 00487 m_lockaspect = enable; 00488 00489 m_popmenu.Check(mpID_LOCKASPECT, enable); 00490 00491 if (m_lockaspect) 00492 { 00493 double s = (m_scaleX + m_scaleY)/2; 00494 m_scaleX = s; 00495 m_scaleY = s; 00496 } 00497 00498 UpdateAll(); 00499 }
bool mpWindow::IsAspectLocked | ( | ) | [inline] |
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::Fit | ( | ) |
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 439 of file mathplot.cxx.
References m_lockaspect, m_maxX, m_maxY, m_minX, m_minY, m_posX, m_posY, m_scaleX, m_scaleY, UpdateAll(), and UpdateBBox().
Referenced by OnFit().
00440 { 00441 if (UpdateBBox()) 00442 { 00443 int cx, cy; 00444 GetClientSize( &cx, &cy); 00445 00446 double d; 00447 d = m_maxX - m_minX; 00448 if (d!=0) 00449 { 00450 m_scaleX = cx/d; 00451 m_posX = m_minX + d/2; 00452 } 00453 d = m_maxY - m_minY; 00454 if (d!=0) 00455 { 00456 m_scaleY = cy/d; 00457 m_posY = m_minY + d/2; 00458 } 00459 00460 if (m_lockaspect) 00461 { 00462 double s = (m_scaleX + m_scaleY)/2; 00463 m_scaleX = s; 00464 m_scaleY = s; 00465 } 00466 00467 UpdateAll(); 00468 } 00469 }
void mpWindow::ZoomIn | ( | ) |
Zoom into current view and refresh display
Definition at line 471 of file mathplot.cxx.
References m_scaleX, m_scaleY, and UpdateAll().
Referenced by OnZoomIn().
void mpWindow::ZoomOut | ( | ) |
Zoom out current view and refresh display
Definition at line 478 of file mathplot.cxx.
References m_scaleX, m_scaleY, and UpdateAll().
Referenced by OnZoomOut().
void mpWindow::UpdateAll | ( | ) |
Refresh display
Definition at line 701 of file mathplot.cxx.
References Refresh(), and UpdateBBox().
Referenced by pPlotterWindow::actualizeViewRange(), pPlotterWindow::addFunction(), pPlotterWindow::addFunctionToMove(), AddLayer(), DelLayer(), Fit(), LockAspect(), pPlotter::onActualChange_Bar(), pPlotterWindow::onAddNewPoint(), pPlotterWindow::onAddPoint(), pPlotterWindow::onChangeActual(), pPlotterWindow::onChangeColor(), pPlotter::onColorBar(), pPlotterWindow::onDeletePoint(), pPlotterWindow::OnGuideLines(), pPlotterWindow::onLine(), pPlotterWindow::onLoad(), pPlotterWindow::onMouseMove(), pPlotter::onMoved_ColorPoint(), pPlotterWindow::onMyZoomIn(), pPlotterWindow::onMyZoomOut(), pPlotterWindow::onNoShowPoints(), pPlotter::onSelectionEnd(), pPlotterWindow::onShowPoints(), OnSize(), pPlotterWindow::onSplinePoints(), pPlotterWindow::onStopDrawing(), pPlotter::update(), ZoomIn(), and ZoomOut().
00702 { 00703 if (UpdateBBox()) 00704 { 00705 int cx, cy; 00706 GetClientSize( &cx, &cy); 00707 printf("EED mpWindow::UpdateAll %d %d\n",cx,cy); 00708 00709 //const int sx = (int)((m_maxX - m_minX) * GetScaleX()); // JPRx 00710 //const int sy = (int)((m_maxY - m_minY) * GetScaleY()); // JPRx 00711 //const int px = (int)((GetPosX() - m_minX) * GetScaleX() - (cx>>1)); // JPRx 00712 //const int py = (int)((GetPosY() - m_minY) * GetScaleY() - (cy>>1)); // JPRx 00713 //SetScrollbars( 1, 1, sx, sy, px, py); 00714 } 00715 00716 FitInside(); 00717 Refresh( false ); 00718 }
int mpWindow::GetYTranslated | ( | wxSize | size, | |
double | y | |||
) | [inline] |
void mpWindow::Refresh | ( | bool | eraseBackground = true , |
|
const wxRect * | rect = NULL | |||
) | [protected] |
Definition at line 557 of file mathplot.cxx.
Referenced by UpdateAll().
void mpWindow::OnPaint | ( | wxPaintEvent & | event | ) | [protected] |
Paint handler, will plot all attached layers.
Definition at line 563 of file mathplot.cxx.
References _bitmap_functions, m_layers, m_scrX, and m_scrY.
00564 { 00565 wxPaintDC dc(this); 00566 dc.GetSize(&m_scrX, &m_scrY); 00567 printf("EED mpWindow::OnPaint %d %d\n",m_scrX,m_scrY); 00568 00569 //m_scrX=200; 00570 //m_scrY=200; 00571 00572 wxMemoryDC temp_dc; 00573 //_bitmap_functions->SetWidth(m_scrX); 00574 //_bitmap_functions->SetHeight(m_scrY); 00575 _bitmap_functions=new wxBitmap(m_scrX,m_scrY); 00576 temp_dc.SelectObject(*_bitmap_functions); 00577 00578 // Background 00579 // wxColour colourParent = wxColour(255,0,0); 00580 temp_dc.SetBrush(wxBrush( *wxWHITE_BRUSH ) ); 00581 temp_dc.SetPen(wxPen( *wxBLACK_PEN )); 00582 temp_dc.DrawRectangle(0,0,m_scrX,m_scrY); 00583 00584 00585 wxNode *node = m_layers.GetFirst(); 00586 while (node) 00587 { 00588 ((mpLayer*)node->GetData())->Plot( temp_dc, *this); 00589 node = node->GetNext(); 00590 } 00591 00592 //dc.SetDeviceOrigin(70,40); 00593 //dc.SetAxisOrientation(false,true); 00594 //temp_dc.SetAxisOrientation(true,false); 00595 00596 //EED 14mai2009 00597 //dc.Blit(0,0, m_scrX, m_scrY, &temp_dc,-70,-m_scrY+40); 00598 00599 temp_dc.SetDeviceOrigin(0,0); 00600 dc.Blit(0,0, m_scrX, m_scrY, &temp_dc,0,0); 00601 00602 00603 delete _bitmap_functions; 00604 //_bitmap_functions 00605 //dc.SetAxisOrientation(false,true); 00606 00607 00608 }
void mpWindow::OnSize | ( | wxSizeEvent & | event | ) | [protected] |
Size handler, will update scroll bar sizes.
Definition at line 539 of file mathplot.cxx.
References UpdateAll().
00540 { 00541 UpdateAll(); 00542 }
void mpWindow::OnScroll2 | ( | wxScrollWinEvent & | event | ) | [protected] |
Scroll handler, will move canvas.
Definition at line 653 of file mathplot.cxx.
References GetScaleX(), GetScaleY(), m_maxY, m_minX, SetPosX(), and SetPosY().
00654 { 00655 int width, height; 00656 GetClientSize( &width, &height); 00657 int px, py; 00658 GetViewStart( &px, &py); 00659 00660 if (event.GetOrientation() == wxHORIZONTAL) 00661 { 00662 SetPosX( (double)px / GetScaleX() + m_minX + (double)(width>>1)/GetScaleX()); 00663 } 00664 else 00665 { 00666 SetPosY( m_maxY - (double)py / GetScaleY() - (double)(height>>1)/GetScaleY()); 00667 } 00668 event.Skip(); 00669 }
void mpWindow::OnShowPopupMenu | ( | wxMouseEvent & | event | ) | [protected] |
Mouse handler, will show context menu.
Definition at line 501 of file mathplot.cxx.
References m_clickedX, m_clickedY, and m_popmenu.
00502 { 00503 m_clickedX = event.GetX(); 00504 m_clickedY = event.GetY(); 00505 PopupMenu( &m_popmenu, event.GetX(), event.GetY()); 00506 }
void mpWindow::OnCenter | ( | wxCommandEvent & | event | ) | [protected] |
Context menu handler.
Definition at line 518 of file mathplot.cxx.
References m_clickedX, m_clickedY, m_posX, m_posY, m_scaleX, m_scaleY, and SetPos().
00519 { 00520 int cx, cy; 00521 GetClientSize(&cx, &cy); 00522 SetPos( (double)(m_clickedX-cx/2) / m_scaleX + m_posX, (double)(cy/2-m_clickedY) / m_scaleY + m_posY); 00523 }
void mpWindow::OnFit | ( | wxCommandEvent & | event | ) | [protected] |
Context menu handler.
Definition at line 513 of file mathplot.cxx.
References Fit().
00514 { 00515 Fit(); 00516 }
void mpWindow::OnZoomIn | ( | wxCommandEvent & | event | ) | [protected] |
Context menu handler.
Definition at line 525 of file mathplot.cxx.
References m_clickedX, m_clickedY, m_posX, m_posY, m_scaleX, m_scaleY, and ZoomIn().
00526 { 00527 int cx, cy; 00528 GetClientSize(&cx, &cy); 00529 m_posX = (double)(m_clickedX-cx/2) / m_scaleX + m_posX; 00530 m_posY = (double)(cy/2-m_clickedY) / m_scaleY + m_posY; 00531 ZoomIn(); 00532 }
void mpWindow::OnZoomOut | ( | wxCommandEvent & | event | ) | [protected] |
Context menu handler.
Definition at line 534 of file mathplot.cxx.
References ZoomOut().
00535 { 00536 ZoomOut(); 00537 }
void mpWindow::OnLockAspect | ( | wxCommandEvent & | event | ) | [protected] |
Context menu handler.
Definition at line 508 of file mathplot.cxx.
References LockAspect(), m_popmenu, and mpID_LOCKASPECT.
00509 { 00510 LockAspect( !m_popmenu.IsChecked(mpID_LOCKASPECT) ); 00511 }
bool mpWindow::UpdateBBox | ( | ) | [protected] |
Recalculate global layer bounding box.
Definition at line 671 of file mathplot.cxx.
References mpLayer::GetMaxX(), mpLayer::GetMaxY(), mpLayer::GetMinX(), mpLayer::GetMinY(), mpLayer::HasBBox(), m_layers, m_maxX, m_maxY, m_minX, and m_minY.
Referenced by Fit(), and UpdateAll().
00672 { 00673 bool first = TRUE; 00674 00675 wxNode *node = m_layers.GetFirst(); 00676 00677 while(node) 00678 { 00679 mpLayer* f = (mpLayer*)node->GetData(); 00680 00681 if (f->HasBBox()) 00682 { 00683 if (first) 00684 { 00685 first = FALSE; 00686 m_minX = f->GetMinX(); m_maxX=f->GetMaxX(); 00687 m_minY = f->GetMinY(); m_maxY=f->GetMaxY(); 00688 } 00689 else 00690 { 00691 if (f->GetMinX()<m_minX) m_minX=f->GetMinX(); if (f->GetMaxX()>m_maxX) m_maxX=f->GetMaxX(); 00692 if (f->GetMinY()<m_minY) m_minY=f->GetMinY(); if (f->GetMaxY()>m_maxY) m_maxY=f->GetMaxY(); 00693 } 00694 } 00695 node = node->GetNext(); 00696 } 00697 00698 return first == FALSE; 00699 }
wxList mpWindow::m_layers [protected] |
List of attached plot layers.
Definition at line 818 of file mathplot.h.
Referenced by AddLayer(), DelLayer(), OnPaint(), and UpdateBBox().
wxMenu mpWindow::m_popmenu [protected] |
Canvas' context menu.
Definition at line 819 of file mathplot.h.
Referenced by pPlotterWindow::InitFunctionForVectors(), LockAspect(), pPlotterWindow::moveFunctions(), pPlotterWindow::onChangeActual(), pPlotterWindow::OnGuideLines(), pPlotterWindow::onLine(), pPlotterWindow::onLoad(), OnLockAspect(), pPlotterWindow::onMoveFunction(), pPlotterWindow::onNoShowPoints(), pPlotterWindow::onShowPoints(), OnShowPopupMenu(), pPlotterWindow::onSplinePoints(), pPlotterWindow::onStartDrawing(), pPlotterWindow::onStopDrawing(), and pPlotterWindow::setPopUpMenu().
bool mpWindow::m_lockaspect [protected] |
Scale aspect is locked or not.
Definition at line 820 of file mathplot.h.
Referenced by Fit(), and LockAspect().
double mpWindow::m_minX [protected] |
Global layer bounding box, left border incl.
Definition at line 822 of file mathplot.h.
Referenced by Fit(), OnScroll2(), and UpdateBBox().
double mpWindow::m_maxX [protected] |
Global layer bounding box, right border incl.
Definition at line 823 of file mathplot.h.
Referenced by Fit(), and UpdateBBox().
double mpWindow::m_minY [protected] |
Global layer bounding box, bottom border incl.
Definition at line 824 of file mathplot.h.
Referenced by Fit(), and UpdateBBox().
double mpWindow::m_maxY [protected] |
Global layer bounding box, top border incl.
Definition at line 825 of file mathplot.h.
Referenced by Fit(), OnScroll2(), and UpdateBBox().
double mpWindow::m_scaleX [protected] |
Current view's X scale.
Definition at line 826 of file mathplot.h.
Referenced by Fit(), pPlotterWindow::getRealPoint(), pPlotterWindow::InitFunctionForVectors(), LockAspect(), OnCenter(), OnZoomIn(), pPlotterWindow::setActualScales(), ZoomIn(), and ZoomOut().
double mpWindow::m_scaleY [protected] |
Current view's Y scale.
Definition at line 827 of file mathplot.h.
Referenced by Fit(), pPlotterWindow::getRealPoint(), pPlotterWindow::InitFunctionForVectors(), LockAspect(), OnCenter(), OnZoomIn(), pPlotterWindow::setActualScales(), ZoomIn(), and ZoomOut().
double mpWindow::m_posX [protected] |
Current view's X position.
Definition at line 828 of file mathplot.h.
Referenced by Fit(), OnCenter(), and OnZoomIn().
double mpWindow::m_posY [protected] |
Current view's Y position.
Definition at line 829 of file mathplot.h.
Referenced by Fit(), OnCenter(), and OnZoomIn().
int mpWindow::m_scrX [protected] |
Current view's X dimension.
Definition at line 830 of file mathplot.h.
Referenced by pPlotterWindow::actualizeViewRange(), pPlotterWindow::InitFunctionForVectors(), pPlotterWindow::onChangeActual(), pPlotterWindow::onMouseMove(), pPlotterWindow::onMyZoomIn(), pPlotterWindow::onMyZoomOut(), OnPaint(), and pPlotterWindow::setActualScales().
int mpWindow::m_scrY [protected] |
Current view's Y dimension.
Definition at line 831 of file mathplot.h.
Referenced by pPlotterWindow::InitFunctionForVectors(), pPlotterWindow::onAddNewPoint(), pPlotterWindow::onAddPoint(), pPlotterWindow::onChangeActual(), pPlotterWindow::onDeletePoint(), pPlotterWindow::onMouseMove(), pPlotterWindow::onMyZoomIn(), pPlotterWindow::onMyZoomOut(), OnPaint(), and pPlotterWindow::setActualScales().
int mpWindow::m_clickedX [protected] |
Last mouse click X position, for centering and zooming the view.
Definition at line 832 of file mathplot.h.
Referenced by pPlotterWindow::onAddNewPoint(), OnCenter(), pPlotterWindow::onDeletePoint(), pPlotterWindow::onMyZoomIn(), pPlotterWindow::onMyZoomOut(), OnShowPopupMenu(), and OnZoomIn().
int mpWindow::m_clickedY [protected] |
Last mouse click Y position, for centering and zooming the view.
Definition at line 833 of file mathplot.h.
Referenced by pPlotterWindow::onAddNewPoint(), OnCenter(), pPlotterWindow::onDeletePoint(), pPlotterWindow::onMyZoomIn(), pPlotterWindow::onMyZoomOut(), OnShowPopupMenu(), and OnZoomIn().
int mpWindow::maxScrX [protected] |
the max value in the x axis
Definition at line 841 of file mathplot.h.
Referenced by pPlotterWindow::actualizeViewRange(), pPlotterWindow::getRealPoint(), pPlotterWindow::InitFunctionForVectors(), and pPlotterWindow::onStartDrawing().
int mpWindow::maxScrY [protected] |
the max value in the y axis
Definition at line 846 of file mathplot.h.
Referenced by pPlotterWindow::getRealPoint(), pPlotterWindow::InitFunctionForVectors(), and pPlotterWindow::onStartDrawing().
int mpWindow::minScrX [protected] |
the min value in the x axis
Definition at line 850 of file mathplot.h.
Referenced by pPlotterWindow::actualizeViewRange(), pPlotterWindow::getRealPoint(), pPlotterWindow::InitFunctionForVectors(), and pPlotterWindow::onStartDrawing().
int mpWindow::minScrY [protected] |
the min value in the y axis
Definition at line 855 of file mathplot.h.
Referenced by pPlotterWindow::getRealPoint(), pPlotterWindow::InitFunctionForVectors(), and pPlotterWindow::onStartDrawing().
float mpWindow::zoomFactor [protected] |
Definition at line 860 of file mathplot.h.
Referenced by pPlotterWindow::actualizeViewRange(), pPlotterWindow::onChangeActual(), pPlotterWindow::onLoad(), pPlotterWindow::onMyZoomIn(), pPlotterWindow::onMyZoomOut(), pPlotterWindow::onStartDrawing(), and pPlotterWindow::setActualScales().
int mpWindow::offsetPixelX [protected] |
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 pPlotterWindow::getRealPoint().
int mpWindow::offsetPixelY [protected] |
int mpWindow::offsetX [protected] |
int mpWindow::offsetY [protected] |
int mpWindow::real_guideLine_X [protected] |
Definition at line 878 of file mathplot.h.
int mpWindow::real_guideLine_Y [protected] |
Definition at line 882 of file mathplot.h.
bool mpWindow::drawGuides [protected] |
Definition at line 887 of file mathplot.h.
Referenced by drawGuideLines(), and pPlotterWindow::OnGuideLines().
int mpWindow::type [protected] |
Definition at line 893 of file mathplot.h.
Referenced by pPlotterWindow::InitFunctionForVectors(), pPlotterWindow::moveFunctions(), pPlotterWindow::onChangeActual(), and pPlotterWindow::onMouseMove().
wxBitmap* mpWindow::_bitmap_functions [private] |