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"
26 #include "wx/object.h"
28 #include "wx/colour.h"
29 #include "wx/settings.h"
33 #include "wx/dcclient.h"
36 #include "wx/generic/plot.h"
37 #include "wx/bmpbuttn.h"
41 // ----------------------------------------------------------------------------
43 // ----------------------------------------------------------------------------
45 #if !defined(__WXMSW__) && !defined(__WXPM__)
46 #include "wx/generic/plot_enl.xpm"
47 #include "wx/generic/plot_shr.xpm"
48 #include "wx/generic/plot_zin.xpm"
49 #include "wx/generic/plot_zot.xpm"
50 #include "wx/generic/plot_up.xpm"
51 #include "wx/generic/plot_dwn.xpm"
54 // ----------------------------------------------------------------------------
55 // accessor functions for the bitmaps (may return NULL, check for it!)
56 // ----------------------------------------------------------------------------
58 static wxBitmap
*GetEnlargeBitmap();
59 static wxBitmap
*GetShrinkBitmap();
60 static wxBitmap
*GetZoomInBitmap();
61 static wxBitmap
*GetZoomOutBitmap();
62 static wxBitmap
*GetUpBitmap();
63 static wxBitmap
*GetDownBitmap();
65 //-----------------------------------------------------------------------------
67 //-----------------------------------------------------------------------------
69 #define wxPLOT_SCROLL_STEP 30
71 //-----------------------------------------------------------------------------
73 //-----------------------------------------------------------------------------
75 wxPlotEvent::wxPlotEvent( wxEventType commandType
, int id
)
76 : wxNotifyEvent( commandType
, id
)
78 m_curve
= (wxPlotCurve
*) NULL
;
83 //-----------------------------------------------------------------------------
85 //-----------------------------------------------------------------------------
87 IMPLEMENT_ABSTRACT_CLASS(wxPlotCurve
, wxObject
)
89 wxPlotCurve::wxPlotCurve( int offsetY
, double startY
, double endY
)
96 //-----------------------------------------------------------------------------
98 //-----------------------------------------------------------------------------
100 IMPLEMENT_DYNAMIC_CLASS(wxPlotArea
, wxWindow
)
102 BEGIN_EVENT_TABLE(wxPlotArea
, wxWindow
)
103 EVT_PAINT( wxPlotArea::OnPaint
)
104 EVT_LEFT_DOWN( wxPlotArea::OnMouse
)
105 EVT_LEFT_DCLICK( wxPlotArea::OnMouse
)
108 wxPlotArea::wxPlotArea( wxPlotWindow
*parent
)
109 : wxWindow( parent
, -1, wxDefaultPosition
, wxDefaultSize
, wxSIMPLE_BORDER
, "plotarea" )
115 SetBackgroundColour( *wxWHITE
);
118 void wxPlotArea::OnMouse( wxMouseEvent
&event
)
122 GetClientSize( &client_width
, &client_height
);
125 m_owner
->GetViewStart( &view_x
, &view_y
);
126 view_x
*= wxPLOT_SCROLL_STEP
;
127 view_y
*= wxPLOT_SCROLL_STEP
;
129 wxCoord x
= event
.GetX();
130 wxCoord y
= event
.GetY();
134 wxNode
*node
= m_owner
->m_curves
.First();
137 wxPlotCurve
*curve
= (wxPlotCurve
*)node
->Data();
139 double double_client_height
= (double)client_height
;
140 double range
= curve
->GetEndY() - curve
->GetStartY();
141 double end
= curve
->GetEndY();
142 wxCoord offset_y
= curve
->GetOffsetY();
144 double dy
= (end
- curve
->GetY( (wxInt32
)(x
/m_owner
->GetZoom()) )) / range
;
145 wxCoord curve_y
= (wxCoord
)(dy
* double_client_height
) - offset_y
- 1;
147 if ((y
-curve_y
< 4) && (y
-curve_y
> -4))
149 wxPlotEvent
event1( event
.ButtonDClick() ? wxEVT_PLOT_DOUBLECLICKED
: wxEVT_PLOT_CLICKED
, m_owner
->GetId() );
150 event1
.SetEventObject( m_owner
);
151 event1
.SetZoom( m_owner
->GetZoom() );
152 event1
.SetCurve( curve
);
153 event1
.SetPosition( (int)floor(x
/m_owner
->GetZoom()) );
154 m_owner
->GetEventHandler()->ProcessEvent( event1
);
156 if (curve
!= m_owner
->GetCurrent());
158 wxPlotEvent
event2( wxEVT_PLOT_SEL_CHANGING
, m_owner
->GetId() );
159 event2
.SetEventObject( m_owner
);
160 event2
.SetZoom( m_owner
->GetZoom() );
161 event2
.SetCurve( curve
);
162 if (!m_owner
->GetEventHandler()->ProcessEvent( event2
) || event2
.IsAllowed())
164 m_owner
->SetCurrent( curve
);
174 void wxPlotArea::DeleteCurve( wxPlotCurve
*curve
, int from
, int to
)
177 m_owner
->PrepareDC( dc
);
178 dc
.SetPen( *wxWHITE_PEN
);
179 DrawCurve( &dc
, curve
, from
, to
);
182 void wxPlotArea::DrawCurve( wxDC
*dc
, wxPlotCurve
*curve
, int from
, int to
)
186 m_owner
->GetViewStart( &view_x
, &view_y
);
187 view_x
*= wxPLOT_SCROLL_STEP
;
194 GetClientSize( &client_width
, &client_height
);
197 to
= view_x
+ client_width
;
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
);
209 double double_client_height
= (double)client_height
;
210 double range
= curve
->GetEndY() - curve
->GetStartY();
211 double end
= curve
->GetEndY();
212 wxCoord offset_y
= curve
->GetOffsetY();
214 wxCoord y
=0,last_y
=0;
215 for (int x
= start_x
; x
< end_x
; x
++)
217 double dy
= (end
- curve
->GetY( (wxInt32
)(x
/zoom
) )) / range
;
218 y
= (wxCoord
)(dy
* double_client_height
) - offset_y
- 1;
221 dc
->DrawLine( x
-1, last_y
, x
, y
);
227 void wxPlotArea::OnPaint( wxPaintEvent
&WXUNUSED(event
) )
231 m_owner
->GetViewStart( &view_x
, &view_y
);
232 view_x
*= wxPLOT_SCROLL_STEP
;
233 view_y
*= wxPLOT_SCROLL_STEP
;
235 wxPaintDC
dc( this );
236 m_owner
->PrepareDC( dc
);
238 wxRegionIterator
upd( GetUpdateRegion() );
242 int update_x
= upd
.GetX();
243 int update_y
= upd
.GetY();
244 int update_width
= upd
.GetWidth();
250 if (m_owner->m_current)
252 dc.SetPen( *wxLIGHT_GREY_PEN );
253 int base_line = client_height - m_owner->m_current->GetOffsetY();
254 dc.DrawLine( update_x-1, base_line-1, update_x+update_width+2, base_line-1 );
258 wxNode
*node
= m_owner
->m_curves
.First();
261 wxPlotCurve
*curve
= (wxPlotCurve
*)node
->Data();
263 if (curve
== m_owner
->GetCurrent())
264 dc
.SetPen( *wxBLACK_PEN
);
266 dc
.SetPen( *wxGREY_PEN
);
268 DrawCurve( &dc
, curve
, update_x
-1, update_x
+update_width
+2 );
276 void wxPlotArea::ScrollWindow( int dx
, int dy
, const wxRect
*rect
)
278 wxWindow::ScrollWindow( dx
, dy
, rect
);
279 // m_owner->m_xaxis->ScrollWindow( dx, 0 );
282 //-----------------------------------------------------------------------------
284 //-----------------------------------------------------------------------------
286 IMPLEMENT_DYNAMIC_CLASS(wxPlotXAxisArea
, wxWindow
)
288 BEGIN_EVENT_TABLE(wxPlotXAxisArea
, wxWindow
)
289 EVT_PAINT( wxPlotXAxisArea::OnPaint
)
290 EVT_LEFT_DOWN( wxPlotXAxisArea::OnMouse
)
293 wxPlotXAxisArea::wxPlotXAxisArea( wxPlotWindow
*parent
)
294 : wxWindow( parent
, -1, wxDefaultPosition
, wxSize(-1,40), 0, "plotxaxisarea" )
298 SetBackgroundColour( *wxWHITE
);
299 SetFont( *wxSMALL_FONT
);
302 void wxPlotXAxisArea::OnMouse( wxMouseEvent
&event
)
306 GetClientSize( &client_width
, &client_height
);
309 m_owner
->GetViewStart( &view_x
, &view_y
);
310 view_x
*= wxPLOT_SCROLL_STEP
;
311 view_y
*= wxPLOT_SCROLL_STEP
;
313 wxCoord x
= event
.GetX();
314 wxCoord y
= event
.GetY();
318 /* do something here */
321 void wxPlotXAxisArea::OnPaint( wxPaintEvent
&WXUNUSED(event
) )
325 m_owner
->GetViewStart( &view_x
, &view_y
);
326 view_x
*= wxPLOT_SCROLL_STEP
;
327 view_y
*= wxPLOT_SCROLL_STEP
;
329 wxPaintDC
dc( this );
333 GetClientSize( &client_width
, &client_height
);
335 double zoom
= m_owner
->GetZoom();
337 double ups
= m_owner
->GetUnitsPerValue() / zoom
;
339 double start
= view_x
* ups
;
340 double end
= (view_x
+ client_width
) * ups
;
341 double range
= end
- start
;
343 int int_log_range
= (int)floor( log10( range
) );
345 if (int_log_range
> 0)
347 for (int i
= 0; i
< int_log_range
; i
++)
350 if (int_log_range
< 0)
352 for (int i
= 0; i
< -int_log_range
; i
++)
355 double lower
= ceil(start
/ step
) * step
;
356 double upper
= floor(end
/ step
) * step
;
358 // if too few values, shrink size
359 if ((range
/step
) < 4)
362 if (lower
-step
> start
) lower
-= step
;
363 if (upper
+step
< end
) upper
+= step
;
366 // if still too few, again
367 if ((range
/step
) < 4)
370 if (lower
-step
> start
) lower
-= step
;
371 if (upper
+step
< end
) upper
+= step
;
374 dc
.SetBrush( *wxWHITE_BRUSH
);
375 dc
.SetPen( *wxTRANSPARENT_PEN
);
376 dc
.DrawRectangle( 4, 5, client_width
-14, 10 );
377 dc
.DrawRectangle( 0, 20, client_width
, 20 );
378 dc
.SetPen( *wxBLACK_PEN
);
380 double current
= lower
;
381 while (current
< upper
+(step
/2))
383 int x
= (int)ceil((current
-start
) / range
* (double)client_width
) - 1;
384 if ((x
> 4) && (x
< client_width
-25))
386 dc
.DrawLine( x
, 5, x
, 15 );
390 label
.Printf( wxT("%f"), current
);
391 while (label
.Last() == wxT('0'))
393 if ((label
.Last() == wxT('.')) || (label
.Last() == wxT(',')))
394 label
.Append( wxT('0') );
397 label
.Printf( wxT("%d"), (int)floor(current
) );
398 dc
.DrawText( label
, x
-4, 20 );
404 dc
.DrawLine( 0, 15, client_width
-8, 15 );
405 dc
.DrawLine( client_width
-4, 15, client_width
-10, 10 );
406 dc
.DrawLine( client_width
-4, 15, client_width
-10, 20 );
409 //-----------------------------------------------------------------------------
411 //-----------------------------------------------------------------------------
413 IMPLEMENT_DYNAMIC_CLASS(wxPlotYAxisArea
, wxWindow
)
415 BEGIN_EVENT_TABLE(wxPlotYAxisArea
, wxWindow
)
416 EVT_PAINT( wxPlotYAxisArea::OnPaint
)
417 EVT_LEFT_DOWN( wxPlotYAxisArea::OnMouse
)
420 wxPlotYAxisArea::wxPlotYAxisArea( wxPlotWindow
*parent
)
421 : wxWindow( parent
, -1, wxDefaultPosition
, wxSize(60,-1), 0, "plotyaxisarea" )
425 SetBackgroundColour( *wxWHITE
);
426 SetFont( *wxSMALL_FONT
);
429 void wxPlotYAxisArea::OnMouse( wxMouseEvent
&WXUNUSED(event
) )
431 /* do something here */
434 void wxPlotYAxisArea::OnPaint( wxPaintEvent
&WXUNUSED(event
) )
436 wxPaintDC
dc( this );
438 wxPlotCurve
*curve
= m_owner
->GetCurrent();
444 GetClientSize( &client_width
, &client_height
);
447 double range
= curve
->GetEndY() - curve
->GetStartY();
448 double offset
= ((double) curve
->GetOffsetY() / (double)client_height
) * range
;
449 double start
= curve
->GetStartY() - offset
;
450 double end
= curve
->GetEndY() - offset
;
452 int int_log_range
= (int)floor( log10( range
) );
454 if (int_log_range
> 0)
456 for (int i
= 0; i
< int_log_range
; i
++)
459 if (int_log_range
< 0)
461 for (int i
= 0; i
< -int_log_range
; i
++)
464 double lower
= ceil(start
/ step
) * step
;
465 double upper
= floor(end
/ step
) * step
;
467 // if too few values, shrink size
468 if ((range
/step
) < 4)
471 if (lower
-step
> start
) lower
-= step
;
472 if (upper
+step
< end
) upper
+= step
;
475 // if still too few, again
476 if ((range
/step
) < 4)
479 if (lower
-step
> start
) lower
-= step
;
480 if (upper
+step
< end
) upper
+= step
;
483 dc
.SetPen( *wxBLACK_PEN
);
485 double current
= lower
;
486 while (current
< upper
+(step
/2))
488 int y
= (int)((curve
->GetEndY()-current
) / range
* (double)client_height
) - 1;
489 y
-= curve
->GetOffsetY();
490 if ((y
> 10) && (y
< client_height
-7))
492 dc
.DrawLine( client_width
-15, y
, client_width
-7, y
);
496 label
.Printf( wxT("%f"), current
);
497 while (label
.Last() == wxT('0'))
499 if ((label
.Last() == wxT('.')) || (label
.Last() == wxT(',')))
500 label
.Append( wxT('0') );
503 label
.Printf( wxT("%d"), (int)floor(current
) );
504 dc
.DrawText( label
, 5, y
-7 );
510 dc
.DrawLine( client_width
-15, 6, client_width
-15, client_height
);
511 dc
.DrawLine( client_width
-15, 2, client_width
-20, 8 );
512 dc
.DrawLine( client_width
-15, 2, client_width
-10, 8 );
515 //-----------------------------------------------------------------------------
517 //-----------------------------------------------------------------------------
519 #define ID_ENLARGE 1000
520 #define ID_SHRINK 1002
522 #define ID_MOVE_UP 1006
523 #define ID_MOVE_DOWN 1007
525 #define ID_ZOOM_IN 1010
526 #define ID_ZOOM_OUT 1011
529 IMPLEMENT_DYNAMIC_CLASS(wxPlotWindow
, wxScrolledWindow
)
531 BEGIN_EVENT_TABLE(wxPlotWindow
, wxScrolledWindow
)
532 EVT_BUTTON( ID_MOVE_UP
, wxPlotWindow::OnMoveUp
)
533 EVT_BUTTON( ID_MOVE_DOWN
, wxPlotWindow::OnMoveDown
)
535 EVT_BUTTON( ID_ENLARGE
, wxPlotWindow::OnEnlarge
)
536 EVT_BUTTON( ID_SHRINK
, wxPlotWindow::OnShrink
)
538 EVT_BUTTON( ID_ZOOM_IN
, wxPlotWindow::OnZoomIn
)
539 EVT_BUTTON( ID_ZOOM_OUT
, wxPlotWindow::OnZoomOut
)
541 EVT_SCROLLWIN( wxPlotWindow::OnScroll2
)
544 wxPlotWindow::wxPlotWindow( wxWindow
*parent
, wxWindowID id
, const wxPoint
&pos
, const wxSize
&size
, int flag
)
545 : wxScrolledWindow( parent
, id
, pos
, size
, flag
, "plotcanvas" )
547 m_xUnitsPerValue
= 1.0;
550 m_enlargeAroundWindowCentre
= FALSE
;
551 m_scrollOnThumbRelease
= FALSE
;
553 m_area
= new wxPlotArea( this );
554 wxBoxSizer
*mainsizer
= new wxBoxSizer( wxHORIZONTAL
);
556 if ((GetWindowStyleFlag() & wxPLOT_BUTTON_ALL
) != 0)
558 wxBoxSizer
*buttonlist
= new wxBoxSizer( wxVERTICAL
);
559 if ((GetWindowStyleFlag() & wxPLOT_BUTTON_ENLARGE
) != 0)
561 buttonlist
->Add( new wxBitmapButton( this, ID_ENLARGE
, *GetEnlargeBitmap() ), 0, wxEXPAND
|wxALL
, 2 );
562 buttonlist
->Add( new wxBitmapButton( this, ID_SHRINK
, *GetShrinkBitmap() ), 0, wxEXPAND
|wxALL
, 2 );
563 buttonlist
->Add( 20,10, 0 );
565 if ((GetWindowStyleFlag() & wxPLOT_BUTTON_MOVE
) != 0)
567 buttonlist
->Add( new wxBitmapButton( this, ID_MOVE_UP
, *GetUpBitmap() ), 0, wxEXPAND
|wxALL
, 2 );
568 buttonlist
->Add( new wxBitmapButton( this, ID_MOVE_DOWN
, *GetDownBitmap() ), 0, wxEXPAND
|wxALL
, 2 );
569 buttonlist
->Add( 20,10, 0 );
571 if ((GetWindowStyleFlag() & wxPLOT_BUTTON_ZOOM
) != 0)
573 buttonlist
->Add( new wxBitmapButton( this, ID_ZOOM_IN
, *GetZoomInBitmap() ), 0, wxEXPAND
|wxALL
, 2 );
574 buttonlist
->Add( new wxBitmapButton( this, ID_ZOOM_OUT
, *GetZoomOutBitmap() ), 0, wxEXPAND
|wxALL
, 2 );
576 mainsizer
->Add( buttonlist
, 0, wxEXPAND
|wxALL
, 4 );
579 wxBoxSizer
*plotsizer
= new wxBoxSizer( wxHORIZONTAL
);
581 if ((GetWindowStyleFlag() & wxPLOT_Y_AXIS
) != 0)
583 m_yaxis
= new wxPlotYAxisArea( this );
585 wxBoxSizer
*vert1
= new wxBoxSizer( wxVERTICAL
);
586 plotsizer
->Add( vert1
, 0, wxEXPAND
);
587 vert1
->Add( m_yaxis
, 1 );
588 if ((GetWindowStyleFlag() & wxPLOT_X_AXIS
) != 0)
589 vert1
->Add( 60, 40 );
593 m_yaxis
= (wxPlotYAxisArea
*) NULL
;
596 if ((GetWindowStyleFlag() & wxPLOT_X_AXIS
) != 0)
598 m_xaxis
= new wxPlotXAxisArea( this );
600 wxBoxSizer
*vert2
= new wxBoxSizer( wxVERTICAL
);
601 plotsizer
->Add( vert2
, 1, wxEXPAND
);
602 vert2
->Add( m_area
, 1, wxEXPAND
);
603 vert2
->Add( m_xaxis
, 0, wxEXPAND
);
607 plotsizer
->Add( m_area
, 1, wxEXPAND
);
608 m_xaxis
= (wxPlotXAxisArea
*) NULL
;
611 mainsizer
->Add( plotsizer
, 1, wxEXPAND
);
613 SetAutoLayout( TRUE
);
614 SetSizer( mainsizer
);
616 SetTargetWindow( m_area
);
618 SetBackgroundColour( *wxWHITE
);
620 m_current
= (wxPlotCurve
*) NULL
;
623 wxPlotWindow::~wxPlotWindow()
627 void wxPlotWindow::Add( wxPlotCurve
*curve
)
629 m_curves
.Append( curve
);
630 if (!m_current
) m_current
= curve
;
635 size_t wxPlotWindow::GetCount()
637 return m_curves
.GetCount();
640 wxPlotCurve
*wxPlotWindow::GetAt( size_t n
)
642 wxNode
*node
= m_curves
.Nth( n
);
644 return (wxPlotCurve
*) NULL
;
646 return (wxPlotCurve
*) node
->Data();
649 void wxPlotWindow::SetCurrent( wxPlotCurve
* current
)
652 m_area
->Refresh( FALSE
);
656 wxPlotEvent
event( wxEVT_PLOT_SEL_CHANGED
, GetId() );
657 event
.SetEventObject( this );
658 event
.SetZoom( GetZoom() );
659 event
.SetCurve( m_current
);
660 GetEventHandler()->ProcessEvent( event
);
663 void wxPlotWindow::Delete( wxPlotCurve
* curve
)
665 wxNode
*node
= m_curves
.Find( curve
);
668 m_curves
.DeleteObject( curve
);
670 m_area
->DeleteCurve( curve
);
671 m_area
->Refresh( FALSE
);
674 wxPlotCurve
*wxPlotWindow::GetCurrent()
679 void wxPlotWindow::Move( wxPlotCurve
* curve
, int pixels_up
)
681 m_area
->DeleteCurve( curve
);
683 curve
->SetOffsetY( curve
->GetOffsetY() + pixels_up
);
685 m_area
->Refresh( FALSE
);
690 void wxPlotWindow::OnMoveUp( wxCommandEvent
& WXUNUSED(event
) )
692 if (!m_current
) return;
694 Move( m_current
, 25 );
697 void wxPlotWindow::OnMoveDown( wxCommandEvent
& WXUNUSED(event
) )
699 if (!m_current
) return;
701 Move( m_current
, -25 );
704 void wxPlotWindow::Enlarge( wxPlotCurve
*curve
, double factor
)
706 m_area
->DeleteCurve( curve
);
710 m_area
->GetClientSize( &client_width
, &client_height
);
711 double offset
= (double)curve
->GetOffsetY() / (double)client_height
;
713 double range
= curve
->GetEndY() - curve
->GetStartY();
716 double new_range
= range
/ factor
;
717 double new_offset
= offset
/ factor
;
719 if (m_enlargeAroundWindowCentre
)
721 double middle
= curve
->GetStartY() - offset
+ range
/2;
723 curve
->SetStartY( middle
- new_range
/ 2 + new_offset
);
724 curve
->SetEndY( middle
+ new_range
/ 2 + new_offset
);
728 curve
->SetStartY( (curve
->GetStartY() - offset
)/factor
+ new_offset
);
729 curve
->SetEndY( (curve
->GetEndY() - offset
)/factor
+ new_offset
);
732 m_area
->Refresh( FALSE
);
736 void wxPlotWindow::SetUnitsPerValue( double upv
)
738 m_xUnitsPerValue
= upv
;
743 void wxPlotWindow::SetZoom( double zoom
)
745 double old_zoom
= m_xZoom
;
750 GetViewStart( &view_x
, &view_y
);
753 wxNode
*node
= m_curves
.First();
756 wxPlotCurve
*curve
= (wxPlotCurve
*) node
->Data();
757 if (curve
->GetEndX() > max
)
758 max
= curve
->GetEndX();
761 SetScrollbars( wxPLOT_SCROLL_STEP
, wxPLOT_SCROLL_STEP
,
762 (int)((max
*m_xZoom
)/wxPLOT_SCROLL_STEP
)+1, 0,
763 (int)(view_x
*zoom
/old_zoom
), 0,
767 m_area
->Refresh( TRUE
);
770 void wxPlotWindow::ResetScrollbar()
773 wxNode
*node
= m_curves
.First();
776 wxPlotCurve
*curve
= (wxPlotCurve
*) node
->Data();
777 if (curve
->GetEndX() > max
)
778 max
= curve
->GetEndX();
782 SetScrollbars( wxPLOT_SCROLL_STEP
, wxPLOT_SCROLL_STEP
,
783 (int)(((max
*m_xZoom
)/wxPLOT_SCROLL_STEP
)+1), 0 );
786 void wxPlotWindow::RedrawXAxis()
789 m_xaxis
->Refresh( FALSE
);
792 void wxPlotWindow::RedrawYAxis()
795 m_yaxis
->Refresh( TRUE
);
798 void wxPlotWindow::RedrawEverything()
801 m_xaxis
->Refresh( TRUE
);
803 m_yaxis
->Refresh( TRUE
);
804 m_area
->Refresh( TRUE
);
807 void wxPlotWindow::OnZoomIn( wxCommandEvent
& WXUNUSED(event
) )
809 SetZoom( m_xZoom
* 1.5 );
812 void wxPlotWindow::OnZoomOut( wxCommandEvent
& WXUNUSED(event
) )
814 SetZoom( m_xZoom
* 0.6666 );
817 void wxPlotWindow::OnEnlarge( wxCommandEvent
& WXUNUSED(event
) )
819 if (!m_current
) return;
821 Enlarge( m_current
, 1.5 );
824 void wxPlotWindow::OnShrink( wxCommandEvent
& WXUNUSED(event
) )
826 if (!m_current
) return;
828 Enlarge( m_current
, 0.6666666 );
831 void wxPlotWindow::OnScroll2( wxScrollWinEvent
& event
)
833 if ((!m_scrollOnThumbRelease
) || (event
.GetEventType() != wxEVT_SCROLLWIN_THUMBTRACK
))
835 wxScrolledWindow::OnScroll( event
);
840 // ----------------------------------------------------------------------------
842 // ----------------------------------------------------------------------------
845 static wxBitmap
*GetEnlargeBitmap()
847 static wxBitmap
* s_bitmap
= (wxBitmap
*) NULL
;
848 static bool s_loaded
= FALSE
;
852 s_loaded
= TRUE
; // set it to TRUE anyhow, we won't try again
854 #if defined(__WXMSW__) || defined(__WXPM__)
855 s_bitmap
= new wxBitmap("plot_enl_bmp", wxBITMAP_TYPE_RESOURCE
);
857 s_bitmap
= new wxBitmap( plot_enl_xpm
);
864 static wxBitmap
*GetShrinkBitmap()
866 static wxBitmap
* s_bitmap
= (wxBitmap
*) NULL
;
867 static bool s_loaded
= FALSE
;
871 s_loaded
= TRUE
; // set it to TRUE anyhow, we won't try again
873 #if defined(__WXMSW__) || defined(__WXPM__)
874 s_bitmap
= new wxBitmap("plot_shr_bmp", wxBITMAP_TYPE_RESOURCE
);
876 s_bitmap
= new wxBitmap( plot_shr_xpm
);
883 static wxBitmap
*GetZoomInBitmap()
885 static wxBitmap
* s_bitmap
= (wxBitmap
*) NULL
;
886 static bool s_loaded
= FALSE
;
890 s_loaded
= TRUE
; // set it to TRUE anyhow, we won't try again
892 #if defined(__WXMSW__) || defined(__WXPM__)
893 s_bitmap
= new wxBitmap("plot_zin_bmp", wxBITMAP_TYPE_RESOURCE
);
895 s_bitmap
= new wxBitmap( plot_zin_xpm
);
902 static wxBitmap
*GetZoomOutBitmap()
904 static wxBitmap
* s_bitmap
= (wxBitmap
*) NULL
;
905 static bool s_loaded
= FALSE
;
909 s_loaded
= TRUE
; // set it to TRUE anyhow, we won't try again
911 #if defined(__WXMSW__) || defined(__WXPM__)
912 s_bitmap
= new wxBitmap("plot_zot_bmp", wxBITMAP_TYPE_RESOURCE
);
914 s_bitmap
= new wxBitmap( plot_zot_xpm
);
921 static wxBitmap
*GetUpBitmap()
923 static wxBitmap
* s_bitmap
= (wxBitmap
*) NULL
;
924 static bool s_loaded
= FALSE
;
928 s_loaded
= TRUE
; // set it to TRUE anyhow, we won't try again
930 #if defined(__WXMSW__) || defined(__WXPM__)
931 s_bitmap
= new wxBitmap("plot_up_bmp", wxBITMAP_TYPE_RESOURCE
);
933 s_bitmap
= new wxBitmap( plot_up_xpm
);
940 static wxBitmap
*GetDownBitmap()
942 static wxBitmap
* s_bitmap
= (wxBitmap
*) NULL
;
943 static bool s_loaded
= FALSE
;
947 s_loaded
= TRUE
; // set it to TRUE anyhow, we won't try again
949 #if defined(__WXMSW__) || defined(__WXPM__)
950 s_bitmap
= new wxBitmap("plot_dwn_bmp", wxBITMAP_TYPE_RESOURCE
);
952 s_bitmap
= new wxBitmap( plot_dwn_xpm
);