Skip to content

Commit 71cc0ea

Browse files
committed
Variable Links are now Blue
1 parent b4777cd commit 71cc0ea

File tree

7 files changed

+46
-37
lines changed

7 files changed

+46
-37
lines changed

packages/catlog/src/stdlib/models.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,8 @@ pub fn water_volume(th: Rc<UstrDiscreteTabTheory>) -> UstrDiscreteTabModel {
138138
model.add_mor(inflow, TabOb::Basic(source), TabOb::Basic(water), th.hom_type(ob_type.clone()));
139139
model.add_mor(flow, TabOb::Basic(water), TabOb::Basic(sediment), th.hom_type(ob_type));
140140
let spillover = ustr("SpilloverChecker");
141-
let dynamible_type = TabObType::Basic(ustr("DynamicVariable"));
142141
// flow link
143-
model.add_ob(spillover, dynamible_type.clone());
142+
model.add_ob(spillover, TabObType::Basic(ustr("AuxiliaryVariable")));
144143
model.add_mor(
145144
ustr("dynVolume"),
146145
TabOb::Basic(spillover),

packages/catlog/src/stdlib/theories.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ pub fn th_category_dynamic_stockflow() -> UstrDiscreteTabTheory {
159159
TabObType::Basic(x),
160160
th.tabulator(th.hom_type(TabObType::Basic(x))),
161161
);
162-
let v = ustr("DynamicVariable");
162+
let v = ustr("AuxiliaryVariable");
163163
th.add_ob_type(v);
164164
// there is a proarrow from the flow tabulator to the dynamic variable
165165
th.add_mor_type(

packages/frontend/src/stdlib/analyses/model_graph.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export function modelToGraphviz(
108108
theory: Theory,
109109
attributes?: GV.GraphvizAttributes,
110110
nodeAttributes?: (jgmt: ModelJudgment) => Record<string, string> | undefined,
111-
edgeAttributes?: (jgmt: ModelJudgment) => Record<string, string> | undefined,
111+
// edgeAttributes?: (jgmt: ModelJudgment) => Record<string, string> | undefined,
112112
): Viz.Graph {
113113
const nodes = new Map<string, Required<Viz.Graph>["nodes"][0]>();
114114
for (const judgment of model) {
@@ -163,12 +163,11 @@ export function modelToGraphviz(
163163
fontname: GV.graphvizFontname(meta),
164164
// Not recognized by Graphviz but will be passed through!
165165
arrowstyle: meta?.arrowStyle ?? "default",
166-
...(edgeAttributes?.(judgment).state.value ?? {
167-
// label: judgment.name
168-
})
166+
// ...(edgeAttributes?.(judgment).state.value ?? {
167+
// // label: judgment.name
168+
// })
169169
},
170170
});
171-
console.log(edges);
172171
}
173172

174173
return {

packages/frontend/src/stdlib/analyses/stock_flow_diagram.tsx

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -96,35 +96,34 @@ export function StockFlowGraphviz(props: {
9696

9797
const vizLayout = () => {
9898
const viz = vizResource();
99-
const patternAuxiliaryVariable: Pattern<ModelJudgment> = {
99+
const patternAuxiliaryVariable: P.Pattern<ModelJudgment> = {
100100
tag: "object",
101101
obType: {
102-
content: "DynamicVariable",
102+
content: "AuxiliaryVariable",
103103
tag: "Basic",
104104
}
105105
};
106-
const patternVariableLink: Pattern<ModelJudgment> = {
107-
tag: "morphism",
108-
morType: {
109-
content: "VariableLink",
110-
tag: "Basic",
111-
}
112-
};
106+
// const patternVariableLink: P.Pattern<ModelJudgment> = {
107+
// tag: "morphism",
108+
// morType: {
109+
// content: "VariableLink",
110+
// tag: "Basic",
111+
// }
112+
// };
113113
return (
114114
viz &&
115115
vizLayoutGraph(
116116
viz,
117117
modelToGraphviz(props.model, props.theory, props.attributes,
118-
(jgmt: ModelJudgment) => {
118+
(jgmt: ModelJudgment) =>
119119
match(jgmt)
120120
.with(patternAuxiliaryVariable, () => ({ xlabel: jgmt.name, label: "" }))
121121
.with(P._, () => undefined)
122-
},
123-
(jgmt: ModelJudgment) =>
124-
match(jgmt)
125-
.with(patternVariableLink, () => ({ style: "variable-link" }))
126-
.with(P._, () => undefined)
127-
122+
.run()
123+
// (jgmt: ModelJudgment) =>
124+
// match(jgmt)
125+
// .with(patternVariableLink, () => ({ style: "variable-link" }))
126+
// .with(P._, () => undefined)
128127
),
129128
props.options,
130129
)
@@ -146,8 +145,24 @@ function StockFlowSVG(props: {
146145
const result: string[] = [];
147146
const nodeMap = uniqueIndexArray(props.layout?.nodes ?? [], (node) => node.id);
148147
const edgeMap = uniqueIndexArray(props.layout?.edges ?? [], (edge) => edge.id);
149-
console.log(nodeMap, edgeMap);
150-
const patternFlowLink: Pattern<ModelJudgment> = {
148+
// const patternFlowLink: P.Pattern<ModelJudgment> = {
149+
// tag: "morphism",
150+
// dom: {
151+
// tag: "Basic",
152+
// content: P.select("srcId"),
153+
// },
154+
// cod: {
155+
// tag: "Tabulated",
156+
// content: {
157+
// tag: "Basic",
158+
// content: P.select("tgtId"),
159+
// },
160+
// },
161+
// };
162+
for (const judgment of props.model) {
163+
match(judgment)
164+
.with(
165+
{
151166
tag: "morphism",
152167
dom: {
153168
tag: "Basic",
@@ -160,10 +175,7 @@ function StockFlowSVG(props: {
160175
content: P.select("tgtId"),
161176
},
162177
},
163-
};
164-
for (const judgment of props.model) {
165-
match(judgment)
166-
.with(patternFlowLink,
178+
},
167179
({ srcId, tgtId }) => {
168180
const srcNode = nodeMap.get(srcId);
169181
const tgtEdge = edgeMap.get(tgtId);

packages/frontend/src/stdlib/svg_styles.module.css.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ declare const styles: {
22
readonly box: string;
33
readonly circle: string;
44
readonly point: string;
5+
readonly link: string;
56
};
67
export = styles;

packages/frontend/src/stdlib/theories.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -716,18 +716,18 @@ stdTheories.add(
716716
},
717717
{
718718
tag: "ObType",
719-
obType: { tag: "Basic", content: "DynamicVariable" },
719+
obType: { tag: "Basic", content: "AuxiliaryVariable" },
720720
name: "Variable",
721-
description: "Variable stuff",
722-
shortcut: ["V"],
721+
description: "A function of different stocks",
722+
shortcut: ["A"],
723723
cssClasses: [styles.point],
724724
svgClasses: [svgStyles.point],
725725
},
726726
{
727727
tag: "MorType",
728728
morType: { tag: "Basic", content: "FlowLink" },
729729
name: "Flow Link",
730-
description: "Influence of a stock on a flow",
730+
description: "Influence of an auxiliary variable on a flow",
731731
preferUnnamed: true,
732732
shortcut: ["L"],
733733
},
@@ -736,7 +736,7 @@ stdTheories.add(
736736
morType: { tag: "Basic", content: "VariableLink" },
737737
name: "Variable Link",
738738
description: "Variable controlling stock quantity",
739-
shortcut: ["F"],
739+
shortcut: ["V"],
740740
arrowStyle: "flat",
741741
cssClasses: [styles.link],
742742
svgClasses: [svgStyles.link],

packages/frontend/src/theory/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ export class Theory {
100100

101101
/** Get metadata for a morphism type as used in models. */
102102
modelMorTypeMeta(typ: MorType): ModelMorTypeMeta | undefined {
103-
console.log(this.modelTypeMeta.morTypeMeta(typ));
104103
return this.modelTypeMeta.morTypeMeta(typ);
105104
}
106105

@@ -179,7 +178,6 @@ class TypeMetadata<ObMeta extends HasObTypeMeta, MorMeta extends HasMorTypeMeta>
179178
}
180179

181180
morTypeMeta(typ: MorType): MorMeta | undefined {
182-
console.log("META: ", this.morTypeIndex.get(typ), this.types);
183181
const i = this.morTypeIndex.get(typ);
184182
return i !== undefined ? (this.types[i] as MorMeta) : undefined;
185183
}

0 commit comments

Comments
 (0)