public void PutParameter(string[] path, AnalyticRuleType type)
 {
     if (path.Length == 0)
     {
         children.Add(new RuleEvaluationChronologyViewModel(
                          EvaluationCache.Get(vin).GetRuleEvaluationChronology(type)));
     }
     else
     {
         if (!children.Any(f =>
                           f is EvaluationFolderViewModel &&
                           ((EvaluationFolderViewModel)f).Key == path[0]))
         {
             EvaluationFolderViewModel newFolder =
                 new EvaluationFolderViewModel(path[0], vin);
             newFolder.PutParameter(GetSubPath(path), type);
             children.Add(newFolder);
         }
         else
         {
             EvaluationFolderViewModel folder =
                 children.First(f =>
                                f is EvaluationFolderViewModel &&
                                ((EvaluationFolderViewModel)f).Key == path[0])
                 as EvaluationFolderViewModel;
             folder.PutParameter(GetSubPath(path), type);
         }
     }
     OnPropertyChanged("Children");
     RefreshSummaryMark();
 }
    private void Draw()
    {
        var worldBezier = targetPath.WorldSpaceBezier;
        var vertexCount = DynamicBezier.GoodNumMidPoints * worldBezier.Knots.Count;

        vertexCount /= 2;
        var cPointCache = new EvaluationCache(worldBezier, vertexCount).Values;

        // draw bezier
        PathEditorUtility.DrawSplineInScene(cPointCache);

        // draw direction cone cap
        if (!settings.HideDirectionCones &&
            targetScript.transform.lossyScale != Vector3.zero &&
            targetPath.LocalBezier.Knots.Count > 1)     // also hide cones if virtually a dot
        {
            float startConeSize = PathEditorUtility.Nice3DHandleSize(worldBezier.Evaluate(0f));
            float endConeSize   = PathEditorUtility.Nice3DHandleSize(worldBezier.Evaluate(1f));

            Handles.color = Color.yellow;
            Handles.ConeCap(0, worldBezier.Evaluate(0f), Quaternion.LookRotation(worldBezier.Evaluate(0.01f) - worldBezier.Evaluate(0f)), startConeSize);
            Handles.color = Color.magenta;
            Handles.ConeCap(0, worldBezier.Evaluate(1f), Quaternion.LookRotation(worldBezier.Evaluate(1f) - worldBezier.Evaluate(1f - 0.01f)), endConeSize);
        }

        // draw tangent lines
        if (!settings.HideTangentLines)
        {
            Handles.color = Color.cyan;
            for (int i = 0; i < worldBezier.Knots.Count - 1; i++)
            {
                Handles.DrawDottedLine(worldBezier.Knots[i], worldBezier.Knots[i + 1], 7.5f);
            }
        }

        // Draw knot labels
        var knotLabelStyle = new GUIStyle();

        knotLabelStyle.fontStyle     = FontStyle.Bold;
        knotLabelStyle.fontSize      = 17;
        knotLabelStyle.alignment     = TextAnchor.UpperRight;
        knotLabelStyle.contentOffset = new Vector2(25f, -50f);

        for (int i = 0; i < worldBezier.Knots.Count; i++)
        {
            knotLabelStyle.normal.textColor = PathEditorUtility.GetTColor((float)i / worldBezier.Knots.Count);
            Handles.Label(worldBezier.Knots[i], i.ToString(), knotLabelStyle);
        }

        // test t
        if (settings.TestInterpolate)
        {
            PathEditorUtility.DrawTestInterpolate(worldBezier, settings.EditorData.T);
        }

        // draw GUI
        InterpolateSceneGUI();
        ToolShelf();
    }
Пример #3
0
    private void UpdateLineRendererVertices()
    {
        if (vertexCount < 0)
            vertexCount = 0;

        lineRenderer.SetVertexCount(vertexCount);

        var vertices = new EvaluationCache(path, vertexCount - 2).Values;
        for (int i = 0; i < vertices.Length; i++)
            lineRenderer.SetPosition(i, vertices[i]);
    }
