Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
seto77 committed Mar 5, 2024
1 parent 4fe34fb commit 714fcfe
Show file tree
Hide file tree
Showing 62 changed files with 2,645 additions and 2,678 deletions.
3 changes: 1 addition & 2 deletions Crystallography.Controls/CheckLocation.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using static System.Net.WebRequestMethods;

namespace Crystallography.Controls
{
Expand All @@ -11,7 +10,7 @@ public static void Adjust(Form form)
{
double fL = form.Bounds.Left, fR = form.Bounds.Right, fT = form.Bounds.Top, fB = form.Bounds.Bottom, fW = form.Size.Width, fH = form.Size.Height;

if (Screen.AllScreens.All(s => (fL - s.Bounds.Left) / fW < -0.8 || (s.Bounds.Right- fR) / fW < -0.8 || (fT - s.Bounds.Top) / fH < -0.8 || (s.Bounds.Bottom - fB) / fH < -0.8))
if (Screen.AllScreens.All(s => (fL - s.Bounds.Left) / fW < -0.8 || (s.Bounds.Right - fR) / fW < -0.8 || (fT - s.Bounds.Top) / fH < -0.8 || (s.Bounds.Bottom - fB) / fH < -0.8))
{
var scr = Screen.AllScreens.First(e => e.DeviceName == Screen.FromControl(form).DeviceName);
form.Location = new Point(scr.Bounds.X + 100, scr.Bounds.Y + 100);
Expand Down
4 changes: 2 additions & 2 deletions Crystallography.Controls/Crystal/BoundControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ private void dataGridView_CellValueChanged(object sender, DataGridViewCellEventA
}
#endregion






}
4 changes: 2 additions & 2 deletions Crystallography.Controls/Crystal/CrystalControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -620,14 +620,14 @@ public void toAnotherSpaceGroup(int destNum)
"-b1" => forward ? (-z, y, x) : (z, y, -x),
"-b2" => forward ? (x + z, y, z) : (x - z, y, z),
"-b3" => forward ? (-x, y, -z - x) : (-x, y, x - z),

"c1" => forward ? (z, x, y) : (y, z, x),
"c2" => forward ? (x - z, -z, y) : (x - y, z, -y),
"c3" => forward ? (-x, z - x, y) : (-x, z, y - x),
"-c1" => forward ? (x, -z, y) : (x, z, -y),
"-c2" => forward ? (z, x + z, y) : (y - x, z, x),
"-c3" => forward ? (-z - x, -x, y) : (-y, z, y - x),

"a1" => forward ? (y, z, x) : (z, x, y),
"a2" => forward ? (y, x - z, -z) : (y - z, x, -z),
"a3" => forward ? (y, -x, z - x) : (-y, x, z - y),
Expand Down
4,834 changes: 2,417 additions & 2,417 deletions Crystallography.Controls/Crystal/CrystalControl.resx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Crystallography.Controls/Crystal/FormAnotherSpaceGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public partial class FormAnotherSpaceGroup : Form
}
}
public int SeriesNum => candidates[listBox.SelectedIndex].SeriesNum;


public FormAnotherSpaceGroup()
{
Expand Down
2 changes: 1 addition & 1 deletion Crystallography.Controls/Crystal/FormScatteringFactor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private void SetSortedPlanes()

c.SetVectorOfG((double)numericUpDownThresholdD.Value / 10, waveLengthControl1.WaveSource, false);

Array.Sort(c.VectorOfG,(g1, g2) => g2.d.CompareTo(g1.d));
Array.Sort(c.VectorOfG, (g1, g2) => g2.d.CompareTo(g1.d));

if (c.VectorOfG.Length == 0) return;

Expand Down
2 changes: 1 addition & 1 deletion Crystallography.Controls/Crystal/SymmetryControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ public void SetCellConstantsBySymmetry()

ItemChanged?.Invoke(this, new EventArgs());
//GenerateFromInterface();

}
#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ private void backgroundWorkerSearch_RunWorkerCompleted(object sender, System.Com
//if (flagCount == 0)
// CrystalDatabaseControl.Suspend();
//else
CrystalDatabaseControl.Resume();//バインディングを繋げる
CrystalDatabaseControl.Resume();//バインディングを繋げる


this.Enabled = true;
Expand Down
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>2024.3.5.1029</AssemblyVersion>
<FileVersion>2024.3.5.1029</FileVersion>
<AssemblyVersion>2024.3.5.1043</AssemblyVersion>
<FileVersion>2024.3.5.1043</FileVersion>
<ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode>
<ApplicationUseCompatibleTextRendering>true</ApplicationUseCompatibleTextRendering>
<ApplicationVisualStyles>true</ApplicationVisualStyles>
Expand Down
4 changes: 2 additions & 2 deletions Crystallography.Controls/GraphControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ public GraphControl()
#endregion イベント

