Exemple #1
0
        static MultiValPointer()
        {
            RectangularValue rv = new RectangularValue()
            {
                LeftBottom  = double.NaN,
                RightBottom = double.NaN,
                RightTop    = double.NaN,
                LeftTop     = double.NaN
            };

            MultiValPointer.INVALID = new MultiValPointer(new List <int>(), new Point(0, 0), new Point(0, 0), true, rv, false);
        }
Exemple #2
0
        internal SingleValue(double _value, string _name)
            : base(MultiValueType.SINGLE, _name)
        {
            RectangularValue rv = new RectangularValue()
            {
                LeftBottom  = _value,
                RightBottom = _value,
                RightTop    = _value,
                LeftTop     = _value
            };

            this.MVDisplayVector = new MultiValPointer(new List <int> {
                0
            }, new Point(10, 10), new Point(1, 1), true, rv, false);
        }
Exemple #3
0
        public MultiValPointer(List <int> _cell_indices, Point _cell_size, Point _position, bool _pos_is_absolute,
                               RectangularValue _cell_values, bool _can_interpolate,
                               double _abs_offset_x = 0, double _abs_offset_y = 0)
        {
            this.NrDim                = 0;
            this.cell_indices         = new List <int>();
            this.cell_size            = new Point(0, 0);
            this.pos_in_cell_relative = new Point(0, 0);
            this.pos_in_cell_abs_Px   = new Point(0, 0);
            this.Value                = double.NaN;

            if (!MultiValPointer.InputValid(_cell_indices, _cell_size, _position, _pos_is_absolute))
            {
                return;
            }

            // calculate position
            this.NrDim        = _cell_indices.Count;
            this.cell_indices = _cell_indices;
            this.cell_size    = _cell_size;

            if (_pos_is_absolute)
            {
                this.pos_in_cell_abs_Px     = new Point(_position.X + _abs_offset_x, _position.Y + _abs_offset_y);
                this.pos_in_cell_relative   = new Point(0, 0);
                this.pos_in_cell_relative.X = (_cell_size.X < Parameter.Calculation.MIN_DOUBLE_VAL) ? 1 : _position.X / _cell_size.X;
                this.pos_in_cell_relative.Y = (_cell_size.Y < Parameter.Calculation.MIN_DOUBLE_VAL) ? 1 : (_cell_size.Y - _position.Y) / _cell_size.Y;
            }
            else
            {
                this.pos_in_cell_relative = _position;
                this.pos_in_cell_abs_Px   = new Point(_cell_size.X * _position.X + _abs_offset_x,
                                                      _cell_size.Y * (1 - _position.Y) + _abs_offset_y);
            }

            // calculate value
            double result = double.NaN;

            if (_can_interpolate)
            {
                double resultY_bottom = _cell_values.LeftBottom * (1.0 - this.pos_in_cell_relative.X) + _cell_values.RightBottom * this.pos_in_cell_relative.X;
                double resultY_top    = _cell_values.LeftTop * (1.0 - this.pos_in_cell_relative.X) + _cell_values.RightTop * this.pos_in_cell_relative.X;
                result = resultY_bottom * (1.0 - this.pos_in_cell_relative.Y) + resultY_top * this.pos_in_cell_relative.Y;
            }
            else
            {
                bool take_right  = (this.pos_in_cell_relative.X > 0.5);
                bool take_bottom = (this.pos_in_cell_relative.Y < 0.5);
                if (take_right && take_bottom)
                {
                    result = _cell_values.RightBottom;
                }
                else if (take_right && !take_bottom)
                {
                    result = _cell_values.RightTop;
                }
                else if (!take_right && take_bottom)
                {
                    result = _cell_values.LeftBottom;
                }
                else
                {
                    result = _cell_values.LeftTop;
                }
            }
            this.Value = result;
        }