public static Tuple <bool, string> EvaluateTests(Operator testingOp, string filterPattern) { try { //connect it to a testsevaluator var compositionOp = testingOp.Parent; var evaluatorMetaOpID = Guid.Parse("0316356c-b1fe-490a-89ce-73c8f67ebccc"); var evaluatorMetaOp = MetaManager.Instance.GetMetaOperator(evaluatorMetaOpID); var addOpCmd = new AddOperatorCommand(compositionOp, evaluatorMetaOpID); addOpCmd.Do(); var evaluatorOp = evaluatorMetaOp.GetOperatorInstance(addOpCmd.AddedInstanceID); var connection = new MetaConnection(testingOp.ID, testingOp.Outputs[0].ID, evaluatorOp.ID, evaluatorOp.Inputs[0].ID); var addConnectionCmd = new InsertConnectionCommand(compositionOp.Definition, connection, 0); addConnectionCmd.Do(); //configure the testsevaluator op and start testing var startTestsTriggerOpPart = evaluatorOp.Inputs[1]; var filterOpPart = evaluatorOp.Inputs[3]; //we must create a down flank for the startTestsTrigger value to start the tests properly var updateStartTestsCmd = new UpdateOperatorPartValueFunctionCommand(startTestsTriggerOpPart, new Float(1.0f)); updateStartTestsCmd.Do(); var updateFilterCmd = new UpdateOperatorPartValueFunctionCommand(filterOpPart, new Text(filterPattern)); updateFilterCmd.Do(); evaluatorOp.Outputs[0].Eval(new OperatorPartContext()); updateStartTestsCmd.Value = new Float(0.0f); updateStartTestsCmd.Do(); var resultLog = evaluatorOp.Outputs[0].Eval(new OperatorPartContext()).Text; var result = new Tuple <bool, string>(resultLog.StartsWith(compositionOp.Definition.Name + " : passed"), resultLog); var deleteOperatorCmd = new DeleteOperatorsCommand(compositionOp, new List <Operator>() { evaluatorOp }); deleteOperatorCmd.Do(); return(result); } catch (Exception ex) { Logger.Error("Failed to evaluate operator definition {0}: {1}", testingOp.Name, ex.ToString()); return(new Tuple <bool, string>(false, "")); } }
public void ParameterRow_UpdateManipulaitonHandler(object sender, ParameterGroupManipulatedEventArgs e) { var factor = (float)(e.Offset / 100.0 * UIHelper.SubScaleFromKeyboardModifiers() + 1); var metaInput = ValueHolder.Parent.GetMetaInput(ValueHolder); var newValue = _keepValueBeforeManipulation * (1 + factor * metaInput.Scale); newValue = Core.Utilities.Clamp(newValue, metaInput.Min, metaInput.Max); _setValueCommand.Value = new Core.Float(newValue); _setValueCommand.Do(); App.Current.UpdateRequiredAfterUserInteraction = true; }
private void FloatEditButton_ValueChangedHandler(float newValue) { newValue = Math.Max(_metaInput.Min, Math.Min(_metaInput.Max, newValue)); // ToDo: clamping should be done by FloatEdit // Update animation curve if (IsAnimated && _addKeyframeCommand != null) { _addKeyframeCommand.KeyframeValue.Value = newValue; _addKeyframeCommand.Do(); } else if (_updateValueCommand != null) { _updateValueCommand.Value = new Float(newValue); _updateValueCommand.Do(); } App.Current.UpdateRequiredAfterUserInteraction = true; // ToDo: This line should be moved to the source of interaction. Here, we only deal with result. }
/** * This is an extremely rough stub for testing the TimeClip splitting functionality. * Need fixes for... * - duplicate connections of original op * - get rid of magic numbers of parameters * - fix potential problems when parameters are animated of connected * - move this to an Memento-Operation * - resolve direct dependencies to CompositionGraphView an it's members */ public static void SplitSelectedTimeClips() { var nextSelection = new List <ISelectable>(); var currentTime = (float)App.Current.Model.GlobalTime; var selectedOpWidgets = new List <OperatorWidget>(); foreach (var element in App.Current.MainWindow.CompositionView.CompositionGraphView.SelectionHandler.SelectedElements) { var opWidget = element as OperatorWidget; if (opWidget == null || !(opWidget.Operator.InternalParts[0].Func is ITimeClip)) { continue; } selectedOpWidgets.Add(opWidget); } var commandList = new List <ICommand>(); foreach (var opWidget in selectedOpWidgets) { var op = opWidget.Operator; if (op == null) { continue; } var startTime = op.Inputs[HACK_TIMECLIP_STARTTIME_PARAM_INDEX].Eval(new OperatorPartContext()).Value; var endTime = op.Inputs[HACK_TIMECLIP_ENDTIME_PARAM_INDEX].Eval(new OperatorPartContext()).Value; var sourceIn = op.Inputs[HACK_TIMECLIP_SOURCEIN_PARAM_INDEX].Eval(new OperatorPartContext()).Value; var sourceOut = op.Inputs[HACK_TIMECLIP_SOURCEOUT_PARAM_INDEX].Eval(new OperatorPartContext()).Value; var layerIndex = op.Inputs[HACK_TIMECLIP_SOURCEOUT_LAYER_ID].Eval(new OperatorPartContext()).Value; var sourceCutTime = (currentTime - startTime) / (endTime - startTime) * (sourceOut - sourceIn) + sourceIn; if (!(startTime + MIN_SEGMENT_DURATION < currentTime) || !(currentTime < endTime - MIN_SEGMENT_DURATION)) { continue; } nextSelection.Add(opWidget); // Cut current op var currentOpSetEndtimeCommand = new UpdateOperatorPartValueFunctionCommand(op.Inputs[HACK_TIMECLIP_ENDTIME_PARAM_INDEX], new Core.Float(currentTime)); currentOpSetEndtimeCommand.Do(); var currentOpSetSourceOutCommand = new UpdateOperatorPartValueFunctionCommand(op.Inputs[HACK_TIMECLIP_SOURCEOUT_PARAM_INDEX], new Core.Float(sourceCutTime)); currentOpSetSourceOutCommand.Do(); // Intitial new op var compositionOp = App.Current.MainWindow.CompositionView.CompositionGraphView.CompositionOperator; var addNewOpCommand = new AddOperatorCommand(compositionOp, op.Definition.ID, op.Position.X + 10, op.Position.Y + 10); addNewOpCommand.Do(); var newOpWidget = App.Current.MainWindow.CompositionView.CompositionGraphView.FindOperatorWidgetById(addNewOpCommand.AddedInstanceID); nextSelection.Add(newOpWidget); var newOp = newOpWidget.Operator; if (!String.IsNullOrEmpty(op.Name)) { newOp.Name = Utilities.GetDuplicatedTitle(op.Name); } var newOpSetStartTimeCommand = new UpdateOperatorPartValueFunctionCommand(newOp.Inputs[HACK_TIMECLIP_STARTTIME_PARAM_INDEX], new Core.Float(currentTime)); newOpSetStartTimeCommand.Do(); var newOpSetEndTimeCommand = new UpdateOperatorPartValueFunctionCommand(newOp.Inputs[HACK_TIMECLIP_ENDTIME_PARAM_INDEX], new Core.Float(endTime)); newOpSetEndTimeCommand.Do(); var newOpSetSourceInCommand = new UpdateOperatorPartValueFunctionCommand(newOp.Inputs[HACK_TIMECLIP_SOURCEIN_PARAM_INDEX], new Core.Float(sourceCutTime)); newOpSetSourceInCommand.Do(); var newOpSetSourceOutCommand = new UpdateOperatorPartValueFunctionCommand(newOp.Inputs[HACK_TIMECLIP_SOURCEOUT_PARAM_INDEX], new Core.Float(sourceOut)); newOpSetSourceOutCommand.Do(); var newOpSetLayerCommand = new UpdateOperatorPartValueFunctionCommand(newOp.Inputs[HACK_TIMECLIP_SOURCEOUT_LAYER_ID], new Float(layerIndex)); newOpSetLayerCommand.Do(); commandList.AddRange(new ICommand[] { currentOpSetEndtimeCommand, currentOpSetSourceOutCommand, addNewOpCommand, newOpSetStartTimeCommand, newOpSetEndTimeCommand, newOpSetSourceInCommand, newOpSetSourceOutCommand, newOpSetLayerCommand }); } App.Current.UndoRedoStack.Add(new MacroCommand("Split time clip", commandList)); if (nextSelection.Any()) { App.Current.MainWindow.CompositionView.CompositionGraphView.SelectionHandler.SetElements(nextSelection); } }