Exemple #1
0
        /// <summary>
        /// Calculates or sets X and Y.
        /// </summary>
        /// <param name="x">x value. Half width of rectangle.</param>
        /// <param name="y">y value. Half height of rectangle.</param>
        /// <param name="relativity">States, if value is relative or absolute.</param>
        /// <remarks>If values are relative, values have to be in [0,1].<para>
        /// Calculation fails, if (BaseX = 0 or BaseY = 0).<para/>
        /// If calculation fails, [call Calculate with parameter Relativity.Absolute] or [set BaseX and BaseY != 0]</para></remarks>
        /// <exception cref="ArgumentOutOfRangeException">Relative value is out of expected range [0,1].</exception>
        public void Calculate(double x, double y, Relativity relativity)
        {
            successful = false;

            if (relativity == Relativity.Relative && baseX != 0 && baseY != 0)
            {
                if ((y < 0) || (y > 1))
                {
                    throw new ArgumentOutOfRangeException("Relative y value is out of expected range [0,1].");
                }
                if ((x < 0) || (x > 1))
                {
                    throw new ArgumentOutOfRangeException("Relative x value is out of expected range [0,1].");
                }

                this.x     = x * baseX;
                this.y     = y * baseY;
                successful = true;
            }
            else if (relativity == Relativity.Absolute)
            {
                this.x     = x;
                this.y     = y;
                successful = true;
            }
        }
Exemple #2
0
 /// <summary>
 ///  Creates an instance of Options2. Sets default values.
 /// </summary>
 /// <param name="x">x value of TubeSize. Half width of rectangle. </param>
 /// <param name="y">y value of TubeSize. Half height of rectangle.</param>
 /// <remarks>Default values: <para>
 /// Use relative values for calculation of TubeSize: Relativity = Relativity.Relative <para/>
 /// Delimiter = ';' <para/>
 /// Separator = '.' <para/>
 /// Don't save log file: log = new Log()<para/>
 /// Don't save image: reportFolder = ""<para/>
 /// Don't show window: showWindow = false<para/>
 /// Show all (valid and invalid): ShowValidity = Validity.All<para/>
 /// Always use normal drawing methods, never fast drawing methods: drawFastAbove = 0<para/>
 /// Always draw points: drawPointsBelow = Int32.MaxValue
 /// </para></remarks>
 public Options2(double x, double y)
 {
     this.x          = x;
     this.y          = y;
     relativity      = Relativity.Relative;
     baseX           = Double.NaN;
     baseY           = Double.NaN;
     ratio           = Double.NaN;
     log             = new Log();
     reportFolder    = "";
     showWindow      = false;
     showValidity    = Validity.All;
     drawFastAbove   = 0;
     drawPointsBelow = Int32.MaxValue;
     drawLabelNumber = false;
 }
Exemple #3
0
 /// <summary>
 ///  Creates an instance of Options2. Sets default values.
 /// </summary>
 /// <param name="x">x value of TubeSize. Half width of rectangle. </param>
 /// <param name="y">y value of TubeSize. Half height of rectangle.</param>
 /// <remarks>Default values: <para>
 /// Use relative values for calculation of TubeSize: Relativity = Relativity.Relative <para/>
 /// Delimiter = ';' <para/>
 /// Separator = '.' <para/>
 /// Don't save log file: log = new Log()<para/>
 /// Don't save image: reportFolder = ""<para/>
 /// Don't show window: showWindow = false<para/>
 /// Show all (valid and invalid): ShowValidity = Validity.All<para/>
 /// Always use normal drawing methods, never fast drawing methods: drawFastAbove = 0<para/>
 /// Always draw points: drawPointsBelow = Int32.MaxValue
 /// </para></remarks>
 public Options2(double x, double y)
 {
     this.x = x;
     this.y = y;
     relativity = Relativity.Relative;
     baseX = Double.NaN;
     baseY = Double.NaN;
     ratio = Double.NaN;
     log = new Log();
     reportFolder = "";
     showWindow = false;
     showValidity = Validity.All;
     drawFastAbove = 0;
     drawPointsBelow = Int32.MaxValue;
     drawLabelNumber = false;
 }
