/// <summary> /// Gets the raw data of the specified type from this measurement. /// </summary> /// <param name="arrayType">The data type of the array.</param> /// <returns></returns> /// <exception cref="System.ArgumentException">This SimpleMeasurement does not contain data of the specified array type</exception> public double[] GetRawData(DataArrayType arrayType) { if (!AvailableDataTypes.Contains(arrayType)) { throw new ArgumentException("This SimpleMeasurement does not contain data of the specified array type"); } DataArray[] dataArrays = Measurement.DataSet.GetDataArrays().Where(a => a.ArrayType == (int)arrayType).ToArray(); return(dataArrays[0].GetValues()); }
public ExportViewModel(ModelsEx models, string extension, GliFormat preferredFormat, string filename, bool is3D, DefaultStatistics stats) { this.models = models; this.extension = extension; this.filename = filename; this.is3D = is3D; this.usedFormat = models.Export.Formats.First(fmt => fmt.Extension == extension); models.Display.IsExporting = true; Quality = models.Settings.LastQuality; // init layers for (var i = 0; i < models.Images.NumLayers; ++i) { AvailableLayers.Add(new ListItemViewModel <int> { Cargo = i, Name = "Layer " + i }); } selectedLayer = AvailableLayers[models.Export.Layer]; Debug.Assert(selectedLayer.Cargo == models.Export.Layer); // init mipmaps for (var i = 0; i < models.Images.NumMipmaps; ++i) { AvailableMipmaps.Add(new ListItemViewModel <int> { Cargo = i, Name = "Mipmap " + i }); } selectedMipmap = AvailableMipmaps[models.Export.Mipmap]; Debug.Assert(selectedMipmap.Cargo == models.Export.Mipmap); // all layer option for ktx and dds if (models.Images.NumLayers > 1 && (extension == "ktx" || extension == "dds")) { AvailableLayers.Add(new ListItemViewModel <int> { Cargo = -1, Name = "All Layer" }); selectedLayer = AvailableLayers.Last(); models.Export.Layer = selectedLayer.Cargo; } // all mipmaps option for ktx and dds if (models.Images.NumMipmaps > 1 && (extension == "ktx" || extension == "dds")) { AvailableMipmaps.Add(new ListItemViewModel <int> { Cargo = -1, Name = "All Mipmaps" }); selectedMipmap = AvailableMipmaps.Last(); models.Export.Mipmap = selectedMipmap.Cargo; } // init available pixel data types var usedPixelTypes = new SortedSet <PixelDataType>(); foreach (var format in usedFormat.Formats) { // exclude some formats for 3d export if (is3D && format.IsExcludedFrom3DExport()) { continue; } allFormats.Add(new ListItemViewModel <GliFormat> { Cargo = format, Name = format.ToString(), ToolTip = format.GetDescription() }); formatRatings.Add(stats.GetFormatRating(format, preferredFormat)); usedPixelTypes.Add(format.GetDataType()); } if (usedPixelTypes.Count > 1) { AvailableDataTypes.Add(new ListItemViewModel <PixelDataType> { Cargo = PixelDataType.Undefined, Name = "All" }); } var preferredPixelType = preferredFormat.GetDataType(); foreach (var usedPixelType in usedPixelTypes) { AvailableDataTypes.Add(new ListItemViewModel <PixelDataType> { Cargo = usedPixelType, Name = usedPixelType.ToString(), ToolTip = usedPixelType.GetDescription() }); if (usedPixelType == preferredPixelType) { SelectedDataType = AvailableDataTypes.Last(); } } if (SelectedDataType == null) { SelectedDataType = AvailableDataTypes[0]; } // assert that those were were set by SelectedDataType Debug.Assert(AvailableFormats != null); Debug.Assert(SelectedFormat != null); // enable quality if (extension == "jpg") { hasQualityValue = true; nonSrgbExportWarnings = true; } else if (extension == "bmp") { nonSrgbExportWarnings = true; } else { SetKtxDdsQuality(); } models.Export.PropertyChanged += ExportOnPropertyChanged; if (models.Export.CropEndX == 0 && models.Export.CropEndY == 0 && models.Export.CropEndZ == 0) { // assume cropping was not set SetMaxCropping(); } }
/// <summary> /// Add a new SimpleCurve to the measurement with the specified X and Y-Axis data types. /// </summary> /// <param name="xAxisArrayType">Data type of the x axis.</param> /// <param name="yAxisArrayType">Data type of the y axis.</param> /// <param name="title">The title of the SimpleCurve.</param> /// <param name="silent">if set to <c>true</c> [silent] the SimpleCurveAdded even is not raised.</param> /// <returns></returns> /// <exception cref="System.ArgumentException"> /// This SimpleMeasurement does not contain the specified X-Axis array type /// or /// This SimpleMeasurement does not contain the specified Y-Axis array type /// </exception> public List <SimpleCurve> NewSimpleCurve(DataArrayType xAxisArrayType, DataArrayType yAxisArrayType, string title = "", bool silent = false) { if (!AvailableDataTypes.Contains(xAxisArrayType)) { throw new ArgumentException("This SimpleMeasurement does not contain the specified X-Axis array type"); } if (!AvailableDataTypes.Contains(yAxisArrayType)) { throw new ArgumentException("This SimpleMeasurement does not contain the specified Y-Axis array type"); } List <SimpleCurve> simpleCurves = new List <SimpleCurve>(); DataArray[] xDataArrays = Measurement.DataSet.GetDataArrays().Where(a => a.ArrayType == (int)xAxisArrayType).ToArray(); DataArray[] yDataArrays = Measurement.DataSet.GetDataArrays().Where(a => a.ArrayType == (int)yAxisArrayType).ToArray(); if (xDataArrays.Length > 1 && xDataArrays.Length == yDataArrays.Length) { for (int i = 0; i < xDataArrays.Length; i++) { Curve c = new Curve(xDataArrays[i], yDataArrays[i], $"{xDataArrays[i].Description}:{title}", Measurement.DataSet.IsFinished); if (Measurement.DataSet.IsFinished) { c.Finish(); } simpleCurves.Add(new SimpleCurve(c, this)); } } else if (xDataArrays.Length > 1 && yDataArrays.Length == 1) { for (int i = 0; i < xDataArrays.Length; i++) { Curve c = new Curve(xDataArrays[i], yDataArrays[0], $"{xDataArrays[i].Description}:{title}", Measurement.DataSet.IsFinished); if (Measurement.DataSet.IsFinished) { c.Finish(); } simpleCurves.Add(new SimpleCurve(c, this)); } } else if (yDataArrays.Length > 1 && xDataArrays.Length == 1) { for (int i = 0; i < yDataArrays.Length; i++) { Curve c = new Curve(xDataArrays[0], yDataArrays[i], $"{yDataArrays[i].Description}:{title}", Measurement.DataSet.IsFinished); if (Measurement.DataSet.IsFinished) { c.Finish(); } simpleCurves.Add(new SimpleCurve(c, this)); } } else { Curve c = new Curve(xDataArrays[0], yDataArrays[0], title, Measurement.DataSet.IsFinished); if (Measurement.DataSet.IsFinished) { c.Finish(); } simpleCurves.Add(new SimpleCurve(c, this)); } AddSimpleCurves(simpleCurves, silent); return(simpleCurves); }