Ejemplo n.º 1
0
        /// <summary>User has clicked an axis.</summary>
        /// <param name="axisType">Type of the axis.</param>
        private void OnAxisClick(Axis.AxisType axisType)
        {
            if (currentPresenter != null)
            {
                currentPresenter.Detach();
            }

            AxisPresenter axisPresenter = new AxisPresenter();

            currentPresenter = axisPresenter;
            AxisView a         = new AxisView(graphView as GraphView);
            string   dimension = (axisType == Axis.AxisType.Left || axisType == Axis.AxisType.Right) ? "Y" : "X";

            graphView.ShowEditorPanel(a.MainWidget, dimension + "-Axis options");
            axisPresenter.Attach(GetAxis(axisType), a, explorerPresenter);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add regression line and stats to graph
        /// </summary>
        /// <param name="graphView">The graph to add line and stats to</param>
        /// <param name="stats">The regression stats</param>
        /// <param name="xAxis">The associated x axis</param>
        /// <param name="yAxis">The associated y axis</param>
        /// <param name="colour">The color to use</param>
        /// <param name="seriesIndex">The series index</param>
        private static void AddRegressionToGraph(IGraphView graphView,
                                                 MathUtilities.RegrStats stats,
                                                 Axis.AxisType xAxis, Axis.AxisType yAxis,
                                                 Color colour,
                                                 int seriesIndex)
        {
            if (stats != null)
            {
                double minimumX = graphView.AxisMinimum(xAxis);
                double maximumX = graphView.AxisMaximum(xAxis);
                double minimumY = graphView.AxisMinimum(yAxis);
                double maximumY = graphView.AxisMaximum(yAxis);

                double[] regressionX = new double[] { minimumX, maximumX };
                double[] regressionY = new double[] { stats.m *minimumX + stats.c, stats.m *maximumX + stats.c };
                graphView.DrawLineAndMarkers("", regressionX, regressionY,
                                             xAxis, yAxis, colour,
                                             Series.LineType.Solid, Series.MarkerType.None, true);

                // Show the 1:1 line
                double   lowestAxisScale  = Math.Min(minimumX, minimumY);
                double   largestAxisScale = Math.Max(maximumX, maximumY);
                double[] oneToOne         = new double[] { lowestAxisScale, largestAxisScale };
                graphView.DrawLineAndMarkers("", oneToOne, oneToOne,
                                             xAxis, yAxis, colour,
                                             Series.LineType.Dash, Series.MarkerType.None, true);

                // Draw the equation.
                double interval  = (largestAxisScale - lowestAxisScale) / 13;
                double yPosition = largestAxisScale - seriesIndex * interval;

                string equation = string.Format("y = {0:F2} x + {1:F2}, r2 = {2:F2}, n = {3:F0}\r\n" +
                                                "NSE = {4:F2}, ME = {5:F2}, MAE = {6:F2}\r\n" +
                                                "RSR = {7:F2}, RMSD = {8:F2}",
                                                new object[] { stats.m,
                                                               stats.c,
                                                               stats.R2,
                                                               stats.n,
                                                               stats.NSE,
                                                               stats.ME,
                                                               stats.MAE,
                                                               stats.RSR,
                                                               stats.RMSD });
                graphView.DrawText(equation, lowestAxisScale, yPosition, xAxis, yAxis, colour);
            }
        }
Ejemplo n.º 3
0
        public Axis AddAxis(String AxisName, Axis.AxisType type, float sensitivity = 1.0f)
        {
            Axis a = new Axis(this, AxisName, type, sensitivity);

            if (type == Axis.AxisType.Mouse && this.isMouseAxisAdded)
            {
                throw new Exception("Mouse-Axis can only be added once!");
            }

            this.axises.Add(a);

            if (type == Axis.AxisType.Mouse)
            {
                this.isMouseAxisAdded = true;
            }
            return(a);
        }
        private AstNode ParseNodeTest(AstNode qyInput, Axis.AxisType axisType, XPathNodeType nodeType)
        {
            string stringValue;
            string prefix;

            XPathScanner.LexKind kind = this.scanner.Kind;
            if (kind != XPathScanner.LexKind.Star)
            {
                if (kind != XPathScanner.LexKind.Name)
                {
                    throw XPathException.Create("Xp_NodeSetExpected", this.scanner.SourceText);
                }
                if (this.scanner.CanBeFunction && IsNodeType(this.scanner))
                {
                    prefix      = string.Empty;
                    stringValue = string.Empty;
                    nodeType    = (this.scanner.Name == "comment") ? XPathNodeType.Comment : ((this.scanner.Name == "text") ? XPathNodeType.Text : ((this.scanner.Name == "node") ? XPathNodeType.All : ((this.scanner.Name == "processing-instruction") ? XPathNodeType.ProcessingInstruction : XPathNodeType.Root)));
                    this.NextLex();
                    this.PassToken(XPathScanner.LexKind.LParens);
                    if ((nodeType == XPathNodeType.ProcessingInstruction) && (this.scanner.Kind != XPathScanner.LexKind.RParens))
                    {
                        this.CheckToken(XPathScanner.LexKind.String);
                        stringValue = this.scanner.StringValue;
                        this.NextLex();
                    }
                    this.PassToken(XPathScanner.LexKind.RParens);
                }
                else
                {
                    prefix      = this.scanner.Prefix;
                    stringValue = this.scanner.Name;
                    this.NextLex();
                    if (stringValue == "*")
                    {
                        stringValue = string.Empty;
                    }
                }
            }
            else
            {
                prefix      = string.Empty;
                stringValue = string.Empty;
                this.NextLex();
            }
            return(new Axis(axisType, qyInput, prefix, stringValue, nodeType));
        }
Ejemplo n.º 5
0
        //>> Step ::= '.' | '..' | ( AxisName '::' | '@' )? NodeTest Predicate*
        private AstNode ParseStep(AstNode?qyInput)
        {
            AstNode opnd;

            if (XPathScanner.LexKind.Dot == _scanner.Kind)
            {         //>> '.'
                NextLex();
                opnd = new Axis(Axis.AxisType.Self, qyInput);
            }
            else if (XPathScanner.LexKind.DotDot == _scanner.Kind)
            { //>> '..'
                NextLex();
                opnd = new Axis(Axis.AxisType.Parent, qyInput);
            }
            else
            {                                                          //>> ( AxisName '::' | '@' )? NodeTest Predicate*
                Axis.AxisType axisType = Axis.AxisType.Child;
                switch (_scanner.Kind)
                {
                case XPathScanner.LexKind.At:                                   //>> '@'
                    axisType = Axis.AxisType.Attribute;
                    NextLex();
                    break;

                case XPathScanner.LexKind.Axe:                                  //>> AxisName '::'
                    axisType = GetAxis();
                    NextLex();
                    break;
                }
                XPathNodeType nodeType = (
                    axisType == Axis.AxisType.Attribute ? XPathNodeType.Attribute :
                    //                    axisType == Axis.AxisType.Namespace ? XPathNodeType.Namespace : // No Idea why it's this way but otherwise Axes doesn't work
                    /* default: */ XPathNodeType.Element
                    );

                opnd = ParseNodeTest(qyInput, axisType, nodeType);

                while (XPathScanner.LexKind.LBracket == _scanner.Kind)
                {
                    opnd = new Filter(opnd, ParsePredicate(opnd));
                }
            }
            return(opnd);
        }
        //>> Step ::= '.' | '..' | ( AxisName '::' | '@' )? NodeTest Predicate*
        private AstNode ParseStep(AstNode qyInput)
        {
            AstNode opnd;

            if (XPathScanner.LexKind.Dot == this.scanner.Kind)           //>> '.'
            {
                NextLex();
                opnd = new Axis(Axis.AxisType.Self, qyInput);
            }
            else if (XPathScanner.LexKind.DotDot == this.scanner.Kind)   //>> '..'
            {
                NextLex();
                opnd = new Axis(Axis.AxisType.Parent, qyInput);
            }
            else                                                            //>> ( AxisName '::' | '@' )? NodeTest Predicate*
            {
                Axis.AxisType axisType = Axis.AxisType.Child;
                switch (this.scanner.Kind)
                {
                case XPathScanner.LexKind.At:                               //>> '@'
                    axisType = Axis.AxisType.Attribute;
                    NextLex();
                    break;

                case XPathScanner.LexKind.Axe:                              //>> AxisName '::'
                    axisType = GetAxis(this.scanner);
                    NextLex();
                    break;
                }
                XPathNodeType nodeType = (
                    axisType == Axis.AxisType.Attribute ? XPathNodeType.Attribute :
                    /* default: */ XPathNodeType.Element
                    );

                opnd = ParseNodeTest(qyInput, axisType, nodeType);

                while (XPathScanner.LexKind.LBracket == this.scanner.Kind)
                {
                    opnd = new Filter(opnd, ParsePredicate(opnd));
                }
            }
            return(opnd);
        }
Ejemplo n.º 7
0
 /// <summary>Constructor</summary>
 /// <param name="title">The series title.</param>
 /// <param name="colour">The series colour.</param>
 /// <param name="line">The series line type.</param>
 /// <param name="marker">The series marker type.</param>
 /// <param name="showInLegend">Show series in legend?</param>
 /// <param name="type">The series type.</param>
 /// <param name="xAxis">The location of the x axis.</param>
 /// <param name="yAxis">The location of the y axis.</param>
 /// <param name="x">X data points.</param>
 /// <param name="y">Y data points.</param>
 public SeriesDefinition(string title,
                         Color colour,
                         double[] x, double[] y,
                         LineType line       = LineType.Solid,
                         MarkerType marker   = MarkerType.None,
                         bool showInLegend   = true,
                         SeriesType type     = SeriesType.Scatter,
                         Axis.AxisType xAxis = Axis.AxisType.Bottom,
                         Axis.AxisType yAxis = Axis.AxisType.Left)
 {
     this.Title        = title;
     this.Colour       = colour;
     this.Line         = line;
     this.Marker       = marker;
     this.ShowInLegend = showInLegend;
     this.Type         = type;
     this.XAxis        = xAxis;
     this.YAxis        = yAxis;
     this.X            = x;
     this.Y            = y;
 }
Ejemplo n.º 8
0
        public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
        {
            Rect drawRect = pos;

            drawRect.height = EditorGUIUtility.singleLineHeight;

            SerializedProperty m_Show          = prop.FindPropertyRelative("m_Show");
            SerializedProperty m_Type          = prop.FindPropertyRelative("m_Type");
            SerializedProperty m_SplitNumber   = prop.FindPropertyRelative("m_SplitNumber");
            SerializedProperty m_TextRotation  = prop.FindPropertyRelative("m_TextRotation");
            SerializedProperty m_ShowSplitLine = prop.FindPropertyRelative("m_ShowSplitLine");
            SerializedProperty m_SplitLineType = prop.FindPropertyRelative("m_SplitLineType");
            SerializedProperty m_BoundaryGap   = prop.FindPropertyRelative("m_BoundaryGap");
            SerializedProperty m_Data          = prop.FindPropertyRelative("m_Data");
            SerializedProperty m_AxisTick      = prop.FindPropertyRelative("m_AxisTick");
            SerializedProperty m_MinMaxType    = prop.FindPropertyRelative("m_MinMaxType");
            SerializedProperty m_Min           = prop.FindPropertyRelative("m_Min");
            SerializedProperty m_Max           = prop.FindPropertyRelative("m_Max");

            ChartEditorHelper.MakeFoldout(ref drawRect, ref m_AxisModuleToggle, prop.displayName, m_Show);
            drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            if (m_AxisModuleToggle)
            {
                Axis.AxisType type = (Axis.AxisType)m_Type.enumValueIndex;
                EditorGUI.indentLevel++;
                EditorGUI.PropertyField(drawRect, m_Type);
                drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                if (type == Axis.AxisType.Value)
                {
                    EditorGUI.PropertyField(drawRect, m_MinMaxType);
                    drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                    Axis.AxisMinMaxType minMaxType = (Axis.AxisMinMaxType)m_MinMaxType.enumValueIndex;
                    switch (minMaxType)
                    {
                    case Axis.AxisMinMaxType.Default:
                        break;

                    case Axis.AxisMinMaxType.MinMax:
                        break;

                    case Axis.AxisMinMaxType.Custom:
                        EditorGUI.indentLevel++;
                        EditorGUI.PropertyField(drawRect, m_Min);
                        drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                        EditorGUI.PropertyField(drawRect, m_Max);
                        drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                        EditorGUI.indentLevel--;
                        break;
                    }
                }
                EditorGUI.PropertyField(drawRect, m_SplitNumber);
                drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                EditorGUI.PropertyField(drawRect, m_TextRotation);
                drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                if (m_ShowSplitLine.boolValue)
                {
                    drawRect.width = EditorGUIUtility.labelWidth + 10;
                    EditorGUI.PropertyField(drawRect, m_ShowSplitLine);
                    //drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                    drawRect.x     = EditorGUIUtility.labelWidth + 35;
                    drawRect.width = EditorGUIUtility.currentViewWidth - EditorGUIUtility.labelWidth - 55;
                    EditorGUI.PropertyField(drawRect, m_SplitLineType, GUIContent.none);
                    drawRect.x     = pos.x;
                    drawRect.width = pos.width;
                    drawRect.y    += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                }
                else
                {
                    EditorGUI.PropertyField(drawRect, m_ShowSplitLine);
                    drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                }
                EditorGUI.PropertyField(drawRect, m_BoundaryGap);
                drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                EditorGUI.PropertyField(drawRect, m_AxisTick);
                drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                drawRect.y += EditorGUI.GetPropertyHeight(m_AxisTick);

                if (type == Axis.AxisType.Category)
                {
                    drawRect.width = EditorGUIUtility.labelWidth + 10;
                    m_DataFoldout  = EditorGUI.Foldout(drawRect, m_DataFoldout, "Data");
                    ChartEditorHelper.MakeJsonData(ref drawRect, ref m_ShowJsonDataArea, ref m_JsonDataAreaText, prop);
                    drawRect.width = pos.width;
                    if (m_DataFoldout)
                    {
                        ChartEditorHelper.MakeList(ref drawRect, ref m_DataSize, m_Data);
                    }
                }
                EditorGUI.indentLevel--;
            }
        }
Ejemplo n.º 9
0
        public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
        {
            base.OnGUI(pos, prop, label);
            if (MakeFoldout(prop, "m_Show"))
            {
                SerializedProperty m_Type       = prop.FindPropertyRelative("m_Type");
                SerializedProperty m_LogBase    = prop.FindPropertyRelative("m_LogBase");
                SerializedProperty m_MinMaxType = prop.FindPropertyRelative("m_MinMaxType");
                Axis.AxisType      type         = (Axis.AxisType)m_Type.enumValueIndex;
                var chart   = prop.serializedObject.targetObject as BaseChart;
                var isPolar = chart is PolarChart;
                EditorGUI.indentLevel++;
                PropertyField(prop, isPolar ? "m_PolarIndex" : "m_GridIndex");
                PropertyField(prop, "m_Type");
                PropertyField(prop, "m_Position");
                PropertyField(prop, "m_Offset");
                if (type == Axis.AxisType.Log)
                {
                    PropertyField(prop, "m_LogBaseE");
                    EditorGUI.BeginChangeCheck();
                    PropertyField(prop, "m_LogBase");
                    if (m_LogBase.floatValue <= 0 || m_LogBase.floatValue == 1)
                    {
                        m_LogBase.floatValue = 10;
                    }
                    EditorGUI.EndChangeCheck();
                }
                if (type == Axis.AxisType.Value || type == Axis.AxisType.Time)
                {
                    PropertyField(prop, "m_MinMaxType");
                    Axis.AxisMinMaxType minMaxType = (Axis.AxisMinMaxType)m_MinMaxType.enumValueIndex;
                    switch (minMaxType)
                    {
                    case Axis.AxisMinMaxType.Default:
                        break;

                    case Axis.AxisMinMaxType.MinMax:
                        break;

                    case Axis.AxisMinMaxType.Custom:
                        EditorGUI.indentLevel++;
                        PropertyField(prop, "m_Min");
                        PropertyField(prop, "m_Max");
                        EditorGUI.indentLevel--;
                        break;
                    }
                    PropertyField(prop, "m_CeilRate");
                    if (type == Axis.AxisType.Value)
                    {
                        PropertyField(prop, "m_Inverse");
                    }
                }
                PropertyField(prop, "m_SplitNumber");
                if (type == Axis.AxisType.Category)
                {
                    PropertyField(prop, "m_InsertDataToHead");
                    PropertyField(prop, "m_MaxCache");
                    PropertyField(prop, "m_BoundaryGap");
                }
                else
                {
                    PropertyField(prop, "m_Interval");
                }
                DrawExtendeds(prop);
                PropertyField(prop, "m_AxisLine");
                PropertyField(prop, "m_AxisName");
                PropertyField(prop, "m_AxisTick");
                PropertyField(prop, "m_AxisLabel");
                PropertyField(prop, "m_SplitLine");
                PropertyField(prop, "m_SplitArea");

                if (type == Axis.AxisType.Category)
                {
                    PropertyListField(prop, "m_Data", true);
                }
                EditorGUI.indentLevel--;
            }
        }
Ejemplo n.º 10
0
        public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
        {
            base.OnGUI(pos, prop, label);
            if (MakeFoldout(prop, "m_Show"))
            {
                SerializedProperty m_Type       = prop.FindPropertyRelative("m_Type");
                SerializedProperty m_LogBase    = prop.FindPropertyRelative("m_LogBase");
                SerializedProperty m_Data       = prop.FindPropertyRelative("m_Data");
                SerializedProperty m_MinMaxType = prop.FindPropertyRelative("m_MinMaxType");
                Axis.AxisType      type         = (Axis.AxisType)m_Type.enumValueIndex;
                var chart   = prop.serializedObject.targetObject as BaseChart;
                var isPolar = chart is PolarChart;
                EditorGUI.indentLevel++;
                PropertyField(prop, isPolar ? "m_PolarIndex" : "m_GridIndex");
                PropertyField(prop, "m_Type");
                PropertyField(prop, "m_Position");
                PropertyField(prop, "m_Offset");
                if (type == Axis.AxisType.Log)
                {
                    PropertyField(prop, "m_LogBaseE");
                    EditorGUI.BeginChangeCheck();
                    PropertyField(prop, "m_LogBase");
                    if (m_LogBase.floatValue <= 0 || m_LogBase.floatValue == 1)
                    {
                        m_LogBase.floatValue = 10;
                    }
                    EditorGUI.EndChangeCheck();
                }
                if (type == Axis.AxisType.Value)
                {
                    PropertyField(prop, "m_MinMaxType");
                    Axis.AxisMinMaxType minMaxType = (Axis.AxisMinMaxType)m_MinMaxType.enumValueIndex;
                    switch (minMaxType)
                    {
                    case Axis.AxisMinMaxType.Default:
                        break;

                    case Axis.AxisMinMaxType.MinMax:
                        break;

                    case Axis.AxisMinMaxType.Custom:
                        EditorGUI.indentLevel++;
                        PropertyField(prop, "m_Min");
                        PropertyField(prop, "m_Max");
                        EditorGUI.indentLevel--;
                        break;
                    }
                    PropertyField(prop, "m_CeilRate");
                    PropertyField(prop, "m_Inverse");
                }
                PropertyField(prop, "m_SplitNumber");
                if (type == Axis.AxisType.Category)
                {
                    PropertyField(prop, "m_BoundaryGap");
                }
                else
                {
                    PropertyField(prop, "m_Interval");
                }
                DrawExtendeds(prop);
                PropertyField(prop, "m_AxisLine");
                PropertyField(prop, "m_AxisName");
                PropertyField(prop, "m_AxisTick");
                PropertyField(prop, "m_AxisLabel");
                PropertyField(prop, "m_SplitLine");
                PropertyField(prop, "m_SplitArea");

                if (type == Axis.AxisType.Category)
                {
                    m_DrawRect.width         = EditorGUIUtility.labelWidth + 10;
                    m_DataToggles[m_KeyName] = EditorGUI.Foldout(m_DrawRect, m_DataToggles[m_KeyName], "Data");
                    AddSingleLineHeight();
                    m_DrawRect.width = pos.width;
                    if (m_DataToggles[m_KeyName])
                    {
                        var height = m_Heights[m_KeyName];
                        ChartEditorHelper.MakeList(ref m_DrawRect, ref height, ref m_DataSize, m_Data);
                        m_Heights[m_KeyName] = height;
                    }
                }
                EditorGUI.indentLevel--;
            }
        }
Ejemplo n.º 11
0
        public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
        {
            Rect drawRect = pos;

            drawRect.height = EditorGUIUtility.singleLineHeight;

            SerializedProperty m_Show        = prop.FindPropertyRelative("m_Show");
            SerializedProperty m_Type        = prop.FindPropertyRelative("m_Type");
            SerializedProperty m_LogBaseE    = prop.FindPropertyRelative("m_LogBaseE");
            SerializedProperty m_LogBase     = prop.FindPropertyRelative("m_LogBase");
            SerializedProperty m_SplitNumber = prop.FindPropertyRelative("m_SplitNumber");
            SerializedProperty m_Interval    = prop.FindPropertyRelative("m_Interval");
            SerializedProperty m_AxisLabel   = prop.FindPropertyRelative("m_AxisLabel");
            SerializedProperty m_BoundaryGap = prop.FindPropertyRelative("m_BoundaryGap");
            SerializedProperty m_Data        = prop.FindPropertyRelative("m_Data");
            SerializedProperty m_AxisLine    = prop.FindPropertyRelative("m_AxisLine");
            SerializedProperty m_AxisName    = prop.FindPropertyRelative("m_AxisName");
            SerializedProperty m_AxisTick    = prop.FindPropertyRelative("m_AxisTick");
            SerializedProperty m_SplitArea   = prop.FindPropertyRelative("m_SplitArea");
            SerializedProperty m_SplitLine   = prop.FindPropertyRelative("m_SplitLine");
            SerializedProperty m_MinMaxType  = prop.FindPropertyRelative("m_MinMaxType");
            SerializedProperty m_Min         = prop.FindPropertyRelative("m_Min");
            SerializedProperty m_Max         = prop.FindPropertyRelative("m_Max");
            SerializedProperty m_CeilRate    = prop.FindPropertyRelative("m_CeilRate");
            SerializedProperty m_Inverse     = prop.FindPropertyRelative("m_Inverse");

            int  index  = InitToggle(prop);
            bool toggle = m_AxisModuleToggle[index];

            m_AxisModuleToggle[index] = ChartEditorHelper.MakeFoldout(ref drawRect, ref toggle,
                                                                      GetDisplayName(prop.displayName), m_Show);
            drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            if (m_AxisModuleToggle[index])
            {
                Axis.AxisType type = (Axis.AxisType)m_Type.enumValueIndex;
                EditorGUI.indentLevel++;
                EditorGUI.PropertyField(drawRect, m_Type);
                drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                if (type == Axis.AxisType.Log)
                {
                    EditorGUI.PropertyField(drawRect, m_LogBaseE);
                    drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                    EditorGUI.BeginChangeCheck();
                    EditorGUI.PropertyField(drawRect, m_LogBase);
                    if (m_LogBase.floatValue <= 0 || m_LogBase.floatValue == 1)
                    {
                        m_LogBase.floatValue = 10;
                    }
                    EditorGUI.EndChangeCheck();
                    drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                }
                if (type == Axis.AxisType.Value)
                {
                    EditorGUI.PropertyField(drawRect, m_MinMaxType);
                    drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                    Axis.AxisMinMaxType minMaxType = (Axis.AxisMinMaxType)m_MinMaxType.enumValueIndex;
                    switch (minMaxType)
                    {
                    case Axis.AxisMinMaxType.Default:
                        break;

                    case Axis.AxisMinMaxType.MinMax:
                        break;

                    case Axis.AxisMinMaxType.Custom:
                        EditorGUI.indentLevel++;
                        EditorGUI.PropertyField(drawRect, m_Min);
                        drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                        EditorGUI.PropertyField(drawRect, m_Max);
                        drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                        EditorGUI.indentLevel--;
                        break;
                    }
                    EditorGUI.PropertyField(drawRect, m_CeilRate);
                    drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                    EditorGUI.PropertyField(drawRect, m_Inverse);
                    drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                }
                EditorGUI.PropertyField(drawRect, m_SplitNumber);
                drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                if (type == Axis.AxisType.Category)
                {
                    EditorGUI.PropertyField(drawRect, m_BoundaryGap);
                    drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                }
                else
                {
                    EditorGUI.PropertyField(drawRect, m_Interval);
                    drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                }
                DrawExtended(ref drawRect, prop);
                EditorGUI.PropertyField(drawRect, m_AxisLine);
                drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                drawRect.y += EditorGUI.GetPropertyHeight(m_AxisLine);
                EditorGUI.PropertyField(drawRect, m_AxisName);
                drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                drawRect.y += EditorGUI.GetPropertyHeight(m_AxisName);
                EditorGUI.PropertyField(drawRect, m_AxisTick);
                drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                drawRect.y += EditorGUI.GetPropertyHeight(m_AxisTick);
                EditorGUI.PropertyField(drawRect, m_AxisLabel);
                drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                drawRect.y += EditorGUI.GetPropertyHeight(m_AxisLabel);
                EditorGUI.PropertyField(drawRect, m_SplitLine);
                drawRect.y += EditorGUI.GetPropertyHeight(m_SplitLine);
                EditorGUI.PropertyField(drawRect, m_SplitArea);
                drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
                drawRect.y += EditorGUI.GetPropertyHeight(m_SplitArea);

                if (type == Axis.AxisType.Category)
                {
                    drawRect.width       = EditorGUIUtility.labelWidth + 10;
                    m_DataFoldout[index] = EditorGUI.Foldout(drawRect, m_DataFoldout[index], "Data");
                    ChartEditorHelper.MakeJsonData(ref drawRect, ref m_ShowJsonDataArea, ref m_JsonDataAreaText, prop, pos.width);
                    drawRect.width = pos.width;
                    if (m_DataFoldout[index])
                    {
                        ChartEditorHelper.MakeList(ref drawRect, ref m_DataSize, m_Data);
                    }
                }
                EditorGUI.indentLevel--;
            }
        }
Ejemplo n.º 12
0
        public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
        {
            int index = InitToggle(prop);

            if (!m_AxisModuleToggle[index])
            {
                return(EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing);
            }
            else
            {
                SerializedProperty m_Type      = prop.FindPropertyRelative("m_Type");
                SerializedProperty m_AxisTick  = prop.FindPropertyRelative("m_AxisTick");
                SerializedProperty m_AxisLine  = prop.FindPropertyRelative("m_AxisLine");
                SerializedProperty m_AxisName  = prop.FindPropertyRelative("m_AxisName");
                SerializedProperty m_AxisLabel = prop.FindPropertyRelative("m_AxisLabel");
                SerializedProperty m_SplitArea = prop.FindPropertyRelative("m_SplitArea");
                SerializedProperty m_SplitLine = prop.FindPropertyRelative("m_SplitLine");
                float height = 0;
                height += 10 * EditorGUIUtility.singleLineHeight + 9 * EditorGUIUtility.standardVerticalSpacing;
                Axis.AxisType type = (Axis.AxisType)m_Type.enumValueIndex;
                if (type == Axis.AxisType.Category)
                {
                    if (m_DataFoldout[index])
                    {
                        SerializedProperty m_Data = prop.FindPropertyRelative("m_Data");
                        int num = m_Data.arraySize + 2;
                        if (num > 30)
                        {
                            num = 14;
                        }
                        height += num * EditorGUIUtility.singleLineHeight + (num - 1) * EditorGUIUtility.standardVerticalSpacing;
                        height += EditorGUIUtility.standardVerticalSpacing;
                    }
                    else
                    {
                        height += 0 * EditorGUIUtility.singleLineHeight + 0 * EditorGUIUtility.standardVerticalSpacing;
                    }
                    if (m_ShowJsonDataArea)
                    {
                        height += EditorGUIUtility.singleLineHeight * 3 + EditorGUIUtility.standardVerticalSpacing;
                    }
                }
                else if (type == Axis.AxisType.Value)
                {
                    height += 2 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
                    SerializedProperty m_MinMaxType = prop.FindPropertyRelative("m_MinMaxType");
                    if (m_MinMaxType.enumValueIndex == (int)Axis.AxisMinMaxType.Custom)
                    {
                        height += EditorGUIUtility.singleLineHeight * 2 + EditorGUIUtility.standardVerticalSpacing;
                    }
                }
                else if (type == Axis.AxisType.Log)
                {
                    height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
                    SerializedProperty m_MinMaxType = prop.FindPropertyRelative("m_MinMaxType");
                    if (m_MinMaxType.enumValueIndex == (int)Axis.AxisMinMaxType.Custom)
                    {
                        height += EditorGUIUtility.singleLineHeight * 2 + EditorGUIUtility.standardVerticalSpacing;
                    }
                }
                height += EditorGUI.GetPropertyHeight(m_AxisName);
                height += EditorGUI.GetPropertyHeight(m_AxisLine);
                height += EditorGUI.GetPropertyHeight(m_AxisTick);
                height += EditorGUI.GetPropertyHeight(m_AxisLabel);
                height += EditorGUI.GetPropertyHeight(m_SplitArea);
                height += EditorGUI.GetPropertyHeight(m_SplitLine);
                height += GetExtendedHeight();
                return(height);
            }
        }
Ejemplo n.º 13
0
        private IQuery ProcessNode(AstNode root, IQuery qyInput, int parent,
                                   Axis.AxisType parentaxis, ref bool cache, ref bool position)
        {
            IQuery result = null;

            if (root == null)
            {
                return(null);
            }
            switch (root.TypeOfAst)
            {
            case AstNode.QueryType.Axis:
                filterCount = 0;
                firstInput  = null;
                Axis axis = (Axis)root;
                if (axis.TypeOfAxis == Axis.AxisType.Descendant || axis.TypeOfAxis ==
                    Axis.AxisType.DescendantOrSelf)
                {
                    if (_smart > 0)
                    {
                        result = ProcessAxis(
                            axis,
                            ProcessNode(axis.Input,
                                        qyInput, Smart_D,
                                        axis.TypeOfAxis, ref cache, ref position),
                            parent, parentaxis);
                        break;
                    }
                }
                _smart++;
                result = ProcessAxis(
                    axis,
                    ProcessNode(axis.Input,
                                qyInput, Regular_D,
                                axis.TypeOfAxis, ref cache, ref position),
                    parent, parentaxis);
                _smart--;
                break;

            case AstNode.QueryType.Operator:
                _smart = 2;
                result = ProcessOperator((Operator)root, null, ref cache, ref position);
                break;

            case AstNode.QueryType.Filter:
                _smart = 2;
                result = ProcessFilter((Filter)root, ref cache, ref position);
                break;

            case AstNode.QueryType.ConstantOperand:
                result = ProcessOperand((Operand)root);
                break;

            case AstNode.QueryType.Variable:
                result = ProcessVariable((Variable)root);
                break;

            case AstNode.QueryType.Function:
                result = ProcessFunction(
                    (System.Xml.XPath.Function)root,
                    qyInput, ref cache, ref position);
                break;

            case AstNode.QueryType.Group:
                _smart = 2;
                result = new GroupQuery(ProcessNode(
                                            ((System.Xml.XPath.Group)root).GroupNode,
                                            qyInput, Regular_D,
                                            Axis.AxisType.None,
                                            ref cache, ref position));
                break;

            case AstNode.QueryType.Root:
                result = new AbsoluteQuery();
                break;

            default:
                Debug.Assert(false, "Unknown QueryType encountered!!");
                break;
            }
            return(result);
        }
Ejemplo n.º 14
0
        private IQuery ProcessAxis(Axis root, IQuery qyInput, int parent, Axis.AxisType parentaxis)
        {
            IQuery result = null;
            String URN    = String.Empty;

            if (root.Prefix.Length > 0)
            {
                _hasPrefix = true;
            }
            hasReverseAxis = false;
            switch (root.TypeOfAxis)
            {
            case Axis.AxisType.Ancestor:
                result       = new XPathAncestorQuery(qyInput, false, root.Name, root.Prefix, URN, root.Type);
                _specialAxis = hasReverseAxis = true;
                break;

            case Axis.AxisType.AncestorOrSelf:
                result       = new XPathAncestorQuery(qyInput, true, root.Name, root.Prefix, URN, root.Type);
                _specialAxis = hasReverseAxis = true;
                break;

            case Axis.AxisType.Child:
                if (_slashslash)
                {
                    result = new XPathDescendantQuery(qyInput, false, root.Name, root.Prefix, URN, root.Type, abbrAxis);
                    if (_specialAxis || (qyInput != null && (int)qyInput.getName() > (int)Querytype.Self))
                    {
                        result = new CacheQuery(result);
                    }
                    _slashslash  = false;
                    _specialAxis = true;
                    break;
                }
                if (_specialAxis || (qyInput != null && (int)qyInput.getName() > (int)Querytype.Self))
                {
                    result = new CacheChildrenQuery(qyInput, root.Name, root.Prefix, URN, root.Type);
                }
                else
                {
                    result = new ChildrenQuery(qyInput, root.Name, root.Prefix, URN, root.Type);
                }
                break;

            case Axis.AxisType.Parent:
                result = new ParentQuery(qyInput, root.Name, root.Prefix, URN, root.Type);
                break;

            case Axis.AxisType.Descendant:
                switch (parent)
                {
                case Smart_D:
                    result = new SmartXPathDescendantQuery(qyInput, false, root.Name, root.Prefix, URN, root.Type);
                    break;

                case Regular_D:
                    result = new XPathDescendantQuery(qyInput, false, root.Name, root.Prefix, URN, root.Type);
                    if (_specialAxis || (qyInput != null && (int)qyInput.getName() > (int)Querytype.Self))
                    {
                        result = new CacheQuery(result);
                    }
                    _specialAxis = true;
                    break;
                }
                break;

            case Axis.AxisType.DescendantOrSelf:
                switch (parent)
                {
                case Smart_D:
                    result = new SmartXPathDescendantQuery(qyInput, true, root.Name, root.Prefix, URN, root.Type, root.abbrAxis);
                    break;

                case Regular_D:
                    if (_smart <= 1 || root.Type != XPathNodeType.All ||
                        parentaxis != Axis.AxisType.Child)
                    {
                        result = new XPathDescendantQuery(
                            qyInput,
                            true,
                            root.Name,
                            root.Prefix,
                            URN,
                            root.Type,
                            root.abbrAxis);
                        if (_specialAxis || (qyInput != null && (int)qyInput.getName() > (int)Querytype.Self))
                        {
                            result = new CacheQuery(result);
                        }
                        _specialAxis = true;
                    }
                    else
                    {
                        _slashslash = true;
                        abbrAxis    = root.abbrAxis;
                        result      = qyInput;
                    }
                    break;
                }
                break;

            case Axis.AxisType.Preceding:
                result = new PrecedingQuery(
                    qyInput,
                    root.Name,
                    root.Prefix,
                    URN,
                    root.Type);
                _specialAxis = hasReverseAxis = true;
                break;

            case Axis.AxisType.Following:
                result = new FollowingQuery(
                    qyInput,
                    root.Name,
                    root.Prefix,
                    URN,
                    root.Type);
                _specialAxis = true;
                break;

            case Axis.AxisType.FollowingSibling:
                result = new FollSiblingQuery(
                    qyInput,
                    root.Name,
                    root.Prefix,
                    URN,
                    root.Type);
                if (_specialAxis || (qyInput != null && (int)qyInput.getName() > (int)Querytype.Self))
                {
                    result = new DocumentOrderQuery(result);
                }
                break;

            case Axis.AxisType.PrecedingSibling:
                result = new PreSiblingQuery(
                    qyInput,
                    root.Name,
                    root.Prefix,
                    URN,
                    root.Type);
                hasReverseAxis = true;
                break;

            case Axis.AxisType.Attribute:
                result = new AttributeQuery(
                    qyInput,
                    root.Name,
                    root.Prefix,
                    URN,
                    root.Type);
                break;

            case Axis.AxisType.Self:
                result = new XPathSelfQuery(
                    qyInput,
                    root.Name,
                    root.Prefix,
                    URN,
                    root.Type);
                break;

            case Axis.AxisType.Namespace:
                if (
                    (root.Type == XPathNodeType.All || root.Type == XPathNodeType.Element || root.Type == XPathNodeType.Attribute) &&
                    root.Prefix == string.Empty
                    )
                {
                    result = new NamespaceQuery(qyInput, root.Name, root.Prefix, URN, root.Type);
                }
                else
                {
                    result = new EmptyNamespaceQuery();
                }
                break;

            default:
                throw new XPathException(Res.Xp_NotSupported, _query);
            }
            return(result);
        }