Пример #4
0
    private void Draw()
    {
        CubicBezier worldBezier = cubicBezierPath.WorldSpaceBezier;

        // draw bezier
        Vector3[] cPointCache = new EvaluationCache(worldBezier, CubicBezier.GoodNumMidPoints).Values;

        /*Handles.color = Color.yellow;
         * Handles.DrawAAPolyLine(cPointCache);
         */
        for (int i = 0; i < cPointCache.Length - 1; i++)
        {
            Handles.color = Color.Lerp(Color.yellow, Color.magenta, (float)i / cPointCache.Length);
            var lineSegment = new Vector3[2];
            lineSegment[0] = cPointCache[i];
            lineSegment[1] = cPointCache[i + 1];
            Handles.DrawAAPolyLine(lineSegment);
        }

        // draw direction cone cap
        if (!settings.HideDirectionCones && targetScript.transform.lossyScale != Vector3.zero) //check for zero vector, since LookRotation logs messages
        {
            float startConeSize = PathEditorUtility.Nice3DHandleSize(worldBezier.Evaluate(0f));
            float endConeSize   = PathEditorUtility.Nice3DHandleSize(worldBezier.Evaluate(1f));

            Handles.color = Color.yellow;
            Handles.ConeCap(0, worldBezier.Evaluate(0f), Quaternion.LookRotation(worldBezier.Tangent(0f)), startConeSize);
            Handles.color = Color.magenta;
            Handles.ConeCap(0, worldBezier.Evaluate(1f), Quaternion.LookRotation(worldBezier.Tangent(1f)), endConeSize);
        }

        // draw tangent lines
        if (!settings.HideTangentLines)
        {
            Handles.color = Color.cyan;
            Handles.DrawDottedLine(worldBezier.StartPosition, worldBezier.StartTangent, 7.5f);
            Handles.DrawDottedLine(worldBezier.EndPosition, worldBezier.EndTangent, 7.5f);
        }

        // test t
        if (settings.TestInterpolate)
        {
            PathEditorUtility.DrawTestInterpolate(worldBezier, settings.EditorData.T);
        }

        // draw GUI
        InterpolateSceneGUI();
        ToolShelf();
    }
