initial commit

This commit is contained in:
Michael Becker 2020-08-28 16:33:33 -04:00
parent 57664bd409
commit cd05d0ee03
No known key found for this signature in database
GPG Key ID: 506F54899E2BFED7
16 changed files with 997 additions and 0 deletions

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<UniversalEditor Version="4.0">
<Associations>
<Association>
<Filters>
<Filter Title="Simple Data Format">
<FileNameFilters>
<FileNameFilter>*.sdf</FileNameFilter>
</FileNameFilters>
</Filter>
</Filters>
<ObjectModels>
<ObjectModel TypeName="UniversalEditor.Plugins.Scientific.ObjectModels.DataSetCollection.DataSetCollectionObjectModel" />
</ObjectModels>
<DataFormats>
<DataFormat TypeName="UniversalEditor.Plugins.Scientific.DataFormats.SDF.SDFDataFormat" />
</DataFormats>
</Association>
</Associations>
</UniversalEditor>

View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.2 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkWindow">
<property name="can_focus">False</property>
<child type="titlebar">
<placeholder/>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="tv">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child internal-child="selection">
<object class="GtkTreeSelection"/>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View File

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D46D9232-F585-4552-B3CA-6B0F284B746A}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>UniversalEditor.Extensions.Scientific</RootNamespace>
<AssemblyName>UniversalEditor.Extensions.Scientific</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\..\Production.snk</AssemblyOriginatorKeyFile>
<ReleaseVersion>4.0.2019.12</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Output\Debug\Extensions</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Output\Release\Extensions</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Content Include="Associations\DataSetCollection\SDFDataFormat.uexml" />
<Content Include="Editors\Scientific\DataSet\DataSetEditor.glade" />
</ItemGroup>
<ItemGroup>
<Folder Include="Associations\" />
<Folder Include="Editors\" />
<Folder Include="Editors\Scientific\" />
</ItemGroup>
<Import Project="..\..\UniversalEditor.Compiler.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,131 @@
//
// DataSetEditor.cs
//
// Author:
// Michael Becker <alcexhim@gmail.com>
//
// Copyright (c) 2020 Mike Becker's Software
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Collections.Generic;
using MBS.Framework.UserInterface;
using MBS.Framework.UserInterface.Controls.ListView;
using UniversalEditor.Plugins.Scientific.ObjectModels.DataSetCollection;
using UniversalEditor.UserInterface;
namespace UniversalEditor.Plugins.Scientific.UserInterface.Editors.DataSetCollection
{
[ContainerLayout("~/Editors/Scientific/DataSet/DataSetEditor.glade")]
public class DataSetCollectionEditor : Editor
{
private ListViewControl tv = null;
private static EditorReference _er = null;
public override EditorReference MakeReference()
{
if (_er == null)
{
_er = base.MakeReference();
_er.SupportedObjectModels.Add(typeof(DataSetCollectionObjectModel));
}
return _er;
}
public override void UpdateSelections()
{
}
protected override Selection CreateSelectionInternal(object content)
{
return null;
}
protected override void OnCreated(EventArgs e)
{
base.OnCreated(e);
OnObjectModelChanged(e);
}
private void tm_RowCompare(object sender, TreeModelRowCompareEventArgs e)
{
float? _Value = e.Left.RowColumns[e.ColumnIndex].GetExtraData<float?>("value");
if (_Value == null) _Value = 0.0f;
float? value = e.Right.RowColumns[e.ColumnIndex].GetExtraData<float?>("value");
if (value == null) value = 0.0f;
e.Value = _Value.Value.CompareTo(value.Value);
e.Handled = true;
}
protected override void OnObjectModelChanged(EventArgs e)
{
base.OnObjectModelChanged(e);
if (!IsCreated) return;
tv.Columns.Clear();
tv.Model = null;
DataSetCollectionObjectModel dsc = (ObjectModel as DataSetCollectionObjectModel);
if (dsc == null) return;
DataSet ds = null;
if (dsc.DataSets.Count > 0)
ds = dsc.DataSets[0];
if (ds != null)
{
List<Type> list = new List<Type>();
for (int i = 0; i < ds.Dimensions; i++)
{
list.Add(typeof(string));
}
DefaultTreeModel tm = new DefaultTreeModel(list.ToArray());
tm.RowCompare += tm_RowCompare;
for (int i = 0; i < ds.Dimensions; i++)
{
tv.Columns.Add(new ListViewColumnText(tm.Columns[i], i.ToString()));
for (int j = 0; j < ds.Sizes[i]; j++)
{
float? val = ds.GetValue(i, j);
TreeModelRow row = null;
if (j >= tm.Rows.Count)
{
row = new TreeModelRow();
for (int i1 = 0; i1 < ds.Dimensions; i1++)
{
row.RowColumns.Add(new TreeModelRowColumn(tm.Columns[i], String.Empty));
}
tm.Rows.Add(row);
}
else
{
row = tm.Rows[j];
}
row.RowColumns[i].Value = (val == null ? String.Empty : val.ToString());
row.RowColumns[i].SetExtraData<float?>("value", val);
}
}
tv.Model = tm;
}
}
}
}

