Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
seto committed Dec 6, 2024
1 parent 51726f7 commit e96911f
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Crystallography.Controls/Crystallography.Controls.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<OutputType>Library</OutputType>
<TargetFramework>net9.0-windows10.0.26100.0</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<AssemblyVersion>2024.12.6.0246</AssemblyVersion>
<FileVersion>2024.12.6.0246</FileVersion>
<AssemblyVersion>2024.12.6.2328</AssemblyVersion>
<FileVersion>2024.12.6.2328</FileVersion>
<ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode>
<ApplicationUseCompatibleTextRendering>true</ApplicationUseCompatibleTextRendering>
<ApplicationVisualStyles>true</ApplicationVisualStyles>
Expand Down
4 changes: 2 additions & 2 deletions Crystallography.OpenGL/Crystallography.OpenGL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<OutputType>Library</OutputType>
<TargetFramework>net9.0-windows10.0.26100.0</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<AssemblyVersion>2024.11.25.0729</AssemblyVersion>
<FileVersion>2024.11.25.0729</FileVersion>
<AssemblyVersion>2024.12.6.2327</AssemblyVersion>
<FileVersion>2024.12.6.2327</FileVersion>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Crystallography/Atom/AtomMinimum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Crystallography;
/// <summary>
/// Atoms2クラス
/// </summary>
[Serializable()]
//[Serializable()]
[MemoryPackable]
public partial class Atoms2
{
Expand Down
40 changes: 39 additions & 1 deletion Crystallography/Crystal/CrystalMinimum.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MemoryPack;
using MemoryPack.Compression;
using System;
using System.Collections.Frozen;
using System.Collections.Generic;
Expand All @@ -11,7 +12,7 @@ namespace Crystallography;

//必要最小限の情報だけを保存するクラス
//[ProtoContract]
[Serializable()]
//[Serializable()]
[MemoryPackable]
public partial class Crystal2
{
Expand Down Expand Up @@ -217,6 +218,43 @@ [ Compose(a.Dsf.Aniso11, a.Dsf.Aniso11_err),
return c2;
}

/// <summary>
/// MemoryPackでシリアライズしてbyte[]配列を返す
/// </summary>
/// <returns></returns>
public byte[] Serialize()
{
return Serialize(this);
}

/// <summary>
/// 静的メソッド MemoryPackでシリアライズしてbyte[]配列を返す
/// </summary>
/// <param name="c"></param>
/// <returns></returns>
public static byte[] Serialize(Crystal2 c )
{
using var compressor = new BrotliCompressor(System.IO.Compression.CompressionLevel.Optimal);
MemoryPackSerializer.Serialize(compressor, c);
var data = compressor.ToArray();
return data;
}

/// <summary>
/// MemoryPackでシリアライズされたbyte[]配列からCrystal2を返す. 不適切な入力値だった場合はnull返し。
/// </summary>
/// <param name="bytes"></param>
/// <returns></returns>
public static Crystal2 Deserialize(byte[] bytes)
{
try
{
using var decompressor = new BrotliDecompressor();// Decompression(require using)
return MemoryPackSerializer.Deserialize<Crystal2>(decompressor.Decompress(bytes));
}
catch { return null; }
}

[MemoryPackIgnore]
private static readonly CultureInfo culture = CultureInfo.InvariantCulture;
[MemoryPackIgnore]
Expand Down
4 changes: 2 additions & 2 deletions Crystallography/Crystallography.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<OutputType>Library</OutputType>
<TargetFramework>net9.0-windows10.0.26100.0</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<AssemblyVersion>2024.12.6.0246</AssemblyVersion>
<FileVersion>2024.12.6.0246</FileVersion>
<AssemblyVersion>2024.12.6.2328</AssemblyVersion>
<FileVersion>2024.12.6.2328</FileVersion>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
Expand Down
5 changes: 5 additions & 0 deletions ReciPro/DiffractionSimulator/FormDiffractionSimulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,8 @@ double fillCircleSpread(Color c, PointD pt, double intensity, double sigma)
{
g.Flag2 = true;
var rInt = g.RelativeIntensity;
if (radioButtonIntensityExcitation.Checked)
rInt = 1;

if (checkBoxDrawSameSize.Checked && Math.Abs(dev) < 3 * ExcitationError)//全て同一サイズで描画する場合はここで dev2=0, rInt=1;
{
Expand Down Expand Up @@ -976,6 +978,9 @@ double fillCircleSpread(Color c, PointD pt, double intensity, double sigma)
var sphereRadius = bethe ?
ExcitationError * Math.Sqrt(g.RelativeIntensity) ://ベーテ法の場合は、相対強度の平方根が半径に比例
ExcitationError * Math.Pow(g.RelativeIntensity, 1.0 / 3.0);//excitaion only あるいは Kinematicの場合は、半径に相対強度の1/3乗を掛ける

if (radioButtonIntensityExcitation.Checked)
sphereRadius = ExcitationError;

if (bethe || Math.Abs(dev) < sphereRadius)
{
Expand Down
6 changes: 3 additions & 3 deletions ReciPro/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ protected override void WndProc(ref System.Windows.Forms.Message msg)
switch (msg.Msg)
{
case WM_DRAWCLIPBOARD:
if ((Clipboard.GetDataObject()).GetDataPresent(typeof(Crystal2)))
if (Clipboard.GetDataObject().GetDataPresent(typeof(byte[])))
{
var data = Clipboard.GetDataObject();
var c2 = (Crystal2)data.GetData(typeof(Crystal2));
var bytes = (byte[])Clipboard.GetDataObject().GetData(typeof(byte[]));
var c2 = Crystal2.Deserialize(bytes);
crystalControl.Crystal = Crystal2.GetCrystal(c2);
}

Expand Down
4 changes: 2 additions & 2 deletions ReciPro/ReciPro.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<OutputType>WinExe</OutputType>
<TargetFramework>net9.0-windows10.0.26100.0</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<AssemblyVersion>2024.11.25.0729</AssemblyVersion>
<FileVersion>2024.11.25.0729</FileVersion>
<AssemblyVersion>2024.12.6.2329</AssemblyVersion>
<FileVersion>2024.12.6.2329</FileVersion>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<ApplicationIcon>App.ico</ApplicationIcon>
Expand Down

0 comments on commit e96911f

Please sign in to comment.