Exemple #4
0
 /// <summary>
 /// Creates an instance of Options1.
 /// </summary>
 /// <param name="value">Value of TubeSize.</param>
 /// <param name="axes">States, if value is x (half width of rectangle) or y (half height of rectangle).</param>
 /// /// <remarks>Default values: <para>
 /// Use relative values for calculation of TubeSize: Relativity = Relativity.Relative <para/>
 /// Delimiter = ';' <para/>
 /// Separator = '.' <para/>
 /// Don't save log file: log = new Log()<para/>
 /// Don't save image: reportFolder = ""<para/>
 /// Don't show window: showWindow = false<para/>
 /// Show all (valid and invalid): ShowValidity = Validity.All<para/>
 /// Always use normal drawing methods, never fast drawing methods: drawFastAbove = 0<para/>
 /// Always draw points: drawPointsBelow = Int32.MaxValue
 /// </para></remarks>
 public Options1(double value, Axes axes)
 {
     this.val = value;
     this.axes = axes;
     relativity = Relativity.Relative;
     baseX = Double.NaN;
     baseY = Double.NaN;
     ratio = Double.NaN;
     log = new Log();
     reportFolder = "";
     showWindow = false;
     showValidity = Validity.All;
     drawFastAbove = 0;
     drawPointsBelow = Int32.MaxValue;
     formerBaseAndRatio = false;
     drawLabelNumber = false;
 }
Exemple #5
0
 /// <summary>
 /// Creates an instance of Options1.
 /// </summary>
 /// <param name="value">Value of TubeSize.</param>
 /// <param name="axes">States, if value is x (half width of rectangle) or y (half height of rectangle).</param>
 /// <param name="formerBaseAndRatio">Base and Ratio are calculated like in the former CSV-Compare, if true;<para>
 /// Ratio and Base get standard values, elsewise.</para></param>
 /// /// <remarks>Default values: <para>
 /// Use relative values for calculation of TubeSize: Relativity = Relativity.Relative <para/>
 /// Delimiter = ';' <para/>
 /// Separator = '.' <para/>
 /// Don't save log file: log = new Log()<para/>
 /// Don't save image: reportFolder = ""<para/>
 /// Don't show window: showWindow = false<para/>
 /// Show all (valid and invalid): ShowValidity = Validity.All<para/>
 /// Always use normal drawing methods, never fast drawing methods: drawFastAbove = 0<para/>
 /// Always draw points: drawPointsBelow = Int32.MaxValue
 /// </para></remarks>
 public Options1(double value, Axes axes, bool formerBaseAndRatio)
 {
     this.val                = value;
     this.axes               = axes;
     relativity              = Relativity.Relative;
     baseX                   = Double.NaN;
     baseY                   = Double.NaN;
     ratio                   = Double.NaN;
     log                     = new Log();
     reportFolder            = "";
     showWindow              = false;
     showValidity            = Validity.All;
     drawFastAbove           = 0;
     drawPointsBelow         = Int32.MaxValue;
     this.formerBaseAndRatio = formerBaseAndRatio;
     drawLabelNumber         = false;
 }
Exemple #6
0
        public override bool Translate()
        {
            var        cellExp       = (SpreadsheetParser.CellExpContext)Exp;
            Relativity leftRelative  = getRelativity(cellExp.left);
            Relativity rightRelative = getRelativity(cellExp.right);

            var left  = getValueExp(cellExp.left);
            var right = getValueExp(cellExp.right);

            if (left is SpreadsheetParser.ValueExpContext && right is SpreadsheetParser.ValueExpContext)
            {
                var leftParam  = (SpreadsheetParser.ValueExpContext)left;
                var rightParam = (SpreadsheetParser.ValueExpContext)right;
                if (leftParam.val is SpreadsheetParser.IntValContext && rightParam.val is SpreadsheetParser.IntValContext)
                {
                    var leftVal = int.Parse(leftParam.val.GetText());
                    if (leftRelative == Relativity.Neg)
                    {
                        leftVal *= -1;
                    }
                    var rightVal = int.Parse(rightParam.val.GetText());
                    if (rightRelative == Relativity.Neg)
                    {
                        rightVal *= -1;
                    }

                    Node = new AbstractCellNode(this, new Tuple <int, int>(leftVal, rightVal), isRelative(leftRelative), isRelative(rightRelative));
                }
                else
                {
                    var text = "Typecheck Error - Cell Expression has indices of type other than int.";
                    Node = new AbstractErrorNode(this, text);
                    return(false);
                }
            }
            else
            {
                var text = "Cell Expression has indices of type other than simple values - this is not supported yet.";
                Node = new AbstractErrorNode(this, text);
                return(false);
            }
            return(true);
        }
