21#if !defined ( WXPLPLOTWINDOW_H__INCLUDED_ )
22#define WXPLPLOTWINDOW_H__INCLUDED_
27#include <wx/dcmemory.h>
28#include <wx/dcclient.h>
29#include <wx/dcgraph.h>
30#include <wx/dcbuffer.h>
36template <
class WXWINDOW>
40 wxPLplotwindow(
bool useGraphicsContext =
true, wxSize clientSize = wxDefaultSize,
41 int resizeRenderDelay_ms = 0 );
45 bool SavePlot(
const wxString& driver,
const wxString& filename );
52 virtual void OnPaint( wxPaintEvent& event );
53 virtual void OnSize( wxSizeEvent & event );
54 virtual void OnErase( wxEraseEvent &event );
55 virtual void OnCreate( wxWindowCreateEvent &event );
57 void OnMouse( wxMouseEvent &event );
70#ifdef wxUSE_GRAPHICS_CONTEXT
85template<
class WXWINDOW>
93template<
class WXWINDOW>
100#ifdef wxUSE_GRAPHICS_CONTEXT
126template<
class WXWINDOW>
141template<
class WXWINDOW>
152 int width = WXWINDOW::GetClientSize().GetWidth();
153 int height = WXWINDOW::GetClientSize().GetHeight();
155 wxPaintDC paintDc(
this );
169 paintDc.Blit( 0, 0, width, height,
m_memoryDc, 0, 0 );
175 bool needResize = width !=
m_bitmap.GetWidth() || height !=
m_bitmap.GetHeight();
178 m_bitmap.Create( width, height, 32 );
184#ifdef wxUSE_GRAPHICS_CONTEXT
201 paintDc.Blit( 0, 0, width, height,
m_memoryDc, 0, 0 );
203 if ( width > 0 && height > 0 )
210template<
class WXWINDOW>
220 int width = WXWINDOW::GetClientSize().GetWidth();
221 int height = WXWINDOW::GetClientSize().GetHeight();
225 ( width == oldWidth && height == oldHeight ) )
240 if ( width > oldWidth )
241 WXWINDOW::RefreshRect( wxRect( width, 0, width - oldWidth, height ) );
242 if ( height > oldHeight )
243 WXWINDOW::RefreshRect( wxRect( 0, oldHeight, oldWidth, height - oldHeight ) );
252template<
class WXWINDOW>
264template<
class WXWINDOW>
274 int width = WXWINDOW::GetClientSize().GetWidth();
275 int height = WXWINDOW::GetClientSize().GetHeight();
282#ifdef wxUSE_GRAPHICS_CONTEXT
303template<
class WXWINDOW>
314template<
class WXWINDOW>
318 wxPoint cursorPosition =
event.GetPosition();
319 wxSize clientSize = WXWINDOW::GetClientSize();
321 graphicsIn.
pX = cursorPosition.x;
322 graphicsIn.
pY = cursorPosition.y;
323 graphicsIn.
dX =
PLFLT( cursorPosition.x + 0.5 ) /
PLFLT( clientSize.GetWidth() );
324 graphicsIn.
dY = 1.0 -
PLFLT( cursorPosition.y + 0.5 ) /
PLFLT( clientSize.GetHeight() );
326 graphicsIn.
state = 0;
329 graphicsIn.
string[0] =
'\0';
330 if ( event.LeftUp() )
335 else if ( event.MiddleUp() )
340 else if ( event.RightUp() )
345 else if ( event.Aux1Up() )
350 else if ( event.Aux2Up() )
360 graphicsIn.
state = 0;
364 if ( wxGetKeyState( WXK_SHIFT ) )
366 if ( wxGetKeyState( WXK_CAPITAL ) )
368 if ( wxGetKeyState( WXK_ALT ) && wxGetKeyState( WXK_CONTROL ) )
370 else if ( wxGetKeyState( WXK_CONTROL ) )
372 else if ( wxGetKeyState( WXK_ALT ) )
374 if ( wxGetKeyState( WXK_NUMLOCK ) )
376 if ( wxGetKeyState( WXK_SCROLL ) )
381 m_stream.translatecursor( &graphicsIn );
388template<
class WXWINDOW>
401template<
class WXWINDOW>
407 if ( ( sfile = fopen( filename.mb_str(),
"wb+" ) ) == NULL )
419 plsdev( devname.mb_str() );
422 plspage( 0., 0., 800, 600, 0, 0 );
435template<
class WXWINDOW>
439#ifdef wxUSE_GRAPHICS_CONTEXT
453template<
class WXWINDOW>
wxPLplotstream is inherited from plstream, which is the C++ interface
virtual void OnCreate(wxWindowCreateEvent &event)
Window created event.
void RenewPlot(void)
Redo plot.
static const int ID_RENDERTIMER
void setUseGraphicsContext(bool useGraphicsContext)
wxPLplotwindow(bool useGraphicsContext=true, wxSize clientSize=wxDefaultSize, int resizeRenderDelay_ms=0)
Constructor.
wxPLplotstream m_stream
The wxPLplotstream which belongs to this plot widget.
virtual void OnPaint(wxPaintEvent &event)
Paint event.
wxPLplotstream * GetStream()
Get pointer to wxPLplotstream of this widget.
void setCanvasColour(const wxColour &colour)
virtual void OnSize(wxSizeEvent &event)
Size event.
size_t m_resizeRenderDelay
void OnRenderTimer(wxTimerEvent &event)
Timer used in delayed rendering after resize.
virtual void OnErase(wxEraseEvent &event)
Background erase event.
virtual ~wxPLplotwindow(void)
Destructor.
bool m_completedFirstRender
bool m_created
Flag to indicate the window has been Created.
virtual void OnLocate(const PLGraphicsIn &graphicsIn)
bool SavePlot(const wxString &driver, const wxString &filename)
Save plot using a different driver.
void OnMouse(wxMouseEvent &event)
Mouse events.
bool m_useGraphicsContext
Flag to indicate whether we should use a wxGCDC.
static PLStream * pls[PL_NSTREAMS]
#define PLPLOT_wxLogDebug(string)