Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
seto77 committed Oct 25, 2022
1 parent b332dfe commit 3efeee2
Show file tree
Hide file tree
Showing 33 changed files with 7,960 additions and 7,482 deletions.
4 changes: 2 additions & 2 deletions CSManager/CSManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<AssemblyVersion>2022.09.09.2035</AssemblyVersion>
<FileVersion>2022.09.09.2035</FileVersion>
<AssemblyVersion>2022.10.25.1516</AssemblyVersion>
<FileVersion>2022.10.25.1516</FileVersion>
<ApplicationIcon>App.ico</ApplicationIcon>
</PropertyGroup>

Expand Down
194 changes: 145 additions & 49 deletions Crystallography.Controls/Crystal/CrystalControl.Designer.cs

Large diffs are not rendered by default.

83 changes: 72 additions & 11 deletions Crystallography.Controls/Crystal/CrystalControl.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#region Using
using Crystallography.Controls;
using MathNet.Numerics.LinearAlgebra.Double;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
Expand Down Expand Up @@ -283,17 +285,8 @@ public void SetToInterface(bool ChangeCellParameter = true)

public void ReadCrystal(string filename)
{

try
{
Crystal = ConvertCrystalData.ConvertToCrystal(filename);
}
catch (Exception ex)
{
if (Crystallography.AssemblyState.IsDebug)
MessageBox.Show(ex.ToString());
return;
}
try { Crystal = ConvertCrystalData.ConvertToCrystal(filename); }
catch (Exception ex) { if (AssemblyState.IsDebug) MessageBox.Show(ex.ToString()); return; }
}

#region ドラッグドロップイベント
Expand Down Expand Up @@ -369,6 +362,69 @@ private void strainControlToolStripMenuItem_Click(object sender, EventArgs e)
formStrain.Visible = !formStrain.Visible;
}

/// <summary>
/// 空間群P1に変換
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void convertToP1ToolStripMenuItem_Click(object sender, EventArgs e)
{
toSuperStructure(1, 1, 1);
}

//超構造に変換
private void convertToSuperstructureToolStripMenuItem_Click(object sender, EventArgs e)
{
var dlg = new FormSuperStructure();
if(dlg.ShowDialog()== DialogResult.OK)
toSuperStructure(dlg.A, dlg.B, dlg.C);
}

private void toSuperStructure(int _u, int _v, int _w)
{
GenerateFromInterface();
crystal.SymmetrySeriesNumber = 1;

var temp_atoms = new List<Atoms>();
foreach (var atoms in Crystal.Atoms)
{
int n = 0;
foreach (var atom in atoms.Atom)
{
for (double u = 0; u < _u; u++)
for (double v = 0; v < _v; v++)
for (double w = 0; w < _w; w++)
{
var x = (atom.X + u) / _u;
var y = (atom.Y + v) / _v;
var z = (atom.Z + w) / _w;

var x_err = atoms.X_err / _u;
var y_err = atoms.Y_err / _v;
var z_err = atoms.Z_err / _w;

temp_atoms.Add(new Atoms(
atoms.Label.TrimEnd() + "_" + n.ToString(),
atoms.AtomicNumber, atoms.SubNumberXray, atoms.SubNumberElectron, atoms.Isotope,
1,
new Vector3DBase(x, y, z), new Vector3DBase(x_err, y_err, z_err),
atoms.Occ, atoms.Occ_err,
atoms.Dsf,
atoms.Material,
atoms.Radius, atoms.GLEnabled, atoms.ShowLabel));
n++;
}
}
}
crystal.A *= _u;
crystal.B *= _v;
crystal.C *= _w;
crystal.Atoms = temp_atoms.ToArray();

SetToInterface(true);
GenerateFromInterface();
}

#endregion 右クリックメニュー

#region キーボードイベント
Expand Down Expand Up @@ -664,5 +720,10 @@ private void button1_Click(object sender, EventArgs e)
{
GenerateFromInterface();
}

private void clearAllDataToolStripMenuItem_Click(object sender, EventArgs e)
{

}
}
}
Loading

0 comments on commit 3efeee2

Please sign in to comment.