protected override void Initialize(bool initData)
        {
            base.Initialize(initData);

            if (initData)
            {
                _xColumn = _doc.RowHeaderColumn;
                _yColumn = _doc.ColumnHeaderColumn;
                // Initialize value columns
                _valueColumns.Clear();
                for (int i = 0; i < _doc.ColumnCount; ++i)
                {
                    var col = _doc.GetDataColumnProxy(i);
                    _valueColumns.Add(new SelectableListNode(col.Document != null ? col.Document.FullName : "Unresolved column", col, false));
                }

                CalcMaxPossiblePlotRangeTo();

                // Initialize tables
                string[] tables = Current.Project.DataTableCollection.GetSortedTableNames();

                string dataTableName = _doc.DataTable == null ? string.Empty : _doc.DataTable.Name;

                _availableTables.Clear();
                foreach (var tableName in tables)
                {
                    _availableTables.Add(new SelectableListNode(tableName, Current.Project.DataTableCollection[tableName], dataTableName == tableName));
                }

                // Initialize columns
                FillAvailableColumnList();

                _rowsController = new Common.AscendingIntegerCollectionController();
                _rowsController.InitializeDocument(_doc.ParticipatingDataRows.Clone());
            }

            if (null != _view)
            {
                EhSelectedColumnKindChanged(); // ask view which column kind is now selected
                UpdateButtonEnablingInView();  // do that in every case, even if nothing has changed

                _view.InitializeAvailableTables(_availableTables);
                _view.InitializeAvailableColumns(_availableColumns);

                _view.GroupNumber = _doc.GroupNumber;
                _view.UseAllAvailableDataColumns = _doc.UseAllAvailableDataColumnsOfGroup;
                _view.UseAllAvailableDataRows    = _doc.UseAllAvailableDataRows;

                _view.Initialize_XColumn(_xColumn == null ? string.Empty : _xColumn.FullName);
                _view.Initialize_YColumn(_yColumn == null ? string.Empty : _yColumn.FullName);
                _view.Initialize_VColumns(_valueColumns);
                CalcMaxPossiblePlotRangeTo();

                if (_rowsController.ViewObject == null)
                {
                    Current.Gui.FindAndAttachControlTo(_rowsController);
                }
                _view.Initialize_DataRowsControl(_rowsController.ViewObject);
            }
        }
示例#2
0
 private string GetName(Altaxo.Data.IReadableColumn col, int level)
 {
     if (col is Altaxo.Data.DataColumn)
     {
         Altaxo.Data.DataTable table = Altaxo.Data.DataTable.GetParentDataTableOf((DataColumn)col);
         string tablename            = table == null ? string.Empty : table.Name + "\\";
         string collectionname       = table == null ? string.Empty : (table.PropertyColumns.ContainsColumn((DataColumn)col) ? "PropCols\\" : "DataCols\\");
         if (level <= 0)
         {
             return(((DataColumn)col).Name);
         }
         else if (level == 1)
         {
             return(tablename + ((DataColumn)col).Name);
         }
         else
         {
             return(tablename + collectionname + ((DataColumn)col).Name);
         }
     }
     else if (col != null)
     {
         return(col.FullName);
     }
     else
     {
         return(string.Empty);
     }
 }
 private void EhClearYColumn()
 {
     _yColumn = null;
     if (null != _view)
     {
         _view.Initialize_YColumn(_yColumn == null ? string.Empty : _yColumn.FullName);
     }
 }
        public void CalculateCachedData()
        {
            if (null == m_DataColumns || m_DataColumns.Length == 0)
            {
                m_Rows = 0;
                return;
            }

            this.m_xBoundaries.BeginUpdate(); // disable events
            this.m_yBoundaries.BeginUpdate(); // disable events
            this.m_vBoundaries.BeginUpdate();

            this.m_xBoundaries.Reset();
            this.m_yBoundaries.Reset();
            this.m_vBoundaries.Reset();

            // get the length of the largest column as row count
            m_Rows = 0;
            for (int i = 0; i < m_DataColumns.Length; i++)
            {
                if (m_DataColumns[i] is IDefinedCount)
                {
                    m_Rows = System.Math.Max(m_Rows, ((IDefinedCount)m_DataColumns[i]).Count);
                }
            }

            for (int i = 0; i < m_DataColumns.Length; i++)
            {
                Altaxo.Data.IReadableColumn col = m_DataColumns[i];
                int collength = (col is Altaxo.Data.IDefinedCount) ? ((Altaxo.Data.IDefinedCount)col).Count : m_Rows;
                for (int j = 0; j < collength; j++)
                {
                    this.m_vBoundaries.Add(col, j);
                }
            }


            // enter the two bounds for x
            for (int i = 0; i < m_DataColumns.Length; i++)
            {
                this.m_yBoundaries.Add(m_YColumn, i);
            }

            // enter the bounds for y
            for (int i = 0; i < m_Rows; i++)
            {
                this.m_xBoundaries.Add(m_XColumn, i);
            }

            // now the cached data are valid
            m_bCachedDataValid = true;


            // now when the cached data are valid, we can reenable the events
            this.m_xBoundaries.EndUpdate(); // enable events
            this.m_yBoundaries.EndUpdate(); // enable events
            this.m_vBoundaries.EndUpdate(); // enable events
        }
