1 #include <../../nrnconf.h>
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;
110 static const Brush* mb_brush_;
111 static const Color* mb_color_;
118 info.glyph_->request(s);
129 if (
info.status_ & SceneInfoAllocated) {
130 if (!a_old.
equals(a, epsilon)) {
137 info.status_ |= SceneInfoAllocated;
145 info.glyph_->request(s);
158 if ((
info.status_ & SceneInfoAllocated) && !a_old.
equals(a, epsilon)) {
163 info.status_ |= SceneInfoAllocated;
166 static const Color* scene_background_;
167 static const Color* scene_foreground_;
170 if (!scene_background_) {
171 Style* s = Session::instance()->style();
173 if (!s->find_attribute(
"Scene_background",
c) ||
174 (scene_background_ =
Color::lookup(Session::instance()->default_display(),
c)) ==
176 scene_background_ =
Color::lookup(Session::instance()->default_display(),
"#ffffff");
180 return scene_background_;
184 if (!scene_foreground_) {
185 Style* s = Session::instance()->style();
187 if (!s->find_attribute(
"Scene_foreground",
c) ||
188 (scene_foreground_ =
Color::lookup(Session::instance()->default_display(),
c)) ==
190 scene_foreground_ =
Color::lookup(Session::instance()->default_display(),
"#000000");
194 return scene_foreground_;
199 drawing_fixed_item_ =
false;
203 info_ =
new SceneInfo_List();
204 views_ =
new XYView_PtrList();
214 scene_list =
new Scene_PtrList;
220 Session::instance()->style()->find_attribute(
"scene_menu_box_size", mbs_);
223 mb_brush_ =
new Brush(1);
231 scene_list->append(
this);
267 printf(
"No help for this tool\n");
312 for (
long i = 0;
i <
views_->count(); ++
i) {
352 for (
long j = 0;
j < scene_list->count(); ++
j) {
353 if (scene_list->item(
j) ==
this) {
354 scene_list->remove(
j);
369 return int(
views_->count());
390 for (
long i =
count - 1;
i >= 0; --
i) {
392 if (
g &&
g->has_window()) {
393 g->window()->dismiss();
408 (
info.status_ & SceneInfoFixed) != 0,
409 (
info.status_ & SceneInfoViewFixed) != 0);
420 (
info.status_ & SceneInfoFixed) != 0,
421 (
info.status_ & SceneInfoViewFixed) != 0);
426 for (
long i = 0;
i <
views_->count(); ++
i) {
444 if (((
info.status_ & SceneInfoShowing) == SceneInfoShowing) !=
showing) {
448 info.status_ |= SceneInfoShowing;
450 info.status_ &= ~SceneInfoShowing;
457 return (
info_->item_ref(
index).status_ & SceneInfoShowing) != 0;
466 if (!(
info.status_ & SceneInfoAllocated) ||
x1 != x ||
y1 != y) {
478 return info_->count();
486 a =
info_->item_ref(
index).allocation_.allotment(res);
495 if (
info.status_ & SceneInfoViewFixed) {
496 info.status_ &= ~SceneInfoViewFixed;
497 printf(
"changed to fixed\n");
501 info.status_ |= SceneInfoFixed;
507 if (!(
info.status_ & SceneInfoViewFixed)) {
508 info.status_ |= SceneInfoViewFixed;
509 info.status_ |= SceneInfoFixed;
510 printf(
"changed to vfixed\n");
511 v->s2o().inverse_transform(
info.x_,
info.y_);
518 SceneInfo
info(glyph);
525 SceneInfo
info(glyph);
526 info.status_ |= SceneInfoFixed;
534 SceneInfo
info(glyph);
535 info.status_ |= SceneInfoFixed | SceneInfoViewFixed;
542 SceneInfo
info(glyph);
549 SceneInfo
info(glyph);
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);
611 Coord x1, y1, x2, y2;
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;
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);
665 if ((
info.status_ & SceneInfoFixed) &&
info.glyph_ !=
NULL &&
666 (
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);
686 ((
Scene*)
this)->drawing_fixed_item_ =
false;
687 canvas->pop_transform();
697 bool are_fixed =
false;
700 if (
info.status_ & SceneInfoFixed) {
702 }
else if (
info.glyph_ !=
NULL && (
info.status_ & SceneInfoShowing)) {
706 if (canvas->damaged(b)) {
707 info.glyph_->print(canvas, a);
713 ((
Scene*)
this)->drawing_fixed_item_ =
true;
714 canvas->push_transform();
718 canvas->transform(tv);
721 if ((
info.status_ & SceneInfoFixed) &&
info.glyph_ !=
NULL &&
722 (
info.status_ & SceneInfoShowing)) {
725 if (!(
info.status_ & SceneInfoViewFixed)) {
726 tv.inverse_transform(a.
x(), a.
y(), x, y);
734 if (canvas->damaged(b)) {
735 info.glyph_->print(canvas, a);
739 ((
Scene*)
this)->drawing_fixed_item_ =
false;
740 canvas->pop_transform();
746 if (
mbs() > 0. &&
picker_ && h.
event() && h.event()->type() == Event::down) {
747 Coord ax, ay, ex, ey;
748 c->transformer().transform(h.left(), h.top(), ex, ey);
749 c->transformer().transform(a.
left(), a.
top(), ax, ay);
767 if (
info.glyph_ !=
NULL && (
info.status_ & SceneInfoShowing)) {
770 h.right() >= a.
left() && h.left() < a.
right()
771 && h.top() >= a.
bottom() && h.bottom() < a.
top()
773 h.begin(depth,
this,
index);
774 info.glyph_->pick(
c, a, depth + 1, h);
784 bool are_fixed =
false;
787 if (
info.status_ & SceneInfoFixed) {
789 }
else if (
info.glyph_ !=
NULL && (
info.status_ & SceneInfoShowing)) {
791 if (h.right() >= a.
left() - epsx && h.left() < a.
right() + epsx &&
792 h.top() >= a.
bottom() - epsy && h.bottom() < a.
top() + epsy) {
793 h.begin(depth,
this,
index);
794 info.glyph_->pick(
c, a, depth + 1, h);
805 tv.matrix(scx, tmp, tmp, scy, tmp, tmp);
808 if ((
info.status_ & SceneInfoFixed) &&
info.glyph_ !=
NULL &&
809 (
info.status_ & SceneInfoShowing)) {
812 if (
info.status_ & SceneInfoViewFixed) {
820 l = (a.
left() - a.
x()) * scx + a.
x();
821 r = (a.
right() - a.
x()) * scx + a.
x();
822 t = (a.
top() - a.
y()) * scy + a.
y();
823 b = (a.
bottom() - a.
y()) * scy + a.
y();
827 if (h.right() >= l && h.left() < r && h.top() >= b && h.bottom() <
t) {
828 h.begin(depth,
this,
index);
829 info.glyph_->pick(
c, a, depth + 1, h);
839 long i,
cnt = scene_list->count();
840 for (
i = 0;
i <
cnt; ++
i) {
841 if (s == scene_list->item(
i)) {
850 o <<
"objectvar save_window_, rvp_" << endl;
854 long count = scene_list->count();
860 Scene* s = scene_list->item(
i);
868 o <<
"save_window_ = new " << s <<
"(0)" << endl;
void allot_y(const Allotment &)
bool equals(const Allocation &, float epsilon) const
void allot(DimensionName, const Allotment &)
Allotment & x_allotment()
Allotment & y_allotment()
void allot_x(const Allotment &)
void set(Canvas *, const Allocation &)
static bool inside(Coord x, Coord min, Coord max)
static void help(const char *)
static PrintableWindowManager * current()
void psfilter(const char *filename)
void require_x(const Requirement &)
void require_y(const Requirement &)
const Requirement & requirement(DimensionName) const
virtual void unref() const
virtual GlyphIndex glyph_index(const Glyph *)
virtual void pick(Canvas *, const Allocation &, int depth, Hit &)
static long scene_list_index(Scene *)
virtual XYView * sceneview(int) const
void show(GlyphIndex, bool)
virtual void printfile(const char *)
void move(GlyphIndex, Coord x, Coord y)
virtual void save_phase1(std::ostream &)
virtual void change_to_fixed(GlyphIndex, XYView *)
virtual void save_phase2(std::ostream &)
virtual void replace(GlyphIndex, Glyph *)
virtual void damage(GlyphIndex)
virtual void allocate(Canvas *, const Allocation &, Extension &)
bool showing(GlyphIndex) const
virtual void background(Glyph *bg=NULL)
virtual void append_viewfixed(Glyph *)
static const Color * default_background()
void location(GlyphIndex, Coord &x, Coord &y) const
Scene(Coord x1, Coord y1, Coord x2, Coord y2, Glyph *background=NULL)
void check_allocation(GlyphIndex)
virtual void damage_all()
virtual void append(Glyph *)
virtual void change_to_vfixed(GlyphIndex, XYView *)
virtual void new_size(Coord x1, Coord y1, Coord x2, Coord y2)
virtual void prepend(Glyph *)
void remove_view(XYView *)
static const Color * default_foreground()
virtual void change(GlyphIndex)
virtual void save_class(std::ostream &, const char *)
virtual int view_count() const
virtual void request(Requisition &) const
virtual void wholeplot(Coord &x1, Coord &y1, Coord &x2, Coord &y2) const
virtual GlyphIndex count() const
virtual Glyph * component(GlyphIndex) const
virtual void remove(GlyphIndex)
virtual void insert(GlyphIndex, Glyph *)
static void save_all(std::ostream &)
virtual void allotment(GlyphIndex, DimensionName, Allotment &) const
void append_view(XYView *)
virtual void print(Printer *, const Allocation &) const
virtual void append_fixed(Glyph *)
virtual void modified(GlyphIndex)
virtual void draw(Canvas *, const Allocation &) const
virtual Coord mbs() const
virtual void pick_menu(Glyph *, int, Hit &)
void event(const Event &)
virtual void view_ratio(float xratio, float yratio, Coord &x, Coord &y) const
virtual void printfile(const char *)
virtual void damage(Glyph *, const Allocation &, bool fixed=false, bool viewfixed=false)
virtual void zin(Coord &x1, Coord &y1, Coord &x2, Coord &y2) const
static XYView * current_draw_view()
static XYView * current_pick_view()
const Transformer & s2o() const
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)
unsigned int DimensionName
#define implementPtrList(PtrList, T)
#define declareList(List, T)
#define declarePtrList(PtrList, T)
implementList(__AnyPtrList, __AnyPtr) static long ListImpl_best_new_sizes[]
static void pr(N_Vector x)
static const char * fname(const char *name)