Exemple #1
0
        private void EhCurvePointsCopyLogicalTriggered()
        {
            var layer = Altaxo.Main.AbsoluteDocumentPath.GetRootNodeImplementing <Altaxo.Graph.Gdi.XYPlotLayer>(_doc);

            if (null == layer)
            {
                Current.Gui.ErrorMessageBox("Could not find a parent X-Y layer. Thus, the calculation of logical coordinates is not possible!");
                return;
            }

            var cachedTransformation = _doc.TransformationFromHereToParent(layer);
            var points = _view.CurvePoints;

            var xcol = new Altaxo.Data.DoubleColumn();
            var ycol = new Altaxo.Data.DoubleColumn();

            for (int i = 0; i < points.Count; i++)
            {
                var pt = cachedTransformation.TransformPoint(points[i]);
                if (layer.CoordinateSystem.LayerToLogicalCoordinates(pt.X, pt.Y, out var r))
                {
                    var x = r.RX;
                    var y = r.RY;
                    xcol[i] = x;
                    ycol[i] = y;
                }
                else
                {
                    xcol[i] = ycol[i] = double.NaN;
                }
            }

            PutXYColumnsToClipboard(xcol, ycol);
        }
        private void WriteBasicYData(bool bWriteEndElement)
        {
            Altaxo.Data.DoubleColumn col = null;
            string colname;

            _writer.WriteStartElement("YData");

            colname = WorksheetAnalysis.GetYMean_ColumnName();
            col     = _table.DataColumns.TryGetColumn(colname) as Altaxo.Data.DoubleColumn;
            if (null == col)
            {
                NotFound(colname);
            }
            WriteVector("YMean", col, _numberOfY);

            colname = WorksheetAnalysis.GetYScale_ColumnName();
            col     = _table.DataColumns.TryGetColumn(colname) as Altaxo.Data.DoubleColumn;
            if (null == col)
            {
                NotFound(colname);
            }
            WriteVector("YScale", col, _numberOfY);

            if (bWriteEndElement)
            {
                _writer.WriteEndElement(); // YData
            }
        }
        public void EhView_CopyParameterNVV()
        {
            System.Windows.Forms.DataObject dao = new System.Windows.Forms.DataObject();
            Altaxo.Data.TextColumn          txt = new Altaxo.Data.TextColumn();
            Altaxo.Data.DoubleColumn        col = new Altaxo.Data.DoubleColumn();
            Altaxo.Data.DoubleColumn        var = new Altaxo.Data.DoubleColumn();

            for (int i = 0; i < _doc.CurrentParameters.Count; i++)
            {
                txt[i] = _doc.CurrentParameters[i].Name;
                col[i] = _doc.CurrentParameters[i].Parameter;
                var[i] = _doc.CurrentParameters[i].Variance;
            }

            Altaxo.Data.DataTable tb = new Altaxo.Data.DataTable();
            tb.DataColumns.Add(txt, "Name", Altaxo.Data.ColumnKind.V, 0);
            tb.DataColumns.Add(col, "Value", Altaxo.Data.ColumnKind.V, 0);
            tb.DataColumns.Add(var, "Variance", Altaxo.Data.ColumnKind.V, 0);
            Altaxo.Worksheet.Commands.EditCommands.WriteAsciiToClipBoardIfDataCellsSelected(
                tb, new Altaxo.Collections.AscendingIntegerCollection(),
                new Altaxo.Collections.AscendingIntegerCollection(),
                new Altaxo.Collections.AscendingIntegerCollection(),
                dao);
            System.Windows.Forms.Clipboard.SetDataObject(dao, true);
        }
        public static void FFT(WorksheetController dg)
        {
            int len = dg.SelectedDataColumns.Count;

            if (len == 0)
            {
                return; // nothing selected
            }
            if (!(dg.DataTable[dg.SelectedDataColumns[0]] is Altaxo.Data.DoubleColumn))
            {
                return;
            }


            // preliminary

            // we simply create a new column, copy the values
            Altaxo.Data.DoubleColumn col = (Altaxo.Data.DoubleColumn)dg.DataTable[dg.SelectedDataColumns[0]];


            double[] arr = col.Array;
            FastHartleyTransform.RealFFT(arr, arr.Length);

            col.Array = arr;
        }
        private void WriteVector(string name, Altaxo.Data.DoubleColumn col, int numberOfData)
        {
            _writer.WriteStartElement(name);

            for (int i = 0; i < numberOfData; i++)
            {
                _writer.WriteElementString("e", System.Xml.XmlConvert.ToString(col[i]));
            }

            _writer.WriteEndElement(); // name
        }
        public static string TwoDimCenteredFFT(Altaxo.AltaxoDocument mainDocument, GUI.WorksheetController dg)
        {
            int rows = dg.Doc.DataColumns.RowCount;
            int cols = dg.Doc.DataColumns.ColumnCount;

            // reserve two arrays (one for real part, which is filled with the table contents)
            // and the imaginary part - which is left zero here)

            double[] rePart;
            double[] imPart;

            string stringresult = TwoDimFFT(mainDocument, dg, out rePart, out imPart);

            if (stringresult != null)
            {
                return(stringresult);
            }

            Altaxo.Data.DataTable table = new Altaxo.Data.DataTable("Fourieramplitude of " + dg.Doc.Name);

            // Fill the Table so that the zero frequency point is in the middle
            // this means for the point order:
            // for even number of points, i.e. 8 points, the frequencies are -3, -2, -1, 0, 1, 2, 3, 4  (the frequency 4 is the nyquist part)
            // for odd number of points, i.e. 9 points, the frequencies are -4, -3, -2, -1, 0, 1, 2, 3, 4 (for odd number of points there is no nyquist part)

            table.Suspend();
            int colsNegative = (cols - 1) / 2;      // number of negative frequency points
            int colsPositive = cols - colsNegative; // number of positive (or null) frequency points
            int rowsNegative = (rows - 1) / 2;
            int rowsPositive = rows - rowsNegative;

            for (int i = 0; i < cols; i++)
            {
                int sc = i < colsNegative ?  i + colsPositive : i - colsNegative;// source column index centered
                Altaxo.Data.DoubleColumn col = new Altaxo.Data.DoubleColumn();
                for (int j = 0; j < rows; j++)
                {
                    int sr = j < rowsNegative ? j + rowsPositive : j - rowsNegative; // source row index centered
                    col[j] = rePart[sc * rows + sr];
                }
                table.DataColumns.Add(col);
            }
            table.Resume();
            mainDocument.DataTableCollection.Add(table);
            // create a new worksheet without any columns
            Current.ProjectService.CreateNewWorksheet(table);

            return(null);
        }
