PLplot
5.15.0
Toggle main menu visibility
Loading...
Searching...
No Matches
wxPLplotstream.cpp
Go to the documentation of this file.
1
// Copyright (C) 2015 Phil Rosenberg
2
// Copyright (C) 2005 Werner Smekal
3
//
4
// This file is part of PLplot.
5
//
6
// PLplot is free software; you can redistribute it and/or modify
7
// it under the terms of the GNU Library General Public License as published
8
// by the Free Software Foundation; either version 2 of the License, or
9
// (at your option) any later version.
10
//
11
// PLplot is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
// GNU Library General Public License for more details.
15
//
16
// You should have received a copy of the GNU Library General Public License
17
// along with PLplot; if not, write to the Free Software
18
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
//
20
21
// wxwidgets headers
22
#include "wx/wx.h"
23
24
// plplot headers
25
#include "
plplotP.h
"
26
27
#include "
wxPLplotstream.h
"
28
30
// Here we set the driver (wxwidgets :), and tell plplot in which dc to
31
// plot to and the size of the canvas. We also check and set several
32
// device style options.
33
//
34
wxPLplotstream::wxPLplotstream
( wxDC *dc,
int
width
,
int
height,
int
style ) :
plstream
()
35
{
36
m_created
=
false
;
37
Create
( dc,
width
, height, style );
38
}
39
40
41
wxPLplotstream::wxPLplotstream
() :
plstream
()
42
{
43
m_created
=
false
;
44
}
45
47
// We set the driver to be wxwidgets, set the page size, set the driver options and initialize
48
// the plot.
49
void
wxPLplotstream::Create
( wxDC *dc,
int
width
,
int
height,
int
style )
50
{
51
if
(
m_created
)
52
{
53
plabort
(
"wxPLplotstream::Create - Stream already created"
);
54
return
;
55
}
56
const
size_t
bufferSize = 256;
57
58
m_width
=
width
;
59
m_height
= height;
60
m_style
= style;
61
62
sdev
(
"wxwidgets"
);
63
spage
( 90.0, 90.0,
m_width
,
m_height
, 0, 0 );
64
65
char
drvopt[bufferSize],
buffer
[bufferSize];
66
drvopt[0] =
'\0'
;
67
68
sprintf(
buffer
,
"hrshsym=%d,text=%d"
,
69
m_style
&
wxPLPLOT_USE_HERSHEY_SYMBOLS
? 1 : 0,
70
m_style
&
wxPLPLOT_DRAW_TEXT
? 1 : 0 );
71
strncat( drvopt,
buffer
, bufferSize - strlen( drvopt ) );
72
73
setopt
(
"-drvopt"
, drvopt );
74
75
sdevdata
( (
void
*) dc );
76
77
init
();
78
}
79
81
// the device is NULL
82
void
wxPLplotstream::SetDC
( wxDC *dc )
83
{
84
set_stream
();
85
cmd
(
PLESC_DEVINIT
, (
void
*) dc );
86
}
87
89
wxPLplotstream::~wxPLplotstream
()
90
{
91
}
92
93
95
// code processed before every call of a plplot functions, since set_stream()
96
// is called before every plplot function. Not used in the moment.
97
//
98
void
wxPLplotstream::set_stream
()
99
{
100
plstream::set_stream
();
101
}
102
103
105
// to set the new size. You need to call RenewPlot afterwards.
106
//
107
void
wxPLplotstream::SetSize
(
int
width
,
int
height )
108
{
109
wxSize size(
width
, height );
110
cmd
(
PLESC_RESIZE
, (
void
*) &size );
111
m_width
=
width
;
112
m_height
= height;
113
}
114
115
117
//
118
void
wxPLplotstream::RenewPlot
()
119
{
120
replot
();
121
}
122
123
void
wxPLplotstream::ImportBuffer
(
void
*
buffer
,
size_t
size )
124
{
125
plbuffer
buf
;
126
buf
.buffer =
buffer
;
127
buf
.size = size;
128
cmd
(
PLESC_IMPORT_BUFFER
, &
buf
);
129
RenewPlot
();
130
}
131
132
void
wxPLplotstream::AppendBuffer
(
void
*
buffer
,
size_t
size )
133
{
134
plbuffer
buf
;
135
buf
.buffer =
buffer
;
136
buf
.size = size;
137
cmd
(
PLESC_APPEND_BUFFER
, &
buf
);
138
cmd
(
PLESC_FLUSH_REMAINING_BUFFER
, NULL );
139
}
140
141
void
wxPLplotstream::SetFixedAspectRatio
(
bool
fixed )
142
{
143
PLBOOL
f = fixed ? 1 : 0;
144
cmd
(
PLESC_FIXASPECT
, &f );
145
}
146
147
bool
wxPLplotstream::IsValid
()
148
{
149
return
m_created
;
150
}
plstream::cmd
void cmd(PLINT op, void *ptr)
Definition
plstream.cc:2482
plstream::setopt
PLINT setopt(const char *opt, const char *optarg)
Definition
plstream.cc:2434
plstream::sdevdata
void sdevdata(void *data)
Definition
plstream.cc:1718
plstream::set_stream
virtual void set_stream(void)
Definition
plstream.h:133
plstream::replot
void replot(void)
Definition
plstream.cc:1391
plstream::spage
void spage(PLFLT xp, PLFLT yp, PLINT xleng, PLINT yleng, PLINT xoff, PLINT yoff)
Definition
plstream.cc:1932
plstream::width
void width(PLFLT width)
Definition
plstream.cc:2244
plstream::sdev
void sdev(const char *devname)
Definition
plstream.cc:1597
plstream::plstream
plstream(const plstream &)
plstream::init
void init(void)
Definition
plstream.cc:981
wxPLplotstream::set_stream
void set_stream()
Calls some code before every PLplot command.
Definition
wxPLplotstream.cpp:98
wxPLplotstream::m_width
int m_width
Width of dc/plot area.
Definition
wxPLplotstream.h:68
wxPLplotstream::m_style
int m_style
style of this plot
Definition
wxPLplotstream.h:70
wxPLplotstream::SetDC
void SetDC(wxDC *dc)
Set a new dc to write to.
Definition
wxPLplotstream.cpp:82
wxPLplotstream::~wxPLplotstream
~wxPLplotstream()
Destructor, although we have no resources to free.
Definition
wxPLplotstream.cpp:89
wxPLplotstream::AppendBuffer
void AppendBuffer(void *buffer, size_t size)
Append a buffer of plplot commands.
Definition
wxPLplotstream.cpp:132
wxPLplotstream::RenewPlot
void RenewPlot()
Redo plot and update dc.
Definition
wxPLplotstream.cpp:118
wxPLplotstream::IsValid
bool IsValid()
Definition
wxPLplotstream.cpp:147
wxPLplotstream::wxPLplotstream
wxPLplotstream()
Constructor.
Definition
wxPLplotstream.cpp:41
wxPLplotstream::m_height
int m_height
Height of dc/plot area.
Definition
wxPLplotstream.h:69
wxPLplotstream::m_created
bool m_created
Definition
wxPLplotstream.h:71
wxPLplotstream::SetFixedAspectRatio
void SetFixedAspectRatio(bool fixed)
Set Fixed aspect ratio of the plot.
Definition
wxPLplotstream.cpp:141
wxPLplotstream::ImportBuffer
void ImportBuffer(void *buffer, size_t size)
Import a buffer of plplot commands.
Definition
wxPLplotstream.cpp:123
wxPLplotstream::SetSize
void SetSize(int width, int height)
Set new size of plot area.
Definition
wxPLplotstream.cpp:107
wxPLplotstream::Create
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.
Definition
wxPLplotstream.cpp:49
plabort
void plabort(PLCHAR_VECTOR errormsg)
Definition
plctrl.c:1894
buffer
static PLINT * buffer
Definition
plfill.c:74
plplotP.h
PLESC_FIXASPECT
#define PLESC_FIXASPECT
Definition
plplot.h:308
PLESC_IMPORT_BUFFER
#define PLESC_IMPORT_BUFFER
Definition
plplot.h:309
PLESC_DEVINIT
#define PLESC_DEVINIT
Definition
plplot.h:296
PLESC_APPEND_BUFFER
#define PLESC_APPEND_BUFFER
Definition
plplot.h:310
PLESC_RESIZE
#define PLESC_RESIZE
Definition
plplot.h:275
PLESC_FLUSH_REMAINING_BUFFER
#define PLESC_FLUSH_REMAINING_BUFFER
Definition
plplot.h:311
PLBOOL
PLINT PLBOOL
Definition
plplot.h:204
plbuffer
Definition
plplot.h:628
buf
static char buf[200]
Definition
tclAPI.c:873
wxPLplotstream.h
wxPLPLOT_DRAW_TEXT
@ wxPLPLOT_DRAW_TEXT
Definition
wxPLplotstream.h:39
wxPLPLOT_USE_HERSHEY_SYMBOLS
@ wxPLPLOT_USE_HERSHEY_SYMBOLS
Definition
wxPLplotstream.h:40
bindings
wxwidgets
wxPLplotstream.cpp
Generated on
for PLplot by
1.17.0