Example #1
0
 public override void Paint(Graphics g, IPaintContext context, IPlotArea layer, IGPlotItem previousPlotItem, IGPlotItem nextPlotItem)
 {
     if (null != _plotStyle)
     {
         _plotStyle.Paint(g, layer, _plotData);
     }
 }
Example #2
0
        public override void Paint(Graphics g, IPaintContext paintContext)
        {
            if (null == _cachedLayerSegment) // _privLayer should be set before in FixupInternalDataStructures
            {
                PaintErrorInvalidLayerType(g, paintContext);
                return;
            }

            if (_background == null)
            {
                _axisStyle.Paint(g, paintContext, _cachedLayerSegment, _cachedLayerSegment.GetAxisStyleInformation);
            }
            else
            {
                // if we have a background, we paint in a dummy bitmap in order to measure all items
                // the real painting is done later on after painting the background.
                using (var bmp = new Bitmap(4, 4))
                {
                    using (var gg = Graphics.FromImage(bmp))
                    {
                        _axisStyle.Paint(gg, paintContext, _cachedLayerSegment, _cachedLayerSegment.GetAxisStyleInformation);
                    }
                }
            }

            _cachedPath = _axisStyle.AxisLineStyle.GetObjectPath(_cachedLayerSegment, true);

            // calculate size information
            RectangleD2D bounds1 = _cachedPath.GetBounds();

            if (_axisStyle.AreMinorLabelsEnabled)
            {
                var path = _axisStyle.MinorLabelStyle.GetSelectionPath();
                if (path.PointCount > 0)
                {
                    _cachedPath.AddPath(path, false);
                    RectangleD2D bounds2 = path.GetBounds();
                    bounds1.ExpandToInclude(bounds2);
                }
            }
            if (_axisStyle.AreMajorLabelsEnabled)
            {
                var path = _axisStyle.MajorLabelStyle.GetSelectionPath();
                if (path.PointCount > 0)
                {
                    _cachedPath.AddPath(path, false);
                    RectangleD2D bounds2 = path.GetBounds();
                    bounds1.ExpandToInclude(bounds2);
                }
            }

            ((ItemLocationDirectAutoSize)_location).SetSizeInAutoSizeMode(bounds1.Size, false); // size here is important only for selection, thus we set size silently

            if (_background != null)
            {
                bounds1.Expand(_backgroundPadding);
                _background.Draw(g, bounds1);
                _axisStyle.Paint(g, paintContext, _cachedLayerSegment, _cachedLayerSegment.GetAxisStyleInformation);
            }
        }
Example #3
0
 public void Paint(Graphics g, IPaintContext paintContext, IPlotArea layer)
 {
     for (int i = 0; i < _axisStyles.Count; ++i)
     {
         _axisStyles[i].Paint(g, paintContext, layer);
     }
 }
Example #4
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);
            }
        }
Example #5
0
 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]);
     }
 }
Example #6
0
 public void Paint(Graphics g, IPaintContext paintContext, IPlotArea layer, Func <CSLineID, CSAxisInformation> GetAxisStyleInformation)
 {
     PaintLine(g, layer);
     PaintMajorLabels(g, layer);
     PaintMinorLabels(g, layer);
     PaintTitle(g, paintContext, layer);
 }
Example #7
0
 public void PaintTitle(Graphics g, IPaintContext paintContext, IPlotArea layer)
 {
     if (IsTitleEnabled)
     {
         _axisTitle.Paint(g, paintContext);
     }
 }
Example #8
0
        public void PaintChild(System.Drawing.Graphics g, IPaintContext paintContext, IPlotArea layer, PlotItemCollection coll, int i)
        {
            CachedPaintData paintData = paintContext.GetValue <CachedPaintData>(this);

            if (_useClipping)
            {
                //g.SetClip(clippingColl[i], CombineMode.Replace);
                g.Clip = paintData._clippingColl[i];
            }

            if (null == paintData._plotDataColl[i])
            {
                coll[i].Paint(g, paintContext, layer, i == coll.Count - 1 ? null : coll[i - 1], i == 0 ? null : coll[i - 1]);
            }
            else
            {
                var layerwrapper = new TransformedLayerWrapper(layer, paintData._xincColl[i], paintData._yincColl[i]);
                ((G2DPlotItem)coll[i]).Paint(g, layerwrapper, paintData._plotDataColl[i], i == coll.Count - 1 ? null : paintData._plotDataColl[i + 1], i == 0 ? null : paintData._plotDataColl[i - 1]);
            }

            // The clipping region is no longer needed, so we can dispose it
            if (_useClipping)
            {
                if (i == 0)
                {
                    g.Clip = paintData._clippingColl[0]; // restore the original clipping region
                }
                else
                {
                    paintData._clippingColl[i].Dispose(); // for i!=0 dispose the clipping region
                }
            }
        }
		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]);
			}
		}
Example #10
0
        public override void Paint(Graphics g, IPaintContext paintContext)
        {
            System.Drawing.Drawing2D.GraphicsState gs = g.Save();
            TransformGraphics(g);

            // Modification of StringFormat is necessary to avoid
            // too big spaces between successive words
            var strfmt = (StringFormat)StringFormat.GenericTypographic.Clone();

            strfmt.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;

            strfmt.LineAlignment = StringAlignment.Near;
            strfmt.Alignment     = StringAlignment.Near;

            // next statement is necessary to have a consistent string length both
            // on 0 degree rotated text and rotated text
            // without this statement, the text is fitted to the pixel grid, which
            // leads to "steps" during scaling
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;

            if (AutoSize)
            {
                var mySize = g.MeasureString(_text, GdiFontManager.ToGdi(_font));
                Width  = mySize.Width;
                Height = mySize.Height;
                g.DrawString(_text, GdiFontManager.ToGdi(_font), new SolidBrush(_color), 0, 0, strfmt);
            }
            else
            {
                var rect = new RectangleF(0, 0, (float)Width, (float)Height);
                g.DrawString(_text, GdiFontManager.ToGdi(_font), new SolidBrush(_color), rect, strfmt);
            }

            g.Restore(gs);
        }
Example #11
0
        public override void Paint(IGraphicsContext3D g, IPaintContext context)
        {
            var gs = g.SaveGraphicsState();

            g.PrependTransform(_transformation);
            g.DrawLine(_linePen, Bounds.Location, Bounds.LocationPlusSize);
            g.RestoreGraphicsState(gs);
        }
