示例#1
0
        void Initialize(bool initDocument)
        {
            if (initDocument)
            {
                m_Layer = Main.DocumentPath.GetRootNodeImplementing <XYPlotLayer>(_originalDoc);
            }

            if (_view != null)
            {
                _view.BeginUpdate();

                _view.Background = _doc.Background;

                _view.EditText = _doc.Text;

                _view.Position = _doc.Position;
                _view.Rotation = _doc.Rotation;

                // fill the font name combobox with all fonts
                _view.FontFamily = _doc.Font.FontFamily;

                _view.FontSize = _doc.Font.Size;

                // fill the font size combobox with reasonable values
                //this.m_cbFontSize.Items.AddRange(new string[] { "8", "9", "10", "11", "12", "14", "16", "18", "20", "22", "24", "26", "28", "36", "48", "72" });
                //this.m_cbFontSize.Text = m_TextObject.Font.Size.ToString();


                // fill the color dialog box
                _view.FontColor = this._doc.TextFillBrush;

                _view.EndUpdate();
            }
        }
示例#2
0
        /// <summary>
        /// Handler for all submenu items of the data popup.".
        /// </summary>
        /// <param name="sender">The menuitem, must be of type <see cref="DataMenuItem"/>.</param>
        /// <param name="e">Not used.</param>
        /// <remarks>The handler either checks the menuitem, if it was unchecked. If it was already checked,
        /// it shows the LineScatterPlotStyleControl into a dialog box.
        /// </remarks>
        private void EhMenuData_Data(object sender, System.EventArgs e)
        {
            DataMenuItem dmi = (DataMenuItem)sender;

            if (!dmi.Checked)
            {
                // if the menu item was not checked before, check it now
                // by making the plot association shown by the menu item
                // the actual plot association
                int         actLayerNum = this.CurrentLayerNumber;
                XYPlotLayer actLayer    = this.Layers[actLayerNum];
                if (null != actLayer && dmi.PlotItemNumber < actLayer.PlotItems.Flattened.Length)
                {
                    dmi.Checked       = true;
                    CurrentPlotNumber = dmi.PlotItemNumber;
                }
            }
            else
            {
                // if it was checked before, then bring up the plot style dialog
                // of the plot association represented by this menu item
                int         actLayerNum = this.CurrentLayerNumber;
                XYPlotLayer actLayer    = this.Layers[actLayerNum];
                IGPlotItem  pa          = actLayer.PlotItems.Flattened[CurrentPlotNumber];

                Current.Gui.ShowDialog(new object[] { pa }, string.Format("#{0}: {1}", pa.Name, pa.ToString()), true);
            }
        }
示例#3
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>
        /// <returns>The graphics path of the selection rectangle.</returns>
        protected GraphicsPath GetPath(XYPlotLayer layer, bool withTicks, float inflateby)
        {
            Logical3D    r0 = _cachedAxisStyleInfo.Identifier.Begin;
            Logical3D    r1 = _cachedAxisStyleInfo.Identifier.End;
            GraphicsPath gp = new GraphicsPath();

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

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

            Pen widenPen = new Pen(Color.Black, 2 * inflateby);

            gp.Widen(widenPen);

            return(gp);
        }
 public void Paint(Graphics g, XYPlotLayer layer)
 {
     for (int i = 0; i < _axisStyles.Count; ++i)
     {
         _axisStyles[i].Paint(g, layer);
     }
 }
示例#5
0
        /// <summary>
        /// Updates a special menu item, the data item, with the currently available plot names. The active plot is marked with a
        /// check.
        /// </summary>
        public void UpdateDataPopup()
        {
            if (null == this.m_MenuDataPopup)
            {
                return;                 // as long there is no menu, we cannot do it
            }
            // first delete old menuitems
            this.m_MenuDataPopup.MenuItems.Clear();


            // check there is at least one layer
            if (m_Graph.Layers.Count == 0)
            {
                return;                 // there is no layer, we can not have items in the data menu
            }
            // now it is save to get the active layer
            int         actLayerNum = this.CurrentLayerNumber;
            XYPlotLayer actLayer    = this.Layers[actLayerNum];

            // then append the plot associations of the actual layer

            int actPA = CurrentPlotNumber;
            int len   = actLayer.PlotItems.Flattened.Length;

            for (int i = 0; i < len; i++)
            {
                IGPlotItem   pa = actLayer.PlotItems.Flattened[i];
                DataMenuItem mi = new DataMenuItem(pa.ToString(), new EventHandler(EhMenuData_Data));
                mi.Checked        = (i == actPA);
                mi.PlotItemNumber = i;
                this.m_MenuDataPopup.MenuItems.Add(mi);
            }
        }
示例#6
0
        public static bool ShowDialog(XYPlotLayer layer, string currentPage, CSLineID currentEdge)
        {
            LayerController ctrl = new LayerController(layer, currentPage, currentEdge);
            LayerControl    view = new LayerControl();

            ctrl.View = view;

            return(Current.Gui.ShowDialog(ctrl, layer.Name, true));
        }
示例#7
0
        public AxisScaleController(XYPlotLayer layer, int axisnumber)
        {
            m_Layer      = layer;
            m_axisNumber = axisnumber;
            m_Axis       = m_Layer.LinkedScales.Scale(axisnumber);
            _tempAxis    = (Scale)m_Axis.Clone();


            SetElements();
        }
