21 #if !defined ( WXPLPLOTWINDOW_H__INCLUDED_ ) 22 #define WXPLPLOTWINDOW_H__INCLUDED_ 26 #include <wx/window.h> 27 #include <wx/dcmemory.h> 28 #include <wx/dcclient.h> 29 #include <wx/dcgraph.h> 30 #include <wx/dcbuffer.h> 36 template <
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 85 template<
class WXWINDOW>
93 template<
class WXWINDOW>
100 #ifdef wxUSE_GRAPHICS_CONTEXT 126 template<
class WXWINDOW>
141 template<
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 )
210 template<
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 ) );
252 template<
class WXWINDOW>
264 template<
class WXWINDOW>
274 int width = WXWINDOW::GetClientSize().GetWidth();
275 int height = WXWINDOW::GetClientSize().GetHeight();
282 #ifdef wxUSE_GRAPHICS_CONTEXT 303 template<
class WXWINDOW>
314 template<
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 ) )
388 template<
class WXWINDOW>
401 template<
class WXWINDOW>
407 if ( ( sfile = fopen( filename.mb_str(),
"wb+" ) ) == NULL )
419 plsdev( devname.mb_str() );
422 plspage( 0., 0., 800, 600, 0, 0 );
435 template<
class WXWINDOW>
439 #ifdef wxUSE_GRAPHICS_CONTEXT 453 template<
class WXWINDOW>
460 #endif // !defined( WXPLPLOTWINDOW_H__INCLUDED_ )
void Create(wxDC *dc, int width, int height, int style)
Called from the constructor or can be called by the user if the default constructor is used...
virtual void OnLocate(const PLGraphicsIn &graphicsIn)
void OnRenderTimer(wxTimerEvent &event)
Timer used in delayed rendering after resize.
void setUseGraphicsContext(bool useGraphicsContext)
static const int ID_RENDERTIMER
wxPLplotstream is inherited from plstream, which is the C++ interface
size_t m_resizeRenderDelay
bool m_useGraphicsContext
Flag to indicate whether we should use a wxGCDC.
bool m_created
Flag to indicate the window has been Created.
virtual void OnCreate(wxWindowCreateEvent &event)
Window created event.
void OnMouse(wxMouseEvent &event)
Mouse events.
void SetDC(wxDC *dc)
Set a new dc to write to.
wxPLplotstream m_stream
The wxPLplotstream which belongs to this plot widget.
static PLStream * pls[PL_NSTREAMS]
void SetSize(int width, int height)
Set new size of plot area.
wxPLplotstream * GetStream()
Get pointer to wxPLplotstream of this widget.
virtual void OnPaint(wxPaintEvent &event)
Paint event.
void RenewPlot(void)
Redo plot.
bool m_completedFirstRender
virtual void OnErase(wxEraseEvent &event)
Background erase event.
PLINT translatecursor(PLGraphicsIn *gin)
#define PLPLOT_wxLogDebug(string)
void setCanvasColour(const wxColour &colour)
wxPLplotwindow(bool useGraphicsContext=true, wxSize clientSize=wxDefaultSize, int resizeRenderDelay_ms=0)
Constructor.
virtual ~wxPLplotwindow(void)
Destructor.
virtual void OnSize(wxSizeEvent &event)
Size event.
bool SavePlot(const wxString &driver, const wxString &filename)
Save plot using a different driver.