/// <summary> /// return TRUE if the positioning was accomplished but with collision /// </summary> /// <param name="arc"></param> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> private bool positionSourceOverDest(Ark arc, ref int x, ref int y) { throw new Exception("Not Yet Implemented"); }
protected override bool addIOArk(List<Parameter> io, int index, Ark a) { List<DXType> newTypesList = null; if (IsInput) { int i; Node dest = a.getDestinationNode(out i); Parameter pin = dest.getInputParameter(i); ParameterDefinition pind = pin.Definition; ParameterDefinition macroPd = getParameterDefinition(); List<DXType> outTypes = macroPd.getTypes(); newTypesList = DXType.IntersectTypeLists(outTypes, pind.getTypes()); foreach (DXType t in outTypes.ToArray()) { macroPd.removeType(t); } Parameter pout = getOutputParameter(1); ParameterDefinition nodePd = pout.Definition; outTypes = nodePd.getTypes(); foreach (DXType t in outTypes.ToArray()) { nodePd.removeType(t); } foreach (DXType t in newTypesList.ToArray()) { DXType newt = t.duplicate(); nodePd.addType(newt); macroPd.addType(t); } setTypeSafeOptions(a); } else { int i; Node dest = a.getSourceNode(out i); Parameter pin = dest.getOutputParameter(i); ParameterDefinition pind = pin.Definition; ParameterDefinition macroPd = getParameterDefinition(); List<DXType> outTypes = macroPd.getTypes(); newTypesList = DXType.IntersectTypeLists(outTypes, pind.getTypes()); foreach (DXType t in outTypes.ToArray()) { macroPd.removeType(t); } Parameter pout = getInputParameter(1); ParameterDefinition nodePd = pout.Definition; outTypes = nodePd.getTypes(); foreach (DXType t in outTypes.ToArray()) { nodePd.removeType(t); } foreach (DXType t in newTypesList.ToArray()) { DXType newt = t.duplicate(); nodePd.addType(newt); macroPd.addType(t); } } if (getConfigurationDialog() != null) { getConfigurationDialog().changeInput(1); getConfigurationDialog().changeOutput(1); } return base.addIOArk(io, index, a); }
/// <summary> /// return TRUE if the positioning was accomplished but with collision /// </summary> /// <param name="arc"></param> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> private bool positionDestUnderSource(Ark arc, ref int x, ref int y) { throw new Exception("Not Yet Implemented"); }
/// <summary> /// return TRUE if the positioning was accomplished but with collision /// </summary> /// <param name="arc"></param> /// <param name="x"></param> /// <returns></returns> private bool positionSource(Ark arc, int x) { throw new Exception("Not Yet Implemented"); }
public bool removeArk(Ark a) { return arcs.Remove(a); }
/// <summary> /// return TRUE if the positioning was accomplished but with collision /// </summary> /// <param name="arc"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="prefer_left"></param> /// <param name="ususableNodes"></param> /// <returns></returns> private bool positionDestBesideSibling(Ark arc, ref int x, ref int y, bool prefer_left, List<Node> ususableNodes) { throw new Exception("Not Yet Implemented"); }
public virtual bool deleteArk(Ark a) { throw new Exception("Not Yet Implemented"); }
public void addArk(EditorWindow editor, Ark a) { throw new Exception("Not Yet Implemented"); }
protected virtual bool removeIOArk(List<Parameter> io, int index, Ark a) { throw new Exception("Not Yet Implemented"); }
protected bool removeOutputArk(int index, Ark a) { return removeIOArk(outputParameters, index, a); }
public bool addOutputArk(Ark a, int index) { return addIOArk(outputParameters, index, a); }
/// <summary> /// Add an Ark to the index'th parameter of parameter list 'io'. /// </summary> /// <param name="io"></param> /// <param name="index"></param> /// <param name="a"></param> /// <returns></returns> protected virtual bool addIOArk(List<Parameter> io, int index, Ark a) { Parameter p; Debug.Assert(index >= 1); p = io[index - 1]; Debug.Assert(p != null); if (!p.addArk(a)) return false; notifyIoParameterStatusChanged(io == inputParameters, index, NodeParameterStatusChange.ParameterArkAdded); return true; }
public virtual void updateDefinition() { int numInputs = InputCount; bool[] defaulting = new bool[numInputs]; bool[] visibilities = new bool[numInputs]; String[] values = new String[numInputs]; List<ArkInfo>[] inputArks = new List<ArkInfo>[numInputs]; for (int i = 1; i <= numInputs; i++) { inputArks[i - 1] = null; values[i - 1] = null; defaulting[i - 1] = false; visibilities[i - 1] = isInputVisible(i); if (isInputConnected(i)) { List<Ark> arcs = getInputArks(i); inputArks[i - 1] = new List<ArkInfo>(); foreach (Ark a in arcs) { ArkInfo ai = new ArkInfo(); ai.src = a.getSourceNode(out ai.srcIndex); ai.dst = a.getDestinationNode(out ai.dstIndex); inputArks[i - 1].Add(ai); } } else if (!(defaulting[i - 1] = isInputDefaulting(i))) values[i - 1] = getInputValueString(i); } inputParameters.Clear(); int numOutputs = OutputCount; List<ArkInfo>[] outputArks = new List<ArkInfo>[numOutputs]; for (int i = 1; i <= numOutputs; i++) { outputArks[i - 1] = null; if (isOutputConnected(i)) { List<Ark> arcs = getOutputArks(i); outputArks[i - 1] = new List<ArkInfo>(); foreach (Ark a in arcs) { ArkInfo ai = new ArkInfo(); ai.src = a.getSourceNode(out ai.srcIndex); ai.dst = a.getDestinationNode(out ai.dstIndex); outputArks[i - 1].Add(ai); } } } outputParameters.Clear(); buildParameterLists(); for (int i = 1; i <= numInputs && i <= InputCount; i++) { setInputVisibility(i, visibilities[i - 1]); if (inputArks[i - 1] != null) { foreach (ArkInfo ai in inputArks[i - 1]) { if (ai.src.typeMatchOutputToInput(ai.srcIndex, ai.dst, ai.dstIndex)) { Ark newArk = new Ark(ai.src, ai.srcIndex, ai.dst, ai.dstIndex); if (ai.src.getNetwork().getEditor() != null && ai.src.getStandIn() != null) ai.src.getStandIn().addArk(ai.src.getNetwork().getEditor(), newArk); } } inputArks[i - 1] = null; } else if (defaulting[i - 1]) useDefaultInputValue(i); else setInputValue(i, values[i - 1]); } // must increase j by the number of repeats added in buildParameterLists() int repeats = InputCount - definition.InputCount; int mini = Math.Min(numInputs, InputCount); int j = numInputs + repeats; for (; j >= mini; j--) { if (cdb != null) cdb.deleteInput(j); if (standin != null) standin.removeLastInput(); } for (; mini <= InputCount; mini++) { if (cdb != null) cdb.newInput(mini); if (standin != null) standin.addInput(mini); } for (int i = 1; i <= numOutputs && i <= OutputCount; i++) { if (outputArks[i - 1] != null) { foreach (ArkInfo ai in outputArks[i - 1]) { if (ai.src.typeMatchOutputToInput(ai.srcIndex, ai.dst, ai.dstIndex)) { Ark newArk = new Ark(ai.src, ai.srcIndex, ai.dst, ai.dstIndex); if (ai.src.getNetwork().getEditor() != null && ai.src.getStandIn() != null) { ai.src.getStandIn().addArk(ai.src.getNetwork().getEditor(), newArk); } } outputArks[i - 1] = null; } } notifyIoParameterStatusChanged(false, i, NodeParameterStatusChange.ParameterValueChanged); } j = numOutputs; mini = Math.Min(numOutputs, OutputCount); for (; j >= mini; j--) { if (cdb != null) cdb.deleteOutput(j); if (standin != null) standin.removeLastOutput(); } for (; mini <= OutputCount; mini++) { if (cdb != null) cdb.newOutput(mini); if (standin != null) standin.addOutput(mini); } EditorWindow e = getNetwork().getEditor(); if (e != null) e.notifyDefinitionChange(this); }
protected override bool removeIOArk(List<Parameter> io, int index, Ark a) { throw new Exception("Not Yet Implemented"); return base.removeIOArk(io, index, a); }
public bool addArk(Ark a) { arcs.Add(a); // If this is the first arc and this is an output parameter, // be sure it gets sent on the next execution (assuming someone // asks this parameter if it needs to be sent). if (arcs.Count == 1 && !IsInput) setDirty(); return true; }
/// <summary> /// Based on the node's connectivity, select values for OPTIONS /// automatically. The strategy is /// - Try to keep the OPTIONS the node already has. /// - look for OPTIONS in the next connected downstream node(s) /// - for each value in OPTIONS, see if the value can be coerced /// to our current type(s) /// - Prefer to use OPTIONS from the node at the other end of /// prefer because it's probably the node were adding via ::addIOArk(). /// /// At this point in the code, our new list of types has already been /// computed based on our new connectivity. /// </summary> /// <param name="pref"></param> private void setTypeSafeOptions(Ark pref) { // This method is nonsense in the case of an Output tool. Debug.Assert(IsInput); // If we have OPTIONS && any item in OPTION is illegal input given // our new type, then remove all the OPTIONS. ParameterDefinition macroPd = getParameterDefinition(); String[] options = macroPd.getValueOptions(); List<DXType> types = macroPd.getTypes(); bool can_coerce = true; if (options != null && options.Length > 0) { can_coerce = true; for (int i = 0; i < options.Length && can_coerce; i++) { can_coerce = can_coerce && canCoerceValue(options[i], types); } if (!can_coerce) { macroPd.removeValueOptions(); options = null; } } //If our current OPTIONS are safe to keep using... if (options != null && options.Length > 0) return; // If the parameter has no option values, then check each downstream // input tab. If any has option values, then try to use those but // only if each of the option values is legal given our new type. Node destination; NodeDefinition destinationDef; ParameterDefinition destinationParamDef; int paramIndex; // First check the new ark to see if it gave give us // option values. option strings are stored as a null-terminated // array of char*. String[] dest_option_values = null; can_coerce = true; if (pref != null) { destination = pref.getDestinationNode(out paramIndex); destinationDef = destination.Definition; destinationParamDef = destinationDef.getInputDefinition(paramIndex); dest_option_values = destinationParamDef.getValueOptions(); if (dest_option_values != null && dest_option_values.Length > 0) { for (int i = 0; i < dest_option_values.Length && can_coerce; i++) { can_coerce = can_coerce && canCoerceValue(dest_option_values[i], types); } } } if (can_coerce && dest_option_values != null && dest_option_values.Length > 0) { for (int i = 0; i < dest_option_values.Length; i++) { if (!macroPd.addValueOption(dest_option_values[i])) { ErrorDialog ed = new ErrorDialog(); ed.post("Cannot add {0} to Options values", dest_option_values[i]); break; } } } else { // get all the destination nodes When we're called as via ::addIOArk(), // the new connection has not yet been added to our list // of downstream nodes. List<Ark> arks = getOutputArks(1); foreach (Ark ark in arks) { destination = ark.getDestinationNode(out paramIndex); destinationDef = destination.Definition; destinationParamDef = destinationDef.getInputDefinition(paramIndex); // for each option value see, see if it can be coerced. dest_option_values = destinationParamDef.getValueOptions(); if (dest_option_values == null || dest_option_values.Length == 0) continue; can_coerce = true; for (int i = 0; i < dest_option_values.Length && can_coerce; i++) { can_coerce = can_coerce && canCoerceValue(dest_option_values[i], types); } if (can_coerce) { for (int i = 0; i < dest_option_values.Length; i++) { if (!macroPd.addValueOption(dest_option_values[i])) { ErrorDialog ed = new ErrorDialog(); ed.post("Cannot add {0} to Options values", dest_option_values[i]); break; } } break; } } } }
public void deleteArk(Ark a) { throw new Exception("Not Yet Implemented"); }