1 #include <../../nrnconf.h> 2 #if HAVE_IV // to end of file 6 #include <InterViews/background.h> 7 #include <InterViews/canvas.h> 8 #include <InterViews/printer.h> 9 #include <InterViews/label.h> 10 #include <IV-look/kit.h> 22 virtual ~GAxisItem(){};
36 init(min_, max_, pos_, ntic_);
46 init(
float(amin_),
float(amax_), pos_, ntic_);
50 int ntic,
int nminor,
int invert,
bool number) {
53 init(x1, x2, pos, ntic, nminor, invert, number);
57 int ntic,
int nminor,
int invert,
bool number) {
89 sprintf(buf,
"save_window_.%caxis(%g,%g,%g,%d,%d,%d,%d)",
90 c, amin_, amax_, pos_, ntic_, nminor_, invert_, number_);
114 Coord x1, y1, x2, y2;
116 if (v && v->
scene() == s_) {
117 v->
zin(x1, y1, x2, y2);
154 float y_align, x_align;
160 if (invert_ == 1) { l_minor *= -1.; length *= -1.; }
165 double s = (amax_ - amin_)/
float(ntic_);
166 while (s < 1) s *= 10.;
167 if (s == 1 || s == 2) addprec = 0;
else addprec = 1;
169 double logstep = -
log10((amax_ - amin_)/
float(ntic_));
173 if (logstep >= 0 && logstep <= 5) {
174 sprintf(pform,
"%%0.%.0ff",logstep+addprec);
179 s_->append(
new GAxisItem(
new Line(amax_ - amin_, 0)));
180 gi = s_->count() - 1;
181 s_->move(gi, amin_, y);
183 tic =
new Line(0,length);
185 minor_tic =
new Line(0,l_minor);
187 tic_space = (amax_ - amin_)/
float(ntic_);
189 for (i=0; i <= ntic_; ++
i) {
190 x = amin_ + i*tic_space;
195 s_->append_fixed(
new GAxisItem(tic));
196 gi = s_->count() - 1;
206 if (invert_ == 1) y_align = -0.3;
else y_align = 1.5;
208 s_->append_fixed(
new GAxisItem(
210 true, 1, x_align, y_align)));
211 gi = s_->count() - 1;
215 if (i < ntic_ && invert_ >= 0) {
216 for (j=0;j<nminor_;j++) {
217 x = amin_ + i*tic_space + j*tic_space/nminor_;
218 s_->append_fixed(
new GAxisItem(minor_tic));
219 gi = s_->count() - 1;
226 if (logstep >= 0 && logstep <= 5) {
227 sprintf(pform,
" %%0.%.0ff ",logstep+1);
232 s_->append(
new GAxisItem(
new Line(0, amax_ - amin_)));
233 gi = s_->count() - 1;
234 s_->move(gi, x, amin_);
236 tic =
new Line(length,0);
238 minor_tic =
new Line(l_minor,0);
240 tic_space = (amax_ - amin_)/
float(ntic_);
242 for (i=0; i <= ntic_; ++
i) {
243 y = amin_ + i*tic_space;
245 s_->append_fixed(
new GAxisItem(tic));
246 gi = s_->count() - 1;
256 if (invert_ == 1) x_align = 0;
else x_align = 1.3;
257 s_->append_fixed(
new GAxisItem(
259 true, 1, x_align, y_align)));
260 gi = s_->count() - 1;
264 if (i < ntic_ && invert_ >= 0) {
265 for (j=0;j<nminor_;j++) {
266 y = amin_ + i*tic_space + j*tic_space/nminor_;
267 s_->append_fixed(
new GAxisItem(minor_tic));
268 gi = s_->count() - 1;
289 s_->append(
new GAxisItem(
new Line(amax_ - amin_, 0)));
290 gi = s_->count() - 1;
291 s_->move(gi, amin_, y);
293 tic =
new Line(0,length);
295 for (i=0; i <= ntic_; ++
i) {
296 x = amin_ + i*(amax_ - amin_)/
float(ntic_);
300 s_->append_fixed(
new GAxisItem(tic));
301 gi = s_->count() - 1;
304 s_->append_fixed(
new GAxisItem(
307 gi = s_->count() - 1;
312 s_->append(
new GAxisItem(
new Line(0, amax_ - amin_)));
313 gi = s_->count() - 1;
314 s_->move(gi, x, amin_);
316 tic =
new Line(length, 0);
318 for (i=0; i <= ntic_; ++
i) {
319 y = amin_ + i*(amax_ - amin_)/
float(ntic_);
320 s_->append_fixed(
new GAxisItem(tic));
321 gi = s_->count() - 1;
324 s_->append_fixed(
new GAxisItem(
327 gi = s_->count() - 1;
342 Background::draw(c, a);
350 #define IDLINE(x1,y1,x2,y2,color,br) \ 351 c->line(x1,y1,x2,y2,color,br); \ 352 IfIdraw(line(c, x1, y1,x2,y2,color,br)); 357 Coord x1, y1, x2, y2;
361 v.
zin(x1, y1, x2, y2);
373 tr.inverse_transform(x1, y1, l, b);
374 tr.inverse_transform(x2, y2, r, t);
376 c->rect(l, b, r, t, color, br);
377 IfIdraw(rect(c, l, b, r, t, color, br,
false));
378 const Coord tic = 10;
381 Coord dtic = (r-l)/xtic;
382 Coord dx = (x2 - x1)/xtic;
384 for (i=0; i <= xtic; ++
i) {
386 if (i > 0 && i < xtic) {
387 IDLINE(x, b, x, b + tic, color, br);
388 IDLINE(x, t, x, t - tic, color, br);
390 tic_label(x, b-5, x1+i*dx, .5, 1, c);
394 for (i=0; i <= ytic; ++
i) {
396 if (i > 0 && i < ytic) {
397 IDLINE(l, y , l+tic, y, color, br);
398 IDLINE(r, y, r-tic, y, color, br);
400 tic_label(l-5, y, y1+i*dx, 1, .5, c);
403 c->clip_rect(l, b, r, t);
409 float xa,
float ya,
Canvas* c)
const 424 t.translate(a.
x(), a.
y());
436 Background::draw(c, a);
447 Coord x1, y1, x2, y2;
451 v.
zin(x1, y1, x2, y2);
463 tr.inverse_transform(x1, y1, l, b);
464 tr.inverse_transform(x2, y2, r, t);
476 tr.inverse_transform(xorg, yorg, xo, yo);
478 IDLINE(l, yo, r, yo, color, br);
479 IDLINE(xo, b, xo, t, color, br);
480 const Coord tic = 10;
483 Coord dtic = (r-l)/xtic;
484 Coord dx = (x2 - x1)/xtic;
486 for (i=0; i <= xtic; ++
i) {
488 IDLINE(x, yo, x, yo + tic, color, br);
489 tic_label(x, yo-5, x1+i*dx, .5, 1, c);
493 for (i=0; i <= ytic; ++
i) {
495 IDLINE(xo, y , xo+tic, y, color, br);
496 tic_label(xo-5, y, y1+i*dx, 1, .5, c);
504 float xa,
float ya,
Canvas* c)
const 519 t.translate(a.
x(), a.
y());
virtual void print(Printer *, const Allocation &) const
void draw_help(Canvas *, const Allocation &) const
static ostream * idraw_stream
double max(double a, double b)
void init(Coord x1, Coord x2, Coord pos=0., int ntic=1, int nminor=0, int invert=0, bool number=true)
const Transformer & s2o() const
static void round_range(Coord x1, Coord x2, double &y1, double &y2, int &ntic)
virtual ~AxisBackground()
virtual void update(Observable *)
virtual void draw(Canvas *, const Allocation &) const
static const Color * default_color()
static double location(void *v)
void tic_label(Coord x, Coord y, Coord val, float x_align, float y_align, Canvas *) const
static void round_range_down(Coord x1, Coord x2, double &y1, double &y2, int &ntic)
virtual void draw(Canvas *, const Allocation &) const
const Requirement & x_requirement() const
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)
static const Color * default_foreground()
static const Brush * default_brush()
void tic_label(Coord x, Coord y, Coord val, float x_align, float y_align, Canvas *) const
const Requirement & y_requirement() const
static XYView * current_draw_view()
virtual void save(ostream &)
virtual void unref() const
unsigned int DimensionName
virtual Scene * scene() const
Axis(Scene *, DimensionName)
virtual void size(float &, float &)
virtual void remove(GlyphIndex)
Allotment & x_allotment()
static void text(Canvas *, const char *, const Transformer &, const Font *f=NULL, const Color *c=NULL)
Allotment & y_allotment()
void draw_help(Canvas *, const Allocation &) const
virtual void erase(Scene *, GlyphIndex, int erase_type)
static XYView * current_pick_view()
virtual void zin(Coord &x1, Coord &y1, Coord &x2, Coord &y2) const
virtual void print(Printer *, const Allocation &) const