1 #include <../../nrnconf.h> 2 #if HAVE_IV // to end of file 40 #include <InterViews/canvas.h> 41 #include <InterViews/hit.h> 42 #include <InterViews/session.h> 43 #include <InterViews/style.h> 44 #include <InterViews/color.h> 45 #include <InterViews/brush.h> 46 #include <InterViews/background.h> 56 #define Scene_Move_Text_ "MoveText Graph" 57 #define Scene_ChangeColor_ "ChangeColor Graph" 58 #define Scene_Delete_ "Delete Graph" 60 static const int SceneInfoShowing = 0x01;
61 static const int SceneInfoFixed = 0x02;
62 static const int SceneInfoViewFixed = 0x04;
63 static const int SceneInfoAllocated = 0x08;
77 void SceneInfo::pinfo() {
82 SceneInfo::SceneInfo() {
93 status_ = SceneInfoShowing;
103 static const float epsilon = 0.001;
104 static Scene_PtrList* scene_list;
108 static const Brush* mb_brush_;
109 static const Color* mb_color_;
114 SceneInfo&
info = info_->item_ref(index);
116 info.glyph_->request(s);
131 if (info.status_ & SceneInfoAllocated) {
132 if (!a_old.
equals(a, epsilon)) {
133 damage(index, a_old);
139 info.status_ |= SceneInfoAllocated;
145 SceneInfo& info = info_->item_ref(index);
147 info.glyph_->request(s);
163 if ((info.status_ & SceneInfoAllocated) && !a_old.
equals(a, epsilon)) {
165 damage(index, a_old);
168 info.status_ |= SceneInfoAllocated;
171 static const Color* scene_background_;
172 static const Color* scene_foreground_;
175 if (!scene_background_) {
176 Style* s = Session::instance()->style();
178 if (!s->find_attribute(
"Scene_background", c )
180 Session::instance()->default_display(), c)) ==
NULL)
183 Session::instance()->default_display(),
"#ffffff" );
187 return scene_background_;
191 if (!scene_foreground_) {
192 Style* s = Session::instance()->style();
194 if (!s->find_attribute(
"Scene_foreground", c )
196 Session::instance()->default_display(), c)) ==
NULL)
199 Session::instance()->default_display(),
"#000000" );
203 return scene_foreground_;
207 drawing_fixed_item_ =
false;
211 info_ =
new SceneInfo_List();
212 views_ =
new XYView_PtrList();
222 scene_list =
new Scene_PtrList;
228 Session::instance()->style()->find_attribute(
"scene_menu_box_size", mbs_);
230 mb_color_ =
new Color(
235 mb_brush_ =
new Brush(1);
243 scene_list->append(
this);
274 printf(
"No help for this tool\n");
289 if (x1 == x2) { x1 -= 1.; x2 += 1.;}
290 if (y1 == y2) { y1 -= 1.; y2 += 1.;}
313 for (
long i = 0; i <
views_->count(); ++
i) {
320 for (i=0; i <
count; ++
i) {
331 SceneInfo& info =
info_->item_ref(i);
347 for (i = 0; i <
count; ++
i) {
353 for (
long j = 0;
j < scene_list->count(); ++
j) {
354 if (scene_list->item(
j) ==
this) {
355 scene_list->remove(
j);
379 long count =
views_->count();
380 for (
long i = 0; i <
count; ++
i) {
381 if (v ==
views_->item(i)) {
390 long count =
views_->count();
391 for (
long i = count - 1; i >= 0; --
i) {
401 SceneInfo& info =
info_->item_ref(index);
403 long count =
views_->count();
404 for (
long i = 0; i <
count; ++
i) {
407 view->
damage(info.glyph_, a,
408 (info.status_ & SceneInfoFixed) != 0,
409 (info.status_ & SceneInfoViewFixed) != 0
415 SceneInfo& info =
info_->item_ref(index);
416 long count =
views_->count();
417 for (
long i = 0; i <
count; ++
i) {
419 view->
damage(info.glyph_, a,
420 (info.status_ & SceneInfoFixed) != 0,
421 (info.status_ & SceneInfoViewFixed) != 0
427 for (
long i = 0; i <
views_->count(); ++
i) {
436 long count =
views_->count();
437 for (
long i = 0; i <
count; ++
i) {
439 view->
damage(x1, y1, x2, y2);
444 SceneInfo& info =
info_->item_ref(index);
445 if (((info.status_ & SceneInfoShowing) == SceneInfoShowing) != showing) {
449 info.status_ |= SceneInfoShowing;
451 info.status_ &= ~SceneInfoShowing;
458 return (
info_->item_ref(index).status_ & SceneInfoShowing) != 0;
462 SceneInfo& info =
info_->item_ref(index);
463 float x1=info.x_, y1=info.y_;
467 if (!(info.status_ & SceneInfoAllocated) || x1 != x || y1 != y) {
473 SceneInfo& info =
info_->item_ref(index);
479 return info_->count();
483 return info_->item_ref(index).glyph_;
487 a =
info_->item_ref(index).allocation_.allotment(res);
495 SceneInfo& info =
info_->item_ref(index);
496 if (info.status_ & SceneInfoViewFixed) {
497 info.status_ &= ~SceneInfoViewFixed;
498 printf(
"changed to fixed\n");
499 v->
view_ratio(info.x_, info.y_, info.x_, info.y_);
500 v->
s2o().transform(info.x_, info.y_);
502 info.status_ |= SceneInfoFixed;
507 SceneInfo& info =
info_->item_ref(index);
508 if (!(info.status_ & SceneInfoViewFixed)) {
509 info.status_ |= SceneInfoViewFixed;
510 info.status_ |= SceneInfoFixed;
511 printf(
"changed to vfixed\n");
512 v->
s2o().inverse_transform(info.x_, info.y_);
513 v->
ratio_view(info.x_, info.y_, info.x_, info.y_);
519 SceneInfo
info(glyph);
526 SceneInfo
info(glyph);
527 info.status_ |= SceneInfoFixed;
535 SceneInfo
info(glyph);
536 info.status_ |= SceneInfoFixed | SceneInfoViewFixed;
543 SceneInfo
info(glyph);
544 info_->prepend(info);
550 SceneInfo
info(glyph);
551 info_->insert(index, info);
557 SceneInfo& info =
info_->item_ref(index);
560 info_->remove(index);
564 SceneInfo& info =
info_->item_ref(index);
574 for (i=0; i <
cnt; ++
i) {
575 if (
info_->item_ref(i).glyph_ ==
g) {
605 #include <IV-X11/xcanvas.h> 606 #include <InterViews/transformer.h> 609 printf(
"damage %g %g %g %g\n", cd.left, cd.bottom, cd.right, cd.top);
612 t.inverse_transform(cd.left, cd.bottom, x1, y1);
613 t.inverse_transform(cd.right, cd.top, x2, y2);
614 printf(
" model %g %g %g %g\n", x1, y1, x2, y2);
627 canvas->transformer().transform(a.
left(), a.
top(), l,
t);
628 if (canvas->damaged(l, t-
mbs_, l+
mbs_, t)) {
630 canvas->push_transform();
632 canvas->transformer(tr);
633 canvas->rect(l, t-
mbs_, l+
mbs_, t, mb_color_, mb_brush_);
634 canvas->pop_transform();
638 bool are_fixed =
false;
640 SceneInfo& info =
info_->item_ref(index);
641 if (info.status_ & SceneInfoFixed) {
643 }
else if (info.glyph_ !=
NULL && (info.status_ & SceneInfoShowing)) {
649 if (canvas->damaged(b)) {
650 info.glyph_->draw(canvas, a);
656 ((
Scene*)
this)->drawing_fixed_item_ =
true;
657 canvas->push_transform();
661 canvas->transform(tv);
664 SceneInfo& info =
info_->item_ref(index);
665 if ((info.status_ & SceneInfoFixed)
666 && info.glyph_ !=
NULL && (info.status_ & SceneInfoShowing)) {
669 if (!(info.status_ & SceneInfoViewFixed)) {
670 tv.inverse_transform(a.
x(), a.
y(), x, y);
678 if (canvas->damaged(b)) {
679 info.glyph_->draw(canvas, a);
685 ((
Scene*)
this)->drawing_fixed_item_ =
false;
686 canvas->pop_transform();
696 bool are_fixed =
false;
698 SceneInfo& info =
info_->item_ref(index);
699 if (info.status_ & SceneInfoFixed) {
701 }
else if (info.glyph_ !=
NULL && (info.status_ & SceneInfoShowing)) {
705 if (canvas->damaged(b)) {
706 info.glyph_->print(canvas, a);
712 ((
Scene*)
this)->drawing_fixed_item_ =
true;
713 canvas->push_transform();
717 canvas->transform(tv);
719 SceneInfo& info =
info_->item_ref(index);
720 if ((info.status_ & SceneInfoFixed)
721 && info.glyph_ !=
NULL && (info.status_ & SceneInfoShowing)) {
724 if (!(info.status_ & SceneInfoViewFixed)) {
725 tv.inverse_transform(a.
x(), a.
y(), x, y);
733 if (canvas->damaged(b)) {
734 info.glyph_->print(canvas, a);
738 ((
Scene*)
this)->drawing_fixed_item_ =
false;
739 canvas->pop_transform();
745 if (
mbs() > 0. &&
picker_ && h.event() && h.event()->type() == Event::down) {
746 Coord ax, ay, ex, ey;
747 c->transformer().transform(h.left(), h.top(), ex, ey);
748 c->transformer().transform(a.
left(), a.
top(), ax, ay);
765 SceneInfo& info =
info_->item_ref(index);
766 if (info.glyph_ !=
NULL && (info.status_ & SceneInfoShowing)) {
769 h.right() >= a.
left() && h.left() < a.
right()
770 && h.top() >= a.
bottom() && h.bottom() < a.
top()
772 h.begin(depth,
this, index);
773 info.glyph_->pick(c, a, depth + 1, h);
783 bool are_fixed =
false;
785 SceneInfo& info =
info_->item_ref(index);
786 if (info.status_ & SceneInfoFixed) {
788 }
else if (info.glyph_ !=
NULL && (info.status_ & SceneInfoShowing)) {
791 h.right() >= a.
left() - epsx && h.left() < a.
right() + epsx
792 && h.top() >= a.
bottom() - epsy && h.bottom() < a.
top() + epsy
794 h.begin(depth,
this, index);
795 info.glyph_->pick(c, a, depth + 1, h);
806 tv.matrix(scx,tmp,tmp,scy,tmp,tmp);
808 SceneInfo& info =
info_->item_ref(index);
809 if ((info.status_ & SceneInfoFixed)
810 && info.glyph_ !=
NULL && (info.status_ & SceneInfoShowing)) {
813 if (info.status_ & SceneInfoViewFixed) {
821 l = (a.
left() - a.
x())*scx + a.
x();
822 r = (a.
right() - a.
x())*scx + a.
x();
823 t = (a.
top() - a.
y())*scy + a.
y();
824 b = (a.
bottom() - a.
y())*scy + a.
y();
829 h.right() >= l && h.left() < r
830 && h.top() >= b && h.bottom() <
t 832 h.begin(depth,
this, index);
833 info.glyph_->pick(c, a, depth + 1, h);
843 long i, cnt = scene_list->count();
844 for (i = 0; i <
cnt; ++
i) {
845 if (s == scene_list->item(i)) {
854 o <<
"objectvar save_window_, rvp_" << endl;
858 long count = scene_list->count();
860 sprintf(buf,
"objectvar scene_vector_[%ld]", count);
863 for (
long i = 0; i <
count; ++
i) {
864 Scene* s = scene_list->item(i);
870 long count =
views_->count();
872 o <<
"save_window_ = new " << s <<
"(0)" << endl;
884 sprintf(buf,
"save_window_.size(%g,%g,%g,%g)", left, right, bottom, top);
893 views_->item(0)->printfile(fname);
899 if (!obuf.open(fname,
IOS_OUT)) {
910 pr->resize(0, 0, xsize_, ysize_);
911 pr->clip_rect(0, 0, xsize_, ysize_);
void allot_x(const Allotment &)
virtual void damage_all()
virtual bool has_window()
#define declarePtrList(PtrList, T)
virtual Glyph * component(GlyphIndex) const
virtual void printfile(const char *)
virtual int view_count() const
void set(Canvas *, const Allocation &)
bool equals(const Allocation &, float epsilon) const
virtual void save_phase2(std::ostream &)
const Transformer & s2o() const
virtual void eps_prolog(ostream &, Coord width, Coord height, const char *creator="InterViews")
virtual void append(Glyph *)
void psfilter(const char *filename)
virtual void append_viewfixed(Glyph *)
virtual void allocate(Canvas *, const Allocation &, Extension &)
static void help(const char *)
#define implementList(List, T)
virtual void box_size(Coord x1, Coord y1, Coord x2, Coord y2)
static void save_all(std::ostream &)
virtual void modified(GlyphIndex)
virtual void replace(GlyphIndex, Glyph *)
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 void pr(N_Vector x)
static const Color * default_foreground()
virtual void wholeplot(Coord &x1, Coord &y1, Coord &x2, Coord &y2) const
#define implementPtrList(PtrList, T)
const Requirement & requirement(DimensionName) const
void allot_y(const Allotment &)
virtual void damage(GlyphIndex)
virtual void allotment(GlyphIndex, DimensionName, Allotment &) const
virtual void background(Glyph *bg=NULL)
virtual void damage(Glyph *, const Allocation &, bool fixed=false, bool viewfixed=false)
virtual PrintableWindow * window()
virtual void view_ratio(float xratio, float yratio, Coord &x, Coord &y) const
virtual void append_fixed(Glyph *)
static const char * fname(const char *name)
static XYView * current_draw_view()
void location(GlyphIndex, Coord &x, Coord &y) const
void require_y(const Requirement &)
virtual void change(GlyphIndex)
virtual void printfile(const char *)
virtual XYView * sceneview(int) const
virtual void draw(Canvas *, const Allocation &) const
void move(GlyphIndex, Coord x, Coord y)
virtual void save_phase1(std::ostream &)
virtual void insert(GlyphIndex, Glyph *)
virtual void unref() const
virtual void new_size(Coord x1, Coord y1, Coord x2, Coord y2)
void show(GlyphIndex, bool)
virtual void pick_menu(Glyph *, int, Hit &)
unsigned int DimensionName
bool showing(GlyphIndex) const
virtual void change_to_fixed(GlyphIndex, XYView *)
void append_view(XYView *)
virtual void print(Printer *, const Allocation &) const
void require_x(const Requirement &)
virtual Coord mbs() const
void remove_view(XYView *)
void allot(DimensionName, const Allotment &)
static const Color * default_background()
virtual void remove(GlyphIndex)
virtual void pick(Canvas *, const Allocation &, int depth, Hit &)
Scene(Coord x1, Coord y1, Coord x2, Coord y2, Glyph *background=NULL)
void origin(Coord x1, Coord y1)
static PrintableWindowManager * current()
#define declareList(List, T)
void check_allocation(GlyphIndex)
Allotment & x_allotment()
virtual void ratio_view(Coord x, Coord y, float &xratio, float &yratio) const
virtual void save_class(std::ostream &, const char *)
virtual GlyphIndex count() const
virtual void prepend(Glyph *)
virtual GlyphIndex glyph_index(const Glyph *)
Allotment & y_allotment()
static XYView * current_pick_view()
virtual void zin(Coord &x1, Coord &y1, Coord &x2, Coord &y2) const
static long scene_list_index(Scene *)
virtual void change_to_vfixed(GlyphIndex, XYView *)
virtual void request(Requisition &) const
virtual void damage_all()