From a0b7cb1ba1e5e95f32cd80bf06da54f65d6d0ff5 Mon Sep 17 00:00:00 2001 From: Russell Standish Date: Sun, 7 Jan 2024 16:44:54 +1100 Subject: [PATCH] More hidden variable stuff to remove. --- gui-js/libs/shared/src/lib/backend/minsky.ts | 11 -------- model/group.cc | 2 +- model/intOp.cc | 7 ----- model/intOp.h | 2 -- model/item.cc | 13 ---------- model/item.h | 11 -------- model/variable.cc | 27 +------------------- model/variable.h | 1 - model/wire.cc | 7 ----- model/wire.h | 5 ---- 10 files changed, 2 insertions(+), 84 deletions(-) diff --git a/gui-js/libs/shared/src/lib/backend/minsky.ts b/gui-js/libs/shared/src/lib/backend/minsky.ts index bbf7c68a5..ba777ad9f 100644 --- a/gui-js/libs/shared/src/lib/backend/minsky.ts +++ b/gui-js/libs/shared/src/lib/backend/minsky.ts @@ -47,7 +47,6 @@ export class Item extends CppClass { async RESTProcess(a1: classdesc__RESTProcess_t,a2: string): Promise {return this.$callMethod('RESTProcess',a1,a2);} async TCL_obj(a1: classdesc__TCL_obj_t,a2: string): Promise {return this.$callMethod('TCL_obj',a1,a2);} async adjustBookmark(): Promise {return this.$callMethod('adjustBookmark');} - async attachedToDefiningVar(...args: any[]): Promise {return this.$callMethod('attachedToDefiningVar',...args);} async bookmark(...args: boolean[]): Promise {return this.$callMethod('bookmark',...args);} async bookmarkId(): Promise {return this.$callMethod('bookmarkId');} async bottom(): Promise {return this.$callMethod('bottom');} @@ -119,7 +118,6 @@ export class Item extends CppClass { async updateIcon(a1: number): Promise {return this.$callMethod('updateIcon',a1);} async value(): Promise {return this.$callMethod('value');} async visible(): Promise {return this.$callMethod('visible');} - async visibleWithinGroup(): Promise {return this.$callMethod('visibleWithinGroup');} async width(): Promise {return this.$callMethod('width');} async x(): Promise {return this.$callMethod('x');} async y(): Promise {return this.$callMethod('y');} @@ -204,7 +202,6 @@ export class VariableBase extends Item { async accessibleVars(): Promise {return this.$callMethod('accessibleVars');} async adjustBookmark(): Promise {return this.$callMethod('adjustBookmark');} async adjustSliderBounds(): Promise {return this.$callMethod('adjustSliderBounds');} - async attachedToDefiningVar(...args: Container[]): Promise {return this.$callMethod('attachedToDefiningVar',...args);} async bookmark(...args: boolean[]): Promise {return this.$callMethod('bookmark',...args);} async bookmarkId(): Promise {return this.$callMethod('bookmarkId');} async bottom(): Promise {return this.$callMethod('bottom');} @@ -323,7 +320,6 @@ export class VariableBase extends Item { async variableCast(): Promise {return this.$callMethod('variableCast');} async varsPassed(...args: number[]): Promise {return this.$callMethod('varsPassed',...args);} async visible(): Promise {return this.$callMethod('visible');} - async visibleWithinGroup(): Promise {return this.$callMethod('visibleWithinGroup');} async width(): Promise {return this.$callMethod('width');} async x(): Promise {return this.$callMethod('x');} async y(): Promise {return this.$callMethod('y');} @@ -1043,7 +1039,6 @@ export class Group extends Item { async adjustBookmark(): Promise {return this.$callMethod('adjustBookmark');} async adjustWiresGroup(a1: Wire): Promise {return this.$callMethod('adjustWiresGroup',a1);} async arguments(): Promise {return this.$callMethod('arguments');} - async attachedToDefiningVar(...args: any[]): Promise {return this.$callMethod('attachedToDefiningVar',...args);} async autoLayout(): Promise {return this.$callMethod('autoLayout');} async bookmark(...args: boolean[]): Promise {return this.$callMethod('bookmark',...args);} async bookmarkId(): Promise {return this.$callMethod('bookmarkId');} @@ -1175,7 +1170,6 @@ export class Group extends Item { async updateTimestamp(): Promise {return this.$callMethod('updateTimestamp');} async value(): Promise {return this.$callMethod('value');} async visible(): Promise {return this.$callMethod('visible');} - async visibleWithinGroup(): Promise {return this.$callMethod('visibleWithinGroup');} async width(): Promise {return this.$callMethod('width');} async x(): Promise {return this.$callMethod('x');} async y(): Promise {return this.$callMethod('y');} @@ -1241,7 +1235,6 @@ export class IntOp extends Item { super(prefix.$prefix()) this.intVar=new VariableBase(this.$prefix()+'.intVar'); } - async attachedToDefiningVar(a1: Container): Promise {return this.$callMethod('attachedToDefiningVar',a1);} async coupled(): Promise {return this.$callMethod('coupled');} async description(...args: string[]): Promise {return this.$callMethod('description',...args);} async draw(a1: minsky__dummy): Promise {return this.$callMethod('draw',a1);} @@ -1529,7 +1522,6 @@ export class PhillipsFlow extends Item { } async addTerm(a1: number,a2: string): Promise {return this.$callMethod('addTerm',a1,a2);} async adjustBookmark(): Promise {return this.$callMethod('adjustBookmark');} - async attachedToDefiningVar(...args: Container[]): Promise {return this.$callMethod('attachedToDefiningVar',...args);} async bookmark(...args: boolean[]): Promise {return this.$callMethod('bookmark',...args);} async coords(...args: any[]): Promise {return this.$callMethod('coords',...args);} async deleteHandle(a1: number,a2: number): Promise {return this.$callMethod('deleteHandle',a1,a2);} @@ -1944,7 +1936,6 @@ export class Selection extends CppClass { async adjustBookmark(): Promise {return this.$callMethod('adjustBookmark');} async adjustWiresGroup(a1: Wire): Promise {return this.$callMethod('adjustWiresGroup',a1);} async arguments(): Promise {return this.$callMethod('arguments');} - async attachedToDefiningVar(...args: any[]): Promise {return this.$callMethod('attachedToDefiningVar',...args);} async autoLayout(): Promise {return this.$callMethod('autoLayout');} async bookmark(...args: boolean[]): Promise {return this.$callMethod('bookmark',...args);} async bookmarkId(): Promise {return this.$callMethod('bookmarkId');} @@ -2077,7 +2068,6 @@ export class Selection extends CppClass { async updateIcon(a1: number): Promise {return this.$callMethod('updateIcon',a1);} async value(): Promise {return this.$callMethod('value');} async visible(): Promise {return this.$callMethod('visible');} - async visibleWithinGroup(): Promise {return this.$callMethod('visibleWithinGroup');} async width(): Promise {return this.$callMethod('width');} async x(): Promise {return this.$callMethod('x');} async y(): Promise {return this.$callMethod('y');} @@ -2324,7 +2314,6 @@ export class Wire extends CppClass { super(prefix); } async adjustBookmark(): Promise {return this.$callMethod('adjustBookmark');} - async attachedToDefiningVar(...args: any[]): Promise {return this.$callMethod('attachedToDefiningVar',...args);} async bookmark(...args: boolean[]): Promise {return this.$callMethod('bookmark',...args);} async coords(...args: any[]): Promise {return this.$callMethod('coords',...args);} async deleteHandle(a1: number,a2: number): Promise {return this.$callMethod('deleteHandle',a1,a2);} diff --git a/model/group.cc b/model/group.cc index 60ea096ea..88a4c8e8c 100644 --- a/model/group.cc +++ b/model/group.cc @@ -786,7 +786,7 @@ namespace minsky y1=-numeric_limits::max(); for (auto& i: items) - if (!i->ioVar() && i->visibleWithinGroup()) + if (!i->ioVar()) { if (i->left()left(); if (i->right()>x1) x1=i->right(); diff --git a/model/intOp.cc b/model/intOp.cc index 761885f64..2b9805b4b 100644 --- a/model/intOp.cc +++ b/model/intOp.cc @@ -39,13 +39,6 @@ namespace minsky return r; } - bool IntOp::attachedToDefiningVar(std::set& visited) const - { - visited.insert(this); - if (coupled()) return intVar->attachedToDefiningVar(visited); - return Item::attachedToDefiningVar(visited); - } - void IntOp::draw(cairo_t* cairo) const { // if rotation is in 1st or 3rd quadrant, rotate as diff --git a/model/intOp.h b/model/intOp.h index afad6464a..e6ee2eeb6 100644 --- a/model/intOp.h +++ b/model/intOp.h @@ -66,8 +66,6 @@ namespace minsky std::string valueId() const {return intVar->valueId();} - bool attachedToDefiningVar(std::set&) const override; - using Item::attachedToDefiningVar; void draw(cairo_t*) const override; void resize(const LassoBox& b) override; diff --git a/model/item.cc b/model/item.cc index 9b9e9d549..80d62cc65 100644 --- a/model/item.cc +++ b/model/item.cc @@ -237,14 +237,10 @@ namespace minsky bool Item::visible() const { - if (attachedToDefiningVar()) return false; auto g=group.lock(); return (!g || g->displayContents()); } - bool Item::visibleWithinGroup() const - {return !attachedToDefiningVar();} - void Item::moveTo(float x, float y) { if (auto g=group.lock()) @@ -354,15 +350,6 @@ namespace minsky cairo_stroke(cairo); } - bool Item::attachedToDefiningVar(std::set& visited) const - { - if (!visited.insert(this).second) return false; // break network cycles - if ((variableCast() || operationCast()) && !m_ports.empty()) - for (auto w: m_ports[0]->wires()) - if (w->attachedToDefiningVar(visited)) return true; - return false; - } - // default is just to display the detailed text (ie a "note") void Item::draw(cairo_t* cairo) const { diff --git a/model/item.h b/model/item.h index ff5240a5d..06b35c760 100644 --- a/model/item.h +++ b/model/item.h @@ -282,17 +282,6 @@ namespace minsky /// whether this item is visible on the canvas. virtual bool visible() const; - /// whether this item is visible if the group is expanded to display items. - virtual bool visibleWithinGroup() const; - - - /// whether this item is attached to a defining variable that is hidden - virtual bool attachedToDefiningVar(std::set& visited) const; - bool attachedToDefiningVar() const { - std::set visited; - return attachedToDefiningVar(visited); - } - void moveTo(float x, float y); /// draw this item into a cairo context diff --git a/model/variable.cc b/model/variable.cc index 21c5166df..59f4bcc89 100644 --- a/model/variable.cc +++ b/model/variable.cc @@ -499,32 +499,7 @@ bool VariableBase::visible() const auto g=group.lock(); //toplevel i/o items always visible if ((!g || !g->group.lock()) && g==controller.lock()) return true; - if (!Item::visible()) return false; - return visibleWithinGroup(); -} - -bool VariableBase::visibleWithinGroup() const -{ - // ensure pars, constants and flows with invisible out wires are made invisible. for ticket 1275 - if ((type()==constant || type()==parameter) && !m_ports[0]->wires().empty()) - { - return !(controller.lock() || - std::any_of(m_ports[0]->wires().begin(),m_ports[0]->wires().end(), - [](Wire* w) {return w->attachedToDefiningVar() && !w->visible();} - )); - } - // ensure flow vars with out wires remain visible. for ticket 1275 - if (attachedToDefiningVar()) - { - bool visibleOutWires=false; - for (auto w: m_ports[0]->wires()) - visibleOutWires |= w->visible(); - if (visibleOutWires) - return true; - } - if (auto i=dynamic_cast(controller.lock().get())) - if (i->attachedToDefiningVar()) return true; - return !controller.lock(); + return Item::visible(); } bool VariableBase::sliderVisible() const diff --git a/model/variable.h b/model/variable.h index 356fe615b..8d1e4ae8b 100644 --- a/model/variable.h +++ b/model/variable.h @@ -117,7 +117,6 @@ namespace minsky /// reference to a controlling item - eg GodleyIcon, IntOp or a Group if an IOVar. classdesc::Exclude> controller; bool visible() const override; - bool visibleWithinGroup() const override; const VariableBase* variableCast() const override {return this;} VariableBase* variableCast() override {return this;} diff --git a/model/wire.cc b/model/wire.cc index e932806fd..3d8e2f310 100644 --- a/model/wire.cc +++ b/model/wire.cc @@ -107,7 +107,6 @@ namespace minsky bool Wire::visible() const { - if (attachedToDefiningVar()) return false; auto f=from(), t=to(); auto fgroup=f->item().group.lock(), tgroup=t->item().group.lock(); return f && t && @@ -371,12 +370,6 @@ namespace cairo_path_destroy (path); } - bool Wire::attachedToDefiningVar(std::set& visited) const - { - assert(to()); - return (to()->item().attachedToDefiningVar(visited)); - } - void Wire::draw(cairo_t* cairo, bool reverseArrow) const { auto coords=this->coords(); diff --git a/model/wire.h b/model/wire.h index 5727d0325..b4c466c6e 100644 --- a/model/wire.h +++ b/model/wire.h @@ -68,11 +68,6 @@ namespace minsky /// stash all the internal cairo coordinates along a wire void storeCairoCoords(cairo_t* cairo) const; - bool attachedToDefiningVar(std::set& visited) const; - bool attachedToDefiningVar() const { - std::set visited; - return attachedToDefiningVar(visited); - } /// draw this item into a cairo context void draw(cairo_t* cairo, bool reverseArrow=false) const;