Exemple #7
0
        /// <summary>
        /// Calculates or sets X and Y.
        /// </summary>
        /// <param name="value">Value.</param>
        /// <param name="axes">States, if value is x (half width of rectangle) or y (half height of rectangle).</param>
        /// <param name="relativity">States, if value is relative or absolute. </param>
        /// <remarks>If value is relative, value have to be in [0,1]. <para>
        /// Calculation fails, if (Ratio = 0 or BaseX = 0 or BaseY = 0).<para/>
        /// If calculation fails, [set Ratio and BaseX and BaseY != 0] or [call Calculate(double x, double y, Relativity relativity) with parameter Relativity.Absolute]</para></remarks>
        /// <exception cref="ArgumentOutOfRangeException">Relative value is out of expected range [0,1].</exception>
        public void Calculate(double value, Axes axes, Relativity relativity)
        {
            successful = false;

            if (ratio > 0)
            {
                if (relativity == Relativity.Relative)
                {
                    if ((value < 0) || (value > 1))
                    {
                        throw new ArgumentOutOfRangeException("Relative value is out of expected range [0,1].");
                    }

                    if (axes == Axes.Y && baseY > 0)
                    {
                        y          = value * baseY;
                        x          = y / ratio;
                        successful = true;
                    }
                    else if (axes == Axes.X && baseX > 0)
                    {
                        x          = value * baseX;
                        y          = ratio * x;
                        successful = true;
                    }
                }
                else if (relativity == Relativity.Absolute)
                {
                    if (axes == Axes.Y)
                    {
                        this.y = value;
                        this.x = value / ratio;
                    }
                    else if (axes == Axes.X)
                    {
                        this.x = value;
                        this.y = value * ratio;
                    }
                    successful = true;
                }
            }
        }
Exemple #8
0
        private void resetWidget()
        {
            if (bone == null)
            {
                txtPositionX.Text = "-";
                txtPositionY.Text = "-";
                txtPositionZ.Text = "-";
                txtRotationX.Text = "-";
                txtRotationY.Text = "-";
                txtRotationZ.Text = "-";
                txtScaleX.Text = "-";
                txtScaleY.Text = "-";
                txtScaleZ.Text = "-";

                txtPositionX.Enabled = false;
                txtPositionY.Enabled = false;
                txtPositionZ.Enabled = false;
                txtRotationX.Enabled = false;
                txtRotationY.Enabled = false;
                txtRotationZ.Enabled = false;
                txtScaleX.Enabled = false;
                txtScaleY.Enabled = false;
                txtScaleZ.Enabled = false;

                return;
            }

            resetLinks();
            gang.Reset();

            txtPositionX.Enabled = true;
            txtPositionY.Enabled = true;
            txtPositionZ.Enabled = true;
            txtRotationX.Enabled = true;
            txtRotationY.Enabled = true;
            txtRotationZ.Enabled = true;
            txtScaleX.Enabled = true;
            txtScaleY.Enabled = true;
            txtScaleZ.Enabled = true;

            relativity = (rdoRelative.Checked ? Relativity.Relative : Relativity.Absolute);

            if (relativity == Relativity.Relative)
            {
                txtPositionX.Text = "0.00";
                txtPositionY.Text = "0.00";
                txtPositionZ.Text = "0.00";
                txtRotationX.Text = "0";
                txtRotationY.Text = "0";
                txtRotationZ.Text = "0";
                txtScaleX.Text = "100";
                txtScaleY.Text = "100";
                txtScaleZ.Text = "100";

                btnFreezePosition.Enabled = false;
                btnFreezeRotation.Enabled = false;
                btnFreezeScale.Enabled = false;
            }
            else
            {
                btnFreezePosition.Enabled = true;
                btnFreezeRotation.Enabled = true;
                btnFreezeScale.Enabled = true;

                var p = bone.GetPosition();
                var r = bone.GetRotation();
                var s = bone.GetScale();

                txtPositionX.Text = p.X.ToString(FlummeryApplication.Culture);
                txtPositionY.Text = p.Y.ToString(FlummeryApplication.Culture);
                txtPositionZ.Text = p.Z.ToString(FlummeryApplication.Culture);
                txtRotationX.Text = r.X.ToString(FlummeryApplication.Culture);
                txtRotationY.Text = r.Y.ToString(FlummeryApplication.Culture);
                txtRotationZ.Text = r.Z.ToString(FlummeryApplication.Culture);
                txtScaleX.Text = s.X.ToString(FlummeryApplication.Culture);
                txtScaleY.Text = s.Y.ToString(FlummeryApplication.Culture);
                txtScaleZ.Text = s.Z.ToString(FlummeryApplication.Culture);
            }
        }
