#945 Some more cleanup focusing on stateDb

This commit is contained in:
Knut Sveidqvist 2019-10-05 10:02:58 +02:00
parent d4306e61c2
commit cfc14ade2a
4 changed files with 5 additions and 38 deletions

View File

@ -126,7 +126,6 @@ statement
| COMPOSIT_STATE STRUCT_START document STRUCT_STOP
{
console.warn('Adding document for state without id ', $1);
// yy.addDocument('noId');
$$={ stmt: 'state', id: $1, type: 'default', description: '', doc: $3 }
}
| STATE_DESCR AS ID { $$={id: $3, type: 'default', description: $1.trim()};}

View File

@ -1,6 +1,7 @@
import * as d3 from 'd3';
import idCache from './id-cache.js';
import stateDb from './stateDb';
import utils from '../../utils';
console.warn('ID cache', idCache);

View File

@ -11,16 +11,10 @@ const getRootDoc = () => rootDoc;
const extract = doc => {
const res = { states: [], relations: [] };
clear();
doc.forEach(item => {
if (item.stmt === 'state') {
// if (item.doc) {
// addState(item.id, 'composit');
// addDocument(item.id);
// extract(item.doc);
// currentDocument = currentDocument.parent;
// } else {
addState(item.id, item.type, item.doc);
// }
}
if (item.stmt === 'relation') {
addRelation(item.state1.id, item.state2.id, item.description);
@ -81,12 +75,7 @@ export const clear = function() {
export const getState = function(id) {
return currentDocument.states[id];
};
export const addDocument = id => {
console.warn(currentDocument, documents);
currentDocument.documents[id] = newDoc();
currentDocument.documents[id].parent = currentDocument;
currentDocument = currentDocument.documents[id];
};
export const getStates = function() {
return currentDocument.states;
};
@ -94,8 +83,6 @@ export const logDocuments = function() {
console.warn('Documents = ', documents);
};
export const getRelations = function() {
// const relations1 = [{ id1: 'start1', id2: 'state1' }, { id1: 'state1', id2: 'exit1' }];
// return relations;
return currentDocument.relations;
};
@ -162,7 +149,6 @@ export default {
lineType,
relationType,
logDocuments,
addDocument,
getRootDoc,
setRootDoc,
extract

View File

@ -61,7 +61,6 @@ const insertMarkers = function(elem) {
export const draw = function(text, id) {
parser.yy.clear();
parser.parse(text);
stateDb.logDocuments();
logger.info('Rendering diagram ' + text);
// /// / Fetch the default direction, use TD if none was found
@ -124,7 +123,7 @@ const renderDoc = (doc, diagram, parentId) => {
});
}
// // Default to assigning a new object as a label for each new edge.
// Default to assigning a new object as a label for each new edge.
graph.setDefaultEdgeLabel(function() {
return {};
});
@ -146,15 +145,13 @@ const renderDoc = (doc, diagram, parentId) => {
.append('g')
.attr('id', stateDef.id)
.attr('class', 'classGroup');
node = renderDoc2(stateDef.doc, sub, stateDef.id);
node = renderDoc(stateDef.doc, sub, stateDef.id);
sub = addIdAndBox(sub, stateDef);
let boxBounds = sub.node().getBBox();
node.width = boxBounds.width;
node.height = boxBounds.height + 10;
transformationLog[stateDef.id] = { y: 35 };
// node.x = boxBounds.y;
// node.y = boxBounds.x;
} else {
node = drawState(diagram, stateDef, graph);
}
@ -163,21 +160,6 @@ const renderDoc = (doc, diagram, parentId) => {
// metadata about the node. In this case we're going to add labels to each of
// our nodes.
graph.setNode(node.id, node);
// if (parentId) {
// console.warn('apa1 P>', node.id, parentId);
// // graph.setParent(node.id, parentId);
// }
// graph.setNode(node.id + 'note', nodeAppendix);
// let parent = 'p1';
// if (node.id === 'XState1') {
// parent = 'p2';
// }
// graph.setParent(node.id, parent);
// graph.setParent(node.id + 'note', parent);
// logger.info('Org height: ' + node.height);
}
console.info('Count=', graph.nodeCount());
@ -192,7 +174,6 @@ const renderDoc = (doc, diagram, parentId) => {
console.warn(getGraphId(relation.id1), relation.id2, {
relation: relation
});
// graph.setEdge(getGraphId(relation.id1), getGraphId(relation.id2));
});
dagre.layout(graph);