From 1e9665b876381b5654ff3846ba9e3f474ecb17d7 Mon Sep 17 00:00:00 2001 From: Russell Standish Date: Sun, 7 Jan 2024 16:26:16 +1100 Subject: [PATCH 1/6] Removed features supporting hiding variable definitions, as well as plot tab support. For #1675. --- Makefile | 2 +- RESTService/typescriptAPI.cc | 2 - .../src/app/managers/ContextMenuManager.ts | 35 --- gui-js/libs/shared/src/lib/backend/minsky.ts | 12 +- .../shared/src/lib/constants/constants.ts | 2 +- model/canvas.cc | 48 ---- model/canvas.h | 8 - model/itemTab.cc | 230 ------------------ model/itemTab.h | 103 -------- model/minsky.h | 5 - model/plotWidget.h | 3 - model/variable.h | 4 - schema/plotOptions.h | 4 +- 13 files changed, 4 insertions(+), 454 deletions(-) delete mode 100644 model/itemTab.cc delete mode 100644 model/itemTab.h diff --git a/Makefile b/Makefile index 7ba4b0960..b5802ea5c 100644 --- a/Makefile +++ b/Makefile @@ -126,7 +126,7 @@ PREFIX=/usr/local # custom one that picks up its scripts from a relative library # directory MODLINK=$(LIBMODS:%=$(ECOLAB_HOME)/lib/%) -MODEL_OBJS=autoLayout.o cairoItems.o canvas.o CSVDialog.o dataOp.o equationDisplay.o godleyIcon.o godleyTable.o godleyTableWindow.o grid.o group.o item.o itemTab.o intOp.o lasso.o lock.o minsky.o operation.o operationRS.o operationRS1.o operationRS2.o phillipsDiagram.o plotWidget.o port.o pubTab.o ravelWrap.o renderNativeWindow.o selection.o sheet.o SVGItem.o switchIcon.o userFunction.o userFunction_units.o variableInstanceList.o variable.o variablePane.o windowInformation.o wire.o +MODEL_OBJS=autoLayout.o cairoItems.o canvas.o CSVDialog.o dataOp.o equationDisplay.o godleyIcon.o godleyTable.o godleyTableWindow.o grid.o group.o item.o intOp.o lasso.o lock.o minsky.o operation.o operationRS.o operationRS1.o operationRS2.o phillipsDiagram.o plotWidget.o port.o pubTab.o ravelWrap.o renderNativeWindow.o selection.o sheet.o SVGItem.o switchIcon.o userFunction.o userFunction_units.o variableInstanceList.o variable.o variablePane.o windowInformation.o wire.o ENGINE_OBJS=coverage.o clipboard.o derivative.o equationDisplayRender.o equations.o evalGodley.o evalOp.o flowCoef.o \ godleyExport.o latexMarkup.o valueId.o variableValue.o node_latex.o node_matlab.o CSVParser.o \ minskyTensorOps.o mdlReader.o saver.o rungeKutta.o diff --git a/RESTService/typescriptAPI.cc b/RESTService/typescriptAPI.cc index 269fca5db..f3c8fa26a 100644 --- a/RESTService/typescriptAPI.cc +++ b/RESTService/typescriptAPI.cc @@ -32,8 +32,6 @@ #include "intOp.tcd" #include "item.tcd" #include "itemT.tcd" -#include "itemTab.h" -#include "itemTab.tcd" #include "lasso.tcd" #include "lock.tcd" #include "noteBase.tcd" diff --git a/gui-js/apps/minsky-electron/src/app/managers/ContextMenuManager.ts b/gui-js/apps/minsky-electron/src/app/managers/ContextMenuManager.ts index 864a0af9a..a86528b62 100644 --- a/gui-js/apps/minsky-electron/src/app/managers/ContextMenuManager.ts +++ b/gui-js/apps/minsky-electron/src/app/managers/ContextMenuManager.ts @@ -43,9 +43,6 @@ export class ContextMenuManager { case "html-godley": this.initContextMenuForGodleyHTMLPopup(event, command,x,y); break; - case "html-summary": - this.initContextMenuForSummaryTab(command); - break; case "ravel": this.initContextMenuForRavelPopup(command,x,y); break; @@ -284,19 +281,6 @@ export class ContextMenuManager { CommandsManager.pasteAt(this.x, this.y); }, }), - new MenuItem({ - label: 'Hide defining groups of selected variables', - click: async () => {minsky.canvas.pushDefiningVarsToTab(); - await CommandsManager.requestRedraw(); - }, - }), - new MenuItem({ - label: 'Show all defining groups on canvas', - click: async () => { - minsky.canvas.showDefiningVarsOnCanvas(); - await CommandsManager.requestRedraw(); - }, - }), new MenuItem({ label: 'Bookmark here', @@ -1040,15 +1024,6 @@ export class ContextMenuManager { }), ]; - if (await v.defined()) { - menuItems.push( - new MenuItem({ - label: 'Hide variable definition', - click: () => {v.toggleVarTabDisplay();} - }) - ); - } - menuItems.push( new MenuItem({ label: 'Flip', @@ -1100,16 +1075,6 @@ export class ContextMenuManager { this.initContextMenuForGodley(godley, r, c, clickType, () => {}); } - private static async initContextMenuForSummaryTab(valueId: string) - { - var menu=new Menu(); - menu.append(new MenuItem({ - label: "Show variable on canvas", - click: async ()=> {await minsky.showVariableDefinitionOnCanvas(valueId);}, - })); - menu.popup(); - } - private static async initContextMenuForGodley(godley: GodleyIcon, r: number, c: number, clickType: string, refreshFunction: () => void) { var menu=new Menu(); diff --git a/gui-js/libs/shared/src/lib/backend/minsky.ts b/gui-js/libs/shared/src/lib/backend/minsky.ts index 2671f1014..bbf7c68a5 100644 --- a/gui-js/libs/shared/src/lib/backend/minsky.ts +++ b/gui-js/libs/shared/src/lib/backend/minsky.ts @@ -204,7 +204,7 @@ 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: any[]): Promise {return this.$callMethod('attachedToDefiningVar',...args);} + 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');} @@ -308,7 +308,6 @@ export class VariableBase extends Item { async temp(): Promise {return this.$callMethod('temp');} async throw_error(a1: string): Promise {return this.$callMethod('throw_error',a1);} async toggleLocal(): Promise {return this.$callMethod('toggleLocal');} - async toggleVarTabDisplay(): Promise {return this.$callMethod('toggleVarTabDisplay');} async tooltip(...args: string[]): Promise {return this.$callMethod('tooltip',...args);} async top(): Promise {return this.$callMethod('top');} async type(): Promise {return this.$callMethod('type');} @@ -321,7 +320,6 @@ export class VariableBase extends Item { async value(...args: any[]): Promise {return this.$callMethod('value',...args);} async valueId(): Promise {return this.$callMethod('valueId');} async valueIdInCurrentScope(a1: string): Promise {return this.$callMethod('valueIdInCurrentScope',a1);} - async varTabDisplay(...args: boolean[]): Promise {return this.$callMethod('varTabDisplay',...args);} async variableCast(): Promise {return this.$callMethod('variableCast');} async varsPassed(...args: number[]): Promise {return this.$callMethod('varsPassed',...args);} async visible(): Promise {return this.$callMethod('visible');} @@ -423,7 +421,6 @@ export class Canvas extends RenderNativeWindow { backgroundColour: ecolab__cairo__Colour; item: Item; itemFocus: Item; - itemVector: Sequence; lasso: LassoBox; model: Group; selection: Selection; @@ -438,7 +435,6 @@ export class Canvas extends RenderNativeWindow { this.backgroundColour=new ecolab__cairo__Colour(this.$prefix()+'.backgroundColour'); this.item=new Item(this.$prefix()+'.item'); this.itemFocus=new Item(this.$prefix()+'.itemFocus'); - this.itemVector=new Sequence(this.$prefix()+'.itemVector',Item); this.lasso=new LassoBox(this.$prefix()+'.lasso'); this.model=new Group(this.$prefix()+'.model'); this.selection=new Selection(this.$prefix()+'.selection'); @@ -494,7 +490,6 @@ export class Canvas extends RenderNativeWindow { async moveTo(a1: number,a2: number): Promise {return this.$callMethod('moveTo',a1,a2);} async openGroupInCanvas(a1: Item): Promise {return this.$callMethod('openGroupInCanvas',a1);} async position(): Promise {return this.$callMethod('position');} - async pushDefiningVarsToTab(): Promise {return this.$callMethod('pushDefiningVarsToTab');} async ravelsSelected(): Promise {return this.$callMethod('ravelsSelected');} async recentre(): Promise {return this.$callMethod('recentre');} async redraw(): Promise {return this.$callMethod('redraw');} @@ -522,8 +517,6 @@ export class Canvas extends RenderNativeWindow { async selectVar(a1: number,a2: number): Promise {return this.$callMethod('selectVar',a1,a2);} async setDefaultPlotOptions(): Promise {return this.$callMethod('setDefaultPlotOptions');} async setItemFocus(a1: Item): Promise {return this.$callMethod('setItemFocus',a1);} - async showDefiningVarsOnCanvas(): Promise {return this.$callMethod('showDefiningVarsOnCanvas');} - async showPlotsOnTab(): Promise {return this.$callMethod('showPlotsOnTab');} async surface(): Promise {return this.$callMethod('surface');} async termX(...args: number[]): Promise {return this.$callMethod('termX',...args);} async termY(...args: number[]): Promise {return this.$callMethod('termY',...args);} @@ -1459,7 +1452,6 @@ export class Minsky extends CppClass { async setGroupIconResource(a1: string): Promise {return this.$callMethod('setGroupIconResource',a1);} async setLockIconResource(a1: string,a2: string): Promise {return this.$callMethod('setLockIconResource',a1,a2);} async setRavelIconResource(a1: string): Promise {return this.$callMethod('setRavelIconResource',a1);} - async showVariableDefinitionOnCanvas(a1: string): Promise {return this.$callMethod('showVariableDefinitionOnCanvas',a1);} async simulationDelay(...args: number[]): Promise {return this.$callMethod('simulationDelay',...args);} async srand(a1: number): Promise {return this.$callMethod('srand',a1);} async step(): Promise {return this.$callMethod('step');} @@ -1678,7 +1670,6 @@ export class PlotWidget extends Item { async pack(a1: classdesc__pack_t): Promise {return this.$callMethod('pack',a1);} async percent(...args: boolean[]): Promise {return this.$callMethod('percent',...args);} async plot(a1: object): Promise {return this.$callMethod('plot',a1);} - async plotTabDisplay(...args: boolean[]): Promise {return this.$callMethod('plotTabDisplay',...args);} async plotType(...args: string[]): Promise {return this.$callMethod('plotType',...args);} async plotWidgetCast(): Promise {return this.$callMethod('plotWidgetCast');} async position(): Promise {return this.$callMethod('position');} @@ -1700,7 +1691,6 @@ export class PlotWidget extends Item { async setMinMax(): Promise {return this.$callMethod('setMinMax');} async subgrid(...args: boolean[]): Promise {return this.$callMethod('subgrid',...args);} async title(...args: string[]): Promise {return this.$callMethod('title',...args);} - async togglePlotTabDisplay(): Promise {return this.$callMethod('togglePlotTabDisplay');} async unpack(a1: classdesc__pack_t): Promise {return this.$callMethod('unpack',a1);} async updateIcon(a1: number): Promise {return this.$callMethod('updateIcon',a1);} async vectorRender(a1: number,a2: minsky__dummy): Promise {return this.$callMethod('vectorRender',a1,a2);} diff --git a/gui-js/libs/shared/src/lib/constants/constants.ts b/gui-js/libs/shared/src/lib/constants/constants.ts index c1cfb8698..871ecec30 100644 --- a/gui-js/libs/shared/src/lib/constants/constants.ts +++ b/gui-js/libs/shared/src/lib/constants/constants.ts @@ -11,7 +11,7 @@ export const ZOOM_IN_FACTOR = 1.1; export const ZOOM_OUT_FACTOR = 0.91; export const RESET_ZOOM_FACTOR = 1; -export const OPEN_DEV_TOOLS_IN_DEV_BUILD = false; +export const OPEN_DEV_TOOLS_IN_DEV_BUILD = true; export const events = { ADD_RECENT_FILE: 'add-recent-file', diff --git a/model/canvas.cc b/model/canvas.cc index c6e00d40d..2167e050e 100644 --- a/model/canvas.cc +++ b/model/canvas.cc @@ -511,54 +511,6 @@ namespace minsky r->leaveLockGroup(); } - void Canvas::pushDefiningVarsToTab() - { - for (auto& i: selection.items) - { - auto v=i->variableCast(); - if (v && v->defined() && !v->varTabDisplay) { - itemVector.push_back(i); - v->toggleVarTabDisplay(); - } - } - requestRedraw(); - } - - void Canvas::showDefiningVarsOnCanvas() - { - for (auto& i: itemVector) - { - auto v=(*i).variableCast(); - if (v && v->defined() && v->varTabDisplay) - v->toggleVarTabDisplay(); - } - // ensure individual hidden defining vars can be made visible once more. for ticket 145. - if (itemVector.empty()) - { - model->recursiveDo - (&GroupItems::items, [&](const Items&,Items::const_iterator i) - { - if (auto v=(*i)->variableCast()) - if (v->defined() && v->varTabDisplay) - v->toggleVarTabDisplay(); - return false; - }); - } - itemVector.clear(); - requestRedraw(); - } - - void Canvas::showPlotsOnTab() - { - model->recursiveDo - (&GroupItems::items, [&](const Items&,Items::const_iterator i) - { - if (auto p=(*i)->plotWidgetCast()) - if (!p->plotTabDisplay) p->togglePlotTabDisplay(); - return false; - }); - } - void Canvas::deleteItem() { if (item) diff --git a/model/canvas.h b/model/canvas.h index fd874a82d..b21b3b9ff 100644 --- a/model/canvas.h +++ b/model/canvas.h @@ -215,14 +215,6 @@ namespace minsky void lockRavelsInSelection(); void unlockRavelsInSelection(); - /// hide or reveal the defining variables and attached items within a selection on the canvas - Items itemVector; - void pushDefiningVarsToTab(); - void showDefiningVarsOnCanvas(); - - /// push all plots on the canvas to the plot tab - void showPlotsOnTab(); - /// delete item referenced by item void deleteItem(); /// delete wire referenced by wire diff --git a/model/itemTab.cc b/model/itemTab.cc deleted file mode 100644 index f8b23b3f7..000000000 --- a/model/itemTab.cc +++ /dev/null @@ -1,230 +0,0 @@ -/* - @copyright Steve Keen 2020 - @author Russell Standish - @author Wynand Dednam - This file is part of Minsky. - - Minsky is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Minsky is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Minsky. If not, see . -*/ -#include "itemTab.h" -#include "latexMarkup.h" -#include "group.h" -#include -#include "minsky.h" -#include "equations.h" -#include "itemTab.rcd" -#include "itemTab.xcd" -#include "pannableTab.rcd" -#include "pannableTab.xcd" -#include "pango.rcd" -#include "pango.xcd" -#include "minsky_epilogue.h" -using namespace std; -using ecolab::cairo::Surface; -using ecolab::Pango; -using ecolab::cairo::CairoSave; - -namespace minsky -{ - void ItemTab::populateItemVector() { - itemVector.clear(); - minsky().canvas.model->recursiveDo(&GroupItems::items, - [&](Items&, Items::iterator i) { - if (itemSelector(*i)) - { - itemVector.emplace_back(*i); - if (!(*i)->itemTabInitialised) - { - // NANs used to indicate the position on tab has not yet been initialised - (*i)->itemTabX=(*i)->x(); - (*i)->itemTabY=(*i)->y(); - (*i)->itemTabInitialised=true; - } - } - return false; - }); - } - - void ItemTab::moveItemTo(float x, float y) - { - if (itemFocus) { - itemFocus->itemTabX=x-offsx; - itemFocus->itemTabY=y-offsy; - } - } - - ItemTab::ClickType ItemTab::clickType(double x, double y) const - { - return (colX(x)>=0 && rowY(y)>=0)? internal: background; - } - - void ItemTab::mouseDown(float x, float y) - { - switch (clickType(x-offsx,y-offsy)) - { - case background: - itemFocus.reset(); - break; - case internal: - if ((itemFocus=itemAt(x-offsx,y-offsy))) - { - moveOffsX=x-itemFocus->itemTabX; - moveOffsY=y-itemFocus->itemTabY; - } - break; - } - - } - - void ItemTab::mouseUp(float x, float y) - { - mouseMove(x,y); - itemFocus.reset(); - } - - void ItemTab::mouseMove(float x, float y) - { - if (itemFocus) - { - moveItemTo(x-moveOffsX,y-moveOffsY); - requestRedraw(); - } - } - - void ItemTab::displayDelayedTooltip(float x, float y) - { - if (auto item=itemAt(x,y)) - { - item->displayDelayedTooltip(x,y); - requestRedraw(); - } - } - - ItemPtr ItemTab::itemAt(float x, float y) - { - ItemPtr item; - auto minD=numeric_limits::max(); - for (auto& i: itemVector) - { - float xx=i->itemTabX+offsx, yy=i->itemTabY+offsy; - float d=sqr(xx-x)+sqr(yy-y); - float z=i->zoomFactor(); - float w=0.5*i->iWidth()*z,h=0.5*i->iHeight()*z; - if (dcairo()); - if (row==0) - cellPtr->setText(varAttrib[col]); - else if (row-1variableCast()) - switch (col) - { - case 0: - cellPtr->setMarkup(latexToPango(v->name())); - break; - case 1: - cellPtr->setMarkup(v->definition()); - break; - case 2: - cellPtr->setMarkup(latexToPango(v->init())); - break; - case 3: - cellPtr->setMarkup(latexToPango(v->tooltip)); - break; - case 4: - cellPtr->setMarkup(latexToPango(v->detailedText)); - break; - case 5: - cellPtr->setText(str(v->sliderStep)); - break; - case 6: - cellPtr->setText(str(v->sliderMin)); - break; - case 7: - cellPtr->setText(str(v->sliderMax)); - break; - case 8: - if (!v->dims().empty()) - cellPtr->setText(""); - else - cellPtr->setText(str(v->value())); - break; - default: - break; - } - assert(varAttrib.size()==9); - return *cellPtr; - } - - - - void ItemTab::draw(cairo_t* cairo) - { - Grid::draw(); - { - cairo::CairoSave cs(cairo); - cairo_set_source_rgba(cairo,0,0,0,0.2); - cairo_rectangle(cairo,0,0,rightColMargin.back(),bottomRowMargin[0]); - cairo_fill(cairo); - } - { - cairo::CairoSave cs(cairo); - cairo_set_source_rgba(cairo,0,0,0,0.5); - // horizontal grid lines - cairo_move_to(cairo,0,0); - cairo_line_to(cairo,rightColMargin.back(),0); - for (auto r: bottomRowMargin) - { - cairo_move_to(cairo,0,r); - cairo_line_to(cairo,rightColMargin.back(),r); - } - // vertical grid lines - cairo_move_to(cairo,0,0); - cairo_line_to(cairo,0,bottomRowMargin.back()); - for (auto r: rightColMargin) - { - cairo_move_to(cairo,r,0); - cairo_line_to(cairo,r,bottomRowMargin.back()); - } - cairo_stroke(cairo); - } - } - - bool ItemTab::redraw(int, int, int, int) - { - if (surface.get()) { - populateItemVector(); - cairo_t* cairo=surface->cairo(); - cairo_translate(cairo,offsx,offsy); - draw(cairo); - ecolab::cairo::Surface surf - (cairo_recording_surface_create(CAIRO_CONTENT_COLOR_ALPHA,NULL)); - draw(surf.cairo()); - m_width=surf.width(); - m_height=surf.height(); - } - return surface.get(); - } - -} -CLASSDESC_ACCESS_EXPLICIT_INSTANTIATION(minsky::ItemTab); diff --git a/model/itemTab.h b/model/itemTab.h deleted file mode 100644 index ecd284022..000000000 --- a/model/itemTab.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - @copyright Steve Keen 2020 - @author Russell Standish - @author Wynand Dednam - This file is part of Minsky. - - Minsky is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Minsky is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Minsky. If not, see . -*/ - -#ifndef ITEMTAB_H -#define ITEMTAB_H -#include "variable.h" -#include "grid.h" -#include -#include "eventInterface.h" -#include "renderNativeWindow.h" -#include "classdesc_access.h" - -namespace minsky -{ - class ItemTabCellPtr: public std::shared_ptr - { - cairo_t* cachedCairo=nullptr; - public: - void reset(cairo_t* cairo) { - if (cairo!=cachedCairo) { - cachedCairo=cairo; - std::shared_ptr::operator=(std::make_shared(cairo)); - } - } - }; - - class ItemTab: public RenderNativeWindow, public Grid - { - CLASSDESC_ACCESS(ItemTab); - bool redraw(int, int, int width, int height) override; - protected: - classdesc::Exclude cellPtr; - public: - ItemTab() {} - - double xoffs=80; - float offsx=0, offsy=0; - float m_width=600, m_height=800; - virtual float width() const {return m_width;} - virtual float height() const {return m_height;} - Items itemVector; - - unsigned numRows() const override {return itemVector.size()+1;} - unsigned numCols() const override {return varAttrib.size();} - - ecolab::Pango& cell(unsigned row, unsigned col) override; - - void moveCursorTo(double x, double y) override { - if (surface.get()) - cairo_move_to(surface->cairo(),x,y); - } - - virtual void populateItemVector(); - virtual bool itemSelector(const ItemPtr& i) = 0; - void toggleVarDisplay(int i) const {if (i>0 && i-1variableCast()->toggleVarTabDisplay(); else return;} - std::string getVarName(int i) const {if (i>0 && i-1variableCast()->name(); else return "";} - std::vector varAttrib{"Name","Definition","Initial Value","Short Description", "Long Description","Slider Step","Slider Min","Slider Max","Value"}; - void moveItemTo(float x, float y); - - float moveOffsX, moveOffsY,xItem,yItem; - ItemPtr itemFocus; - bool getItemAt(float x, float y) override {return (item=itemAt(x,y)).get();} - enum ClickType {background, internal}; - virtual ClickType clickType(double x, double y) const; - virtual void draw(cairo_t* cairo); - void requestRedraw() {if (surface.get()) surface->requestRedraw();} - - void mouseDown(float x, float y) override; - void mouseUp(float x, float y) override; - void mouseMove(float x, float y) override; - void moveTo(float x, float y) override - { - offsx=x; - offsy=y; - requestRedraw(); - } - virtual ItemPtr itemAt(float x, float y); - void displayDelayedTooltip(float x, float y); - - virtual ~ItemTab() {} - }; - -} - -#include "itemTab.cd" -#endif diff --git a/model/minsky.h b/model/minsky.h index 8a4f45f98..63995f3c4 100644 --- a/model/minsky.h +++ b/model/minsky.h @@ -273,11 +273,6 @@ namespace minsky void makeVariablesConsistent(); - void showVariableDefinitionOnCanvas(const std::string& valueId) { - if (auto v=definingVar(valueId)) - v->varTabDisplay=false; - } - void imposeDimensions(); // runs over all ports and variables removing those not in use diff --git a/model/plotWidget.h b/model/plotWidget.h index 9c4760bca..8e86ff965 100644 --- a/model/plotWidget.h +++ b/model/plotWidget.h @@ -130,9 +130,6 @@ namespace minsky void requestRedraw(); ///< redraw plot using current data to all open windows void redrawWithBounds() override {redraw(0,0,500,500);} - bool plotTabDisplay=true; // ensure plots persisted on plot tab, but can optionally be made hidden. for ticket 1298 - void togglePlotTabDisplay() {plotTabDisplay=!plotTabDisplay;} - /// add this as a display plot to its group void makeDisplayPlot(); diff --git a/model/variable.h b/model/variable.h index 544850ea8..356fe615b 100644 --- a/model/variable.h +++ b/model/variable.h @@ -198,10 +198,6 @@ namespace minsky virtual VariableBase* clone() const override=0; bool isStock() const {return type()==stock || type()==integral;} - bool varTabDisplay=false; - void toggleVarTabDisplay() {varTabDisplay=!varTabDisplay;} - bool attachedToDefiningVar(std::set&) const override {return varTabDisplay;} // <-- does this definition make any sense?? - using Item::attachedToDefiningVar; /// formula defining this variable std::string definition() const; diff --git a/schema/plotOptions.h b/schema/plotOptions.h index 8307347a2..a2f6f7baf 100644 --- a/schema/plotOptions.h +++ b/schema/plotOptions.h @@ -47,7 +47,7 @@ namespace minsky PlotOptions()=default; PlotOptions(const Base& x): Base(x) {} Optional name; //name, description or title - Optional logx, logy, ypercent, plotTabDisplay, grid, subgrid; + Optional logx, logy, ypercent, grid, subgrid; Optional plotType; Optional xlabel, ylabel, y1label; Optional nxTicks, nyTicks; @@ -60,7 +60,6 @@ namespace minsky logx=plot.logx; logy=plot.logy; ypercent=plot.percent; - plotTabDisplay=plot.plotTabDisplay; grid=plot.grid; subgrid=plot.subgrid; plotType=plot.plotType; @@ -82,7 +81,6 @@ namespace minsky if (logx) plot.logx=*logx; if (logy) plot.logy=*logy; if (ypercent) plot.percent=*ypercent; - if (plotTabDisplay) plot.plotTabDisplay=*plotTabDisplay; if (grid) plot.grid=*grid; if (subgrid) plot.subgrid=*subgrid; if (plotType) plot.plotType=*plotType; From 4a5c801ea2bbfc585f884a371d1c15819d9437e9 Mon Sep 17 00:00:00 2001 From: Russell Standish Date: Sun, 7 Jan 2024 16:27:17 +1100 Subject: [PATCH 2/6] Disable dev tools. --- gui-js/libs/shared/src/lib/constants/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui-js/libs/shared/src/lib/constants/constants.ts b/gui-js/libs/shared/src/lib/constants/constants.ts index 871ecec30..c1cfb8698 100644 --- a/gui-js/libs/shared/src/lib/constants/constants.ts +++ b/gui-js/libs/shared/src/lib/constants/constants.ts @@ -11,7 +11,7 @@ export const ZOOM_IN_FACTOR = 1.1; export const ZOOM_OUT_FACTOR = 0.91; export const RESET_ZOOM_FACTOR = 1; -export const OPEN_DEV_TOOLS_IN_DEV_BUILD = true; +export const OPEN_DEV_TOOLS_IN_DEV_BUILD = false; export const events = { ADD_RECENT_FILE: 'add-recent-file', From a0b7cb1ba1e5e95f32cd80bf06da54f65d6d0ff5 Mon Sep 17 00:00:00 2001 From: Russell Standish Date: Sun, 7 Jan 2024 16:44:54 +1100 Subject: [PATCH 3/6] 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; From 33eeebc71408ef49b452bc351afbb5647dc439ba Mon Sep 17 00:00:00 2001 From: Russell Standish Date: Sun, 7 Jan 2024 16:44:54 +1100 Subject: [PATCH 4/6] More hidden variable stuff to remove. Fir #1675. --- 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; From 23f74d58c3654551ca4e4a891b2bf33aa293abca Mon Sep 17 00:00:00 2001 From: Russell Standish Date: Sun, 7 Jan 2024 20:13:22 +1100 Subject: [PATCH 5/6] Removed itemTab test. For #1675. --- test/Makefile | 2 +- test/testItemTab.cc | 139 -------------------------------------------- 2 files changed, 1 insertion(+), 140 deletions(-) delete mode 100644 test/testItemTab.cc diff --git a/test/Makefile b/test/Makefile index f33a8ba93..14668898b 100755 --- a/test/Makefile +++ b/test/Makefile @@ -9,7 +9,7 @@ endif VPATH= .. ../schema ../model ../engine ../RESTService ../RavelCAPI/civita ../RavelCAPI $(ECOLAB_HOME)/include -UNITTESTOBJS=main.o testCSVParser.o testCanvas.o testDerivative.o testExpressionWalker.o testGrid.o testItemTab.o testLatexToPango.o testLockGroup.o testMdl.o testMinsky.o testModel.o testPannableTab.o testPlotWidget.o testSaver.o testStr.o testTensorOps.o testUnits.o testUserFunction.o testVariable.o testXVector.o ticket-1461.o +UNITTESTOBJS=main.o testCSVParser.o testCanvas.o testDerivative.o testExpressionWalker.o testGrid.o testLatexToPango.o testLockGroup.o testMdl.o testMinsky.o testModel.o testPannableTab.o testPlotWidget.o testSaver.o testStr.o testTensorOps.o testUnits.o testUserFunction.o testVariable.o testXVector.o ticket-1461.o MINSKYOBJS=$(filter-out ../tclmain.o ../minskyTCL.o ../RESTService.o ../httpd.o ../addon.o ../dummy-addon.o ../itemTemplateInstantiations.o ../typescriptAPI.o,$(wildcard ../*.o)) localMinsky.o FLAGS:=-I.. -I../RESTService -I../RavelCAPI/civita -I../RavelCAPI $(FLAGS) diff --git a/test/testItemTab.cc b/test/testItemTab.cc deleted file mode 100644 index 19362279e..000000000 --- a/test/testItemTab.cc +++ /dev/null @@ -1,139 +0,0 @@ -/* - @copyright Steve Keen 2021 - @author Russell Standish - This file is part of Minsky. - - Minsky is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Minsky is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Minsky. If not, see . -*/ -#include "minsky.h" -#include "itemTab.h" -#include -#include "minsky_epilogue.h" -#include - -using namespace minsky; -using namespace std; - -namespace -{ - struct TestFixture: public Minsky - { - LocalMinsky lm; - ecolab::cairo::Surface surface{cairo_recording_surface_create(CAIRO_CONTENT_COLOR_ALPHA,NULL)}; - TestFixture(): lm(*this) {} - }; - - struct ParVarTabFixture: public TestFixture - { - VariablePtr a{VariableType::parameter, "a"}; - VariablePtr b{VariableType::parameter, "b"}; - VariablePtr c{VariableType::flow, "c"}; - shared_ptr intOp=make_shared(); - ParVarTabFixture() - { - model->addItem(a); - model->addItem(b); - model->addItem(c); - model->addItem(intOp); - a->toggleVarTabDisplay(); - b->toggleVarTabDisplay(); - c->toggleVarTabDisplay(); - intOp->intVar->toggleVarTabDisplay(); - model->addWire(*a, *c, 1); - } - }; - - struct MockItem: public Item { - bool displayDelayedTooltip_called=false; - void displayDelayedTooltip(float x, float y) {displayDelayedTooltip_called=true;} - MockItem() {m_width=10; m_height=10;} - }; - - struct MockItemTab: public ItemTab - { - bool itemSelector(const ItemPtr& i) override {return true;} - ClickType clickType(double x, double y) const override {return internal;} - MockItemTab() - { - itemVector.emplace_back(make_shared()); - itemVector.emplace_back(make_shared()); - itemVector.emplace_back(make_shared()); - itemVector[0]->itemTabX=itemVector[0]->itemTabY=0; - itemVector[1]->itemTabX=itemVector[1]->itemTabY=50; - itemVector[2]->itemTabX=itemVector[2]->itemTabY=100; - } - }; - -} - -SUITE(ItemTab) -{ - // TODO - revamp tests for pulications tab... -// TEST_FIXTURE(ParVarTabFixture, populateItemVector) -// { -// CHECK_EQUAL(2,parameterTab.itemVector.size()); -// set params(parameterTab.itemVector.begin(), parameterTab.itemVector.end()); -// CHECK_EQUAL(1, params.count(a)); -// CHECK_EQUAL(1, params.count(b)); -// -// // parameters are always displayed in the tab -// -// CHECK_EQUAL(2,variableTab.itemVector.size()); -// set vars(variableTab.itemVector.begin(), variableTab.itemVector.end()); -// CHECK_EQUAL(1, vars.count(c)); -// CHECK_EQUAL(1, vars.count(intOp->intVar)); -// } -// -// TEST_FIXTURE(ParVarTabFixture, checkCells) -// { -// variableTab.surface=make_shared(cairo_recording_surface_create(CAIRO_CONTENT_COLOR_ALPHA,NULL)); -// ecolab::Pango pango(surface.cairo()); -// CHECK_EQUAL(2,variableTab.itemVector.size()); -// // name -// pango.setMarkup(latexToPango(variableTab.itemVector[0]->variableCast()->name())); -// CHECK_EQUAL(pango.width(),variableTab.cell(1,0).width()); -// // definition -// pango.setMarkup(variableTab.itemVector[0]->variableCast()->definition()); -// CHECK_EQUAL(pango.width(),variableTab.cell(1,1).width()); -// pango.setMarkup(variableTab.itemVector[1]->variableCast()->definition()); -// CHECK_EQUAL(pango.width(),variableTab.cell(1,2).width()); -// // test other columns maybe? -// } -// -// TEST_FIXTURE(ParVarTabFixture, itemAt) -// { -// auto item0=variableTab.itemVector[0]; -// CHECK_EQUAL(item0, variableTab.itemAt(item0->itemTabX, item0->itemTabY)); -// auto item1=variableTab.itemVector[1]; -// CHECK_EQUAL(item1, variableTab.itemAt(item1->itemTabX, item1->itemTabY)); -// } - - TEST_FIXTURE(MockItemTab, displayDelayedTooltip) - { - displayDelayedTooltip(50,50); - CHECK(!dynamic_cast(*itemVector[0]).displayDelayedTooltip_called); - CHECK(dynamic_cast(*itemVector[1]).displayDelayedTooltip_called); - CHECK(!dynamic_cast(*itemVector[2]).displayDelayedTooltip_called); - } - - TEST_FIXTURE(MockItemTab, mouseDownUp) - { - mouseDown(50,50); - mouseUp(60,75); - CHECK_EQUAL(60,itemVector[1]->itemTabX); - CHECK_EQUAL(75,itemVector[1]->itemTabY); - } - - -} From 486440e1208477acae6ae7c9a6d5aaea16d24b37 Mon Sep 17 00:00:00 2001 From: Russell Standish Date: Sun, 7 Jan 2024 20:33:44 +1100 Subject: [PATCH 6/6] Remove defunct menu item from Tk version to allow regression test to pass. --- gui-tk/wiring.tcl | 3 --- 1 file changed, 3 deletions(-) diff --git a/gui-tk/wiring.tcl b/gui-tk/wiring.tcl index 4ed2934d7..3fd8d3436 100755 --- a/gui-tk/wiring.tcl +++ b/gui-tk/wiring.tcl @@ -804,9 +804,6 @@ proc contextMenu {x y X Y} { .wiring.context add command -label "Make Group Plot" -command "$item.makeDisplayPlot" .wiring.context add command -label "Options" -command "doPlotOptions $item" .wiring.context add command -label "Pen Styles" -command "penStyles $item" - global plotTabDisplay - set plotTabDisplay [$item.plotTabDisplay] - .wiring.context add checkbutton -label "Display plot on tab" -command "$item.togglePlotTabDisplay" -variable plotTabDisplay .wiring.context add command -label "Export as CSV" -command exportItemAsCSV .wiring.context add command -label "Export resolution factor: [$item.resolutionScaleFactor]" -command "setExportResolutionFactor $item"