Ejemplo n.º 1
0
    /// <summary>
    /// Used to invert variable in use
    /// </summary>
    public void InvertVaraibles()
    {
        Vector3Int variableIndex = plotter.GetVariableIndex(); // get variables index in used

        // swap them round based on which axes are in used

        if (plotter.UseX() && plotter.UseY() && plotter.UseZ())
        {
            variableIndex = new Vector3Int(variableIndex.y, variableIndex.z, variableIndex.x);
            plotter.RedrawAxisInvert(variableIndex);
        }

        else if (!plotter.UseX() && plotter.UseY() && plotter.UseZ())
        {
            variableIndex = new Vector3Int(0, variableIndex.z, variableIndex.y);
            plotter.RedrawAxisInvert(variableIndex);
        }

        else if (plotter.UseX() && !plotter.UseY() && plotter.UseZ())
        {
            variableIndex = new Vector3Int(variableIndex.z, 0, variableIndex.x);
            plotter.RedrawAxisInvert(variableIndex);
        }

        else if (plotter.UseX() && plotter.UseY() && !plotter.UseZ())
        {
            variableIndex = new Vector3Int(variableIndex.y, variableIndex.x, 0);
            plotter.RedrawAxisInvert(variableIndex);
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Used to update variable in use
    /// </summary>
    public void UpdateVariable()
    {
        List <string> variables            = plot.GetVariables(); // get the list of variables
        List <int>    variableIndexesInUse = new List <int>();

        // check variable indexes used by axis by counting
        int varsInUse = 0;

        if (plot.UseX())
        {
            varsInUse++;
            variableIndexesInUse.Add(plot.GetVariableIndex().x);
        }

        if (plot.UseY())
        {
            varsInUse++;
            variableIndexesInUse.Add(plot.GetVariableIndex().y);
        }

        if (plot.UseZ())
        {
            varsInUse++;
            variableIndexesInUse.Add(plot.GetVariableIndex().z);
        }

        // if there is other variables to use allow switch
        if (varsInUse < variables.Count)
        {
            // check which axis we are dealing with
            Vector3Int newVariableIndex = new Vector3Int();
            int        i;
            switch (axisName)
            {
            // update the variable in use for that axis, making sure it is not used by something else
            case Axis.X:
                newVariableIndex = plot.GetVariableIndex();
                i = newVariableIndex.x;

                while (variableIndexesInUse.Contains(i)) // while i is in use
                {
                    i = (i + 1) % (variables.Count);     // look for a new index in range
                }

                // once you find a new index in range, set it and redraw
                newVariableIndex.x = i;
                plot.RedrawAxis(newVariableIndex);

                break;

            case Axis.Y:

                newVariableIndex = plot.GetVariableIndex();
                i = newVariableIndex.y;

                while (variableIndexesInUse.Contains(i)) // while i is in use
                {
                    i = (i + 1) % (variables.Count);     // look for a new index in range
                }

                // once you find a new index in range, set it and redraw
                newVariableIndex.y = i;
                plot.RedrawAxis(newVariableIndex);

                break;

            case Axis.Z:

                newVariableIndex = plot.GetVariableIndex();
                i = newVariableIndex.z;

                while (variableIndexesInUse.Contains(i)) // while i is in use
                {
                    i = (i + 1) % (variables.Count);     // look for a new index in range
                }

                // once you find a new index in range, set it and redraw
                newVariableIndex.z = i;
                plot.RedrawAxis(newVariableIndex);

                break;
            }
        }
    }