#region プロパティ、フィールド

/// <summary>
/// グラフの描き方の列挙体
/// </summary>
public enum DrawingMode { Line, Histogram, Point }

private Bitmap Bmp;
private Graphics G;

Expand Down
2 changes: 1 addition & 1 deletion Crystallography.Controls/Macro/FormMacro.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public void RunMacro(string srcCode)
}

_cancelSource = new CancellationTokenSource();
task = new Task(()=> Engine.CreateScriptSourceFromString(srcCode).Execute(Scope), _cancelSource.Token);
task = new Task(() => Engine.CreateScriptSourceFromString(srcCode).Execute(Scope), _cancelSource.Token);
task.RunSynchronously();
}
catch (Microsoft.Scripting.ArgumentTypeException ex) { MessageBox.Show(ex.Message); }
Expand Down
12 changes: 6 additions & 6 deletions Crystallography.Controls/ScalablePictureBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ public PseudoBitmap PseudoBitmap
public bool TitleVisible { get; set; } = false;
public (string Text, Font Font, Color Color1, Color Color2) Title { get; set; }


#endregion プロパティ

/// <summary>
Expand Down Expand Up @@ -507,12 +507,12 @@ private void pictureBox_MouseDown(object sender, MouseEventArgs e)
_Center = ConvertToSrcPt(e.Location);//イベントを起こさないように小文字のcenterに代入
Zoom *= 0.5f;
}
else if ((e.Button == MouseButtons.Left||e.Button== MouseButtons.Middle) && e.Clicks == 1)
else if ((e.Button == MouseButtons.Left || e.Button == MouseButtons.Middle) && e.Clicks == 1)
{
justBeforePoint = e.Location;
}
}


private bool manualSpotMode = false;

Expand All @@ -535,7 +535,7 @@ private void pictureBox_MouseMove(object sender, MouseEventArgs e)
mouseRangeEnd = e.Location;
pictureBox.Refresh();
}
else if ((e.Button == MouseButtons.Left||e.Button == MouseButtons.Middle) && MouseTranslation && justBeforePoint != e.Location)
else if ((e.Button == MouseButtons.Left || e.Button == MouseButtons.Middle) && MouseTranslation && justBeforePoint != e.Location)
{
Center = new PointD(Center.X + (justBeforePoint.X - e.Location.X) / Zoom, Center.Y + (justBeforePoint.Y - e.Location.Y) / Zoom);
justBeforePoint = e.Location;
Expand Down Expand Up @@ -1018,13 +1018,13 @@ public Bitmap GetBitmapImage()
public void SaveAsPNG()
{
var dlg = new SaveFileDialog() { Filter = "*.png|*.png" };
if(dlg.ShowDialog()== DialogResult.OK)
if (dlg.ShowDialog() == DialogResult.OK)
GetBitmapImage().Save(dlg.FileName);
}

public void CopyAsBitmap()
{
Clipboard.SetDataObject(GetBitmapImage(),true);
Clipboard.SetDataObject(GetBitmapImage(), true);
}

public void SaveAsMetafile() => metafile(true);
Expand Down
14 changes: 8 additions & 6 deletions Crystallography.Controls/Wave/WaveLengthControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,16 @@ public FlowDirection Direction

public bool Monochrome
{
set
{ numericBoxEnergy.Visible = numericBoxWaveLength.Visible = value;
flowLayoutPanelElement.Visible = WaveSource == WaveSource.Xray && value;
labelFlatWhite.Visible = !value; }
set
{
numericBoxEnergy.Visible = numericBoxWaveLength.Visible = value;
flowLayoutPanelElement.Visible = WaveSource == WaveSource.Xray && value;
labelFlatWhite.Visible = !value;
}
get => numericBoxEnergy.Visible;
}

[Localizable(true)]
[Localizable(true)]
public Font TextFont
{
set
Expand Down Expand Up @@ -280,7 +282,7 @@ public WaveLengthControl()
comboBoxXRayElement.SelectedIndex = 0;
}



/// <summary>
/// X線のElementが変更されたとき
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>net8.0-windows10.0.22621.0</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<AssemblyVersion>2024.3.5.1029</AssemblyVersion>
<FileVersion>2024.3.5.1029</FileVersion>
<AssemblyVersion>2024.3.5.1043</AssemblyVersion>
<FileVersion>2024.3.5.1043</FileVersion>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions Crystallography.OpenGL/GLControlAlpha.cs
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ public void DeleteAllObjects()
glObjects.Clear();
}


