Beispiel #1
0
        private void on_Loaded(object sender, RoutedEventArgs e)
        {
            MultiValPointer pointer = this.DataField.MVDisplayVector;

            if (pointer != MultiValPointer.INVALID && pointer.CellIndices.Count > 2 && pointer.CellIndices[2] == this.Depth)
            {
                this.SetMark(pointer.CellIndices[0], pointer.CellIndices[1], pointer.PosInCell_AbsolutePx, pointer.Value);
            }
        }
Beispiel #2
0
        private void MValueFunct3DInfo_Loaded(object sender, RoutedEventArgs e)
        {
            if (this.DataField == null)
            {
                return;
            }
            MultiValPointer pointer = this.DataField.MVDisplayVector;

            if (pointer != MultiValPointer.INVALID && pointer.CellIndices.Count > 2)
            {
                this.MarkTab(pointer.CellIndices[2]);
            }
        }
Beispiel #3
0
        protected override void MValueFunct2DBase_Loaded(object sender, RoutedEventArgs e)
        {
            if (!this.grid_set)
            {
                base.MValueFunct2DBase_Loaded(sender, e);
                this.RescaleAxesLabels();
                this.SetAxisValues();
                this.ApplyAxisValues(this.AxisValues);
                this.ReDrawAllLines();
            }

            MultiValPointer pointer = this.DataField.MVDisplayVector;

            if (pointer != MultiValPointer.INVALID && pointer.CellIndices.Count > 2 && pointer.CellIndices[2] == this.Depth)
            {
                this.SetMark(pointer.PosInCell_AbsolutePx, pointer.Value);
            }
        }
Beispiel #4
0
        private void table_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
        {
            DataGrid dg = sender as DataGrid;

            if (dg == null || e == null)
            {
                return;
            }

            if (e.AddedCells != null && e.AddedCells.Count > 0)
            {
                BigTableRow item = e.AddedCells[0].Item as BigTableRow;
                if (item != null)
                {
                    int row_ind = item.Col00_Index - 1;

                    int col_ind = e.AddedCells[0].Column.DisplayIndex;

                    string content = item.GetColAt(col_ind);
                    double value   = 0;
                    bool   success = double.TryParse(content, NumberStyles.Float, BigTableRow.FORMATTER, out value);
                    if (success)
                    {
                        RectangularValue rv = new RectangularValue()
                        {
                            RightBottom = value,
                            RightTop    = value,
                            LeftBottom  = value,
                            LeftTop     = value
                        };
                        MultiValPointer pointer = new MultiValPointer(new List <int> {
                            row_ind, col_ind, 0
                        }, new Point(1, 1), new Point(0, 0), true, rv, false);
                        if (pointer != MultiValPointer.INVALID)
                        {
                            this.DataField.MVDisplayVector = pointer;
                        }
                    }
                }
            }
        }
Beispiel #5
0
        protected override void line_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Line line = sender as Line;

            if (line == null)
            {
                return;
            }
            if (this.canvas == null)
            {
                return;
            }
            if (this.fact_x == 0 || this.fact_y == 0)
            {
                return;
            }

            // save the graph indices (added 27.10.2016)
            int ind_graph     = -1;
            int ind_line_segm = -1;

            if (line.Tag != null)
            {
                if (line.Tag is Point)
                {
                    Point p = (Point)line.Tag;
                    ind_graph     = (int)p.X;
                    ind_line_segm = (int)p.Y;
                }
            }

            // communicate to others
            this.MarkSet = true;

            Point pos = e.GetPosition(this.canvas);

            // apply snap
            if (Math.Abs(line.X1 - pos.X) <= MValueFunct2DBase.SNAP_DIST_PX &&
                Math.Abs(line.Y1 - pos.Y) <= MValueFunct2DBase.SNAP_DIST_PX)
            {
                pos.X = line.X1;
                pos.Y = line.Y1;
            }
            if (Math.Abs(line.X2 - pos.X) <= MValueFunct2DBase.SNAP_DIST_PX &&
                Math.Abs(line.Y2 - pos.Y) <= MValueFunct2DBase.SNAP_DIST_PX)
            {
                pos.X = line.X2;
                pos.Y = line.Y2;
            }

            double x_left   = Math.Min(line.X1, line.X2);
            double x_right  = Math.Max(line.X1, line.X2);
            double y_top    = Math.Min(line.Y1, line.Y2);
            double y_bottom = Math.Max(line.Y1, line.Y2);

            double y_left  = 0;
            double y_right = 0;

            if (x_left == line.X1)
            {
                y_left  = line.Y1;
                y_right = line.Y2;
            }
            else
            {
                y_left  = line.Y2;
                y_right = line.Y1;
            }

            Point pos_rel = new Point(0, 0);

            pos_rel.X = (Math.Abs(line.X1 - line.X2) < ParameterStructure.Parameter.Calculation.MIN_DOUBLE_VAL) ? 1 : Math.Abs(x_left - pos.X) / Math.Abs(line.X1 - line.X2);
            pos_rel.Y = (Math.Abs(line.Y1 - line.Y2) < ParameterStructure.Parameter.Calculation.MIN_DOUBLE_VAL) ? 1 : Math.Abs(y_bottom - pos.Y) / Math.Abs(line.Y1 - line.Y2);
            if (pos_rel.X < 0)
            {
                pos_rel.X = 0;
            }
            if (pos_rel.X > 1)
            {
                pos_rel.X = 1;
            }
            if (pos_rel.Y < 0)
            {
                pos_rel.Y = 0;
            }
            if (pos_rel.Y > 1)
            {
                pos_rel.Y = 1;
            }

            // calculate the interpolated value
            // scaling ACTUAL -> SCALED
            // double x1_scaled = (_x1 - this.xs[0]) * this.fact_x;
            // double y1_scaled = this.canvas.Height - (_y1 - this.ys[0]) * this.fact_y;

            // scaling SCALED -> ACTUAL
            RectangularValue rv = new RectangularValue();

            if (Math.Abs(x_left - x_right) >= ParameterStructure.Parameter.Calculation.MIN_DOUBLE_VAL)
            {
                rv.LeftBottom  = (this.canvas.Height - y_left) / this.fact_y + this.ys[0];
                rv.LeftTop     = rv.LeftBottom;
                rv.RightBottom = (this.canvas.Height - y_right) / this.fact_y + this.ys[0];
                rv.RightTop    = rv.RightBottom;
            }
            else
            {
                // account for vertical function segments
                rv.LeftBottom  = (this.canvas.Height - y_bottom) / this.fact_y + this.ys[0];
                rv.RightBottom = rv.LeftBottom;
                rv.LeftTop     = (this.canvas.Height - y_top) / this.fact_y + this.ys[0];
                rv.RightTop    = rv.LeftTop;
            }

            MultiValPointer pointer = new MultiValPointer(new List <int> {
                ind_graph, ind_line_segm, this.Depth
            },
                                                          new Point(Math.Abs(line.X1 - line.X2), Math.Abs(line.Y1 - line.Y2)),
                                                          pos_rel,
                                                          false, rv, true,
                                                          x_left, y_top);

            this.DataField.MVDisplayVector = pointer;
            if (pointer != MultiValPointer.INVALID)
            {
                this.SetMark(pos, pointer.Value);
            }
        }
