1 #include <../../nrnconf.h> 2 #if HAVE_IV // to end of file 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 ==
')') {
90 static void rgbcolor(
const Color*
c,
96 c->intensities(r,g,b);
100 static void common_pict() {
113 out <<
"%I t u" << endl;
118 out <<
"%I t" << endl;
123 out <<
"End %I eop" << endl;
134 rgbcolor(color, r,g,b);
138 sprintf(buf,
"%%I cfg %x%x%x\n%f %f %f SetCFg\n",
139 int(r*256),
int(g*256),
int(b*256), r, g, b);
140 out <<
"Begin %I Text\n";
143 out <<
"%I f " << font->encoding() <<
"\n";
144 out << font->name() << font->size() <<
"SetF\n";
147 %I f -*-helvetica-medium-r-normal-*-12-*-*-*-*-*-*-*\n\ 151 out <<
"%I t" << endl;
157 %I f -*-helvetica-medium-r-normal-*-12-*-*-*-*-*-*-*\n\ 162 Glyph* l = WidgetKit::instance()->label(s);
172 out <<
"%I\n[" << endl;
173 out <<
"(" << hidepar(s) <<
")" << endl;
174 out <<
"] Text\nEnd" << endl;
179 #define cnt_group 200 180 int ixd[cnt_group], iyd[cnt_group];
182 float xmax = x[0], xmin = x[0], ymax = y[0], ymin = y[0];
184 for (i = 1; i < count; ++
i) {
185 if (x[i] > xmax) xmax = x[
i];
186 if (x[i] < xmin) xmin = x[
i];
187 if (y[i] > ymax) ymax = y[
i];
188 if (y[i] < ymin) ymin = y[
i];
197 float scalex, scaley;
199 scalex = 10000/(xmax - xmin);
204 scaley = 10000/(ymax - ymin);
209 t.translate(-xmin, -ymin);
210 t.scale(scalex, scaley);
212 if (count > cnt_group) {
215 for (i = 0; i < count;) {
217 ixold = iyold = -20000;
218 for (; i < count; ++
i) {
223 for (size = 0; i < count;) {
226 t.inverse_transform(x[i], y[i], x1, y1);
227 if (x1 > 20000.) x1 = 20000.;
228 if (x1 < -20000.) x1 = -20000.;
229 if (y1 > 20000.) y1 = 20000.;
230 if (y1 < -20000.) y1 = -20000.;
233 if (ix != ixold || iy != iyold) {
238 if (size >= cnt_group) {
249 out <<
"\nBegin %I MLine\n";
252 out <<
"%I t" << endl;
267 out <<
"%I " << size << endl;
269 for (
int j=0;
j < size; ++
j ) {
270 out << ixd[
j] <<
" " << iyd[
j]<< endl;
273 out << size <<
" MLine\n%I 1\nEnd" << endl;
276 if (count > cnt_group) {
285 x[0] = x1; y[0] = y1;
286 x[1] = x2; y[1] = y1;
287 x[2] = x2; y[2] = y2;
288 x[3] = x1; y[3] = y2;
289 polygon(c, 4, x, y, color, b, f);
295 out <<
"\nBegin %I Poly\n";
296 poly(count, x, y, color, b, f);
297 sprintf(buf,
"%d Poly\nEnd", count);
304 out <<
"\nBegin %I BSpl\n";
305 poly(count, x, y, color, b,
false);
306 sprintf(buf,
"%d BSpl\n%%I 1\nEnd", count);
313 out <<
"\nBegin %I CBSpl\n";
314 poly(count, x, y, color, b, f);
315 sprintf(buf,
"%d CBSpl\nEnd", count);
323 out <<
"%I t" << endl;
326 float x1, x2, y1, y2;
331 float scalex, scaley;
335 scalex = (x2 - x1)/10000.;
340 scaley = (y2 - y1)/10000.;
343 t.scale(scalex, scaley);
346 out <<
"%I " << count << endl;
348 for (
int i=0; i < count; ++
i) {
350 t.inverse_transform(x[i], y[i], a, b);
351 sprintf(buf,
"%d %d\n",
int(a),
int(b));
359 out <<
"\nBegin %I Line\n";
362 out <<
"%I t" << endl;
377 float scalex, scaley;
381 scalex = (x2 - x1)/10000;
386 scaley = (y2 - y1)/10000;
389 t.scale(scalex, scaley);
394 t.inverse_transform(x1, y1, a, bb);
395 t.inverse_transform(x2, y2, x, y);
396 out <<
int(a) <<
" " <<
int(bb) <<
" " <<
int(x) <<
" " <<
int(y);
398 out <<
" Line\n%I 1\nEnd" << endl;
406 out <<
"\nBegin %I Elli\n";
409 out <<
"%I t" << endl;
418 sprintf(buf,
"%%I\n0 0 %d %d Elli\nEnd",
int(width*100),
int(height*100));
425 Coord w = b?b->width():0;
430 if(b)
for (i=0; i < b->dash_count(); ++
i) {
431 int nbit = b->dash_list(i);
432 for (
int j = 0;
j < nbit; ++
j) {
433 p = ((p << 1) | ((i+1)%2));
437 sprintf(buf,
"%%I b %d\n%d 0 0 [", p,
int(w));
440 if (b)
for (i=0; i < b->dash_count(); ++
i) {
441 out << b->dash_list(i) <<
" ";
452 rgbcolor(color,r,g,b);
456 sprintf(buf,
"%%I cfg %x%x%x\n%f %f %f SetCFg",
457 int(r*256),
int(g*256),
int(b*256),r,g,b);
462 sprintf(buf,
"%%I cbg %x%x%x\n%f %f %f SetCBg\n%%I p\n1 SetP",
463 int(r*256),
int(g*256),
int(b*256), r,g,b);
465 sprintf(buf,
"%%I cbg %s\n%d %d %d SetCBg\nnone SetP %%I p n",
494 #else //http://www.timotheegroleau.com/Flash/articles/cubic_bezier_in_flash.htm 495 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);
558 for (
int i=0; i <
ipath_; ++
i) {
virtual Coord bottom() const
static void fill(Canvas *, const Color *)
static void curve_to(Coord x, Coord y, Coord x1, Coord y1, Coord x2, Coord y2)
static void bspl(Canvas *, int count, const Coord *x, const Coord *y, const Color *c=NULL, const Brush *b=NULL)
static bool equal(float x, float y, float e)
const char * expand_env_var(const char *s)
virtual Coord top() const
static void brush(const Brush *)
sprintf(buf," if (secondorder) {\ " int _i;\" " for(_i=0;_i< %d;++_i) {\" " _p[_slist%d[_i]]+=dt *_p[_dlist%d[_i]];\" " }}\", numeqn, listnum, listnum)
static bool inside(Coord x, Coord min, Coord max)
const char * string() const
static float min(int count, const float *)
static const Color * default_foreground()
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 poly(int count, const Coord *x, const Coord *y, const Color *c=NULL, const Brush *b=NULL, bool fill=false)
const Requirement & y_requirement() const
virtual Coord left() const
static XYView * current_draw_view()
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 ifill(const Color *, bool)
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 line_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 mline(Canvas *, int count, const Coord *x, const Coord *y, const Color *c=NULL, const Brush *b=NULL)
static void move_to(Coord x, Coord y)
static float max(int count, const float *)
static void add(Coord, Coord)
static void rcurve(int level, Coord x, Coord y, Coord x1, Coord y1, Coord x2, Coord y2)
static void text(Canvas *, const char *, const Transformer &, const Font *f=NULL, const Color *c=NULL)
virtual Coord right() const
static void stroke(Canvas *, const Color *, const Brush *)
static void ellipse(Canvas *, Coord x1, Coord y1, Coord width, Coord height, const Color *c=NULL, const Brush *b=NULL, bool fill=false)