Example #12
0
        public void PaintPreprocessing(IPaintContext paintContext, IPlotArea layer, PlotItemCollection coll)
        {
            if (!CanUseStyle(layer, coll, out var plotDataDict))
            {
                return;
            }
            else
            {
                paintContext.AddValue(this, plotDataDict);
            }

            AltaxoVariant[] vSumArray = null;
            foreach (IGPlotItem pi in coll)
            {
                if (pi is G3DPlotItem)
                {
                    var gpi   = pi as G3DPlotItem;
                    var pdata = plotDataDict[gpi];
                    vSumArray = AbsoluteStackTransform.AddUp(vSumArray, pdata);
                }
            }

            // now plot the data - the summed up y is in yArray
            AltaxoVariant[]     vArray           = null;
            Processed3DPlotData previousItemData = null;

            foreach (IGPlotItem pi in coll)
            {
                if (pi is G3DPlotItem)
                {
                    var gpi   = pi as G3DPlotItem;
                    var pdata = plotDataDict[gpi];
                    vArray = AbsoluteStackTransform.AddUp(vArray, pdata);
                    var localArray = new AltaxoVariant[vArray.Length];

                    int j = -1;
                    foreach (int originalIndex in pdata.RangeList.OriginalRowIndices())
                    {
                        j++;
                        AltaxoVariant v = 100 * vArray[j] / vSumArray[j];
                        localArray[j] = v;

                        var rel = new Logical3D(
                            layer.XAxis.PhysicalVariantToNormal(pdata.GetXPhysical(originalIndex)),
                            layer.YAxis.PhysicalVariantToNormal(pdata.GetYPhysical(originalIndex)),
                            layer.ZAxis.PhysicalVariantToNormal(v));

                        layer.CoordinateSystem.LogicalToLayerCoordinates(rel, out var pabs);
                        pdata.PlotPointsInAbsoluteLayerCoordinates[j] = pabs;
                    }
                    // we have also to exchange the accessor for the physical z value and replace it by our own one
                    pdata.ZPhysicalAccessor = new IndexedPhysicalValueAccessor(delegate(int i)
                                                                               { return(localArray[i]); });
                    pdata.PreviousItemData = previousItemData;
                    previousItemData       = pdata;
                }
            }
        }
Example #13
0
        public void PaintPreprocessing(IPaintContext paintContext, IPlotArea layer, PlotItemCollection coll)
        {
            if (!CanUseStyle(layer, coll, out var 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++;

                    var gpi = pi as G3DPlotItem;
                    Processed3DPlotData pdata = plotDataDict[gpi];
                    if (null == pdata)
                    {
                        continue;
                    }

                    vArray = AddUp(vArray, pdata);

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

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

                    // we have also to exchange the accessor for the physical y value and replace it by our own one
                    var localArray       = (AltaxoVariant[])vArray.Clone();
                    var localArrayHolder = new LocalArrayHolder(localArray, pdata);
                    pdata.ZPhysicalAccessor = localArrayHolder.GetPhysical;
                    pdata.PreviousItemData  = previousItemData;
                    previousItemData        = pdata;
                }
            }
        }
Example #14
0
 /// <summary>
 /// Initialize a new instance <see cref="ListBoxItemDrawingEventArgs"/>
 /// </summary>
 public ListBoxItemDrawingEventArgs(T item, Color background, Color foreground,
                                    Rect drawingArea, ColumnHeader <T> header, IPaintContext context)
 {
     Handled     = false;
     Item        = item;
     Background  = background;
     Foreground  = foreground;
     DrawingArea = drawingArea;
     Header      = header;
     Context     = context;
 }
Example #15
0
        public override void Paint(Graphics g, IPaintContext context, IPlotArea layer, IGPlotItem prevPlotItem, IGPlotItem nextPlotItem)
        {
            Processed2DPlotData pdata = GetRangesAndPoints(layer);

            if (pdata != null)
            {
                Paint(g, layer, pdata,
                      (prevPlotItem is G2DPlotItem) ? ((G2DPlotItem)prevPlotItem).GetPlotData(layer) : null,
                      (nextPlotItem is G2DPlotItem) ? ((G2DPlotItem)nextPlotItem).GetPlotData(layer) : null
                      );
            }
        }
Example #16
0
        /// <summary>
        /// Paint the shape group in the graphic context.
        /// </summary>
        /// <param name="g">Graphic context.</param>
        /// <param name="paintContext">The paint context.</param>
        public override void Paint(Graphics g, IPaintContext paintContext)
        {
            GraphicsState gs = g.Save();

            TransformGraphics(g);

            foreach (GraphicBase graphics in _groupedObjects)
            {
                graphics.Paint(g, paintContext);
            }

            g.Restore(gs);
        }
Example #17
0
        private void MeasureGlyphs(Graphics g, FontCache cache, IPaintContext paintContext)
        {
            var mc = new MeasureContext
            {
                FontCache    = cache,
                LinkedObject = Altaxo.Main.AbsoluteDocumentPath.GetRootNodeImplementing <HostLayer>(this),
                TabStop      = Glyph.MeasureString(g, "MMMM", _font).X
            };

            if (null != _rootNode)
            {
                _rootNode.Measure(g, mc, 0);
            }
        }
Example #18
0
        public override void Paint(Graphics g, IPaintContext paintContext)
        {
            GraphicsState gs = g.Save();

            TransformGraphics(g);

            Image myImage = GetImage();

            if (null != myImage)
            {
                var bounds = Bounds;
                g.DrawImage(myImage, (float)bounds.X, (float)bounds.Y, (float)bounds.Width, (float)bounds.Height);
            }

            g.Restore(gs);
        }
Example #19
0
        public void PaintPreprocessing(IPaintContext context)
        {
            var coordTransStyle = _plotGroupStyles.CoordinateTransformingStyle;

            if (null != coordTransStyle)
            {
                var layer = Altaxo.Main.AbsoluteDocumentPath.GetRootNodeImplementing <IPlotArea>(this);
                coordTransStyle.PaintPreprocessing(context, layer, this);
            }
            else
            {
                foreach (var pi in _plotItems)
                {
                    pi.PaintPreprocessing(context);
                }
            }
        }
Example #20
0
        public override void Paint(Graphics g, IPaintContext context)
        {
            GraphicsState gs = g.Save();

            TransformGraphics(g);

            Image img = _imageProxy == null ? null : _imageProxy.GetImage();

            if (null != img)
            {
                var bounds = Bounds;

                g.DrawImage(img, (float)bounds.X, (float)bounds.Y, (float)bounds.Width, (float)bounds.Height);
            }

            g.Restore(gs);
        }
Example #21
0
        public void Paint(IGraphicsContext3D g, IPaintContext context, Graph3D.IPlotArea layer, IGPlotItem previousPlotItem, IGPlotItem nextPlotItem)
        {
            var coordinateTransformingStyle = _plotGroupStyles.CoordinateTransformingStyle;

            for (int i = 0; i < _plotItems.Count; ++i)
            {
                if (null != coordinateTransformingStyle)
                {
                    coordinateTransformingStyle.PaintChild(g, context, layer, this, i);
                }
                else
                {
                    var previousItem = i == 0 ? null : _plotItems[i - 1];
                    var nextItem     = i == _plotItems.Count - 1 ? null : _plotItems[i + 1];
                    _plotItems[i].Paint(g, context, layer, previousItem, nextItem);
                }
            }
        }
