2using System.Collections.Generic;
5using System.Threading.Tasks;
6using System.Windows.Forms;
7using System.Globalization;
9using System.Diagnostics;
10using System.Threading;
11using System.Reflection;
14using Point = AForge.Point;
15using RectangleD = AForge.RectangleD;
16using Bitmap = AForge.Bitmap;
23 public static double minX;
24 public static double maxX;
25 public static double minY;
26 public static double maxY;
28 public Stage(
object st)
30 if (Properties.Settings.Default.LibPath.Contains(
"MTB"))
59 public int moveWait = 250;
60 private void MoveWait()
62 Thread.Sleep(moveWait);
72 Recorder.AddLine(
"Microscope.Stage.SetPosition(" + px +
"," + py +
");");
75 if(Properties.Settings.Default.PMicroscope)
77 Microscope.pMicroscope.SetPosition(
new PointD(px, py));
80 if (Properties.Settings.Default.PycroManager)
82 MicroManager.SetPosition(
new PointD(px, py));
85 if (Properties.Settings.Default.LibPath.Contains(
"MTB"))
89 else if (Properties.Settings.Default.LibPath.Contains(
"Prio"))
91 Microscope.sdk.SetPosition(
new PointD(px, py));
93 if (
App.viewer !=
null)
147 if (Properties.Settings.Default.PMicroscope)
150 Microscope.pMicroscope.GetPosition(out pd,
false);
154 if (Properties.Settings.Default.PycroManager)
157 MicroManager.GetPosition(out pd,
false);
161 if (Properties.Settings.Default.LibPath.Contains(
"MTB"))
165 return new PointD(com.doubles[0], com.doubles[1]);
167 else if (Properties.Settings.Default.LibPath.Contains(
"Prio"))
169 return Microscope.sdk.GetPosition();
171 return new PointD(x, y);
213 if (Properties.Settings.Default.LibPath.Contains(
"MTB"))
217 minX = com.doubles[0];
218 minY = com.doubles[1];
219 maxX = com.doubles[2];
220 maxY = com.doubles[3];
230 public void SetSWLimit(
double xmin,
double xmax,
double ymin,
double ymax)
232 if (Properties.Settings.Default.LibPath.Contains(
"MTB"))
236 new double[] {xmin,xmax,ymin,ymax}));
239 Recorder.AddLine(
"Microscope.Focus.SetSWLimit(" + xmin +
"," + xmax +
"," + ymin +
"," + ymax +
");");
246 public static double upperLimit;
247 public static double lowerLimit;
248 private static double z;
260 Recorder.AddLine(
"Microscope.Focus.SetFocus(" + f +
");");
261 if (Properties.Settings.Default.PMicroscope)
263 PointD p = Microscope.Stage.GetPosition(
true);
264 Microscope.pMicroscope.SetPosition(
new Point3D(p.X,p.Y,f));
267 if (Properties.Settings.Default.PycroManager)
269 PointD p = Microscope.Stage.GetPosition(
true);
270 MicroManager.SetPosition(
new Point3D(p.X, p.Y, f));
273 if (Properties.Settings.Default.LibPath.Contains(
"MTB"))
279 else if (Properties.Settings.Default.LibPath.Contains(
"Prio"))
281 Microscope.sdk.SetZ(f);
283 if (
Automation.Properties.ContainsKey(
"SetFocus"))
306 if (Properties.Settings.Default.PMicroscope)
309 Microscope.pMicroscope.GetPosition3D(out p, update);
312 else if(Properties.Settings.Default.PycroManager)
315 MicroManager.GetPosition3D(out p, update);
318 if (Properties.Settings.Default.LibPath.Contains(
"MTB"))
322 return com.doubles[0];
324 if (Properties.Settings.Default.LibPath.Contains(
"Prio"))
326 return Microscope.sdk.GetZ();
328 if(
Automation.Properties.ContainsKey(
"GetFocus"))
340 if (Properties.Settings.Default.LibPath.Contains(
"MTB"))
344 upperLimit = com.doubles[0];
345 lowerLimit = com.doubles[1];
346 return new PointD(upperLimit,lowerLimit);
348 return new PointD(lowerLimit, upperLimit);
358 if (Properties.Settings.Default.LibPath.Contains(
"MTB"))
362 new double[] { xd, yd }));
367 Recorder.AddLine(
"Microscope.Focus.SetSWLimit(" + xd +
"," + yd +
");");
374 public List<Objective> List =
new List<Objective>();
378 for (
int i = 0; i < count; i++)
386 public Dictionary<string, object> config =
new Dictionary<string, object>();
389 public double LocateExposure = 50;
390 public int WorkingDistance = 0;
391 public double AcquisitionExposure = 50;
392 public string Configuration =
"";
393 public double MoveAmountL = 40;
394 public double MoveAmountR = 10;
395 public double FocusMoveAmount = 0.02;
396 public double ViewWidth;
397 public double ViewHeight;
405 public override string ToString()
407 if (Name ==
"" || Name ==
null)
408 return "Objective " + Index.ToString();
413 public int moveWait = 1000;
416 private void MoveWait()
418 Thread.Sleep(moveWait);
424 return GetPosition();
441 Recorder.AddLine(
"Microscope.Objectives.SetObjective(" + index +
");");
443 if (!Properties.Settings.Default.LibPath.Contains(
"MTB") && !Properties.Settings.Default.LibPath.Contains(
"Prio") &&
Function.Functions.ContainsKey(
"SetO" + index))
449 else if(Properties.Settings.Default.LibPath.Contains(
"MTB"))
455 else if(Properties.Settings.Default.PycroManager)
457 MicroManager.Objectives.SetPosition(index);
461 public int GetPosition()
463 if (Properties.Settings.Default.LibPath.Contains(
"MTB"))
467 return (
int)com.doubles[0];
469 else if (Properties.Settings.Default.LibPath.Contains(
"Prio"))
471 return Microscope.sdk.GetNosePiece();
473 else if(Properties.Settings.Default.PycroManager)
475 return MicroManager.Objectives.GetPosition();
477 else if(!Properties.Settings.Default.PMicroscope && Automation.Properties.ContainsKey(
"GetO1"))
479 if (Function.Functions.ContainsKey(
"GetO7"))
483 b = (bool)Automation.GetProperty(
"Get01");
486 b = (bool)Automation.GetProperty(
"Get02");
489 b = (bool)Automation.GetProperty(
"Get03");
492 b = (bool)Automation.GetProperty(
"Get04");
495 b = (bool)Automation.GetProperty(
"Get05");
498 b = (bool)Automation.GetProperty(
"Get06");
501 b = (bool)Automation.GetProperty(
"Get07");
509 b = (bool)Automation.GetProperty(
"Get01");
512 b = (bool)Automation.GetProperty(
"Get02");
515 b = (bool)Automation.GetProperty(
"Get03");
518 b = (bool)Automation.GetProperty(
"Get04");
521 b = (bool)Automation.GetProperty(
"Get05");
524 b = (bool)Automation.GetProperty(
"Get06");
531 public Objective GetObjective()
536 p = (short)GetPosition();
541 Console.WriteLine(e.ToString());
543 return new Objective();
550 public static Type tlType;
551 public static object tlShutter =
null;
552 public static int position;
561 return (
short)com.doubles[0];
573 Recorder.AddLine(
"Microscope.TLShutter.SetPosition(" + p +
");");
574 if (Properties.Settings.Default.LibPath.Contains(
"MTB"))
580 if (Properties.Settings.Default.LibPath.Contains(
"Prio"))
583 Microscope.sdk.shutterClose();
585 Microscope.sdk.shutterOpen();
592 public static Type tlType;
593 public static object tlShutter =
null;
594 public static int position;
603 if (com.doubles ==
null)
605 return (
short)com.doubles[0];
617 Recorder.AddLine(
"Microscope.TLShutter.SetPosition(" + p +
");");
618 if (Properties.Settings.Default.LibPath.Contains(
"MTB"))
630 public static Type rlType;
631 public static object rlShutter =
null;
632 internal static int position;
641 return (
short)com.doubles[0];
650 if (Properties.Settings.Default.LibPath.Contains(
"MTB"))
657 Recorder.AddLine(
"Microscope.RLShutter.SetPosition(" + p +
");");
670 public double position;
681 if (Properties.Settings.Default.LibPath.Contains(
"MTB"))
683 if (type == Type.HXP)
687 return (
short)com.doubles[0];
689 else if(type == Type.RL)
693 return (
short)com.doubles[0];
695 else if (type == Type.TL)
699 return (
short)com.doubles[0];
711 Recorder.AddLine(
"Microscope.LightSource.SetPosition(" + f +
");");
712 if (Properties.Settings.Default.LibPath.Contains(
"MTB"))
714 if (type == Type.HXP)
719 else if(type == Type.RL)
724 else if (type == Type.TL)
731 public override string ToString()
750 if(Properties.Settings.Default.LibPath.Contains(
"MTB"))
754 return (
int)com.doubles[0];
756 if (Properties.Settings.Default.PMicroscope)
759 Microscope.pMicroscope.GetFilterWheelPosition(out pos);
771 if (Properties.Settings.Default.LibPath.Contains(
"MTB"))
776 if (Properties.Settings.Default.PMicroscope)
779 Microscope.pMicroscope.SetFilterWheelPosition(i);
781 Recorder.AddLine(
"Microscope.FilterWheel.SetPosition(" + i +
");");
786 public static class Microscope
808 public static bool redraw =
false;
809 public static Focus Focus =
null;
810 public static Stage Stage =
null;
811 public static Objectives Objectives =
null;
812 public static TLShutter TLShutter =
null;
813 public static RLShutter RLShutter =
null;
814 public static HXPShutter HXPShutter =
null;
815 public static LightSource TLHalogen =
null;
816 public static LightSource RLHalogen =
null;
817 public static LightSource HXP =
null;
818 public static FilterWheel TLFilterWheel =
null;
819 public static FilterWheel RLFilterWheel =
null;
820 public static FilterWheel FilterWheel =
new FilterWheel();
821 public static double UpperLimit, LowerLimit, fInterVal;
822 public static object CmdSetMode =
null;
823 public static bool initialized =
false;
824 public static bool ArrowKeysEnabled =
true;
825 public static Point3D defaultPos =
new Point3D(30000, 30000, 23900);
826 public static object root =
null;
827 public static StringBuilder dllVersion =
new StringBuilder();
828 public static SDK sdk;
829 public static int sessionID = -1;
830 public static string userRx =
"";
831 public static PointD viewSize;
832 public static PMicroscope pMicroscope =
null;
834 public static int ImageCount = 0;
836 public static Objectives.Objective Objective
840 return Objectives.GetObjective();
847 public static void Initialize()
852 folder = Properties.Settings.Default.ImagingPath;
853 if (Properties.Settings.Default.PMicroscope)
855 pMicroscope =
new PMicroscope();
856 pMicroscope.Initialize();
857 bool b = pMicroscope.SetPosition(
new Point3D(100, 100, 100));
859 bool res = pMicroscope.GetPosition3D(out p,
false);
860 bool bb = pMicroscope.TakeImage(Application.StartupPath +
"\\Image");
861 Objectives =
new Objectives(6);
866 if (Properties.Settings.Default.PycroManager)
869 if (Properties.Settings.Default.MMConfig ==
"")
871 OpenFileDialog fl =
new OpenFileDialog();
872 fl.Filter =
"Config Files (*.cfg)|*.cfg";
873 fl.InitialDirectory = Properties.Settings.Default.AppPath;
874 MessageBox.Show(
"Micro-Manager current configuration file not set please select the current configuration.");
875 fl.Title =
"Set Current Config File (Shown in MicroManager GUI)";
876 if (fl.ShowDialog() != DialogResult.OK)
878 Properties.Settings.Default.MMConfig = fl.FileName;
880 MicroManager.Initialize(Properties.Settings.Default.MMConfig);
881 Objectives =
new Objectives(7);
882 for (
int i = 0; i < MicroManager.Objectives.List.Count; i++)
884 Objectives.List[MicroManager.Objectives.List[i].Index].Name = MicroManager.Objectives.List[i].Name;
890 if (Properties.Settings.Default.AppPath ==
"")
892 OpenFileDialog fl =
new OpenFileDialog();
893 MessageBox.Show(
"Imaging application path is not set. Please set executable location.");
894 fl.Title =
"Set imaging application location.";
895 if (fl.ShowDialog() != DialogResult.OK)
897 Properties.Settings.Default.AppPath = fl.FileName;
901 if (Properties.Settings.Default.LibPath ==
"")
903 OpenFileDialog fl =
new OpenFileDialog();
904 MessageBox.Show(
"Imaging library path is not set. Please set imaging library.");
905 fl.Title =
"Set imaging library location.";
906 if (fl.ShowDialog() != DialogResult.OK)
908 Properties.Settings.Default.LibPath = fl.FileName;
911 if (Properties.Settings.Default.LibPath.Contains(
"MTB"))
913 TLFilterWheel =
new FilterWheel();
914 RLFilterWheel =
new FilterWheel();
917 Objectives =
new Objectives(7);
918 TLShutter =
new TLShutter();
919 RLShutter =
new RLShutter();
920 HXPShutter =
new HXPShutter();
921 TLHalogen =
new LightSource();
922 RLHalogen =
new LightSource();
923 HXP =
new LightSource();
924 Point3D.SetLimits(Stage.minX, Stage.maxX, Stage.minY, Stage.maxY, Focus.lowerLimit, Focus.upperLimit);
925 PointD.SetLimits(Stage.minX, Stage.maxX, Stage.minY, Stage.maxY);
929 else if (Properties.Settings.Default.LibPath.Contains(
"Prio"))
933 if ((err = sdk.GetVersion(dllVersion)) != Prior.PRIOR_OK)
935 MessageBox.Show(
"Error getting Prior SDK version (" + err.ToString() +
")");
941 if ((err = sdk.Initialise()) != Prior.PRIOR_OK)
943 MessageBox.Show(
"Error initialising Prior SDK (" + err.ToString() +
")");
950 if ((sessionID = sdk.OpenSession()) < 0)
952 MessageBox.Show(
"Error (" + sessionID.ToString() +
") Creating session in SDK " + dllVersion);
958 for (
int port = 0; port < 10; port++)
965 open = sdk.Cmd(sessionID,
"controller.connect " + port.ToString(), ref userRx,
false);
973 if (open != Prior.PRIOR_OK)
975 MessageBox.Show(
"Error (" + open.ToString() +
") connecting to stage controller ",
"",
976 MessageBoxButtons.OK, MessageBoxIcon.Error);
979 err = sdk.Cmd(sessionID,
"controller.stage.hostdirection.set 1 1", ref userRx);
980 Objectives =
new Objectives(sdk.GetNosePiecePositions());
985 RectangleD rec = GetObjectiveViewRectangle();
986 viewSize =
new PointD(rec.W, rec.H);
994 public static void CalibrateXYZ(
int calibMode)
996 if (Properties.Settings.Default.LibPath.Contains(
"MTB"))
1001 PointD cur = Stage.GetPosition(
true);
1002 double z = Focus.GetFocus();
1014 public static Point3D GetPosition()
1016 PointD p = Stage.GetPosition(
false);
1017 double f = Focus.GetFocus();
1018 return new Point3D(p.X, p.Y, f);
1025 public static void SetPosition(Point3D p)
1027 Stage.SetPosition(p.X,p.Y);
1028 Focus.SetFocus(p.Z);
1029 Microscope.redraw =
true;
1035 public static void SetPosition(PointD p)
1037 Stage.SetPosition(p.X, p.Y);
1038 Microscope.redraw =
true;
1041 public static void OpenRL()
1044 if (RLShutter.GetPosition() == 0)
1045 RLShutter.SetPosition(1);
1050 public static void OpenTL()
1053 if (TLShutter.GetPosition() == 0)
1054 TLShutter.SetPosition(1);
1058 public static void CloseRL()
1061 if (RLShutter.GetPosition() == 0)
1062 RLShutter.SetPosition(1);
1066 public static void CloseTL()
1069 if (TLShutter.GetPosition() == 0)
1070 TLShutter.SetPosition(1);
1076 public static void SetTL(uint tl)
1078 TLShutter.SetPosition((
short)tl);
1084 public static void SetRL(uint tr)
1086 RLShutter.SetPosition((
short)tr);
1092 public static int GetTL()
1094 return TLShutter.GetPosition();
1100 public static int GetRL()
1102 return RLShutter.GetPosition();
1109 public static int GetShutterPosition(
string shutter)
1111 return MicroManager.Shutters.GetPosition(shutter);
1118 public static void SetShutterPosition(
string shutter,
int state)
1120 MicroManager.Shutters.SetPosition(shutter, state);
1125 public static void MoveUp(
double d)
1133 public static void MoveRight(
double d)
1141 public static void MoveDown(
double d)
1149 public static void MoveLeft(
double d)
1154 public static void MoveFieldUp()
1156 Stage.MoveUp(viewSize.Y);
1159 public static void MoveFieldRight()
1161 Stage.MoveRight(viewSize.X);
1164 public static void MoveFieldDown()
1166 Stage.MoveDown(viewSize.Y);
1169 public static void MoveFieldLeft()
1171 Stage.MoveLeft(viewSize.X);
1177 public static void SetFocus(
double d)
1184 public static double GetFocus()
1186 return Focus.GetFocus();
1188 private static string folder =
"";
1195 public static string GetFolder()
1197 object o = Recordings.GetProperty(Automation.Action.ValueType.ValuePattern,
"GetFolder");
1201 if (s ==
null && folder ==
"" && Properties.Settings.Default.ImagingPath ==
"")
1203 FolderBrowserDialog fs =
new FolderBrowserDialog();
1204 fs.Description =
"Select Imaging Folder";
1205 if (fs.ShowDialog() != DialogResult.OK)
1213 Properties.Settings.Default.ImagingPath = fs.SelectedPath;
1214 return fs.SelectedPath;
1219 folder = Properties.Settings.Default.ImagingPath;
1227 public static void SetFolder(
string fol)
1229 if (!Directory.Exists(fol))
1230 Directory.CreateDirectory(fol);
1231 if(Automation.Properties.ContainsKey(
"SetFolder"))
1232 Automation.SetProperty(
"SetFolder",fol);
1234 Properties.Settings.Default.ImagingPath = folder;
1235 Properties.Settings.Default.Save();
1241 public static BioImage TakeImage()
1243 return TakeImage(
true,
true,
false);
1246 public static BioImage TakeImage(
bool save,
bool addToImages,
bool newTab)
1248 if (Properties.Settings.Default.SimulateCamera && !Properties.Settings.Default.PMicroscope)
1250 folder = GetFolder();
1251 BioImage b = MicroscopeSetup.simImage.Copy();
1252 Point3D p = GetPosition();
1253 b.Volume.Location =
new Point3D(p.X,p.Y,p.Z);
1254 RectangleD view = Microscope.GetViewRectangle(
true);
1255 b.Resolutions[0] =
new Resolution(b.SizeX, b.SizeY, b.Buffers[0].PixelFormat,view.W / b.SizeX, view.H / b.SizeY, b.PhysicalSizeZ,p.X,p.Y,p.Z);
1256 b.Volume.Location = p;
1257 b.Volume.Width = view.W;
1258 b.Volume.Height = view.H;
1260 if (folder ==
"" || folder ==
null)
1261 file = Properties.Settings.Default.ImageName + (ImageCount++) +
".ome.tif";
1263 file = folder +
"/" + Properties.Settings.Default.ImageName + (ImageCount++) +
".ome.tif";
1269 App.tabsView.AddTab(b);
1272 BioImage.SaveOME(file, b.ID);
1275 else if (Properties.Settings.Default.PMicroscope)
1277 folder = GetFolder();
1279 if (folder ==
"" || folder ==
null)
1280 file = Properties.Settings.Default.ImageName + (ImageCount++).ToString();
1282 file = folder +
"/" + Properties.Settings.Default.ImageName + (ImageCount++);
1283 pMicroscope.TakeImage(file);
1284 byte[] bts = File.ReadAllBytes(file);
1287 Enum.TryParse<PixelFormat>(Properties.Settings.Default.PCameraFormat, out px);
1288 pMicroscope.GetSize(out w, out h);
1289 Bitmap bf =
new Bitmap(file, w, h, px, bts,
new ZCT(0, 0, 0), 0);
1290 bf.Stats = Statistics.FromBytes(bf);
1291 BioImage bm =
new BioImage(file +
".ome.tif");
1294 RectangleD rec = GetViewRectangle(
false);
1295 Point3D p = Microscope.GetPosition();
1296 Resolution res =
new Resolution(w,h,px,rec.W / bm.SizeX,rec.H / bm.SizeY,1, p.X,p.Y,p.Z);
1297 bm.Volume.Location = p;
1298 bm.Volume.Width = rec.W;
1299 bm.Volume.Height = rec.H;
1300 bm.bitsPerPixel = bf.BitsPerPixel;
1301 bm.UpdateCoords(1, 1, 1);
1302 bm.Resolutions.Add(res);
1303 for (
int c = 0; c < bf.RGBChannelsCount; c++)
1305 bm.Channels.Add(
new Channel(c, bf.BitsPerPixel, bf.RGBChannelsCount));
1307 BioImage.AutoThreshold(bm,
false);
1312 Images.AddImage(bm);
1313 App.tabsView.AddTab(bm);
1316 BioImage.SaveAsync(file +
".ome.tif", bm.ID,0,
true);
1317 if (bm.bitsPerPixel > 8)
1318 bm.StackThreshold(
true);
1320 bm.StackThreshold(
false);
1323 bi.Buffers.Add(bm.Buffers[0]);
1329 else if (Properties.Settings.Default.PycroManager)
1331 folder = GetFolder();
1333 if (folder ==
"" || folder ==
null)
1334 file = Properties.Settings.Default.ImageName + (ImageCount++).ToString();
1336 file = folder +
"/" + Properties.Settings.Default.ImageName + (ImageCount++);
1337 BioImage bm = MicroManager.TakeImage(file);
1343 Images.AddImage(bm);
1344 App.tabsView.AddTab(bm);
1347 BioImage.SaveAsync(file +
".ome.tif", bm.ID,0,
true);
1351 bi.Buffers.AddRange(bm.Buffers);
1361 if (Function.Functions.ContainsKey(
"TakeImage"))
1363 App.imager.PerformFunction(Function.Functions[
"TakeImage"]);
1368 MessageBox.Show(
"Go to Microscope Setup to set 'TakeImage' function eg. a Button shortcut or GUI recording. Or set camera simulation on & set Camera image.",
"Function 'TakeImage' not defined.");
1376 public static BioImage TakeImageStack()
1378 return TakeImageStack(UpperLimit, LowerLimit, fInterVal);
1380 static FileSystemWatcher watcher =
new FileSystemWatcher();
1383 public static void Watcher()
1385 string s = GetFolder();
1386 watcher.Created += fileSystemWatcher1_Created;
1388 watcher.BeginInit();
1389 watcher.EnableRaisingEvents =
true;
1393 static BioImage currentImage;
1394 static bool imagingStack =
false;
1395 static List<BioImage> images =
new List<BioImage>();
1396 static Dictionary<int,string> locked =
new Dictionary<int, string>();
1398 static void LockWait()
1403 for (
int i = 0; i < locked.Count; i++)
1408 List<Process> pr = FileUtil.Locking(locked[i]);
1409 FileInfo fi =
new FileInfo(locked[i]);
1410 if (pr.Count == 0 && fi.Length > 0)
1415 }
while (imagingStack);
1418 private static void WaitLocking()
1420 System.Threading.Thread t =
new Thread(LockWait);
1429 private static void fileSystemWatcher1_Created(
object sender, FileSystemEventArgs e)
1431 if (!Properties.Settings.Default.PMicroscope)
1434 if (!Path.HasExtension(e.FullPath))
1436 locked.Add(ImageCount-1,e.FullPath);
1448 public static BioImage TakeImageStack(
double UpperLimit,
double LowerLimit,
double interval)
1450 imagingStack =
true;
1453 bi =
new BioImage(Properties.Settings.Default.ImageName);
1454 watcher.Path = GetFolder();
1455 Focus.SetFocus(UpperLimit);
1456 double d = UpperLimit - LowerLimit;
1457 double dd = d / interval;
1458 for (
int i = 0; i < dd; i++)
1463 Focus.SetFocus(Focus.GetFocus() - fInterVal);
1464 Application.DoEvents();
1468 if (!Properties.Settings.Default.PMicroscope)
1474 Application.DoEvents();
1475 }
while (bi.Buffers.Count < (
int)dd);
1478 bi.UpdateCoords(bi.Buffers.Count, 1, 1);
1479 for (
int c = 0; c < bi.Buffers[0].RGBChannelsCount; c++)
1481 bi.Channels.Add(
new Channel(c, bi.bitsPerPixel, bi.Buffers[c].RGBChannelsCount));
1484 RectangleD rec = GetObjectiveViewRectangle();
1485 bi.bitsPerPixel = bi.Buffers[0].BitsPerPixel;
1491 bi.Resolutions.Add(
new Resolution(bi.SizeX, bi.SizeY, bi.Buffers[0].PixelFormat,
1492 rec.W / bi.SizeX, rec.H / bi.SizeY, (UpperLimit - LowerLimit) / bi.SizeZ, rec.X,rec.Y,UpperLimit));
1493 bi.Volume =
new VolumeD(
new Point3D(bi.StageSizeX, bi.StageSizeY, bi.StageSizeZ),
new Point3D(bi.SizeX * bi.PhysicalSizeX, bi.SizeY * bi.PhysicalSizeY, bi.StageSizeZ * bi.PhysicalSizeZ));
1494 BioImage.AutoThreshold(bi,
false);
1495 if (bi.bitsPerPixel > 8)
1496 bi.StackThreshold(
true);
1498 bi.StackThreshold(
false);
1499 Images.AddImage(bi);
1500 App.tabsView.AddTab(bi);
1501 imagingStack =
false;
1512 public static BioImage[] TakeTiles(
int width,
int height,
bool save =
true,
bool addToImages =
true,
bool newTab =
false)
1514 List<BioImage> ims =
new List<BioImage>();
1515 imagingStack =
false;
1516 bool leftright =
false;
1517 if (Properties.Settings.Default.PMicroscope)
1519 Point3D p = Microscope.GetPosition();
1521 Microscope.SetPosition(p);
1523 for (
int y = 0; y < height; y++)
1527 Microscope.MoveFieldDown();
1529 leftright = !leftright;
1530 ims.Add(Microscope.TakeImage(save, addToImages, newTab));
1531 for (
int x = 0; x < width - 1; x++)
1535 Microscope.MoveFieldRight();
1539 Microscope.MoveFieldLeft();
1541 ims.Add(Microscope.TakeImage(save,addToImages,newTab));
1546 if(!Properties.Settings.Default.PMicroscope)
1551 Application.DoEvents();
1552 }
while (images.Count < width * height);
1553 for (
int i = 0; i < images.Count; i++)
1555 App.viewer.AddImage(images[i]);
1559 imagingStack =
false;
1560 return ims.ToArray();
1565 public static RectangleD GetObjectiveViewRectangle()
1567 Objectives.Objective o = Objectives.GetObjective();
1568 PointD d = Stage.GetPosition(
false);
1569 return new RectangleD(d.X, d.Y, o.ViewWidth, o.ViewHeight);
1578 public static RectangleD GetViewRectangle(
bool update)
1582 PointD d = Stage.GetPosition(
false);
1583 return new RectangleD(d.X, d.Y, viewSize.X, viewSize.Y);
1587 if(Properties.Settings.Default.PMicroscope)
1589 return new RectangleD(PMicroscope.location.X, PMicroscope.location.Y, viewSize.X, viewSize.Y);
1593 PointD d = Stage.GetPosition(
false);
1594 return new RectangleD(d.X, d.Y, viewSize.X, viewSize.Y);
1598 public static void Close()
static void SetProperty(string prop, string val)
static object GetProperty(string prop)
void SetSWLimit(double xd, double yd)
double GetFocus(bool update)
object PerformFunction(Function f)
void SetPosition(double f)
void SetPosition(int index)
double GetPositionY(bool update)
PointD GetPosition(bool update)
void UpdateSWLimit()
It gets the software limits of the microscope stage.
void SetPosition(double px, double py)
double GetPositionX(bool update)
void SetSWLimit(double xmin, double xmax, double ymin, double ymax)
void SetPositionY(double py)
void SetPositionX(double px)