当前位置: 首页>>代码示例>>C#>>正文


C# Altaxo.EnsureValidityOfCurrentLayerNumber方法代码示例

本文整理汇总了C#中Altaxo.EnsureValidityOfCurrentLayerNumber方法的典型用法代码示例。如果您正苦于以下问题:C# Altaxo.EnsureValidityOfCurrentLayerNumber方法的具体用法?C# Altaxo.EnsureValidityOfCurrentLayerNumber怎么用?C# Altaxo.EnsureValidityOfCurrentLayerNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Altaxo的用法示例。


在下文中一共展示了Altaxo.EnsureValidityOfCurrentLayerNumber方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetActivePlotPoints

		/// <summary>
		/// Retrieves the data points of the current active plot.
		/// </summary>
		/// <param name="ctrl">The graph controller which controls the graph from which the points are to retrieve.</param>
		/// <param name="xarr">The array of the data point's x values.</param>
		/// <param name="yarr">The array of the data point's y values.</param>
		/// <returns>Null if all is ok, or error message if not.</returns>
		public static string GetActivePlotPoints(Altaxo.Gui.Graph.Gdi.Viewing.IGraphController ctrl, out double[] xarr, out double[] yarr)
		{
			List<double> xlist = new List<double>();
			List<double> ylist = new List<double>();

			xarr = yarr = null;

			ctrl.EnsureValidityOfCurrentLayerNumber();
			ctrl.EnsureValidityOfCurrentPlotNumber();
			var xylayer = ctrl.ActiveLayer as XYPlotLayer;
			if (null == xylayer || ctrl.CurrentPlotNumber < 0)
				return "No active plot available";

			IGPlotItem plotItem = xylayer.PlotItems.Flattened[ctrl.CurrentPlotNumber];

			XYColumnPlotItem xyPlotItem = plotItem as XYColumnPlotItem;

			if (xyPlotItem == null)
				return "No active plot!";

			XYColumnPlotData data = xyPlotItem.XYColumnPlotData;
			if (data == null)
				return "Active plot item has no data";

			if (!(data.XColumn is Altaxo.Data.INumericColumn) || !(data.YColumn is Altaxo.Data.INumericColumn))
				return "X-Y values of plot data are not both numeric";

			Altaxo.Data.INumericColumn xcol = (Altaxo.Data.INumericColumn)data.XColumn;
			Altaxo.Data.INumericColumn ycol = (Altaxo.Data.INumericColumn)data.YColumn;

			int maxRowIndex = data.GetMaximumRowIndexFromDataColumns();

			foreach (int i in data.DataRowSelection.GetSelectedRowIndicesFromTo(0, maxRowIndex, data.DataTable?.DataColumns, maxRowIndex))
			{
				double x = xcol[i];
				double y = ycol[i];

				if (double.IsNaN(x) || double.IsNaN(y))
					continue;

				xlist.Add(x);
				ylist.Add(y);
			}

			xarr = xlist.ToArray();
			yarr = ylist.ToArray();
			return null;
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:55,代码来源:PolynomialFitting.cs

示例2: GetActivePlotPoints

    /// <summary>
    /// Retrieves the data points of the current active plot.
    /// </summary>
    /// <param name="ctrl">The graph controller which controls the graph from which the points are to retrieve.</param>
    /// <param name="xarr">The array of the data point's x values.</param>
    /// <param name="yarr">The array of the data point's y values.</param>
    /// <param name="nPlotPoints">The number of plot points (may be smaller than the length of x and y arrays.</param>
    /// <returns>Null if all is ok, or error message if not.</returns>
    public static string GetActivePlotPoints(Altaxo.Graph.GUI.GraphController ctrl, ref double[]xarr, ref double[] yarr, out int nPlotPoints)
    {
      nPlotPoints=0;

      ctrl.EnsureValidityOfCurrentLayerNumber();
      ctrl.EnsureValidityOfCurrentPlotNumber();

      IGPlotItem plotItem = ctrl.ActiveLayer.PlotItems.Flattened[ctrl.CurrentPlotNumber];

      XYColumnPlotItem xyPlotItem = plotItem as XYColumnPlotItem;

      if(xyPlotItem==null)
        return "No active plot!";
      
      XYColumnPlotData data = xyPlotItem.XYColumnPlotData;
      if(data==null) 
        return "Active plot item has no data";

      if(!(data.XColumn is Altaxo.Data.INumericColumn) || !(data.YColumn is Altaxo.Data.INumericColumn))
        return "X-Y values of plot data are not both numeric";

      Altaxo.Data.INumericColumn xcol = (Altaxo.Data.INumericColumn)data.XColumn;
      Altaxo.Data.INumericColumn ycol = (Altaxo.Data.INumericColumn)data.YColumn;

      int n = data.PlottablePoints;
      if(null==xarr || xarr.Length<n)
        xarr = new double[n];
      if(null==yarr || yarr.Length<n)
        yarr = new double[n];

      int end = data.PlotRangeEnd;

      int j=0;
      for(int i=data.PlotRangeStart;i<end && j<n;i++)
      {
        double x = xcol[i];
        double y = ycol[i];

        if(double.IsNaN(x) || double.IsNaN(y))
          continue;
        
        xarr[j] = x;
        yarr[j] = y;
        ++j;
      }
      nPlotPoints = j;
      return null;
    }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:56,代码来源:PolynomialFitting.cs

示例3: Run

    public override void Run(Altaxo.Graph.GUI.GraphController ctrl)
    {
      FunctionEvaluationScript script = null; // 

      if(script==null)
        script = new FunctionEvaluationScript();

      object[] args = new object[]{script,new ScriptExecutionHandler(this.EhScriptExecution)};
      if(Current.Gui.ShowDialog(args, "Function script"))
      {
        ctrl.EnsureValidityOfCurrentLayerNumber();

        script = (FunctionEvaluationScript)args[0];
        XYFunctionPlotItem functItem = new XYFunctionPlotItem(new XYFunctionPlotData(script),new G2DPlotStyleCollection(LineScatterPlotStyleKind.Line));
        ctrl.Doc.Layers[ctrl.CurrentLayerNumber].PlotItems.Add(functItem);
      }
    }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:17,代码来源:GraphCommands.cs


注:本文中的Altaxo.EnsureValidityOfCurrentLayerNumber方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。