示例#8
0
        private static Tuple <string, NonlinearFitDocument, string, XYPlotLayer> SelectFitDocument(Altaxo.Gui.Graph.Gdi.Viewing.IGraphController ctrl)
        {
            XYPlotLayer activeLayer = null;

            // is a nonlinear fit function plot item selected ?
            var funcPlotItem = ctrl.SelectedRealObjects.OfType <XYNonlinearFitFunctionPlotItem>().FirstOrDefault();

            if (null != funcPlotItem)
            {
                activeLayer = Altaxo.Main.AbsoluteDocumentPath.GetRootNodeImplementing <XYPlotLayer>(funcPlotItem);
                return(new Tuple <string, NonlinearFitDocument, string, XYPlotLayer>(string.Empty, funcPlotItem.FitDocumentCopy, funcPlotItem.FitDocumentIdentifier, activeLayer)); // if a fit function plot item was selected, then use the fit document of this item
            }

            // is a normal plot item selected ?
            // ------------------------------------------------------------------------------------
            var columnPlotItem = ctrl.SelectedRealObjects.OfType <XYColumnPlotItem>().FirstOrDefault();

            if (null != columnPlotItem)
            {
                return(SelectFitDocument(ctrl, columnPlotItem));
            }

            // is the active layer an XY-plot layer ? Or do we have any XY-plot-layer ?
            // ------------------------------------------------------------------------------------
            activeLayer = (ctrl.ActiveLayer as XYPlotLayer);
            if (null != activeLayer)
            {
                var result = SelectFitDocument(ctrl, activeLayer);
                if (result.Item2 != null)
                {
                    return(result);
                }
            } // null != activeLayer

            activeLayer = TreeNodeExtensions.TakeFromHereToFirstLeaves(ctrl.Doc.RootLayer).OfType <XYPlotLayer>().FirstOrDefault();
            if (null != activeLayer)
            {
                var result = SelectFitDocument(ctrl, activeLayer);
                if (result.Item2 != null)
                {
                    return(result);
                }
                else
                {
                    var localdoc = (ctrl.Doc.GetGraphProperty(FitDocumentPropertyName) as Calc.Regression.Nonlinear.NonlinearFitDocument) ??
                                   (Altaxo.Calc.Regression.Nonlinear.NonlinearFitDocument)_lastFitDocument?.Clone() ??
                                   new Altaxo.Calc.Regression.Nonlinear.NonlinearFitDocument();

                    return(new Tuple <string, NonlinearFitDocument, string, XYPlotLayer>(null, localdoc, null, activeLayer));
                }
            } // null != activeLayer

            // no idea what to fit - there is not even an XY plot layer
            return(new Tuple <string, NonlinearFitDocument, string, XYPlotLayer>("The graph has no XYPlotLayer to host any fit function", null, null, null));
        }
示例#9
0
        public static bool EhLayerPositionEdit(IHitTestObject hit)
        {
            XYPlotLayer layer = hit.HittedObject as XYPlotLayer;

            if (layer == null)
            {
                return(false);
            }

            ShowDialog(layer, "Position");

            return(false);
        }
示例#10
0
        /// <summary>
        /// Handles the double click event onto a plot item.
        /// </summary>
        /// <param name="hit">Object containing information about the double clicked object.</param>
        /// <returns>True if the object should be deleted, false otherwise.</returns>
        protected static bool EhEditPlotItem(IHitTestObject hit)
        {
            XYPlotLayer actLayer = hit.ParentLayer;
            IGPlotItem  pa       = (IGPlotItem)hit.HittedObject;


            // get plot group
            PlotGroupStyleCollection plotGroup = pa.ParentCollection.GroupStyles;

            Current.Gui.ShowDialog(new object[] { pa }, string.Format("#{0}: {1}", pa.Name, pa.ToString()), true);

            return(false);
        }
示例#11
0
        /// <summary>
        /// This plots a label plot into the provided layer.
        /// </summary>
        /// <param name="layer">The layer to plot into.</param>
        /// <param name="xcol">The x column.</param>
        /// <param name="ycol">The y column.</param>
        /// <param name="labelcol">The label column.</param>
        public static void PlotOnlyLabel(XYPlotLayer layer, Altaxo.Data.DataColumn xcol, Altaxo.Data.DataColumn ycol, Altaxo.Data.DataColumn labelcol)
        {
            XYColumnPlotData pa = new XYColumnPlotData(xcol, ycol);

            G2DPlotStyleCollection ps         = new G2DPlotStyleCollection(LineScatterPlotStyleKind.Empty);
            LabelPlotStyle         labelStyle = new LabelPlotStyle(labelcol);

            labelStyle.FontSize        = 10;
            labelStyle.BackgroundStyle = new FilledRectangle(System.Drawing.Color.LightCyan);
            ps.Add(labelStyle);

            layer.PlotItems.Add(new XYColumnPlotItem(pa, ps));
        }
示例#12
0
        /// <summary>
        /// Plots the cross PRESS value into a provided layer.
        /// </summary>
        /// <param name="table">The table of PLS output data.</param>
        /// <param name="layer">The layer to plot into.</param>
        public static void PlotCrossPRESSValue(Altaxo.Data.DataTable table, XYPlotLayer layer)
        {
            Altaxo.Data.DataColumn ycol = table[WorksheetAnalysis.GetCrossPRESSValue_ColumnName()];
            Altaxo.Data.DataColumn xcol = table[WorksheetAnalysis.GetNumberOfFactors_ColumnName()];

            XYColumnPlotData       pa = new XYColumnPlotData(xcol, ycol);
            G2DPlotStyleCollection ps = new G2DPlotStyleCollection(LineScatterPlotStyleKind.LineAndScatter);

            layer.PlotItems.Add(new XYColumnPlotItem(pa, ps));

            layer.DefaultXAxisTitleString = "Number of factors";
            layer.DefaultYAxisTitleString = "Cross PRESS value";
        }