#endregion

#region クリップ操作
Expand Down Expand Up @@ -845,7 +845,7 @@ private void glControl_MouseMove(object sender, MouseEventArgs e)
if (RotationMode == RotationModes.Object)
WorldMatrix *= Mat4d.CreateRotationX((float)(-dy / 100)) * Mat4d.CreateRotationY((float)(dx / 100));
else if (RotationMode == RotationModes.View)
ViewMatrix *= Mat4d.CreateRotationX((float)(-dy / 100)) * Mat4d.CreateRotationY((float)(dx / 100));
ViewMatrix *= Mat4d.CreateRotationX((float)(-dy / 100)) * Mat4d.CreateRotationY((float)(dx / 100));
}
else
{
Expand Down
1 change: 0 additions & 1 deletion Crystallography.OpenGL/GLGeometry.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using M3d = OpenTK.Matrix3d;
using V2d = OpenTK.Vector2d;
using V3d = OpenTK.Vector3d;
Expand Down
8 changes: 4 additions & 4 deletions Crystallography.OpenGL/GLObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public Vertex(V4f position, V3f normal, int argb) : this(new V3f(position), norm
/// <param name="uv"></param>
public Vertex(V3f position, V3f normal, V2f uv)
{
if (GLControlAlpha.DisableTextRendering
||(GLControlAlpha.GraphicsInfo.Count == 1 && GLControlAlpha.GraphicsInfo[0].Product.Contains("AMD Radeon", StringComparison.OrdinalIgnoreCase)))
if (GLControlAlpha.DisableTextRendering
|| (GLControlAlpha.GraphicsInfo.Count == 1 && GLControlAlpha.GraphicsInfo[0].Product.Contains("AMD Radeon", StringComparison.OrdinalIgnoreCase)))
position = new V3f(0, 0, 0);
Position = position;
Normal = normal;
Expand Down Expand Up @@ -450,7 +450,7 @@ private void Render()
GL.BindBuffer(BufferTarget.ElementArrayBuffer, Obj.EBO);

int offset = 0;

foreach (var (t, len) in Primitives)
{
if ((t == PT.Triangles || t == PT.TriangleStrip || t == PT.TriangleFan || t == PT.Quads)
Expand Down Expand Up @@ -1037,7 +1037,7 @@ public Polygon[] ToPolygons(int order = 0)
/// <summary>
/// 平行六面体(原点と3辺のベクトルで定義)
/// </summary>
public class Parallelepiped(V3d o, V3d a, V3d b, V3d c, Material mat, DrawingMode mode)
public class Parallelepiped(V3d o, V3d a, V3d b, V3d c, Material mat, DrawingMode mode)
: Polyhedron(new[] { o, o + a, o + b, o + c, o + a + b, o + b + c, o + c + a, o + a + b + c }, mat, mode)
{
}
Expand Down
10 changes: 5 additions & 5 deletions Crystallography/Atom/AtomMinimum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ public partial class Atoms2

[MemoryPackInclude]
private byte[] occBytes;//Occ

public byte SubXray;

public byte SubElectron;

public byte AtomNo;//原子番号 ただし、255は重水素D

public bool IsU;

public bool IsIso;

[MemoryPackInclude]
Expand Down
26 changes: 13 additions & 13 deletions Crystallography/Atom/AtomStatic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ static AtomStatic()
/// <summary>
/// X線による原子散乱因子 XrayScattering[AtomicNumber][SubNumber]
/// </summary>
public static readonly ES[][] XrayScattering =
public static readonly ES[][] XrayScattering =
[

#region
Expand Down Expand Up @@ -1216,7 +1216,7 @@ static AtomStatic()
/// Peng 1996,1998
/// a1,a2,a3,a4,a5,b1,b2,b3,b4,b5,valence,method
/// </summary>
public static readonly ES[][] ElectronScatteringPeng =
public static readonly ES[][] ElectronScatteringPeng =
[
#region
[
Expand Down Expand Up @@ -1530,7 +1530,7 @@ static AtomStatic()
/// 電子線による原子散乱因子 ElectronScattering[AtomicNumber] 8 gaussian
/// a1,a2,a3,a4,a5,a6,a7,a8,b1,b2,b3,b4,b5,b6,b7,b8
/// </summary>
public static readonly ES[] ElectronScatteringEightGaussian =
public static readonly ES[] ElectronScatteringEightGaussian =
[
#region
new(0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ),
Expand Down Expand Up @@ -2068,7 +2068,7 @@ static AtomStatic()
/// <summary>
/// 中性子の散乱長 単位はfm
/// </summary>
public static readonly Complex[][] NeutronCoherentScattering =
public static readonly Complex[][] NeutronCoherentScattering =
[
#region 単位はfm
[new(0 , 0 )],
Expand Down Expand Up @@ -2520,7 +2520,7 @@ public ES(double a1, double b1, double a2, double b2, double a3, double b3, doub
{
Valence = valence;
Method = methods;
Prms = [(a1, b1), (a2, b2), (a3, b3), (a4, b4) ];
Prms = [(a1, b1), (a2, b2), (a3, b3), (a4, b4)];
Factor = new Func<double, double>(s2 => (Prms.Sum(p => p.A * Math.Exp(-s2 * 0.01 * p.B)) + c) * 0.1);
}

Expand Down Expand Up @@ -2627,14 +2627,14 @@ public double FactorImaginaryAnnularFlatEwald(double kV, Vector3DBase g, double
double f_kMinusG = 0, f_kPlusG = 0;
foreach (var (A, B) in Prms)
{
f_kMinusG += A * Math.Exp(-kMinusG / 400 * B );
f_kPlusG += A * Math.Exp(-kPlusG / 400 * B );
f_kMinusG += A * Math.Exp(-kMinusG / 400 * B);
f_kPlusG += A * Math.Exp(-kPlusG / 400 * B);
}
return f_kMinusG * f_kPlusG * (1 - Math.Exp(m * (gLen2 - kMinusG - kPlusG) / 4));// * sinThetaを外に出して、少しでも早く
}, 0, 2 * Math.PI, 30);
}, k0 * Math.Sin(inner), k0 * Math.Sin(outer), 80);
return gamma / Math.PI/Math.PI/ k0 * result * 0.01;

return gamma / Math.PI / Math.PI / k0 * result * 0.01;
}

/// <summary>
Expand Down Expand Up @@ -2706,7 +2706,7 @@ public double FactorImaginaryAnnular(double kV, Vector3DBase g, Vector3DBase h,
}
return f_k_g * f_k_h * 0.01 * (1 - Math.Exp(m * (g_h - k_g * 100 - k_h * 100)));// * sinThetaを外に出して、少しでも早く
}, 0, 2 * Math.PI, 20) * sinθ;
}, inner, outer, 60) ;
}, inner, outer, 60);
}