View File

@ -0,0 +1,46 @@
//
// AssemblyInfo.cs
//
// Author:
// Michael Becker <alcexhim@gmail.com>
//
// Copyright (c) 2020 Mike Becker's Software
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle("UniversalEditor.Plugins.Scientific.UserInterface")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Mike Becker's Software")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("Mike Becker's Software")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion("1.0.*")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]

View File

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{5F7935DF-55DF-44AC-8B0F-A395658AD7E0}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>UniversalEditor.Plugins.Scientific.UserInterface</RootNamespace>
<AssemblyName>UniversalEditor.Plugins.Scientific.UserInterface</AssemblyName>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<ReleaseVersion>4.0.2019.12</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Output\Debug\Plugins</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>..\..\Output\Release\Plugins</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Editors\DataSetCollection\DataSetCollectionEditor.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Editors\" />
<Folder Include="Editors\DataSetCollection\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Libraries\UniversalEditor.Core\UniversalEditor.Core.csproj">
<Project>{2D4737E6-6D95-408A-90DB-8DFF38147E85}</Project>
<Name>UniversalEditor.Core</Name>
</ProjectReference>
<ProjectReference Include="..\..\Libraries\UniversalEditor.Essential\UniversalEditor.Essential.csproj">
<Project>{30467E5C-05BC-4856-AADC-13906EF4CADD}</Project>
<Name>UniversalEditor.Essential</Name>
</ProjectReference>
<ProjectReference Include="..\..\Plugins\UniversalEditor.Plugins.Scientific\UniversalEditor.Plugins.Scientific.csproj">
<Project>{B9E4DD2F-A059-476F-823A-1AA8C1970663}</Project>
<Name>UniversalEditor.Plugins.Scientific</Name>
</ProjectReference>
<ProjectReference Include="..\..\Libraries\UniversalEditor.UserInterface\UniversalEditor.UserInterface.csproj">
<Project>{8622EBC4-8E20-476E-B284-33D472081F5C}</Project>
<Name>UniversalEditor.UserInterface</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\MBS.Framework\MBS.Framework\MBS.Framework.csproj">
<Project>{00266B21-35C9-4A7F-A6BA-D54D7FDCC25C}</Project>
<Name>MBS.Framework</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\MBS.Framework.UserInterface\Libraries\MBS.Framework.UserInterface\MBS.Framework.UserInterface.csproj">
<Project>{29E1C1BB-3EA5-4062-B62F-85EEC703FE07}</Project>
<Name>MBS.Framework.UserInterface</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,106 @@
//
// CDFDataFormat.cs
//
// Author:
// Michael Becker <alcexhim@gmail.com>
//
// Copyright (c) 2020 Mike Becker's Software
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using UniversalEditor.IO;
namespace UniversalEditor.Plugins.Scientific.DataFormats.NASA.CDF
{
public class CDFDataFormat : DataFormat
{
private const int COPYRIGHT_FIELD_LENGTH_BEFORE_2_5 = 1945;
private const int COPYRIGHT_FIELD_LENGTH_AFTER_2_5 = 256;
private readonly Version VERSION_2_5 = new Version(2, 5);
public Version FormatVersion { get; set; } = new Version(2, 5);
protected override void LoadInternal(ref ObjectModel objectModel)
{
Reader reader = Accessor.Reader;
reader.Endianness = Endianness.BigEndian;
uint magic = reader.ReadUInt32(); // 0xCDF26002, 0xCDF30000
uint compressionFlag = reader.ReadUInt32(); // 0x0000FFFF uncompressed, 0xCCCC0001 compressed
uint dummy = reader.ReadUInt32(); // 0x00000000
while (reader.EndOfStream)
{
long pos = reader.Accessor.Position;
uint recordSize = reader.ReadUInt32(); // 318
CDFRecordType recordType = (CDFRecordType)reader.ReadUInt32(); // 1 - CDR
switch (recordType)
{
case CDFRecordType.CDR:
{
int GDRoffset = reader.ReadInt32();
// The version of the CDF distribution (library) that created this CDF. CDF
// distributions are identi ed with four values: version, release, increment,
// and sub-increment.For example, CDF V2.5.8a is CDF version 2, release 5,
// increment 8, sub - increment `a'. Note that the sub-increment is not stored in a CDF.
int version = reader.ReadInt32();
// The release of the CDF distribution that created this CDF. See the Version field above.
int release = reader.ReadInt32();
// The data encoding for attribute entry and variable values.
int encoding = reader.ReadInt32();
CDFFileFlags flags = (CDFFileFlags)reader.ReadInt32();
int rfuA = reader.ReadInt32(); // reserved
int rfuB = reader.ReadInt32(); // reserved
// The increment of the CDF distribution that created this CDF. See the Version field above. Prior to CDF V2.1 this field was always set to zero.
int increment = reader.ReadInt32();
int rfuD = reader.ReadInt32(); // reserved
int rfuE = reader.ReadInt32(); // reserved
FormatVersion = new Version(version, release, increment);
string copyright = null;
if (FormatVersion < VERSION_2_5)
{
copyright = reader.ReadFixedLengthString(COPYRIGHT_FIELD_LENGTH_BEFORE_2_5);
}
else
{
copyright = reader.ReadFixedLengthString(COPYRIGHT_FIELD_LENGTH_AFTER_2_5);
}
break;
}
}
if (reader.Accessor.Position < pos + recordSize)
{
reader.Accessor.Seek((pos + recordSize) - reader.Accessor.Position, SeekOrigin.Current);
}
}
}
protected override void SaveInternal(ObjectModel objectModel)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,39 @@
//
// CDFFileFlags.cs - flags describing the various aspects of a CDF file
//
// Author:
// Michael Becker <alcexhim@gmail.com>
//
// Copyright (c) 2020 Mike Becker's Software
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
namespace UniversalEditor.Plugins.Scientific.DataFormats.NASA.CDF
{
/// <summary>
/// Flags describing the various aspects of a CDF file.
/// </summary>
[Flags()]
public enum CDFFileFlags
{
/// <summary>
/// The majority of variable values within a variable record. Set indicates row - majority. Clear indicates column-majority.
/// </summary>
RowMajority = 0x00000001,
/// <summary>
/// The file format of the CDF. Set indicates single-file. Clear indicates multi-file.
/// </summary>
SingleFile = 0x00000002
}
}

View File

@ -0,0 +1,83 @@
//
// CDFRecordType.cs
//
// Author:
// Michael Becker <alcexhim@gmail.com>
//
// Copyright (c) 2020 Mike Becker's Software
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
namespace UniversalEditor.Plugins.Scientific.DataFormats.NASA.CDF
{
public enum CDFRecordType : uint
{
/// <summary>
/// CDF Descriptor Record. General information about the CDF.
/// </summary>
CDR = 0x00000001,
/// <summary>
/// Global Descriptor Record. Additional general information about the CDF.
/// </summary>
GDR = 0x00000002,
/// <summary>
/// rVariable Descriptor Record. Information about an rVariable.
/// </summary>
rVDR = 0x00000003,
/// <summary>
/// Attribute Descriptor Record. Information about an attribute.
/// </summary>
ADR = 0x00000004,
/// <summary>
/// Attribute g/rEntry Descriptor Record. Information about a gEntry or rEntry of an attribute.
/// </summary>
AgrEDR = 0x00000005,
/// <summary>
/// Variable Index Record. Indexing information for a variable.
/// </summary>
VXR = 0x00000006,
/// <summary>
/// Variable Values Record. One or more variable records.
/// </summary>
VVR = 0x00000007,
/// <summary>
/// zVariable Descriptor Record. Information about a zVariable.
/// </summary>
zVDR = 0x00000008,
/// <summary>
/// Attribute zEntry Descriptor Record. Information about a zEntry of an attribute.
/// </summary>
AzEDR = 0x00000009,
/// <summary>
/// Compressed CDF Record. Information about a compressed CDF/variable.
/// </summary>
CCR = 0x0000000A,
/// <summary>
/// Compression Parameters Record. Information about the compression used for a CDF/variable.
/// </summary>
CPR = 0x0000000B,
/// <summary>
/// Sparseness Parameters Record. Information about the speci ed sparseness array.
/// </summary>
SPR = 0x0000000C,
/// <summary>
/// Compressed Variable Values Record. Information for the compressed CDF/variable.
/// </summary>
CVVR = 0x0000000D,
/// <summary>
/// Unused Internal Record. An internal record not currently being used.
/// </summary>
UIR = 0xFFFFFFFF
}
}

View File

@ -0,0 +1,126 @@
//
// SDFDataFormat.cs - a platform-independent data format that works in Fortran, C, and IDL
//
// Author:
// Michael Becker <alcexhim@gmail.com>
//
// Copyright (c) 2020 Mike Becker's Software
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using UniversalEditor.IO;
using UniversalEditor.Plugins.Scientific.ObjectModels.DataSetCollection;
namespace UniversalEditor.Plugins.Scientific.DataFormats.SDF
{
/// <summary>
/// A platform-independent data format that works in Fortran, C, and IDL.
/// </summary>
public class SDFDataFormat : DataFormat
{
private static DataFormatReference _dfr = null;
protected override DataFormatReference MakeReferenceInternal()
{
if (_dfr == null)
{
_dfr = base.MakeReferenceInternal();
_dfr.Capabilities.Add(typeof(DataSetCollectionObjectModel), DataFormatCapabilities.All);
}
return _dfr;
}
protected override void LoadInternal(ref ObjectModel objectModel)
{
DataSetCollectionObjectModel dsc = (objectModel as DataSetCollectionObjectModel);
if (dsc == null)
throw new ObjectModelNotSupportedException();
Reader reader = Accessor.Reader;
string signature = reader.ReadFixedLengthString(11);
if (signature != "SDF format\0")
throw new InvalidDataFormatException("File does not begin with 'SDF format', 0x00");
reader.Endianness = Endianness.BigEndian;
// location of next available byte in header
ulong hdrlen = reader.ReadUInt64();
// location of next available byte in data area. This is also equal to the file size.
ulong datalen = reader.ReadUInt64();
// number of datasets currently in file
uint ndatasets = reader.ReadUInt32();
// The current size of the header (initially set to HINITSZ, and incremented in blocks of HINITSZ as
// necessary.Default value of HINITSZ is 2000, but can be set by user.
ulong hdr_alloc_size = reader.ReadUInt64();
for (uint i = 0; i < ndatasets; i++)
{
string dataset_desc = reader.ReadLine();
string[] tokenized = dataset_desc.Split(new char[] { ' ' });
if (tokenized.Length < 6) throw new InvalidDataFormatException("dataset description (tokenized) does not contain at least 6 elements");
DataSet ds = new DataSet();
int iorder = Int32.Parse(tokenized[0]); // the order of this dataset in the file
ds.Order = iorder;
string label = tokenized[1];
ds.Name = label;
SDFDataSetDataType dataType = (SDFDataSetDataType)(byte)Char.Parse(tokenized[2]); // a single character denoting the type of data; i.e., 'f', 'i', 'c', or 'b'
switch (dataType)
{
case SDFDataSetDataType.Byte: ds.DataType = typeof(byte); break;
case SDFDataSetDataType.Complex: ds.DataType = typeof(long); break;
case SDFDataSetDataType.Float: ds.DataType = typeof(float); break;
case SDFDataSetDataType.Integer: ds.DataType = typeof(long); break;
}
int nbpw = Int32.Parse(tokenized[3]); // the number of bytes per word
int ndim = Int32.Parse(tokenized[4]); // the number of dimensions of the dataset or array
ds.Dimensions = ndim;
ds.Sizes = new int[ndim];
for (int j = 5; j < 5 + ndim; j++)
{
int dim = Int32.Parse(tokenized[j]); // the ndim values of the array dimensions
ds.Sizes[j - 5] = dim;
}
dsc.DataSets.Add(ds);
}
reader.Seek((long)hdr_alloc_size, SeekOrigin.Begin);
reader.Seek(19, SeekOrigin.Current); // idk???
for (int i = 0; i < dsc.DataSets.Count; i++)
{
for (int j = 0; j < dsc.DataSets[i].Dimensions; j++)
{
for (int k = 0; k < dsc.DataSets[i].Sizes[j]; k++)
{
float w = reader.ReadSingle();
dsc.DataSets[i].SetValue(j, k, w);
}
}
}
}
protected override void SaveInternal(ObjectModel objectModel)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,31 @@
//
// SDFDataSetDataType.cs
//
// Author:
// Michael Becker <alcexhim@gmail.com>
//
// Copyright (c) 2020 Mike Becker's Software
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
namespace UniversalEditor.Plugins.Scientific.DataFormats.SDF
{
public enum SDFDataSetDataType : byte
{
Float = (byte)'f',
Integer = (byte)'i',
Complex = (byte)'c',
Byte = (byte)'b'
}
}

View File

@ -0,0 +1,73 @@
//
// DataSet.cs
//
// Author:
// Michael Becker <alcexhim@gmail.com>
//
// Copyright (c) 2020 Mike Becker's Software
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
namespace UniversalEditor.Plugins.Scientific.ObjectModels.DataSetCollection
{
public class DataSet : ICloneable
{
public class DataSetCollection
: System.Collections.ObjectModel.Collection<DataSet>
{
}
public string Name { get; set; } = String.Empty;
public int Order { get; set; } = 0;
public Type DataType { get; set; } = null;
public int Dimensions { get; set; }
public int[] Sizes { get; set; } = null;
public object Clone()
{
DataSet clone = new DataSet();
clone.Name = Name.Clone() as string;
clone.Order = Order;
clone.DataType = DataType;
clone.Dimensions = Dimensions;
return clone;
}
private float?[][] fs = null;
private void Init()
{
if (fs == null)
{
fs = new float?[Dimensions][];
for (int i = 0; i < Dimensions; i++)
{
fs[i] = new float?[Sizes[i]];
}
}
}
public float? GetValue(int nDimension, int nIndex, float? defaultValue = null)
{
Init();
return fs[nDimension][nIndex].GetValueOrDefault(defaultValue.GetValueOrDefault());
}
public void SetValue(int nDimension, int nIndex, float? value)
{
Init();
fs[nDimension][nIndex] = value;
}
}
}

View File

@ -0,0 +1,52 @@
//
// DataSetObjectModel.cs
//
// Author:
// Michael Becker <alcexhim@gmail.com>
//
// Copyright (c) 2020 Mike Becker's Software
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
namespace UniversalEditor.Plugins.Scientific.ObjectModels.DataSetCollection
{
public class DataSetCollectionObjectModel : ObjectModel
{
private static ObjectModelReference _omr = null;
protected override ObjectModelReference MakeReferenceInternal()
{
if (_omr == null)
{
_omr = base.MakeReferenceInternal();
_omr.Title = "Data set collection";
}
return _omr;
}
public DataSet.DataSetCollection DataSets { get; } = new DataSet.DataSetCollection();
public override void Clear()
{
DataSets.Clear();
}
public override void CopyTo(ObjectModel where)
{
for (int i = 0; i < DataSets.Count; i++)
{
DataSets.Add(DataSets[i].Clone() as DataSet);
}
}
}
}

View File

@ -0,0 +1,46 @@
//
// AssemblyInfo.cs
//
// Author:
// Michael Becker <alcexhim@gmail.com>
//
// Copyright (c) 2020 Mike Becker's Software
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle("UniversalEditor.Plugins.Scientific")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Mike Becker's Software")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("Mike Becker's Software")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion("1.0.*")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B9E4DD2F-A059-476F-823A-1AA8C1970663}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>UniversalEditor.Plugins.Scientific</RootNamespace>
<AssemblyName>UniversalEditor.Plugins.Scientific</AssemblyName>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<ReleaseVersion>4.0.2019.12</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Output\Debug\Plugins</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>..\..\Output\Release\Plugins</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="DataFormats\NASA\CDF\CDFDataFormat.cs" />
<Compile Include="DataFormats\NASA\CDF\CDFRecordType.cs" />
<Compile Include="DataFormats\NASA\CDF\CDFFileFlags.cs" />
<Compile Include="DataFormats\SDF\SDFDataFormat.cs" />
<Compile Include="DataFormats\SDF\SDFDataSetDataType.cs" />
<Compile Include="ObjectModels\DataSetCollection\DataSetCollectionObjectModel.cs" />
<Compile Include="ObjectModels\DataSetCollection\DataSet.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="DataFormats\" />
<Folder Include="DataFormats\NASA\" />
<Folder Include="DataFormats\NASA\CDF\" />
<Folder Include="DataFormats\SDF\" />
<Folder Include="ObjectModels\" />
<Folder Include="ObjectModels\DataSetCollection\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Libraries\UniversalEditor.Core\UniversalEditor.Core.csproj">
<Project>{2D4737E6-6D95-408A-90DB-8DFF38147E85}</Project>
<Name>UniversalEditor.Core</Name>
</ProjectReference>
<ProjectReference Include="..\..\Libraries\UniversalEditor.Essential\UniversalEditor.Essential.csproj">
<Project>{30467E5C-05BC-4856-AADC-13906EF4CADD}</Project>
<Name>UniversalEditor.Essential</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -189,6 +189,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.MSBuild.Tas
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Compiler", "Applications\UniversalEditor.Compiler\UniversalEditor.Compiler.csproj", "{5E639F63-97B0-4B34-8928-29A5A3C661F4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.Scientific.UserInterface", "Plugins.UserInterface\UniversalEditor.Plugins.Scientific.UserInterface\UniversalEditor.Plugins.Scientific.UserInterface.csproj", "{5F7935DF-55DF-44AC-8B0F-A395658AD7E0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.Scientific", "Plugins\UniversalEditor.Plugins.Scientific\UniversalEditor.Plugins.Scientific.csproj", "{B9E4DD2F-A059-476F-823A-1AA8C1970663}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Extensions.Scientific", "Extensions\UniversalEditor.Extensions.Scientific\UniversalEditor.Extensions.Scientific.csproj", "{D46D9232-F585-4552-B3CA-6B0F284B746A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -545,6 +551,18 @@ Global
{5E639F63-97B0-4B34-8928-29A5A3C661F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5E639F63-97B0-4B34-8928-29A5A3C661F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5E639F63-97B0-4B34-8928-29A5A3C661F4}.Release|Any CPU.Build.0 = Release|Any CPU
{5F7935DF-55DF-44AC-8B0F-A395658AD7E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5F7935DF-55DF-44AC-8B0F-A395658AD7E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5F7935DF-55DF-44AC-8B0F-A395658AD7E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5F7935DF-55DF-44AC-8B0F-A395658AD7E0}.Release|Any CPU.Build.0 = Release|Any CPU
{B9E4DD2F-A059-476F-823A-1AA8C1970663}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B9E4DD2F-A059-476F-823A-1AA8C1970663}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B9E4DD2F-A059-476F-823A-1AA8C1970663}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B9E4DD2F-A059-476F-823A-1AA8C1970663}.Release|Any CPU.Build.0 = Release|Any CPU
{D46D9232-F585-4552-B3CA-6B0F284B746A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D46D9232-F585-4552-B3CA-6B0F284B746A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D46D9232-F585-4552-B3CA-6B0F284B746A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D46D9232-F585-4552-B3CA-6B0F284B746A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{6F0AB1AF-E1A1-4D19-B19C-05BBB15C94B2} = {05D15661-E684-4EC9-8FBD-C014BA433CC5}
@ -633,6 +651,9 @@ Global
{8A0618F6-4FE6-4BA2-81DE-87C222235FBE} = {5E4765D1-3959-4433-8E9C-992E26D7BE62}
{676D52A3-F285-4F58-B7A8-7BF415E3F733} = {0399182F-AF56-4E86-B229-EAB38C2EE6AF}
{5E639F63-97B0-4B34-8928-29A5A3C661F4} = {05D15661-E684-4EC9-8FBD-C014BA433CC5}
{5F7935DF-55DF-44AC-8B0F-A395658AD7E0} = {7B535D74-5496-4802-B809-89ED88274A91}
{B9E4DD2F-A059-476F-823A-1AA8C1970663} = {2ED32D16-6C06-4450-909A-40D32DA67FB4}
{D46D9232-F585-4552-B3CA-6B0F284B746A} = {5E4765D1-3959-4433-8E9C-992E26D7BE62}
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
Policies = $0