public bool InitializeDocument(params object[] args) { if (args == null || args.Length == 0) { return(false); } if (!(args[0] is DensityImagePlotItem)) { return(false); } else { _doc = _tempdoc = (DensityImagePlotItem)args[0]; } if (_useDocument == UseDocument.Copy) { _tempdoc = (DensityImagePlotItem)_doc.Clone(); } InitializeStyle(); BringTabToFront(0); return(true); }
/// <summary> /// Plots a density image of the selected columns. /// </summary> /// <param name="dg"></param> /// <param name="bLine"></param> /// <param name="bScatter"></param> public static void PlotDensityImage(GUI.WorksheetController dg, bool bLine, bool bScatter) { DensityImagePlotStyle plotStyle = new DensityImagePlotStyle(); // if nothing is selected, assume that the whole table should be plotted int len = dg.SelectedDataColumns.Count; XYZMeshedColumnPlotData assoc = new XYZMeshedColumnPlotData(dg.Doc.DataColumns, len == 0 ? null : dg.SelectedDataColumns); // now create a new Graph with this plot associations Altaxo.Graph.GUI.IGraphController gc = Current.ProjectService.CreateNewGraph(); IGPlotItem pi = new DensityImagePlotItem(assoc, plotStyle); gc.Doc.Layers[0].PlotItems.Add(pi); }
/// <summary> /// Plots a density image of the selected columns. /// </summary> /// <param name="dg"></param> /// <param name="bLine"></param> /// <param name="bScatter"></param> public static void PlotDensityImage(IWorksheetController dg, bool bLine, bool bScatter) { var graph = Altaxo.Graph.Gdi.GraphTemplates.TemplateWithXYPlotLayerWithG2DCartesicCoordinateSystem.CreateGraph(dg.DataTable.GetPropertyContext(), null, dg.DataTable.Name, true); var xylayer = graph.RootLayer.Layers.OfType <XYPlotLayer>().First(); var context = graph.GetPropertyContext(); var plotStyle = new DensityImagePlotStyle(); var assoc = new XYZMeshedColumnPlotData(dg.DataTable, dg.SelectedDataRows, dg.SelectedDataColumns, dg.SelectedPropertyColumns); if (assoc.DataTableMatrix.RowHeaderColumn == null) { assoc.DataTableMatrix.RowHeaderColumn = new IndexerColumn(); } if (assoc.DataTableMatrix.ColumnHeaderColumn == null) { assoc.DataTableMatrix.ColumnHeaderColumn = new IndexerColumn(); } IGPlotItem pi = new DensityImagePlotItem(assoc, plotStyle); xylayer.PlotItems.Add(pi); Current.ProjectService.CreateNewGraph(graph); }
public DensityImageLegend(DensityImagePlotItem plotItem, Main.IDocumentNode futureParentObject, PointD2D initialLocation, PointD2D graphicSize, Main.Properties.IReadOnlyPropertyBag context) : base(new ItemLocationDirect()) { if (null == plotItem) { throw new ArgumentNullException("plotItem"); } if (null == futureParentObject) { throw new ArgumentNullException("futureParentObject"); } ParentObject = futureParentObject; PlotItem = plotItem; if (null == _plotItemProxy.DocumentPath) { throw new ArgumentException("No path could be found between plotItem and futureParentObject. This is an indication that one of the objects is not rooted."); } SetSize(graphicSize.X, graphicSize.Y, Main.EventFiring.Suppressed); SetPosition(initialLocation, Main.EventFiring.Suppressed); // _orientationIsVertical = true; // _scaleIsReversed = false; var cachedScale = (NumericalScale)PlotItem.Style.Scale.Clone(); var scaleTickSpacing = Altaxo.Graph.Scales.Scale.CreateDefaultTicks(cachedScale.GetType()); _cachedArea = new DensityLegendArea(Size, true, false, cachedScale, scaleTickSpacing); //_cachedArea.ParentObject = this; // --> moved to the end of this function _axisStyles = new AxisStyleCollection(); _axisStyles.UpdateCoordinateSystem(_cachedArea.CoordinateSystem); // _axisStyles.ParentObject = this; --> see below var sx0 = new AxisStyle(CSLineID.X0, true, true, false, "Z values", context); sx0.AxisLineStyle.FirstDownMajorTicks = true; sx0.AxisLineStyle.FirstUpMajorTicks = false; sx0.AxisLineStyle.FirstDownMinorTicks = true; sx0.AxisLineStyle.FirstUpMinorTicks = false; var sx1 = new AxisStyle(CSLineID.X1, true, false, false, null, context); sx1.AxisLineStyle.FirstDownMajorTicks = false; sx1.AxisLineStyle.FirstUpMajorTicks = false; sx1.AxisLineStyle.FirstDownMinorTicks = false; sx1.AxisLineStyle.FirstUpMinorTicks = false; var sy0 = new AxisStyle(CSLineID.Y0, true, false, false, "Color map", context); var sy1 = new AxisStyle(CSLineID.Y1, true, false, false, null, context); _axisStyles.Add(sx0); _axisStyles.Add(sx1); _axisStyles.Add(sy0); _axisStyles.Add(sy1); sx0.Title.Rotation = 90; sx0.Title.Location.ParentAnchorX = RADouble.NewRel(0); // Left sx0.Title.Location.ParentAnchorY = RADouble.NewRel(0.5); // Center sx0.Title.Location.LocalAnchorX = RADouble.NewRel(0.5); // Center sx0.Title.Location.LocalAnchorY = RADouble.NewRel(1); // Bottom sx0.Title.X = -Width / 3; sx0.Title.Y = 0; sy0.Title.Location.ParentAnchorX = RADouble.NewRel(0.5); // Center sy0.Title.Location.ParentAnchorY = RADouble.NewRel(0); // Top sy0.Title.Location.LocalAnchorX = RADouble.NewRel(0.5); // Center sy0.Title.Location.LocalAnchorY = RADouble.NewRel(1); // Bottom sy0.Title.X = 0; sy0.Title.Y = sy0.Title.Height / 2; // set the parent objects _axisStyles.ParentObject = this; _cachedArea.ParentObject = this; UpdateTransformationMatrix(); }