/[gr2lib]/trunk/gr2lib/core/coretypes/implementation/ArtToolInfo.cs
ViewVC logotype

Contents of /trunk/gr2lib/core/coretypes/implementation/ArtToolInfo.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 186 - (show annotations) (download)
Sat Jul 24 02:23:18 2010 UTC (9 years, 4 months ago) by william
File size: 11566 byte(s)
continue to add xml documentation

1 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 using gr2lib.core.interfaces;
8 using System.Diagnostics;
9 using gr2lib.core.exceptions;
10 using System.ComponentModel;
11 using gr2lib.core.ui.helpers;
12 using System.Drawing.Design;
13 using gr2lib.core.ui.typeeditors;
14 namespace gr2lib.core.coretypes.implementation
15 {
16 #region public class ArtToolInfoVersion
17 /// <summary>
18 /// ArtToolInfoVersion class
19 /// </summary>
20 public class ArtToolInfoVersion : IArtToolInfoVersion
21 {
22 /// <summary>
23 /// default constructor
24 /// </summary>
25 public ArtToolInfoVersion()
26 {
27 this.Major = 0;
28 this.Minor = 0;
29 }
30 /// <summary>
31 /// default constructor - specify: Major, Minor
32 /// </summary>
33 public ArtToolInfoVersion(int Major, int Minor)
34 {
35 this.Major = Major;
36 this.Minor = Minor;
37 }
38
39 private int _Major;
40 /// <summary>
41 /// Get/set the major
42 /// </summary>
43 [RefreshPropertiesAttribute(RefreshProperties.All)]
44 public int Major
45 {
46 get { return _Major; }
47 set { _Major = value; }
48 }
49 private int _Minor;
50 /// <summary>
51 /// Get/set the minor
52 /// </summary>
53 [RefreshPropertiesAttribute(RefreshProperties.All)]
54 public int Minor
55 {
56 get { return _Minor; }
57 set { _Minor = value; }
58 }
59 /// <summary>
60 /// string representation
61 /// </summary>
62 /// <returns></returns>
63 public override string ToString()
64 {
65 return string.Format("{0}.{1}", Major, Minor);
66 }
67 }
68 #endregion
69
70 #region public class ArtToolInfoVector
71 /// <summary>
72 /// ArtToolInfoVector class
73 /// </summary>
74 public class ArtToolInfoVector : IArtToolInfoVector
75 {
76 private Vector3 _Origin;
77 private Vector3 _Right;
78 private Vector3 _Up;
79 private Vector3 _Back;
80
81 /// <summary>
82 /// default constructor
83 /// </summary>
84 public ArtToolInfoVector()
85 {
86 this.Origin = new Vector3();
87 this.Right = new Vector3();
88 this.Up = new Vector3();
89 this.Back = new Vector3();
90 }
91 /// <summary>
92 /// default constructor - specify: Origin, Right, Up, Back
93 /// </summary>
94 public ArtToolInfoVector(Vector3 Origin, Vector3 Right, Vector3 Up, Vector3 Back)
95 {
96 this.Origin = Origin;
97 this.Right = Right;
98 this.Up = Up;
99 this.Back = Back;
100 }
101 /// <summary>
102 /// Get/set the Origin
103 /// </summary>
104 [RefreshPropertiesAttribute(RefreshProperties.All)]
105 public Vector3 Origin { get { return _Origin; } set { _Origin = value; } }
106 /// <summary>
107 /// Get/set the Right
108 /// </summary>
109 [RefreshPropertiesAttribute(RefreshProperties.All)]
110 public Vector3 Right { get { return _Right; } set { _Right = value; } }
111 /// <summary>
112 /// Get/set the Up
113 /// </summary>
114 [RefreshPropertiesAttribute(RefreshProperties.All)]
115 public Vector3 Up { get { return _Up; } set { _Up = value; } }
116 /// <summary>
117 /// Get/set the Back
118 /// </summary>
119 [RefreshPropertiesAttribute(RefreshProperties.All)]
120 public Vector3 Back { get { return _Back; } set { _Back = value; } }
121
122 /// <summary>
123 /// get string representation
124 /// </summary>
125 /// <returns></returns>
126 public override string ToString()
127 {
128 string format = "0.00";
129
130 string origin = "{" + string.Format("{0:" + format + "},{1:" + format + "},{2:" + format + "}", Origin.x, Origin.y, Origin.z) + "}";
131 string right = "{" + string.Format("{0:" + format + "},{1:" + format + "},{2:" + format + "}", Right.x, Right.y, Right.z) + "}";
132 string up = "{" + string.Format("{0:" + format + "},{1:" + format + "},{2:" + format + "}", Up.x, Up.y, Up.z) + "}";
133 string back = "{" + string.Format("{0:" + format + "},{1:" + format + "},{2:" + format + "}", Back.x, Back.y, Back.z) + "}";
134
135 return string.Format("{0} ; {1} ; {2} ; {3}", origin, right, up, back);
136 }
137
138
139
140 }
141 #endregion
142
143 /// <summary>
144 /// ArtToolInfo class
145 /// </summary>
146 public class ArtToolInfo : GrannyRigParentResource,IArtToolInfo
147 {
148 private StringType _fromArtToolName;
149 //private granny_int32 _artToolMajorRevision;
150 //private granny_int32 _artToolMinorRevision;
151 private NumericType<float> _unitsPerMeter;
152
153
154
155
156 //private Vector3 _Origin;
157 //private Vector3 _Right;
158 //private Vector3 _Up;
159 //private Vector3 _Back;
160
161 /// <summary>
162 /// default constructor
163 /// </summary>
164 public ArtToolInfo() : base("Art Tool Info")
165 {
166 this.FromArtToolName = "";
167 this.ToolVersion = new ArtToolInfoVersion();
168
169 this.ArtToolMajorRevision = 0;
170 this.ArtToolMinorRevision = 0;
171 this.UnitsPerMeter = 1;
172 //this.ExtendedData = IntPtr.Zero;
173 //this.NativePointer = IntPtr.Zero;
174 this.Vector = new ArtToolInfoVector();
175
176 //this.Origin = new Vector3(0, 0, 0);
177 //this.Right = new Vector3(0, 0, 0);
178 //this.Up = new Vector3(0, 0, 0);
179 //this.Back = new Vector3(0, 0, 0);
180
181
182
183 }
184 internal static ArtToolInfo ReadFromMemory(IntPtr pointer)
185 {
186 try
187 {
188
189 if (pointer == IntPtr.Zero) return null;
190 native.ArtToolInfo native = Helpers.ReadFromMemory<native.ArtToolInfo>(pointer);
191 ArtToolInfo managed = ReadFromNative(native);
192 managed.NativePointer = pointer;
193 return managed;
194 }
195 catch (Exception ex)
196 {
197 StackTrace st = new StackTrace(true);
198 #if ENABLE_EXCEPTION_OUTPUT_TO_CONSOLE
199 Granny2ExceptionWriter.WriteToConsole(ex,st);
200 #endif
201 return default(ArtToolInfo);
202 }
203 }
204 internal static ArtToolInfo ReadFromNative(gr2lib.core.coretypes.native.ArtToolInfo native)
205 {
206 try
207 {
208 ArtToolInfo managed = new ArtToolInfo();
209 managed.FromArtToolName = string.IsNullOrEmpty(native.FromArtToolName) ? "{null}" : native.FromArtToolName;
210 managed.ToolVersion = new ArtToolInfoVersion();
211 managed.ArtToolMajorRevision = native.ArtToolMajorRevision;
212 managed.ArtToolMinorRevision = native.ArtToolMinorRevision;
213 //managed.ArtToolPointerSize = native.ArtToolPointerSize;
214 managed.UnitsPerMeter = new NumericType<float>(native.UnitsPerMeter);
215 managed.Origin = new Vector3(native.Origin.X, native.Origin.Y, native.Origin.Z);
216 managed.Right = new Vector3(native.Right.X, native.Right.Y, native.Right.Z);
217 managed.Up = new Vector3(native.Up.X, native.Up.Y, native.Up.Z);
218 managed.Back = new Vector3(native.Back.X, native.Back.Y, native.Back.Z);
219 managed.ExtendedData = native.ExtendedData;
220 //managed.OnInvalidate();
221 return managed;
222 }
223 catch (Exception ex)
224 {
225 StackTrace st = new StackTrace(true);
226 #if ENABLE_EXCEPTION_OUTPUT_TO_CONSOLE
227 Granny2ExceptionWriter.WriteToConsole(ex,st);
228 #endif
229 return default(ArtToolInfo);
230 }
231 }
232
233 #region IArtToolInfo Members
234 /// <summary>
235 /// Get/set ArtTool Name
236 /// </summary>
237 [RefreshPropertiesAttribute(RefreshProperties.All)]
238 public StringType FromArtToolName { get { return _fromArtToolName; } set { _fromArtToolName = value; } }
239 /// <summary>
240 /// Get/set ArtTool Major
241 /// </summary>
242 [RefreshPropertiesAttribute(RefreshProperties.All)]
243 public int ArtToolMajorRevision { get { return _ToolVersion.Major; } set { _ToolVersion.Major = value; } }
244 /// <summary>
245 /// Get/set ArtTool Minor
246 /// </summary>
247 [RefreshPropertiesAttribute(RefreshProperties.All)]
248 public int ArtToolMinorRevision { get { return _ToolVersion.Minor; } set { _ToolVersion.Minor = value; } }
249
250 private ArtToolInfoVersion _ToolVersion;
251 /// <summary>
252 /// Get/set ArtTool Version
253 /// </summary>
254 [RefreshPropertiesAttribute(RefreshProperties.All)]
255 public ArtToolInfoVersion ToolVersion { get { return _ToolVersion; } set { _ToolVersion = value; } }
256
257 /// <summary>
258 ///Get/set ArtTool UnitsPerMeter
259 /// </summary>
260 [RefreshPropertiesAttribute(RefreshProperties.All)]
261 [Editor(typeof(UINumericEditor<NumericType<float>,float>), typeof(UITypeEditor))]
262 public NumericType<float> UnitsPerMeter { get { return _unitsPerMeter; } set { _unitsPerMeter = value; } }
263
264 /// <summary>
265 ///Get/set ArtTool Origin
266 /// </summary>
267 [RefreshPropertiesAttribute(RefreshProperties.All)]
268 public Vector3 Origin { get { return Vector.Origin; } set { Vector.Origin = value; } }
269 /// <summary>
270 ///Get/set ArtTool Right
271 /// </summary>
272 [RefreshPropertiesAttribute(RefreshProperties.All)]
273 public Vector3 Right { get { return Vector.Right; } set { Vector.Right = value; } }
274 /// <summary>
275 ///Get/set ArtTool Up
276 /// </summary>
277 [RefreshPropertiesAttribute(RefreshProperties.All)]
278 public Vector3 Up { get { return Vector.Up; } set { Vector.Up = value; } }
279 /// <summary>
280 ///Get/set ArtTool Back
281 /// </summary>
282 [RefreshPropertiesAttribute(RefreshProperties.All)]
283 public Vector3 Back { get { return Vector.Back; } set { Vector.Back = value; } }
284
285 private ArtToolInfoVector _Vector;
286 /// <summary>
287 ///Get/set ArtTool Vector
288 /// </summary>
289 [RefreshPropertiesAttribute(RefreshProperties.All)]
290 public ArtToolInfoVector Vector
291 {
292 get { return _Vector; }
293 set { _Vector = value; }
294 }
295 #endregion
296 #region INativePointer Members
297 private IntPtr _NativePointer;
298 /// <summary>
299 /// When used in a derived class, gets the native pointer for this instance
300 /// </summary>
301 public IntPtr NativePointer { get { return _NativePointer; } set { _NativePointer = value; } }
302 #endregion
303
304 #region IExtendedData Members
305 private IntPtr _ExtendedData;
306 /// <summary>
307 /// When used in a derived class, gets the ExtendedData pointer for this instance
308 /// </summary>
309 public IntPtr ExtendedData { get { return _ExtendedData; } set { _ExtendedData = value; } }
310 #endregion
311
312 }
313 }
314

  ViewVC Help
Powered by ViewVC 1.1.22