Example #22
0
        public override void Paint(Graphics g, IPaintContext context)
        {
            GraphicsState gs = g.Save();

            TransformGraphics(g);

            var bounds  = Bounds;
            var boundsF = (RectangleF)bounds;

            if (Brush.IsVisible)
            {
                Brush.SetEnvironment(boundsF, BrushX.GetEffectiveMaximumResolution(g, Math.Max(ScaleX, ScaleY)));
                g.FillEllipse(Brush, boundsF);
            }

            Pen.SetEnvironment(boundsF, BrushX.GetEffectiveMaximumResolution(g, Math.Max(ScaleX, ScaleY)));
            g.DrawEllipse(Pen, boundsF);
            g.Restore(gs);
        }
Example #23
0
        public override void Paint(Graphics g, IPaintContext paintContext)
        {
            GraphicsState gs = g.Save();

            TransformGraphics(g);
            var bounds = Bounds;
            var path   = InternalGetPath(bounds.LeftTop);

            Pen.SetEnvironment((RectangleF)bounds, BrushX.GetEffectiveMaximumResolution(g, Math.Max(ScaleX, ScaleY)));
            g.DrawPath(Pen, path);
            if (_outlinePen != null && _outlinePen.IsVisible)
            {
                path.Widen(Pen);
                OutlinePen.SetEnvironment((RectangleF)bounds, BrushX.GetEffectiveMaximumResolution(g, Math.Max(ScaleX, ScaleY)));
                g.DrawPath(OutlinePen, path);
            }

            g.Restore(gs);
        }
Example #24
0
        public override void Paint(IGraphicsContext3D g, IPaintContext context)
        {
            throw new NotImplementedException();

            /*
             *                GraphicsState gs = g.Save();
             *                TransformGraphics(g);
             *
             *                Image img = _imageProxy == null ? null : _imageProxy.GetImage();
             *
             *                if (null != img)
             *                {
             *                        var bounds = this.Bounds;
             *
             *                        g.DrawImage(img, (float)bounds.X, (float)bounds.Y, (float)bounds.Width, (float)bounds.Height);
             *                }
             *
             *                g.Restore(gs);
             */
        }
Example #25
0
        public override void Paint(IGraphicsContext3D g, IPaintContext context)
        {
            var buffers = g.GetPositionNormalIndexedTriangleBuffer(_material);

            if (null != buffers.PositionNormalIndexedTriangleBuffer)
            {
                var buffer = buffers.PositionNormalIndexedTriangleBuffer;

                var offs = buffer.VertexCount;

                var sphere = new SolidIcoSphere(3); // gives a sphere with radius = 1

                var bounds = Bounds;

                double sx = Bounds.SizeX / 2;
                double sy = Bounds.SizeY / 2;
                double sz = Bounds.SizeZ / 2;

                var dx = Bounds.X + sx;
                var dy = Bounds.Y + sy;
                var dz = Bounds.Z + sz;

                var transformation = Matrix4x3.NewScalingShearingRotationDegreesTranslation(sx, sy, sz, 0, 0, 0, 0, 0, 0, dx, dy, dz);
                transformation.AppendTransform(_transformation);

                var normalTransform = transformation.GetTransposedInverseMatrix3x3();

                foreach (var entry in sphere.VerticesAndNormalsForSphere)
                {
                    var pt = transformation.Transform(entry.Item1);
                    var nm = normalTransform.Transform(entry.Item2).Normalized;
                    buffer.AddTriangleVertex(pt.X, pt.Y, pt.Z, nm.X, nm.Y, nm.Z);
                }
                foreach (var idx in sphere.TriangleIndicesForSphere)
                {
                    buffer.AddTriangleIndices(idx.Item1 + offs, idx.Item2 + offs, idx.Item3 + offs);
                }
            }
        }
Example #26
0
        public override void Paint(Graphics g, IPaintContext paintContext)
        {
            GraphicsState gs = g.Save();

            TransformGraphics(g);

            var bounds = Bounds;

            Pen.SetEnvironment((RectangleF)bounds, BrushX.GetEffectiveMaximumResolution(g, Math.Max(ScaleX, ScaleY)));
            g.DrawLine(Pen, (float)bounds.X, (float)bounds.Y, (float)bounds.Right, (float)bounds.Bottom);

            if (_outlinePen != null && _outlinePen.IsVisible)
            {
                var p = new GraphicsPath();
                p.AddLine((float)bounds.X, (float)bounds.Y, (float)bounds.Right, (float)bounds.Bottom);
                p.Widen(Pen);
                OutlinePen.SetEnvironment((RectangleF)bounds, BrushX.GetEffectiveMaximumResolution(g, Math.Max(ScaleX, ScaleY)));
                g.DrawPath(OutlinePen, p);
            }

            g.Restore(gs);
        }
Example #27
0
        public override void Paint(Graphics g, IPaintContext context)
        {
            GraphicsState gs = g.Save();

            TransformGraphics(g);

            var bounds = Bounds;

            var path = InternalGetPath(bounds.LeftTop);

            if (Brush.IsVisible)
            {
                Brush.SetEnvironment((RectangleF)bounds, BrushX.GetEffectiveMaximumResolution(g, Math.Max(ScaleX, ScaleY)));
                g.FillPath(Brush, path);
            }

            if (Pen.IsVisible)
            {
                Pen.SetEnvironment((RectangleF)bounds, BrushX.GetEffectiveMaximumResolution(g, Math.Max(ScaleX, ScaleY)));
                g.DrawPath(Pen, path);
            }
            g.Restore(gs);
        }