示例#5
0
 public XYZColumnPlotData(Altaxo.Data.DataTable dataTable, int groupNumber, Altaxo.Data.IReadableColumn xColumn, Altaxo.Data.IReadableColumn yColumn, Altaxo.Data.IReadableColumn zColumn)
 {
     DataTable = dataTable;
     ChildSetMember(ref _dataRowSelection, new AllRows());
     _groupNumber = groupNumber;
     XColumn      = xColumn;
     YColumn      = yColumn;
     ZColumn      = zColumn;
 }
示例#6
0
        public XYColumnPlotData(Altaxo.Data.IReadableColumn xColumn, Altaxo.Data.IReadableColumn yColumn)
        {
            XColumn = xColumn;
            YColumn = yColumn;


            //this.SetXBoundsFromTemplate( new FiniteNumericalBoundaries() );
            //this.SetYBoundsFromTemplate( new FiniteNumericalBoundaries() );
        }
        private void EhUseSelectedItemAsXColumn()
        {
            var node = _availableColumns.FirstSelectedNode;

            _xColumn = node == null ? null : node.Tag as DataColumn;
            if (null != _view)
            {
                _view.Initialize_XColumn(_xColumn == null ? string.Empty : _xColumn.FullName);
            }
        }
        public override void Dispose(bool isDisposing)
        {
            _xColumn          = null;
            _yColumn          = null;
            _valueColumns     = null;
            _availableTables  = null;
            _availableColumns = null;

            base.Dispose(isDisposing);
        }
            public void Serialize(object obj, Altaxo.Serialization.Xml.IXmlSerializationInfo info)
            {
                XYZMeshedColumnPlotData s = (XYZMeshedColumnPlotData)obj;

                if (s.m_XColumn is Main.IDocumentNode && !s.Equals(((Main.IDocumentNode)s.m_XColumn).ParentObject))
                {
                    info.AddValue("XColumn", Main.DocumentPath.GetAbsolutePath((Main.IDocumentNode)s.m_XColumn));
                }
                else
                {
                    info.AddValue("XColumn", s.m_XColumn);
                }

                if (s.m_YColumn is Main.IDocumentNode && !s.Equals(((Main.IDocumentNode)s.m_YColumn).ParentObject))
                {
                    info.AddValue("YColumn", Main.DocumentPath.GetAbsolutePath((Main.IDocumentNode)s.m_YColumn));
                }
                else
                {
                    info.AddValue("YColumn", s.m_YColumn);
                }

                info.CreateArray("DataColumns", s.m_DataColumns.Length);
                for (int i = 0; i < s.m_DataColumns.Length; i++)
                {
                    Altaxo.Data.IReadableColumn col = s.m_DataColumns[i];
                    if (col is Main.IDocumentNode && !s.Equals(((Main.IDocumentNode)col).ParentObject))
                    {
                        info.AddValue("e", Main.DocumentPath.GetAbsolutePath((Main.IDocumentNode)col));
                    }
                    else
                    {
                        info.AddValue("e", col);
                    }
                }
                info.CommitArray();

                info.AddValue("XBoundaries", s.m_xBoundaries);
                info.AddValue("YBoundaries", s.m_yBoundaries);
                info.AddValue("VBoundaries", s.m_vBoundaries);
            }
