Skip to content

Commit

Permalink
#36 frontend model interpreter refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ddelpiano committed Oct 6, 2022
1 parent 80f8911 commit feb3dd0
Show file tree
Hide file tree
Showing 10 changed files with 3,087 additions and 185 deletions.
23 changes: 10 additions & 13 deletions src/components/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Composition from './views/compositions/Composition';
import GenericMechanism from './views/mechanisms/GenericMechanism';
import MetaDiagram, { ComponentsMap } from "@metacell/meta-diagram";
import CustomLinkWidget from './views/projections/CustomLinkWidget';

const mockModel = require('../resources/model').mockModel;

const styles = () => ({
Expand All @@ -26,24 +25,22 @@ class Main extends React.Component {
constructor (props) {
super(props);
this.state = {};
this.interpreter = new ModelInterpreter(mockModel);
this.model = this.interpreter.getModel();
this.metaModel = this.interpreter.getMetaModel();
this.componentsMap = new ComponentsMap(new Map(), new Map());

this.componentsMap.nodes.set(PNLClasses.COMPOSITION, Composition);
this.componentsMap.nodes.set(PNLClasses.MECHANISM, GenericMechanism);
this.componentsMap.links.set(PNLClasses.PROJECTION, CustomLinkWidget);
}

render() {
const { classes } = this.props;
const interpreter = new ModelInterpreter(mockModel);
const model = interpreter.getModel();
const metaModel = buildModel(model);
console.log(interpreter.getModelElementsMap())

const componentsMap = new ComponentsMap(new Map(), new Map());

componentsMap.nodes.set(PNLClasses.COMPOSITION, Composition);
componentsMap.nodes.set(PNLClasses.MECHANISM, GenericMechanism);
componentsMap.links.set(PNLClasses.PROJECTION, CustomLinkWidget);

return (
<div className={classes.root}>
<MetaDiagram metaNodes={[...metaModel[PNLClasses.COMPOSITION], ...metaModel[PNLClasses.MECHANISM],]} metaLinks={metaModel[PNLClasses.PROJECTION]} componentsMap={componentsMap}
<MetaDiagram metaNodes={[...this.metaModel[PNLClasses.COMPOSITION], ...this.metaModel[PNLClasses.MECHANISM]]} metaLinks={this.metaModel[PNLClasses.PROJECTION]} componentsMap={this.componentsMap}
metaTheme={{
customThemeVariables: {},
canvasClassName: classes.canvasBG,
Expand All @@ -55,4 +52,4 @@ class Main extends React.Component {
}


export default withStyles(styles)(Main);
export default withStyles(styles)(Main);
3 changes: 2 additions & 1 deletion src/components/views/mechanisms/MechSimple.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class MechSimple extends React.Component {
</PortWidget>
);
default:
console.log('different port found' + port.getName() + ' ' + port.getType());
// TODO: what to do with other ports?
// console.log('different port found' + port.getName() + ' ' + port.getType());
}
})}
</Box>
Expand Down
Loading

0 comments on commit feb3dd0

Please sign in to comment.