Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
seto77 committed Dec 13, 2023
1 parent f298445 commit 146ecb1
Show file tree
Hide file tree
Showing 9 changed files with 479 additions and 324 deletions.
472 changes: 235 additions & 237 deletions Crystallography.Controls/Crystal/AtomCoordinateTable.cs

Large diffs are not rendered by default.

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>net8.0-windows10.0.22621.0</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<AssemblyVersion>2023.12.6.0629</AssemblyVersion>
<FileVersion>2023.12.6.0629</FileVersion>
<AssemblyVersion>2023.12.13.0441</AssemblyVersion>
<FileVersion>2023.12.13.0441</FileVersion>
<ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode>
<ApplicationUseCompatibleTextRendering>true</ApplicationUseCompatibleTextRendering>
<ApplicationVisualStyles>true</ApplicationVisualStyles>
Expand Down
14 changes: 6 additions & 8 deletions Crystallography.Controls/Numeric/NumericBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,13 @@ public string ToolTip
[Category("Font && Color")]
public Color TextBoxForeColor { set => textBox.ForeColor = value; get => textBox.ForeColor; }

[DefaultValue(typeof(Color), "Window")]
[Category("Font && Color")]
[DefaultValue(typeof(Color), "Window")]
public Color TextBoxBackColor { set => textBox.BackColor = value; get => textBox.BackColor; }

[DefaultValue(typeof(Font), "Segoe UI Symbol, 9.75pt")]
[Localizable(true)]
[Category("Font && Color")]
[DefaultValue(typeof(Font), "Segoe UI Symbol, 9.75pt")]
/// <summary>
/// font
/// </summary>
Expand All @@ -239,7 +239,7 @@ public Font TextFont
MaximumSize = new Size(1000, textBox.Height + 5);
}
}
get { return textBox.Font; }
get => textBox.Font;
}


Expand Down Expand Up @@ -519,8 +519,6 @@ public void Calculate(object sender, EventArgs e)
}
}



/// <summary>
/// 現在のnumericalValueからテキストボックスの文字列を設定する
/// </summary>
Expand Down Expand Up @@ -559,11 +557,11 @@ internal string GetString()
{
text = numericalValue.ToString(DecimalPlaces >= 0 ? $"f{DecimalPlaces}" : "");
if (TrimEndZero && text.Contains('.'))
text = text.TrimEnd(new[] { '0' }).TrimEnd(new[] { '.' });
text = text.TrimEnd(['0']).TrimEnd(['.']);

text = separateThousands(text);
}
if (!text.StartsWith("-") && ShowPositiveSign && text != "0")
if (!text.StartsWith('-') && ShowPositiveSign && text != "0")
text = "+" + text;

return text;
Expand All @@ -575,7 +573,7 @@ private static string separateThousands(string valueString)
if (valueString.Contains(','))
decimalPoint = ',';

var integer = valueString.Split(new[] { decimalPoint });
var integer = valueString.Split([decimalPoint]);
for (int i = integer[0].Length - 3; i > 0; i -= 3)
{
if (integer[0][i - 1] != '-')
Expand Down
60 changes: 60 additions & 0 deletions Crystallography.Controls/Numeric/NumericBox.resx
Original file line number Diff line number Diff line change
@@ -1,4 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
Expand Down
47 changes: 47 additions & 0 deletions Crystallography/Crystal/Crystal.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#region using
using MathNet.Numerics;
using MathNet.Numerics.LinearAlgebra.Factorization;
using Microsoft.VisualBasic.Devices;
using System;
using System.Collections.Generic;
using System.Drawing;
Expand Down Expand Up @@ -1824,4 +1825,50 @@ public void RevertInitialCellConstants()
}
#endregion


