Ejemplo n.º 1
0
 public override void Paint(Graphics g, IPaintContext context, IPlotArea layer, IGPlotItem previousPlotItem, IGPlotItem nextPlotItem)
 {
     if (null != _plotStyle)
     {
         _plotStyle.Paint(g, layer, _plotData);
     }
 }
Ejemplo n.º 2
0
 public void PrepareScales(IPlotArea layer)
 {
     foreach (IGPlotItem pi in _plotItems)
     {
         pi.PrepareScales(layer);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns the index of a scatter point that is nearest to the location <c>hitpoint</c>
        /// </summary>
        /// <param name="layer">The layer in which this plot item is drawn into.</param>
        /// <param name="hitpoint">The point where the mouse is pressed.</param>
        /// <returns>The information about the point that is nearest to the location, or null if it can not be determined.</returns>
        public XYScatterPointInformation GetNearestPlotPoint(IPlotArea layer, PointD2D hitpoint)
        {
            Processed2DPlotData pdata;

            if (null != (pdata = _cachedPlotDataUsedForPainting))
            {
                PlotRangeList rangeList   = pdata.RangeList;
                PointF[]      ptArray     = pdata.PlotPointsInAbsoluteLayerCoordinates;
                double        mindistance = double.MaxValue;
                int           minindex    = -1;
                for (int i = 1; i < ptArray.Length; i++)
                {
                    double distance = Math2D.SquareDistanceLineToPoint(hitpoint, ptArray[i - 1], ptArray[i]);
                    if (distance < mindistance)
                    {
                        mindistance = distance;
                        minindex    = Math2D.Distance(ptArray[i - 1], hitpoint) < Math2D.Distance(ptArray[i], hitpoint) ? i - 1 : i;
                    }
                }
                // ok, minindex is the point we are looking for
                // so we have a look in the rangeList, what row it belongs to
                int rowindex = rangeList.GetRowIndexForPlotIndex(minindex);

                return(new XYScatterPointInformation(ptArray[minindex], rowindex, minindex));
            }

            return(null);
        }
Ejemplo n.º 4
0
        public void SetAttachmentDirection()
        {
            IPlotArea layer = Main.DocumentPath.GetRootNodeImplementing(_doc, typeof(IPlotArea)) as IPlotArea;

            List <ListNode> names = new List <ListNode>();

            int idx = -1;

            if (layer != null)
            {
                int count = -1;
                foreach (CSPlaneID id in layer.CoordinateSystem.GetJoinedPlaneIdentifier(layer.AxisStyleIDs, new CSPlaneID[] { _doc.AttachedAxis }))
                {
                    count++;
                    if (id == _doc.AttachedAxis)
                    {
                        idx = count;
                    }

                    CSPlaneInformation info = layer.CoordinateSystem.GetPlaneInformation(id);
                    names.Add(new ListNode(info.Name, id));
                }
            }

            _view.AttachedAxis_Initialize(names, Math.Max(idx, 0));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Returns the index of a scatter point that is closest to the location <c>hitpoint</c>
        /// </summary>
        /// <param name="layer">The layer in which this plot item is drawn into.</param>
        /// <param name="hitpoint">The point where the mouse is pressed.</param>
        /// <returns>The information about the point that is nearest to the location, or null if it can not be determined.</returns>
        public XYZScatterPointInformation GetNearestPlotPoint(IPlotArea layer, HitTestPointData hitpoint)
        {
            Processed3DPlotData pdata;

            if (null != (pdata = _cachedPlotDataUsedForPainting))
            {
                PlotRangeList rangeList         = pdata.RangeList;
                var           ptArray           = pdata.PlotPointsInAbsoluteLayerCoordinates;
                double        mindistance       = double.MaxValue;
                int           minindex          = -1;
                var           hitTransformation = hitpoint.HitTransformation;
                var           lineStart         = hitTransformation.Transform(ptArray[0]).PointD2DWithoutZ;
                for (int i = 1; i < ptArray.Length; i++)
                {
                    var    lineEnd  = hitTransformation.Transform(ptArray[i]).PointD2DWithoutZ;
                    double distance = Math2D.SquareDistanceLineToPoint(PointD2D.Empty, lineStart, lineEnd);
                    if (distance < mindistance)
                    {
                        mindistance = distance;
                        minindex    = Math2D.Distance(lineStart, PointD2D.Empty) < Math2D.Distance(lineEnd, PointD2D.Empty) ? i - 1 : i;
                    }
                    lineStart = lineEnd;
                }
                // ok, minindex is the point we are looking for
                // so we have a look in the rangeList, what row it belongs to
                int rowindex = rangeList.GetRowIndexForPlotIndex(minindex);

                return(new XYZScatterPointInformation(ptArray[minindex], rowindex, minindex));
            }

            return(null);
        }
Ejemplo n.º 6
0
 public void FixupInternalDataStructures(IPlotArea layer)
 {
     for (int i = 0; i < _axisStyles.Count; ++i)
     {
         _axisStyles[i].FixupInternalDataStructures(layer);
     }
 }
Ejemplo n.º 7
0
 public void PaintPreprocessing(IPlotArea layer)
 {
     for (int i = 0; i < _axisStyles.Count; ++i)
     {
         _axisStyles[i].PaintPreprocessing(layer);
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// For a given plot point of index oldplotindex, finds the index and coordinates of a plot point
        /// of index oldplotindex+increment.
        /// </summary>
        /// <param name="layer">The layer this plot belongs to.</param>
        /// <param name="oldplotindex">Old plot index.</param>
        /// <param name="increment">Increment to the plot index.</param>
        /// <returns>Information about the new plot point find at position (oldplotindex+increment). Returns null if no such point exists.</returns>
        public XYScatterPointInformation GetNextPlotPoint(IPlotArea layer, int oldplotindex, int increment)
        {
            Processed2DPlotData pdata;

            if (null != (pdata = _cachedPlotDataUsedForPainting))
            {
                PlotRangeList rangeList = pdata.RangeList;
                PointF[]      ptArray   = pdata.PlotPointsInAbsoluteLayerCoordinates;
                if (ptArray.Length == 0)
                {
                    return(null);
                }

                int minindex = oldplotindex + increment;
                minindex = Math.Max(minindex, 0);
                minindex = Math.Min(minindex, ptArray.Length - 1);
                // ok, minindex is the point we are looking for
                // so we have a look in the rangeList, what row it belongs to
                int rowindex = rangeList.GetRowIndexForPlotIndex(minindex);
                return(new XYScatterPointInformation(ptArray[minindex], rowindex, minindex));
            }


            return(null);
        }
Ejemplo n.º 9
0
 public void Paint(Graphics g, IPaintContext paintContext, IPlotArea layer)
 {
     for (int i = 0; i < _axisStyles.Count; ++i)
     {
         _axisStyles[i].Paint(g, paintContext, layer);
     }
 }
		public static void Paint(IGraphicsContext3D g, Altaxo.Graph.IPaintContext paintContext, IPlotArea layer, PlotItemCollection coll)
		{
			for (int i = coll.Count - 1; i >= 0; --i)
			{
				coll[i].Paint(g, paintContext, layer, i == coll.Count - 1 ? null : coll[i + 1], i == 0 ? null : coll[i - 1]);
			}
		}
Ejemplo n.º 11
0
        public void GetFillPath(GraphicsPath gp, IPlotArea layer, Processed2DPlotData pdata, CSPlaneID fillDirection)
        {
            PointF[] plotPositions = pdata.PlotPointsInAbsoluteLayerCoordinates;
            if (0 != _cachedLogicalShiftX || 0 != _cachedLogicalShiftY)
            {
                plotPositions = Processed2DPlotData.GetPlotPointsInAbsoluteLayerCoordinatesWithShift(pdata, layer, _cachedLogicalShiftX, _cachedLogicalShiftY);
            }

            PlotRangeList rangeList = pdata.RangeList;

            fillDirection = layer.UpdateCSPlaneID(fillDirection);

            int rangelistlen = rangeList.Count;

            if (_ignoreMissingDataPoints)
            {
                // in case we ignore the missing points, all ranges can be plotted
                // as one range, i.e. continuously
                // for this, we create the totalRange, which contains all ranges
                var totalRange = new PlotRange(rangeList[0].LowerBound, rangeList[rangelistlen - 1].UpperBound);
                _connectionStyle.FillOneRange(gp, pdata, totalRange, layer, fillDirection, _ignoreMissingDataPoints, _connectCircular, plotPositions, _cachedLogicalShiftX, _cachedLogicalShiftY);
            }
            else // we not ignore missing points, so plot all ranges separately
            {
                for (int i = 0; i < rangelistlen; i++)
                {
                    _connectionStyle.FillOneRange(gp, pdata, rangeList[i], layer, fillDirection, _ignoreMissingDataPoints, _connectCircular, plotPositions, _cachedLogicalShiftX, _cachedLogicalShiftY);
                }
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Template to get a fill path.
        /// </summary>
        /// <param name="gp">Graphics path to fill with data.</param>
        /// <param name="pdata">The plot data. Don't use the Range property of the pdata, since it is overriden by the next argument.</param>
        /// <param name="range">The plot range to use.</param>
        /// <param name="layer">Graphics layer.</param>
        /// <param name="fillDirection">Designates a bound to fill to.</param>
        /// <param name="linePoints">The points that mark the line.</param>
        /// <param name="connectCircular">If true, a circular connection is drawn.</param>
        private void FillOneRange_PreprocessedPoints(
            GraphicsPath gp,
            Processed2DPlotData pdata,
            IPlotRange range,
            IPlotArea layer,
            CSPlaneID fillDirection,
            PointF[] linePoints,
            bool connectCircular,
            double logicalShiftX,
            double logicalShiftY
            )
        {
            if (connectCircular)
            {
                gp.AddBeziers(linePoints);
                gp.CloseFigure();
            }
            else
            {
                Logical3D r0 = layer.GetLogical3D(pdata, range.OriginalFirstPoint);
                r0.RX += logicalShiftX;
                r0.RY += logicalShiftY;
                layer.CoordinateSystem.GetIsolineFromPlaneToPoint(gp, fillDirection, r0);
                gp.AddBeziers(linePoints);

                Logical3D r1 = layer.GetLogical3D(pdata, range.GetOriginalRowIndexFromPlotPointIndex(range.LowerBound + linePoints.Length - 1));
                r1.RX += logicalShiftX;
                r1.RY += logicalShiftY;

                layer.CoordinateSystem.GetIsolineFromPointToPlane(gp, r1, fillDirection);
                layer.CoordinateSystem.GetIsolineOnPlane(gp, fillDirection, r1, r0);

                gp.CloseFigure();
            }
        }
Ejemplo n.º 13
0
 public void PaintTitle(Graphics g, IPaintContext paintContext, IPlotArea layer)
 {
     if (IsTitleEnabled)
     {
         _axisTitle.Paint(g, paintContext);
     }
 }
Ejemplo n.º 14
0
        private void BuildImage(Graphics gfrx, IPlotArea gl, XYZMeshedColumnPlotData myPlotAssociation, IROMatrix <double> matrix, IReadOnlyList <double> logicalRowHeaderValues, IReadOnlyList <double> logicalColumnHeaderValues)
        {
            // ---------------- prepare the color scaling -------------------------------------

            // --------------- end preparation of color scaling ------------------------------

            // test if the coordinate system is affine and the scale is linear
            if (!gl.CoordinateSystem.IsAffine)
            {
                BuildImageV3(gfrx, gl, logicalRowHeaderValues, logicalColumnHeaderValues, matrix);
            }
            else // Coordinate System is affine
            {
                // now test lx and ly (only the valid indices for equidistantness
                bool isEquististantX = IsEquidistant(logicalRowHeaderValues, 0.2);
                bool isEquististantY = IsEquidistant(logicalColumnHeaderValues, 0.2);

                bool areLinearScales = (gl.XAxis is LinearScale) && (gl.YAxis is LinearScale);

                if (areLinearScales && isEquististantX && isEquististantY)
                {
                    BuildImageV1(matrix); // affine, linear scales, and equidistant points
                }
                else if (areLinearScales)
                {
                    BuildImageV3(gfrx, gl, logicalRowHeaderValues, logicalColumnHeaderValues, matrix); // affine and linear, but nonequidistant scale
                }
                else
                {
                    BuildImageV3(gfrx, gl, logicalRowHeaderValues, logicalColumnHeaderValues, matrix); // affine, but nonlinear scales
                }
            }
        }
		protected override PointF[] GetStepPolylinePoints(
		PointF[] allLinePoints,
		IPlotRange range,
		IPlotArea layer,
		bool connectCircular,
		out int numberOfPointsPerOriginalPoint,
		out int lastIndex)
		{
			numberOfPointsPerOriginalPoint = 3;

			PointF[] subLinePoints = new PointF[numberOfPointsPerOriginalPoint * (range.Length - 1 + (connectCircular ? 1 : 0)) + 1];
			int end = range.UpperBound - 1;
			int i, j;
			for (i = 0, j = range.LowerBound; j < end; i += numberOfPointsPerOriginalPoint, j++)
			{
				subLinePoints[i] = allLinePoints[j];
				subLinePoints[i + 1] = new PointF((allLinePoints[j].X + allLinePoints[j + 1].X) / 2, allLinePoints[j].Y);
				subLinePoints[i + 2] = new PointF((allLinePoints[j].X + allLinePoints[j + 1].X) / 2, allLinePoints[j + 1].Y);
			}
			subLinePoints[i] = allLinePoints[j];
			lastIndex = i;

			if (connectCircular)
			{
				subLinePoints[i + 1] = new PointF((allLinePoints[j].X + allLinePoints[range.LowerBound].X) / 2, allLinePoints[j].Y);
				subLinePoints[i + 2] = new PointF((allLinePoints[j].X + allLinePoints[range.LowerBound].X) / 2, allLinePoints[range.LowerBound].Y);
				subLinePoints[i + 3] = allLinePoints[range.LowerBound];
				lastIndex = i + 3;
			}
			return subLinePoints;
		}
Ejemplo n.º 16
0
        public void Paint(Graphics g, IPlotArea layer, Altaxo.Graph.Gdi.Plot.Data.Processed2DPlotData pdata, Processed2DPlotData prevItemData, Processed2DPlotData nextItemData)
        {
            if (_fillToPrevPlotItem && null != prevItemData)
            {
                PaintFillToPrevPlotItem(g, layer, pdata, prevItemData);
            }

            if (_fillToNextPlotItem && null != nextItemData)
            {
                // ensure that brush and pen are cached
                if (null != _fillBrush)
                {
                    _fillBrush.SetEnvironment(new RectangleD2D(PointD2D.Empty, layer.Size), BrushX.GetEffectiveMaximumResolution(g, 1));
                }

                PlotRangeList rangeList    = pdata.RangeList;
                int           rangelistlen = rangeList.Count;

                if (rangelistlen > 0)
                {
                    // we have to ignore the missing points here, thus all ranges can be plotted
                    // as one range, i.e. continuously
                    // for this, we create the totalRange, which contains all ranges
                    var totalRange = new PlotRange(rangeList[0].LowerBound, rangeList[rangelistlen - 1].UpperBound);
                    _cachedPaintOneRange(g, pdata, totalRange, layer, nextItemData);
                }
            }
        }
Ejemplo n.º 17
0
 /// <summary>
 /// This routine ensures that the plot item updates all its cached data and send the appropriate
 /// events if something has changed. Called before the layer paint routine paints the axes because
 /// it must be ensured that the axes are scaled correctly before the plots are painted.
 /// </summary>
 /// <param name="layer">The plot layer.</param>
 public override void PrepareScales(IPlotArea layer)
 {
     if (null != this._plotData)
     {
         _plotData.CalculateCachedData(layer.XAxis.DataBoundsObject, layer.YAxis.DataBoundsObject);
     }
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Gets the sub points for a given range. For step connections, at least one points needs to be inserted inbetween two original points, for some step connection styles two points.
 /// </summary>
 /// <param name="pdata">The pdata.</param>
 /// <param name="range">The range.</param>
 /// <param name="layer">The layer.</param>
 /// <param name="connectCircular">if set to <c>true</c> [connect circular].</param>
 /// <param name="numberOfPointsPerOriginalPoint">The number of points per original point. For most step styles one additional point is inserted, thus the return value is 2. For some connection styles, two points are inserted inbetween two original points, thus the return value will be 3.</param>
 /// <param name="lastIndex">The last index.</param>
 /// <returns></returns>
 protected abstract PointF[] GetStepPolylinePoints(
     PointF[] pdata,
     IPlotRange range,
     IPlotArea layer,
     bool connectCircular,
     out int numberOfPointsPerOriginalPoint,
     out int lastIndex);
Ejemplo n.º 19
0
        /// <summary>
        /// Gives the path where the hit test is successfull.
        /// </summary>
        /// <param name="layer"></param>
        /// <param name="withTicks">If true, the selection path is not only drawn around the axis, but around the axis and the ticks.</param>
        /// <param name="inflateby">Value in points, that the calculated path is inflated.</param>
        /// <returns>The graphics path of the selection rectangle.</returns>
        protected GraphicsPath GetPath(IPlotArea layer, bool withTicks, double inflateby)
        {
            Logical3D r0 = _cachedAxisStyleInfo.Identifier.GetLogicalPoint(_cachedAxisStyleInfo.LogicalValueAxisOrg);
            Logical3D r1 = _cachedAxisStyleInfo.Identifier.GetLogicalPoint(_cachedAxisStyleInfo.LogicalValueAxisEnd);
            var       gp = new GraphicsPath();

            layer.CoordinateSystem.GetIsoline(gp, r0, r1);

            if (withTicks)
            {
                if (_showFirstDownMajorTicks || _showFirstUpMajorTicks)
                {
                    inflateby = Math.Max(inflateby, _majorTickLength);
                }
                if (_showFirstDownMinorTicks || _showFirstUpMinorTicks)
                {
                    inflateby = Math.Max(inflateby, _minorTickLength);
                }
            }

            var widenPen = new Pen(System.Drawing.Color.Black, (float)(2 * inflateby));

            gp.Widen(widenPen);

            return(gp);
        }
Ejemplo n.º 20
0
 /// <summary>
 /// This routine ensures that the plot item updates all its cached data and send the appropriate
 /// events if something has changed. Called before the layer paint routine paints the axes because
 /// it must be ensured that the axes are scaled correctly before the plots are painted.
 /// </summary>
 /// <param name="layer">The plot layer.</param>
 public override void PrepareScales(IPlotArea layer)
 {
     if (null != this.m_PlotAssociation)
     {
         m_PlotAssociation.CalculateCachedData();
     }
 }
Ejemplo n.º 21
0
		/// <summary>
		/// Gets the sub points for a given range. For step connections, at least one points needs to be inserted inbetween two original points, for some step connection styles two points.
		/// </summary>
		/// <param name="pdata">The pdata.</param>
		/// <param name="range">The range.</param>
		/// <param name="layer">The layer.</param>
		/// <param name="connectCircular">if set to <c>true</c> [connect circular].</param>
		/// <param name="numberOfPointsPerOriginalPoint">The number of points per original point. For most step styles one additional point is inserted, thus the return value is 2. For some connection styles, two points are inserted inbetween two original points, thus the return value will be 3.</param>
		/// <param name="lastIndex">The last index.</param>
		/// <returns></returns>
		protected abstract PointF[] GetStepPolylinePoints(
		PointF[] pdata,
		IPlotRange range,
		IPlotArea layer,
		bool connectCircular,
		out int numberOfPointsPerOriginalPoint,
		out int lastIndex);
Ejemplo n.º 22
0
        /// <summary>
        /// Paint the density image in the layer.
        /// </summary>
        /// <param name="gfrx">The graphics context painting in.</param>
        /// <param name="gl">The layer painting in.</param>
        /// <param name="plotObject">The data to plot.</param>
        public void Paint(IGraphicsContext3D gfrx, IPlotArea gl, object plotObject) // plots the curve with the choosen style
        {
            if (!(plotObject is XYZMeshedColumnPlotData))
            {
                return; // we cannot plot any other than a TwoDimMeshDataAssociation now
            }
            var myPlotAssociation = (XYZMeshedColumnPlotData)plotObject;

            myPlotAssociation.DataTableMatrix.GetWrappers(
                gl.XAxis.PhysicalVariantToNormal, // transformation function for row header values
                Altaxo.Calc.RMath.IsFinite,       // selection functiton for row header values
                gl.YAxis.PhysicalVariantToNormal, // transformation function for column header values
                Altaxo.Calc.RMath.IsFinite,       // selection functiton for column header values
                out var matrix,
                out var logicalRowHeaderValues,
                out var logicalColumnHeaderValues
                );

            int cols = matrix.ColumnCount;
            int rows = matrix.RowCount;

            if (cols <= 1 || rows <= 1)
            {
                return; // we cannot plot anything  if one length is zero or one
            }
            BuildImage(gfrx, gl, myPlotAssociation, matrix, logicalRowHeaderValues, logicalColumnHeaderValues);
        }
Ejemplo n.º 23
0
 public override void Paint(Graphics g, IPlotArea layer)
 {
     if (null != this.m_PlotStyle)
     {
         m_PlotStyle.Paint(g, layer, m_PlotAssociation);
     }
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Paints the grid of all planes, but not the background.
 /// </summary>
 /// <param name="g">The g.</param>
 /// <param name="layer">The layer.</param>
 public void PaintGrid(IGraphicsContext3D g, IPlotArea layer)
 {
     for (int i = 0; i < _innerList.Count; ++i)
     {
         _innerList[i].PaintGrid(g, layer);
     }
 }
Ejemplo n.º 25
0
 public void Paint(Graphics g, IPlotArea layer, Processed2DPlotData pdata)
 {
     for (int i = _innerList.Count - 1; i >= 0; i--)
     {
         this[i].Paint(g, layer, pdata);
     }
 }
Ejemplo n.º 26
0
        public void Paint(Graphics g, IPlotArea layer, Processed2DPlotData pdata, Processed2DPlotData prevItemData, Processed2DPlotData nextItemData)
        {
            // adjust the skip frequency if it was not set appropriate
            if (_skipFrequency <= 0)
            {
                _skipFrequency = 1;
            }

            if (_independentOnShiftingGroupStyles)
            {
                _cachedLogicalShiftX = _cachedLogicalShiftY = 0;
            }

            PlotRangeList rangeList = pdata.RangeList;

            if (_ignoreMissingDataPoints)
            {
                // in case we ignore the missing points, all ranges can be plotted
                // as one range, i.e. continuously
                // for this, we create the totalRange, which contains all ranges
                var totalRange = new PlotRangeCompound(rangeList);
                PaintOneRange(g, layer, totalRange, pdata);
            }
            else // we not ignore missing points, so plot all ranges separately
            {
                for (int i = 0; i < rangeList.Count; i++)
                {
                    PaintOneRange(g, layer, rangeList[i], pdata);
                }
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Prepares a new substyle (one that is not already in the collection) for becoming member of the collection. The substyle will get
        /// all distributes group properties (local only) of this style collection.
        /// </summary>
        /// <param name="newSubStyle">Sub style to prepare.</param>
        /// <param name="layer"></param>
        /// <param name="pdata"></param>
        public void PrepareNewSubStyle(IG2DPlotStyle newSubStyle, IPlotArea layer, Processed2DPlotData pdata)
        {
            PlotGroupStyleCollection externGroup = new PlotGroupStyleCollection();
            PlotGroupStyleCollection localGroup  = new PlotGroupStyleCollection();

            // because we don't step, the order is essential only for PrepareStyles
            for (int i = 0; i < _innerList.Count; i++)
            {
                this[i].CollectLocalGroupStyles(externGroup, localGroup);
            }
            newSubStyle.CollectLocalGroupStyles(externGroup, localGroup);



            // prepare
            for (int i = 0; i < Count; i++)
            {
                this[i].PrepareGroupStyles(externGroup, localGroup, layer, pdata);
            }
            newSubStyle.PrepareGroupStyles(externGroup, localGroup, layer, pdata);

            // apply
            for (int i = 0; i < Count; i++)
            {
                this[i].ApplyGroupStyles(externGroup, localGroup);
            }
            newSubStyle.ApplyGroupStyles(externGroup, localGroup);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Distibute changes made to one group style of the collection (at index <c>pivot</c> to all other members of the collection.
        /// </summary>
        /// <param name="pivot">Index of the group style that was changed. This style keeps it's properties.</param>
        /// <param name="layer"></param>
        /// <param name="pdata"></param>
        public void DistributeSubStyleChange(int pivot, IPlotArea layer, Processed2DPlotData pdata)
        {
            PlotGroupStyleCollection externGroup = new PlotGroupStyleCollection();
            PlotGroupStyleCollection localGroup  = new PlotGroupStyleCollection();

            // because we don't step, the order is essential only for PrepareStyles
            for (int i = 0; i < _innerList.Count; i++)
            {
                CollectLocalGroupStyles(externGroup, localGroup);
            }

            // prepare
            this[pivot].PrepareGroupStyles(externGroup, localGroup, layer, pdata);
            for (int i = 0; i < Count; i++)
            {
                if (i != pivot)
                {
                    this[i].PrepareGroupStyles(externGroup, localGroup, layer, pdata);
                }
            }

            // apply
            this[pivot].ApplyGroupStyles(externGroup, localGroup);
            for (int i = 0; i < Count; i++)
            {
                if (i != pivot)
                {
                    this[i].ApplyGroupStyles(externGroup, localGroup);
                }
            }
        }
Ejemplo n.º 29
0
 /// <summary>
 /// Prepares the scales of the plot styles. This is intended to be used with plot styles which
 /// have an internal scale, for instance <see cref="Gdi.Plot.Styles.ColumnDrivenColorPlotStyle"/> or
 /// <see cref="Gdi.Plot.Styles.ColumnDrivenSymbolSizePlotStyle"/>, which should act on this call with updating their internal scale.
 /// </summary>
 /// <param name="layer">The parent layer.</param>
 public void PrepareScales(IPlotArea layer)
 {
     for (int i = _innerList.Count - 1; i >= 0; i--)
     {
         this[i].PrepareScales(layer);
     }
 }
		public static void Paint(System.Drawing.Graphics g, IPaintContext paintContext, IPlotArea layer, PlotItemCollection coll)
		{
			for (int i = coll.Count - 1; i >= 0; --i)
			{
				coll[i].Paint(g, paintContext, layer, i == coll.Count - 1 ? null : coll[i + 1], i == 0 ? null : coll[i - 1]);
			}
		}
Ejemplo n.º 31
0
 public void Paint(Graphics g, IPlotArea layer)
 {
     for (int i = 0; i < _innerList.Count; ++i)
     {
         _innerList[i].Paint(g, layer);
     }
 }
 public static void Paint(System.Drawing.Graphics g, IPlotArea layer, PlotItemCollection coll)
 {
     foreach (IGPlotItem pi in coll)
     {
         pi.Paint(g, layer);
     }
 }
Ejemplo n.º 33
0
        protected override PointF[] GetStepPolylinePoints(
            PointF[] allLinePoints,
            IPlotRange range,
            IPlotArea layer,
            bool connectCircular,
            out int numberOfPointsPerOriginalPoint,
            out int lastIndex)
        {
            numberOfPointsPerOriginalPoint = 2;

            var subLinePoints = new PointF[range.Length * 2 - 1 + (connectCircular ? 2 : 0)];
            int end = range.UpperBound - 1;
            int i, j;

            for (i = 0, j = range.LowerBound; j < end; i += 2, j++)
            {
                subLinePoints[i]       = allLinePoints[j];
                subLinePoints[i + 1].X = allLinePoints[j + 1].X;
                subLinePoints[i + 1].Y = allLinePoints[j].Y;
            }
            subLinePoints[i] = allLinePoints[j];
            lastIndex        = i;

            if (connectCircular)
            {
                subLinePoints[i + 1] = new PointF(allLinePoints[range.LowerBound].X, allLinePoints[j].Y);
                subLinePoints[i + 2] = allLinePoints[range.LowerBound];
                lastIndex            = i + 2;
            }
            return(subLinePoints);
        }
Ejemplo n.º 34
0
        public void PaintChild(IGraphicsContext3D g, IPaintContext paintContext, IPlotArea layer, PlotItemCollection coll, int indexOfChild)
        {
            var plotDataDict = paintContext.GetValueOrDefault <Dictionary <G3DPlotItem, Processed3DPlotData> >(this);

            if (null == plotDataDict) // if initializing this dict was not successfull, then make a normal plot
            {
                coll[indexOfChild].Paint(g, paintContext, layer, indexOfChild == coll.Count - 1 ? null : coll[indexOfChild + 1], indexOfChild == 0 ? null : coll[indexOfChild - 1]);
                return;
            }

            Processed3DPlotData prevPlotData = null;
            Processed3DPlotData nextPlotData = null;

            if ((indexOfChild + 1) < coll.Count && (coll[indexOfChild + 1] is G3DPlotItem))
            {
                prevPlotData = plotDataDict[coll[indexOfChild + 1] as G3DPlotItem];
            }

            if (indexOfChild > 0 && (coll[indexOfChild - 1] is G3DPlotItem))
            {
                nextPlotData = plotDataDict[coll[indexOfChild - 1] as G3DPlotItem];
            }

            if (coll[indexOfChild] is G3DPlotItem)
            {
                var gpi = coll[indexOfChild] as G3DPlotItem;
                gpi.Paint(g, layer, plotDataDict[gpi], prevPlotData, nextPlotData);
            }
            else
            {
                coll[indexOfChild].Paint(g, paintContext, layer, null, null);
            }
        }
Ejemplo n.º 35
0
		/// <summary>
		/// Template to make a line draw.
		/// </summary>
		/// <param name="g">Graphics context.</param>
		/// <param name="pdata">The plot data. Don't use the Range property of the pdata, since it is overriden by the next argument.</param>
		/// <param name="range">The plot range to use.</param>
		/// <param name="layer">Graphics layer.</param>
		/// <param name="pen">The pen to draw the line.</param>
		/// <param name="symbolGap">The size of the symbol gap. Argument is the original index of the data. The return value is the absolute symbol gap at this index.
		/// This function is null if no symbol gap is required.</param>
		/// <param name="skipFrequency">Skip frequency. Normally 1, thus all gaps are taken into account. If 2, only every 2nd gap is taken into account, and so on.</param>
		/// <param name="connectCircular">If true, the end of the line is connected with the start of the line.</param>
		public abstract void Paint(
			IGraphicsContext3D g,
			Processed3DPlotData pdata,
			PlotRange range,
			IPlotArea layer,
			PenX3D pen,
			Func<int, double> symbolGap,
			int skipFrequency,
			bool connectCircular);
    public void MergeYBoundsInto(IPlotArea layer, IPhysicalBoundaries pb, PlotItemCollection coll)
    {
      Dictionary<G2DPlotItem, Processed2DPlotData> plotDataList;
      IPhysicalBoundaries pbclone = (IPhysicalBoundaries)pb.Clone(); // before we can use CanUseStyle, we have to give physical y boundaries template
      CoordinateTransformingStyleBase.MergeYBoundsInto(pbclone, coll);
      if (!CanUseStyle(layer, coll, out plotDataList))
      {
        pb.Add(pbclone);
        return;
      }

      // we put zero into the y-Boundaries, since the addition starts with that value
      pb.Add(new AltaxoVariant(0.0));

      AltaxoVariant[] ySumArray = null;

      int idx = -1;
      foreach (IGPlotItem pi in coll)
      {
        if (pi is G2DPlotItem)
        {
          idx++;

          G2DPlotItem gpi = (G2DPlotItem)pi;
          Processed2DPlotData pdata = plotDataList[gpi];

          // Note: we can not use AddUp function here, since
          // when we have positive/negative items, the intermediate bounds
          // might be wider than the bounds of the end result

          if (ySumArray == null)
          {
            ySumArray = new AltaxoVariant[pdata.RangeList.PlotPointCount];

            int j = -1;
            foreach (int originalIndex in pdata.RangeList.OriginalRowIndices())
            {
              j++;
              ySumArray[j] = pdata.GetYPhysical(originalIndex);
              pb.Add(ySumArray[j]);
            }
          }
          else // this is not the first item
          {
            int j = -1;
            foreach (int originalIndex in pdata.RangeList.OriginalRowIndices())
            {
              j++;
              ySumArray[j] += pdata.GetYPhysical(originalIndex);
              pb.Add(ySumArray[j]);

            }
          }
        }
      }
    }
Ejemplo n.º 37
0
		/// <summary>
		/// Template to make a line draw.
		/// </summary>
		/// <param name="g">Graphics context.</param>
		/// <param name="allLinePoints">The plot data. Don't use the Range property of the pdata, since it is overriden by the next argument.</param>
		/// <param name="range">The plot range to use.</param>
		/// <param name="layer">Graphics layer.</param>
		/// <param name="linePen">The pen to draw the line.</param>
		/// <param name="symbolGap">The size of the symbol gap. Argument is the original index of the data. The return value is the absolute symbol gap at this index.
		/// This function is null if no symbol gap is required.</param>
		/// <param name="skipFrequency">Skip frequency. Normally 1, thus all gaps are taken into account. If 2, only every 2nd gap is taken into account, and so on.</param>
		/// <param name="connectCircular">If true, there is a line connecting the start and the end of the range.</param>
		/// <param name="linePlotStyle">The line plot style.</param>
		public override void PaintOneRange(
			Graphics g,
			PointF[] allLinePoints,
			IPlotRange range,
			IPlotArea layer,
			PenX linePen,
			Func<int, double> symbolGap,
			int skipFrequency,
			bool connectCircular,
			LinePlotStyle linePlotStyle)
		{
			if (range.Length < 2)
				return;

			int lastIdx;
			int numberOfPointsPerOriginalPoint;
			PointF[] stepPolylinePoints = GetStepPolylinePoints(allLinePoints, range, layer, connectCircular, out numberOfPointsPerOriginalPoint, out lastIdx);

			GraphicsPath gp = new GraphicsPath();

			if (null != symbolGap)
			{
				int end = range.UpperBound - 1;

				var subPointsLength = skipFrequency * numberOfPointsPerOriginalPoint + 1;
				for (int i = 0; i < range.Length; i += skipFrequency)
				{

					int partialPolylineLength = Math.Min(subPointsLength, stepPolylinePoints.Length - numberOfPointsPerOriginalPoint * i);
					if (partialPolylineLength < 2)
						continue; // happens probably at the end of the range if there are not enough points to draw

					double gapAtStart = symbolGap(range.GetOriginalRowIndexFromPlotPointIndex(range.LowerBound + i));
					double gapAtEnd;
					if (connectCircular && skipFrequency >= (range.Length - i))
						gapAtEnd = symbolGap(range.OriginalFirstPoint);
					else if (skipFrequency <= (range.Length - 1 - i))
						gapAtEnd = symbolGap(range.GetOriginalRowIndexFromPlotPointIndex(range.LowerBound + i + skipFrequency));
					else
						gapAtEnd = 0;

					int startOfPartialPolyline = numberOfPointsPerOriginalPoint * i;
					var shortenedPolyline = stepPolylinePoints.ShortenPartialPolylineByDistanceFromStartAndEnd(startOfPartialPolyline, startOfPartialPolyline + partialPolylineLength - 1, gapAtStart / 2, gapAtEnd / 2);

					if (null != shortenedPolyline)
						g.DrawLines(linePen, shortenedPolyline);
				}
			}
			else
			{
				if (connectCircular)
					g.DrawPolygon(linePen, stepPolylinePoints);
				else
					g.DrawLines(linePen, stepPolylinePoints);
			}
		}
Ejemplo n.º 38
0
		/// <summary>
		/// Template to make a line draw.
		/// </summary>
		/// <param name="g">Graphics context.</param>
		/// <param name="allLinePoints">The plot data. Don't use the Range property of the pdata, since it is overriden by the next argument.</param>
		/// <param name="range">The plot range to use.</param>
		/// <param name="layer">Graphics layer.</param>
		/// <param name="pen">The pen to draw the line.</param>
		/// <param name="symbolGap">The size of the symbol gap. Argument is the original index of the data. The return value is the absolute symbol gap at this index.
		/// This function is null if no symbol gap is required.</param>
		/// <param name="skipFrequency">Skip frequency. Normally 1, thus all gaps are taken into account. If 2, only every 2nd gap is taken into account, and so on.</param>
		/// <param name="connectCircular">If true, the line is connected circular, and the area is the polygon inside of that circular connection.</param>
		/// <param name="linePlotStyle">The line plot style.</param>
		public abstract void PaintOneRange(
			Graphics g,
			PointF[] allLinePoints,
			IPlotRange range,
			IPlotArea layer,
			PenX pen,
			Func<int, double> symbolGap,
			int skipFrequency,
			bool connectCircular,
			LinePlotStyle linePlotStyle
);
    public void MergeYBoundsInto(IPlotArea layer, IPhysicalBoundaries pb, PlotItemCollection coll)
    {
      Dictionary<G2DPlotItem, Processed2DPlotData> plotDataList;
      IPhysicalBoundaries pbclone = (IPhysicalBoundaries)pb.Clone(); // before we can use CanUseStyle, we have to give physical y boundaries template
      CoordinateTransformingStyleBase.MergeYBoundsInto(pbclone, coll);
      if (!CanUseStyle(layer, coll, out plotDataList))
      {
        pb.Add(pbclone);
        return;
      }

      pb.Add(0);
      pb.Add(100);
    }
Ejemplo n.º 40
0
		public void PaintChild(IGraphicsContext3D g, IPaintContext paintContext, IPlotArea layer, PlotItemCollection coll, int indexOfChild)
		{
			var plotDataDict = paintContext.GetValueOrDefault<Dictionary<G3DPlotItem, Processed3DPlotData>>(this);

			if (null == plotDataDict) // if initializing this dict was not successfull, then make a normal plot
			{
				coll[indexOfChild].Paint(g, paintContext, layer, indexOfChild == coll.Count - 1 ? null : coll[indexOfChild + 1], indexOfChild == 0 ? null : coll[indexOfChild - 1]);
				return;
			}

			Processed3DPlotData prevPlotData = null;
			Processed3DPlotData nextPlotData = null;

			if ((indexOfChild + 1) < coll.Count && (coll[indexOfChild + 1] is G3DPlotItem))
				prevPlotData = plotDataDict[coll[indexOfChild + 1] as G3DPlotItem];

			if (indexOfChild > 0 && (coll[indexOfChild - 1] is G3DPlotItem))
				nextPlotData = plotDataDict[coll[indexOfChild - 1] as G3DPlotItem];

			if (coll[indexOfChild] is G3DPlotItem)
			{
				var gpi = coll[indexOfChild] as G3DPlotItem;
				gpi.Paint(g, layer, plotDataDict[gpi], prevPlotData, nextPlotData);
			}
			else
			{
				coll[indexOfChild].Paint(g, paintContext, layer, null, null);
			}
		}
Ejemplo n.º 41
0
		public void PaintPreprocessing(IPaintContext paintContext, IPlotArea layer, PlotItemCollection coll)
		{
			Dictionary<G3DPlotItem, Processed3DPlotData> plotDataDict = null;
			if (!CanUseStyle(layer, coll, out plotDataDict))
			{
				return;
			}
			else
			{
				paintContext.AddValue(this, plotDataDict);
			}

			AltaxoVariant[] vArray = null;
			// First, add up all items since we start always with the last item
			int idx = -1;
			Processed3DPlotData previousItemData = null;
			foreach (IGPlotItem pi in coll)
			{
				if (pi is G3DPlotItem)
				{
					idx++;

					G3DPlotItem gpi = pi as G3DPlotItem;
					Processed3DPlotData pdata = plotDataDict[gpi];
					vArray = AddUp(vArray, pdata);

					if (idx > 0) // this is not the first item
					{
						int j = -1;
						foreach (int originalIndex in pdata.RangeList.OriginalRowIndices())
						{
							j++;
							Logical3D rel = new Logical3D(
							layer.XAxis.PhysicalVariantToNormal(pdata.GetXPhysical(originalIndex)),
							layer.YAxis.PhysicalVariantToNormal(pdata.GetYPhysical(originalIndex)),
							layer.ZAxis.PhysicalVariantToNormal(vArray[j]));

							PointD3D pabs;
							layer.CoordinateSystem.LogicalToLayerCoordinates(rel, out pabs);
							pdata.PlotPointsInAbsoluteLayerCoordinates[j] = pabs;
						}
					}

					// we have also to exchange the accessor for the physical y value and replace it by our own one
					AltaxoVariant[] localArray = (AltaxoVariant[])vArray.Clone();
					LocalArrayHolder localArrayHolder = new LocalArrayHolder(localArray, pdata);
					pdata.ZPhysicalAccessor = localArrayHolder.GetPhysical;
					pdata.PreviousItemData = previousItemData;
					previousItemData = pdata;
				}
			}
		}
Ejemplo n.º 42
0
		/// <summary>
		/// Determines whether the plot items in <paramref name="coll"/> can be plotted as stack. Presumption is that all plot items
		/// have the same number of plot points, and that all items have the same order of x values associated with the plot points.
		/// </summary>
		/// <param name="layer">Plot layer.</param>
		/// <param name="coll">Collection of plot items.</param>
		/// <param name="plotDataList">Output: dictionary with associates each plot item with a list of processed plot data.</param>
		/// <returns>Returns <c>true</c> if the plot items in <paramref name="coll"/> can be plotted as stack; otherwise, <c>false</c>.</returns>
		public static bool CanUseStyle(IPlotArea layer, PlotItemCollection coll, out Dictionary<G3DPlotItem, Processed3DPlotData> plotDataList)
		{
			plotDataList = new Dictionary<G3DPlotItem, Processed3DPlotData>();

			AltaxoVariant[] xArray = null;
			AltaxoVariant[] yArray = null;

			int idx = -1;
			foreach (IGPlotItem pi in coll)
			{
				if (pi is G3DPlotItem)
				{
					idx++;
					G3DPlotItem gpi = (G3DPlotItem)pi;
					Processed3DPlotData pdata = gpi.GetRangesAndPoints(layer);
					plotDataList.Add(gpi, pdata);

					if (xArray == null)
					{
						xArray = new AltaxoVariant[pdata.RangeList.PlotPointCount];
						yArray = new AltaxoVariant[pdata.RangeList.PlotPointCount];

						int j = -1;
						foreach (int originalIndex in pdata.RangeList.OriginalRowIndices())
						{
							j++;
							xArray[j] = pdata.GetXPhysical(originalIndex);
							yArray[j] = pdata.GetYPhysical(originalIndex);
						}
					}
					else // this is not the first item
					{
						if (pdata.RangeList.PlotPointCount != xArray.Length)
							return false;

						int j = -1;
						foreach (int originalIndex in pdata.RangeList.OriginalRowIndices())
						{
							j++;

							if (xArray[j] != pdata.GetXPhysical(originalIndex))
								return false;

							if (yArray[j] != pdata.GetYPhysical(originalIndex))
								return false;
						}
					}
				}
			}

			return idx >= 1;
		}
Ejemplo n.º 43
0
		/// <inheritdoc/>
		public override void FillOneRange(
		GraphicsPath gp,
			Processed2DPlotData pdata,
			IPlotRange rangeRaw,
			IPlotArea layer,
			CSPlaneID fillDirection,
			bool ignoreMissingDataPoints,
			bool connectCircular,
			PointF[] allLinePointsShiftedAlready,
			double logicalShiftX,
			double logicalShiftY
		)
		{
		}
Ejemplo n.º 44
0
		public void FixupInternalDataStructures(IPlotArea layer)
		{
			FixupInternalDataStructures(layer, layer.CoordinateSystem.GetAxisStyleInformation);
		}
Ejemplo n.º 45
0
    protected void PaintXErrorBars(System.Drawing.Graphics g, IPlotArea layer, Altaxo.Graph.Gdi.Plot.Data.Processed2DPlotData pdata)
    {

      // Plot error bars for the independent variable (x)
      PlotRangeList rangeList = pdata.RangeList;
      PointF[] ptArray = pdata.PlotPointsInAbsoluteLayerCoordinates;
      INumericColumn posErrCol = _positiveErrorColumn.Document;
      INumericColumn negErrCol = _negativeErrorColumn.Document;

      if (posErrCol == null && negErrCol == null)
        return; // nothing to do if both error columns are null

      System.Drawing.Drawing2D.GraphicsPath errorBarPath = new System.Drawing.Drawing2D.GraphicsPath();

      Region oldClippingRegion = g.Clip;
      Region newClip = (Region)oldClippingRegion.Clone();

      foreach (PlotRange r in rangeList)
      {
        int lower = r.LowerBound;
        int upper = r.UpperBound;
        int offset = r.OffsetToOriginal;
        for (int j = lower; j < upper; j++)
        {
          AltaxoVariant x = pdata.GetXPhysical(j + offset);
          Logical3D lm = layer.GetLogical3D(pdata, j + offset);
          lm.RX += _cachedLogicalShiftOfIndependent;
          if (lm.IsNaN)
            continue;

          Logical3D lh = lm;
          Logical3D ll = lm;
          bool lhvalid = false;
          bool llvalid = false;
          if (posErrCol != null)
          {
            lh.RX = layer.XAxis.PhysicalVariantToNormal(x + Math.Abs(posErrCol[j + offset]));
            lhvalid = !lh.IsNaN;
          }
          if (negErrCol != null)
          {
            ll.RX = layer.XAxis.PhysicalVariantToNormal(x - Math.Abs(negErrCol[j + offset]));
            llvalid = !ll.IsNaN;
          }
          if (!(lhvalid || llvalid))
            continue; // nothing to do for this point if both pos and neg logical point are invalid.

          // now paint the error bar
          if (_symbolGap) // if symbol gap, then clip the painting, exclude a rectangle of size symbolSize x symbolSize
          {
            double xlm, ylm;
            layer.CoordinateSystem.LogicalToLayerCoordinates(lm, out xlm, out ylm);
            newClip.Union(oldClippingRegion);
            newClip.Exclude(new RectangleF((float)(xlm - _symbolSize / 2), (float)(ylm - _symbolSize / 2), _symbolSize, _symbolSize));
            g.Clip = newClip;
          }

          if (lhvalid && llvalid)
          {
            errorBarPath.Reset();
            layer.CoordinateSystem.GetIsoline(errorBarPath, ll, lm);
            layer.CoordinateSystem.GetIsoline(errorBarPath, lm, lh);
            g.DrawPath(_strokePen, errorBarPath);
          }
          else if (llvalid)
          {
            layer.CoordinateSystem.DrawIsoline(g, _strokePen, ll, lm);
          }
          else if (lhvalid)
          {
            layer.CoordinateSystem.DrawIsoline(g, _strokePen, lm, lh);
          }


          // now the end bars
          if (_showEndBars)
          {
            if (lhvalid)
            {
              PointF outDir;
              layer.CoordinateSystem.GetNormalizedDirection(lm, lh, 1, new Logical3D(0, 1), out outDir);
              outDir.X *= _symbolSize / 2;
              outDir.Y *= _symbolSize / 2;
              double xlay, ylay;
              layer.CoordinateSystem.LogicalToLayerCoordinates(lh, out xlay, out ylay);
              // Draw a line from x,y to 
              g.DrawLine(_strokePen, (float)(xlay - outDir.X), (float)(ylay - outDir.Y), (float)(xlay + outDir.X), (float)(ylay + outDir.Y));
            }

            if (llvalid)
            {
              PointF outDir;
              layer.CoordinateSystem.GetNormalizedDirection(lm, ll, 1, new Logical3D(0, 1), out outDir);
              outDir.X *= _symbolSize / 2;
              outDir.Y *= _symbolSize / 2;
              double xlay, ylay;
              layer.CoordinateSystem.LogicalToLayerCoordinates(ll, out xlay, out ylay);
              // Draw a line from x,y to 
              g.DrawLine(_strokePen, (float)(xlay - outDir.X), (float)(ylay - outDir.Y), (float)(xlay + outDir.X), (float)(ylay + outDir.Y));
            }

          }
        }
      }

      g.Clip = oldClippingRegion;
    }
Ejemplo n.º 46
0
		public void PaintMinorLabels(IGraphicsContext3D g, IPlotArea layer)
		{
			if (AreMinorLabelsEnabled)
			{
				var labelSide = _minorLabelStyle.PredictLabelSide(_cachedAxisInfo);
				var outerDistance = null == _axisLineStyle ? 0 : _axisLineStyle.GetOuterDistance(labelSide);
				var scaleWithTicks = layer.Scales[_cachedAxisInfo.Identifier.ParallelAxisNumber];
				this._minorLabelStyle.Paint(g, layer.CoordinateSystem, scaleWithTicks, _customTickSpacing ?? scaleWithTicks.TickSpacing, _cachedAxisInfo, outerDistance, true);
			}
		}
Ejemplo n.º 47
0
		public void PaintTitle(IGraphicsContext3D g, Altaxo.Graph.IPaintContext paintContext, IPlotArea layer)
		{
			if (IsTitleEnabled)
			{
				_axisTitle.Paint(g, paintContext);
			}
		}
Ejemplo n.º 48
0
		public void Paint(IGraphicsContext3D g, Altaxo.Graph.IPaintContext paintContext, IPlotArea layer, Func<CSLineID, CSAxisInformation> GetAxisStyleInformation)
		{
			PaintLine(g, layer);
			PaintMajorLabels(g, layer);
			PaintMinorLabels(g, layer);
			PaintTitle(g, paintContext, layer);
		}
Ejemplo n.º 49
0
		public void PaintLine(IGraphicsContext3D g, IPlotArea layer)
		{
			if (IsAxisLineEnabled)
			{
				_axisLineStyle.Paint(g, layer, _cachedAxisInfo, _customTickSpacing);
			}
		}
Ejemplo n.º 50
0
		public void Paint(IGraphicsContext3D g, Altaxo.Graph.IPaintContext paintContext, IPlotArea layer)
		{
			Paint(g, paintContext, layer, layer.CoordinateSystem.GetAxisStyleInformation);
		}
Ejemplo n.º 51
0
		public void PaintPreprocessing(IPlotArea layer)
		{
		}
Ejemplo n.º 52
0
		public void FixupInternalDataStructures(IPlotArea layer, Func<CSLineID, CSAxisInformation> GetAxisStyleInformation)
		{
			// update the logical values of the physical axes before
			if (_styleID.UsePhysicalValueOtherFirst)
			{
				// then update the logical value of this identifier
				double logicalValue = layer.Scales[_styleID.AxisNumberOtherFirst].PhysicalVariantToNormal(_styleID.PhysicalValueOtherFirst);
				_styleID = _styleID.WithLogicalValueOtherFirst(logicalValue);
			}
			if (_styleID.UsePhysicalValueOtherSecond)
			{
				// then update the logical value of this identifier
				double logicalValue = layer.Scales[_styleID.AxisNumberOtherSecond].PhysicalVariantToNormal(_styleID.PhysicalValueOtherSecond);
				_styleID = _styleID.WithLogicalValueOtherSecond(logicalValue);
			}

			CachedAxisInformation = GetAxisStyleInformation(_styleID);

			if (null != _customTickSpacing)
			{
				CSLineID styleID = _cachedAxisInfo.Identifier;
				Scale scale = layer.Scales[styleID.ParallelAxisNumber];
				Altaxo.Data.AltaxoVariant org = scale.OrgAsVariant, end = scale.EndAsVariant;
				_customTickSpacing.PreProcessScaleBoundaries(ref org, ref end, false, false);
				_customTickSpacing.FinalProcessScaleBoundaries(org, end, scale);
			}

			if (null != _axisTitle)
				_axisTitle.SetParentSize(layer.Size, false);
		}
Ejemplo n.º 53
0
		public void MergeYBoundsInto(IPlotArea layer, IPhysicalBoundaries pb, PlotItemCollection coll)
		{
			CoordinateTransformingStyleBase.MergeYBoundsInto(pb, coll);
		}
Ejemplo n.º 54
0
		public void Paint(Graphics g, IPlotArea layer, Processed2DPlotData pdata, Processed2DPlotData prevItemData, Processed2DPlotData nextItemData)
		{
			if (this._connectionStyle is LineConnectionStyles.NoConnection)
				return;

			PointF[] plotPositions = pdata.PlotPointsInAbsoluteLayerCoordinates;

			if(_independentOnShiftingGroupStyles)
			{
				_cachedLogicalShiftX = _cachedLogicalShiftY = 0;
			}

			if (0 != _cachedLogicalShiftX || 0 != _cachedLogicalShiftY)
			{
				plotPositions = Processed2DPlotData.GetPlotPointsInAbsoluteLayerCoordinatesWithShift(pdata, layer, _cachedLogicalShiftX, _cachedLogicalShiftY);
			}

			// ensure that brush and pen are cached
			if (null != _framePen) _framePen.Cached = true;

			if (null != _fillBrush)
				_fillBrush.SetEnvironment(new RectangleD2D(PointD2D.Empty, layer.Size), BrushX.GetEffectiveMaximumResolution(g, 1));

			_fillDirection = layer.UpdateCSPlaneID(_fillDirection);

			var gp = new GraphicsPath();

			PlotRangeList rangeList = pdata.RangeList;
			if (this._ignoreMissingDataPoints)
			{
				// in case we ignore the missing points, all ranges can be plotted
				// as one range, i.e. continuously
				// for this, we create the totalRange, which contains all ranges
				IPlotRange totalRange = new PlotRangeCompound(rangeList);
				_connectionStyle.FillOneRange(gp, pdata, totalRange, layer, _fillDirection, _ignoreMissingDataPoints, _connectCircular, plotPositions, _cachedLogicalShiftX, _cachedLogicalShiftY);
			}
			else // we not ignore missing points, so plot all ranges separately
			{
				for (int i = 0; i < rangeList.Count; i++)
				{
					_connectionStyle.FillOneRange(gp, pdata, rangeList[i], layer, _fillDirection, _ignoreMissingDataPoints, _connectCircular, plotPositions, _cachedLogicalShiftX, _cachedLogicalShiftY);
				}
			}

			g.FillPath(_fillBrush, gp);

			g.DrawPath(_framePen, gp);
		}
Ejemplo n.º 55
0
		public void Paint(IGraphicsContext3D g, IPlotArea layer, Processed3DPlotData pdata, Processed3DPlotData prevItemData, Processed3DPlotData nextItemData)
		{
			PlotRangeList rangeList = pdata.RangeList;
			var ptArray = pdata.PlotPointsInAbsoluteLayerCoordinates;

			// adjust the skip frequency if it was not set appropriate
			if (_skipFreq <= 0)
				_skipFreq = 1;

			var dropTargets = new List<CSPlaneID>(_dropTargets.Select(id => layer.UpdateCSPlaneID(id)));
			if (_additionalDropTargetIsEnabled)
			{
				CSPlaneID userPlane;
				if (_additionalDropTargetUsePhysicalBaseValue)
				{
					userPlane = new CSPlaneID(_additionalDropTargetPerpendicularAxis, layer.Scales[_additionalDropTargetPerpendicularAxis].PhysicalVariantToNormal(_additionalDropTargetBaseValue));
				}
				else
				{
					userPlane = new CSPlaneID(_additionalDropTargetPerpendicularAxis, _additionalDropTargetBaseValue);
				}
				dropTargets.Add(userPlane);
			}

			// paint the scatter style

			PointD3D pos = PointD3D.Empty;

			if (null == _cachedSymbolSizeForIndexFunction && null == _cachedColorForIndexFunction) // using a constant symbol size and constant color
			{
				var pen = _pen;
				// update pen widths
				double w1 = _lineWidth1Offset + _lineWidth1Factor * _cachedSymbolSize;
				double w2 = _lineWidth2Offset + _lineWidth2Factor * _cachedSymbolSize;
				pen = pen.WithThickness1(w1).WithThickness2(w2);

				var gapStart = 0.5 * (_gapAtStartOffset + _gapAtStartFactor * _cachedSymbolSize);
				var gapEnd = 0.5 * (_gapAtEndOffset + _gapAtEndFactor * _cachedSymbolSize);

				for (int r = 0; r < rangeList.Count; r++)
				{
					var range = rangeList[r];
					int lower = range.LowerBound;
					int upper = range.UpperBound;

					for (int j = lower; j < upper; j += _skipFreq)
					{
						Logical3D r3d = layer.GetLogical3D(pdata, j + range.OffsetToOriginal);
						foreach (CSPlaneID id in dropTargets)
						{
							IPolylineD3D isoLine;
							layer.CoordinateSystem.GetIsolineFromPointToPlane(r3d, id, out isoLine);
							if (gapStart != 0 || gapEnd != 0)
								isoLine = isoLine.ShortenedBy(RADouble.NewAbs(gapStart), RADouble.NewAbs(gapEnd));

							if (null != isoLine)
								g.DrawLine(pen, isoLine);
						}
					}
				} // for each range
			}
			else // using a variable symbol size or variable symbol color
			{
				for (int r = 0; r < rangeList.Count; r++)
				{
					var range = rangeList[r];
					int lower = range.LowerBound;
					int upper = range.UpperBound;
					int offset = range.OffsetToOriginal;
					for (int j = lower; j < upper; j += _skipFreq)
					{
						var pen = _pen;
						if (null == _cachedColorForIndexFunction)
						{
							_cachedSymbolSize = _cachedSymbolSizeForIndexFunction(j + offset);
							double w1 = _lineWidth1Offset + _lineWidth1Factor * _cachedSymbolSize;
							double w2 = _lineWidth2Offset + _lineWidth2Factor * _cachedSymbolSize;
							pen = _pen.WithThickness1(w1).WithThickness2(w2);
						}
						else
						{
							_cachedSymbolSize = null == _cachedSymbolSizeForIndexFunction ? _cachedSymbolSize : _cachedSymbolSizeForIndexFunction(j + offset);
							double w1 = _lineWidth1Offset + _lineWidth1Factor * _cachedSymbolSize;
							double w2 = _lineWidth2Offset + _lineWidth2Factor * _cachedSymbolSize;

							var customSymbolColor = _cachedColorForIndexFunction(j + offset);
							pen = _pen.WithThickness1(w1).WithThickness2(w2).WithColor(NamedColor.FromArgb(customSymbolColor.A, customSymbolColor.R, customSymbolColor.G, customSymbolColor.B));
						}

						var gapStart = 0.5 * (_gapAtStartOffset + _gapAtStartFactor * _cachedSymbolSize);
						var gapEnd = 0.5 * (_gapAtEndOffset + _gapAtEndFactor * _cachedSymbolSize);

						Logical3D r3d = layer.GetLogical3D(pdata, j + rangeList[r].OffsetToOriginal);
						foreach (CSPlaneID id in _dropTargets)
						{
							IPolylineD3D isoLine;
							layer.CoordinateSystem.GetIsolineFromPointToPlane(r3d, id, out isoLine);

							if (gapStart != 0 || gapEnd != 0)
								isoLine = isoLine.ShortenedBy(RADouble.NewAbs(gapStart), RADouble.NewAbs(gapEnd));
							if (null != isoLine)
								g.DrawLine(pen, isoLine);
						}
					}
				}
			}
		}
Ejemplo n.º 56
0
		/// <summary>
		/// Prepares the scale of this plot style. Since this style does not utilize a scale, this function does nothing.
		/// </summary>
		/// <param name="layer">The parent layer.</param>
		public void PrepareScales(IPlotArea layer)
		{
		}
Ejemplo n.º 57
0
 public void Paint(System.Drawing.Graphics g, IPlotArea layer, Altaxo.Graph.Gdi.Plot.Data.Processed2DPlotData pdata)
 {
   if (_isHorizontalStyle)
     PaintXErrorBars(g, layer, pdata);
   else
     PaintYErrorBars(g, layer, pdata);
 }
Ejemplo n.º 58
0
		public void PrepareGroupStyles(PlotGroupStyleCollection externalGroups, PlotGroupStyleCollection localGroups, IPlotArea layer, Processed2DPlotData pdata)
		{
			if (this._fillColorLinkage == ColorLinkage.Dependent && this._fillBrush != null)
				ColorGroupStyle.PrepareStyle(externalGroups, localGroups, delegate () { return this._fillBrush.Color; });
			else if (this._frameColorLinkage == ColorLinkage.Dependent && this._framePen != null)
				ColorGroupStyle.PrepareStyle(externalGroups, localGroups, delegate () { return this._framePen.Color; });

			IgnoreMissingDataPointsGroupStyle.PrepareStyle(externalGroups, localGroups, () => _ignoreMissingDataPoints);
			LineConnection2DGroupStyle.PrepareStyle(externalGroups, localGroups, () => new Tuple<ILineConnectionStyle, bool>(_connectionStyle, _connectCircular));
		}
Ejemplo n.º 59
0
		public void Paint(Graphics g, IPlotArea layer, int axisnumber)
		{
			if (!_showGrid)
				return;

			Scale axis = layer.Scales[axisnumber];
			TickSpacing ticking = layer.Scales[axisnumber].TickSpacing;

			RectangleD2D layerRect = new RectangleD2D(PointD2D.Empty, layer.Size);

			if (_showZeroOnly)
			{
				Altaxo.Data.AltaxoVariant var = new Altaxo.Data.AltaxoVariant(0.0);
				double rel = axis.PhysicalVariantToNormal(var);
				_majorPen.SetEnvironment(layerRect, BrushX.GetEffectiveMaximumResolution(g, 1));
				if (rel >= 0 && rel <= 1)
				{
					if (axisnumber == 0)
						layer.CoordinateSystem.DrawIsoline(g, MajorPen, new Logical3D(rel, 0), new Logical3D(rel, 1));
					else
						layer.CoordinateSystem.DrawIsoline(g, MajorPen, new Logical3D(0, rel), new Logical3D(1, rel));

					//layer.DrawIsoLine(g, MajorPen, axisnumber, rel, 0, 1);
				}
			}
			else
			{
				double[] ticks;

				if (_showMinor)
				{
					_minorPen.SetEnvironment(layerRect, BrushX.GetEffectiveMaximumResolution(g, 1));
					ticks = ticking.GetMinorTicksNormal(axis);
					for (int i = 0; i < ticks.Length; ++i)
					{
						if (axisnumber == 0)
							layer.CoordinateSystem.DrawIsoline(g, MinorPen, new Logical3D(ticks[i], 0), new Logical3D(ticks[i], 1));
						else
							layer.CoordinateSystem.DrawIsoline(g, MinorPen, new Logical3D(0, ticks[i]), new Logical3D(1, ticks[i]));

						//layer.DrawIsoLine(g, MinorPen, axisnumber, ticks[i], 0, 1);
					}
				}

				MajorPen.SetEnvironment(layerRect, BrushX.GetEffectiveMaximumResolution(g, 1));
				ticks = ticking.GetMajorTicksNormal(axis);
				for (int i = 0; i < ticks.Length; ++i)
				{
					if (axisnumber == 0)
						layer.CoordinateSystem.DrawIsoline(g, MajorPen, new Logical3D(ticks[i], 0), new Logical3D(ticks[i], 1));
					else
						layer.CoordinateSystem.DrawIsoline(g, MajorPen, new Logical3D(0, ticks[i]), new Logical3D(1, ticks[i]));

					//layer.DrawIsoLine(g, MajorPen, axisnumber, ticks[i], 0, 1);
				}
			}
		}
Ejemplo n.º 60
0
		public void PrepareGroupStyles(PlotGroupStyleCollection externalGroups, PlotGroupStyleCollection localGroups, IPlotArea layer, Processed3DPlotData pdata)
		{
			if (this.IsColorProvider)
				ColorGroupStyle.PrepareStyle(externalGroups, localGroups, delegate () { return this.Color; });

			// SkipFrequency should be the same for all sub plot styles, so there is no "private" property
			if (!_independentSkipFreq)
				SkipFrequencyGroupStyle.PrepareStyle(externalGroups, localGroups, delegate () { return _skipFreq; });
		}