示例#13
0
        public override IHitTestObject HitTest(XYPlotLayer layer, PointF pt)
        {
            GraphicsPath gp = GetSelectionPath(layer);

            if (gp.IsVisible(pt))
            {
                return(new HitTestObject(gp, this));
            }
            else
            {
                return(null);
            }
        }
 /// <summary>
 /// Find the plot item number of a given plot item.
 /// </summary>
 /// <param name="layer">The layer in which this plot item resides.</param>
 /// <param name="plotitem">The plot item for which the number should be retrieved.</param>
 /// <returns></returns>
 private int GetPlotItemNumber(XYPlotLayer layer, XYColumnPlotItem plotitem)
 {
     if (null != layer)
     {
         for (int i = 0; i < layer.PlotItems.Flattened.Length; i++)
         {
             if (object.ReferenceEquals(layer.PlotItems.Flattened[i], plotitem))
             {
                 return(i);
             }
         }
     }
     return(-1);
 }
示例#15
0
        /// <summary>
        /// Plots the predicted versus actual Y (concentration) into a provided layer.
        /// </summary>
        /// <param name="table">The table of PLS output data.</param>
        /// <param name="layer">The layer to plot into.</param>
        /// <param name="whichY">The number of the component (y, concentration etc.) for which to plot the residuals.</param>
        /// <param name="numberOfFactors">The number of factors used for calculation of the residuals.</param>
        public static void PlotPredictedVersusActualY(Altaxo.Data.DataTable table, XYPlotLayer layer, int whichY, int numberOfFactors)
        {
            string ypredcolname = WorksheetAnalysis.GetYPredicted_ColumnName(whichY, numberOfFactors);
            string yactcolname  = WorksheetAnalysis.GetYOriginal_ColumnName(whichY);

            if (table[ypredcolname] == null)
            {
                GetAnalysis(table).CalculateYPredicted(table, whichY, numberOfFactors);
            }

            PlotOnlyLabel(layer, table[yactcolname], table[ypredcolname], table[WorksheetAnalysis.GetMeasurementLabel_ColumnName()]);

            layer.DefaultXAxisTitleString = string.Format("Y original{0}", whichY);
            layer.DefaultYAxisTitleString = string.Format("Y predicted{0} (#factors:{1})", whichY, numberOfFactors);
        }
        public void SetDropLineConditions()
        {
            XYPlotLayer layer = Main.DocumentPath.GetRootNodeImplementing(_doc, typeof(XYPlotLayer)) as XYPlotLayer;

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

            foreach (CSPlaneID id in layer.CoordinateSystem.GetJoinedPlaneIdentifier(layer.AxisStyles.AxisStyleIDs, _tempDoc.DropLine))
            {
                bool sel = _tempDoc.DropLine.Contains(id);
                CSPlaneInformation info = layer.CoordinateSystem.GetPlaneInformation(id);
                names.Add(new SelectableListNode(info.Name, id, sel));
            }

            _view.InitializeDropLineConditions(names);
        }
示例#17
0
        /// <summary>
        /// Plots the x (spectral) leverage into a provided layer.
        /// </summary>
        /// <param name="table">The table of PLS output data.</param>
        /// <param name="layer">The layer to plot into.</param>
        /// <param name="preferredNumberOfFactors">The number of factors used for leverage calculation.</param>
        public static void PlotXLeverage(Altaxo.Data.DataTable table, XYPlotLayer layer, int preferredNumberOfFactors)
        {
            string xcolname = WorksheetAnalysis.GetMeasurementLabel_ColumnName();
            string ycolname = WorksheetAnalysis.GetXLeverage_ColumnName(preferredNumberOfFactors);

            if (table[ycolname] == null)
            {
                GetAnalysis(table).CalculateXLeverage(table, preferredNumberOfFactors);
            }

            PlotOnlyLabel(layer, table[xcolname], table[ycolname], table[WorksheetAnalysis.GetMeasurementLabel_ColumnName()]);

            layer.DefaultXAxisTitleString = string.Format("Measurement");
            layer.DefaultYAxisTitleString = string.Format("Score leverage (#factors:{0})", preferredNumberOfFactors);
        }
示例#18
0
        public AxisScaleController(XYPlotLayer layer, Scale ax)
        {
            m_Layer      = layer;
            m_axisNumber = layer.LinkedScales.IndexOf(ax);
            if (m_axisNumber < 0)
            {
                throw new ArgumentException("Provided axis is not member of the layer");
            }

            m_Axis    = ax;
            _tempAxis = (Scale)m_Axis.Clone();


            SetElements();
        }
