static void Main(string[] args) { var variables = new VariableSet() { new Variable<int>("port", _("Port number"), 8080) }; GimpMain<WebServer>(args, variables); }
static void Main(string[] args) { var variables = new VariableSet() { new Variable<string>("test_dll", _("Test dll to load"), "gimptest.dll") }; GimpMain<UnitTest>(args, variables); }
static void Main(string[] args) { var variables = new VariableSet() { new Variable<int>("type", _("Stroke or dots type"), 0) }; GimpMain<Mezzotint>(args, variables); }
public Dialog(Drawable drawable, VariableSet variables = null) : base("CountTool", variables) { var hbox = new HBox(false, 12) {BorderWidth = 12}; VBox.PackStart(hbox, true, true, 0); var preview = new Preview(drawable, _coordinates); hbox.PackStart(preview, true, true, 0); var sw = new ScrolledWindow(); hbox.Add(sw); var store = new TreeStore(typeof(Coordinate<int>)); for (int i = 0; i < 10; i++) { var coordinate = new Coordinate<int>(10 * i, 10 * i); _coordinates.Add(coordinate); store.AppendValues(coordinate); } var view = new TreeView(store); sw.Add(view); var textRenderer = new CellRendererText(); view.AppendColumn("X", textRenderer, new TreeCellDataFunc(RenderX)); view.AppendColumn("Y", textRenderer, new TreeCellDataFunc(RenderY)); }
public Dialog(Drawable drawable, VariableSet variables) : base("QR", drawable, variables, () => new AspectPreview(drawable)) { var table = new GimpTable(4, 2) { ColumnSpacing = 6, RowSpacing = 6 }; var text = CreateText(); table.Attach(text, 0, 2, 0, 2); var encoding = CreateOutputEncoding(); table.Attach(encoding, 0, 1, 2, 3); var errorCorrection = CreateErrorCorrection(); table.Attach(errorCorrection, 1, 2, 2, 3); CreateMargin(table); Vbox.PackStart(table, false, false, 0); InvalidatePreview(); }
public override SolutionBuilder.BuildResult ProcessBuildResult (VariableSet variables, Configuration configuration, SolutionBuilder.BuildResult buildResult) { CopiedOutputGatherer.GatherFromProjectFiles( variables, configuration, buildResult ); return base.ProcessBuildResult(variables, configuration, buildResult); }
/// <summary> /// Gets matrix pointers /// </summary> /// <param name="variables">Nodes</param> /// <param name="solver">Solver</param> public void GetEquationPointers(VariableSet variables, Solver <double> solver) { solver.ThrowIfNull(nameof(solver)); ControlBranchEq = VoltageLoad.BranchEq; PosControlBranchPtr = solver.GetMatrixElement(PosNode, ControlBranchEq); NegControlBranchPtr = solver.GetMatrixElement(NegNode, ControlBranchEq); }
/// <summary> /// Get equation pointers /// </summary> /// <param name="variables">Variables</param> /// <param name="solver">Solver</param> public override void GetEquationPointers(VariableSet variables, Solver <double> solver) { if (variables == null) { throw new ArgumentNullException(nameof(variables)); } if (solver == null) { throw new ArgumentNullException(nameof(solver)); } // Create PosPrimeNode = _mbp.Resistance > 0 ? variables.Create(Name.Combine("pos")).Index : _posNode; // Get matrix elements PosPosPrimePtr = solver.GetMatrixElement(_posNode, PosPrimeNode); NegPosPrimePtr = solver.GetMatrixElement(_negNode, PosPrimeNode); PosPrimePosPtr = solver.GetMatrixElement(PosPrimeNode, _posNode); PosPrimeNegPtr = solver.GetMatrixElement(PosPrimeNode, _negNode); PosPosPtr = solver.GetMatrixElement(_posNode, _posNode); NegNegPtr = solver.GetMatrixElement(_negNode, _negNode); PosPrimePosPrimePtr = solver.GetMatrixElement(PosPrimeNode, PosPrimeNode); // Get RHS elements NegPtr = solver.GetRhsElement(_negNode); PosPrimePtr = solver.GetRhsElement(PosPrimeNode); }
public Renderer(VariableSet variables, Drawable drawable) : base(variables) { _drawable = drawable; const double lensAngle = 70.0; const double earthRadius = 6375.0; var amplitudes = new double[] { 1.0, 0.5, 0.25, 0.125, 0.0625, 0.03125, 0.05, 0.05, 0.04, 0.0300 }; _width = drawable.Width; _height = drawable.Height; _clouds = new Perlin3D(10, 16.0, amplitudes, (int)GetValue <UInt32>("seed")); _cameraDistance = _width * 0.5 / Math.Tan(lensAngle * Math.PI / 180.0); _intSunX = (int)Math.Round((_width - 1) * GetValue <double>("sun_x")); _intSunY = (int)Math.Round((_height - 1) * GetValue <double>("sun_y")); _horizonColor2 = FromScreen("horizon_color"); _skyColor2 = FromScreen("sky_color"); _sunColor2 = FromScreen("sun_color"); _cloudColor2 = FromScreen("cloud_color"); _shadowColor2 = FromScreen("shadow_color"); var tilt = new TMatrix(GetValue <double>("tilt"), 1); var rotation = new TMatrix(GetValue <double>("rotation"), 2); _transform = TMatrix.Combine(tilt, rotation); _cameraLocation = new Vector3(0.0, earthRadius + 0.2, 0.0); }
void CreateColorModeWidget(VariableSet variables) { var mode = new GimpComboBox(variables.Get <int>("color_mode"), new string[] { _("Grayscale"), _("RGB Color") }); AttachAligned(0, 3, _("_Mode:"), 0.0, 0.5, mode, 2, false); }
static void Main(string[] args) { var variables = new VariableSet() { new Variable <double>("tilt", _("Camera tilt angle (0.0 - 90.0)"), 0.0), new Variable <double>("rotation", _("Camera rotation angle (0.0 - 90.0)"), 0.0), new Variable <UInt32>("seed", _("Random seed, -1 to use current time"), 0), new Variable <bool>("sun_show", _("Show sun? (bool)"), true), new Variable <double>("sun_x", _("Sun's x coordinate (0.0 - 1.0)"), 0.2), new Variable <double>("sun_y", _("Sun's y coordinate (0.0 - 1.0)"), 0.2), new Variable <double>("time", _("Time in hours (0.0 - 24.0)"), 0.0), new Variable <RGB>("horizon_color", _("Horizon color"), new RGB(0.31, 0.35, 0.40)), new Variable <RGB>("sky_color", _("Color at highest point in the sky"), new RGB(0.01, 0.04, 0.18)), new Variable <RGB>("sun_color", _("Sun color"), new RGB(0.995, 0.90, 0.83)), new Variable <RGB>("cloud_color", _("Cloud color"), new RGB(1.0, 1.0, 1.0)), new Variable <RGB>("shadow_color", _("Cloud shadow color"), new RGB(0, 0, 0)), new Variable <bool>("random_seed", _(""), false) }; GimpMain <Sky>(args, variables); }
static void Main(string[] args) { var variables = new VariableSet() { new Variable<int>("cell_size", "Cell size", 30) }; GimpMain<Pointillize>(args, variables); }
public void UnregisterNestedVariable() { VariableSet vSet = new VariableSet(); VariableSet childVset = new VariableSet(); Variable inScope = new Variable("Horace", OperandType.String, "I am hungry"); vSet.RegisterVariable(OperandType.VSet, "child", childVset); childVset.RegisterVariable(inScope); Assert.IsTrue(vSet.GetVariable("child.Horace") == inScope); vSet.UnregisterVariable("child.Horace"); try { var variable = vSet.GetVariable("Horace"); Assert.Fail("Did not throw expected exception"); } catch (KeyNotFoundException knfex) { } catch { Assert.Fail("Did not throw expected exception"); } }
/// <summary> /// Gets matrix pointers /// </summary> /// <param name="variables">Variables</param> /// <param name="solver">Matrix</param> public override void GetEquationPointers(VariableSet variables, Solver <double> solver) { if (variables == null) { throw new ArgumentNullException(nameof(variables)); } if (solver == null) { throw new ArgumentNullException(nameof(solver)); } // Add a series drain node if necessary if (_mbp.DrainResistance > 0 || _mbp.SheetResistance > 0 && _bp.DrainSquares > 0) { DrainNodePrime = variables.Create(new SubIdentifier(Name, "drain")).Index; } else { DrainNodePrime = _drainNode; } // Add a series source node if necessary if (_mbp.SourceResistance > 0 || _mbp.SheetResistance > 0 && _bp.SourceSquares > 0) { SourceNodePrime = variables.Create(new SubIdentifier(Name, "source")).Index; } else { SourceNodePrime = _sourceNode; } // Get matrix elements DrainDrainPtr = solver.GetMatrixElement(_drainNode, _drainNode); GateGatePtr = solver.GetMatrixElement(_gateNode, _gateNode); SourceSourcePtr = solver.GetMatrixElement(_sourceNode, _sourceNode); BulkBulkPtr = solver.GetMatrixElement(_bulkNode, _bulkNode); DrainPrimeDrainPrimePtr = solver.GetMatrixElement(DrainNodePrime, DrainNodePrime); SourcePrimeSourcePrimePtr = solver.GetMatrixElement(SourceNodePrime, SourceNodePrime); DrainDrainPrimePtr = solver.GetMatrixElement(_drainNode, DrainNodePrime); GateBulkPtr = solver.GetMatrixElement(_gateNode, _bulkNode); GateDrainPrimePtr = solver.GetMatrixElement(_gateNode, DrainNodePrime); GateSourcePrimePtr = solver.GetMatrixElement(_gateNode, SourceNodePrime); SourceSourcePrimePtr = solver.GetMatrixElement(_sourceNode, SourceNodePrime); BulkDrainPrimePtr = solver.GetMatrixElement(_bulkNode, DrainNodePrime); BulkSourcePrimePtr = solver.GetMatrixElement(_bulkNode, SourceNodePrime); DrainPrimeSourcePrimePtr = solver.GetMatrixElement(DrainNodePrime, SourceNodePrime); DrainPrimeDrainPtr = solver.GetMatrixElement(DrainNodePrime, _drainNode); BulkGatePtr = solver.GetMatrixElement(_bulkNode, _gateNode); DrainPrimeGatePtr = solver.GetMatrixElement(DrainNodePrime, _gateNode); SourcePrimeGatePtr = solver.GetMatrixElement(SourceNodePrime, _gateNode); SourcePrimeSourcePtr = solver.GetMatrixElement(SourceNodePrime, _sourceNode); DrainPrimeBulkPtr = solver.GetMatrixElement(DrainNodePrime, _bulkNode); SourcePrimeBulkPtr = solver.GetMatrixElement(SourceNodePrime, _bulkNode); SourcePrimeDrainPrimePtr = solver.GetMatrixElement(SourceNodePrime, DrainNodePrime); // Get rhs elements BulkPtr = solver.GetRhsElement(_bulkNode); DrainPrimePtr = solver.GetRhsElement(DrainNodePrime); SourcePrimePtr = solver.GetRhsElement(SourceNodePrime); }
public void TestDoubleAssignmentSecondToFirst() { ExpressionParser e = new ExpressionParser(); VariableSet variables = new VariableSet(); variables.RegisterVariable(OperandType.Double, "Answer1", 4.2); variables.RegisterVariable(OperandType.Double, "Answer2", 4.2); var compiledExpression = e.Parse("Answer1=5.1,Answer2=Answer1"); var evalResult = compiledExpression.Evaluate(variables); Assert.AreEqual(2, evalResult.Count); var actualResult2 = (double)evalResult.Pop().GetValue(); var actualResult1 = (double)evalResult.Pop().GetValue(); var variable1 = variables.GetVariable("Answer1"); var variable2 = variables.GetVariable("Answer2"); var answer1 = 5.1; var answer2 = 5.1; Assert.AreEqual(OperandType.Double, (variable1.VariableType)); Assert.AreEqual(OperandType.Double, (variable2.VariableType)); Assert.AreEqual(answer1, (double)(variable1.Value)); Assert.AreEqual(answer2, (double)(variable2.Value)); Assert.AreEqual(answer1, actualResult1); Assert.AreEqual(answer2, actualResult2); }
public void DocTest3() { // Parse ... ExpressionParser parser = new ExpressionParser(); var compiledExpression = parser.Parse("(cabbages+onions)*bananas"); Debug.WriteLine(compiledExpression.ToString()); // Variables ... VariableSet vSet = new VariableSet(); vSet.RegisterVariable(OperandType.Double, "cabbages", 6); vSet.RegisterVariable(OperandType.Long, "onions", 2); vSet.RegisterVariable(OperandType.Long, "bananas", 5); // Evaluate ... var resultStack = compiledExpression.Evaluate(vSet); Debug.WriteLine(TokenService.TokensAsString(resultStack)); // Result ... IOperand result = resultStack.Pop(); Debug.WriteLine($"{result.Type}, {result.GetValue()}"); double answer = (double)result.GetValue(); Debug.WriteLine(answer); }
public static VariableReference CreateNewVariableForUnwiredTerminal(this Terminal terminal) { VariableSet variableSet = terminal.GetVariableSet(); int diagramLifetimeId = terminal.ParentDiagram.GetLifetimeGraphIdentifier().Id; return(variableSet.CreateNewVariable(diagramLifetimeId, variableSet.TypeVariableSet.CreateReferenceToNewTypeVariable())); }
public void TestDoubleAssignmentSecondToSelf() { ExpressionParser e = new ExpressionParser(); VariableSet variables = new VariableSet(); variables.RegisterVariable(OperandType.Long, "Age", 42); variables.RegisterVariable(OperandType.Double, "Opacity", 4.2); variables.RegisterVariable(OperandType.Double, "Answer", 4.2); var compiledExpression = e.Parse("Answer=5.1,Answer=Answer"); var evalResult = compiledExpression.Evaluate(variables); Assert.AreEqual(2, evalResult.Count); var actualResult2 = evalResult.Pop(); var actualResult1 = evalResult.Pop(); var variable1 = variables.GetVariable("Answer"); var answer1 = 5.1; var answer2 = 5.1; Assert.AreEqual(OperandType.Double, (variable1.VariableType)); Assert.AreEqual(answer1, (double)(variable1.Value)); Assert.AreEqual(answer1, actualResult1.GetValue()); Assert.AreEqual(answer2, actualResult2.GetValue()); }
/// <summary> /// Allocate elements in the Y-matrix and Rhs-vector to populate during loading. Additional /// equations can also be allocated here. /// </summary> /// <param name="variables">The variable set.</param> /// <param name="solver">The solver.</param> public void GetEquationPointers(VariableSet variables, Solver <double> solver) { // Allocate branch equations first Internal1 = variables.Create(Name.Combine("int1")).Index; Internal2 = variables.Create(Name.Combine("int2")).Index; BranchEq1 = variables.Create(Name.Combine("branch1"), VariableType.Current).Index; BranchEq2 = variables.Create(Name.Combine("branch2"), VariableType.Current).Index; Pos1Pos1Ptr = solver.GetMatrixElement(Pos1, Pos1); Pos1Int1Ptr = solver.GetMatrixElement(Pos1, Internal1); Int1Pos1Ptr = solver.GetMatrixElement(Internal1, Pos1); Int1Int1Ptr = solver.GetMatrixElement(Internal1, Internal1); Int1Ibr1Ptr = solver.GetMatrixElement(Internal1, BranchEq1); Ibr1Int1Ptr = solver.GetMatrixElement(BranchEq1, Internal1); Neg1Ibr1Ptr = solver.GetMatrixElement(Neg1, BranchEq1); Ibr1Neg1Ptr = solver.GetMatrixElement(BranchEq1, Neg1); Pos2Pos2Ptr = solver.GetMatrixElement(Pos2, Pos2); Pos2Int2Ptr = solver.GetMatrixElement(Pos2, Internal2); Int2Pos2Ptr = solver.GetMatrixElement(Internal2, Pos2); Int2Int2Ptr = solver.GetMatrixElement(Internal2, Internal2); Int2Ibr2Ptr = solver.GetMatrixElement(Internal2, BranchEq2); Ibr2Int2Ptr = solver.GetMatrixElement(BranchEq2, Internal2); Neg2Ibr2Ptr = solver.GetMatrixElement(Neg2, BranchEq2); Ibr2Neg2Ptr = solver.GetMatrixElement(BranchEq2, Neg2); // These pointers are only used to calculate the DC operating point Ibr1Pos1Ptr = solver.GetMatrixElement(BranchEq1, Pos1); Ibr1Pos2Ptr = solver.GetMatrixElement(BranchEq1, Pos2); Ibr1Neg2Ptr = solver.GetMatrixElement(BranchEq1, Neg2); Ibr2Ibr1Ptr = solver.GetMatrixElement(BranchEq2, BranchEq1); Ibr2Ibr2Ptr = solver.GetMatrixElement(BranchEq2, BranchEq2); }
static void Main(string[] args) { var variables = new VariableSet { new Variable<int>("pieces", _("Number of shards"), 4) }; GimpMain<Shatter>(args, variables); }
public Dialog(VariableSet variables) : base("Splitter", variables) { var vbox = new VBox(false, 12) {BorderWidth = 12}; VBox.PackStart(vbox, true, true, 0); var table = new GimpTable(4, 2) {ColumnSpacing = 6, RowSpacing = 6}; vbox.PackStart(table, false, false, 0); var hbox = new HBox(false, 6); table.Attach(hbox, 0, 2, 0, 1); hbox.Add(new Label("f(x, y):")); hbox.Add(new GimpEntry(GetVariable<string>("formula"))); hbox.Add(new Label("= 0")); table.Attach(CreateLayerFrame("Layer 1", "translate_1_x", "translate_1_y", "rotate_1"), 0, 1, 1, 2); table.Attach(CreateLayerFrame("Layer 2", "translate_2_x", "translate_2_y", "rotate_2"), 1, 2, 1, 2); table.Attach(new GimpCheckButton(_("_Merge visible layers"), GetVariable<bool>("merge")), 0, 1, 3, 4); table.Attach(CreateAdvancedOptions(), 1, 2, 3, 4); var keep = new GimpComboBox(GetVariable<int>("keep_layer"), new string[]{_("Both Layers"), _("Layer 1"), _("Layer 2")}); table.AttachAligned(0, 5, _("Keep:"), 0.0, 0.5, keep, 1, true); }
public Renderer(VariableSet variables, Drawable drawable) : base(variables) { _drawable = drawable; const double lensAngle = 70.0; const double earthRadius = 6375.0; var amplitudes = new double[]{1.0, 0.5, 0.25, 0.125, 0.0625, 0.03125, 0.05, 0.05, 0.04, 0.0300}; _width = drawable.Width; _height = drawable.Height; _clouds = new Perlin3D(10, 16.0, amplitudes, (int) GetValue<UInt32>("seed")); _cameraDistance = _width * 0.5 / Math.Tan(lensAngle * Math.PI / 180.0); _intSunX = (int) Math.Round((_width - 1) * GetValue<double>("sun_x")); _intSunY = (int) Math.Round((_height - 1) * GetValue<double>("sun_y")); _horizonColor2 = FromScreen("horizon_color"); _skyColor2 = FromScreen("sky_color"); _sunColor2 = FromScreen("sun_color"); _cloudColor2 = FromScreen("cloud_color"); _shadowColor2 = FromScreen("shadow_color"); var tilt = new TMatrix(GetValue<double>("tilt"), 1); var rotation = new TMatrix(GetValue<double>("rotation"), 2); _transform = TMatrix.Combine(tilt, rotation); _cameraLocation = new Vector3(0.0, earthRadius + 0.2, 0.0); }
public void TestSpecializedBools() { ExpressionParser e = new ExpressionParser(); VariableSet variables = new VariableSet(null, new TestVariableFactory()); variables.RegisterVariable(OperandType.NullableBool, "Left", true); variables.RegisterVariable(OperandType.Bool, "Right", true); variables.SetVariableValue("Right", false); variables.SetVariableValue("Right", true); variables.SetVariableValue("Right", false); bool?left = true; bool right = false; bool expectedResult = left == right; var compiledExpression = e.Parse("Left == Right"); var evalResult = compiledExpression.Evaluate(variables); Assert.AreEqual(1, evalResult.Count); bool actualResult = (bool)evalResult.Pop().GetValue(); Assert.AreEqual(expectedResult, actualResult); Assert.AreEqual(3, ((CrazyBool)variables.GetVariable("Right")).ChangeCount); }
/// <summary> /// Gets matrix pointers /// </summary> /// <param name="variables">Nodes</param> /// <param name="solver">Solver</param> public void GetEquationPointers(VariableSet variables, Solver <double> solver) { if (variables == null) { throw new ArgumentNullException(nameof(variables)); } if (solver == null) { throw new ArgumentNullException(nameof(solver)); } // Add series drain node if necessary if (ModelParameters.DrainResistance > 0 || ModelParameters.SheetResistance > 0 && BaseParameters.DrainSquares > 0) { DrainNodePrime = variables.Create(Name.Combine("DrainNode")).Index; } else { DrainNodePrime = DrainNode; } // Add series source node if necessary if (ModelParameters.SourceResistance > 0 || ModelParameters.SheetResistance > 0 && BaseParameters.SourceSquares > 0) { SourceNodePrime = variables.Create(Name.Combine("source")).Index; } else { SourceNodePrime = SourceNode; } // Get matrix pointers DrainDrainPtr = solver.GetMatrixElement(DrainNode, DrainNode); GateGatePtr = solver.GetMatrixElement(GateNode, GateNode); SourceSourcePtr = solver.GetMatrixElement(SourceNode, SourceNode); BulkBulkPtr = solver.GetMatrixElement(BulkNode, BulkNode); DrainPrimeDrainPrimePtr = solver.GetMatrixElement(DrainNodePrime, DrainNodePrime); SourcePrimeSourcePrimePtr = solver.GetMatrixElement(SourceNodePrime, SourceNodePrime); DrainDrainPrimePtr = solver.GetMatrixElement(DrainNode, DrainNodePrime); GateBulkPtr = solver.GetMatrixElement(GateNode, BulkNode); GateDrainPrimePtr = solver.GetMatrixElement(GateNode, DrainNodePrime); GateSourcePrimePtr = solver.GetMatrixElement(GateNode, SourceNodePrime); SourceSourcePrimePtr = solver.GetMatrixElement(SourceNode, SourceNodePrime); BulkDrainPrimePtr = solver.GetMatrixElement(BulkNode, DrainNodePrime); BulkSourcePrimePtr = solver.GetMatrixElement(BulkNode, SourceNodePrime); DrainPrimeSourcePrimePtr = solver.GetMatrixElement(DrainNodePrime, SourceNodePrime); DrainPrimeDrainPtr = solver.GetMatrixElement(DrainNodePrime, DrainNode); BulkGatePtr = solver.GetMatrixElement(BulkNode, GateNode); DrainPrimeGatePtr = solver.GetMatrixElement(DrainNodePrime, GateNode); SourcePrimeGatePtr = solver.GetMatrixElement(SourceNodePrime, GateNode); SourcePrimeSourcePtr = solver.GetMatrixElement(SourceNodePrime, SourceNode); DrainPrimeBulkPtr = solver.GetMatrixElement(DrainNodePrime, BulkNode); SourcePrimeBulkPtr = solver.GetMatrixElement(SourceNodePrime, BulkNode); SourcePrimeDrainPrimePtr = solver.GetMatrixElement(SourceNodePrime, DrainNodePrime); // Get rhs pointers BulkPtr = solver.GetRhsElement(BulkNode); DrainPrimePtr = solver.GetRhsElement(DrainNodePrime); SourcePrimePtr = solver.GetRhsElement(SourceNodePrime); }
public void TestMissingVariable3() { ExpressionParser e = new ExpressionParser(); VariableSet variables = new VariableSet(); variables.RegisterVariable(OperandType.String, "Banana", "Hello Banana!"); IOperand actualResult1 = null; Stack <IOperand> evalResult = null; bool shortedOut = true; var compiledExpression = e.Parse("Banana , Melon"); try { evalResult = compiledExpression.Evaluate(variables); Assert.AreEqual(2, evalResult.Count); shortedOut = false; actualResult1 = OperatorActions.PopAndResolve(evalResult, variables); } catch (ExpressionEvaluatorException ex) { Assert.AreEqual(shortedOut, false); Assert.AreEqual(actualResult1, null); var actualResult2 = OperatorActions.PopAndResolve(evalResult, variables).GetValue(); Assert.AreEqual((string)actualResult2, "Hello Banana!"); Assert.AreEqual(ex.Cause, ExpressionEvaluatorException.ExceptionCause.UndefinedVariable); Assert.AreEqual(ex.Offset, 9); Assert.AreEqual(ex.Message, "'Melon'"); } }
public void GetEquationPointers(VariableSet variables, Solver <double> solver) { foreach (var node in _nodes) { variables.MapNode(node); } }
/// <summary> /// Allocate elements in the Y-matrix and Rhs-vector to populate during loading. Additional /// equations can also be allocated here. /// </summary> /// <param name="variables">The variable set.</param> /// <param name="solver">The solver.</param> public void GetEquationPointers(VariableSet variables, Solver <double> solver) { variables.ThrowIfNull(nameof(variables)); solver.ThrowIfNull(nameof(solver)); SourcePrimeNode = ModelParameters.SourceResistance > 0 ? variables.Create(Name.Combine("source")).Index : SourceNode; DrainPrimeNode = ModelParameters.DrainResistance > 0 ? variables.Create(Name.Combine("drain")).Index : DrainNode; GateNodePtr = solver.GetRhsElement(GateNode); DrainPrimeNodePtr = solver.GetRhsElement(DrainPrimeNode); SourcePrimeNodePtr = solver.GetRhsElement(SourcePrimeNode); DrainDrainPrimePtr = solver.GetMatrixElement(DrainNode, DrainPrimeNode); GateDrainPrimePtr = solver.GetMatrixElement(GateNode, DrainPrimeNode); GateSourcePrimePtr = solver.GetMatrixElement(GateNode, SourcePrimeNode); SourceSourcePrimePtr = solver.GetMatrixElement(SourceNode, SourcePrimeNode); DrainPrimeDrainPtr = solver.GetMatrixElement(DrainPrimeNode, DrainNode); DrainPrimeGatePtr = solver.GetMatrixElement(DrainPrimeNode, GateNode); DrainPrimeSourcePrimePtr = solver.GetMatrixElement(DrainPrimeNode, SourcePrimeNode); SourcePrimeGatePtr = solver.GetMatrixElement(SourcePrimeNode, GateNode); SourcePrimeSourcePtr = solver.GetMatrixElement(SourcePrimeNode, SourceNode); SourcePrimeDrainPrimePtr = solver.GetMatrixElement(SourcePrimeNode, DrainPrimeNode); DrainDrainPtr = solver.GetMatrixElement(DrainNode, DrainNode); GateGatePtr = solver.GetMatrixElement(GateNode, GateNode); SourceSourcePtr = solver.GetMatrixElement(SourceNode, SourceNode); DrainPrimeDrainPrimePtr = solver.GetMatrixElement(DrainPrimeNode, DrainPrimeNode); SourcePrimeSourcePrimePtr = solver.GetMatrixElement(SourcePrimeNode, SourcePrimeNode); }
public Dialog(VariableSet variables) : base("JavaFX", variables) { var table = new GimpTable(4, 3) {ColumnSpacing = 6, RowSpacing = 6}; VBox.PackStart(table, false, false, 0); // Fix me: dialog is still empty }
/// <summary> /// Evaluate this parse tree node with the given variable values. /// </summary> /// <param name="variables">The variable values to use in calculation.</param> /// <returns>Returns the result of the evaluation.</returns> public override double Evaluate(VariableSet variables) { double leftResult = Left.Evaluate(variables); double rightResult = Right.Evaluate(variables); return(Evaluator.Function(leftResult, rightResult)); }
static void Main(string[] args) { var variables = new VariableSet() { new Variable<string>("image_path", _("Path to load frame image from"), "") }; GimpMain<PictureFrame>(args, variables); }
private void ReferenceVariable(BinaryReader reader, IReadSavegameProgress progress) { List <Variable> referencedVariables = new List <Variable>(); for (int i = 0; i < Variables.Length; i++) { Variable currentVariable = Variables[i]; VariableSet currentVariableSet = currentVariable as VariableSet; if (currentVariableSet != null && currentVariable.Size > currentVariable.TokenSize) { int size = currentVariable.Size - currentVariableSet.TokenSize; List <Variable> childrenVariables = new List <Variable>(); while (size > 0) { Variable nextVariable = Variables[++i]; childrenVariables.Add(nextVariable); size -= nextVariable.TokenSize; } currentVariableSet.Variables = childrenVariables.ToArray(); } referencedVariables.Add(currentVariable); } Variables = referencedVariables.ToArray(); }
public void TestComplexLogicalOperators() { ExpressionParser e = new ExpressionParser(); VariableSet variables = new VariableSet(); variables.RegisterVariable(OperandType.Long, "L0", 42); variables.RegisterVariable(OperandType.Long, "L1", -129); variables.RegisterVariable(OperandType.Long, "L2", -475); variables.RegisterVariable(OperandType.Bool, "B0", false); variables.RegisterVariable(OperandType.Bool, "B1", true); variables.RegisterVariable(OperandType.Bool, "B2", true); variables.RegisterVariable(OperandType.Bool, "Result", false); long l0 = 42, l1 = -129, l2 = -475; bool b0 = false, b1 = true, b2 = true; bool expectedResult = b0 | (b1 & b2) == true & ((l0 & l1) > 11); var compiledExpression = e.Parse("Result = B0 | (B1 & B2) == True & ( (L0 & L1) > 11)"); var evalResult = compiledExpression.Evaluate(variables); Assert.AreEqual(1, evalResult.Count); bool actualResult = (bool)evalResult.Pop().GetValue(); Assert.AreEqual(expectedResult, variables.GetVariable("Result").Value); Assert.AreEqual(expectedResult, actualResult); }
public Dialog(Image image, Drawable drawable, VariableSet variables) : base("Ministeck", drawable, variables, () => new DrawablePreview(drawable)) { _image = image; var table = new GimpTable(2, 2) { ColumnSpacing = 6, RowSpacing = 6 }; Vbox.PackStart(table, false, false, 0); var size = new GimpSpinButton(3, 100, 1, GetVariable <int>("size")); table.AttachAligned(0, 0, _("_Size:"), 0.0, 0.5, size, 2, true); var limit = new GimpCheckButton(_("_Limit Shapes"), GetVariable <bool>("limit")); table.Attach(limit, 2, 3, 0, 1); var colorButton = new GimpColorButton("", 16, 16, GetVariable <RGB>("color"), ColorAreaType.Flat) { Update = true }; table.AttachAligned(0, 1, _("C_olor:"), 0.0, 0.5, colorButton, 1, true); }
void CreateResolutionWidget(VariableSet variables) { var resolution = variables.Get <int>("resolution"); var button = new GimpSpinButton(0, 1200, 1, resolution); AttachAligned(0, 2, _("_Resolution:"), 0.0, 0.5, button, 1, true); }
public async Task UpdateVariableSet(VariableSet varSet) { var id = varSet.Id; if (varSet.IdType == VariableSet.VariableIdTypes.Library) { id = (await client.Repository.LibraryVariableSets.Get(id)).VariableSetId; } var set = await client.Repository.VariableSets.Get(id); foreach (var variable in varSet.Variables) { var scope = new ScopeSpecification(); if (variable.EnvironmentIds.Any()) { scope.Add(ScopeField.Environment, new ScopeValue(variable.EnvironmentIds)); } if (variable.TargetIds.Any()) { scope.Add(ScopeField.Machine, new ScopeValue(variable.TargetIds)); } if (variable.RoleIds.Any()) { scope.Add(ScopeField.Role, new ScopeValue(variable.RoleIds)); } set.AddOrUpdateVariableValue(variable.Key, variable.Value, scope); } await client.Repository.VariableSets.Modify(set); }
public void AdvancedDocumentationSample() { /////////////////////////////////////////////// // Create and configure the Parser object ... /////////////////////////////////////////////// ExpressionParser parser = new ExpressionParser(); // Overload that will allow a Bool to be appended to a String // To add a String to a Bool you'll need to add another overload parser.RegisterOverload("+", OperandType.String, OperandType.Bool, (left, right) => new Operand(OperandType.String, (string)left.GetValue() + ((bool)right.GetValue()).ToString())); // A user-defined function // Note (at time of writing) validation of parameter count for functions isn't robust. parser.RegisterFunction("StringContains", DoStringContains, 3); /////////////////////////////////////////////// // Note the comma operator - this expression yields two results each time it is evaluated // It calls the function 'StringContains' registered above, passing in a variable, a constant and a bool // It uses the overload registered above to add a bool to a string /////////////////////////////////////////////// var compiledExpression = parser.Parse( "text = text + child.textPhrase, 'HammerCat found: ' + (StringContains(text, 'HammerCat', true) >= 0)" ); /////////////////////////////////////////////// // Configure a VariableSet with a custom factory /////////////////////////////////////////////// var variableFactory = new TestVariableFactory(); VariableSet vSet = new VariableSet(variableFactory); vSet.RegisterVariable(OperandType.String, "text", "GO!-> "); vSet.RegisterVariable(OperandType.VSet, "child", new VariableSet(variableFactory)); // VariableSet - same factory vSet.RegisterVariable(OperandType.String, "child.textPhrase", "Who seeks HammerCat?"); // Nested Variable /////////////////////////////////////////////// // Evaluate ... /////////////////////////////////////////////// var resultStack = compiledExpression.Evaluate(vSet); /////////////////////////////////////////////// // Get both of the results ... /////////////////////////////////////////////// // Result of "'HammerCat found: ' + StringContains(text, 'HammerCat', true) >= 0" var second = (string)resultStack.Pop().GetValue(); // Result of "text = text + child.textPhrase" var first = (string)resultStack.Pop().GetValue(); // Ensure the result matches the variable ... string text = (string)vSet.GetVariable("text").Value; Assert.AreEqual(first, text); // Show the results ... Debug.WriteLine($"First result is: {first}"); Debug.WriteLine($"Second result is: {second}"); ShowCustomVariables("", vSet); }
public override SolutionBuilder.BuildResult ProcessBuildResult( VariableSet variables, Configuration configuration, SolutionBuilder.BuildResult buildResult ) { Common.ProcessContentProjects(variables, configuration, buildResult, ContentProjectsProcessed); return base.ProcessBuildResult(variables, configuration, buildResult); }
public Renderer(VariableSet variables) : base(variables) { _random = new Random((int) GetValue<UInt32>("seed")); _turbulence = GetValue<double>("turbulence"); _progressBar = new Progress(_("Difference Clouds...")); }
public Renderer(VariableSet variables) : base(variables) { _random = new Random((int)GetValue <UInt32>("seed")); _turbulence = GetValue <double>("turbulence"); _progressBar = new Progress(_("Difference Clouds...")); }
public override SolutionBuilder.BuildResult ProcessBuildResult(VariableSet variables, Configuration configuration, SolutionBuilder.BuildResult buildResult) { CopiedOutputGatherer.GatherFromProjectFiles( variables, configuration, buildResult ); return(base.ProcessBuildResult(variables, configuration, buildResult)); }
public virtual TranslationResult Translate ( VariableSet variables, AssemblyTranslator translator, Configuration configuration, string assemblyPath, bool scanForProxies ) { var result = translator.Translate(assemblyPath, scanForProxies); return result; }
static void Main(string[] args) { var variables = new VariableSet { new Variable <int>("pieces", _("Number of shards"), 4) }; GimpMain <Shatter>(args, variables); }
public override SolutionBuilder.BuildResult ProcessBuildResult( VariableSet variables, Configuration configuration, SolutionBuilder.BuildResult buildResult ) { Common.ProcessContentProjects(variables, configuration, buildResult, ContentProjectsProcessed); return(base.ProcessBuildResult(variables, configuration, buildResult)); }
public virtual TranslationResult Translate(VariableSet variables, AssemblyTranslator translator, Configuration configuration, string assemblyPath, bool scanForProxies) { var result = translator.Translate(assemblyPath, scanForProxies); AssemblyTranslator.GenerateManifest(translator.Manifest, assemblyPath, result); return(result); }
public static void Main(string[] args) { var variables = new VariableSet { new Variable<int>(VariablesConsts.ITERATIONS, _("Number of iterations"), 50), new Variable<int>(VariablesConsts.WINDOW_SIZE, _("Window size"), 9) }; GimpMain<ObjectRemovalPlugin>(args, variables); }
static void Main(string[] args) { var variables = new VariableSet() { new Variable<UInt32>("seed", _("Random seed"), 0), new Variable<bool>("random_seed", _("Random seed enabled"), false), new Variable<double>("turbulence", _("Turbulence of the cloud"), 0) }; GimpMain<DifferenceClouds>(args, variables); }
public Dialog(VariableSet variables) : base(_("Difference Clouds"), variables) { var table = new GimpTable(3, 4) {ColumnSpacing = 6, RowSpacing = 6}; VBox.PackStart(table, false, false, 0); CreateRandomSeedWidget(table); CreateTurbulenceEntry(table); }
public void GetData(VariableSet variables) { var data = ProceduralDb.GetData(_name); if (data != null) { var stream = new MemoryStream(data); variables.ForEach(v => v.Deserialize(_formatter, stream)); } }
public void SetData(VariableSet variables) { var stream = new MemoryStream(); variables.ForEach(v => v.Serialize(_formatter, stream)); if (stream.Length != 0) { ProceduralDb.SetData(_name, stream.GetBuffer()); } }
public virtual void WriteOutputs(VariableSet variables, TranslationResult result, string path, string manifestPrefix) { Console.WriteLine(manifestPrefix + "manifest.js"); foreach (var fe in result.OrderedFiles) Console.WriteLine(fe.Filename); result.WriteToDirectory(path, manifestPrefix); }
static void Main(string[] args) { var variables = new VariableSet { new Variable<UInt32>("seed", _("Value for random seed"), 0), new Variable<bool>("random_seed", _("Use specified random seed"), false), new Variable<int>("points", _("Fix me"), 3) }; GimpMain<Swirlies>(args, variables); }
static void Main(string[] args) { var variables = new VariableSet() { new Variable<int>("drop_size", _("Size of raindrops"), 80), new Variable<int>("number", _("Number of raindrops"), 80), new Variable<int>("fish_eye", _("Fisheye effect"), 30) }; GimpMain<Raindrops>(args, variables); }
public Dialog(Drawable drawable, VariableSet variables) : base(_("Pointillize"), drawable, variables, () => new AspectPreview(drawable)) { var table = new GimpTable(1, 3); VBox.PackStart(table, false, false, 0); new ScaleEntry(table, 0, 1, _("Cell _Size:"), 150, 3, GetVariable<int>("cell_size"), 3.0, 300.0, 1.0, 8.0, 0); }
public Dialog(VariableSet variables) : base("ShapeCollage", variables) { var table = new GimpTable(4, 3) { ColumnSpacing = 6, RowSpacing = 6 }; VBox.PackStart(table, false, false, 0); }
public Renderer(VariableSet variables) : base(variables) { _random = new Random((int) GetValue<UInt32>("seed")); for (int i = 0; i < 7; i++) { _random.Next(); } }
public Dialog(VariableSet variables, Variable<int> performed, Variable<int> total) : base("UnitTest", variables) { var vbox = new VBox(false, 12) {BorderWidth = 12}; VBox.PackStart(vbox, true, true, 0); vbox.PackStart(CreateTestDllButton(), false, false, 0); vbox.PackEnd(CreateProgressBar(performed, total)); }
public GetString(string variableName, string npcName, Conversation conversation) { this.variableName = variableName; if (npcName != null){ GameObject npc = CharacterManager.GetCharacter(npcName); variableSet = ((CharacterState)npc.GetComponent("CharacterState")).GetVariableSet(); } else { variableSet = conversation.GetVariableSet(); } }
public Dialog(Drawable drawable, VariableSet variables) : base("Shatter", drawable, variables, () => new AspectPreview(drawable)) { var table = new GimpTable(4, 3, false) { ColumnSpacing = 6, RowSpacing = 6}; Vbox.PackStart(table, false, false, 0); new ScaleEntry(table, 0, 1, "Pieces:", 150, 3, GetVariable<int>("pieces"), 1.0, 256.0, 1.0, 8.0, 0); }
public SubtractFromInteger(string variableName, string npcName, NumericOperand operand, Conversation conversation) { this.variableName = variableName; if (npcName != null){ GameObject npc = CharacterManager.GetCharacter(npcName); variableSet = ((CharacterState)npc.GetComponent("CharacterState")).GetVariableSet(); } else { variableSet = conversation.GetVariableSet(); } this.operand = operand; }
public SetString(string variableName, string npcName, StringOperand operand, Conversation conversation) { this.variableName = variableName; if (npcName != null){ GameObject npc = CharacterManager.GetCharacter(npcName); variableSet = ((CharacterState)npc.GetComponent(typeof(CharacterState))).GetVariableSet(); } else { variableSet = conversation.GetVariableSet(); } this.operand = operand; }