Пример #5
0
    private void UpdateLineRendererVertices()
    {
        if (vertexCount < 0)
        {
            vertexCount = 0;
        }

        lineRenderer.SetVertexCount(vertexCount);

        var vertices = new EvaluationCache(path, vertexCount - 2).Values;

        for (int i = 0; i < vertices.Length; i++)
        {
            lineRenderer.SetPosition(i, vertices[i]);
        }
    }
    private void Draw()
    {
        QuadraticBezier worldBezier = qdrBezierPath.WorldSpaceBezier;
        var             cPointCache = new EvaluationCache(worldBezier, QuadraticBezier.GoodNumMidPoints).Values;

        // draw bezier
        PathEditorUtility.DrawSplineInScene(cPointCache);

        // draw direction cone cap
        if (!settings.HideDirectionCones &&
            targetScript.transform.lossyScale != Vector3.zero)         // also hide cones if virtually a dot
        {
            float startConeSize = PathEditorUtility.Nice3DHandleSize(worldBezier.Evaluate(0f));
            float endConeSize   = PathEditorUtility.Nice3DHandleSize(worldBezier.Evaluate(1f));

            Handles.color = Color.yellow;
            Handles.ConeCap(0, worldBezier.Evaluate(0f), Quaternion.LookRotation(worldBezier.Evaluate(0.01f) - worldBezier.Evaluate(0f)), startConeSize);
            Handles.color = Color.magenta;
            Handles.ConeCap(0, worldBezier.Evaluate(1f), Quaternion.LookRotation(worldBezier.Evaluate(1f) - worldBezier.Evaluate(1f - 0.01f)), endConeSize);
        }

        // draw tangent lines
        if (!settings.HideTangentLines)
        {
            Handles.color = Color.cyan;
            Handles.DrawDottedLine(worldBezier.StartPosition, worldBezier.MidTangent, 7.5f);
            Handles.DrawDottedLine(worldBezier.MidTangent, worldBezier.EndPosition, 7.5f);
        }

        // test t
        if (settings.TestInterpolate)
        {
            PathEditorUtility.DrawTestInterpolate(worldBezier, settings.EditorData.T);
        }

        // draw GUI
        InterpolateSceneGUI();
        ToolShelf();
    }
 public EvaluationRootFolderViewModel(VehicleViewModel vehicle)
     : base("root", vehicle.Vin.ToUpper())
 {
     Children.Add(new VehicleEvaluationRootFolderViewModel(
                      EvaluationCache.Get(vehicle.Vin), vehicle));
 }
    private void Draw()
    {
        QuadraticBezier worldBezier = qdrBezierPath.WorldSpaceBezier;
        var cPointCache = new EvaluationCache(worldBezier, QuadraticBezier.GoodNumMidPoints).Values;

        // draw bezier
        PathEditorUtility.DrawSplineInScene(cPointCache);

        // draw direction cone cap
        if (!settings.HideDirectionCones
                && targetScript.transform.lossyScale != Vector3.zero)  // also hide cones if virtually a dot
        {
            float startConeSize = PathEditorUtility.Nice3DHandleSize(worldBezier.Evaluate(0f));
            float endConeSize = PathEditorUtility.Nice3DHandleSize(worldBezier.Evaluate(1f));

            Handles.color = Color.yellow;
            Handles.ConeCap(0, worldBezier.Evaluate(0f), Quaternion.LookRotation(worldBezier.Evaluate(0.01f) - worldBezier.Evaluate(0f)), startConeSize);
            Handles.color = Color.magenta;
            Handles.ConeCap(0, worldBezier.Evaluate(1f), Quaternion.LookRotation(worldBezier.Evaluate(1f) - worldBezier.Evaluate(1f - 0.01f)), endConeSize);
        }

        // draw tangent lines
        if (!settings.HideTangentLines)
        {
            Handles.color = Color.cyan;
            Handles.DrawDottedLine(worldBezier.StartPosition, worldBezier.MidTangent, 7.5f);
            Handles.DrawDottedLine(worldBezier.MidTangent, worldBezier.EndPosition, 7.5f);
        }

        // test t
        if (settings.TestInterpolate)
            PathEditorUtility.DrawTestInterpolate(worldBezier, settings.EditorData.T);

        // draw GUI
        InterpolateSceneGUI();
        ToolShelf();
    }
    private void Draw()
    {
        Vector3 startPoint = circlePath.Evaluate(0f);
        Vector3 endPoint = circlePath.Evaluate(1f);
        CirclePath reducedCirclePath = new CirclePath(
            circlePath.LocalSpaceTransform,
            new Circle(circlePath.LocalCircle.Center, circlePath.LocalCircle.Radius),
            circlePath.MaxAngle % Circle.TwoPI // remove loops
            );
        if (circlePath.MaxAngle >= Circle.TwoPI) // add back a single loop if it loops
            reducedCirclePath.MaxAngle += Circle.TwoPI;
        else if (Mathf.Abs(circlePath.MaxAngle) >= Circle.TwoPI) // if negative maxAngle and is still at least one loop
            reducedCirclePath.MaxAngle -= Circle.TwoPI;

        // draw circle
        var cPointCache = new EvaluationCache(reducedCirclePath, 128).Values;
        /*Handles.color = Color.yellow;
        Handles.DrawAAPolyLine(cPointCache);
        */
        for (int i = 0; i < cPointCache.Length - 1; i++)
        {
            Handles.color = Color.Lerp(Color.yellow, Color.magenta, (float)i / cPointCache.Length);
            var lineSegment = new Vector3[2];
            lineSegment[0] = cPointCache[i];
            lineSegment[1] = cPointCache[i + 1];
            Handles.DrawAAPolyLine(lineSegment);
        }

        // draw direction cone cap
        if (!settings.HideDirectionCones
            && circlePath.LocalSpaceTransform.lossyScale != Vector3.zero
            && circlePath.LocalCircle.Radius != 0f
            && Mathf.Abs(reducedCirclePath.MaxAngle * Mathf.Rad2Deg) > 10.0f) // also hide cones if virtually a dot
        {
            float startConeSize = PathEditorUtility.Nice3DHandleSize(startPoint);
            float endConeSize = PathEditorUtility.Nice3DHandleSize(endPoint);

            Handles.color = Color.yellow;
            Handles.ConeCap(0, startPoint, Quaternion.LookRotation(circlePath.Tangent(0f)), startConeSize);
            Handles.color = Color.magenta;
            Handles.ConeCap(0, endPoint, Quaternion.LookRotation(circlePath.Tangent(1f)), endConeSize);
        }

        // test t
        if (settings.TestInterpolate)
            PathEditorUtility.DrawTestInterpolate(circlePath, settings.EditorData.T);

        #region Scene View GUI

        Handles.BeginGUI(); //Note: GUILayout.BeginArea() deprecates Handles, however it behaves incorrectly (debug lines offset)
        {
            GUILayout.BeginHorizontal(GUILayout.Width(Screen.width));
            {
                GUILayout.Space(20.0f);
                targetScript.EditorOnlyToolSettings.TestInterpolate
                    = GUILayout.Toggle(targetScript.EditorOnlyToolSettings.TestInterpolate, "Test Interpolate", GUILayout.ExpandWidth(false));
                if (targetScript.EditorOnlyToolSettings.TestInterpolate)
                {
                    settings.EditorData.T
                        = GUILayout.HorizontalSlider(settings.EditorData.T, 0f, 1.0f, GUILayout.Width(100.0f));
                    GUILayout.Label(settings.EditorData.T.ToString(), GUILayout.Width(75.0f));
                    GUILayout.Label("Custom: ", GUILayout.Width(60.0f));
                    settings.EditorData.CustomT
                        = GUILayout.TextField(settings.EditorData.CustomT, GUILayout.Width(100.0f));
                    if (Event.current.keyCode == KeyCode.Return)
                    {
                        float tempT;
                        if (System.Single.TryParse(settings.EditorData.CustomT, out tempT))
                            settings.EditorData.T = tempT;
                    }
                }
            }
            GUILayout.EndHorizontal();
        }

        Handles.EndGUI();

        #endregion Scene View GUI

        ToolShelf();
    }
 /// <summary>
 ///     Initialize runtime arguments
 /// </summary>
 public RuntimeEventArgs()
 {
     this._contexts = new Stack<IContext>();
     this._contextMatchCache = new EvaluationCache<IContext, bool>();
     this._conditionEvalCache = new EvaluationCache<ICondition, bool>();
 }
    private void Draw()
    {
        var worldBezier = targetPath.WorldSpaceBezier;
        var vertexCount = DynamicBezier.GoodNumMidPoints * worldBezier.Knots.Count;
        vertexCount /= 2;
        var cPointCache = new EvaluationCache(worldBezier, vertexCount).Values;

        // draw bezier
        PathEditorUtility.DrawSplineInScene(cPointCache);

        // draw direction cone cap
        if (!settings.HideDirectionCones
            && targetScript.transform.lossyScale != Vector3.zero
            && targetPath.LocalBezier.Knots.Count > 1)  // also hide cones if virtually a dot
        {
            float startConeSize = PathEditorUtility.Nice3DHandleSize(worldBezier.Evaluate(0f));
            float endConeSize = PathEditorUtility.Nice3DHandleSize(worldBezier.Evaluate(1f));

            Handles.color = Color.yellow;
            Handles.ConeCap(0, worldBezier.Evaluate(0f), Quaternion.LookRotation(worldBezier.Evaluate(0.01f) - worldBezier.Evaluate(0f)), startConeSize);
            Handles.color = Color.magenta;
            Handles.ConeCap(0, worldBezier.Evaluate(1f), Quaternion.LookRotation(worldBezier.Evaluate(1f) - worldBezier.Evaluate(1f - 0.01f)), endConeSize);
        }

        // draw tangent lines
        if (!settings.HideTangentLines)
        {
            Handles.color = Color.cyan;
            for (int i = 0; i < worldBezier.Knots.Count - 1; i++)
                Handles.DrawDottedLine(worldBezier.Knots[i], worldBezier.Knots[i + 1], 7.5f);
        }

        // Draw knot labels
        var knotLabelStyle = new GUIStyle();
        knotLabelStyle.fontStyle = FontStyle.Bold;
        knotLabelStyle.fontSize = 17;
        knotLabelStyle.alignment = TextAnchor.UpperRight;
        knotLabelStyle.contentOffset = new Vector2(25f, -50f);

        for (int i = 0; i < worldBezier.Knots.Count; i++)
        {
            knotLabelStyle.normal.textColor = PathEditorUtility.GetTColor((float)i / worldBezier.Knots.Count);
            Handles.Label(worldBezier.Knots[i], i.ToString(), knotLabelStyle);
        }

        // test t
        if (settings.TestInterpolate)
            PathEditorUtility.DrawTestInterpolate(worldBezier, settings.EditorData.T);

        // draw GUI
        InterpolateSceneGUI();
        ToolShelf();
    }