示例#19
0
        /// <summary>
        /// Plots the x (spectral) residuals (of cross prediction) into a provided layer.
        /// </summary>
        /// <param name="table">The table of PLS output data.</param>
        /// <param name="layer">The layer to plot into.</param>
        /// <param name="whichY">The number of the component (y, concentration etc.) for which to plot the residuals.</param>
        /// <param name="numberOfFactors">The number of factors used for calculation of the residuals.</param>
        public static void PlotXCrossResiduals(Altaxo.Data.DataTable table, XYPlotLayer layer, int whichY, int numberOfFactors)
        {
            string xresidualcolname = WorksheetAnalysis.GetXCrossResidual_ColumnName(whichY, numberOfFactors);
            string yactcolname      = WorksheetAnalysis.GetYOriginal_ColumnName(whichY);

            if (table[xresidualcolname] == null)
            {
                GetAnalysis(table).CalculateCrossPredictedAndResidual(table, whichY, numberOfFactors, false, false, true);
            }

            PlotOnlyLabel(layer, table[yactcolname], table[xresidualcolname], table[WorksheetAnalysis.GetMeasurementLabel_ColumnName()]);

            layer.DefaultXAxisTitleString = string.Format("Y original{0}", whichY);
            layer.DefaultYAxisTitleString = string.Format("X cross residual{0} (#factors:{1})", whichY, numberOfFactors);
        }
示例#20
0
        /// <summary>
        /// Copy constructor. Clones (!) all the items in the list.
        /// </summary>
        /// <param name="owner">The new owner of the cloned list.</param>
        /// <param name="from">The list to clone all items from.</param>
        public PlotItemCollection(XYPlotLayer owner, PlotItemCollection from)
        {
            _parent    = owner;
            _styles    = new PlotGroupStyleCollection();
            _plotItems = new List <IGPlotItem>();


            // Clone all the items in the list.
            for (int i = 0; i < from.Count; i++)
            {
                Add((IGPlotItem)from[i].Clone()); // clone the items
            }
            // special way neccessary to handle plot groups
            this._styles = null == from._styles ? null : from._styles.Clone();
        }
示例#21
0
        /// <summary>
        /// Plots the residual y values of a given component into a provided layer.
        /// </summary>
        /// <param name="table">The table of PLS output data.</param>
        /// <param name="layer">The layer to plot into.</param>
        /// <param name="whichY">The number of the component (y, concentration etc.) for which to plot the residuals.</param>
        /// <param name="numberOfFactors">The number of factors used for calculation of the residuals.</param>
        public static void PlotYResiduals(Altaxo.Data.DataTable table, XYPlotLayer layer, int whichY, int numberOfFactors)
        {
            string yrescolname = WorksheetAnalysis.GetYResidual_ColumnName(whichY, numberOfFactors);
            string yactcolname = WorksheetAnalysis.GetYOriginal_ColumnName(whichY);

            // Calculate the residual if not here
            if (table[yrescolname] == null)
            {
                GetAnalysis(table).CalculateYResidual(table, whichY, numberOfFactors);
            }

            PlotOnlyLabel(layer, table[yactcolname], table[yrescolname], table[WorksheetAnalysis.GetMeasurementLabel_ColumnName()]);

            layer.DefaultXAxisTitleString = string.Format("Y original{0}", whichY);
            layer.DefaultYAxisTitleString = string.Format("Y residual{0} (#factors:{1})", whichY, numberOfFactors);
        }
示例#22
0
        LayerController(XYPlotLayer layer, string currentPage, int axisScaleIdx, CSLineID id)
        {
            _originalDoc    = layer;
            _doc            = (XYPlotLayer)layer.Clone();
            _docSuspendLock = _doc.BeginUpdate();

            SetCoordinateSystemDependentObjects(id);

            _currentScale    = axisScaleIdx;
            _currentAxisID   = id;
            _currentPlaneID  = CSPlaneID.Front;
            _currentPageName = currentPage;
            if (null != View)
            {
                SetViewElements();
            }
        }
        public void SetElements(bool bInit)
        {
            if (bInit)
            {
                m_Height          = m_Layer.UserHeight;
                m_Width           = m_Layer.UserWidth;
                m_Left            = m_Layer.UserXPosition;
                m_Top             = m_Layer.UserYPosition;
                m_Rotation        = m_Layer.Rotation;
                m_Scale           = m_Layer.Scale;
                m_ClipDataToFrame = m_Layer.ClipDataToFrame == LayerDataClipping.StrictToCS;

                m_LeftType    = m_Layer.UserXPositionType;
                m_TopType     = m_Layer.UserYPositionType;
                m_HeightType  = m_Layer.UserHeightType;
                m_WidthType   = m_Layer.UserWidthType;
                m_LinkedLayer = m_Layer.LinkedLayer;


                m_XAxisLink = new AxisLinkController(m_Layer, true);
                m_YAxisLink = new AxisLinkController(m_Layer, false);
            }

            if (View != null)
            {
                InitializeWidthValue();
                InitializeHeightValue();

                InitializeLeftValue();
                InitializeTopValue();

                View.InitializeRotation((float)m_Rotation);
                View.InitializeScale(Serialization.GUIConversion.GetPercentMeasureText(m_Scale));
                View.InitializeClipDataToFrame(m_ClipDataToFrame);

                InitializePositionTypes();
                InitializeSizeTypes();
                InitializeLinkedAxisChoices();

                // initialize the axis link properties
                m_XAxisLink.View = View.GetXAxisLink();
                m_YAxisLink.View = View.GetYAxisLink();
            }
        }