Beispiel #6
0
        private void rect_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Rectangle rect = sender as Rectangle;

            if (rect == null)
            {
                return;
            }

            // communicate to others
            this.MarkSet = true;

            // detect position in the grid
            string name = rect.Name;

            string[] grid_pos = name.Split(new string[] { "x_", "__y_" }, StringSplitOptions.RemoveEmptyEntries);
            if (grid_pos == null || grid_pos.Length != 2)
            {
                return;
            }

            int row_index = -1, col_index = -1;

            int.TryParse(grid_pos[0], out col_index);
            int.TryParse(grid_pos[1], out row_index);
            if (row_index < 0 || col_index < 0)
            {
                return;
            }

            // detect position in the value table
            if (!(rect.Tag is RectangularValue))
            {
                return;
            }

            RectangularValue rv = (RectangularValue)rect.Tag;

            Point pos = e.GetPosition(rect);

            // apply snap
            if ((rect.Width - pos.X) <= MValueField2DBase.SNAP_DIST_PX)
            {
                pos.X = rect.Width;
            }
            if (pos.X <= MValueField2DBase.SNAP_DIST_PX)
            {
                pos.X = 0;
            }
            if ((rect.Height - pos.Y) <= MValueField2DBase.SNAP_DIST_PX)
            {
                pos.Y = rect.Height;
            }
            if (pos.Y <= MValueField2DBase.SNAP_DIST_PX)
            {
                pos.Y = 0;
            }

            MultiValPointer pointer = new MultiValPointer(new List <int> {
                row_index, col_index, this.Depth
            },
                                                          new Point(this.column_width, this.row_height),
                                                          pos,
                                                          true, rv, this.DataField.MVCanInterpolate);

            this.DataField.MVDisplayVector = pointer;
            if (pointer != MultiValPointer.INVALID)
            {
                this.SetMark(pointer.CellIndices[0], pointer.CellIndices[1], pointer.PosInCell_AbsolutePx, pointer.Value);
            }
        }
        // only call when parsing
        internal Parameter ReconstructParameter(long _id, string _name, string _unit, Category _category, InfoFlow _propagation,
                                                double _value_min, double _value_max, double _value_current, bool _is_within_bounds,
                                                MultiValue _value_field, long _value_field_ref, MultiValPointer _value_field_pointer,
                                                DateTime _time_stamp, string _text_value)
        {
            Parameter created = new Parameter(_id, _name, _unit, _category, _propagation,
                                              _value_min, _value_max, _value_current, _is_within_bounds,
                                              _text_value, _value_field_ref, _value_field_pointer);

            // value field
            created.ValueField = _value_field; // resets ValueFieldRef und MValPointer (e.g. if the field is NULL)
            if (_value_field != null)
            {
                created.MValPointer = _value_field_pointer; // DO NOT FORGET to corrct the MValPointer
            }
            // time stamp
            if (_time_stamp != null)
            {
                created.TimeStamp = _time_stamp;
            }
            else
            {
                created.TimeStamp = DateTime.Now;
            }

            // check if a valid value table was created
            if (created == null)
            {
                return(null);
            }

            // create
            this.parameter_record.Add(created);
            // adjust type counter
            Parameter.NR_PARAMS = Math.Max(Parameter.NR_PARAMS, created.ID);
            // done
            return(created);
        }