Example #28
0
		public void Paint(Graphics g, IPaintContext paintContext, bool bForPreview)
		{
			//_isStructureInSync = false;
			_isMeasureInSync = false;  // Change: interpret text every time in order to update plot items and \ID

			if (!this._isStructureInSync)
			{
				// this.Interpret(g);
				this.InterpretText();

				_isStructureInSync = true;
				_isMeasureInSync = false;
			}

			using (FontCache fontCache = new FontCache())
			{
				if (!this._isMeasureInSync)
				{
					// this.MeasureStructure(g, obj);
					this.MeasureGlyphs(g, fontCache, paintContext);

					MeasureBackground(g, _rootNode.Width, _rootNode.Height);

					_isMeasureInSync = true;
				}

				_cachedSymbolPositions.Clear();

				System.Drawing.Drawing2D.GraphicsState gs = g.Save();
				g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;

				var bounds = Bounds;

				Matrix transformmatrix = new Matrix();
				transformmatrix.Translate((float)_location.AbsolutePivotPositionX, (float)_location.AbsolutePivotPositionY);
				transformmatrix.Rotate((float)(-Rotation));
				transformmatrix.Shear((float)Shear, 0);
				transformmatrix.Scale((float)ScaleX, (float)ScaleY);
				transformmatrix.Translate((float)bounds.X, (float)bounds.Y);

				if (!bForPreview)
				{
					TransformGraphics(g);
					g.TranslateTransform((float)bounds.X, (float)bounds.Y);
				}

				// first of all paint the background
				PaintBackground(g);

				DrawContext dc = new DrawContext();
				dc.FontCache = fontCache;
				dc.bForPreview = bForPreview;
				dc.LinkedObject = Altaxo.Main.AbsoluteDocumentPath.GetRootNodeImplementing<HostLayer>(this);
				dc.transformMatrix = transformmatrix;
				dc._cachedSymbolPositions = _cachedSymbolPositions;
				DrawGlyphs(g, dc, _cachedTextOffset.X, _cachedTextOffset.Y);
				g.Restore(gs);
			}
		}
Example #29
0
		private void MeasureGlyphs(Graphics g, FontCache cache, IPaintContext paintContext)
		{
			MeasureContext mc = new MeasureContext();
			mc.FontCache = cache;
			mc.LinkedObject = Altaxo.Main.AbsoluteDocumentPath.GetRootNodeImplementing<HostLayer>(this);
			mc.TabStop = Glyph.MeasureString(g, "MMMM", _font).X;

			if (null != _rootNode)
				_rootNode.Measure(g, mc, 0);
		}
Example #30
0
		public void PaintChild(System.Drawing.Graphics g, IPaintContext paintContext, IPlotArea layer, PlotItemCollection coll, int i)
		{
			CachedPaintData paintData = paintContext.GetValue<CachedPaintData>(this);

			if (_useClipping)
			{
				//g.SetClip(clippingColl[i], CombineMode.Replace);
				g.Clip = paintData._clippingColl[i];
			}

			if (null == paintData._plotDataColl[i])
			{
				coll[i].Paint(g, paintContext, layer, i == coll.Count - 1 ? null : coll[i - 1], i == 0 ? null : coll[i - 1]);
			}
			else
			{
				TransformedLayerWrapper layerwrapper = new TransformedLayerWrapper(layer, paintData._xincColl[i], paintData._yincColl[i]);
				((G2DPlotItem)coll[i]).Paint(g, layerwrapper, paintData._plotDataColl[i], i == coll.Count - 1 ? null : paintData._plotDataColl[i + 1], i == 0 ? null : paintData._plotDataColl[i - 1]);
			}

			// The clipping region is no longer needed, so we can dispose it
			if (_useClipping)
			{
				if (i == 0)
					g.Clip = paintData._clippingColl[0]; // restore the original clipping region
				else
					paintData._clippingColl[i].Dispose(); // for i!=0 dispose the clipping region
			}
		}
Example #31
0
		public override void Paint(Graphics g, IPaintContext paintContext)
		{
			GraphicsState gs = g.Save();
			TransformGraphics(g);

			var bounds = Bounds;
			Pen.SetEnvironment((RectangleF)bounds, BrushX.GetEffectiveMaximumResolution(g, Math.Max(ScaleX, ScaleY)));
			g.DrawLine(Pen, (float)bounds.X, (float)bounds.Y, (float)bounds.Right, (float)bounds.Bottom);

			if (_outlinePen != null && _outlinePen.IsVisible)
			{
				GraphicsPath p = new GraphicsPath();
				p.AddLine((float)bounds.X, (float)bounds.Y, (float)bounds.Right, (float)bounds.Bottom);
				p.Widen(Pen);
				OutlinePen.SetEnvironment((RectangleF)bounds, BrushX.GetEffectiveMaximumResolution(g, Math.Max(ScaleX, ScaleY)));
				g.DrawPath(OutlinePen, p);
			}

			g.Restore(gs);
		}
Example #32
0
		public override void Paint(Graphics g, IPaintContext paintContext)
		{
			GraphicsState gs = g.Save();
			TransformGraphics(g);

			var bounds = this.Bounds;
			var boundsF = (RectangleF)bounds;
			if (Brush.IsVisible)
			{
				Brush.SetEnvironment(boundsF, BrushX.GetEffectiveMaximumResolution(g, Math.Max(ScaleX, ScaleY)));
				g.FillRectangle(Brush, boundsF);
			}

			Pen.SetEnvironment(boundsF, BrushX.GetEffectiveMaximumResolution(g, Math.Max(ScaleX, ScaleY)));
			g.DrawRectangle(Pen, (float)bounds.X, (float)bounds.Y, (float)bounds.Width, (float)bounds.Height);
			g.Restore(gs);
		}