Exemple #7
0
        public static void ImportImage(Altaxo.Data.DataTable table)
        {
            ColorAmplitudeFunction colorfunc;

            System.IO.Stream myStream;
            OpenFileDialog   openFileDialog1 = new OpenFileDialog();

            openFileDialog1.InitialDirectory = "c:\\";
            openFileDialog1.Filter           = "Image files (*.bmp;*.jpg;*.png,*.tif)|*.bmp;*.jpg;*.png,*.tif|All files (*.*)|*.*";
            openFileDialog1.FilterIndex      = 1;
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                if ((myStream = openFileDialog1.OpenFile()) != null)
                {
                    System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(myStream);

                    int sizex = bmp.Width;
                    int sizey = bmp.Height;
                    //if(Format16bppGrayScale==bmp.PixelFormat)

                    colorfunc = new ColorAmplitudeFunction(ColorToBrightness);
                    // add here other function or the result of a dialog box

                    // now add new columns to the worksheet,
                    // the name of the columns should preferabbly simply
                    // the index in x direction

                    table.Suspend();
                    for (int i = 0; i < sizex; i++)
                    {
                        Altaxo.Data.DoubleColumn dblcol = new Altaxo.Data.DoubleColumn();
                        for (int j = sizey - 1; j >= 0; j--)
                        {
                            dblcol[j] = colorfunc(bmp.GetPixel(i, j));
                        }

                        table.DataColumns.Add(dblcol, table.DataColumns.FindUniqueColumnName(i.ToString())); // Spalte hinzufügen
                    } // end for all x coordinaates

                    table.Resume();

                    myStream.Close();
                    myStream = null;
                } // end if myStream was != null
            }
        }
Exemple #8
0
        private static void PutXYColumnsToClipboard(Altaxo.Data.DoubleColumn xcol, Altaxo.Data.DoubleColumn ycol)
        {
            var tb = new Altaxo.Data.DataTable();

            tb.DataColumns.Add(xcol, "XPosition", Altaxo.Data.ColumnKind.V, 0);
            tb.DataColumns.Add(ycol, "YPosition", Altaxo.Data.ColumnKind.V, 0);

            var dao = Current.Gui.GetNewClipboardDataObject();

            Altaxo.Worksheet.Commands.EditCommands.WriteAsciiToClipBoardIfDataCellsSelected(
                tb, new Altaxo.Collections.AscendingIntegerCollection(),
                new Altaxo.Collections.AscendingIntegerCollection(),
                new Altaxo.Collections.AscendingIntegerCollection(),
                dao);
            Current.Gui.SetClipboardDataObject(dao, true);
        }
Exemple #9
0
        private void EhCurvePointsCopyTriggered()
        {
            var points = _view.CurvePoints;

            var dao  = Current.Gui.GetNewClipboardDataObject();
            var xcol = new Altaxo.Data.DoubleColumn();
            var ycol = new Altaxo.Data.DoubleColumn();

            for (int i = 0; i < points.Count; i++)
            {
                xcol[i] = new DimensionfulQuantity(points[i].X, AUL.Point.Instance).AsValueIn(PositionEnvironment.Instance.DefaultUnit);
                ycol[i] = new DimensionfulQuantity(points[i].Y, AUL.Point.Instance).AsValueIn(PositionEnvironment.Instance.DefaultUnit);
            }

            PutXYColumnsToClipboard(xcol, ycol);
        }
