1 #include <../../nrnconf.h>
7 #include <InterViews/color.h>
8 #include <InterViews/brush.h>
9 #include <InterViews/font.h>
10 #include <IV-look/kit.h>
11 #include <InterViews/transformer.h>
12 #include <InterViews/session.h>
13 #include <InterViews/style.h>
14 #include <OS/string.h>
22 #define out *OcIdraw::idraw_stream
33 Style*
s = Session::instance()->style();
35 if (!
s->find_attribute(
"pwm_idraw_prologue",
name)) {
36 printf(
"can't find the \"pwm_idraw_prologue\" attribute\n");
37 printf(
"will have to prepend the prologue by hand before reading with idraw.\n");
42 if (!ibuf.open(
name.string(), std::ios::in)) {
44 if (!ibuf.open(
name.string(), std::ios::in)) {
46 printf(
"can't open the idraw prologue in %s\n",
name.string());
49 out << &ibuf << std::endl;
68 float a00, a01, a10, a11, a20, a21;
69 t.matrix(a00, a01, a10, a11, a20, a21);
71 Sprintf(
buf,
"[ %g %g %g %g %g %g ] concat", a00, a01, a10, a11, a20, a21);
72 out <<
buf << std::endl;
75 static char* hidepar(
const char*
s) {
79 for (ps =
s, pbuf =
buf; *ps;) {
80 if (*ps ==
'(' || *ps ==
')') {
96 c->intensities(r, g, b);
100 static void common_pict() {
113 out <<
"%I t u" << std::endl;
118 out <<
"%I t" << std::endl;
123 out <<
"End %I eop" << std::endl;
130 const Color* color) {
136 rgbcolor(color, r, g, b);
141 "%%I cfg %x%x%x\n%f %f %f SetCFg\n",
148 out <<
"Begin %I Text\n";
151 out <<
"%I f " << font->encoding() <<
"\n";
152 out << font->name() << font->size() <<
"SetF\n";
155 %I f -*-helvetica-medium-r-normal-*-12-*-*-*-*-*-*-*\n\
159 out <<
"%I t" << std::endl;
160 Glyph* l = WidgetKit::instance()->label(
s);
170 out <<
"%I\n[" << std::endl;
171 out <<
"(" << hidepar(
s) <<
")" << std::endl;
172 out <<
"] Text\nEnd" << std::endl;
181 #define cnt_group 200
182 int ixd[cnt_group], iyd[cnt_group];
184 float xmax = x[0], xmin = x[0], ymax = y[0], ymin = y[0];
191 float scalex, scaley;
193 scalex = 10000 / (xmax - xmin);
198 scaley = 10000 / (ymax - ymin);
203 t.translate(-xmin, -ymin);
204 t.scale(scalex, scaley);
206 if (count > cnt_group) {
209 for (
i = 0;
i < count;) {
211 ixold = iyold = -20000;
212 for (;
i < count; ++
i) {
217 for (size = 0;
i < count;) {
220 t.inverse_transform(x[
i], y[
i], x1, y1);
231 if (ix != ixold || iy != iyold) {
236 if (size >= cnt_group) {
246 out <<
"\nBegin %I MLine\n";
249 out <<
"%I t" << std::endl;
251 out <<
"%I " << size << std::endl;
253 for (
int j = 0;
j < size; ++
j) {
254 out << ixd[
j] <<
" " << iyd[
j] << std::endl;
257 out << size <<
" MLine\n%I 1\nEnd" << std::endl;
260 if (count > cnt_group) {
293 out <<
"\nBegin %I Poly\n";
294 poly(count, x, y, color, b, f);
296 out <<
buf << std::endl;
306 out <<
"\nBegin %I BSpl\n";
307 poly(count, x, y, color, b,
false);
309 out <<
buf << std::endl;
320 out <<
"\nBegin %I CBSpl\n";
321 poly(count, x, y, color, b, f);
323 out <<
buf << std::endl;
334 out <<
"%I t" << std::endl;
337 float x1, x2, y1, y2;
342 float scalex, scaley;
346 scalex = (x2 - x1) / 10000.f;
351 scaley = (y2 - y1) / 10000.f;
354 t.scale(scalex, scaley);
357 out <<
"%I " << count << std::endl;
359 for (
int i = 0;
i < count; ++
i) {
361 t.inverse_transform(x[
i], y[
i], a, b);
374 out <<
"\nBegin %I Line\n";
377 out <<
"%I t" << std::endl;
378 float scalex, scaley;
382 scalex = (x2 - x1) / 10000;
387 scaley = (y2 - y1) / 10000;
390 t.scale(scalex, scaley);
393 out <<
"%I" << std::endl;
395 t.inverse_transform(x1, y1, a, bb);
396 t.inverse_transform(x2, y2, x, y);
397 out << int(a) <<
" " << int(bb) <<
" " << int(x) <<
" " << int(y);
399 out <<
" Line\n%I 1\nEnd" << std::endl;
410 out <<
"\nBegin %I Elli\n";
413 out <<
"%I t" << std::endl;
422 Sprintf(
buf,
"%%I\n0 0 %d %d Elli\nEnd",
int(width * 100),
int(height * 100));
423 out <<
buf << std::endl;
428 Coord w = b ? b->width() : 0;
433 for (
i = 0;
i < b->dash_count(); ++
i) {
434 int nbit = b->dash_list(
i);
435 for (
int j = 0;
j < nbit; ++
j) {
436 p = ((
p << 1) | ((
i + 1) % 2));
442 for (
i = 0;
i < b->dash_count(); ++
i) {
443 out << b->dash_list(
i) <<
" ";
446 out <<
buf << std::endl;
453 rgbcolor(color, r, g, b);
458 buf,
"%%I cfg %x%x%x\n%f %f %f SetCFg",
int(r * 256),
int(g * 256),
int(b * 256), r, g, b);
459 out <<
buf << std::endl;
464 "%%I cbg %x%x%x\n%f %f %f SetCBg\n%%I p\n1 SetP",
472 Sprintf(
buf,
"%%I cbg %s\n%d %d %d SetCBg\nnone SetP %%I p n",
"White", 1, 1, 1);
474 out <<
buf << std::endl;
496 rcurve(0, x, y, x1, y1, x2, y2);
504 Coord m12x = (x1 + x2) / 2;
505 Coord m12y = (y1 + y2) / 2;
506 Coord m23x = (x2 + x) / 2;
507 Coord m23y = (y2 + y) / 2;
508 Coord ax = (m01x + m12x) / 2;
509 Coord ay = (m01y + m12y) / 2;
510 Coord bx = (m12x + m23x) / 2;
511 Coord by = (m12y + m23y) / 2;
512 Coord cx = (ax + bx) / 2;
513 Coord cy = (ay + by) / 2;
514 rcurve(r + 1, cx, cy, m01x, m01y, ax, ay);
515 rcurve(r + 1, x, y, bx, by, m23x, m23y);
517 add((x1 + x2) / 2, (y1 + y2) / 2);
static bool eq(T x, T y, T e)
static float max(int count, const float *)
static bool inside(Coord x, Coord min, Coord max)
static float min(int count, const float *)
static void curve_to(Coord x, Coord y, Coord x1, Coord y1, Coord x2, Coord y2)
static void mline(Canvas *, int count, const Coord *x, const Coord *y, const Color *c=NULL, const Brush *b=NULL)
static void poly(int count, const Coord *x, const Coord *y, const Color *c=NULL, const Brush *b=NULL, bool fill=false)
static void bspl(Canvas *, int count, const Coord *x, const Coord *y, const Color *c=NULL, const Brush *b=NULL)
static void rcurve(int level, Coord x, Coord y, Coord x1, Coord y1, Coord x2, Coord y2)
static void add(Coord, Coord)
static void move_to(Coord x, Coord y)
static void line(Canvas *, Coord x1, Coord y1, Coord x2, Coord y2, const Color *c=NULL, const Brush *b=NULL)
static void polygon(Canvas *, int count, const Coord *x, const Coord *y, const Color *c=NULL, const Brush *b=NULL, bool fill=false)
static void text(Canvas *, const char *, const Transformer &, const Font *f=NULL, const Color *c=NULL)
static void brush(const Brush *)
static void line_to(Coord x, Coord y)
static void stroke(Canvas *, const Color *, const Brush *)
static void rect(Canvas *, Coord x1, Coord y1, Coord x2, Coord y2, const Color *c=NULL, const Brush *b=NULL, bool fill=false)
static void cbspl(Canvas *, int count, const Coord *x, const Coord *y, const Color *c=NULL, const Brush *b=NULL, bool fill=false)
static void ellipse(Canvas *, Coord x1, Coord y1, Coord width, Coord height, const Color *c=NULL, const Brush *b=NULL, bool fill=false)
static void ifill(const Color *, bool)
static void fill(Canvas *, const Color *)
const Requirement & y_requirement() const
static const Color * default_foreground()
static XYView * current_draw_view()
const char * expand_env_var(const char *s)
int Sprintf(char(&buf)[N], const char *fmt, Args &&... args)
Redirect sprintf to snprintf if the buffer size can be deduced.
HOC interpreter function declarations (included by hocdec.h)