Example #33
0
		public override void Paint(Graphics g, IPaintContext paintContext)
		{
			var layer = Altaxo.Main.AbsoluteDocumentPath.GetRootNodeImplementing<XYPlotLayer>(this);

			if (null == layer)
			{
				PaintErrorInvalidLayerType(g, paintContext);
				return;
			}

			Logical3D rBegin;
			layer.CoordinateSystem.LayerToLogicalCoordinates(X, Y, out rBegin);

			Logical3D rEnd = rBegin;
			switch (_scaleSpanType)
			{
				case FloatingScaleSpanType.IsLogicalValue:
					rEnd[_scaleNumber] = rBegin[_scaleNumber] + _scaleSpanValue;
					break;

				case FloatingScaleSpanType.IsPhysicalEndOrgDifference:
					{
						var physValue = layer.Scales[_scaleNumber].NormalToPhysicalVariant(rBegin[this._scaleNumber]);
						physValue += _scaleSpanValue; // to be replaced by the scale span
						var logValue = layer.Scales[_scaleNumber].PhysicalVariantToNormal(physValue);
						rEnd[_scaleNumber] = logValue;
					}
					break;

				case FloatingScaleSpanType.IsPhysicalEndOrgRatio:
					{
						var physValue = layer.Scales[_scaleNumber].NormalToPhysicalVariant(rBegin[this._scaleNumber]);
						physValue *= _scaleSpanValue; // to be replaced by the scale span
						var logValue = layer.Scales[_scaleNumber].PhysicalVariantToNormal(physValue);
						rEnd[_scaleNumber] = logValue;
					}
					break;
			}

			// axis style
			var csLineId = new CSLineID(_scaleNumber, rBegin);
			if (_axisStyle.StyleID != csLineId)
			{
				var propertyContext = this.GetPropertyContext();
				var axStyle = new AxisStyle(new CSLineID(_scaleNumber, rBegin), false, false, false, null, propertyContext);
				axStyle.CopyWithoutIdFrom(_axisStyle);
				_axisStyle = axStyle;
			}

			var privScale = new ScaleSegment(layer.Scales[_scaleNumber], rBegin[_scaleNumber], rEnd[_scaleNumber], _scaleSegmentType);
			_tickSpacing.FinalProcessScaleBoundaries(privScale.OrgAsVariant, privScale.EndAsVariant, privScale);
			privScale.TickSpacing = _tickSpacing;
			var privLayer = new LayerSegment(layer, privScale, rBegin, rEnd, _scaleNumber);

			if (_background == null)
			{
				_axisStyle.Paint(g, paintContext, privLayer, privLayer.GetAxisStyleInformation);
			}
			else
			{
				// if we have a background, we paint in a dummy bitmap in order to measure all items
				// the real painting is done later on after painting the background.
				using (var bmp = new Bitmap(4, 4))
				{
					using (Graphics gg = Graphics.FromImage(bmp))
					{
						_axisStyle.Paint(gg, paintContext, privLayer, privLayer.GetAxisStyleInformation);
					}
				}
			}

			_cachedPath = _axisStyle.AxisLineStyle.GetObjectPath(privLayer, true);

			// calculate size information
			RectangleD2D bounds1 = _cachedPath.GetBounds();

			if (_axisStyle.AreMinorLabelsEnabled)
			{
				var path = _axisStyle.MinorLabelStyle.GetSelectionPath();
				if (path.PointCount > 0)
				{
					_cachedPath.AddPath(path, false);
					RectangleD2D bounds2 = path.GetBounds();
					bounds1.ExpandToInclude(bounds2);
				}
			}
			if (_axisStyle.AreMajorLabelsEnabled)
			{
				var path = _axisStyle.MajorLabelStyle.GetSelectionPath();
				if (path.PointCount > 0)
				{
					_cachedPath.AddPath(path, false);
					RectangleD2D bounds2 = path.GetBounds();
					bounds1.ExpandToInclude(bounds2);
				}
			}

			((ItemLocationDirectAutoSize)_location).SetSizeInAutoSizeMode(bounds1.Size);
			//this._leftTop = bounds1.Location - this.GetPosition();
			//throw new NotImplementedException("debug the previous statement");
			if (_background != null)
			{
				bounds1.Expand(_backgroundPadding);
				_background.Draw(g, bounds1);
				_axisStyle.Paint(g, paintContext, privLayer, privLayer.GetAxisStyleInformation);
			}
		}
Example #34
0
		public override void Paint(IGraphicsContext3D g, IPaintContext context)
		{
			var gs = g.SaveGraphicsState();
			g.PrependTransform(_transformation);
			g.DrawLine(_linePen, Bounds.Location, Bounds.LocationPlusSize);
			g.RestoreGraphicsState(gs);
		}
Example #35
0
		public override void Paint(Graphics g, IPaintContext context)
		{
			GraphicsState gs = g.Save();
			TransformGraphics(g);

			var bounds = Bounds;
			var boundsF = (RectangleF)bounds;

			Pen.SetEnvironment(boundsF, BrushX.GetEffectiveMaximumResolution(g, Math.Max(ScaleX, ScaleY)));
			var path = GetPath();
			g.DrawPath(Pen, path);

			if (_outlinePen != null && _outlinePen.IsVisible)
			{
				path.Widen(Pen);
				_outlinePen.SetEnvironment(boundsF, BrushX.GetEffectiveMaximumResolution(g, Math.Max(ScaleX, ScaleY)));
				g.DrawPath(_outlinePen, path);
			}

			g.Restore(gs);
		}
Example #36
0
		public override void Paint(Graphics g, IPaintContext paintContext)
		{
			GraphicsState gs = g.Save();
			TransformGraphics(g);

			Image myImage = this.GetImage();

			if (null != myImage)
			{
				var bounds = this.Bounds;
				g.DrawImage(myImage, (float)bounds.X, (float)bounds.Y, (float)bounds.Width, (float)bounds.Height);
			}

			g.Restore(gs);
		}
Example #37
0
		public override void Paint(IGraphicsContext3D g, IPaintContext context)
		{
			var buffers = g.GetPositionNormalIndexedTriangleBuffer(_material);

			if (null != buffers.PositionNormalIndexedTriangleBuffer)
			{
				var buffer = buffers.PositionNormalIndexedTriangleBuffer;

				var offs = buffer.VertexCount;

				var sphere = new SolidIcoSphere(3); // gives a sphere with radius = 1

				var bounds = this.Bounds;

				double sx = this.Bounds.SizeX / 2;
				double sy = this.Bounds.SizeY / 2;
				double sz = this.Bounds.SizeZ / 2;

				var dx = this.Bounds.X + sx;
				var dy = this.Bounds.Y + sy;
				var dz = this.Bounds.Z + sz;

				var transformation = Matrix4x3.NewScalingShearingRotationDegreesTranslation(sx, sy, sz, 0, 0, 0, 0, 0, 0, dx, dy, dz);
				transformation.AppendTransform(_transformation);

				var normalTransform = transformation.GetTransposedInverseMatrix3x3();

				foreach (var entry in sphere.VerticesAndNormalsForSphere)
				{
					var pt = transformation.Transform(entry.Item1);
					var nm = normalTransform.Transform(entry.Item2).Normalized;
					buffer.AddTriangleVertex(pt.X, pt.Y, pt.Z, nm.X, nm.Y, nm.Z);
				}
				foreach (var idx in sphere.TriangleIndicesForSphere)
				{
					buffer.AddTriangleIndices(idx.Item1 + offs, idx.Item2 + offs, idx.Item3 + offs);
				}
			}
		}
Example #38
0
		public override void Paint(IGraphicsContext3D g, IPaintContext context)
		{
			throw new NotImplementedException();

			/*
			GraphicsState gs = g.Save();
			TransformGraphics(g);

			Image img = _imageProxy == null ? null : _imageProxy.GetImage();

			if (null != img)
			{
				var bounds = this.Bounds;

				g.DrawImage(img, (float)bounds.X, (float)bounds.Y, (float)bounds.Width, (float)bounds.Height);
			}

			g.Restore(gs);
			*/
		}
Example #39
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);
			}
		}