/// <summary>
Expand Down Expand Up @@ -7199,7 +7199,7 @@ public static PointD[] LinearAbsorptionCoefficient(int z)

public static PointD[] MassAbsorptionCoefficient(int z)
{
List<PointD> pt =[];
List<PointD> pt = [];
for (int n = 0; n < AtomStaticSub.MassAbsorptionCoefficient[z].Length; n++)
pt.AddRange(AtomStaticSub.MassAbsorptionCoefficient[z][n].Select(e => new PointD(e)));
return [.. pt];
Expand Down Expand Up @@ -7387,8 +7387,8 @@ public static void ReadChantlerData(string[] fileNames)
reader.Close();

int i = 0;
int z = Convert.ToInt32(str[1].Split([ ',' ])[0].Replace("<b>Z=", ""));//2行目から原子番号を読み取る
//edgeの値を読み取る
int z = Convert.ToInt32(str[1].Split([','])[0].Replace("<b>Z=", ""));//2行目から原子番号を読み取る
//edgeの値を読み取る
while (!str[i].Contains("edge")) i++;
var edgeNo = Convert.ToInt32(str[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[0]);
i += 2;
Expand Down
4 changes: 2 additions & 2 deletions Crystallography/Atom/Atoms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public override bool Equals(object obj)

public override int GetHashCode()
{
return new { X,Y,Z,Occ,Label,WyckoffNumber,SymmetrySeriesNumber,Dsf,Atom,Texture }.GetHashCode();
return new { X, Y, Z, Occ, Label, WyckoffNumber, SymmetrySeriesNumber, Dsf, Atom, Texture }.GetHashCode();
}
#endregion

Expand Down Expand Up @@ -91,7 +91,7 @@ public override int GetHashCode()
public Vector3DBase PositionError => new(X_err, Y_err, Z_err);
[XmlIgnore]
public Vector3DBase Position => new(X, Y, Z);

[XmlIgnore]
public (float Ambient, float Diffusion, float Specular, float Shininess, float Emission) Texture
{
Expand Down
Loading

0 comments on commit 714fcfe

Please sign in to comment.