1 #include <../../nrnconf.h>
6 #include <InterViews/color.h>
7 #include <InterViews/brush.h>
8 #include <InterViews/font.h>
9 #include <IV-look/kit.h>
10 #include <InterViews/transformer.h>
11 #include <InterViews/session.h>
12 #include <InterViews/style.h>
19 #define out *OcIdraw::idraw_stream
34 Style* s = Session::instance()->style();
36 if (!s->find_attribute(
"pwm_idraw_prologue",
name)) {
37 printf(
"can't find the \"pwm_idraw_prologue\" attribute\n");
38 printf(
"will have to prepend the prologue by hand before reading with idraw.\n");
42 #if defined(WIN32) || defined(MAC)
43 if (!ibuf.open(
name.string(), ios::in)) {
47 printf(
"can't open the idraw prologue in %s\n",
name.string());
69 float a00, a01, a10, a11, a20, a21;
70 t.matrix(a00, a01, a10, a11, a20, a21);
72 sprintf(
buf,
"[ %g %g %g %g %g %g ] concat", a00, a01, a10, a11, a20, a21);
76 static char* hidepar(
const char* s) {
80 for (ps = s, pbuf =
buf; *ps;) {
81 if (*ps ==
'(' || *ps ==
')') {
97 c->intensities(r,
g, b);
101 static void common_pict() {
114 out <<
"%I t u" << endl;
119 out <<
"%I t" << endl;
124 out <<
"End %I eop" << endl;
143 "%%I cfg %x%x%x\n%f %f %f SetCFg\n",
150 out <<
"Begin %I Text\n";
153 out <<
"%I f " << font->encoding() <<
"\n";
154 out << font->name() << font->size() <<
"SetF\n";
157 %I f -*-helvetica-medium-r-normal-*-12-*-*-*-*-*-*-*\n\
161 out <<
"%I t" << endl;
167 %I f -*-helvetica-medium-r-normal-*-12-*-*-*-*-*-*-*\n\
172 Glyph* l = WidgetKit::instance()->label(s);
182 out <<
"%I\n[" << endl;
183 out <<
"(" << hidepar(s) <<
")" << endl;
184 out <<
"] Text\nEnd" << endl;
193 #define cnt_group 200
194 int ixd[cnt_group], iyd[cnt_group];
196 float xmax = x[0], xmin = x[0], ymax = y[0], ymin = y[0];
198 for (
i = 1;
i < count; ++
i) {
199 if (x[
i] > xmax) xmax = x[
i];
200 if (x[
i] < xmin) xmin = x[
i];
201 if (y[
i] > ymax) ymax = y[
i];
202 if (y[
i] < ymin) ymin = y[
i];
211 float scalex, scaley;
213 scalex = 10000 / (xmax - xmin);
218 scaley = 10000 / (ymax - ymin);
223 t.translate(-xmin, -ymin);
224 t.scale(scalex, scaley);
226 if (count > cnt_group) {
229 for (
i = 0;
i < count;) {
231 ixold = iyold = -20000;
232 for (;
i < count; ++
i) {
237 for (size = 0;
i < count;) {
240 t.inverse_transform(x[
i], y[
i], x1, y1);
251 if (ix != ixold || iy != iyold) {
256 if (size >= cnt_group) {
267 out <<
"\nBegin %I MLine\n";
270 out <<
"%I t" << endl;
285 out <<
"%I " << size << endl;
287 for (
int j = 0;
j < size; ++
j) {
288 out << ixd[
j] <<
" " << iyd[
j] << endl;
291 out << size <<
" MLine\n%I 1\nEnd" << endl;
294 if (count > cnt_group) {
327 out <<
"\nBegin %I Poly\n";
340 out <<
"\nBegin %I BSpl\n";
354 out <<
"\nBegin %I CBSpl\n";
368 out <<
"%I t" << endl;
371 float x1, x2, y1, y2;
376 float scalex, scaley;
380 scalex = (x2 - x1) / 10000.;
385 scaley = (y2 - y1) / 10000.;
388 t.scale(scalex, scaley);
391 out <<
"%I " << count << endl;
393 for (
int i = 0;
i < count; ++
i) {
395 t.inverse_transform(x[
i], y[
i], a, b);
409 out <<
"\nBegin %I Line\n";
412 out <<
"%I t" << endl;
427 float scalex, scaley;
431 scalex = (x2 - x1) / 10000;
436 scaley = (y2 - y1) / 10000;
439 t.scale(scalex, scaley);
444 t.inverse_transform(x1, y1, a, bb);
445 t.inverse_transform(x2, y2, x, y);
446 out << int(a) <<
" " << int(bb) <<
" " << int(x) <<
" " << int(y);
448 out <<
" Line\n%I 1\nEnd" << endl;
459 out <<
"\nBegin %I Elli\n";
462 out <<
"%I t" << endl;
471 sprintf(
buf,
"%%I\n0 0 %d %d Elli\nEnd",
int(width * 100),
int(height * 100));
477 Coord w = b ? b->width() : 0;
483 for (
i = 0;
i < b->dash_count(); ++
i) {
484 int nbit = b->dash_list(
i);
485 for (
int j = 0;
j < nbit; ++
j) {
486 p = ((
p << 1) | ((
i + 1) % 2));
494 for (
i = 0;
i < b->dash_count(); ++
i) {
495 out << b->dash_list(
i) <<
" ";
511 buf,
"%%I cfg %x%x%x\n%f %f %f SetCFg",
int(r * 256),
int(
g * 256),
int(b * 256), r,
g, b);
517 "%%I cbg %x%x%x\n%f %f %f SetCBg\n%%I p\n1 SetP",
525 sprintf(
buf,
"%%I cbg %s\n%d %d %d SetCBg\nnone SetP %%I p n",
"White", 1, 1, 1);
554 rcurve(0, x, y, x1, y1, x2, y2);
563 Coord m12x = (x1 + x2) / 2;
564 Coord m12y = (y1 + y2) / 2;
565 Coord m23x = (x2 + x) / 2;
566 Coord m23y = (y2 + y) / 2;
567 Coord ax = (m01x + m12x) / 2;
568 Coord ay = (m01y + m12y) / 2;
569 Coord bx = (m12x + m23x) / 2;
570 Coord by = (m12y + m23y) / 2;
571 Coord cx = (ax + bx) / 2;
572 Coord cy = (ay + by) / 2;
573 rcurve(r + 1, cx, cy, m01x, m01y, ax, ay);
574 rcurve(r + 1, x, y, bx, by, m23x, m23y);
576 add((x1 + x2) / 2, (y1 + y2) / 2);
static bool equal(float x, float y, float 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()
sprintf(buf, " if (secondorder) {\n" " int _i;\n" " for (_i = 0; _i < %d; ++_i) {\n" " _p[_slist%d[_i]] += dt*_p[_dlist%d[_i]];\n" " }}\n", numeqn, listnum, listnum)
const char * expand_env_var(const char *s)