Exemple #9
0
        private void resetWidget()
        {
            if (bone == null)
            {
                txtPositionX.Text = "-";
                txtPositionY.Text = "-";
                txtPositionZ.Text = "-";
                txtRotationX.Text = "-";
                txtRotationY.Text = "-";
                txtRotationZ.Text = "-";
                txtScaleX.Text    = "-";
                txtScaleY.Text    = "-";
                txtScaleZ.Text    = "-";

                txtPositionX.Enabled = false;
                txtPositionY.Enabled = false;
                txtPositionZ.Enabled = false;
                txtRotationX.Enabled = false;
                txtRotationY.Enabled = false;
                txtRotationZ.Enabled = false;
                txtScaleX.Enabled    = false;
                txtScaleY.Enabled    = false;
                txtScaleZ.Enabled    = false;

                return;
            }

            resetLinks();
            gang.Reset();

            txtPositionX.Enabled = true;
            txtPositionY.Enabled = true;
            txtPositionZ.Enabled = true;
            txtRotationX.Enabled = true;
            txtRotationY.Enabled = true;
            txtRotationZ.Enabled = true;
            txtScaleX.Enabled    = true;
            txtScaleY.Enabled    = true;
            txtScaleZ.Enabled    = true;

            relativity = (rdoRelative.Checked ? Relativity.Relative : Relativity.Absolute);

            if (relativity == Relativity.Relative)
            {
                txtPositionX.Text = "0.00";
                txtPositionY.Text = "0.00";
                txtPositionZ.Text = "0.00";
                txtRotationX.Text = "0";
                txtRotationY.Text = "0";
                txtRotationZ.Text = "0";
                txtScaleX.Text    = "100";
                txtScaleY.Text    = "100";
                txtScaleZ.Text    = "100";

                btnFreezePosition.Enabled = false;
                btnFreezeRotation.Enabled = false;
                btnFreezeScale.Enabled    = false;
            }
            else
            {
                btnFreezePosition.Enabled = true;
                btnFreezeRotation.Enabled = true;
                btnFreezeScale.Enabled    = true;

                var p = bone.GetPosition();
                var r = bone.GetRotation();
                var s = bone.GetScale();

                txtPositionX.Text = p.X.ToString(FlummeryApplication.Culture);
                txtPositionY.Text = p.Y.ToString(FlummeryApplication.Culture);
                txtPositionZ.Text = p.Z.ToString(FlummeryApplication.Culture);
                txtRotationX.Text = r.X.ToString(FlummeryApplication.Culture);
                txtRotationY.Text = r.Y.ToString(FlummeryApplication.Culture);
                txtRotationZ.Text = r.Z.ToString(FlummeryApplication.Culture);
                txtScaleX.Text    = s.X.ToString(FlummeryApplication.Culture);
                txtScaleY.Text    = s.Y.ToString(FlummeryApplication.Culture);
                txtScaleZ.Text    = s.Z.ToString(FlummeryApplication.Culture);
            }
        }
Exemple #10
0
 private bool isRelative(Relativity relative)
 {
     return(relative != Relativity.None);
 }
Exemple #11
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="pathTargetType">Type of path to use</param>
 /// <param name="relativePath">Type of path relativity to use</param>
 public PathAttribute(Path pathTargetType     = Path.File,
                      Relativity relativePath = Relativity.ProjectRelative)
 {
     TargetType     = pathTargetType;
     RelativityType = relativePath;
 }
Exemple #12
0
 public CpkCondition(string name, CalculationTypeHandler calculationtype, double value, RelationHandler relation, Relativity relativity, bool enabled, double halfTolerance)
     : base(name, calculationtype, value, relation, enabled)
 {
     HalfTolerance = halfTolerance;
 }