示例#24
0
        protected override void FinishDrawing()
        {
            // we must deduce from layer coordinates back to physical coordinates
            Logical3D   r0, r1;
            XYPlotLayer layer = this._grac.ActiveLayer;

            layer.CoordinateSystem.LayerToLogicalCoordinates(_Points[0].layerCoord.X, _Points[0].layerCoord.Y, out r0);
            layer.CoordinateSystem.LayerToLogicalCoordinates(_Points[1].layerCoord.X, _Points[1].layerCoord.Y, out r1);

            double xr0 = r0.RX;
            double yr0 = r0.RY;

            double xr1 = r1.RX;
            double yr1 = r1.RY;

            if (xr0 > xr1)
            {
                Swap(ref xr0, ref xr1);
            }
            if (yr0 > yr1)
            {
                Swap(ref yr0, ref yr1);
            }

            // now with the help of the axes, calculate the new boundaries
            AltaxoVariant xo = layer.XAxis.NormalToPhysicalVariant(xr0);
            AltaxoVariant xe = layer.XAxis.NormalToPhysicalVariant(xr1);
            AltaxoVariant yo = layer.YAxis.NormalToPhysicalVariant(yr0);
            AltaxoVariant ye = layer.YAxis.NormalToPhysicalVariant(yr1);

            try             // trying to set the scales can go wrong..
            {
                layer.XAxis.SetScaleOrgEnd(xo, xe);
                layer.YAxis.SetScaleOrgEnd(yo, ye);
            }
            catch (Exception)
            {
            }

            // deselect the text tool
            // this._grac.CurrentGraphToolType = typeof(GraphControllerMouseHandlers.ObjectPointerMouseHandler);
            _grac.WinFormsController.RefreshGraph();
        }
示例#25
0
        /// <summary>
        /// Looks for a graph object at pixel position <paramref name="pixelPos"/> and returns true if one is found.
        /// </summary>
        /// <param name="pixelPos">The pixel coordinates (graph panel coordinates)</param>
        /// <param name="plotItemsOnly">If true, only the plot items where hit tested.</param>
        /// <param name="foundObject">Found object if there is one found, else null</param>
        /// <param name="foundInLayerNumber">The layer the found object belongs to, otherwise 0</param>
        /// <returns>True if a object was found at the pixel coordinates <paramref name="pixelPos"/>, else false.</returns>
        public bool FindGraphObjectAtPixelPosition(PointF pixelPos, bool plotItemsOnly, out IHitTestObject foundObject, out int foundInLayerNumber)
        {
            var mousePT = PixelToPrintableAreaCoordinates(pixelPos);
            var hitData = new HitTestPointData(mousePT, this.ZoomFactor);

            for (int nLayer = 0; nLayer < Layers.Count; nLayer++)
            {
                XYPlotLayer layer = Layers[nLayer];
                foundObject = layer.HitTest(hitData, plotItemsOnly);
                if (null != foundObject)
                {
                    foundInLayerNumber = nLayer;
                    return(true);
                }
            }
            foundObject        = null;
            foundInLayerNumber = 0;
            return(false);
        }
        /// <summary>
        /// Handles the MouseDown event when the plot point tool is selected
        /// </summary>
        /// <param name="position">Mouse position.</param>
        /// <param name="e">The mouse event args</param>
        public override void OnMouseDown(PointD2D position, MouseButtonEventArgs e)
        {
            base.OnMouseDown(position, e);

            var graphXY = _grac.ConvertMouseToRootLayerCoordinates(position);

            _grac.FindGraphObjectAtPixelPosition(position, true, out var clickedObject, out var clickedLayerNumber);
            if (null != clickedObject && clickedObject.HittedObject is XYColumnPlotItem)
            {
                _PlotItem = (XYColumnPlotItem)clickedObject.HittedObject;
                var transXY = clickedObject.Transformation.InverseTransformPoint(graphXY);

                _layer = (XYPlotLayer)(clickedObject.ParentLayer);
                XYScatterPointInformation scatterPoint = _PlotItem.GetNearestPlotPoint(_layer, transXY);
                _PlotItemNumber = GetPlotItemNumber(_layer, _PlotItem);

                if (null != scatterPoint)
                {
                    _PlotIndex = scatterPoint.PlotIndex;
                    _RowIndex  = scatterPoint.RowIndex;
                    // convert this layer coordinates first to PrintableAreaCoordinates
                    var rootLayerCoord = clickedObject.ParentLayer.TransformCoordinatesFromHereToRoot(scatterPoint.LayerCoordinates);
                    _positionOfCrossInRootLayerCoordinates = rootLayerCoord;
                    // m_Cross.X -= _grac.GraphViewOffset.X;
                    // m_Cross.Y -= _grac.GraphViewOffset.Y;

                    var newPixelCoord = _grac.ConvertGraphToMouseCoordinates(rootLayerCoord);

                    // TODO (Wpf)
                    //var newCursorPosition = new Point((int)(Cursor.Position.X + newPixelCoord.X - mouseXY.X),(int)(Cursor.Position.Y + newPixelCoord.Y - mouseXY.Y));
                    //SetCursorPos(newCursorPosition.X, newCursorPosition.Y);

                    DisplayData(_PlotItem, scatterPoint.RowIndex,
                                _PlotItem.XYColumnPlotData.XColumn[scatterPoint.RowIndex],
                                _PlotItem.XYColumnPlotData.YColumn[scatterPoint.RowIndex]);

                    // here we shoud switch the bitmap cache mode on and link us with the AfterPaint event
                    // of the grac
                    _grac.RenderOverlay(); // no refresh necessary, only invalidate to show the cross
                }
            }
        } // end of function
        } // end of function

        void DisplayCrossCoordinates()
        {
            XYPlotLayer layer = _grac.ActiveLayer;

            if (layer == null)
            {
                return;
            }

            PointF layerXY = layer.GraphToLayerCoordinates(m_Cross);



            Logical3D r;

            layer.CoordinateSystem.LayerToLogicalCoordinates(layerXY.X, layerXY.Y, out r);
            Altaxo.Data.AltaxoVariant xphys = layer.XAxis.NormalToPhysicalVariant(r.RX);
            Altaxo.Data.AltaxoVariant yphys = layer.YAxis.NormalToPhysicalVariant(r.RY);

            this.DisplayData(_grac.CurrentLayerNumber, xphys, yphys);
        }