Exemple #10
0
        private void EhCurvePointsPasteTriggered()
        {
            Altaxo.Data.DataTable table = Altaxo.Worksheet.Commands.EditCommands.GetTableFromClipboard();
            if (null == table)
            {
                return;
            }
            Altaxo.Data.DoubleColumn xcol = null;
            Altaxo.Data.DoubleColumn ycol = null;
            // Find the first column that contains numeric values
            int i;

            for (i = 0; i < table.DataColumnCount; i++)
            {
                if (table[i] is Altaxo.Data.DoubleColumn)
                {
                    xcol = table[i] as Altaxo.Data.DoubleColumn;
                    break;
                }
            }
            for (i = i + 1; i < table.DataColumnCount; i++)
            {
                if (table[i] is Altaxo.Data.DoubleColumn)
                {
                    ycol = table[i] as Altaxo.Data.DoubleColumn;
                    break;
                }
            }

            if (!(xcol != null && ycol != null))
            {
                return;
            }

            int len  = Math.Min(xcol.Count, ycol.Count);
            var list = new List <PointD2D>();

            for (i = 0; i < len; i++)
            {
                list.Add(new PointD2D(
                             new DimensionfulQuantity(xcol[i], PositionEnvironment.Instance.DefaultUnit).AsValueIn(AUL.Point.Instance),
                             new DimensionfulQuantity(ycol[i], PositionEnvironment.Instance.DefaultUnit).AsValueIn(AUL.Point.Instance)
                             ));
            }

            _view.CurvePoints = list;
        }
