public static ResponseJson.LayerData getLayerJsonData( ModelClassNS.ModelClass modelStruct, string layerId ) { Layers.Layer layer = modelStruct.layerDict.layers[layerId]; var ports = new Dictionary <string, ResponseJson.LayerPortData>(); var fields = new Dictionary <string, ResponseJson.LayerFieldData>(); foreach (string portName in layer.getPortNames()) { ports[portName] = new ResponseJson.LayerPortData { valueName = layer.getValueNameOfPort(portName), }; } List <string> occupiedValueNames = modelStruct.edgesByVertex[layerId].edgesIn.Select((string edgeId) => { return(modelStruct.layerDict.layers[layerId].getValueNameOfPort(modelStruct.graph.edges[edgeId].targetPortId)); }).ToList(); foreach (string fieldName in layer.getValueNames()) { bool fieldOccupiedByEdge = occupiedValueNames.Contains(fieldName); fields[fieldName] = new ResponseJson.LayerFieldData { value = layer.getValueString(fieldName), fieldIsReadonly = fieldOccupiedByEdge || layer.getValueIsReadonly(fieldName) }; } return(new ResponseJson.LayerData { ports = ports, fields = fields, }); }
public static List <string> getUniqueEdgeIds( ModelClassNS.ModelClass modelContainer, int count ) { return(GraphUtilsNS.GraphUtils.getUniqueEdgeIds(modelContainer.graph, count)); }
public static void dispatch( ModelClassNS.ModelClass modelStruct, JObject jobj ) { string newEdgeId = jobj["newEdgeId"].ToString(); string sourceVertexId = jobj["sourceVertexId"].ToString(); string sourcePortId = jobj["sourcePortId"].ToString(); string targetVertexId = jobj["targetVertexId"].ToString(); string targetPortId = jobj["targetPortId"].ToString(); string validatedEdge = ModelUtilsNS.ModelUtils.validateEdge( modelStruct, newEdgeId, sourceVertexId, sourcePortId, targetVertexId, targetPortId ); if (validatedEdge == null) { ModelUtilsNS.ModelUtils.createEdge( modelStruct, newEdgeId, sourceVertexId, sourcePortId, targetVertexId, targetPortId ); } }
private static List <string> topoSortVertices(ModelClassNS.ModelClass modelStruct) { List <string> topToBottom = new List <string>(); HashSet <string> remainingVertexIds = new HashSet <string>(modelStruct.graph.vertices.Keys); while (remainingVertexIds.Count != 0) { List <string> roots = remainingVertexIds.Where((string vtxId) => { foreach (string edgeId in modelStruct.edgesByVertex[vtxId].edgesIn) { NetworkContainersNS.Edge edge = modelStruct.graph.edges[edgeId]; if (remainingVertexIds.Contains(edge.sourceVertexId)) { return(false); } } return(true); }).ToList(); foreach (string rootId in roots) { topToBottom.Add(rootId); remainingVertexIds.Remove(rootId); } } return(topToBottom); }
public static bool isLayerFieldParameter( ModelClassNS.ModelClass modelContainer, string layerId, string valueId ) { return(!LayerUtilsNS.LayerUtils.isValueReadonly(modelContainer.layerDict, layerId, valueId)); }
public void unsafeOpen(string fileName) { this.currentModelContainer = this.placeholderFS.loadModel(fileName); this.prevModelContainers.Clear(); this.futureModelContainers.Clear(); this.currentFileName = fileName; this.savePosition = 0; }
public static void moveVertex( ModelClassNS.ModelClass modelStruct, string vertexId, float x, float y ) { GraphUtilsNS.GraphUtils.moveVertex(modelStruct.graph, vertexId, x, y); }
public static void dispatch( ModelClassNS.ModelClass modelStruct, JObject jobj ) { string edgeId = jobj["edgeId"].ToString(); ModelUtilsNS.ModelUtils.deleteEdge(modelStruct, edgeId); }
public static void addLayer( VersionedModelClassNS.VersionedModelClass versionedModel, string layerId, string layerType, float x, float y ) { ModelClassNS.ModelClass modelClass = versionedModel.getCurrent(); Layers.Layer layer = Layers.Layer.getNewLayerByType(layerType); NetworkContainersNS.Vertex newVertex = new NetworkContainersNS.Vertex { label = layerType + " Layer", xLocation = x, yLocation = y, ports = new Dictionary <string, NetworkContainersNS.NetworkPort>() }; List <string> inputPortNames = new List <string>(); List <string> outputPortNames = new List <string>(); foreach (string portName in layer.getPortNames()) { if (layer.getValueIsReadonly(layer.getValueNameOfPort(portName))) { outputPortNames.Add(portName); } else { inputPortNames.Add(portName); } } for (int i = 0; i < inputPortNames.Count; i++) { // System.Console.Error.WriteLine(((float)(i + 1)) / ((float)(inputPortNames.Count + 1))); newVertex.ports[inputPortNames[i]] = new NetworkContainersNS.NetworkPort { side = NetworkContainersNS.SideType.Top, position = ((float)(i + 1)) / ((float)(inputPortNames.Count + 1)), type = NetworkContainersNS.PortType.Input, }; } for (int i = 0; i < outputPortNames.Count; i++) { newVertex.ports[outputPortNames[i]] = new NetworkContainersNS.NetworkPort { side = NetworkContainersNS.SideType.Bottom, position = ((float)(i + 1)) / ((float)(outputPortNames.Count + 1)), type = NetworkContainersNS.PortType.Output, }; } modelClass.graph.vertices[layerId] = newVertex; modelClass.layerDict.layers[layerId] = layer; modelClass.edgesByVertex[layerId] = new ModelClassNS.VertexEdgesInfo(); }
public static void dispatch( ModelClassNS.ModelClass modelStruct, JObject jobj ) { string vertexId = jobj["vertexId"].ToString(); ModelUtilsNS.ModelUtils.deleteVertex(modelStruct, vertexId); }
public static void deleteEdge( ModelClassNS.ModelClass modelStruct, string edgeId ) { GraphUtilsNS.GraphUtils.deleteEdge( modelStruct.graph, modelStruct.edgesByVertex, edgeId ); }
public static List <string> getEdgesBetweenVertices( ModelClassNS.ModelClass modelContainer, List <string> vertexIds ) { return(GraphUtilsNS.GraphUtils.getEdgesBetweenVertices( modelContainer.graph, modelContainer.edgesByVertex, vertexIds )); }
public static Layers.LayersValidated validateLayerFields( ModelClassNS.ModelClass modelContainer, string layerId, Dictionary <string, string> fieldValues ) { return(LayerUtilsNS.LayerUtils.validateLayerFields( modelContainer.layerDict, layerId, fieldValues )); }
public static void setLayerFields( ModelClassNS.ModelClass modelContainer, string layerId, Dictionary <string, string> fieldValues ) { LayerUtilsNS.LayerUtils.setLayerFields( modelContainer.layerDict, layerId, fieldValues ); }
public static void propagateModel(ModelClassNS.ModelClass modelStruct) { List <string> topoSortedVertices = ModelUtils.topoSortVertices(modelStruct); foreach (string vertexId in topoSortedVertices) { foreach (string edgeOutId in modelStruct.edgesByVertex[vertexId].edgesOut) { ModelUtils.propagateEdge(modelStruct, edgeOutId); } } }
public static void dispatch( ModelClassNS.ModelClass modelStruct, JObject jobj ) { string newVertexId = jobj["newVertexId"].ToString(); string sourceVertexId = jobj["sourceVertexId"].ToString(); float x = float.Parse(jobj["x"].ToString()); float y = float.Parse(jobj["y"].ToString()); ModelUtilsNS.ModelUtils.cloneVertex(modelStruct, sourceVertexId, newVertexId, x, y); }
public void tryRedo() { if (this.futureModelContainers.Count != 0) { this.prevModelContainers.Add(this.currentModelContainer); this.currentModelContainer = this.futureModelContainers[0]; this.futureModelContainers.RemoveAt(0); if (this.savePosition.HasValue) { this.savePosition--; } } }
public void tryUndo() { if (this.prevModelContainers.Count != 0) { this.futureModelContainers.Insert(0, this.currentModelContainer); this.currentModelContainer = this.prevModelContainers[this.prevModelContainers.Count - 1]; this.prevModelContainers.RemoveAt(this.prevModelContainers.Count - 1); if (this.savePosition.HasValue) { this.savePosition++; } } }
public static bool compareFieldValue( ModelClassNS.ModelClass modelContainer, string layerId, string valueId, string valueToValidate ) { return(LayerUtilsNS.LayerUtils.compareFieldValue( modelContainer.layerDict, layerId, valueId, valueToValidate )); }
public static void deleteVertex( ModelClassNS.ModelClass modelStruct, string vertexId ) { GraphUtilsNS.GraphUtils.deleteVertex( modelStruct.graph, modelStruct.edgesByVertex, vertexId ); LayerUtilsNS.LayerUtils.deleteLayer( modelStruct.layerDict, vertexId ); }
public static void dispatch( ModelClassNS.ModelClass modelStruct, JObject jobj ) { string vertexId = jobj["vertexId"].ToString(); float x = float.Parse(jobj["x"].ToString()); float y = float.Parse(jobj["y"].ToString()); ModelUtilsNS.ModelUtils.moveVertex( modelStruct, vertexId, x, y ); }
public static ModelChangeReqResponseNS.ModelChangeReqResponse dispatch( ModelClassNS.ModelClass modelStruct, JObject jobj ) { var reqArray = jobj["reqs"] as JArray; foreach (var changeReq in reqArray.Children()) { ModelChangeRequests.Dispatcher.dispatch(modelStruct, changeReq as JObject); } ModelUtilsNS.ModelUtils.propagateModel(modelStruct); return(new ModelChangeReqResponseNS.ModelChangeReqResponse()); }
public static void createEdge( ModelClassNS.ModelClass modelStruct, string newEdgeId, string sourceVertexId, string sourcePortId, string targetVertexId, string targetPortId ) { GraphUtilsNS.GraphUtils.createEdge( modelStruct.graph, modelStruct.edgesByVertex, newEdgeId, sourceVertexId, sourcePortId, targetVertexId, targetPortId ); }
public static string validateEdge( ModelClassNS.ModelClass modelStruct, string newEdgeId, string sourceVertexId, string sourcePortId, string targetVertexId, string targetPortId ) { return(GraphUtilsNS.GraphUtils.validateEdge( modelStruct.graph, modelStruct.edgesByVertex, newEdgeId, sourceVertexId, sourcePortId, targetVertexId, targetPortId )); }
public static void dispatch( ModelClassNS.ModelClass modelStruct, JObject jobj ) { Dictionary <string, string> fieldValues = new Dictionary <string, string>(); foreach (var fieldEntry in (jobj["fieldValues"] as JObject).Properties()) { fieldValues[fieldEntry.Name] = fieldEntry.Value.ToString(); } string layerId = jobj["layerId"].ToString(); ModelUtilsNS.ModelUtils.setLayerFields( modelStruct, layerId, fieldValues ); }
public static bool isLayerValueOccupied( ModelClassNS.ModelClass modelContainer, string layerId, string valueId ) { List <string> edgesIn = modelContainer.edgesByVertex[layerId].edgesIn; foreach (string edgeId in edgesIn) { string edgePortId = modelContainer.graph.edges[edgeId].targetPortId; string edgeValueId = modelContainer.layerDict.layers[layerId].getValueNameOfPort(valueId); if (valueId == edgeValueId) { return(true); } } return(false); }
private static void propagateEdge(ModelClassNS.ModelClass modelStruct, string edgeId) { NetworkContainersNS.Edge edge = modelStruct.graph.edges[edgeId]; Layers.Layer sourceLayer = modelStruct.layerDict.layers[edge.sourceVertexId]; Layers.Layer targetLayer = modelStruct.layerDict.layers[edge.targetVertexId]; string sourceFieldName = sourceLayer.getValueNameOfPort(edge.sourcePortId); string targetFieldName = targetLayer.getValueNameOfPort(edge.targetPortId); bool edgeIsConsistent = targetLayer.compareFieldValue(targetFieldName, sourceLayer.getValueString(sourceFieldName)); if (edgeIsConsistent) { edge.consistency = NetworkContainersNS.ConsistencyType.Consistent; return; } string validateFieldValue = targetLayer.validateFieldString(targetFieldName, sourceLayer.getValueString(sourceFieldName)); if (validateFieldValue != null) { edge.consistency = NetworkContainersNS.ConsistencyType.Inconsistent; return; } Layers.LayersValidated validatedUpdate = targetLayer.validateSetFields(new Dictionary <string, string>() { { targetFieldName, sourceLayer.getValueString(sourceFieldName) }, }); if (validatedUpdate.errors.Count != 0) { edge.consistency = NetworkContainersNS.ConsistencyType.Inconsistent; return; } targetLayer.setFields(new Dictionary <string, string>() { { targetFieldName, sourceLayer.getValueString(sourceFieldName) }, }); edge.consistency = NetworkContainersNS.ConsistencyType.Consistent; }
public static void cloneVertex( ModelClassNS.ModelClass modelStruct, string sourceVertexId, string newVertexId, float x, float y ) { GraphUtilsNS.GraphUtils.cloneVertex( modelStruct.graph, modelStruct.edgesByVertex, sourceVertexId, newVertexId, x, y ); LayerUtilsNS.LayerUtils.cloneLayer( modelStruct.layerDict, sourceVertexId, newVertexId ); }
public static void dispatch( ModelClassNS.ModelClass modelStruct, JObject jobj ) { string type = jobj["type"].ToString(); if (type == "moveVertex") { MoveVertexReq.dispatch(modelStruct, jobj); } else if (type == "cloneVertex") { CloneVertexReq.dispatch(modelStruct, jobj); } else if (type == "createEdge") { CreateEdgeReq.dispatch(modelStruct, jobj); } else if (type == "deleteVertex") { DeleteVertexReq.dispatch(modelStruct, jobj); } else if (type == "deleteEdge") { DeleteEdgeReq.dispatch(modelStruct, jobj); } else if (type == "setLayerFields") { SetLayerFieldsReq.dispatch(modelStruct, jobj); } else { throw new InvalidInfoReqType(type); } }
public VersionedModelClass(ModelClassNS.ModelClass modelClass) { this.currentModelContainer = modelClass; }