1 #include <../../nrnconf.h> 2 #if HAVE_IV // to end of file 4 #include <InterViews/canvas.h> 5 #include <InterViews/transformer.h> 6 #include <InterViews/label.h> 7 #include <InterViews/hit.h> 8 #include <InterViews/cursor.h> 9 #include <IV-look/kit.h> 21 #define LineRubberMarker_event_ "Crosshair Graph" 22 #define DeleteLabelHandler_event_ "Delete Graph" 23 #define ChangeLabelHandler_event_ "ChangeText" 24 #define DeleteLineHandler_event_ "Delete Graph" 25 #define LinePicker_event_ "Pick Graph" 26 #define MoveLabelBand_press_ "MoveText Graph" 34 virtual ~LineRubberMarker();
38 int index() {
return index_;}
44 #if defined(WIN32)||MAC 52 virtual ~MoveLabelBand();
65 class DeleteLabelHandler :
public Handler {
67 DeleteLabelHandler(
GLabel*);
68 ~DeleteLabelHandler();
69 virtual bool event(
Event&);
74 class ChangeLabelHandler :
public Handler {
76 ChangeLabelHandler(
GLabel*);
77 ~ChangeLabelHandler();
78 virtual bool event(
Event&);
83 class DeleteLineHandler :
public Handler {
87 virtual bool event(
Event&);
110 if (h.count() && h.target(depth, 0)) {
return;}
111 if (h.event() && h.event()->type() == Event::down
113 Coord x = h.left(), y = h.bottom();
116 if (
near(x, y, 10, c->transformer())) {
117 h.target(depth,
this, 0,
118 new LineRubberMarker(
this,
NULL, c)
123 if (
near(x, y, 10, c->transformer())) {
124 h.target(depth,
this, 0,
125 new DeleteLineHandler(
this)
130 if (
near(x, y, 10, c->transformer())) {
132 change_line_color(
this);
136 if (
near(x, y, 5, c->transformer())) {
137 h.target(depth,
this, 0,
new LinePicker(
this));
144 if (h.count() && h.target(depth, 0)) {
return;}
145 if (h.event() && h.event()->type() == Event::down
147 Coord x = h.left(), y = h.bottom();
150 h.target(depth,
this, 0,
151 new LineRubberMarker(a.
x(), a.
y(),
NULL,
c)
159 if (
x_->count() <= 0) {
162 int index = nearest(xcm, ycm, t);
166 if (index < x_->count() - 1) {
174 t.transform(xcm, ycm, xc, yc);
183 int count =
x_->count();
185 t.transform(x1,y1,x,y);
187 #define Norm2(lval, arg) \ 188 t.transform(x_->get_val(arg), y_->get_val(arg), xt, yt); \ 189 lval = MyMath::norm2(x - xt, y - yt); 192 if (index_begin < 0) {
195 for (i = 1; i < count; ++
i) {
203 float dxleft, dxright;
204 i = index = index_begin;
206 dxleft = dxright = dxmin;
213 if (dxright < dxleft) {
214 while (++i < count) {
257 LineRubberMarker::~LineRubberMarker(){
262 bool LineRubberMarker::event(
Event&
e) {
264 if (e.type() == Event::down) {
271 if (e.mapkey(buf, 1) > 0) {
274 cross_action(buf[0], gl_, index_);
277 cross_action(buf[0],
x_,
y_);
282 #if defined(WIN32)||MAC 283 if (e.type() == Event::down) {
285 }
else if (e.type() == Event::up) {
294 transformer().transform(
x_,
y_, x, y);
298 c->transformer(identity);
299 #if !defined(WIN32)&& !MAC 309 void LineRubberMarker::draw(
Coord x,
Coord y) {
312 transformer().inverse_transform(x, y, x1, y1);
315 index_ = gl_->nearest(x1, y1, transformer(), index_);
322 #if defined(WIN32) || MAC 336 if (h.count() && h.target(depth, 0)) {
return;}
337 if (h.event() && h.event()->type() == Event::down
342 h.target(depth,
this, 0,
343 new MoveLabelBand(
this,
NULL, c)
347 h.target(depth,
this, 0,
348 new DeleteLabelHandler(
this)
355 h.target(depth,
this, 0,
356 new ChangeLabelHandler(
this)
362 DeleteLabelHandler::DeleteLabelHandler(
GLabel* gl) {
367 DeleteLabelHandler::~DeleteLabelHandler(){
370 bool DeleteLabelHandler::event(
Event& e) {
372 if (e.type() == Event::down) {
373 Oc::help(DeleteLabelHandler_event_);
381 ChangeLabelHandler::ChangeLabelHandler(
GLabel* gl) {
386 ChangeLabelHandler::~ChangeLabelHandler(){
389 bool ChangeLabelHandler::event(
Event& e) {
391 if (e.type() == Event::down) {
392 Oc::help(ChangeLabelHandler_event_);
397 strcpy(buf, gl_->text());
401 e.pointer_root_x(), e.pointer_root_y()
410 printf(
"No method for changeing label color %s\n", gl->
text());
414 printf(
"No method for changeing line color \n");
418 printf(
"No method for deleting label %s\n", gl->
text());
421 DeleteLineHandler::DeleteLineHandler(
GPolyLine* gpl) {
426 DeleteLineHandler::~DeleteLineHandler(){
429 bool DeleteLineHandler::event(
Event& e) {
431 if (e.type() == Event::down) {
440 gpl_->erase_line(s, i);
449 LinePicker::~LinePicker(){
472 void LinePicker::common() {
477 if (gpl_->label() && (i=s->
glyph_index(gpl_->label())) >= 0) {
496 transformer().transform(x0_, y0_);
508 MoveLabelBand::~MoveLabelBand() {
521 #if 0 && !defined(WIN32) 522 cursor_ = canvas()->window()->cursor();
523 canvas()->window()->cursor(noCursor);
525 #if !defined(WIN32) && !MAC 535 Coord x1, y1, x2, y2;
537 transformer().inverse_transform(x(), y(), x2, y2);
538 transformer().inverse_transform(x_begin(), y_begin(), x1, y1);
540 x2 = x(); y2 = y(); x1 = x_begin(); y1 = y_begin();
549 x0_ + x2 - x1, y0_ + y2 - y1, x1, y1);
552 gr->
move(index_, x1, y1);
553 #if 0 && !defined(WIN32) 554 canvas()->window()->cursor(cursor_);
564 a_.x_allotment().origin(x + x0_);
565 a_.y_allotment().origin(y + y0_);
566 #if defined(WIN32) || MAC 567 c->rect(
a_.x_allotment().begin(),
a_.y_allotment().begin(),
568 a_.x_allotment().end(),
a_.y_allotment().end(),
void allot_x(const Allotment &)
virtual void delete_label(GLabel *)
static void help(const char *)
virtual void change_label_color(GLabel *)
virtual void modified(GlyphIndex)
sprintf(buf," if (secondorder) {\ " int _i;\" " for(_i=0;_i< %d;++_i) {\" " _p[_slist%d[_i]]+=dt *_p[_dlist%d[_i]];\" " }}\", numeqn, listnum, listnum)
virtual void undraw(Coord x, Coord y)
virtual void change_line_color(GPolyLine *)
virtual GlyphIndex glyph_index(const Glyph *)
void allot_y(const Allotment &)
static const Color * color()
static bool label_chooser(const char *, char *, GLabel *, Coord x=400., Coord y=400.)
virtual void damage(GlyphIndex)
virtual void allotment(GlyphIndex, DimensionName, Allotment &) const
virtual void pick(Canvas *, const Allocation &, int depth, Hit &)
virtual void view_ratio(float xratio, float yratio, Coord &x, Coord &y) const
void location(GlyphIndex, Coord &x, Coord &y) const
virtual void draw(Coord x, Coord y)
void move(GlyphIndex, Coord x, Coord y)
virtual void unref() const
virtual void pick(Canvas *, const Allocation &, int depth, Hit &)
virtual void pick(Canvas *, const Allocation &, int depth, Hit &)
const Event & event() const
static bool near_line(Coord x, Coord y, Coord x1, Coord y1, Coord x2, Coord y2, float epsilon)
virtual Scene * scene() const
virtual void pick(Canvas *, const Allocation &, int depth, Hit &)
int nearest(Coord, Coord, const Transformer &, int index=-1) const
static const Brush * brush()
virtual void ratio_view(Coord x, Coord y, float &xratio, float &yratio) const
virtual GlyphIndex glyph_index(const Glyph *)
static XYView * current_pick_view()
const Color * color(int) const
bool near(Coord, Coord, float, const Transformer &) const
virtual Glyph * clone() const