Example #40
0
		public override void Paint(System.Drawing.Graphics g, IPaintContext paintContext)
		{
			if (null == _cachedArea)
				return;

			bool orientationIsVertical = IsOrientationVertical;
			bool scaleIsReversed = IsScaleReversed;

			int pixelH = orientationIsVertical ? _bitmapPixelsAcross : _bitmapPixelsAlong;
			int pixelV = orientationIsVertical ? _bitmapPixelsAlong : _bitmapPixelsAcross;

			if (null == _bitmap || _bitmap.Width != pixelH || _bitmap.Height != pixelV)
			{
				if (null != _bitmap)
					_bitmap.Dispose();

				_bitmap = new Bitmap(pixelH, pixelV, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
			}

			Data.AltaxoVariant porg;
			Data.AltaxoVariant pend;
			NumericalScale originalZScale;
			Plot.IColorProvider colorProvider;

			if (null != PlotItem)
			{
				porg = PlotItem.Style.Scale.OrgAsVariant;
				pend = PlotItem.Style.Scale.EndAsVariant;
				originalZScale = PlotItem.Style.Scale;
				colorProvider = PlotItem.Style.ColorProvider;
			}
			else
			{
				porg = 0;
				pend = 1;
				originalZScale = new LinearScale();
				colorProvider = new Plot.ColorProvider.ColorProviderBGRY();
			}

			var legendScale = (NumericalScale)ScaleWithTicks;
			var legendTickSpacing = ScaleWithTicks.TickSpacing;

			// Fill the bitmap

			for (int i = 0; i < _bitmapPixelsAlong; i++)
			{
				double r = (scaleIsReversed ^ orientationIsVertical) ? 1 - i / (double)(_bitmapPixelsAlong - 1) : i / (double)(_bitmapPixelsAlong - 1);
				double l = originalZScale.PhysicalToNormal(legendScale.NormalToPhysical(r));
				var color = colorProvider.GetColor(l);
				if (orientationIsVertical)
				{
					for (int j = 0; j < _bitmapPixelsAcross; j++)
						_bitmap.SetPixel(j, i, color);
				}
				else
				{
					for (int j = 0; j < _bitmapPixelsAcross; j++)
						_bitmap.SetPixel(i, j, color);
				}
			}

			var graphicsState = g.Save();
			TransformGraphics(g);

			{
				// Three tricks are neccessary to get the color legend (which is the bitmap) drawn smooth and uniformly:
				// Everything other than this will result in distorted image, or soft (unsharp) edges
				var graphicsState2 = g.Save(); // Of course, save the graphics state so we can make our tricks undone afterwards
				g.InterpolationMode = InterpolationMode.Default; // Trick1: Set the interpolation mode, whatever it was before, back to default
				g.PixelOffsetMode = PixelOffsetMode.Default;  // Trick2: Set the PixelOffsetMode, whatever it was before, back to default

				g.DrawImage(_bitmap,
					new RectangleF(0, 0, (float)Size.X, (float)Size.Y),
					new Rectangle(0, 0, pixelH - 1, pixelV - 1), GraphicsUnit.Pixel); // Trick3: Paint both in X and Y direction one pixel less than the source bitmap acually has, this prevents soft edges

				g.Restore(graphicsState2); // make our tricks undone here
			}
			_axisStyles.Paint(g, paintContext, _cachedArea);

			g.Restore(graphicsState);
		}
Example #41
0
		public override void Paint(Graphics g, IPaintContext paintContext)
		{
			var path = GetPath();
			var bounds = Bounds;

			GraphicsState gs = g.Save();
			TransformGraphics(g);
			var boundsF = (RectangleF)bounds;
			if (Brush.IsVisible)
			{
				Brush.SetEnvironment(boundsF, BrushX.GetEffectiveMaximumResolution(g, Math.Max(ScaleX, ScaleY)));
				g.FillPath(Brush, path);
			}

			Pen.SetEnvironment(boundsF, BrushX.GetEffectiveMaximumResolution(g, Math.Max(ScaleX, ScaleY)));
			g.DrawPath(Pen, path);
			g.Restore(gs);
		}
Example #42
0
		public void Paint(Graphics g, IPaintContext paintContext, IPlotArea layer)
		{
			Paint(g, paintContext, layer, layer.CoordinateSystem.GetAxisStyleInformation);
		}
Example #43
0
        public void PaintPreprocessing(System.Drawing.Graphics g, IPaintContext paintContext, IPlotArea layer, PlotItemCollection coll)
        {
            var paintData = new CachedPaintData
            {
                _clippingColl = new System.Drawing.Region[coll.Count],
                _plotDataColl = new Processed2DPlotData[coll.Count],
                _xincColl     = new double[coll.Count],
                _yincColl     = new double[coll.Count]
            };

            paintContext.AddValue(this, paintData);

            // First prepare
            int idx = -1;
            Processed2DPlotData previousPlotData = null;

            for (int i = 0; i < coll.Count; i++)
            {
                if (coll[i] is G2DPlotItem)
                {
                    idx++;
                    double currxinc = paintData._xincColl[i] = idx * _xinc * _scaleXInc;
                    double curryinc = paintData._yincColl[i] = idx * _yinc * _scaleYInc;

                    var gpi = coll[i] as G2DPlotItem;
                    Processed2DPlotData plotdata = paintData._plotDataColl[i] = gpi.GetRangesAndPoints(layer);
                    plotdata.PreviousItemData = previousPlotData;
                    previousPlotData          = plotdata;

                    int j = -1;
                    foreach (int rowIndex in plotdata.RangeList.OriginalRowIndices())
                    {
                        j++;

                        AltaxoVariant xx = plotdata.GetXPhysical(rowIndex) + currxinc;
                        AltaxoVariant yy = plotdata.GetYPhysical(rowIndex) + curryinc;

                        var rel = new Logical3D(layer.XAxis.PhysicalVariantToNormal(xx), layer.YAxis.PhysicalVariantToNormal(yy));
                        layer.CoordinateSystem.LogicalToLayerCoordinates(rel, out var xabs, out var yabs);
                        plotdata.PlotPointsInAbsoluteLayerCoordinates[j] = new System.Drawing.PointF((float)xabs, (float)yabs);
                    }

                    // if clipping is used, we must get a clipping region for every plot item
                    // and combine the regions from
                    if (_useClipping)
                    {
                        if (i == 0)
                        {
                            paintData._clippingColl[i] = g.Clip;
                        }

                        Plot.Styles.LinePlotStyle linestyle = null;
                        foreach (Plot.Styles.IG2DPlotStyle st in gpi.Style)
                        {
                            if (st is Plot.Styles.LinePlotStyle)
                            {
                                linestyle = st as Plot.Styles.LinePlotStyle;
                                break;
                            }
                        }

                        if (null != linestyle)
                        {
                            var path = new System.Drawing.Drawing2D.GraphicsPath();
                            linestyle.GetFillPath(path, layer, plotdata, CSPlaneID.Bottom);
                            if ((i + 1) < paintData._clippingColl.Length)
                            {
                                paintData._clippingColl[i + 1] = paintData._clippingColl[i].Clone();
                                paintData._clippingColl[i + 1].Exclude(path);
                            }
                        }
                        else
                        {
                            if ((i + 1) < paintData._clippingColl.Length)
                            {
                                paintData._clippingColl[i + 1] = paintData._clippingColl[i];
                            }
                        }
                    }
                }
            }
        }
Example #44
0
		public override void PaintPreprocessing(IPaintContext context)
		{
			base.PaintPreprocessing(context);
			_axisStyles.PaintPreprocessing(_cachedArea); // make sure the AxisStyles know about the size of the parent
		}
Example #45
0
		public void Paint(Graphics g, IPaintContext paintContext, IPlotArea layer, Func<CSLineID, CSAxisInformation> GetAxisStyleInformation)
		{
			PaintLine(g, layer);
			PaintMajorLabels(g, layer);
			PaintMinorLabels(g, layer);
			PaintTitle(g, paintContext, layer);
		}
Example #46
0
		public override void Paint(Graphics g, IPaintContext context, IPlotArea layer, IGPlotItem previousPlotItem, IGPlotItem nextPlotItem)
		{
			if (null != this._plotStyle)
			{
				_plotStyle.Paint(g, layer, _plotData);
			}
		}
Example #47
0
		public override void Paint(Graphics g, IPaintContext context, IPlotArea layer, IGPlotItem prevPlotItem, IGPlotItem nextPlotItem)
		{
			Processed2DPlotData pdata = GetRangesAndPoints(layer);
			if (pdata != null)
				Paint(g, layer, pdata,
					(prevPlotItem is G2DPlotItem) ? ((G2DPlotItem)prevPlotItem).GetPlotData(layer) : null,
					(nextPlotItem is G2DPlotItem) ? ((G2DPlotItem)nextPlotItem).GetPlotData(layer) : null
					);
		}
Example #48
0
 public override void PaintPreprocessing(IPaintContext context)
 {
     base.PaintPreprocessing(context);
     _axisStyles.PaintPreprocessing(_cachedArea); // make sure the AxisStyles know about the size of the parent
 }
Example #49
0
			public override void Paint(Graphics g, IPaintContext paintContext)
			{
				throw new NotImplementedException();
			}
Example #50
0
		public void PaintTitle(Graphics g, IPaintContext paintContext, IPlotArea layer)
		{
			if (IsTitleEnabled)
			{
				_axisTitle.Paint(g, paintContext);
			}
		}
Example #51
0
		public void PaintPreprocessing(System.Drawing.Graphics g, IPaintContext paintContext, IPlotArea layer, PlotItemCollection coll)
		{
			var paintData = new CachedPaintData
			{
				_clippingColl = new System.Drawing.Region[coll.Count],
				_plotDataColl = new Processed2DPlotData[coll.Count],
				_xincColl = new double[coll.Count],
				_yincColl = new double[coll.Count]
			};

			paintContext.AddValue(this, paintData);

			// First prepare
			int idx = -1;
			Processed2DPlotData previousPlotData = null;
			for (int i = 0; i < coll.Count; i++)
			{
				if (coll[i] is G2DPlotItem)
				{
					idx++;
					double currxinc = paintData._xincColl[i] = idx * _xinc * _scaleXInc;
					double curryinc = paintData._yincColl[i] = idx * _yinc * _scaleYInc;

					G2DPlotItem gpi = coll[i] as G2DPlotItem;
					Processed2DPlotData plotdata = paintData._plotDataColl[i] = gpi.GetRangesAndPoints(layer);
					plotdata.PreviousItemData = previousPlotData;
					previousPlotData = plotdata;

					int j = -1;
					foreach (int rowIndex in plotdata.RangeList.OriginalRowIndices())
					{
						j++;

						AltaxoVariant xx = plotdata.GetXPhysical(rowIndex) + currxinc;
						AltaxoVariant yy = plotdata.GetYPhysical(rowIndex) + curryinc;

						Logical3D rel = new Logical3D(layer.XAxis.PhysicalVariantToNormal(xx), layer.YAxis.PhysicalVariantToNormal(yy));
						double xabs, yabs;
						layer.CoordinateSystem.LogicalToLayerCoordinates(rel, out xabs, out yabs);
						plotdata.PlotPointsInAbsoluteLayerCoordinates[j] = new System.Drawing.PointF((float)xabs, (float)yabs);
					}

					// if clipping is used, we must get a clipping region for every plot item
					// and combine the regions from
					if (_useClipping)
					{
						if (i == 0)
							paintData._clippingColl[i] = g.Clip;

						Plot.Styles.LinePlotStyle linestyle = null;
						foreach (Plot.Styles.IG2DPlotStyle st in gpi.Style)
						{
							if (st is Plot.Styles.LinePlotStyle)
							{
								linestyle = st as Plot.Styles.LinePlotStyle;
								break;
							}
						}

						if (null != linestyle)
						{
							GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
							linestyle.GetFillPath(path, layer, plotdata, CSPlaneID.Bottom);
							if ((i + 1) < paintData._clippingColl.Length)
							{
								paintData._clippingColl[i + 1] = (Region)paintData._clippingColl[i].Clone();
								paintData._clippingColl[i + 1].Exclude(path);
							}
						}
						else
						{
							if ((i + 1) < paintData._clippingColl.Length)
								paintData._clippingColl[i + 1] = paintData._clippingColl[i];
						}
					}
				}
			}
		}
Example #52
0
		/// <summary>
		/// This paints the plot to the layer.
		/// </summary>
		/// <param name="g">The graphics context.</param>
		/// <param name="context">The painting context.</param>
		/// <param name="layer">The plot layer.</param>
		/// <param name="previousPlotItem">Previous plot item.</param>
		/// <param name="nextPlotItem">Next plot item.</param>
		/// <returns>A data object, which can be used by the next plot item for some styles (like fill style).</returns>
		public abstract void Paint(Graphics g, IPaintContext context, IPlotArea layer, IGPlotItem previousPlotItem, IGPlotItem nextPlotItem);
Example #53
0
		public override void Paint(Graphics g, IPaintContext paintContext)
		{
			Paint(g, paintContext, false);
		}
Example #54
0
		/// <summary>
		/// Called before painting takes place.
		/// </summary>
		/// <param name="context">The painting context.</param>
		public virtual void PaintPreprocessing(IPaintContext context)
		{
		}
Example #55
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;
				}
			}
		}
