1 #include <../../nrnconf.h> 2 #if HAVE_IV // to end of file 4 #include <IV-look/kit.h> 5 #include <InterViews/layout.h> 6 #include <InterViews/telltale.h> 7 #include <InterViews/window.h> 20 #define Scene_SceneMover_ "Translate Scene" 21 #define Scene_SceneZoom_ "ZoomInOut Scene" 22 #define Scene_RoundView_ "RoundView Scene" 23 #define Scene_WholeSceneView_ "WholeScene Scene" 24 #define Scene_WholePlotView_ "View_equal_Plot Scene" 25 #define Scene_ZoomOut10_ "ZoomOut10 Scene" 26 #define Scene_ZoomeIn10_ "ZoomIn10 Scene" 27 #define Scene_SpecView_ "SetView Scene" 28 #define Scene_SizeScene_ "Scene_equal_View Scene" 29 #define Scene_NewView_ "NewView Scene" 30 #define Scene_ShowMenu_ "Scene" 31 #define Scene_ObjectName_ "ObjectName" 34 Glyph*
g = LayoutKit::instance()->r_margin(
35 WidgetKit::instance()->fancy_label(name), 0.0,
fil, 0.0
37 return WidgetKit::instance()->menu_item(g);
41 Glyph* g = LayoutKit::instance()->r_margin(
42 WidgetKit::instance()->fancy_label(name), 0.0,
fil, 0.0
44 return WidgetKit::instance()->check_menu_item(g);
48 Glyph* g = LayoutKit::instance()->r_margin(
49 WidgetKit::instance()->fancy_label(name), 0.0,
fil, 0.0
51 return WidgetKit::instance()->radio_menu_item(tg, g);
54 class ButtonItemInfo {
57 virtual ~ButtonItemInfo();
73 ButtonItemInfo::~ButtonItemInfo(){}
78 cnt = parent_->item_count();
79 for (i=0; i <
cnt; ++
i) {
80 if (parent_->item(i) == mi_) {
94 virtual ~SceneMover();
95 virtual bool event(
Event&);
105 virtual ~SceneZoom();
106 virtual bool event(
Event&);
121 class RoundView :
public Action {
125 class WholeSceneView :
public Action {
129 class WholePlotView :
public Action {
133 class SpecView :
public Action {
137 class SizeScene :
public Action {
141 class ZoomOut10:
public Action {
145 class ZoomIn10:
public Action {
149 class SPObjectName:
public Action {
153 class ShowMenu:
public Action {
167 SceneZoom* z =
new SceneZoom();
168 SceneMover* m =
new SceneMover();
170 Menu* men = k.pulldown();
173 picker_->add_menu(mi);
175 picker_->add_menu(
"View = plot",
new WholePlotView(), men);
176 picker_->add_menu(
"Set View",
new SpecView(), men);
177 picker_->add_menu(
"10% Zoom out",
new ZoomOut10(), men);
178 picker_->add_menu(
"10% Zoom in",
new ZoomIn10(), men);
179 picker_->add_radio_menu(
"NewView",
new RubberRect(
new NewView()),0 , 0, men);
180 picker_->add_radio_menu(
"Zoom in/out", z, 0, men);
181 picker_->add_radio_menu(
"Translate", m, 0, men);
182 picker_->add_menu(
"Round View",
new RoundView(), men);
183 picker_->add_menu(
"Whole Scene",
new WholeSceneView() , men);
184 picker_->add_menu(
"Scene=View",
new SizeScene(), men);
185 picker_->add_menu(
"Object Name",
new SPObjectName(), men);
189 picker_->add_menu(k.menu_item_separator());
190 picker_->bind_select(z);
191 picker_->bind_adjust(m);
196 class ScenePickerImpl :
public OcHandler {
198 ScenePickerImpl(
Scene* );
199 virtual ~ScenePickerImpl();
200 virtual bool event(
Event&);
201 long info_index(
const char*);
208 ButtonItemInfoList* bil_;
213 h.target(depth, glyph, 0,
spi_);
218 class RadioSelect:
public Action {
221 virtual ~RadioSelect();
229 class RubberTool:
public Action {
232 virtual ~RubberTool();
241 class HandlerTool:
public Action {
244 virtual ~HandlerTool();
253 spi_ =
new ScenePickerImpl(scene);
259 return ScenePickerImpl::window_;
273 spi_->menu_->append_item(mi);
283 mm = spi_->menu_->menu();
286 spi_->bil_->append(
new ButtonItemInfo(name, mi->action(), mi->state(), mi,
mm));
293 return add_menu(name, mi, m);
297 mi->action(
new RadioSelect(name, a, spi_->scene_));
298 return add_menu(name, mi, m);
301 Button* mi = WidgetKit::instance()->radio_button(spi_->tg_, name,
302 new RadioSelect(name, a, spi_->scene_));
303 spi_->bil_->append(
new ButtonItemInfo(name, mi->action(), mi->state()));
307 return add_radio_menu(name,
new RubberTool(sel, rb,
this, tool), m);
310 return radio_button(name,
new RubberTool(sel, rb,
this, tool));
313 return add_radio_menu(name,
new HandlerTool(h,
this, tool), m);
316 long ScenePickerImpl::info_index(
const char* name) {
319 for (i=0; i <
cnt; ++
i) {
320 ButtonItemInfo* b = bil_->item(i);
321 if (strcmp(b->name_.string(),
name) == 0) {
338 ScenePickerImpl::window_ =
NULL;
340 i = spi_->info_index(name);
342 ButtonItemInfo* b = spi_->bil_->item(i);
344 bool chosen = t->test(TelltaleState::is_chosen);
346 if (t->test(TelltaleState::is_toggle)) {
347 t->set(TelltaleState::is_chosen, act);
349 }
else if (t->test(TelltaleState::is_choosable)) {
350 t->set(TelltaleState::is_chosen,
true);
353 if (act && b->a_ !=
NULL) {
361 i = spi_->info_index(name);
363 ButtonItemInfo* b = spi_->bil_->item(i);
364 spi_->bil_->remove(i);
367 b->parent_->remove_item(j);
378 i = spi_->info_index(insert);
380 ButtonItemInfo* b = spi_->bil_->item(i);
383 b->parent_->insert_item(j, mi);
384 spi_->bil_->insert(i,
new ButtonItemInfo(name,
385 mi->action(), mi->state(), mi, b->parent_));
391 spi_->scene_->tool(t);
395 spi_->scene_->help();
399 spi_->sel_name_ =
name;
403 return spi_->sel_name_.string();
406 ScenePickerImpl::ScenePickerImpl(
Scene* scene) : sel_name_(
""){
412 bil_ =
new ButtonItemInfoList(20);
415 ScenePickerImpl::~ScenePickerImpl() {
418 for (
long i=bil_->count() - 1; i >= 0; --
i) {
419 delete bil_->item(i);
424 bool ScenePickerImpl::event(
Event&
e) {
440 RubberTool::~RubberTool() {
446 sp_->bind_select(rb_);
447 sp_->set_scene_tool(tool_);
455 RadioSelect::RadioSelect(
const char* name,
Action* a,
Scene* s) : name_(name) {
461 RadioSelect::~RadioSelect() {
468 s_->picker()->select_name(this->name_.string());
469 for (
int i=0; i < s_->view_count(); ++
i) {
470 XYView* v = s_->sceneview(i);
482 HandlerTool::~HandlerTool() {
487 sp_->bind_select(h_);
488 sp_->set_scene_tool(tool_);
498 SceneMover::SceneMover(){
503 SceneMover::~SceneMover(){}
509 bool SceneMover::event(
Event& e) {
511 if (e.type() == Event::down) {
525 e.window()->grab_pointer();
529 view_->move_view(
x_ - xold,
y_ - yold);
534 e.window()->ungrab_pointer();
541 SceneZoom::SceneZoom(){
548 SceneZoom::~SceneZoom(){}
554 bool SceneZoom::event(
Event& e) {
556 if (e.type() == Event::down) {
570 e.window()->grab_pointer();
576 xold = (
x_ - xold)/50;
577 yold = (
y_ - yold)/50;
578 if (xold > .5) xold = .5;
579 if (yold > .5) yold = .5;
580 if (xold < -.5) xold = -.5;
581 if (yold < -.5) yold = -.5;
582 view_->scale_view(xorg_, yorg_, xold, yold);
587 e.window()->ungrab_pointer();
601 Coord x1, y1, x2, y2;
602 v->
zin(x1, y1, x2, y2);
603 double d1, d2;
int ntic;
611 v->
size(x1, y1, x2, y2);
612 v->
zout(x1, y1, x2, y2);
613 v->
size(x1, y1, x2, y2);
626 Coord x1, y1, x2, y2;
627 v->
zout(x1, y1, x2, y2);
628 v->
size(x1, y1, x2, y2);
640 Coord x1, y1, x2, y2;
645 v->
zout(x1, y1, x2, y2);
656 Coord x1, x2, y1, y2;
657 v->
zout(x1, y1, x2, y2);
658 v->
size(x1, y1, x2, y2);
669 Coord x1, x2, y1, y2;
670 v->
zin(x1, y1, x2, y2);
671 v->
size(x1, y1, x2, y2);
689 Coord x1, x2, y1, y2;
690 v->
zin(x1, y1, x2, y2);
693 v->
size(x1, y1, x2, y2);
694 v->
zout(x1, y1, x2, y2);
695 v->
size(x1, y1, x2, y2);
706 Coord x1, x2, y1, y2;
707 v->
zin(x1, y1, x2, y2);
709 v->
zout(x1, y1, x2, y2);
710 v->
size(x1, y1, x2, y2);
714 NewView::~NewView(){}
728 ((
RubberRect*)rb)->get_rect_canvas(l, b, r, t);
733 w->place(l + e.pointer_root_x() - e.pointer_x(),
734 b + e.pointer_root_y() - e.pointer_y());
738 ShowMenu::ShowMenu(
Menu* m) {
742 ShowMenu::~ShowMenu() {
756 printf(
"OcViewGlyph::viewmenu()\n");
763 hbox->append(lk.center(m, 0, 1));
764 hbox->append(lk.center(
view(), 0, 1));
776 menu_ = WidgetKit::instance()->pulldown();
793 w_->place(10000,10000);
800 if (!grabbed_) {
Coord l, b;
801 w_->place(e.pointer_root_x(), e.pointer_root_y());
803 #if defined(WIN32) || MAC 806 if (b < 0. || l < 0.) {
808 w_->place((l>0.)?l:1., (b>0.)?b:20.);
815 if (b < 0. || l < 0.) {
818 w_->place((l>0.)?l:1., (b>0.)?b:20.);
845 menu_->append_item(mi);
static MenuItem * menu_item(const char *)
virtual void damage_all()
void remove_item(const char *)
#define declarePtrList(PtrList, T)
virtual int view_count() const
virtual XYView * new_view(Coord x1, Coord y1, Coord x2, Coord y2)
void insert_item(const char *, const char *, MenuItem *)
char * hoc_object_name(Object *ob)
virtual const char * select_name()
static void help(const char *)
virtual bool event(Event &)
static MenuItem * check_menu_item(const char *)
static void round_range_down(Coord x1, Coord x2, double &y1, double &y2, int &ntic)
virtual void box_size(Coord x1, Coord y1, Coord x2, Coord y2)
static MenuItem * radio_menu_item(TelltaleGroup *, const char *)
static philox4x32_key_t k
virtual void set_scene_tool(int)
void size(Coord x1, Coord y1, Coord x2, Coord y2)
static double round(float &x1, float &x2, int direction, int digits)
virtual void wholeplot(Coord &x1, Coord &y1, Coord &x2, Coord &y2) const
bool var_pair_chooser(const char *, float &x, float &y, Window *w=NULL, Coord x1=400., Coord y1=400.)
#define implementPtrList(PtrList, T)
static double insert(void *v)
MenuItem * add_radio_menu(const char *, Action *, Menu *=NULL)
virtual void exec_item(const char *)
virtual XYView * sceneview(int) const
virtual void unref() const
virtual void zout(Coord &x1, Coord &y1, Coord &x2, Coord &y2) const
virtual void new_size(Coord x1, Coord y1, Coord x2, Coord y2)
virtual void pick_menu(Glyph *, int, Hit &)
MenuItem * add_menu(MenuItem *, Menu *=NULL)
virtual Scene * scene() const
Button * radio_button(const char *, Action *)
static XYView * current_pick_view()
virtual void zin(Coord &x1, Coord &y1, Coord &x2, Coord &y2) const
static DismissableWindow * last_window()
TelltaleGroup * telltale_group()