/// <summary>
/// 指定した原子(target)の近辺にある原子を探索し、相対座標、距離、ラベルを返す. (絶対座標でないことに注意)
/// </summary>
/// <param name="target"></param>
/// <param name="maxLength"> nm 単位</param>
/// <returns></returns>
public List<(double X, double Y, double Z, double Distance, string Label)> Search(Atoms target, double maxLength)
{
Vector3DBase pos = MatrixReal * target.Atom[0];
var maxLen2 = maxLength * maxLength;
var result = new List<(double X, double Y, double Z, double Distance, string Label)>();
//まず、隣り合った単位格子の原子位置をすべて探索してCoordinatedAtom型のリストに全部入れる
for (int max = 0; max < 8; max++)
{
bool flag = false;
Parallel.For(-max, max + 1, xShift =>
{
for (int yShift = -max; yShift <= max; yShift++)
for (int zShift = -max; zShift <= max; zShift++)
{
if (Math.Abs(xShift) == max || Math.Abs(yShift) == max || Math.Abs(zShift) == max)
{
foreach (var atm in Atoms)
foreach (var v in atm.Atom)
{
var diffPos = MatrixReal * (v + new Vector3DBase(xShift, yShift, zShift)) - pos;
if (maxLen2 > (diffPos ).Length2)
{

lock (lockObj)
{
result.Add((diffPos.X, diffPos.Y, diffPos.Z, diffPos.Length, atm.Label));
flag = true;//一個でも見つけられたら続行
}
}
}
}
}
});
if (flag == false && max > 2)
break;
}
result.Sort((a1, a2) => a1.Distance.CompareTo(a2.Distance));
return result;
}
}
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>net8.0-windows10.0.22621.0</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<AssemblyVersion>2023.12.6.0629</AssemblyVersion>
<FileVersion>2023.12.6.0629</FileVersion>
<AssemblyVersion>2023.12.13.0441</AssemblyVersion>
<FileVersion>2023.12.13.0441</FileVersion>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
</PropertyGroup>

Expand Down
30 changes: 16 additions & 14 deletions Crystallography/Images/ImageIO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Crystallography;
public static class ImageIO
{
public static string[] ListOfExtension =
{
[
"img",
"stl",
"ccd",
Expand All @@ -34,7 +34,7 @@ public static class ImageIO
"png",
"smv",
"mrc",
};
];

public static string FilterString
{
Expand Down Expand Up @@ -317,12 +317,13 @@ private static bool SMV(string filename)
}
#endregion

#region RadIcon rawファイル
#region rawファイル (RadIcon など)
public static bool RadIcon(string str)
{
try
// try
{
if (new FileInfo(str).Length == 6390144)//2064*1548のサイズを持つ検出器 (SACLA EH5の場合)
#region 2064*1548のサイズを持つ検出器 (SACLA EH5の場合)
if (new FileInfo(str).Length == 6390144)
{
var br = new BinaryReader(new FileStream(str, FileMode.Open, FileAccess.Read));
int imageWidth = 2064, imageHeight = 1548, length = imageWidth * imageHeight;
Expand All @@ -346,9 +347,11 @@ public static bool RadIcon(string str)
Ring.ImageType = Ring.ImageTypeEnum.RadIcon;
Ring.Comments = "";

return true;
}
#endregion

//2020年に導入された、PFのRAWファイル形式 (references\ImageExsample\BL18c 柴咲さん を参考せよ)
#region 2020年に導入された、PFのRAWファイル形式 (references\ImageExsample\BL18c 柴咲さん を参考せよ)
else if (Check_PF_RAW(str))
{
var br = new BinaryReader(new FileStream(str, FileMode.Open, FileAccess.Read));
Expand Down Expand Up @@ -438,18 +441,17 @@ public static bool RadIcon(string str)

return true;
}



#endregion

return false;


}
catch (Exception e)
{
MessageBox.Show(e.Message);
return false;
}
//catch (Exception e)
//{
// MessageBox.Show(e.Message);
// return false;
//}
}
#endregion

Expand Down
Loading

0 comments on commit 146ecb1

Please sign in to comment.