1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxPlotWindow
4 // Author: Robert Roebling
8 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "plot.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
24 #include "wx/object.h"
26 #include "wx/colour.h"
27 #include "wx/settings.h"
31 #include "wx/dcclient.h"
34 #include "wx/generic/plot.h"
35 #include "wx/bmpbuttn.h"
39 // ----------------------------------------------------------------------------
41 // ----------------------------------------------------------------------------
43 #if !defined(__WXMSW__) && !defined(__WXPM__)
44 #include "wx/generic/plot_enl.xpm"
45 #include "wx/generic/plot_shr.xpm"
46 #include "wx/generic/plot_zin.xpm"
47 #include "wx/generic/plot_zot.xpm"
48 #include "wx/generic/plot_up.xpm"
49 #include "wx/generic/plot_dwn.xpm"
52 // ----------------------------------------------------------------------------
53 // accessor functions for the bitmaps (may return NULL, check for it!)
54 // ----------------------------------------------------------------------------
56 static wxBitmap
*GetEnlargeBitmap();
57 static wxBitmap
*GetShrinkBitmap();
58 static wxBitmap
*GetZoomInBitmap();
59 static wxBitmap
*GetZoomOutBitmap();
60 static wxBitmap
*GetUpBitmap();
61 static wxBitmap
*GetDownBitmap();
63 //-----------------------------------------------------------------------------
65 //-----------------------------------------------------------------------------
67 #define wxPLOT_SCROLL_STEP 30
69 //-----------------------------------------------------------------------------
71 //-----------------------------------------------------------------------------
73 wxPlotEvent::wxPlotEvent( wxEventType commandType
, int id
)
74 : wxNotifyEvent( commandType
, id
)
76 m_curve
= (wxPlotCurve
*) NULL
;
81 //-----------------------------------------------------------------------------
83 //-----------------------------------------------------------------------------
85 IMPLEMENT_ABSTRACT_CLASS(wxPlotCurve
, wxObject
)
87 wxPlotCurve::wxPlotCurve( int offsetY
, double startY
, double endY
)
94 //-----------------------------------------------------------------------------
96 //-----------------------------------------------------------------------------
98 IMPLEMENT_DYNAMIC_CLASS(wxPlotArea
, wxWindow
)
100 BEGIN_EVENT_TABLE(wxPlotArea
, wxWindow
)
101 EVT_PAINT( wxPlotArea::OnPaint
)
102 EVT_LEFT_DOWN( wxPlotArea::OnMouse
)
103 EVT_LEFT_DCLICK( wxPlotArea::OnMouse
)
106 wxPlotArea::wxPlotArea( wxPlotWindow
*parent
)
107 : wxWindow( parent
, -1, wxDefaultPosition
, wxDefaultSize
, wxSIMPLE_BORDER
, "plotarea" )
113 SetBackgroundColour( *wxWHITE
);
116 void wxPlotArea::OnMouse( wxMouseEvent
&event
)
120 GetClientSize( &client_width
, &client_height
);
123 m_owner
->GetViewStart( &view_x
, &view_y
);
124 view_x
*= wxPLOT_SCROLL_STEP
;
125 view_y
*= wxPLOT_SCROLL_STEP
;
127 int x
= event
.GetX();
128 int y
= event
.GetY();
132 wxNode
*node
= m_owner
->m_curves
.First();
135 wxPlotCurve
*curve
= (wxPlotCurve
*)node
->Data();
137 double double_client_height
= (double)client_height
;
138 double range
= curve
->GetEndY() - curve
->GetStartY();
139 double end
= curve
->GetEndY();
140 wxCoord offset_y
= curve
->GetOffsetY();
142 double dy
= (end
- curve
->GetY( x
/m_owner
->GetZoom() )) / range
;
143 wxCoord curve_y
= (wxCoord
)(dy
* double_client_height
) - offset_y
- 1;
145 if ((y
-curve_y
< 4) && (y
-curve_y
> -4))
147 wxPlotEvent
event1( event
.ButtonDClick() ? wxEVT_PLOT_DOUBLECLICKED
: wxEVT_PLOT_CLICKED
, m_owner
->GetId() );
148 event1
.SetEventObject( m_owner
);
149 event1
.SetZoom( m_owner
->GetZoom() );
150 event1
.SetCurve( curve
);
151 event1
.SetPosition( (int)floor(x
/m_owner
->GetZoom()) );
152 m_owner
->GetEventHandler()->ProcessEvent( event1
);
154 if (curve
!= m_owner
->GetCurrent());
156 wxPlotEvent
event2( wxEVT_PLOT_SEL_CHANGING
, m_owner
->GetId() );
157 event2
.SetEventObject( m_owner
);
158 event2
.SetZoom( m_owner
->GetZoom() );
159 event2
.SetCurve( curve
);
160 if (!m_owner
->GetEventHandler()->ProcessEvent( event2
) || event2
.IsAllowed())
162 m_owner
->SetCurrent( curve
);
172 void wxPlotArea::DeleteCurve( wxPlotCurve
*curve
, int from
, int to
)
175 m_owner
->PrepareDC( dc
);
176 dc
.SetPen( *wxWHITE_PEN
);
177 DrawCurve( &dc
, curve
, from
, to
);
180 void wxPlotArea::DrawCurve( wxDC
*dc
, wxPlotCurve
*curve
, int from
, int to
)
184 m_owner
->GetViewStart( &view_x
, &view_y
);
185 view_x
*= wxPLOT_SCROLL_STEP
;
192 GetClientSize( &client_width
, &client_height
);
195 to
= view_x
+ client_width
;
197 to
+= 2; // no idea why this is needed
199 double zoom
= m_owner
->GetZoom();
201 int start_x
= wxMax( from
, (int)floor(curve
->GetStartX()*zoom
) );
202 int end_x
= wxMin( to
, (int)floor(curve
->GetEndX()*zoom
) );
204 start_x
= wxMax( view_x
, start_x
);
205 end_x
= wxMin( view_x
+ client_width
, end_x
);
207 double double_client_height
= (double)client_height
;
208 double range
= curve
->GetEndY() - curve
->GetStartY();
209 double end
= curve
->GetEndY();
210 wxCoord offset_y
= curve
->GetOffsetY();
212 wxCoord y
=0,last_y
=0;
213 for (int x
= start_x
; x
< end_x
; x
++)
215 double dy
= (end
- curve
->GetY( x
/zoom
)) / range
;
216 y
= (wxCoord
)(dy
* double_client_height
) - offset_y
- 1;
219 dc
->DrawLine( x
-1, last_y
, x
, y
);
225 void wxPlotArea::OnPaint( wxPaintEvent
&WXUNUSED(event
) )
229 m_owner
->GetViewStart( &view_x
, &view_y
);
230 view_x
*= wxPLOT_SCROLL_STEP
;
231 view_y
*= wxPLOT_SCROLL_STEP
;
233 wxPaintDC
dc( this );
234 m_owner
->PrepareDC( dc
);
236 wxRegionIterator
upd( GetUpdateRegion() );
240 int update_x
= upd
.GetX();
241 int update_y
= upd
.GetY();
242 int update_width
= upd
.GetWidth();
248 if (m_owner->m_current)
250 dc.SetPen( *wxLIGHT_GREY_PEN );
251 int base_line = client_height - m_owner->m_current->GetOffsetY();
252 dc.DrawLine( update_x-1, base_line-1, update_x+update_width+2, base_line-1 );
256 wxNode
*node
= m_owner
->m_curves
.First();
259 wxPlotCurve
*curve
= (wxPlotCurve
*)node
->Data();
261 if (curve
== m_owner
->GetCurrent())
262 dc
.SetPen( *wxBLACK_PEN
);
264 dc
.SetPen( *wxGREY_PEN
);
266 DrawCurve( &dc
, curve
, update_x
-1, update_x
+update_width
+2 );
274 void wxPlotArea::ScrollWindow( int dx
, int dy
, const wxRect
*rect
)
276 wxWindow::ScrollWindow( dx
, dy
, rect
);
277 // m_owner->m_xaxis->ScrollWindow( dx, 0 );
280 //-----------------------------------------------------------------------------
282 //-----------------------------------------------------------------------------
284 IMPLEMENT_DYNAMIC_CLASS(wxPlotXAxisArea
, wxWindow
)
286 BEGIN_EVENT_TABLE(wxPlotXAxisArea
, wxWindow
)
287 EVT_PAINT( wxPlotXAxisArea::OnPaint
)
288 EVT_LEFT_DOWN( wxPlotXAxisArea::OnMouse
)
291 wxPlotXAxisArea::wxPlotXAxisArea( wxPlotWindow
*parent
)
292 : wxWindow( parent
, -1, wxDefaultPosition
, wxSize(-1,40), 0, "plotxaxisarea" )
296 SetBackgroundColour( *wxWHITE
);
297 SetFont( *wxSMALL_FONT
);
300 void wxPlotXAxisArea::OnMouse( wxMouseEvent
&event
)
304 GetClientSize( &client_width
, &client_height
);
307 m_owner
->GetViewStart( &view_x
, &view_y
);
308 view_x
*= wxPLOT_SCROLL_STEP
;
309 view_y
*= wxPLOT_SCROLL_STEP
;
311 int x
= event
.GetX();
312 int y
= event
.GetY();
316 /* do something here */
319 void wxPlotXAxisArea::OnPaint( wxPaintEvent
&WXUNUSED(event
) )
323 m_owner
->GetViewStart( &view_x
, &view_y
);
324 view_x
*= wxPLOT_SCROLL_STEP
;
325 view_y
*= wxPLOT_SCROLL_STEP
;
327 wxPaintDC
dc( this );
331 GetClientSize( &client_width
, &client_height
);
333 double zoom
= m_owner
->GetZoom();
335 double ups
= m_owner
->GetUnitsPerValue() / zoom
;
337 double start
= view_x
* ups
;
338 double end
= (view_x
+ client_width
) * ups
;
339 double range
= end
- start
;
341 int int_log_range
= (int)floor( log10( range
) );
343 if (int_log_range
> 0)
345 for (int i
= 0; i
< int_log_range
; i
++)
348 if (int_log_range
< 0)
350 for (int i
= 0; i
< -int_log_range
; i
++)
353 double lower
= ceil(start
/ step
) * step
;
354 double upper
= floor(end
/ step
) * step
;
356 // if too few values, shrink size
357 if ((range
/step
) < 4)
360 if (lower
-step
> start
) lower
-= step
;
361 if (upper
+step
< end
) upper
+= step
;
364 // if still too few, again
365 if ((range
/step
) < 4)
368 if (lower
-step
> start
) lower
-= step
;
369 if (upper
+step
< end
) upper
+= step
;
372 dc
.SetBrush( *wxWHITE_BRUSH
);
373 dc
.SetPen( *wxTRANSPARENT_PEN
);
374 dc
.DrawRectangle( 4, 5, client_width
-14, 10 );
375 dc
.DrawRectangle( 0, 20, client_width
, 20 );
376 dc
.SetPen( *wxBLACK_PEN
);
378 double current
= lower
;
379 while (current
< upper
+(step
/2))
381 int x
= (int)ceil((current
-start
) / range
* (double)client_width
) - 1;
382 if ((x
> 4) && (x
< client_width
-25))
384 dc
.DrawLine( x
, 5, x
, 15 );
388 label
.Printf( wxT("%f"), current
);
389 while (label
.Last() == wxT('0'))
391 if ((label
.Last() == wxT('.')) || (label
.Last() == wxT(',')))
392 label
.Append( wxT('0') );
395 label
.Printf( wxT("%d"), (int)floor(current
) );
396 dc
.DrawText( label
, x
-4, 20 );
402 dc
.DrawLine( 0, 15, client_width
-8, 15 );
403 dc
.DrawLine( client_width
-4, 15, client_width
-10, 10 );
404 dc
.DrawLine( client_width
-4, 15, client_width
-10, 20 );
407 //-----------------------------------------------------------------------------
409 //-----------------------------------------------------------------------------
411 IMPLEMENT_DYNAMIC_CLASS(wxPlotYAxisArea
, wxWindow
)
413 BEGIN_EVENT_TABLE(wxPlotYAxisArea
, wxWindow
)
414 EVT_PAINT( wxPlotYAxisArea::OnPaint
)
415 EVT_LEFT_DOWN( wxPlotYAxisArea::OnMouse
)
418 wxPlotYAxisArea::wxPlotYAxisArea( wxPlotWindow
*parent
)
419 : wxWindow( parent
, -1, wxDefaultPosition
, wxSize(60,-1), 0, "plotyaxisarea" )
423 SetBackgroundColour( *wxWHITE
);
424 SetFont( *wxSMALL_FONT
);
427 void wxPlotYAxisArea::OnMouse( wxMouseEvent
&WXUNUSED(event
) )
429 /* do something here */
432 void wxPlotYAxisArea::OnPaint( wxPaintEvent
&WXUNUSED(event
) )
434 wxPaintDC
dc( this );
436 wxPlotCurve
*curve
= m_owner
->GetCurrent();
442 GetClientSize( &client_width
, &client_height
);
445 double range
= curve
->GetEndY() - curve
->GetStartY();
446 double offset
= ((double) curve
->GetOffsetY() / (double)client_height
) * range
;
447 double start
= curve
->GetStartY() - offset
;
448 double end
= curve
->GetEndY() - offset
;
450 int int_log_range
= (int)floor( log10( range
) );
452 if (int_log_range
> 0)
454 for (int i
= 0; i
< int_log_range
; i
++)
457 if (int_log_range
< 0)
459 for (int i
= 0; i
< -int_log_range
; i
++)
462 double lower
= ceil(start
/ step
) * step
;
463 double upper
= floor(end
/ step
) * step
;
465 // if too few values, shrink size
466 if ((range
/step
) < 4)
469 if (lower
-step
> start
) lower
-= step
;
470 if (upper
+step
< end
) upper
+= step
;
473 // if still too few, again
474 if ((range
/step
) < 4)
477 if (lower
-step
> start
) lower
-= step
;
478 if (upper
+step
< end
) upper
+= step
;
481 dc
.SetPen( *wxBLACK_PEN
);
483 double current
= lower
;
484 while (current
< upper
+(step
/2))
486 int y
= (int)((curve
->GetEndY()-current
) / range
* (double)client_height
) - 1;
487 y
-= curve
->GetOffsetY();
488 if ((y
> 10) && (y
< client_height
-7))
490 dc
.DrawLine( client_width
-15, y
, client_width
-7, y
);
494 label
.Printf( wxT("%f"), current
);
495 while (label
.Last() == wxT('0'))
497 if ((label
.Last() == wxT('.')) || (label
.Last() == wxT(',')))
498 label
.Append( wxT('0') );
501 label
.Printf( wxT("%d"), (int)floor(current
) );
502 dc
.DrawText( label
, 5, y
-7 );
508 dc
.DrawLine( client_width
-15, 6, client_width
-15, client_height
);
509 dc
.DrawLine( client_width
-15, 2, client_width
-20, 8 );
510 dc
.DrawLine( client_width
-15, 2, client_width
-10, 8 );
513 //-----------------------------------------------------------------------------
515 //-----------------------------------------------------------------------------
517 #define ID_ENLARGE 1000
518 #define ID_SHRINK 1002
520 #define ID_MOVE_UP 1006
521 #define ID_MOVE_DOWN 1007
523 #define ID_ZOOM_IN 1010
524 #define ID_ZOOM_OUT 1011
527 IMPLEMENT_DYNAMIC_CLASS(wxPlotWindow
, wxScrolledWindow
)
529 BEGIN_EVENT_TABLE(wxPlotWindow
, wxScrolledWindow
)
530 EVT_BUTTON( ID_MOVE_UP
, wxPlotWindow::OnMoveUp
)
531 EVT_BUTTON( ID_MOVE_DOWN
, wxPlotWindow::OnMoveDown
)
533 EVT_BUTTON( ID_ENLARGE
, wxPlotWindow::OnEnlarge
)
534 EVT_BUTTON( ID_SHRINK
, wxPlotWindow::OnShrink
)
536 EVT_BUTTON( ID_ZOOM_IN
, wxPlotWindow::OnZoomIn
)
537 EVT_BUTTON( ID_ZOOM_OUT
, wxPlotWindow::OnZoomOut
)
539 EVT_SCROLLWIN( wxPlotWindow::OnScroll2
)
542 wxPlotWindow::wxPlotWindow( wxWindow
*parent
, wxWindowID id
, const wxPoint
&pos
, const wxSize
&size
, int flag
)
543 : wxScrolledWindow( parent
, id
, pos
, size
, flag
, "plotcanvas" )
545 m_xUnitsPerValue
= 1.0;
548 m_enlargeAroundWindowCentre
= FALSE
;
549 m_scrollOnThumbRelease
= FALSE
;
551 m_area
= new wxPlotArea( this );
552 wxBoxSizer
*mainsizer
= new wxBoxSizer( wxHORIZONTAL
);
554 if ((GetWindowStyleFlag() & wxPLOT_BUTTON_ALL
) != 0)
556 wxBoxSizer
*buttonlist
= new wxBoxSizer( wxVERTICAL
);
557 if ((GetWindowStyleFlag() & wxPLOT_BUTTON_ENLARGE
) != 0)
559 buttonlist
->Add( new wxBitmapButton( this, ID_ENLARGE
, *GetEnlargeBitmap() ), 0, wxEXPAND
|wxALL
, 2 );
560 buttonlist
->Add( new wxBitmapButton( this, ID_SHRINK
, *GetShrinkBitmap() ), 0, wxEXPAND
|wxALL
, 2 );
561 buttonlist
->Add( 20,10, 0 );
563 if ((GetWindowStyleFlag() & wxPLOT_BUTTON_MOVE
) != 0)
565 buttonlist
->Add( new wxBitmapButton( this, ID_MOVE_UP
, *GetUpBitmap() ), 0, wxEXPAND
|wxALL
, 2 );
566 buttonlist
->Add( new wxBitmapButton( this, ID_MOVE_DOWN
, *GetDownBitmap() ), 0, wxEXPAND
|wxALL
, 2 );
567 buttonlist
->Add( 20,10, 0 );
569 if ((GetWindowStyleFlag() & wxPLOT_BUTTON_ZOOM
) != 0)
571 buttonlist
->Add( new wxBitmapButton( this, ID_ZOOM_IN
, *GetZoomInBitmap() ), 0, wxEXPAND
|wxALL
, 2 );
572 buttonlist
->Add( new wxBitmapButton( this, ID_ZOOM_OUT
, *GetZoomOutBitmap() ), 0, wxEXPAND
|wxALL
, 2 );
574 mainsizer
->Add( buttonlist
, 0, wxEXPAND
|wxALL
, 4 );
577 wxBoxSizer
*plotsizer
= new wxBoxSizer( wxHORIZONTAL
);
579 if ((GetWindowStyleFlag() & wxPLOT_Y_AXIS
) != 0)
581 m_yaxis
= new wxPlotYAxisArea( this );
583 wxBoxSizer
*vert1
= new wxBoxSizer( wxVERTICAL
);
584 plotsizer
->Add( vert1
, 0, wxEXPAND
);
585 vert1
->Add( m_yaxis
, 1 );
586 if ((GetWindowStyleFlag() & wxPLOT_X_AXIS
) != 0)
587 vert1
->Add( 60, 40 );
591 m_yaxis
= (wxPlotYAxisArea
*) NULL
;
594 if ((GetWindowStyleFlag() & wxPLOT_X_AXIS
) != 0)
596 m_xaxis
= new wxPlotXAxisArea( this );
598 wxBoxSizer
*vert2
= new wxBoxSizer( wxVERTICAL
);
599 plotsizer
->Add( vert2
, 1, wxEXPAND
);
600 vert2
->Add( m_area
, 1, wxEXPAND
);
601 vert2
->Add( m_xaxis
, 0, wxEXPAND
);
605 plotsizer
->Add( m_area
, 1, wxEXPAND
);
606 m_xaxis
= (wxPlotXAxisArea
*) NULL
;
609 mainsizer
->Add( plotsizer
, 1, wxEXPAND
);
611 SetAutoLayout( TRUE
);
612 SetSizer( mainsizer
);
614 SetTargetWindow( m_area
);
616 SetBackgroundColour( *wxWHITE
);
618 m_current
= (wxPlotCurve
*) NULL
;
621 wxPlotWindow::~wxPlotWindow()
625 void wxPlotWindow::Add( wxPlotCurve
*curve
)
627 m_curves
.Append( curve
);
628 if (!m_current
) m_current
= curve
;
633 size_t wxPlotWindow::GetCount()
635 return m_curves
.GetCount();
638 wxPlotCurve
*wxPlotWindow::GetAt( size_t n
)
640 wxNode
*node
= m_curves
.Nth( n
);
642 return (wxPlotCurve
*) NULL
;
644 return (wxPlotCurve
*) node
->Data();
647 void wxPlotWindow::SetCurrent( wxPlotCurve
* current
)
650 m_area
->Refresh( FALSE
);
654 wxPlotEvent
event( wxEVT_PLOT_SEL_CHANGED
, GetId() );
655 event
.SetEventObject( this );
656 event
.SetZoom( GetZoom() );
657 event
.SetCurve( m_current
);
658 GetEventHandler()->ProcessEvent( event
);
661 void wxPlotWindow::Delete( wxPlotCurve
* curve
)
663 wxNode
*node
= m_curves
.Find( curve
);
666 m_curves
.DeleteObject( curve
);
668 m_area
->DeleteCurve( curve
);
669 m_area
->Refresh( FALSE
);
672 wxPlotCurve
*wxPlotWindow::GetCurrent()
677 void wxPlotWindow::Move( wxPlotCurve
* curve
, int pixels_up
)
679 m_area
->DeleteCurve( curve
);
681 curve
->SetOffsetY( curve
->GetOffsetY() + pixels_up
);
683 m_area
->Refresh( FALSE
);
688 void wxPlotWindow::OnMoveUp( wxCommandEvent
& WXUNUSED(event
) )
690 if (!m_current
) return;
692 Move( m_current
, 25 );
695 void wxPlotWindow::OnMoveDown( wxCommandEvent
& WXUNUSED(event
) )
697 if (!m_current
) return;
699 Move( m_current
, -25 );
702 void wxPlotWindow::Enlarge( wxPlotCurve
*curve
, double factor
)
704 m_area
->DeleteCurve( curve
);
708 m_area
->GetClientSize( &client_width
, &client_height
);
709 double offset
= (double)curve
->GetOffsetY() / (double)client_height
;
711 double range
= curve
->GetEndY() - curve
->GetStartY();
714 double new_range
= range
/ factor
;
715 double new_offset
= offset
/ factor
;
717 if (m_enlargeAroundWindowCentre
)
719 double middle
= curve
->GetStartY() - offset
+ range
/2;
721 curve
->SetStartY( middle
- new_range
/ 2 + new_offset
);
722 curve
->SetEndY( middle
+ new_range
/ 2 + new_offset
);
726 curve
->SetStartY( (curve
->GetStartY() - offset
)/factor
+ new_offset
);
727 curve
->SetEndY( (curve
->GetEndY() - offset
)/factor
+ new_offset
);
730 m_area
->Refresh( FALSE
);
734 void wxPlotWindow::SetUnitsPerValue( double upv
)
736 m_xUnitsPerValue
= upv
;
741 void wxPlotWindow::SetZoom( double zoom
)
743 double old_zoom
= m_xZoom
;
748 GetViewStart( &view_x
, &view_y
);
751 wxNode
*node
= m_curves
.First();
754 wxPlotCurve
*curve
= (wxPlotCurve
*) node
->Data();
755 if (curve
->GetEndX() > max
)
756 max
= curve
->GetEndX();
759 SetScrollbars( wxPLOT_SCROLL_STEP
, wxPLOT_SCROLL_STEP
,
760 (int)((max
*m_xZoom
)/wxPLOT_SCROLL_STEP
)+1, 0,
761 (int)view_x
*zoom
/old_zoom
, 0,
765 m_area
->Refresh( TRUE
);
768 void wxPlotWindow::ResetScrollbar()
771 wxNode
*node
= m_curves
.First();
774 wxPlotCurve
*curve
= (wxPlotCurve
*) node
->Data();
775 if (curve
->GetEndX() > max
)
776 max
= curve
->GetEndX();
780 SetScrollbars( wxPLOT_SCROLL_STEP
, wxPLOT_SCROLL_STEP
,
781 ((max
*m_xZoom
)/wxPLOT_SCROLL_STEP
)+1, 0 );
784 void wxPlotWindow::RedrawXAxis()
787 m_xaxis
->Refresh( FALSE
);
790 void wxPlotWindow::RedrawYAxis()
793 m_yaxis
->Refresh( TRUE
);
796 void wxPlotWindow::RedrawEverything()
799 m_xaxis
->Refresh( TRUE
);
801 m_yaxis
->Refresh( TRUE
);
802 m_area
->Refresh( TRUE
);
805 void wxPlotWindow::OnZoomIn( wxCommandEvent
& WXUNUSED(event
) )
807 SetZoom( m_xZoom
* 1.5 );
810 void wxPlotWindow::OnZoomOut( wxCommandEvent
& WXUNUSED(event
) )
812 SetZoom( m_xZoom
* 0.6666 );
815 void wxPlotWindow::OnEnlarge( wxCommandEvent
& WXUNUSED(event
) )
817 if (!m_current
) return;
819 Enlarge( m_current
, 1.5 );
822 void wxPlotWindow::OnShrink( wxCommandEvent
& WXUNUSED(event
) )
824 if (!m_current
) return;
826 Enlarge( m_current
, 0.6666666 );
829 void wxPlotWindow::OnScroll2( wxScrollWinEvent
& event
)
831 if ((!m_scrollOnThumbRelease
) || (event
.GetEventType() != wxEVT_SCROLLWIN_THUMBTRACK
))
833 wxScrolledWindow::OnScroll( event
);
838 // ----------------------------------------------------------------------------
840 // ----------------------------------------------------------------------------
843 static wxBitmap
*GetEnlargeBitmap()
845 static wxBitmap
* s_bitmap
= (wxBitmap
*) NULL
;
846 static bool s_loaded
= FALSE
;
850 s_loaded
= TRUE
; // set it to TRUE anyhow, we won't try again
852 #if defined(__WXMSW__) || defined(__WXPM__)
853 s_bitmap
= new wxBitmap("plot_enl_bmp", wxBITMAP_TYPE_RESOURCE
);
855 s_bitmap
= new wxBitmap( plot_enl_xpm
);
862 static wxBitmap
*GetShrinkBitmap()
864 static wxBitmap
* s_bitmap
= (wxBitmap
*) NULL
;
865 static bool s_loaded
= FALSE
;
869 s_loaded
= TRUE
; // set it to TRUE anyhow, we won't try again
871 #if defined(__WXMSW__) || defined(__WXPM__)
872 s_bitmap
= new wxBitmap("plot_shr_bmp", wxBITMAP_TYPE_RESOURCE
);
874 s_bitmap
= new wxBitmap( plot_shr_xpm
);
881 static wxBitmap
*GetZoomInBitmap()
883 static wxBitmap
* s_bitmap
= (wxBitmap
*) NULL
;
884 static bool s_loaded
= FALSE
;
888 s_loaded
= TRUE
; // set it to TRUE anyhow, we won't try again
890 #if defined(__WXMSW__) || defined(__WXPM__)
891 s_bitmap
= new wxBitmap("plot_zin_bmp", wxBITMAP_TYPE_RESOURCE
);
893 s_bitmap
= new wxBitmap( plot_zin_xpm
);
900 static wxBitmap
*GetZoomOutBitmap()
902 static wxBitmap
* s_bitmap
= (wxBitmap
*) NULL
;
903 static bool s_loaded
= FALSE
;
907 s_loaded
= TRUE
; // set it to TRUE anyhow, we won't try again
909 #if defined(__WXMSW__) || defined(__WXPM__)
910 s_bitmap
= new wxBitmap("plot_zot_bmp", wxBITMAP_TYPE_RESOURCE
);
912 s_bitmap
= new wxBitmap( plot_zot_xpm
);
919 static wxBitmap
*GetUpBitmap()
921 static wxBitmap
* s_bitmap
= (wxBitmap
*) NULL
;
922 static bool s_loaded
= FALSE
;
926 s_loaded
= TRUE
; // set it to TRUE anyhow, we won't try again
928 #if defined(__WXMSW__) || defined(__WXPM__)
929 s_bitmap
= new wxBitmap("plot_up_bmp", wxBITMAP_TYPE_RESOURCE
);
931 s_bitmap
= new wxBitmap( plot_up_xpm
);
938 static wxBitmap
*GetDownBitmap()
940 static wxBitmap
* s_bitmap
= (wxBitmap
*) NULL
;
941 static bool s_loaded
= FALSE
;
945 s_loaded
= TRUE
; // set it to TRUE anyhow, we won't try again
947 #if defined(__WXMSW__) || defined(__WXPM__)
948 s_bitmap
= new wxBitmap("plot_dwn_bmp", wxBITMAP_TYPE_RESOURCE
);
950 s_bitmap
= new wxBitmap( plot_dwn_xpm
);