Exemple #11
0
        /// <summary>
        /// Asks for a file name of an image file, and imports the image data into a data table.
        /// </summary>
        /// <param name="table">The table to import to.</param>
        public static void ShowImportImageDialog(this DataTable table)
        {
            ColorAmplitudeFunction colorfunc;
            var options = new Altaxo.Gui.OpenFileOptions();

            options.AddFilter("*.bmp;*.jpg;*.png,*.tif", "Image files (*.bmp;*.jpg;*.png,*.tif)");
            options.AddFilter("*.*", "All files (*.*)");
            options.FilterIndex      = 0;
            options.RestoreDirectory = true;

            if (Current.Gui.ShowOpenFileDialog(options))
            {
                using (Stream myStream = new FileStream(options.FileName, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    var bmp = new System.Drawing.Bitmap(myStream);

                    int sizex = bmp.Width;
                    int sizey = bmp.Height;
                    //if(Format16bppGrayScale==bmp.PixelFormat)

                    colorfunc = new ColorAmplitudeFunction(ColorToBrightness);
                    // add here other function or the result of a dialog box

                    // now add new columns to the worksheet,
                    // the name of the columns should preferabbly simply
                    // the index in x direction

                    using (var suspendToken = table.SuspendGetToken())
                    {
                        for (int i = 0; i < sizex; i++)
                        {
                            var dblcol = new Altaxo.Data.DoubleColumn();
                            for (int j = sizey - 1; j >= 0; j--)
                            {
                                dblcol[j] = colorfunc(bmp.GetPixel(i, j));
                            }

                            table.DataColumns.Add(dblcol, table.DataColumns.FindUniqueColumnName(i.ToString())); // Spalte hinzufügen
                        } // end for all x coordinaates

                        suspendToken.Dispose();
                    }
                    myStream.Close();
                } // end using myStream
            }
        }
        public static string TwoDimFFT(Altaxo.AltaxoDocument mainDocument, GUI.WorksheetController dg)
        {
            int rows = dg.Doc.DataColumns.RowCount;
            int cols = dg.Doc.DataColumns.ColumnCount;

            // reserve two arrays (one for real part, which is filled with the table contents)
            // and the imaginary part - which is left zero here)

            double[] rePart;
            double[] imPart;

            string stringresult = TwoDimFFT(mainDocument, dg, out rePart, out imPart);

            if (stringresult != null)
            {
                return(stringresult);
            }

            Altaxo.Data.DataTable table = new Altaxo.Data.DataTable("Fourieramplitude of " + dg.Doc.Name);

            // Fill the Table
            table.Suspend();
            for (int i = 0; i < cols; i++)
            {
                Altaxo.Data.DoubleColumn col = new Altaxo.Data.DoubleColumn();
                for (int j = 0; j < rows; j++)
                {
                    col[j] = rePart[i * rows + j];
                }

                table.DataColumns.Add(col);
            }
            table.Resume();
            mainDocument.DataTableCollection.Add(table);
            // create a new worksheet without any columns
            Current.ProjectService.CreateNewWorksheet(table);

            return(null);
        }
Exemple #13
0
        /// <summary>
        /// This function searches for patterns like aaa=bbb in the provided string. If it finds such a item, it creates a column named aaa
        /// and stores the value bbb at the same position in it as in the text column.
        /// </summary>
        /// <param name="strg">The string where to search for the patterns described above.</param>
        /// <param name="store">The column collection where to store the newly created columns of properties.</param>
        /// <param name="index">The index into the column where to store the property value.</param>
        public static void ExtractPropertiesFromString(string strg, Altaxo.Data.DataColumnCollection store, int index)
        {
            string pat;

            pat = @"(\S+)=(\S+)";

            Regex r = new Regex(pat, RegexOptions.Compiled | RegexOptions.IgnoreCase);

            for (Match m = r.Match(strg); m.Success; m = m.NextMatch())
            {
                string propname  = m.Groups[1].ToString();
                string propvalue = m.Groups[2].ToString();

                // System.Diagnostics.Trace.WriteLine("Found the pair " + propname + " : " + propvalue);

                if (!store.ContainsColumn(propname))
                {
                    Altaxo.Data.DataColumn col;
                    if (Altaxo.Serialization.DateTimeParsing.IsDateTime(propvalue))
                    {
                        col = new Altaxo.Data.DateTimeColumn();
                    }
                    else if (Altaxo.Serialization.NumberConversion.IsNumeric(propvalue))
                    {
                        col = new Altaxo.Data.DoubleColumn();
                    }
                    else
                    {
                        col = new Altaxo.Data.TextColumn();
                    }

                    store.Add(col, propname); // add the column to the collection
                }

                // now the column is present we can store the value in it.
                store[propname][index] = new Altaxo.Data.AltaxoVariant(propvalue);
            }
        }
Exemple #14
0
		// --------------------------------- Unary Complement ----------------------------
		public static Altaxo.Data.DoubleColumn operator ~(Altaxo.Data.DoubleColumn c1)
		{
			int len = c1._count;
			Altaxo.Data.DoubleColumn c3 = new Altaxo.Data.DoubleColumn(len);
			for (int i = 0; i < len; i++)
			{
				c3._data[i] = ~((long)c1._data[i]);
			}
			c3._count = len;
			return c3;
		}
Exemple #15
0
		public override bool vop_ShiftRight_Rev(AltaxoVariant c2, out DataColumn c3)
		{
			if (((AltaxoVariant)c2).IsType(AltaxoVariant.Content.VDouble))
			{
				DoubleColumn c1 = this;
				int len = c1._count;
				Altaxo.Data.DoubleColumn c33 = new Altaxo.Data.DoubleColumn(len);
				long c22 = (long)(double)c2;
				for (int i = 0; i < len; i++)
					c33._data[i] = c22 >> ((int)c1._data[i]);
				c33._count = len;
				c3 = c33;
				return true;
			}
			c3 = null;
			return false;
		}
Exemple #16
0
		// ----------------------- ShiftRight operator -----------------------------------

		public static Altaxo.Data.DoubleColumn operator >>(Altaxo.Data.DoubleColumn c1, int c2)
		{
			int len = c1._count;
			Altaxo.Data.DoubleColumn c3 = new Altaxo.Data.DoubleColumn(len);
			for (int i = 0; i < len; i++)
				c3._data[i] = ((long)c1._data[i]) >> c2;
			c3._count = len;
			return c3;
		}
 public static Altaxo.Data.DoubleColumn Floor(Altaxo.Data.DoubleColumn s)
 {
     return(Altaxo.Data.DoubleColumn.Floor(s));
 }
    public static void ImportImage(Altaxo.Data.DataTable table)
    {
      ColorAmplitudeFunction colorfunc;
      System.IO.Stream myStream;
      OpenFileDialog openFileDialog1 = new OpenFileDialog();

      openFileDialog1.InitialDirectory = "c:\\" ;
      openFileDialog1.Filter = "Image files (*.bmp;*.jpg;*.png,*.tif)|*.bmp;*.jpg;*.png,*.tif|All files (*.*)|*.*";
      openFileDialog1.FilterIndex = 1 ;
      openFileDialog1.RestoreDirectory = true ;

      if(openFileDialog1.ShowDialog() == DialogResult.OK)
      {
        if((myStream = openFileDialog1.OpenFile())!= null)
        {
          System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(myStream);

          int sizex = bmp.Width;
          int sizey = bmp.Height;
          //if(Format16bppGrayScale==bmp.PixelFormat)
          
          colorfunc = new ColorAmplitudeFunction(ColorToBrightness);
          // add here other function or the result of a dialog box
  
          // now add new columns to the worksheet, 
          // the name of the columns should preferabbly simply
          // the index in x direction

          table.Suspend();
          for(int i=0;i<sizex;i++)
          {
            Altaxo.Data.DoubleColumn dblcol = new Altaxo.Data.DoubleColumn();
            for(int j=sizey-1;j>=0;j--)
              dblcol[j] = colorfunc(bmp.GetPixel(i,j));

            table.DataColumns.Add(dblcol,table.DataColumns.FindUniqueColumnName(i.ToString())); // Spalte hinzufügen
          } // end for all x coordinaates

          table.Resume();

          myStream.Close();
          myStream=null;
        } // end if myStream was != null
      } 
    }
Exemple #19
0
		// -------------------------- operator % ----------------------------------------------
		public static Altaxo.Data.DoubleColumn operator %(Altaxo.Data.DoubleColumn c1, Altaxo.Data.DoubleColumn c2)
		{
			int len = c1._count < c2._count ? c1._count : c2._count;
			Altaxo.Data.DoubleColumn c3 = new Altaxo.Data.DoubleColumn(len);
			for (int i = 0; i < len; i++)
			{
				c3._data[i] = c1._data[i] % c2._data[i];
			}
			c3._count = len;
			return c3;
		}
Exemple #20
0
		public static Altaxo.Data.DoubleColumn Tanh(Altaxo.Data.DoubleColumn c1)
		{
			int len = c1._count;
			Altaxo.Data.DoubleColumn c3 = new Altaxo.Data.DoubleColumn(len);
			for (int i = 0; i < len; i++)
			{
				c3._data[i] = System.Math.Tanh(c1._data[i]);
			}
			c3._count = len;
			return c3;
		}
 public static Altaxo.Data.DoubleColumn Tanh(Altaxo.Data.DoubleColumn s)
 {
     return(Altaxo.Data.DoubleColumn.Tanh(s));
 }
 public static Altaxo.Data.DoubleColumn Sqrt(Altaxo.Data.DoubleColumn s)
 {
     return(Altaxo.Data.DoubleColumn.Sqrt(s));
 }
 public static Altaxo.Data.DoubleColumn Round(double x, Altaxo.Data.DoubleColumn i)
 {
     return(Altaxo.Data.DoubleColumn.Round(x, i));
 }
 public static Altaxo.Data.DoubleColumn Round(Altaxo.Data.DoubleColumn x, int i)
 {
     return(Altaxo.Data.DoubleColumn.Round(x, i));
 }
 public static Altaxo.Data.DoubleColumn Pow(double x, Altaxo.Data.DoubleColumn y)
 {
     return(Altaxo.Data.DoubleColumn.Pow(x, y));
 }
 public static Altaxo.Data.DoubleColumn Pow(Altaxo.Data.DoubleColumn x, double y)
 {
     return(Altaxo.Data.DoubleColumn.Pow(x, y));
 }
 public static Altaxo.Data.DoubleColumn Min(double x, Altaxo.Data.DoubleColumn y)
 {
     return(Altaxo.Data.DoubleColumn.Min(x, y));
 }
Exemple #28
0
		public static Altaxo.Data.DoubleColumn Min(Altaxo.Data.DoubleColumn c1, Altaxo.Data.DoubleColumn c2)
		{
			int len = c1._count < c2._count ? c1._count : c2._count;
			Altaxo.Data.DoubleColumn c3 = new Altaxo.Data.DoubleColumn(len);
			for (int i = 0; i < len; i++)
			{
				c3._data[i] = System.Math.Min(c1._data[i], c2._data[i]);
			}
			c3._count = len;
			return c3;
		}
Exemple #29
0
		public static Altaxo.Data.DoubleColumn Pow(Altaxo.Data.DoubleColumn c1, double c2)
		{
			int len = c1._count;
			Altaxo.Data.DoubleColumn c3 = new Altaxo.Data.DoubleColumn(len);
			for (int i = 0; i < len; i++)
			{
				c3._data[i] = System.Math.Pow(c1._data[i], c2);
			}
			c3._count = len;
			return c3;
		}
 public static Altaxo.Data.DoubleColumn Log(Altaxo.Data.DoubleColumn s)
 {
     return(Altaxo.Data.DoubleColumn.Log(s));
 }
Exemple #31
0
		public static Altaxo.Data.DoubleColumn Subtraction(DateTime c1, Altaxo.Data.DateTimeColumn c2)
		{
			int len = c2.Count;
			Altaxo.Data.DoubleColumn c3 = new Altaxo.Data.DoubleColumn(len);
			for (int i = 0; i < len; i++)
			{
				c3._data[i] = (c1 - c2.GetValueDirect(i)).TotalSeconds;
			}

			c3._count = len;

			return c3;
		}
 public static Altaxo.Data.DoubleColumn IEEERemainder(Altaxo.Data.DoubleColumn c1, double c2)
 {
   int len = c1.m_Count;
   Altaxo.Data.DoubleColumn c3 = new Altaxo.Data.DoubleColumn(len);
   for(int i=0;i<len;i++)
   {
     c3.m_Array[i] = System.Math.IEEERemainder(c1.m_Array[i],c2);
   }
   c3.m_Count=len;
   return c3;  
 }
Exemple #33
0
		/// <summary>
		/// Asks for a file name of an image file, and imports the image data into a data table.
		/// </summary>
		/// <param name="table">The table to import to.</param>
		public static void ShowImportImageDialog(this DataTable table)
		{
			ColorAmplitudeFunction colorfunc;
			var options = new Altaxo.Gui.OpenFileOptions();
			options.AddFilter("*.bmp;*.jpg;*.png,*.tif", "Image files (*.bmp;*.jpg;*.png,*.tif)");
			options.AddFilter("*.*", "All files (*.*)");
			options.FilterIndex = 0;
			options.RestoreDirectory = true;

			if (Current.Gui.ShowOpenFileDialog(options))
			{
				using (Stream myStream = new FileStream(options.FileName, FileMode.Open, FileAccess.Read, FileShare.Read))
				{
					System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(myStream);

					int sizex = bmp.Width;
					int sizey = bmp.Height;
					//if(Format16bppGrayScale==bmp.PixelFormat)

					colorfunc = new ColorAmplitudeFunction(ColorToBrightness);
					// add here other function or the result of a dialog box

					// now add new columns to the worksheet,
					// the name of the columns should preferabbly simply
					// the index in x direction

					using (var suspendToken = table.SuspendGetToken())
					{
						for (int i = 0; i < sizex; i++)
						{
							Altaxo.Data.DoubleColumn dblcol = new Altaxo.Data.DoubleColumn();
							for (int j = sizey - 1; j >= 0; j--)
								dblcol[j] = colorfunc(bmp.GetPixel(i, j));

							table.DataColumns.Add(dblcol, table.DataColumns.FindUniqueColumnName(i.ToString())); // Spalte hinzufügen
						} // end for all x coordinaates

						suspendToken.Dispose();
					}
					myStream.Close();
				} // end using myStream
			}
		}
 public static Altaxo.Data.DoubleColumn Max(Altaxo.Data.DoubleColumn c1, Altaxo.Data.DoubleColumn c2)
 {
   int len = c1.m_Count<c2.m_Count ? c1.m_Count : c2.m_Count;
   Altaxo.Data.DoubleColumn c3 = new Altaxo.Data.DoubleColumn(len);
   for(int i=0;i<len;i++)
   {
     c3.m_Array[i] = System.Math.Max(c1.m_Array[i],c2.m_Array[i]);
   }
   c3.m_Count=len;
   return c3;  
 }
 public static Altaxo.Data.DoubleColumn Max(Altaxo.Data.DoubleColumn x, double y)
 {
     return(Altaxo.Data.DoubleColumn.Max(x, y));
 }
 public static Altaxo.Data.DoubleColumn Pow(double c1, Altaxo.Data.DoubleColumn c2)
 {
   int len = c2.m_Count;
   Altaxo.Data.DoubleColumn c3 = new Altaxo.Data.DoubleColumn(len);
   for(int i=0;i<len;i++)
   {
     c3.m_Array[i] = System.Math.Pow(c1,c2.m_Array[i]);
   }
   c3.m_Count=len;
   return c3;  
 }
Exemple #37
0
		public static Altaxo.Data.DoubleColumn operator ^(double c2, Altaxo.Data.DoubleColumn c1)
		{
			int len = c1._count;
			Altaxo.Data.DoubleColumn c3 = new Altaxo.Data.DoubleColumn(len);
			long c22 = (long)c2;
			for (int i = 0; i < len; i++)
				c3._data[i] = c22 ^ ((long)c1._data[i]);
			c3._count = len;
			return c3;
		}
 public static Altaxo.Data.DoubleColumn Round(Altaxo.Data.DoubleColumn c1, int c2)
 {
   int len = c1.m_Count;
   Altaxo.Data.DoubleColumn c3 = new Altaxo.Data.DoubleColumn(len);
   for(int i=0;i<len;i++)
   {
     c3.m_Array[i] = System.Math.Round(c1.m_Array[i],c2);
   }
   c3.m_Count=len;
   return c3;  
 }
Exemple #39
0
		public override bool vop_ShiftRight_Rev(DataColumn c2, out DataColumn c3)
		{
			if (c2 is Altaxo.Data.DoubleColumn)
			{
				Altaxo.Data.DoubleColumn c1 = this;
				DoubleColumn c22 = (DoubleColumn)c2;
				int len = c1.Count < c2.Count ? c1.Count : c2.Count;
				Altaxo.Data.DoubleColumn c33 = new Altaxo.Data.DoubleColumn(len);
				for (int i = 0; i < len; i++)
				{
					c33._data[i] = ((long)c22._data[i]) >> ((int)c1._data[i]);
				}
				c33._count = len;
				c3 = c33;
				return true;
			}
			c3 = null;
			return false;
		}
 public static Altaxo.Data.DoubleColumn Sqrt(Altaxo.Data.DoubleColumn c1)
 {
   int len=c1.m_Count;
   Altaxo.Data.DoubleColumn c3 = new Altaxo.Data.DoubleColumn(len);
   for(int i=0;i<len;i++)
   {
     c3.m_Array[i] = System.Math.Sqrt(c1.m_Array[i]);
   }
   c3.m_Count=len;
   return c3;
 } 
Exemple #41
0
		public static Altaxo.Data.DoubleColumn operator >=(double c2, Altaxo.Data.DoubleColumn c1)
		{
			int len = c1._count;
			Altaxo.Data.DoubleColumn c3 = new Altaxo.Data.DoubleColumn(len);
			for (int i = 0; i < len; i++)
				c3._data[i] = (c2 >= c1._data[i]) ? 1 : 0;
			c3._count = len;
			return c3;
		}
    public static Altaxo.Data.DoubleColumn Subtraction(Altaxo.Data.DateTimeColumn c1, DateTime c2)
    {
      int len = c1.Count;
      Altaxo.Data.DoubleColumn c3 = new Altaxo.Data.DoubleColumn(len);
      for (int i = 0; i < len; i++)
      {
        c3.m_Array[i] = (c1.GetValueDirect(i) - c2).TotalSeconds;
      }

      c3.m_Count = len;

      return c3;
    }
Exemple #43
0
		public override bool vop_Decrement(out DataColumn c3)
		{
			int len = this._count;
			Altaxo.Data.DoubleColumn c33 = new Altaxo.Data.DoubleColumn(len);
			for (int i = 0; i < len; i++)
			{
				c33._data[i] = this._data[i] - 1;
			}
			c33._count = len;
			c3 = c33;
			return true;
		}
 public static Altaxo.Data.DoubleColumn operator *(double c2, Altaxo.Data.DoubleColumn c1)
 {
   int len = c1.m_Count;
   Altaxo.Data.DoubleColumn c3 = new Altaxo.Data.DoubleColumn(len);
   for(int i=0;i<len;i++)
     c3.m_Array[i] = c1.m_Array[i] * c2;
   c3.m_Count = len;
   return c3;
 }
Exemple #45
0
		public static Altaxo.Data.DoubleColumn Pow9(Altaxo.Data.DoubleColumn c1)
		{
			int len = c1._count;
			Altaxo.Data.DoubleColumn c3 = new Altaxo.Data.DoubleColumn(len);
			for (int i = 0; i < len; i++)
			{
				c3._data[i] = Altaxo.Calc.RMath.Pow9(c1._data[i]);
			}
			c3._count = len;
			return c3;
		}
 public static Altaxo.Data.DoubleColumn operator %(Altaxo.Data.DoubleColumn c1, double c2)
 {
   int len = c1.m_Count;
   Altaxo.Data.DoubleColumn c3 = new Altaxo.Data.DoubleColumn(len);
   for(int i=0;i<len;i++)
   {
     c3.m_Array[i] = c1.m_Array[i] % c2;
   }
   c3.m_Count=len;
   return c3;  
 }
Exemple #47
0
		public static Altaxo.Data.DoubleColumn Round(double c1, Altaxo.Data.DoubleColumn c2)
		{
			int len = c2._count;
			Altaxo.Data.DoubleColumn c3 = new Altaxo.Data.DoubleColumn(len);
			for (int i = 0; i < len; i++)
			{
				c3._data[i] = System.Math.Round(c1, (int)c2._data[i]);
			}
			c3._count = len;
			return c3;
		}
 public static Altaxo.Data.DoubleColumn Ceiling(Altaxo.Data.DoubleColumn s)
 {
     return(Altaxo.Data.DoubleColumn.Ceiling(s));
 }
Exemple #49
0
		public static Altaxo.Data.DoubleColumn Map(Func<double, double, double> function, double c1, Altaxo.Data.DoubleColumn c2)
		{
			int len = c2._count;
			Altaxo.Data.DoubleColumn c3 = new Altaxo.Data.DoubleColumn(len);
			for (int i = 0; i < len; i++)
			{
				c3._data[i] = function(c1, c2._data[i]);
			}
			c3._count = len;
			return c3;
		}
 public static Altaxo.Data.DoubleColumn operator |(double c2, Altaxo.Data.DoubleColumn c1)
 {
   int len = c1.m_Count;
   Altaxo.Data.DoubleColumn c3 = new Altaxo.Data.DoubleColumn(len);
   long c22 = (long)c2;
   for(int i=0;i<len;i++)
     c3.m_Array[i] = c22 | ((long)c1.m_Array[i]);
   c3.m_Count = len;
   return c3;
 }
Exemple #51
0
		public static Altaxo.Data.DoubleColumn operator *(Altaxo.Data.DoubleColumn c1, double c2)
		{
			int len = c1._count;
			Altaxo.Data.DoubleColumn c3 = new Altaxo.Data.DoubleColumn(len);
			for (int i = 0; i < len; i++)
				c3._data[i] = c1._data[i] * c2;
			c3._count = len;
			return c3;
		}
 public static Altaxo.Data.DoubleColumn Exp(Altaxo.Data.DoubleColumn s)
 {
     return(Altaxo.Data.DoubleColumn.Exp(s));
 }
Exemple #53
0
		public static Altaxo.Data.DoubleColumn operator %(double c2, Altaxo.Data.DoubleColumn c1)
		{
			int len = c1._count;
			Altaxo.Data.DoubleColumn c3 = new Altaxo.Data.DoubleColumn(len);
			for (int i = 0; i < len; i++)
			{
				c3._data[i] = c2 % c1._data[i];
			}
			c3._count = len;
			return c3;
		}
 public static Altaxo.Data.DoubleColumn Atan2(double y, Altaxo.Data.DoubleColumn x)
 {
     return(Altaxo.Data.DoubleColumn.Atan2(y, x));
 }
    public void EhView_CopyParameterNVV()
    {
      System.Windows.Forms.DataObject dao = new System.Windows.Forms.DataObject();
      Altaxo.Data.TextColumn txt = new Altaxo.Data.TextColumn();
      Altaxo.Data.DoubleColumn col = new Altaxo.Data.DoubleColumn();
      Altaxo.Data.DoubleColumn var = new Altaxo.Data.DoubleColumn();

      for (int i = 0; i < _doc.CurrentParameters.Count; i++)
      {
        txt[i] = _doc.CurrentParameters[i].Name;
        col[i] = _doc.CurrentParameters[i].Parameter;
        var[i] = _doc.CurrentParameters[i].Variance;
      }

      Altaxo.Data.DataTable tb = new Altaxo.Data.DataTable();
      tb.DataColumns.Add(txt, "Name", Altaxo.Data.ColumnKind.V, 0);
      tb.DataColumns.Add(col, "Value", Altaxo.Data.ColumnKind.V, 0);
      tb.DataColumns.Add(var, "Variance", Altaxo.Data.ColumnKind.V, 0);
      Altaxo.Worksheet.Commands.EditCommands.WriteAsciiToClipBoardIfDataCellsSelected(
        tb, new Altaxo.Collections.AscendingIntegerCollection(),
        new Altaxo.Collections.AscendingIntegerCollection(),
        new Altaxo.Collections.AscendingIntegerCollection(),
        dao);
      System.Windows.Forms.Clipboard.SetDataObject(dao, true);
    }
 public static Altaxo.Data.DoubleColumn IEEERemainder(double x, Altaxo.Data.DoubleColumn y)
 {
     return(Altaxo.Data.DoubleColumn.IEEERemainder(x, y));
 }
Exemple #57
0
        private void EhCurvePointsPasteLogicalTriggered()
        {
            var layer = Altaxo.Main.AbsoluteDocumentPath.GetRootNodeImplementing <Altaxo.Graph.Gdi.XYPlotLayer>(_doc);

            if (null == layer)
            {
                Current.Gui.ErrorMessageBox("Could not find a parent X-Y layer. Thus, the calculation of physical coordinates is not possible!");
                return;
            }

            var cachedTransformation = _doc.TransformationFromHereToParent(layer);

            Altaxo.Data.DataTable table = Altaxo.Worksheet.Commands.EditCommands.GetTableFromClipboard();
            if (null == table)
            {
                return;
            }
            Altaxo.Data.DoubleColumn xcol = null;
            Altaxo.Data.DoubleColumn ycol = null;
            // Find the first column that contains numeric values
            int i;

            for (i = 0; i < table.DataColumnCount; i++)
            {
                if (table[i] is Altaxo.Data.DoubleColumn)
                {
                    xcol = table[i] as Altaxo.Data.DoubleColumn;
                    break;
                }
            }
            for (i = i + 1; i < table.DataColumnCount; i++)
            {
                if (table[i] is Altaxo.Data.DoubleColumn)
                {
                    ycol = table[i] as Altaxo.Data.DoubleColumn;
                    break;
                }
            }

            if (!(xcol != null && ycol != null))
            {
                return;
            }

            int len  = Math.Min(xcol.Count, ycol.Count);
            var list = new List <PointD2D>();

            for (i = 0; i < len; i++)
            {
                // calculate position
                var lx = xcol[i];
                var ly = ycol[i];

                if (layer.CoordinateSystem.LogicalToLayerCoordinates(new Logical3D(lx, ly), out var xpos, out var ypos))
                {
                    var pt = cachedTransformation.InverseTransformPoint(new PointD2D(xpos, ypos));
                    list.Add(new PointD2D(
                                 new DimensionfulQuantity(pt.X, PositionEnvironment.Instance.DefaultUnit).AsValueIn(AUL.Point.Instance),
                                 new DimensionfulQuantity(pt.Y, PositionEnvironment.Instance.DefaultUnit).AsValueIn(AUL.Point.Instance)
                                 ));
                }
            }

            _view.CurvePoints = list;
        }
 public static Altaxo.Data.DoubleColumn Log(double s, Altaxo.Data.DoubleColumn bas)
 {
     return(Altaxo.Data.DoubleColumn.Log(s, bas));
 }
 // ----------------------- OR operator -----------------------------------
 public static Altaxo.Data.DoubleColumn operator |(Altaxo.Data.DoubleColumn c1, Altaxo.Data.DoubleColumn c2)
 {
   int len = c1.m_Count<c2.m_Count ? c1.m_Count : c2.m_Count;
   Altaxo.Data.DoubleColumn c3 = new Altaxo.Data.DoubleColumn(len);
   for(int i=0;i<len;i++)
   {
     c3.m_Array[i] = ((long)c1.m_Array[i]) | ((long)c2.m_Array[i]);
   }
   c3.m_Count=len;
   return c3;  
 }
 public static Altaxo.Data.DoubleColumn Cosh(Altaxo.Data.DoubleColumn s)
 {
     return(Altaxo.Data.DoubleColumn.Cosh(s));
 }