Example #56
0
 /// <summary>
 /// Called before painting takes place.
 /// </summary>
 /// <param name="context">The painting context.</param>
 public virtual void PaintPreprocessing(IPaintContext context)
 {
 }
Example #57
0
		/// <summary>
		/// Paint the shape group in the graphic context.
		/// </summary>
		/// <param name="g">Graphic context.</param>
		/// <param name="paintContext">The paint context.</param>
		public override void Paint(Graphics g, IPaintContext paintContext)
		{
			GraphicsState gs = g.Save();
			this.TransformGraphics(g);

			foreach (GraphicBase graphics in _groupedObjects)
				graphics.Paint(g, paintContext);

			g.Restore(gs);
		}
Example #58
0
		public override void Paint(Graphics g, IPaintContext paintContext)
		{
			System.Drawing.Drawing2D.GraphicsState gs = g.Save();
			TransformGraphics(g);

			// Modification of StringFormat is necessary to avoid
			// too big spaces between successive words
			StringFormat strfmt = (StringFormat)StringFormat.GenericTypographic.Clone();
			strfmt.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;

			strfmt.LineAlignment = StringAlignment.Near;
			strfmt.Alignment = StringAlignment.Near;

			// next statement is necessary to have a consistent string length both
			// on 0 degree rotated text and rotated text
			// without this statement, the text is fitted to the pixel grid, which
			// leads to "steps" during scaling
			g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;

			if (this.AutoSize)
			{
				var mySize = g.MeasureString(_text, GdiFontManager.ToGdi(_font));
				this.Width = mySize.Width;
				this.Height = mySize.Height;
				g.DrawString(_text, GdiFontManager.ToGdi(_font), new SolidBrush(_color), 0, 0, strfmt);
			}
			else
			{
				System.Drawing.RectangleF rect = new RectangleF(0, 0, (float)this.Width, (float)this.Height);
				g.DrawString(_text, GdiFontManager.ToGdi(_font), new SolidBrush(_color), rect, strfmt);
			}

			g.Restore(gs);
		}
