BioCore  5.0.0
A Windows .NET microscopy library and application for viewing, editing, and annotating images.
Loading...
Searching...
No Matches
Microscope.cs
Go to the documentation of this file.
1using System.Reflection;
2using AForge;
3namespace BioCore
4{
5 public class Stage
6 {
7 public static Type stageType;
8 public static Type axisType;
9 public static object xAxis;
10 public static object yAxis;
11 public static double minX;
12 public static double maxX;
13 public static double minY;
14 public static double maxY;
15 /* Initializing the stage. */
16 public Stage()
17 {
18 PointD d = GetPosition();
19 x = GetPositionX();
20 y = GetPositionY();
22 }
23
24 private double x;
25 private double y;
26 public double X
27 {
28 get
29 {
30 return x;
31 }
32 }
33 public double Y
34 {
35 get
36 {
37 return y;
38 }
39 }
40 public int moveWait = 250;
42 private void MoveWait()
43 {
44 Thread.Sleep(moveWait);
45 }
50 public void SetPosition(double px, double py)
51 {
52 x = px;
53 y = py;
54 }
58 public void SetPositionX(double px)
59 {
60 x = px;
61 SetPosition(px, y);
62 }
66 public void SetPositionY(double py)
67 {
68 y = py;
69 SetPosition(x, py);
70 }
74 public double GetPositionX()
75 {
76 x = GetPosition().X;
77 return x;
78 }
82 public double GetPositionY()
83 {
84 y = GetPosition().Y;
85 return y;
86 }
90 public PointD GetPosition()
91 {
92 return new PointD(x, y);
93 }
97 public void MoveUp(double m)
98 {
99 double y = GetPositionY() - m;
100 SetPositionY(y);
101 }
105 public void MoveDown(double m)
106 {
107 double y = GetPositionY() + m;
108 SetPositionY(y);
109 }
113 public void MoveRight(double m)
114 {
115 double x = GetPositionX() + m;
116 SetPositionX(x);
117 }
121 public void MoveLeft(double m)
122 {
123 double x = GetPositionX() - m;
124 SetPositionX(x);
125 }
126 public void UpdateSWLimit()
127 {
128
129 }
136 public void SetSWLimit(double xmin, double xmax, double ymin, double ymax)
137 {
139 Recorder.AddLine("Microscope.Focus.SetSWLimit(" + xmin + "," + xmax + "," + ymin + "," + ymax + ");");
140 }
141 }
142
143 public class Focus
144 {
145 public static Type focusType;
146 public static Type axisType;
147 public static object focus;
148 public static double upperLimit;
149 public static double lowerLimit;
150 private static double z;
151 public Focus()
152 {
153 }
157 public void SetFocus(double f)
158 {
160 Recorder.AddLine("Microscope.Focus.SetFocus(" + f + ");");
161 }
165 public double GetFocus()
166 {
167 return z;
168 }
172 public PointD GetSWLimit()
173 {
174 return new PointD(lowerLimit, upperLimit);
175 }
180 public void SetSWLimit(double xd, double yd)
181 {
182 upperLimit = xd;
183 lowerLimit = yd;
185 Recorder.AddLine("Microscope.Focus.SetSWLimit(" + xd + "," + yd + ");");
186 }
187 }
188
189 public class Objectives
190 {
192 public static Type changerType = null;
193 public static object changer;
194
195 public Objectives()
196 {
197 }
198 public class Objective
199 {
200 public Dictionary<string, object> config = new Dictionary<string, object>();
201 public string Name = "";
202 public string UniqueName = "";
203 public string ElementType = "";
204 public bool Oil = false;
205 public int Magnification = 0;
206 public float NumericAperture = 0;
207 public int Index;
208 public string Modes = "";
209 public string Features = "";
210 public double LocateExposure = 50;
211 public int WorkingDistance = 0;
212 public double AcquisitionExposure = 50;
213 public string Configuration = "";
214 public double MoveAmountL = 40;
215 public double MoveAmountR = 10;
216 public double FocusMoveAmount = 0.02;
217 public double ViewWidth;
218 public double ViewHeight;
219 public Objective(object o, int index)
220 {
221 Index = index;
222 }
223 public Objective()
224 {
225 }
226 public override string ToString()
227 {
228 return Name.ToString() + " " + Index;
229 }
230 }
231 private int index;
232 public int moveWait = 1000;
233 private void MoveWait()
234 {
235 Thread.Sleep(moveWait);
236 }
237 public int Index
238 {
239 get
240 {
241 return GetPosition();
242 }
243 set
244 {
245 SetPosition(value);
246 }
247 }
248 public void SetPosition(int index)
249 {
250 this.index = index;
251 }
252 public int GetPosition()
253 {
254 return index;
255 }
257 {
258 return List[index];
259 }
260 }
261 public class TLShutter
262 {
263 public static Type tlType;
264 public static object tlShutter = null;
265 public static int position;
266 public TLShutter()
267 {
268
269 }
270 public short GetPosition()
271 {
272 return (short)position;
273 }
274 public void SetPosition(int p)
275 {
276 position = p;
278 Recorder.AddLine("Microscope.TLShutter.SetPosition(" + p + ");");
279 }
280 }
281
282 public class RLShutter
283 {
284 public static Type rlType;
285 public static object rlShutter = null;
286 public static int position;
287 public RLShutter()
288 {
289 }
290 public short GetPosition()
291 {
292 return (short)position;
293 }
294 public void SetPosition(int p)
295 {
296 position = p;
298 Recorder.AddLine("Microscope.RLShutter.SetPosition(" + p + ");");
299 }
300 }
301
302 public static class Microscope
303 {
304 public enum Actions
305 {
306 StageUp,
308 StageDown,
309 StageLeft,
314 FocusUp,
315 FocusDown,
316 TL,
317 RL,
319 Locate,
320 }
321 public static bool redraw = false;
322 public static Focus Focus = null;
323 public static Stage Stage = null;
324 public static Objectives Objectives = null;
325 public static TLShutter TLShutter = null;
326 public static RLShutter RLShutter = null;
327 public static double UpperLimit, LowerLimit, fInterVal;
328 public static object CmdSetMode = null;
329 public static bool initialized = false;
330 public static bool ArrowKeysEnabled = true;
331 public static Point3D defaultPos = new Point3D(30000, 30000, 23900);
332 public static Assembly dll = null;
333 public static Dictionary<string, Type> Types = new Dictionary<string, Type>();
334 public static object root = null;
339 public static void Initialize()
340 {
341 if (initialized)
342 return;
344 PointD.SetLimits(Stage.minX, Stage.maxX, Stage.minY, Stage.maxY);
345 Focus = new Focus();
346 Stage = new Stage();
347 Objectives = new Objectives();
348 TLShutter = new TLShutter();
349 RLShutter = new RLShutter();
350 initialized = true;
351 }
356 public static Point3D GetPosition()
357 {
358 if (Stage == null)
359 return new Point3D(0, 0, 0);
360 PointD p = Stage.GetPosition();
361 double f = Focus.GetFocus();
362 return new Point3D(p.X, p.Y, f);
363 }
364
368 public static void SetPosition(Point3D p)
369 {
370 Stage.SetPosition(p.X, p.Y);
371 Focus.SetFocus(p.Z);
372 Microscope.redraw = true;
373 }
374
381 public static void SetPosition(PointD p)
382 {
383 Stage.SetPosition(p.X, p.Y);
384 Microscope.redraw = true;
385 }
387 public static void OpenRL()
388 {
389 //If shutter is closed we open it.
390 if (RLShutter.GetPosition() == 0)
392 }
393
395 public static void OpenTL()
396 {
397 //If shutter is closed we open it.
398 if (TLShutter.GetPosition() == 0)
400 }
401
403 public static void CloseRL()
404 {
405 //If shutter is open then we close it.
406 if (RLShutter.GetPosition() == 0)
408 }
409
411 public static void CloseTL()
412 {
413 //If shutter is open then we close it.
414 if (TLShutter.GetPosition() == 0)
416 }
417
421 public static void SetTL(uint tl)
422 {
423 TLShutter.SetPosition((short)tl);
424 }
425
429 public static void SetRL(uint tr)
430 {
431 RLShutter.SetPosition((short)tr);
432 }
433
437 public static int GetTL()
438 {
439 return TLShutter.GetPosition();
440 }
441
445 public static int GetRL()
446 {
447 return RLShutter.GetPosition();
448 }
449
453 public static void MoveUp(double d)
454 {
455 Stage.MoveUp(d);
456 }
457
461 public static void MoveRight(double d)
462 {
463 Stage.MoveRight(d);
464 }
465
469 public static void MoveDown(double d)
470 {
471 Stage.MoveDown(d);
472 }
473
477 public static void MoveLeft(double d)
478 {
479 Stage.MoveLeft(d);
480 }
482 public static void MoveFieldUp()
483 {
485 }
486
488 public static void MoveFieldRight()
489 {
491 }
492
494 public static void MoveFieldDown()
495 {
497 }
498
500 public static void MoveFieldLeft()
501 {
503 }
504
508 public static void SetFocus(double d)
509 {
510 Focus.SetFocus(d);
511 }
512
516 public static double GetFocus()
517 {
518 return Focus.GetFocus();
519 }
520 }
521
522}
double GetFocus()
void SetFocus(double f)
void SetSWLimit(double xd, double yd)
static double upperLimit
PointD GetSWLimit()
static double lowerLimit
static object focus
static Type axisType
static Type focusType
static void SetPosition(PointD p)
static void MoveDown(double d)
static Dictionary< string, Type > Types
static void SetPosition(Point3D p)
static void OpenRL()
If the shutter is closed, open it.
static void SetRL(uint tr)
static void CloseRL()
If the shutter is open, then close it.
static bool initialized
static void SetFocus(double d)
static double GetFocus()
static bool redraw
static void MoveRight(double d)
static void CloseTL()
If the shutter is open, then we close it.
static double UpperLimit
static TLShutter TLShutter
static void OpenTL()
If the shutter is closed, open it.
static Point3D GetPosition()
static void MoveLeft(double d)
static double LowerLimit
static object root
static Stage Stage
static void MoveUp(double d)
static void MoveFieldUp()
Move the field up by the height of the current objective.
static Objectives Objectives
static bool ArrowKeysEnabled
static Focus Focus
static Point3D defaultPos
static double fInterVal
static void MoveFieldRight()
Move the field right by the width of the view.
static void MoveFieldDown()
Move the field down by the height of the current objective.
static int GetTL()
static RLShutter RLShutter
static Assembly dll
static void MoveFieldLeft()
Move the field left by the width of the view.
static void Initialize()
static object CmdSetMode
static int GetRL()
static void SetTL(uint tl)
Dictionary< string, object > config
Objective(object o, int index)
override string ToString()
List< Objective > List
Objective GetObjective()
static object changer
static Type changerType
void SetPosition(int index)
static object rlShutter
static int position
static Type rlType
void SetPosition(int p)
static void AddLine(string s)
Definition Recorder.cs:6
static bool recordMicroscope
Definition Recorder.cs:11
void MoveDown(double m)
static object xAxis
Definition Microscope.cs:9
static Type axisType
Definition Microscope.cs:8
static object yAxis
Definition Microscope.cs:10
void SetPosition(double px, double py)
Definition Microscope.cs:50
void MoveLeft(double m)
double GetPositionX()
Definition Microscope.cs:74
static double minY
Definition Microscope.cs:13
void SetPositionX(double px)
Definition Microscope.cs:58
void MoveRight(double m)
static double maxX
Definition Microscope.cs:12
void MoveUp(double m)
Definition Microscope.cs:97
void SetSWLimit(double xmin, double xmax, double ymin, double ymax)
double GetPositionY()
Definition Microscope.cs:82
static double minX
Definition Microscope.cs:11
void UpdateSWLimit()
void SetPositionY(double py)
Definition Microscope.cs:66
PointD GetPosition()
Definition Microscope.cs:90
static double maxY
Definition Microscope.cs:14
static Type stageType
Definition Microscope.cs:7
static object tlShutter
static Type tlType
static int position
void SetPosition(int p)