示例#10
0
        /// <summary>
        /// This will create a point list out of the data, which can be used to plot the data. In order to create this list,
        /// the function must have knowledge how to calculate the points out of the data. This will be done
        /// by a function provided by the calling function.
        /// </summary>
        /// <param name="layer">The plot layer.</param>
        /// <returns>An array of plot points in layer coordinates.</returns>
        public Processed3DPlotData GetRangesAndPoints(
            IPlotArea layer)
        {
            const double MaxRelativeValue = 1E2;

            Altaxo.Data.IReadableColumn xColumn = XColumn;
            Altaxo.Data.IReadableColumn yColumn = YColumn;
            Altaxo.Data.IReadableColumn zColumn = ZColumn;

            if (null == xColumn || null == yColumn || null == zColumn)
            {
                return(null); // this plotitem is only for x and y double columns
            }
            var result     = new Processed3DPlotData();
            var myPlotData = new MyPlotData(xColumn, yColumn, zColumn);

            result.XPhysicalAccessor = new IndexedPhysicalValueAccessor(myPlotData.GetXPhysical);
            result.YPhysicalAccessor = new IndexedPhysicalValueAccessor(myPlotData.GetYPhysical);
            result.ZPhysicalAccessor = new IndexedPhysicalValueAccessor(myPlotData.GetZPhysical);
            PlotRangeList rangeList = null;

            // allocate an array PointF to hold the line points
            // _tlsBufferedPlotData is a static buffer that is allocated per thread
            // and thus is only used temporary here in this routine
            if (null == _tlsBufferedPlotData)
            {
                _tlsBufferedPlotData = new List <PointD3D>();
            }
            else
            {
                _tlsBufferedPlotData.Clear();
            }

            // Fill the array with values
            // only the points where x and y are not NaNs are plotted!

            bool weAreInsideSegment = false;
            int  rangeStart         = 0;
            int  rangeOffset        = 0;

            rangeList        = new PlotRangeList();
            result.RangeList = rangeList;

            Scale xAxis = layer.XAxis;
            Scale yAxis = layer.YAxis;
            Scale zAxis = layer.ZAxis;
            G3DCoordinateSystem coordsys = layer.CoordinateSystem;

            int maxRowIndex  = GetMaximumRowIndexFromDataColumns();
            int plotArrayIdx = 0;

            foreach ((int start, int endExclusive) in _dataRowSelection.GetSelectedRowIndexSegmentsFromTo(0, maxRowIndex, _dataTable?.Document?.DataColumns, maxRowIndex))
            {
                for (int dataRowIdx = start; dataRowIdx < endExclusive; ++dataRowIdx)
                {
                    if (xColumn.IsElementEmpty(dataRowIdx) || yColumn.IsElementEmpty(dataRowIdx) || zColumn.IsElementEmpty(dataRowIdx))
                    {
                        if (weAreInsideSegment)
                        {
                            weAreInsideSegment = false;
                            rangeList.Add(new PlotRange(rangeStart, plotArrayIdx, rangeOffset));
                        }
                        continue;
                    }

                    double x_rel, y_rel, z_rel;

                    x_rel = xAxis.PhysicalVariantToNormal(xColumn[dataRowIdx]);
                    y_rel = yAxis.PhysicalVariantToNormal(yColumn[dataRowIdx]);
                    z_rel = zAxis.PhysicalVariantToNormal(zColumn[dataRowIdx]);

                    // chop relative values to an range of about -+ 10^6
                    if (x_rel > MaxRelativeValue)
                    {
                        x_rel = MaxRelativeValue;
                    }
                    if (x_rel < -MaxRelativeValue)
                    {
                        x_rel = -MaxRelativeValue;
                    }
                    if (y_rel > MaxRelativeValue)
                    {
                        y_rel = MaxRelativeValue;
                    }
                    if (y_rel < -MaxRelativeValue)
                    {
                        y_rel = -MaxRelativeValue;
                    }
                    if (z_rel > MaxRelativeValue)
                    {
                        z_rel = MaxRelativeValue;
                    }
                    if (z_rel < -MaxRelativeValue)
                    {
                        z_rel = -MaxRelativeValue;
                    }

                    // after the conversion to relative coordinates it is possible
                    // that with the choosen axis the point is undefined
                    // (for instance negative values on a logarithmic axis)
                    // in this case the returned value is NaN
                    if (coordsys.LogicalToLayerCoordinates(new Logical3D(x_rel, y_rel, z_rel), out var coord))
                    {
                        if (!weAreInsideSegment)
                        {
                            weAreInsideSegment = true;
                            rangeStart         = plotArrayIdx;
                            rangeOffset        = dataRowIdx - plotArrayIdx;
                        }
                        _tlsBufferedPlotData.Add(coord);
                        plotArrayIdx++;
                    }
                    else
                    {
                        if (weAreInsideSegment)
                        {
                            weAreInsideSegment = false;
                            rangeList.Add(new PlotRange(rangeStart, plotArrayIdx, rangeOffset));
                        }
                    }
                } // end for
                if (weAreInsideSegment)
                {
                    weAreInsideSegment = false;
                    rangeList.Add(new PlotRange(rangeStart, plotArrayIdx, rangeOffset)); // add the last range
                }
            } // end foreach

            result.PlotPointsInAbsoluteLayerCoordinates = _tlsBufferedPlotData.ToArray();

            return(result);
        }