Пример #12
0
    private void Draw()
    {
        Vector3    startPoint        = circlePath.Evaluate(0f);
        Vector3    endPoint          = circlePath.Evaluate(1f);
        CirclePath reducedCirclePath = new CirclePath(
            circlePath.LocalSpaceTransform,
            new Circle(circlePath.LocalCircle.Center, circlePath.LocalCircle.Radius),
            circlePath.MaxAngle % Circle.TwoPI // remove loops
            );

        if (circlePath.MaxAngle >= Circle.TwoPI) // add back a single loop if it loops
        {
            reducedCirclePath.MaxAngle += Circle.TwoPI;
        }
        else if (Mathf.Abs(circlePath.MaxAngle) >= Circle.TwoPI) // if negative maxAngle and is still at least one loop
        {
            reducedCirclePath.MaxAngle -= Circle.TwoPI;
        }

        // draw circle
        var cPointCache = new EvaluationCache(reducedCirclePath, 128).Values;

        /*Handles.color = Color.yellow;
         * Handles.DrawAAPolyLine(cPointCache);
         */
        for (int i = 0; i < cPointCache.Length - 1; i++)
        {
            Handles.color = Color.Lerp(Color.yellow, Color.magenta, (float)i / cPointCache.Length);
            var lineSegment = new Vector3[2];
            lineSegment[0] = cPointCache[i];
            lineSegment[1] = cPointCache[i + 1];
            Handles.DrawAAPolyLine(lineSegment);
        }

        // draw direction cone cap
        if (!settings.HideDirectionCones &&
            circlePath.LocalSpaceTransform.lossyScale != Vector3.zero &&
            circlePath.LocalCircle.Radius != 0f &&
            Mathf.Abs(reducedCirclePath.MaxAngle * Mathf.Rad2Deg) > 10.0f)    // also hide cones if virtually a dot
        {
            float startConeSize = PathEditorUtility.Nice3DHandleSize(startPoint);
            float endConeSize   = PathEditorUtility.Nice3DHandleSize(endPoint);

            Handles.color = Color.yellow;
            Handles.ConeCap(0, startPoint, Quaternion.LookRotation(circlePath.Tangent(0f)), startConeSize);
            Handles.color = Color.magenta;
            Handles.ConeCap(0, endPoint, Quaternion.LookRotation(circlePath.Tangent(1f)), endConeSize);
        }

        // test t
        if (settings.TestInterpolate)
        {
            PathEditorUtility.DrawTestInterpolate(circlePath, settings.EditorData.T);
        }

        #region Scene View GUI

        Handles.BeginGUI(); //Note: GUILayout.BeginArea() deprecates Handles, however it behaves incorrectly (debug lines offset)
        {
            GUILayout.BeginHorizontal(GUILayout.Width(Screen.width));
            {
                GUILayout.Space(20.0f);
                targetScript.EditorOnlyToolSettings.TestInterpolate
                    = GUILayout.Toggle(targetScript.EditorOnlyToolSettings.TestInterpolate, "Test Interpolate", GUILayout.ExpandWidth(false));
                if (targetScript.EditorOnlyToolSettings.TestInterpolate)
                {
                    settings.EditorData.T
                        = GUILayout.HorizontalSlider(settings.EditorData.T, 0f, 1.0f, GUILayout.Width(100.0f));
                    GUILayout.Label(settings.EditorData.T.ToString(), GUILayout.Width(75.0f));
                    GUILayout.Label("Custom: ", GUILayout.Width(60.0f));
                    settings.EditorData.CustomT
                        = GUILayout.TextField(settings.EditorData.CustomT, GUILayout.Width(100.0f));
                    if (Event.current.keyCode == KeyCode.Return)
                    {
                        float tempT;
                        if (System.Single.TryParse(settings.EditorData.CustomT, out tempT))
                        {
                            settings.EditorData.T = tempT;
                        }
                    }
                }
            }
            GUILayout.EndHorizontal();
        }

        Handles.EndGUI();

        #endregion Scene View GUI

        ToolShelf();
    }