public static List<IGraphicItem> GeneratedGraphicItems(this NodeModel node, EngineController engineController) { var ids = node.GetAllOutportAstIdentifiers(); var results = new List<IGraphicItem>(); foreach (var id in ids) { var mirror = engineController.GetMirror(id); if (mirror == null) continue; var mirrorData = mirror.GetData(); if (mirrorData == null) continue; GetGraphicItemsFromMirrorData(mirrorData, results); } return results; }
/// <summary> /// Gets the most recent value of this node stored in an EngineController that has evaluated it. /// </summary> /// <param name="outPortIndex"></param> /// <param name="engine"></param> /// <returns></returns> public MirrorData GetValue(int outPortIndex, EngineController engine) { return engine.GetMirror(GetAstIdentifierForOutputIndex(outPortIndex).Value).GetData(); }
/// <summary> /// WARNING: This method is meant for unit test only. It directly accesses /// the EngineController for the mirror data without waiting for any /// possible execution to complete (which, in single-threaded nature of /// unit test, is an okay thing to do). The right way to get the cached /// value for a NodeModel is by going through its RequestValueUpdateAsync /// method). /// </summary> /// <param name="engine">Instance of EngineController from which the node /// value is to be retrieved.</param> /// <returns>Returns the MirrorData if the node's value is computed, or /// null otherwise.</returns> /// internal MirrorData GetCachedValueFromEngine(EngineController engine) { if (cachedMirrorData != null) return cachedMirrorData; // Do not have an identifier for preview right now. For an example, // this can be happening at the beginning of a code block node creation. if (AstIdentifierForPreview.Value == null) return null; cachedMirrorData = null; var runtimeMirror = engine.GetMirror(AstIdentifierForPreview.Value); if (runtimeMirror != null) cachedMirrorData = runtimeMirror.GetData(); return cachedMirrorData; }
public ColorRange1D ComputeColorRange(EngineController engine) { List<Color> colors; List<double> parameters; // If there are colors supplied if (InPorts[0].Connectors.Any()) { var colorsNode = InPorts[0].Connectors[0].Start.Owner; var colorsIndex = InPorts[0].Connectors[0].Start.Index; var startId = colorsNode.GetAstIdentifierForOutputIndex(colorsIndex).Name; var colorsMirror = engine.GetMirror(startId); colors = GetColorsFromMirrorData(colorsMirror); } else { colors = DefaultColorRanges.Analysis; } // If there are indices supplied if (InPorts[1].Connectors.Any()) { var valuesNode = InPorts[1].Connectors[0].Start.Owner; var valuesIndex = InPorts[1].Connectors[0].Start.Index; var endId = valuesNode.GetAstIdentifierForOutputIndex(valuesIndex).Name; var valuesMirror = engine.GetMirror(endId); parameters = GetValuesFromMirrorData(valuesMirror); } else { parameters = CreateParametersForColors(colors); } return ColorRange1D.ByColorsAndParameters(colors, parameters); }