ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/gr2lib/trunk/gr2lib/core/coretypes/implementation/ArtToolInfo.cs
Revision: 106
Committed: Sat Jul 17 14:52:37 2010 UTC (12 years, 4 months ago) by william
File size: 4625 byte(s)
Log Message:
implement Granny2ExceptionWriter

File Contents

# User Rev Content
1 william 70 using System;
2     using System.Collections.Generic;
3     using System.Text;
4     using gr2lib.core.typedefs;
5     using gr2lib.core.helpers;
6     using Microsoft.Xna.Framework;
7 william 79 using gr2lib.core.interfaces;
8 william 95 using System.Diagnostics;
9 william 106 using gr2lib.core.exceptions;
10 william 70 namespace gr2lib.core.coretypes.implementation
11     {
12    
13 william 86
14 william 70 public class ArtToolInfo : IArtToolInfo
15     {
16 william 82 private FilePath _fromArtToolName;
17     private granny_int32 _artToolMajorRevision;
18     private granny_int32 _artToolMinorRevision;
19     private granny_real32 _unitsPerMeter;
20 william 70
21    
22 william 79
23 william 86
24 william 82 private Vector3 _Origin;
25     private Vector3 _Right;
26     private Vector3 _Up;
27     private Vector3 _Back;
28 william 70
29     public ArtToolInfo()
30     {
31 william 73 this.FromArtToolName = "";
32     this.ArtToolMajorRevision = 0;
33     this.ArtToolMinorRevision = 0;
34     this.UnitsPerMeter = 1;
35 william 83 //this.ExtendedData = IntPtr.Zero;
36     //this.NativePointer = IntPtr.Zero;
37 william 73 this.Origin = new Vector3(0, 0, 0);
38     this.Right = new Vector3(0, 0, 0);
39     this.Up = new Vector3(0, 0, 0);
40     this.Back = new Vector3(0, 0, 0);
41    
42    
43 william 70 }
44     internal static ArtToolInfo ReadFromMemory(IntPtr pointer)
45     {
46 william 86 try
47     {
48    
49     if (pointer == IntPtr.Zero) return null;
50     native.ArtToolInfo native = Helpers.ReadFromMemory<native.ArtToolInfo>(pointer);
51     ArtToolInfo managed = ReadFromNative(native);
52     managed.NativePointer = pointer;
53     return managed;
54     }
55 william 106 catch (Exception ex)
56 william 86 {
57 william 95 StackTrace st = new StackTrace(true);
58 william 102 #if ENABLE_EXCEPTION_OUTPUT_TO_CONSOLE
59 william 106 Granny2ExceptionWriter.WriteToConsole(ex,st);
60 william 102 #endif
61 william 86 return default(ArtToolInfo);
62     }
63 william 70 }
64     internal static ArtToolInfo ReadFromNative(gr2lib.core.coretypes.native.ArtToolInfo native)
65     {
66 william 86 try
67     {
68     ArtToolInfo managed = new ArtToolInfo();
69     managed.FromArtToolName = string.IsNullOrEmpty(native.FromArtToolName) ? "{null}" : native.FromArtToolName;
70     managed.ArtToolMajorRevision = native.ArtToolMajorRevision;
71     managed.ArtToolMinorRevision = native.ArtToolMinorRevision;
72     //managed.ArtToolPointerSize = native.ArtToolPointerSize;
73     managed.UnitsPerMeter = native.UnitsPerMeter;
74     managed.Origin = new Vector3(native.Origin.X, native.Origin.Y, native.Origin.Z);
75     managed.Right = new Vector3(native.Right.X, native.Right.Y, native.Right.Z);
76     managed.Up = new Vector3(native.Up.X, native.Up.Y, native.Up.Z);
77     managed.Back = new Vector3(native.Back.X, native.Back.Y, native.Back.Z);
78     managed.ExtendedData = native.ExtendedData;
79     //managed.OnInvalidate();
80     return managed;
81     }
82 william 106 catch (Exception ex)
83 william 86 {
84 william 95 StackTrace st = new StackTrace(true);
85 william 102 #if ENABLE_EXCEPTION_OUTPUT_TO_CONSOLE
86 william 106 Granny2ExceptionWriter.WriteToConsole(ex,st);
87 william 102 #endif
88 william 86 return default(ArtToolInfo);
89     }
90 william 70 }
91    
92     #region IArtToolInfo Members
93 william 75 public FilePath FromArtToolName { get { return _fromArtToolName; } set { _fromArtToolName = value; } }
94 william 70 public granny_int32 ArtToolMajorRevision { get { return _artToolMajorRevision; } set { _artToolMajorRevision = value; } }
95     public granny_int32 ArtToolMinorRevision { get { return _artToolMinorRevision; } set { _artToolMinorRevision = value; } }
96     public granny_real32 UnitsPerMeter { get { return _unitsPerMeter; } set { _unitsPerMeter = value; } }
97     public Vector3 Origin { get { return _Origin; } set { _Origin = value; } }
98     public Vector3 Right { get { return _Right; } set { _Right = value; } }
99     public Vector3 Up { get { return _Up; } set { _Up = value; } }
100     public Vector3 Back { get { return _Back; } set { _Back = value; } }
101 william 86
102 william 70 #endregion
103 william 79
104     #region INativePointer Members
105     private IntPtr _NativePointer;
106     public IntPtr NativePointer { get { return _NativePointer; } set { _NativePointer = value; } }
107     #endregion
108 william 82
109     #region IExtendedData Members
110     private IntPtr _ExtendedData;
111     public IntPtr ExtendedData { get { return _ExtendedData; } set { _ExtendedData = value; } }
112     #endregion
113    
114 william 70 }
115     }
116 william 73