Example #59
0
        public override void Paint(System.Drawing.Graphics g, IPaintContext paintContext)
        {
            if (null == _cachedArea)
            {
                return;
            }

            bool orientationIsVertical = IsOrientationVertical;
            bool scaleIsReversed       = IsScaleReversed;

            int pixelH = orientationIsVertical ? _bitmapPixelsAcross : _bitmapPixelsAlong;
            int pixelV = orientationIsVertical ? _bitmapPixelsAlong : _bitmapPixelsAcross;

            if (null == _bitmap || _bitmap.Width != pixelH || _bitmap.Height != pixelV)
            {
                if (null != _bitmap)
                {
                    _bitmap.Dispose();
                }

                _bitmap = new Bitmap(pixelH, pixelV, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            }

            Data.AltaxoVariant porg;
            Data.AltaxoVariant pend;
            NumericalScale     originalZScale;

            Plot.IColorProvider colorProvider;

            if (null != PlotItem)
            {
                porg           = PlotItem.Style.Scale.OrgAsVariant;
                pend           = PlotItem.Style.Scale.EndAsVariant;
                originalZScale = PlotItem.Style.Scale;
                colorProvider  = PlotItem.Style.ColorProvider;
            }
            else
            {
                porg           = 0;
                pend           = 1;
                originalZScale = new LinearScale();
                colorProvider  = new Plot.ColorProvider.ColorProviderBGRY();
            }

            var legendScale       = (NumericalScale)ScaleWithTicks;
            var legendTickSpacing = ScaleWithTicks.TickSpacing;

            // Fill the bitmap

            for (int i = 0; i < _bitmapPixelsAlong; i++)
            {
                double r     = (scaleIsReversed ^ orientationIsVertical) ? 1 - i / (double)(_bitmapPixelsAlong - 1) : i / (double)(_bitmapPixelsAlong - 1);
                double l     = originalZScale.PhysicalToNormal(legendScale.NormalToPhysical(r));
                var    color = colorProvider.GetColor(l);
                if (orientationIsVertical)
                {
                    for (int j = 0; j < _bitmapPixelsAcross; j++)
                    {
                        _bitmap.SetPixel(j, i, color);
                    }
                }
                else
                {
                    for (int j = 0; j < _bitmapPixelsAcross; j++)
                    {
                        _bitmap.SetPixel(i, j, color);
                    }
                }
            }

            var graphicsState = g.Save();

            TransformGraphics(g);

            {
                // Three tricks are neccessary to get the color legend (which is the bitmap) drawn smooth and uniformly:
                // Everything other than this will result in distorted image, or soft (unsharp) edges
                var graphicsState2 = g.Save();                   // Of course, save the graphics state so we can make our tricks undone afterwards
                g.InterpolationMode = InterpolationMode.Default; // Trick1: Set the interpolation mode, whatever it was before, back to default
                g.PixelOffsetMode   = PixelOffsetMode.Default;   // Trick2: Set the PixelOffsetMode, whatever it was before, back to default

                g.DrawImage(_bitmap,
                            new RectangleF(0, 0, (float)Size.X, (float)Size.Y),
                            new Rectangle(0, 0, pixelH - 1, pixelV - 1), GraphicsUnit.Pixel); // Trick3: Paint both in X and Y direction one pixel less than the source bitmap acually has, this prevents soft edges

                g.Restore(graphicsState2);                                                    // make our tricks undone here
            }
            _axisStyles.Paint(g, paintContext, _cachedArea);

            g.Restore(graphicsState);
        }
Example #60
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[] vSumArray = null;
			foreach (IGPlotItem pi in coll)
			{
				if (pi is G3DPlotItem)
				{
					var gpi = pi as G3DPlotItem;
					var pdata = plotDataDict[gpi];
					vSumArray = AbsoluteStackTransform.AddUp(vSumArray, pdata);
				}
			}

			// now plot the data - the summed up y is in yArray
			AltaxoVariant[] vArray = null;
			Processed3DPlotData previousItemData = null;
			foreach (IGPlotItem pi in coll)
			{
				if (pi is G3DPlotItem)
				{
					var gpi = pi as G3DPlotItem;
					var pdata = plotDataDict[gpi];
					vArray = AbsoluteStackTransform.AddUp(vArray, pdata);
					AltaxoVariant[] localArray = new AltaxoVariant[vArray.Length];

					int j = -1;
					foreach (int originalIndex in pdata.RangeList.OriginalRowIndices())
					{
						j++;
						AltaxoVariant v = 100 * vArray[j] / vSumArray[j];
						localArray[j] = v;

						Logical3D rel = new Logical3D(
						layer.XAxis.PhysicalVariantToNormal(pdata.GetXPhysical(originalIndex)),
						layer.YAxis.PhysicalVariantToNormal(pdata.GetYPhysical(originalIndex)),
						layer.ZAxis.PhysicalVariantToNormal(v));

						PointD3D pabs;
						layer.CoordinateSystem.LogicalToLayerCoordinates(rel, out pabs);
						pdata.PlotPointsInAbsoluteLayerCoordinates[j] = pabs;
					}
					// we have also to exchange the accessor for the physical z value and replace it by our own one
					pdata.ZPhysicalAccessor = new IndexedPhysicalValueAccessor(delegate (int i) { return localArray[i]; });
					pdata.PreviousItemData = previousItemData;
					previousItemData = pdata;
				}
			}
		}