示例#28
0
        protected override void FinishDrawing()
        {
            // we must deduce from layer coordinates back to physical coordinates
            Logical3D   r0, r1;
            XYPlotLayer layer = this._grac.ActiveLayer;

            layer.CoordinateSystem.LayerToLogicalCoordinates(_Points[0].layerCoord.X, _Points[0].layerCoord.Y, out r0);
            layer.CoordinateSystem.LayerToLogicalCoordinates(_Points[1].layerCoord.X, _Points[1].layerCoord.Y, out r1);

            double xr0 = r0.RX;
            double yr0 = r0.RY;

            double xr1 = r1.RX;
            double yr1 = r1.RY;

            if (xr0 > xr1)
            {
                Swap(ref xr0, ref xr1);
            }
            if (yr0 > yr1)
            {
                Swap(ref yr0, ref yr1);
            }

            // now with the help of the axes, calculate the new boundaries
            AltaxoVariant xo = layer.XAxis.NormalToPhysicalVariant(xr0);
            AltaxoVariant xe = layer.XAxis.NormalToPhysicalVariant(xr1);
            AltaxoVariant yo = layer.YAxis.NormalToPhysicalVariant(yr0);
            AltaxoVariant ye = layer.YAxis.NormalToPhysicalVariant(yr1);



            layer.XAxis.ProcessDataBounds(xo, true, xe, true);
            layer.YAxis.ProcessDataBounds(yo, true, ye, true);

            // deselect the text tool
            // this._grac.CurrentGraphToolType = typeof(GraphControllerMouseHandlers.ObjectPointerMouseHandler);
            _grac.RefreshGraph();
        }
示例#29
0
        } // end of function

        bool CalculateCrossCoordinates(out Altaxo.Data.AltaxoVariant x, out Altaxo.Data.AltaxoVariant y)
        {
            XYPlotLayer layer = _grac.ActiveLayer;

            if (layer == null)
            {
                x = new AltaxoVariant();
                y = new AltaxoVariant();
                return(false);
            }

            PointF layerXY = layer.GraphToLayerCoordinates(m_Cross);



            Logical3D r;

            layer.CoordinateSystem.LayerToLogicalCoordinates(layerXY.X, layerXY.Y, out r);
            x = layer.XAxis.NormalToPhysicalVariant(r.RX);
            y = layer.YAxis.NormalToPhysicalVariant(r.RY);
            return(true);
        }
        public void EhView_LinkedLayerChanged(SelectableListNode node)
        {
            XYPlotLayer oldLinkedLayer = m_LinkedLayer;

            m_LinkedLayer = (XYPlotLayer)node.Item;

            // we have to check if there is a need to update the type comboboxes
            if (oldLinkedLayer != null && m_LinkedLayer != null)
            {
            }
            else if (oldLinkedLayer == null && m_LinkedLayer != null)
            {
                InitializePositionTypes();
                InitializeSizeTypes();
            }
            else if (oldLinkedLayer != null && m_LinkedLayer == null)
            {
                if (m_LeftType != XYPlotLayerPositionType.AbsoluteValue && m_LeftType != XYPlotLayerPositionType.RelativeToGraphDocument)
                {
                    ChangeLeftType(XYPlotLayerPositionType.RelativeToGraphDocument);
                }
                if (m_TopType != XYPlotLayerPositionType.AbsoluteValue && m_TopType != XYPlotLayerPositionType.RelativeToGraphDocument)
                {
                    ChangeTopType(XYPlotLayerPositionType.RelativeToGraphDocument);
                }

                if (m_WidthType != XYPlotLayerSizeType.AbsoluteValue && m_WidthType != XYPlotLayerSizeType.RelativeToGraphDocument)
                {
                    ChangeWidthType(XYPlotLayerSizeType.RelativeToGraphDocument);
                }
                if (m_HeightType != XYPlotLayerSizeType.AbsoluteValue && m_HeightType != XYPlotLayerSizeType.RelativeToGraphDocument)
                {
                    ChangeHeightType(XYPlotLayerSizeType.RelativeToGraphDocument);
                }

                InitializeSizeTypes();
                InitializePositionTypes();
            }
        }
示例#31
0
 public override IHitTestObject HitTest(XYPlotLayer layer, PointF pt)
 {
   GraphicsPath gp = GetSelectionPath(layer);
   if(gp.IsVisible(pt))
     return new HitTestObject(gp,this);
   else
     return null;
 }
 public abstract IHitTestObject HitTest(XYPlotLayer layer, PointF pt);
示例#33
0
    public void Paint(Graphics g, XYPlotLayer layer)
    {
      // 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.LogicalValueOtherFirst = logicalValue;
        }
        if (_styleID.UsePhysicalValueOtherSecond)
        {
          // then update the logical value of this identifier
          double logicalValue = layer.Scales(_styleID.AxisNumberOtherSecond).PhysicalVariantToNormal(_styleID.PhysicalValueOtherSecond);
          _styleID.LogicalValueOtherSecond = logicalValue;
        }

      int axisnumber = _styleID.ParallelAxisNumber;
      CSAxisInformation styleinfo = layer.CoordinateSystem.GetAxisStyleInformation(_styleID);
      _cachedAxisInfo = styleinfo;

      if (ShowAxisLine)
        _axisLineStyle.Paint(g, layer, styleinfo);
      if (ShowMajorLabels)
        this._majorLabelStyle.Paint(g, layer, styleinfo, _axisLineStyle, false);
      if (ShowMinorLabels)
        this._minorLabelStyle.Paint(g, layer, styleinfo, _axisLineStyle, true);
      if (ShowTitle)
        _axisTitle.Paint(g, layer);
    }