示例#11
0
        /// <summary>
        /// This will create a point list out of the data, which can be used to plot the data. In order to create this list,
        /// the function must have knowledge how to calculate the points out of the data. This will be done
        /// by a function provided by the calling function.
        /// </summary>
        /// <param name="layer">The plot layer.</param>
        /// <returns>An array of plot points in layer coordinates.</returns>
        public Processed2DPlotData GetRangesAndPoints(
            Gdi.IPlotArea layer)
        {
            const double MaxRelativeValue = 1E2;

            Altaxo.Data.IReadableColumn xColumn = this.XColumn;
            Altaxo.Data.IReadableColumn yColumn = this.YColumn;

            if (null == xColumn || null == yColumn)
            {
                return(null); // this plotitem is only for x and y double columns
            }
            if (this.PlottablePoints <= 0)
            {
                return(null);
            }


            Processed2DPlotData result     = new Processed2DPlotData();
            MyPlotData          myPlotData = new MyPlotData(xColumn, yColumn);

            result.XPhysicalAccessor = new IndexedPhysicalValueAccessor(myPlotData.GetXPhysical);
            result.YPhysicalAccessor = new IndexedPhysicalValueAccessor(myPlotData.GetYPhysical);
            PlotRangeList rangeList = null;

            PointF[] ptArray = null;



            // allocate an array PointF to hold the line points
            ptArray = new PointF[this.PlottablePoints];
            result.PlotPointsInAbsoluteLayerCoordinates = ptArray;

            // Fill the array with values
            // only the points where x and y are not NaNs are plotted!

            int i, j;

            bool bInPlotSpace = true;
            int  rangeStart   = 0;
            int  rangeOffset  = 0;

            rangeList        = new PlotRangeList();
            result.RangeList = rangeList;


            Scale xAxis = layer.XAxis;
            Scale yAxis = layer.YAxis;

            Gdi.G2DCoordinateSystem coordsys = layer.CoordinateSystem;


            int len = this.PlotRangeEnd;

            for (i = this.PlotRangeStart, j = 0; i < len; i++)
            {
                if (xColumn.IsElementEmpty(i) || yColumn.IsElementEmpty(i))
                {
                    if (!bInPlotSpace)
                    {
                        bInPlotSpace = true;
                        rangeList.Add(new PlotRange(rangeStart, j, rangeOffset));
                    }
                    continue;
                }


                double x_rel, y_rel;
                double xcoord, ycoord;



                x_rel = xAxis.PhysicalVariantToNormal(xColumn[i]);
                y_rel = yAxis.PhysicalVariantToNormal(yColumn[i]);

                // chop relative values to an range of about -+ 10^6
                if (x_rel > MaxRelativeValue)
                {
                    x_rel = MaxRelativeValue;
                }
                if (x_rel < -MaxRelativeValue)
                {
                    x_rel = -MaxRelativeValue;
                }
                if (y_rel > MaxRelativeValue)
                {
                    y_rel = MaxRelativeValue;
                }
                if (y_rel < -MaxRelativeValue)
                {
                    y_rel = -MaxRelativeValue;
                }


                // after the conversion to relative coordinates it is possible
                // that with the choosen axis the point is undefined
                // (for instance negative values on a logarithmic axis)
                // in this case the returned value is NaN
                if (coordsys.LogicalToLayerCoordinates(new Logical3D(x_rel, y_rel), out xcoord, out ycoord))
                {
                    if (bInPlotSpace)
                    {
                        bInPlotSpace = false;
                        rangeStart   = j;
                        rangeOffset  = i - j;
                    }
                    ptArray[j].X = (float)xcoord;
                    ptArray[j].Y = (float)ycoord;

                    j++;
                }
                else
                {
                    if (!bInPlotSpace)
                    {
                        bInPlotSpace = true;
                        rangeList.Add(new PlotRange(rangeStart, j, rangeOffset));
                    }
                }
            } // end for
            if (!bInPlotSpace)
            {
                bInPlotSpace = true;
                rangeList.Add(new PlotRange(rangeStart, j, rangeOffset)); // add the last range
            }
            return(result);
        }