|
1 | 1 | using MathNet.Numerics.LinearAlgebra.Double; |
| 2 | +using MemoryPack; |
2 | 3 | using System; |
3 | 4 | using System.Collections.Generic; |
4 | 5 | using System.Drawing; |
|
9 | 10 | namespace Crystallography; |
10 | 11 |
|
11 | 12 | [Serializable] |
12 | | -public class Profile : ICloneable |
| 13 | +[MemoryPackable] |
| 14 | +public partial class Profile : ICloneable |
13 | 15 | { |
14 | 16 | #region プロパティ、フィールド |
15 | 17 | public string text; |
16 | 18 |
|
17 | | - public List<PointD> Pt; |
18 | | - public List<PointD> Err; |
| 19 | + public List<PointD> Pt=[]; |
| 20 | + public List<PointD> Err=[]; |
19 | 21 |
|
| 22 | + [MemoryPackIgnore] |
20 | 23 | public Color Color = Color.Blue; |
21 | 24 |
|
22 | 25 | public float LineWidth = 1f; |
23 | 26 |
|
| 27 | + [MemoryPackIgnore] |
24 | 28 | public RectangleD Range => new(new PointD(Pt.Min(p => p.X), Pt.Min(p => p.Y)), new PointD(Pt.Max(p => p.X), Pt.Max(p => p.Y))); |
| 29 | + [MemoryPackIgnore] |
25 | 30 | public double MaxX => Pt.Max(p => p.X); |
| 31 | + [MemoryPackIgnore] |
26 | 32 | public double MinX => Pt.Min(p => p.X); |
| 33 | + [MemoryPackIgnore] |
27 | 34 | public double MaxY => Pt.Max(p => p.Y); |
| 35 | + [MemoryPackIgnore] |
28 | 36 | public double MinY => Pt.Min(p => p.Y); |
29 | 37 |
|
30 | 38 | #endregion |
31 | 39 |
|
32 | 40 | #region コンストラクタ |
| 41 | + [MemoryPackConstructor] |
33 | 42 | public Profile() |
34 | 43 | { |
35 | 44 | Pt = []; |
@@ -423,29 +432,37 @@ public enum BackgroundMode { BSplineCurve, ReferrenceProfile } |
423 | 432 |
|
424 | 433 | #endregion |
425 | 434 |
|
426 | | -[Serializable] |
427 | | -public class DiffractionProfile2 : ICloneable |
| 435 | +//[Serializable] |
| 436 | +[MemoryPackable] |
| 437 | +public partial class DiffractionProfile2 : ICloneable |
428 | 438 | { |
| 439 | + public static byte ID => 2; |
| 440 | + |
429 | 441 | #region マスク関連ここから |
430 | 442 | [Serializable] |
431 | | - public class MaskingRange |
| 443 | + [MemoryPackable] |
| 444 | + public partial class MaskingRange |
432 | 445 | { |
433 | 446 | public double[] X = new double[2]; |
434 | 447 |
|
| 448 | + [MemoryPackConstructor] |
435 | 449 | public MaskingRange() => X[0] = X[1] = 0; |
436 | 450 |
|
437 | 451 | public MaskingRange(double x1, double x2) |
438 | 452 | { |
439 | 453 | X[0] = x1; |
440 | 454 | X[1] = x2; |
441 | 455 | } |
442 | | - |
| 456 | + |
| 457 | + [MemoryPackIgnore] |
443 | 458 | public double Maximum => Math.Max(X[0], X[1]); |
444 | | - |
| 459 | + |
| 460 | + [MemoryPackIgnore] |
445 | 461 | public double Minimum => Math.Min(X[0], X[1]); |
446 | | - |
| 462 | + |
447 | 463 | public override string ToString() |
448 | 464 | => X[0] < X[1] ? $"{X[0]:g8} - {X[1]:g8}" : $"{X[1]:g8} - {X[0]:g8}"; |
| 465 | + |
449 | 466 | } |
450 | 467 |
|
451 | 468 | public List<MaskingRange> maskingRanges = []; |
@@ -534,12 +551,13 @@ public object Clone() |
534 | 551 | #region プロパティ |
535 | 552 |
|
536 | 553 | #region プロファイル |
| 554 | + |
537 | 555 | /// <summary> |
538 | 556 | /// ソースプロファイル () |
539 | 557 | /// </summary> |
540 | 558 | public Profile SourceProfile; |
541 | 559 |
|
542 | | - public PointD[] BgPoints; |
| 560 | + public PointD[] BgPoints = []; |
543 | 561 |
|
544 | 562 | /// <summary> |
545 | 563 | /// 軸変換後のプロファイル. SetConvertedProfile()を呼び出すことで生成される. |
@@ -1257,7 +1275,8 @@ public PointD[] ConvertDestToSrc(PointD[] pt) |
1257 | 1275 | #region HorizontalAxisProperty プロファイルの性質を表す構造体 |
1258 | 1276 |
|
1259 | 1277 | [Serializable] |
1260 | | -public record struct HorizontalAxisProperty |
| 1278 | +[MemoryPackable] |
| 1279 | +public partial record struct HorizontalAxisProperty |
1261 | 1280 | { |
1262 | 1281 | #region プロパティ |
1263 | 1282 | /// <summary> |
@@ -2222,7 +2241,7 @@ public DiffractionProfile() |
2222 | 2241 |
|
2223 | 2242 | ElectronAccVolatage = 200; |
2224 | 2243 |
|
2225 | | - ColorARGB = null; |
| 2244 | + ColorARGB = Color.Blue.ToArgb(); |
2226 | 2245 | } |
2227 | 2246 |
|
2228 | 2247 |
|
|
0 commit comments