示例#34
0
 /// <summary>
 /// Gives the path where the hit test is successfull.
 /// </summary>
 /// <param name="layer"></param>
 /// <returns></returns>
 public virtual GraphicsPath GetSelectionPath(XYPlotLayer layer)
 {
   return (GraphicsPath)_enclosingPath.Clone();
 }
 /// <summary>
 /// Abstract paint function for the AbstractXYAxisLabelStyle.
 /// </summary>
 /// <param name="g">The graphics context.</param>
 /// <param name="layer">The layer the lables belongs to.</param>
 /// <param name="styleInfo">The information which identifies the axis styles.</param>
 /// <param name="axisstyle">The axis style the axis is formatted with.</param>
 /// <param name="useMinorTicks">If true, the minor ticks where used instead of the (default) major ticks.</param>
 public abstract void Paint(Graphics g, XYPlotLayer layer, CSAxisInformation styleInfo, AxisLineStyle axisstyle, bool useMinorTicks);
示例#36
0
    private GraphicsPath _enclosingPath = new GraphicsPath(); // with Winding also overlapping rectangles are selected
    public override void Paint(Graphics g, XYPlotLayer layer, CSAxisInformation styleInfo, AxisLineStyle axisstyle, bool useMinorTicks)
    {
      _cachedStyleID = styleInfo.Identifier;
      CSLineID styleID = styleInfo.Identifier;
      Scale raxis = styleID.ParallelAxisNumber==0 ? layer.XAxis : layer.YAxis;

      _enclosingPath.Reset();
      _enclosingPath.FillMode = FillMode.Winding; // with Winding also overlapping rectangles are selected
      GraphicsPath helperPath = new GraphicsPath();
      Matrix math = new Matrix();

      Logical3D r0 = _cachedStyleID.Begin;
      Logical3D r1 = _cachedStyleID.End;

      SizeF layerSize = layer.Size;
      PointF outVector;
      Logical3D outer;
      float outerDistance = null==axisstyle? 0 : axisstyle.GetOuterDistance(styleInfo.PreferedLabelSide);
      float dist_x = outerDistance; // Distance from axis tick point to label
      float dist_y = outerDistance; // y distance from axis tick point to label

      // dist_x += this._font.SizeInPoints/3; // add some space to the horizontal direction in order to separate the chars a little from the ticks

      // 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;

      double[] relpositions;
      AltaxoVariant[] ticks;
      if(useMinorTicks)
      {
        relpositions = raxis.GetMinorTicksNormal();
        ticks = raxis.GetMinorTicksAsVariant();
      }
      else
      {
        relpositions = raxis.GetMajorTicksNormal();
        ticks = raxis.GetMajorTicksAsVariant();
      }
      
      IMeasuredLabelItem[] labels = _labelFormatting.GetMeasuredItems(g,_font,_stringFormat,ticks);

      float emSize = _font.SizeInPoints;
      for(int i=0;i<ticks.Length;i++)
      {
        double r = relpositions[i];

        outer = layer.CoordinateSystem.GetLogicalDirection(styleID.ParallelAxisNumber, styleInfo.PreferedLabelSide);
        PointF tickorg = layer.CoordinateSystem.GetNormalizedDirection(r0, r1, r, outer, out outVector);
        PointF tickend = tickorg;
        tickend.X += outVector.X * outerDistance;
        tickend.Y += outVector.Y * outerDistance;
       

        SizeF msize = labels[i].Size;
        PointF morg = tickend;

        if (_automaticRotationShift)
        {
          double alpha = _rotation * Math.PI / 180 - Math.Atan2(outVector.Y, outVector.X);
          double shift = msize.Height * 0.5 * Math.Abs(Math.Sin(alpha)) + (msize.Width + _font.SizeInPoints / 2) * 0.5 * Math.Abs(Math.Cos(alpha));
          morg.X += (float)(outVector.X * shift);
          morg.Y += (float)(outVector.Y * shift);
        }
        else
        {
          morg.X += (float)(outVector.X * _font.SizeInPoints/3);
        }

       
        RectangleF mrect = new RectangleF(morg,msize);
        if(_automaticRotationShift)
          AdjustRectangle(ref mrect, StringAlignment.Center, StringAlignment.Center);
        else
          AdjustRectangle(ref mrect, _horizontalAlignment, _verticalAlignment);

        math.Reset();
        math.Translate((float)morg.X, (float)morg.Y);
        if (this._rotation != 0)
        {
          math.Rotate((float)-this._rotation);
        }
        math.Translate((float)(mrect.X - morg.X + emSize * _xOffset), (float)(mrect.Y - morg.Y + emSize * _yOffset));


        System.Drawing.Drawing2D.GraphicsState gs = g.Save();
        g.MultiplyTransform(math);

        if(this._backgroundStyle!=null)
          _backgroundStyle.Draw(g,new RectangleF(PointF.Empty,msize));

        _brush.Rectangle = new RectangleF(PointF.Empty, msize);      
        labels[i].Draw(g,_brush,new PointF(0,0));
        g.Restore(gs); // Restore the graphics state

        helperPath.Reset();
        helperPath.AddRectangle(new RectangleF(PointF.Empty, msize));
        helperPath.Transform(math);

        _enclosingPath.AddPath(helperPath,true);

       
      }
    

    }
示例#37
0
    public virtual IHitTestObject HitTest(XYPlotLayer layer, PointF pt, bool withTicks)
    {

      GraphicsPath selectionPath = GetSelectionPath(layer,withTicks);
      return selectionPath.IsVisible(pt) ? new HitTestObject(GetObjectPath(layer,withTicks),selectionPath,this) : null;
    }
示例#38
0
 /// <summary>
 /// Gives the path which encloses the axis line only.
 /// </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>
 /// <returns>The graphics path of the axis line.</returns>
 public virtual GraphicsPath GetObjectPath(XYPlotLayer layer, bool withTicks)
 {
   return GetPath(layer, withTicks, 0);
 }
示例#39
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>
 /// <returns>The graphics path of the selection rectangle.</returns>
 public virtual GraphicsPath GetSelectionPath(XYPlotLayer layer, bool withTicks)
 {
   return GetPath(layer, withTicks, 3);
 }
示例#40
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>
    /// <returns>The graphics path of the selection rectangle.</returns>
    protected GraphicsPath GetPath(XYPlotLayer layer, bool withTicks, float inflateby)
    {

      Logical3D r0 = _cachedAxisStyleInfo.Identifier.Begin;
      Logical3D r1 = _cachedAxisStyleInfo.Identifier.End;
      GraphicsPath gp = new GraphicsPath();
      layer.CoordinateSystem.GetIsoline(gp, r0, r1);
     
      if(withTicks)
      {
        if(this._showFirstDownMajorTicks || this._showFirstUpMajorTicks)
          inflateby = Math.Max(inflateby,this._majorTickLength);
        if(this._showFirstDownMinorTicks || this._showFirstUpMinorTicks)
          inflateby = Math.Max(inflateby,this._minorTickLength);
      }

      Pen widenPen = new Pen(Color.Black, 2*inflateby);

      gp.Widen(widenPen);

      return gp;
    }
示例#41
0
    /// <summary>
    /// Paint the axis in the Graphics context.
    /// </summary>
    /// <param name="g">The graphics context painting to.</param>
    /// <param name="layer">The layer the axis belongs to.</param>
    /// <param name="styleInfo">The axis information of the axis to paint.</param>
    public void Paint(Graphics g, XYPlotLayer layer, CSAxisInformation styleInfo)
    {
      CSLineID styleID = styleInfo.Identifier;
      _cachedAxisStyleInfo = styleInfo.Clone();
      Scale axis = styleID.ParallelAxisNumber == 0 ? layer.XAxis : layer.YAxis;
      
      Logical3D r0 = styleID.Begin;
      Logical3D r1 = styleID.End;

      layer.CoordinateSystem.DrawIsoline(g, _axisPen, r0, r1);

      Logical3D outer;
     


      // now the major ticks
      PointF outVector;
      double[] majorticks = axis.GetMajorTicksNormal();
      for(int i=0;i<majorticks.Length;i++)
      {
        double r = majorticks[i];

        if(_showFirstUpMajorTicks)
        {
          outer = layer.CoordinateSystem.GetLogicalDirection(styleID.ParallelAxisNumber,CSAxisSide.FirstUp);
          PointF tickorg = layer.CoordinateSystem.GetNormalizedDirection(r0, r1, r, outer, out outVector);
          PointF tickend = tickorg;
          tickend.X += outVector.X * _majorTickLength;
          tickend.Y += outVector.Y * _majorTickLength;
          g.DrawLine(_majorTickPen,tickorg,tickend);
        }
        if(_showFirstDownMajorTicks)
        {
          outer = layer.CoordinateSystem.GetLogicalDirection(styleID.ParallelAxisNumber, CSAxisSide.FirstDown);
          PointF tickorg = layer.CoordinateSystem.GetNormalizedDirection(r0, r1, r, outer, out outVector);
          PointF tickend = tickorg;
          tickend.X += outVector.X * _majorTickLength;
          tickend.Y += outVector.Y * _majorTickLength;
          g.DrawLine(_majorTickPen,tickorg,tickend);
        }
      }
      // now the major ticks
      double[] minorticks = axis.GetMinorTicksNormal();
      for(int i=0;i<minorticks.Length;i++)
      {
        double r = minorticks[i];
        
        if(_showFirstUpMinorTicks)
        {
          outer = layer.CoordinateSystem.GetLogicalDirection(styleID.ParallelAxisNumber, CSAxisSide.FirstUp);
          PointF tickorg = layer.CoordinateSystem.GetNormalizedDirection(r0, r1, r, outer, out outVector);
          PointF tickend = tickorg;
          tickend.X += outVector.X * _minorTickLength;
          tickend.Y += outVector.Y * _minorTickLength;
          g.DrawLine(_minorTickPen,tickorg,tickend);
        }
        if(_showFirstDownMinorTicks)
        {
          outer = layer.CoordinateSystem.GetLogicalDirection(styleID.ParallelAxisNumber, CSAxisSide.FirstDown);
          PointF tickorg = layer.CoordinateSystem.GetNormalizedDirection(r0, r1, r, outer, out outVector);
          PointF tickend = tickorg;
          tickend.X += outVector.X * _minorTickLength;
          tickend.Y += outVector.Y * _minorTickLength;
          g.DrawLine(_minorTickPen,tickorg,tickend);
        }
      }
    }