BioGTK  6.5.0
A .NET library & program for annotating, editing various microscopy imaging formats using Bioformats supported images. Including whole slide, pyramidal, and series.
Loading...
Searching...
No Matches
BioGTK.ImageView Class Reference
Inheritance diagram for BioGTK.ImageView:

Public Types

enum  ViewMode { Raw , Filtered , RGBImage , Emission }
 

Public Member Functions

void SetCoordinate (int z, int c, int t)
 
ZCT GetCoordinate ()
 
void AddImage (BioImage im)
 
void RequestImmediateRender ()
 
void RequestDeferredRender ()
 
void SetTitle (string s)
 
void UpdateImages (bool force=false)
 It updates the images.
 
void UpdateImage ()
 It updates the image.
 
void UpdateGUI ()
 It updates the GUI to reflect the current state of the image.
 
void CopySelection ()
 It takes the selected ROIs and copies them to the clipboard.
 
void PasteSelection ()
 
void OnMouseWheel (object sender, ScrollEventArgs e)
 
void ZoomAtPoint (double mouseX, double mouseY, bool zoomIn)
 
void UpdateStatus ()
 It updates the status of the user.
 
void UpdateView (bool updateImages=true)
 It updates the view.
 
double GetScale ()
 
List< ROI > GetSelectedROIs ()
 
void ZoomAtPoint (float mouseX, float mouseY, bool zoomIn)
 
PointD ImageToViewSpace (double x, double y)
 
PointF ToViewSpace (PointF p)
 
PointD ToViewSpace (PointD p)
 
PointD ToViewSpace (double x, double y)
 
double ToViewSizeH (double d)
 
double ToViewW (double d)
 
double ToViewH (double d)
 
PointD ToScreenSpace (double x, double y)
 
PointD ToScreenSpace (PointD p)
 
PointF ToScreenSpace (PointF p)
 
PointF[] ToScreenSpace (PointF[] p)
 
PointF ToScreenSpace (Point3D p)
 
float ToScreenScaleW (double x)
 
float ToScreenScaleH (double y)
 
PointF ToScreenScale (PointD p)
 
RectangleD ToScreenRect (double x, double y, double w, double h)
 
RectangleD ToScreenSpace (RectangleD p)
 
RectangleD ToScreenSpace (RectangleF p)
 
RectangleD[] ToScreenSpace (RectangleD[] p)
 
PointD[] ToScreenSpace (PointD[] p)
 
double ToScreenW (double x)
 
float ToScreenH (double y)
 
void GoToImage ()
 This function is used to go to the image at the specified index.
 
void GoToImage (int i)
 

Static Public Member Functions

static ImageView Create (BioImage bm)
 
static SKImage BitmapToSKImage (Bitmap bmp)
 
static Cairo.Color FromColor (Color color)
 

Public Attributes

List< BioImage > Images = new List<BioImage>()
 
Gtk.Box mainBox
 
Menu contextMenu
 
SlideGLArea glArea
 
SlideRenderer slideRenderer
 
SKSlideRenderer sKSlideRenderer
 
GLWindow window
 
bool showRROIs = true
 
bool showGROIs = true
 
bool showBROIs = true
 
ROI selectedROI = new ROI()
 

Static Public Attributes

static bool MacOS = false
 
static int waitz = 1000
 
static int waitc = 1000
 
static int waitt = 1000
 
static int startz = 0
 
static int startc = 0
 
static int startt = 0
 
static int endz = 0
 
static int endc = 0
 
static int endt = 0
 
static Gdk.Key keyDown = Gdk.Key.Key_3270_Test
 
static bool x1State
 
static bool x2State
 
static bool mouseLeftState
 
static ModifierType Modifiers
 

Protected Member Functions

 ImageView (Builder builder, IntPtr handle, BioImage im)
 
void SetupHandlers ()
 Sets up the handlers.
 
override void OnDestroyed ()
 

Properties

double PxWmicron [get, set]
 
double PxHmicron [get, set]
 
bool AllowNavigation [get, set]
 
bool ShowMasks = true [get, set]
 
bool ShowOverview = true [get, set]
 
static AForge.Bitmap SelectedBuffer [get]
 
int SelectedIndex [get, set]
 
static List< ROI > selectedAnnotations [get]
 
int? MacroResolution [get]
 
int? LabelResolution [get]
 
bool OpenSlide [get, set]
 
static BioImage SelectedImage [get, set]
 
ViewMode Mode [get, set]
 
Channel RChannel [get]
 
Channel GChannel [get]
 
Channel BChannel [get]
 
PointD Origin [get, set]
 
PointD TopRightOrigin [get]
 
PointD PyramidalOriginTransformed [get, set]
 
PointD PyramidalOrigin [get, set]
 
double Resolution [get, set]
 
int Level [get, set]
 
SizeF Scale [get, set]
 
PointD MouseDownInt [get, set]
 
PointD MouseMoveInt [get, set]
 
PointD MouseUpInt [get, set]
 
PointD MouseDown [get, set]
 
PointD MouseUp [get, set]
 
PointD MouseMove [get, set]
 
static ROI SelectedAnnotation [get]
 
double ImageViewWidth [get]
 
double ImageViewHeight [get]
 

Detailed Description

Definition at line 35 of file ImageView.cs.

Member Enumeration Documentation

◆ ViewMode

enum BioGTK.ImageView.ViewMode

Definition at line 2239 of file ImageView.cs.

2240 {
2241 Raw,
2242 Filtered,
2243 RGBImage,
2244 Emission,
2245 }

Constructor & Destructor Documentation

◆ ImageView()

BioGTK.ImageView.ImageView ( Builder builder,
IntPtr handle,
BioImage im )
protected

Definition at line 282 of file ImageView.cs.

282 : base(handle)
283 {
284 _builder = builder;
285 App.viewer = this;
286 builder.Autoconnect(this);
287 var gameWindowSettings = new GameWindowSettings()
288 {
289 UpdateFrequency = 60,
290 };
291 NativeWindowSettings nativeSettings;
292
293 if (OperatingSystem.IsMacOS())
294 {
295 MacOS = true;
296 // Create the renderer bridge
297 sk = new SKDrawingArea();
298 sKSlideRenderer = new SKSlideRenderer(sk);
299 }
300 else if (OperatingSystem.IsLinux())
301 {
302 nativeSettings = new NativeWindowSettings()
303 {
304 ClientSize = new Vector2i(600, 400),
305 Location = new Vector2i(0, 0),
306 Title = "OpenGL Context",
307 StartVisible = false, // Window starts hidden
308 API = ContextAPI.OpenGL,
309 Profile = ContextProfile.Core,
310 APIVersion = new Version(3, 3)
311 };
312 //tileCopy = new TileCopyGL(gameWindowSettings, nativeSettings);
313 Environment.SetEnvironmentVariable("GDK_BACKEND", "x11");
314 Environment.SetEnvironmentVariable("GTK_BACKEND", "x11");
315 window = new GLWindow(gameWindowSettings, nativeSettings);
316 // Create the GLArea widget
317 glArea = new SlideGLArea();
318 glArea.OnSkiaRender += RenderSkia;
319 // Create the renderer bridge
320 slideRenderer = new SlideRenderer(glArea);
321 GLFWProvider.SetErrorCallback((error, description) =>
322 {
323 if (description.Contains("Wayland") && description.Contains("window position"))
324 Console.WriteLine($"BioGTK Window Position Error.");
325 Console.WriteLine($"BioGTK GLFW Error {error}: {description}");
326 });
327
328 }
329 else if (OperatingSystem.IsWindows())
330 {
331 nativeSettings = new NativeWindowSettings()
332 {
333 ClientSize = new Vector2i(600, 400),
334 Location = new Vector2i(0, 0),
335 Title = "OpenGL Context",
336 StartVisible = false, // Window starts hidden
337 API = ContextAPI.OpenGL,
338 Profile = ContextProfile.Core,
339 APIVersion = new Version(3, 3)
340 };
341 window = new GLWindow(gameWindowSettings, nativeSettings);
342 // Create the GLArea widget
343 glArea = new SlideGLArea();
344 glArea.OnSkiaRender += RenderSkia;
345 // Create the renderer bridge
346 slideRenderer = new SlideRenderer(glArea);
347 GLFWProvider.SetErrorCallback((error, description) =>
348 {
349 Console.WriteLine($"BioGTK GLFW Error {error}: {description}");
350 });
351 }
352
353 if (MacOS)
354 {
355 if (im.isPyramidal)
356 {
357 // Set the source based on image type
358 if (im.OpenSlideBase != null)
359 {
360 sKSlideRenderer.SetSource(im.OpenSlideBase);
361 }
362 else if (im.SlideBase != null)
363 {
364 sKSlideRenderer.SetSource(im.SlideBase);
365 }
366 }
367 // Add to view
368 viewStack.Add(sk);
369 }
370 else
371 {
372 // Set the source based on image type
373 if (im.OpenSlideBase != null)
374 {
375 slideRenderer.SetSource(im.OpenSlideBase);
376 }
377 else if (im.SlideBase != null)
378 {
379 slideRenderer.SetSource(im.SlideBase);
380 }
381 // Add to view
382 viewStack.Add(glArea);
383 }
384
385 viewStack.ShowAll();
386 if (!MacOS)
387 glArea.Show();
388 this.WidthRequest = 600;
389 this.HeightRequest = 400;
390 roi.Submenu = roiMenu;
391 roi.ShowAll();
392 AddImage(im);
393 ShowMasks = true;
394 pxWmicron = SelectedImage.PhysicalSizeX;
395 pxHmicron = SelectedImage.PhysicalSizeY;
397 //pictureBox.WidthRequest = im.SizeX;
398 //pictureBox.HeightRequest = im.SizeY;
399 Function.InitializeContextMenu();
400 this.Scale = new SizeF(1, 1);
401 // Set the text column to display for comboboxs.
402 var rendererr = new CellRendererText();
403 rBox.PackStart(rendererr, false);
404 rBox.AddAttribute(rendererr, "text", 0);
405 var rendererg = new CellRendererText();
406 gBox.PackStart(rendererg, false);
407 gBox.AddAttribute(rendererg, "text", 0);
408 var rendererb = new CellRendererText();
409 bBox.PackStart(rendererb, false);
410 bBox.AddAttribute(rendererb, "text", 0);
411 App.ApplyStyles(this);
412 }
void SetupHandlers()
Sets up the handlers.
void AddImage(BioImage im)
Definition ImageView.cs:75
void SetSource(OpenSlideGTK.OpenSlideBase openSlideSource)
Set OpenSlide source and initialize pipeline.

Member Function Documentation

◆ AddImage()

void BioGTK.ImageView.AddImage ( BioImage im)

It adds an image to the list of images, and then updates the GUI and the images

Parameters
BioImagea class that contains the image data and metadata

Definition at line 75 of file ImageView.cs.

76 {
77 Images.Add(im);
78 selectedIndex = Images.Count - 1;
79 if (im.Resolutions[0].SizeX < 1920 && im.Resolutions[0].SizeY < 1080)
80 {
81 if (sk != null)
82 {
83 sk.WidthRequest = im.Resolutions[0].SizeX;
84 sk.HeightRequest = im.Resolutions[0].SizeY;
85 }
86 else
87 {
88 glArea.WidthRequest = im.Resolutions[0].SizeX;
89 glArea.HeightRequest = im.Resolutions[0].SizeY;
90 }
91 }
92
93 Initialize();
94 InitPreview();
95 UpdateImages(true);
96 UpdateGUI();
97 GoToImage(Images.Count - 1);
98 }
void GoToImage()
This function is used to go to the image at the specified index.
void UpdateGUI()
It updates the GUI to reflect the current state of the image.
void UpdateImages(bool force=false)
It updates the images.

◆ BitmapToSKImage()

static SKImage BioGTK.ImageView.BitmapToSKImage ( Bitmap bmp)
static

Definition at line 724 of file ImageView.cs.

725 {
726 var rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
727
728 var data = bmp.LockBits(
729 rect,
730 ImageLockMode.ReadOnly,
731 AForge.PixelFormat.Format32bppArgb); // This is BGRA in memory
732
733 try
734 {
735 var info = new SKImageInfo(
736 bmp.Width,
737 bmp.Height,
738 SKColorType.Bgra8888,
739 SKAlphaType.Premul);
740
741 var pixmap = new SKPixmap(info, data.Scan0, data.Stride);
742
743 return SKImage.FromPixels(pixmap);
744 }
745 finally
746 {
747 bmp.UnlockBits(data);
748 }
749 }

◆ CopySelection()

void BioGTK.ImageView.CopySelection ( )

It takes the selected ROIs and copies them to the clipboard.

Definition at line 2199 of file ImageView.cs.

2200 {
2201 copys.Clear();
2202 string s = "";
2203 List<ROI> rois = new List<ROI>();
2204 rois.AddRange(SelectedImage.AnnotationsR);
2205 rois.AddRange(SelectedImage.AnnotationsG);
2206 rois.AddRange(SelectedImage.AnnotationsB);
2207 foreach (ROI item in rois)
2208 {
2209 if (item.Selected)
2210 {
2211 copys.Add(item);
2212 s += BioImage.ROIToString(item);
2213 }
2214 }
2215 Clipboard clipboard = Clipboard.Get(Gdk.Selection.Clipboard);
2216 clipboard.Text = s;
2217 }

◆ Create()

static ImageView BioGTK.ImageView.Create ( BioImage bm)
static

The function creates an ImageView object using a BioImage object and returns it.

Parameters
BioImageThe BioImage parameter is an object that represents an image in a biological context. It likely contains information about the image file, such as the filename, and possibly additional metadata related to the image.
Returns
The method is returning an instance of the ImageView class.

Definition at line 268 of file ImageView.cs.

269 {
270 Console.WriteLine("Creating ImageView for " + bm.file);
271
272 Builder builder = new Builder(new FileStream(System.IO.Path.GetDirectoryName(Environment.ProcessPath) + "/" + "Glade/ImageView.glade", FileMode.Open));
273
274 ImageView v = new ImageView(builder, builder.GetObject("imageView").Handle, bm);
275 v.Title = bm.Filename;
276
277 return v;
278 }

◆ FromColor()

static Cairo.Color BioGTK.ImageView.FromColor ( Color color)
static

It takes a System.Drawing.Color and returns a Cairo.Color

Parameters
ColorThe color to convert
Returns
A Cairo.Color object.

Definition at line 1898 of file ImageView.cs.

1899 {
1900 return new Cairo.Color((double)color.R / 255, (double)color.G / 255, (double)color.B / 255);
1901 }

◆ GetCoordinate()

ZCT BioGTK.ImageView.GetCoordinate ( )

It returns the coordinate of the selected image

Returns
The Coordinate property of the SelectedImage object.

Definition at line 67 of file ImageView.cs.

68 {
69 return SelectedImage.Coordinate;
70 }

◆ GetScale()

double BioGTK.ImageView.GetScale ( )

Definition at line 2575 of file ImageView.cs.

2576 {
2577 return ToViewSizeW(ROI.selectBoxSize / Scale.Width);
2578 }

◆ GetSelectedROIs()

List< ROI > BioGTK.ImageView.GetSelectedROIs ( )

Definition at line 2625 of file ImageView.cs.

2626 {
2627 List<ROI> roi = new List<ROI>();
2628 List<ROI> rois = new List<ROI>();
2629 rois.AddRange(SelectedImage.AnnotationsR);
2630 rois.AddRange(SelectedImage.AnnotationsG);
2631 rois.AddRange(SelectedImage.AnnotationsB);
2632 foreach (ROI r in rois)
2633 {
2634 if (r.Selected)
2635 {
2636 roi.Add(r);
2637 }
2638 }
2639 return roi;
2640 }

◆ GoToImage() [1/2]

void BioGTK.ImageView.GoToImage ( )

This function is used to go to the image at the specified index.

Definition at line 3272 of file ImageView.cs.

3273 {
3274 GoToImage(0);
3275 }

◆ GoToImage() [2/2]

void BioGTK.ImageView.GoToImage ( int i)

It takes an image index and centers the image in the viewport

Parameters
ithe index of the image to go to
Returns
The method is returning the value of the variable "i"

Definition at line 3281 of file ImageView.cs.

3282 {
3283 if (Images.Count <= i)
3284 return;
3285 if (SelectedImage.Type == BioImage.ImageType.pyramidal)
3286 {
3287 if (SelectedImage.OpenSlideBase != null)
3288 {
3289 if (MacroResolution.HasValue)
3290 {
3291 int lev = MacroResolution.Value - 2;
3292 Resolution = _openSlideBase.Schema.Resolutions[lev].UnitsPerPixel * 0.98;
3293 }
3294 else
3295 {
3296 int lev = 0;
3297 Resolution = _openSlideBase.Schema.Resolutions[lev].UnitsPerPixel * 0.98;
3298 }
3299 }
3300 else
3301 {
3302 if (MacroResolution.HasValue)
3303 {
3304 int lev = MacroResolution.Value - 1;
3305 Resolution = SelectedImage.SlideBase.Schema.Resolutions[lev].UnitsPerPixel * 0.98;
3306 PyramidalOrigin = new PointD(0, 0);
3307 }
3308 else
3309 {
3310 Resolution = SelectedImage.GetUnitPerPixel(SelectedImage.Resolutions.Count - 1) * 0.98;
3311 }
3312 }
3313 }
3314 double dx = Images[i].Volume.Width / 2;
3315 double dy = Images[i].Volume.Height / 2;
3316 Origin = new PointD(-(Images[i].Volume.Location.X + dx), -(Images[i].Volume.Location.Y + dy));
3317 double wx, wy;
3318 wx = viewStack.AllocatedWidth / ToScreenW(SelectedImage.Volume.Width);
3319 wy = viewStack.AllocatedHeight / ToScreenH(SelectedImage.Volume.Height);
3320 Scale = new SizeF((float)wy, (float)wy);
3321 UpdateView();
3322 }
void UpdateView(bool updateImages=true)
It updates the view.
float ToScreenH(double y)
double ToScreenW(double x)

◆ ImageToViewSpace()

PointD BioGTK.ImageView.ImageToViewSpace ( double x,
double y )

It takes a point in the image space and returns the point in the view space

Parameters
xthe x coordinate of the point in the image
ythe y coordinate of the point in the image
Returns
The point in the image space that corresponds to the point in the view space.

Definition at line 2976 of file ImageView.cs.

2977 {
2978 if (SelectedImage == null)
2979 return ToViewSpace(x, y);
2980 if (SelectedImage.isPyramidal)
2981 {
2982 return new PointD((PyramidalOrigin.X + x) * Resolution, (PyramidalOrigin.Y + y) * Resolution);
2983 }
2984 else
2985 return ToViewSpace(x, y);
2986 }
PointF ToViewSpace(PointF p)

◆ OnDestroyed()

override void BioGTK.ImageView.OnDestroyed ( )
protected

Definition at line 2919 of file ImageView.cs.

2920 {
2921 base.OnDestroyed();
2922 }

◆ OnMouseWheel()

void BioGTK.ImageView.OnMouseWheel ( object sender,
ScrollEventArgs e )

Definition at line 2372 of file ImageView.cs.

2373 {
2374 if (e.Event.Direction == ScrollDirection.Up)
2375 ZoomAtPoint(PyramidalOrigin.X, PyramidalOrigin.Y, false);
2376 else if (e.Event.Direction == ScrollDirection.Down)
2377 ZoomAtPoint(PyramidalOrigin.X, PyramidalOrigin.Y, true);
2378 }

◆ PasteSelection()

void BioGTK.ImageView.PasteSelection ( )

The function takes the text from the clipboard and splits it into lines. Each line is then converted into an ROI object and added to the list of annotations

Definition at line 2220 of file ImageView.cs.

2221 {
2222 Clipboard clipboard = Clipboard.Get(Gdk.Selection.Clipboard);
2223 string text = clipboard.WaitForText();
2224 string[] sts = text.Split(BioImage.NewLine);
2225 foreach (string line in sts)
2226 {
2227 if (line.Length > 8)
2228 {
2229 ROI an = BioImage.StringToROI(line);
2230 //We set the coordinates of the ROI's we are pasting
2231 an.coord = GetCoordinate();
2232 SelectedImage.Annotations.Add(an);
2233 }
2234 }
2235 UpdateView();
2236 }
ZCT GetCoordinate()
Definition ImageView.cs:67

◆ RequestDeferredRender()

void BioGTK.ImageView.RequestDeferredRender ( )

Definition at line 876 of file ImageView.cs.

877 {
878 lock (_renderLock)
879 {
880 _pendingRender = true;
881
882 // Reset timer - only render after 50ms of no requests
883 _renderTimer?.Dispose();
884 _renderTimer = new System.Threading.Timer(
885 _ => ExecuteDeferredRender(),
886 null,
887 20, // Delay in milliseconds
888 Timeout.Infinite
889 );
890 }
891 }

◆ RequestImmediateRender()

void BioGTK.ImageView.RequestImmediateRender ( )

Definition at line 772 of file ImageView.cs.

773 {
774 UpdateView(true);
775 }

◆ SetCoordinate()

void BioGTK.ImageView.SetCoordinate ( int z,
int c,
int t )

Definition at line 43 of file ImageView.cs.

44 {
45 if (SelectedImage == null)
46 return;
47 if (z > SelectedImage.SizeZ - 1 && SelectedImage.Type == BioImage.ImageType.well)
48 zBar.Value = zBar.Adjustment.Upper;
49 else
50 zBar.Value = z;
51 if (c > SelectedImage.SizeC - 1)
52 cBar.Value = cBar.Adjustment.Upper;
53 else
54 cBar.Value = c;
55 if (t > SelectedImage.SizeT - 1)
56 tBar.Value = tBar.Adjustment.Upper;
57 else
58 tBar.Value = t;
59 if (SelectedImage.Type == BioImage.ImageType.well)
60 SelectedImage.Coordinate = new ZCT(0, (int)cBar.Value, (int)tBar.Value);
61 else
62 SelectedImage.Coordinate = new ZCT((int)zBar.Value, (int)cBar.Value, (int)tBar.Value);
63 }

◆ SetTitle()

void BioGTK.ImageView.SetTitle ( string s)

Definition at line 978 of file ImageView.cs.

979 {
980 this.Title = s;
981 }

◆ SetupHandlers()

void BioGTK.ImageView.SetupHandlers ( )
protected

Sets up the handlers.

Definition at line 1248 of file ImageView.cs.

1249 {
1250 zBar.ValueChanged += ValueChangedZ;
1251 cBar.ValueChanged += ValueChangedC;
1252 tBar.ValueChanged += ValueChangedT;
1253 if (MacOS)
1254 {
1255 sk.MotionNotifyEvent += ImageView_MotionNotifyEvent;
1256 sk.ButtonPressEvent += ImageView_ButtonPressEvent;
1257 sk.ButtonReleaseEvent += ImageView_ButtonReleaseEvent;
1258 sk.ScrollEvent += ImageView_ScrollEvent;
1259 sk.ScrollEvent += OnMouseWheel;
1260 sk.PaintSurface += Sk_PaintSurface;
1261 sk.SizeAllocated += PictureBox_SizeAllocated;
1262 sk.SetSizeRequest(600, 400);
1263 sk.AddEvents((int)(EventMask.ButtonPressMask
1264 | EventMask.ButtonReleaseMask
1265 | EventMask.KeyPressMask
1266 | EventMask.PointerMotionMask
1267 | EventMask.ScrollMask));
1268 }
1269 else
1270 {
1271 glArea.MotionNotifyEvent += ImageView_MotionNotifyEvent;
1272 glArea.ButtonPressEvent += ImageView_ButtonPressEvent;
1273 glArea.ButtonReleaseEvent += ImageView_ButtonReleaseEvent;
1274 glArea.ScrollEvent += ImageView_ScrollEvent;
1275 glArea.ScrollEvent += OnMouseWheel;
1276 glArea.Render += GlArea_Render;
1277 glArea.SizeAllocated += PictureBox_SizeAllocated;
1278 glArea.AddEvents((int)(EventMask.ButtonPressMask
1279 | EventMask.ButtonReleaseMask
1280 | EventMask.KeyPressMask
1281 | EventMask.PointerMotionMask
1282 | EventMask.ScrollMask));
1283 }
1284
1285 this.KeyPressEvent += ImageView_KeyPressEvent;
1286 this.DestroyEvent += ImageView_DestroyEvent;
1287 this.DeleteEvent += ImageView_DeleteEvent;
1288 this.FocusInEvent += ImageView_FocusInEvent;
1289 rBox.Changed += RBox_Changed;
1290 gBox.Changed += GBox_Changed;
1291 bBox.Changed += BBox_Changed;
1292 //Context Menu
1293 goToImageMenu.ButtonPressEvent += GoToImageMenu_ButtonPressEvent;
1294 goToOriginMenu.ButtonPressEvent += GoToOriginMenu_ButtonPressEvent;
1295
1296 roiDelete.ButtonPressEvent += RoiDelete_ButtonPressEvent;
1297 roiID.ButtonPressEvent += RoiID_ButtonPressEvent;
1298 copy.ButtonPressEvent += Copy_ButtonPressEvent;
1299 paste.ButtonPressEvent += Paste_ButtonPressEvent;
1300 draw.ButtonPressEvent += Draw_ButtonPressEvent;
1301 fill.ButtonPressEvent += Fill_ButtonPressEvent;
1302
1303 play.ButtonPressEvent += Play_ButtonPressEvent;
1304 stop.ButtonPressEvent += Stop_ButtonPressEvent;
1305 playSpeed.ButtonPressEvent += PlaySpeed_ButtonPressEvent;
1306 setValueRange.ButtonPressEvent += SetValueRange_ButtonPressEvent;
1307 loop.ButtonPressEvent += Loop_ButtonPressEvent;
1308
1309 zBar.ButtonPressEvent += ZBar_ButtonPressEvent;
1310 tBar.ButtonPressEvent += TBar_ButtonPressEvent;
1311 cBar.ButtonPressEvent += CBar_ButtonPressEvent;
1312
1313 }

◆ ToScreenH()

float BioGTK.ImageView.ToScreenH ( double y)

‍Convert a value in microns to a value in pixels

Parameters
ythe y coordinate of the point to be converted
Returns
The return value is a float.

Definition at line 3267 of file ImageView.cs.

3268 {
3269 return (float)(y * PxHmicron);
3270 }

◆ ToScreenRect()

RectangleD BioGTK.ImageView.ToScreenRect ( double x,
double y,
double w,
double h )

It converts a rectangle in microns to a rectangle in pixels

Parameters
xThe x coordinate of the rectangle
y-0.0015
wwidth of the image in microns
hheight of the rectangle
Returns
A RectangleF object.

Definition at line 3180 of file ImageView.cs.

3181 {
3182 if (SelectedImage == null)
3183 {
3184 double dx = (pxWmicron * (-Origin.X)) * Scale.Width;
3185 double dy = (pxHmicron * (-Origin.Y)) * Scale.Height;
3186 RectangleD rf = new RectangleD((PxWmicron * x * Scale.Width + dx), (PxHmicron * y * Scale.Height + dy), (PxWmicron * w * Scale.Width), (PxHmicron * h * Scale.Height));
3187 return rf;
3188 }
3189 if (SelectedImage.isPyramidal)
3190 {
3191 PointD d = ToViewSpace(x, y);
3192 double dw = ToViewSizeW(w);
3193 double dh = ToViewSizeH(h);
3194 return new RectangleD(d.X, d.Y, dw, dh);
3195 }
3196 else
3197 {
3198 double dx = (pxWmicron * (Origin.X)) * Scale.Width;
3199 double dy = (pxHmicron * (Origin.Y)) * Scale.Height;
3200 RectangleD rf = new RectangleD((PxWmicron * x * Scale.Width + dx), (PxHmicron * y * Scale.Height + dy), (PxWmicron * w * Scale.Width), (PxHmicron * h * Scale.Height));
3201 return rf;
3202 }
3203 }
double ToViewSizeH(double d)

◆ ToScreenScale()

PointF BioGTK.ImageView.ToScreenScale ( PointD p)

‍Convert a point in the world coordinate system to a point in the screen coordinate system

Parameters
PointD
Returns
A PointF object.

Definition at line 3166 of file ImageView.cs.

3167 {
3168 float x = ToScreenScaleW((float)p.X);
3169 float y = ToScreenScaleH((float)p.Y);
3170 return new PointF(x, y);
3171 }
float ToScreenScaleW(double x)
float ToScreenScaleH(double y)

◆ ToScreenScaleH()

float BioGTK.ImageView.ToScreenScaleH ( double y)

‍Convert a value in microns to a value in pixels

Parameters
ythe y coordinate of the point to be converted
Returns
The return value is a float.

Definition at line 3157 of file ImageView.cs.

3158 {
3159 return (float)(-y * PxHmicron * Scale.Height);
3160 }

◆ ToScreenScaleW()

float BioGTK.ImageView.ToScreenScaleW ( double x)

ToScreenScaleW() returns the number of pixels that correspond to the given number of microns

Parameters
xthe x coordinate of the point to be converted
Returns
The return value is a float.

Definition at line 3148 of file ImageView.cs.

3149 {
3150 return (float)(-x * PxWmicron * Scale.Width);
3151 }

◆ ToScreenSpace() [1/9]

PointD BioGTK.ImageView.ToScreenSpace ( double x,
double y )

‍It converts a point in world space to a point in screen space

Parameters
xThe x coordinate of the point to convert.
yThe y coordinate of the point to transform.
Returns
A PointD object.

Definition at line 3095 of file ImageView.cs.

3096 {
3097 RectangleD f = ToScreenRect(x, y, 1, 1);
3098 return new PointD(f.X, f.Y);
3099 }
RectangleD ToScreenRect(double x, double y, double w, double h)

◆ ToScreenSpace() [2/9]

PointF BioGTK.ImageView.ToScreenSpace ( Point3D p)

‍It converts a 3D point to a 2D point

Parameters
Point3D
Returns
A PointF object.

Definition at line 3138 of file ImageView.cs.

3139 {
3140 PointD pd = ToScreenSpace(p.X, p.Y);
3141 return new PointF((float)pd.X, (float)pd.Y);
3142 }
PointD ToScreenSpace(double x, double y)

◆ ToScreenSpace() [3/9]

PointD BioGTK.ImageView.ToScreenSpace ( PointD p)

‍Converts a point from world space to screen space

Parameters
PointDA class that contains an X and Y value.
Returns
A PointD object.

Definition at line 3105 of file ImageView.cs.

3106 {
3107 return ToScreenSpace(p.X, p.Y);
3108 }

◆ ToScreenSpace() [4/9]

PointD[] BioGTK.ImageView.ToScreenSpace ( PointD[] p)

‍Convert a list of points from world space to screen space

Parameters
pThe point to convert
Returns
A PointF[] array of points.

Definition at line 3243 of file ImageView.cs.

3244 {
3245 PointD[] rs = new PointD[p.Length];
3246 for (int i = 0; i < p.Length; i++)
3247 {
3248 PointD pd = ToScreenSpace(p[i]);
3249 rs[i] = new PointD((float)pd.X, (float)pd.Y);
3250 }
3251 return rs;
3252 }

◆ ToScreenSpace() [5/9]

PointF BioGTK.ImageView.ToScreenSpace ( PointF p)

Convert a point in the world coordinate system to the screen coordinate system

Parameters
PointFThe point you want to convert to screen space.
Returns
A PointD object.

Definition at line 3114 of file ImageView.cs.

3115 {
3116 PointD pd = ToScreenSpace(p.X, p.Y);
3117 return new PointF((float)pd.X, (float)pd.Y);
3118 }

◆ ToScreenSpace() [6/9]

PointF[] BioGTK.ImageView.ToScreenSpace ( PointF[] p)

‍It takes an array of points and returns an array of points

Parameters
pThe point to convert
Returns
A PointF array.

Definition at line 3124 of file ImageView.cs.

3125 {
3126 PointF[] pf = new PointF[p.Length];
3127 for (int i = 0; i < p.Length; i++)
3128 {
3129 pf[i] = ToScreenSpace(p[i]);
3130 }
3131 return pf;
3132 }

◆ ToScreenSpace() [7/9]

RectangleD BioGTK.ImageView.ToScreenSpace ( RectangleD p)

‍It converts a rectangle from world space to screen space

Parameters
RectangleDThe rectangle to convert.
Returns
A RectangleF object.

Definition at line 3210 of file ImageView.cs.

3211 {
3212 return ToScreenRect(p.X, p.Y, p.W, p.H);
3213 }

◆ ToScreenSpace() [8/9]

RectangleD[] BioGTK.ImageView.ToScreenSpace ( RectangleD[] p)

It takes an array of RectangleD objects and returns an array of RectangleF objects

Parameters
pThe rectangle to convert
Returns
A RectangleF[]

Definition at line 3228 of file ImageView.cs.

3229 {
3230 RectangleD[] rs = new RectangleD[p.Length];
3231 for (int i = 0; i < p.Length; i++)
3232 {
3233 rs[i] = ToScreenSpace(p[i]);
3234 }
3235 return rs;
3236 }

◆ ToScreenSpace() [9/9]

RectangleD BioGTK.ImageView.ToScreenSpace ( RectangleF p)

‍It converts a rectangle from world space to screen space

Parameters
RectangleFThe rectangle to convert.
Returns
A RectangleF object.

Definition at line 3219 of file ImageView.cs.

3220 {
3221 return ToScreenRect(p.X, p.Y, p.Width, p.Height);
3222 }

◆ ToScreenW()

double BioGTK.ImageView.ToScreenW ( double x)

ToScreenW(x) = x * PxWmicron

Parameters
xthe x coordinate of the point to be converted
Returns
The return value is a float.

Definition at line 3258 of file ImageView.cs.

3259 {
3260 return (float)(x * PxWmicron);
3261 }

◆ ToViewH()

double BioGTK.ImageView.ToViewH ( double d)

‍Convert a distance in microns to a distance in pixels

Parameters
dthe distance in microns
Returns
The return value is the y-coordinate of the point in the view.

Definition at line 3079 of file ImageView.cs.

3080 {
3081 if (SelectedImage != null)
3082 if (SelectedImage.isPyramidal)
3083 {
3084 return d / Resolution;
3085 }
3086 double y = (double)(d / PxHmicron) / scale.Height;
3087 return y;
3088 }

◆ ToViewSizeH()

double BioGTK.ImageView.ToViewSizeH ( double d)

‍Convert a value in microns to a value in pixels

Parameters
dthe size in microns
Returns
The return value is the size of the object in pixels.

Definition at line 3049 of file ImageView.cs.

3050 {
3051 if (SelectedImage != null)
3052 if (SelectedImage.isPyramidal)
3053 {
3054 return d / Resolution;
3055 }
3056 double y = (double)(d / PxHmicron);
3057 return y;
3058 }

◆ ToViewSpace() [1/3]

PointD BioGTK.ImageView.ToViewSpace ( double x,
double y )

Definition at line 3006 of file ImageView.cs.

3007 {
3008 if (SelectedImage == null)
3009 {
3010 double dx = (ToViewSizeW(x - (viewStack.AllocatedWidth / 2)) / Scale.Width) - Origin.X;
3011 double dy = (ToViewSizeH(y - (viewStack.AllocatedHeight / 2)) / Scale.Height) - Origin.Y;
3012 return new PointD(dx, dy);
3013 }
3014
3015 if (SelectedImage.isPyramidal)
3016 {
3017 PointD p = new PointD(x / Resolution, y / Resolution);
3018 return new PointD(p.X - PyramidalOrigin.X, p.Y - PyramidalOrigin.Y);
3019 }
3020 else
3021 {
3022 // Handle non-pyramidal case
3023 double dx = (ToViewSizeW(x - (viewStack.AllocatedWidth / 2)) / Scale.Width) - Origin.X;
3024 double dy = (ToViewSizeH(y - (viewStack.AllocatedHeight / 2)) / Scale.Height) - Origin.Y;
3025 return new PointD(dx, dy);
3026 }
3027 }

◆ ToViewSpace() [2/3]

PointD BioGTK.ImageView.ToViewSpace ( PointD p)

‍Converts a point from world space to view space

Parameters
PointDA class that contains an X and Y value.
Returns
A PointD object.

Definition at line 3002 of file ImageView.cs.

3003 {
3004 return ToViewSpace(p.X, p.Y); ;
3005 }

◆ ToViewSpace() [3/3]

PointF BioGTK.ImageView.ToViewSpace ( PointF p)

Convert a point from world space to view space

Parameters
PointFThe point to convert
Returns
A PointD object.

Definition at line 2992 of file ImageView.cs.

2993 {
2994 PointD d = ToViewSpace(p.X, p.Y);
2995 return new PointF((float)d.X, (float)d.Y);
2996 }

◆ ToViewW()

double BioGTK.ImageView.ToViewW ( double d)

Convert a distance in microns to a distance in pixels on the screen

Parameters
dthe distance in microns
Returns
The width of the image in pixels.

Definition at line 3064 of file ImageView.cs.

3065 {
3066 if (SelectedImage != null)
3067 if (SelectedImage.isPyramidal)
3068 {
3069 return d / Resolution;
3070 }
3071 double x = (double)(d / PxWmicron) / scale.Width;
3072 return x;
3073 }

◆ UpdateGUI()

void BioGTK.ImageView.UpdateGUI ( )

It updates the GUI to reflect the current state of the image.

Definition at line 2129 of file ImageView.cs.

2130 {
2131 cBar.Adjustment.Lower = 0;
2132 cBar.Adjustment.Upper = Images[selectedIndex].SizeC - 1;
2133 zBar.Adjustment.Lower = 0;
2134 zBar.Adjustment.Upper = Images[selectedIndex].SizeZ - 1;
2135 tBar.Adjustment.Lower = 0;
2136 tBar.Adjustment.Upper = Images[selectedIndex].SizeT - 1;
2137 if (endz == 0 || endz > Images[selectedIndex].SizeZ - 1)
2138 endz = Images[selectedIndex].SizeZ - 1;
2139 if (endc == 0 || endc > Images[selectedIndex].SizeC - 1)
2140 endc = Images[selectedIndex].SizeC - 1;
2141 if (endt == 0 || endt > Images[selectedIndex].SizeT - 1)
2142 endt = Images[selectedIndex].SizeT - 1;
2143 var store = new ListStore(typeof(string));
2144 foreach (Channel c in SelectedImage.Channels)
2145 {
2146 store.AppendValues(c.Name);
2147 }
2148 // Set the model for the ComboBox
2149 rBox.Model = store;
2150 gBox.Model = store;
2151 bBox.Model = store;
2152 if (SelectedImage.Channels.Count > 2)
2153 {
2154 rBox.Active = 0;
2155 gBox.Active = 1;
2156 bBox.Active = 2;
2157 }
2158 else
2159 if (SelectedImage.Channels.Count == 2)
2160 {
2161 rBox.Active = 0;
2162 gBox.Active = 1;
2163 }
2164 imagesMenu = new Menu();
2165 foreach (BioImage b in Images)
2166 {
2167 MenuItem mi = new MenuItem(b.Filename);
2168 mi.ButtonPressEvent += Mi_ButtonPressEvent;
2169 imagesMenu.Append(mi);
2170 }
2171 goToImageMenu.Submenu = imagesMenu;
2172 goToImageMenu.ShowAll();
2173 }

◆ UpdateImage()

void BioGTK.ImageView.UpdateImage ( )

It updates the image.

Definition at line 1116 of file ImageView.cs.

1117 {
1118 UpdateImages();
1119 }

◆ UpdateImages()

void BioGTK.ImageView.UpdateImages ( bool force = false)

It updates the images.

Definition at line 1001 of file ImageView.cs.

1002 {
1003 if (SelectedImage == null)
1004 return;
1005 if (zBar.Adjustment.Upper != SelectedImage.SizeZ - 1 ||
1006 tBar.Adjustment.Upper != SelectedImage.SizeT - 1)
1007 {
1008 UpdateGUI();
1009 }
1010 if (!MacOS)
1011 {
1012 if (SelectedImage.isPyramidal && glArea.AllocatedWidth > 1 && glArea.AllocatedHeight > 1)
1013 {
1014 // Use the new renderer - no more ReadPixels!
1015 _ = slideRenderer.UpdateViewAsync(
1016 PyramidalOrigin,
1017 glArea.AllocatedWidth,
1018 glArea.AllocatedHeight,
1019 Resolution,
1021 );
1022 }
1023 else if (!SelectedImage.isPyramidal)
1024 {
1025 for (int i = 0; i < SKImages.Count; i++)
1026 {
1027 SKImages[i].Dispose();
1028 Bitmaps[i].Dispose();
1029 }
1030 SKImages.Clear();
1031 Bitmaps.Clear();
1032 foreach (BioImage b in Images)
1033 {
1034 ZCT c = GetCoordinate();
1035 AForge.Bitmap bitmap = null;
1036 int index = b.GetFrameIndex(c.Z, c.C, c.T);
1037 if (Mode == ViewMode.Filtered)
1038 {
1039 bitmap = b.GetFiltered(c, b.RChannel.RangeR, b.GChannel.RangeG, b.BChannel.RangeB);
1040 }
1041 else if (Mode == ViewMode.RGBImage)
1042 {
1043 bitmap = b.GetRGBBitmap(c, b.RChannel.RangeR, b.GChannel.RangeG, b.BChannel.RangeB);
1044 }
1045 else if (Mode == ViewMode.Raw)
1046 {
1047 bitmap = b.Buffers[index];
1048 }
1049 else
1050 {
1051 bitmap = b.GetEmission(c, b.RChannel.RangeR, b.GChannel.RangeG, b.BChannel.RangeB);
1052 }
1053 if (bitmap == null)
1054 return;
1055 var bm = bitmap.GetImageRGBA();
1056 SKImage skim = BitmapToSKImage(bm);
1057 SKImages.Add(skim);
1058 Bitmaps.Add(bm);
1059 }
1060 }
1061 }
1062 else
1063 {
1064 if (SelectedImage.isPyramidal && sk.AllocatedWidth > 1 && sk.AllocatedHeight > 1)
1065 {
1066 // Use the new renderer - no more ReadPixels!
1067 _ = sKSlideRenderer.UpdateViewAsync(
1068 PyramidalOrigin,
1069 Resolution,
1070 GetCoordinate(),
1071 sk.AllocatedWidth,
1072 sk.AllocatedHeight
1073 );
1074 }
1075 else if (!SelectedImage.isPyramidal)
1076 {
1077 for (int i = 0; i < SKImages.Count; i++)
1078 {
1079 SKImages[i].Dispose();
1080 Bitmaps[i].Dispose();
1081 }
1082 SKImages.Clear();
1083 Bitmaps.Clear();
1084 foreach (BioImage b in Images)
1085 {
1086 ZCT c = GetCoordinate();
1087 AForge.Bitmap bitmap = null;
1088 int index = b.GetFrameIndex(c.Z, c.C, c.T);
1089 if (Mode == ViewMode.Filtered)
1090 {
1091 bitmap = b.GetFiltered(c, b.RChannel.RangeR, b.GChannel.RangeG, b.BChannel.RangeB);
1092 }
1093 else if (Mode == ViewMode.RGBImage)
1094 {
1095 bitmap = b.GetRGBBitmap(c, b.RChannel.RangeR, b.GChannel.RangeG, b.BChannel.RangeB);
1096 }
1097 else if (Mode == ViewMode.Raw)
1098 {
1099 bitmap = b.Buffers[index];
1100 }
1101 else
1102 {
1103 bitmap = b.GetEmission(c, b.RChannel.RangeR, b.GChannel.RangeG, b.BChannel.RangeB);
1104 }
1105 if (bitmap == null)
1106 return;
1107 var bm = bitmap.GetImageRGBA();
1108 SKImage skim = BitmapToSKImage(bm);
1109 SKImages.Add(skim);
1110 Bitmaps.Add(bm);
1111 }
1112 }
1113 }
1114 }
async Task UpdateViewAsync(PointD origin, double resolution, ZCT coordinate, int width=600, int height=400)
Update the rendered view asynchronously - main entry point for rendering.

◆ UpdateStatus()

void BioGTK.ImageView.UpdateStatus ( )

It updates the status of the user.

Definition at line 2508 of file ImageView.cs.

2509 {
2510 if (SelectedImage.Buffers.Count == 0)
2511 return;
2512 if (SelectedImage.Type == BioImage.ImageType.well)
2513 {
2514 statusLabel.Text = (zBar.Value + 1) + "/" + (zBar.Adjustment.Upper + 1) + ", " + (cBar.Value + 1) + "/" + (cBar.Adjustment.Upper + 1) + ", " + (tBar.Value + 1) + "/" + (tBar.Adjustment.Upper + 1) + ", " +
2515 mousePoint + mouseColor + ", " + SelectedImage.Buffers[0].PixelFormat.ToString() + ", (" + SelectedImage.Volume.Location.X.ToString("N2") + ", " + SelectedImage.Volume.Location.Y.ToString("N2") + ") "
2516 + Origin.X.ToString("N2") + "," + Origin.Y.ToString("N2") + " , Well:" + SelectedImage.Level;
2517 }
2518 else
2519 statusLabel.Text = (zBar.Value + 1) + "/" + (zBar.Adjustment.Upper + 1) + ", " + (cBar.Value + 1) + "/" + (cBar.Adjustment.Upper + 1) + ", " + (tBar.Value + 1) + "/" + (tBar.Adjustment.Upper + 1) + ", " +
2520 mousePoint + mouseColor + ", " + SelectedImage.Buffers[0].PixelFormat.ToString() + ", (" + SelectedImage.Volume.Location.X.ToString("N2") + ", " + SelectedImage.Volume.Location.Y.ToString("N2") + ") "
2521 + Origin.X.ToString("N2") + "," + Origin.Y.ToString("N2") + ", Res:" + Resolution + " Level:" + Level;
2522 }

◆ UpdateView()

void BioGTK.ImageView.UpdateView ( bool updateImages = true)

It updates the view.

Definition at line 2524 of file ImageView.cs.

2525 {
2526 refresh = true;
2527 if (SelectedImage?.isPyramidal == true)
2528 {
2529 if (!MacOS)
2530 {
2531 // Trigger async tile update
2532 _ = slideRenderer.UpdateViewAsync(
2533 PyramidalOrigin,
2534 glArea.AllocatedWidth,
2535 glArea.AllocatedHeight,
2536 Resolution,
2538 );
2539 }
2540 else
2541 {
2542 AForge.Size s = new AForge.Size();
2543 if (sk.AllocatedWidth <= 1 || sk.AllocatedHeight <= 1)
2544 s = new AForge.Size(600, 400);
2545 else
2546 s = new AForge.Size(sk.AllocatedWidth, sk.AllocatedHeight);
2547 // Trigger async tile update
2548 _ = sKSlideRenderer.UpdateViewAsync(
2549 PyramidalOrigin,
2550 Resolution,
2551 GetCoordinate(),
2552 s.Width,
2553 s.Height
2554 );
2555 }
2556 }
2557 else
2558 {
2559 UpdateImages(true);
2560 if (!MacOS)
2561 {
2562 glArea.RequestRedraw();
2563 }
2564 else
2565 sk.QueueDraw();
2566 }
2567 }
void RequestRedraw()
Request a redraw of the GLArea.

◆ ZoomAtPoint() [1/2]

void BioGTK.ImageView.ZoomAtPoint ( double mouseX,
double mouseY,
bool zoomIn )

Definition at line 2379 of file ImageView.cs.

2380 {
2381 if (SelectedImage == null) return;
2382 float CurrentLevelWidth = SelectedImage.Resolutions[Level].SizeX;
2383 float CurrentLevelHeight = SelectedImage.Resolutions[Level].SizeY;
2384 // 1. Define zoom factor (e.g., 2.0x zoom steps)
2385 float zoomFactor = zoomIn ? 2.0f : 0.5f;
2386
2387 // 2. Get the current level's scale relative to Full Res (Level 0)
2388 // Formula: CurrentLevelWidth / FullResWidth
2389 double currentLevelScale = (double)CurrentLevelWidth / SelectedImage.Resolutions[0].SizeX;
2390
2391 // 3. Find the "World Point" (Full Res Level 0) currently under the mouse
2392 // We add the origin to the mouse offset and then scale up to Level 0
2393 double worldX = (PyramidalOrigin.X + mouseX) / currentLevelScale;
2394 double worldY = (PyramidalOrigin.Y + mouseY) / currentLevelScale;
2395
2396 // 5. Get the NEW level's scale relative to Full Res
2397 double newLevelScale = (double)CurrentLevelWidth / SelectedImage.Resolutions[0].SizeX;
2398
2399 // 6. Calculate the NEW PyramidalOrigin
2400 // To keep the world point at the same mouse position:
2401 // NewOrigin = (WorldPoint * NewScale) - MouseOffset
2402 float newOriginX = (float)(worldX * newLevelScale - mouseX);
2403 float newOriginY = (float)(worldY * newLevelScale - mouseY);
2404
2405 // 7. Apply and Clamp (to ensure we don't scroll past image edges)
2406 PyramidalOrigin = new PointD(
2407 Math.Max(0, Math.Min(newOriginX, CurrentLevelWidth - AllocatedWidth)),
2408 Math.Max(0, Math.Min(newOriginY, CurrentLevelHeight - AllocatedHeight))
2409 );
2410 }

◆ ZoomAtPoint() [2/2]

void BioGTK.ImageView.ZoomAtPoint ( float mouseX,
float mouseY,
bool zoomIn )

Definition at line 2641 of file ImageView.cs.

2642 {
2643 if (SelectedImage == null) return;
2644
2645 // 1. Define zoom factor (e.g., 2.0x zoom steps)
2646 float zoomFactor = zoomIn ? 2.0f : 0.5f;
2647
2648 // 2. Get the current level's scale relative to Full Res (Level 0)
2649 // Formula: CurrentLevelWidth / FullResWidth
2650 double currentLevelScale = (double)SelectedImage.Resolutions[SelectedImage.Level].SizeX / SelectedImage.SizeX;
2651
2652 // 3. Find the "World Point" (Full Res Level 0) currently under the mouse
2653 // We add the origin to the mouse offset and then scale up to Level 0
2654 double worldX = (PyramidalOrigin.X + mouseX) / currentLevelScale;
2655 double worldY = (PyramidalOrigin.Y + mouseY) / currentLevelScale;
2656
2657 // 4. Update your Level logic here
2658 // This is where you switch your 'CurrentLevelWidth' to the next level in the pyramid
2659 //UpdateLevel(zoomIn);
2660
2661 // 5. Get the NEW level's scale relative to Full Res
2662 double newLevelScale = (double)SelectedImage.Resolutions[SelectedImage.Level].SizeX / SelectedImage.SizeX;
2663
2664 // 6. Calculate the NEW PyramidalOrigin
2665 // To keep the world point at the same mouse position:
2666 // NewOrigin = (WorldPoint * NewScale) - MouseOffset
2667 float newOriginX = (float)(worldX * newLevelScale - mouseX);
2668 float newOriginY = (float)(worldY * newLevelScale - mouseY);
2669
2670 // 7. Apply and Clamp (to ensure we don't scroll past image edges)
2671 PyramidalOrigin = new PointD(
2672 Math.Max(0, Math.Min(newOriginX, SelectedImage.Resolutions[SelectedImage.Level].SizeX - AllocatedWidth)),
2673 Math.Max(0, Math.Min(newOriginY, SelectedImage.Resolutions[SelectedImage.Level].SizeY - AllocatedHeight))
2674 );
2675 }

Member Data Documentation

◆ contextMenu

Menu BioGTK.ImageView.contextMenu

Definition at line 217 of file ImageView.cs.

◆ endc

int BioGTK.ImageView.endc = 0
static

Definition at line 1383 of file ImageView.cs.

◆ endt

int BioGTK.ImageView.endt = 0
static

Definition at line 1384 of file ImageView.cs.

◆ endz

int BioGTK.ImageView.endz = 0
static

Definition at line 1382 of file ImageView.cs.

◆ glArea

SlideGLArea BioGTK.ImageView.glArea

Definition at line 254 of file ImageView.cs.

◆ Images

List<BioImage> BioGTK.ImageView.Images = new List<BioImage>()

Definition at line 41 of file ImageView.cs.

◆ keyDown

Gdk.Key BioGTK.ImageView.keyDown = Gdk.Key.Key_3270_Test
static

Definition at line 1964 of file ImageView.cs.

◆ MacOS

bool BioGTK.ImageView.MacOS = false
static

Definition at line 258 of file ImageView.cs.

◆ mainBox

Gtk.Box BioGTK.ImageView.mainBox

Definition at line 207 of file ImageView.cs.

◆ Modifiers

ModifierType BioGTK.ImageView.Modifiers
static

Definition at line 2582 of file ImageView.cs.

◆ mouseLeftState

bool BioGTK.ImageView.mouseLeftState
static

Definition at line 2581 of file ImageView.cs.

◆ selectedROI

ROI BioGTK.ImageView.selectedROI = new ROI()

Definition at line 2591 of file ImageView.cs.

◆ showBROIs

bool BioGTK.ImageView.showBROIs = true

Definition at line 2573 of file ImageView.cs.

◆ showGROIs

bool BioGTK.ImageView.showGROIs = true

Definition at line 2572 of file ImageView.cs.

◆ showRROIs

bool BioGTK.ImageView.showRROIs = true

Definition at line 2571 of file ImageView.cs.

◆ sKSlideRenderer

SKSlideRenderer BioGTK.ImageView.sKSlideRenderer

Definition at line 256 of file ImageView.cs.

◆ slideRenderer

SlideRenderer BioGTK.ImageView.slideRenderer

Definition at line 255 of file ImageView.cs.

◆ startc

int BioGTK.ImageView.startc = 0
static

Definition at line 1380 of file ImageView.cs.

◆ startt

int BioGTK.ImageView.startt = 0
static

Definition at line 1381 of file ImageView.cs.

◆ startz

int BioGTK.ImageView.startz = 0
static

Definition at line 1379 of file ImageView.cs.

◆ waitc

int BioGTK.ImageView.waitc = 1000
static

Definition at line 1377 of file ImageView.cs.

◆ waitt

int BioGTK.ImageView.waitt = 1000
static

Definition at line 1378 of file ImageView.cs.

◆ waitz

int BioGTK.ImageView.waitz = 1000
static

Definition at line 1376 of file ImageView.cs.

◆ window

GLWindow BioGTK.ImageView.window

Definition at line 257 of file ImageView.cs.

◆ x1State

bool BioGTK.ImageView.x1State
static

Definition at line 2579 of file ImageView.cs.

◆ x2State

bool BioGTK.ImageView.x2State
static

Definition at line 2580 of file ImageView.cs.

Property Documentation

◆ AllowNavigation

bool BioGTK.ImageView.AllowNavigation
getset

Definition at line 148 of file ImageView.cs.

149 {
150 get { return allowNavigation; }
151 set { allowNavigation = value; }
152 }

◆ BChannel

Channel BioGTK.ImageView.BChannel
get

Definition at line 2315 of file ImageView.cs.

2316 {
2317 get
2318 {
2319 return SelectedImage.Channels[SelectedImage.rgbChannels[2]];
2320 }
2321 }

◆ GChannel

Channel BioGTK.ImageView.GChannel
get

Definition at line 2307 of file ImageView.cs.

2308 {
2309 get
2310 {
2311 return SelectedImage.Channels[SelectedImage.rgbChannels[1]];
2312 }
2313 }

◆ ImageViewHeight

double BioGTK.ImageView.ImageViewHeight
get

Definition at line 2962 of file ImageView.cs.

2963 {
2964 get
2965 {
2966 double d = glArea.AllocatedHeight / Resolution;
2967 return d;
2968 }
2969 }

◆ ImageViewWidth

double BioGTK.ImageView.ImageViewWidth
get

Definition at line 2954 of file ImageView.cs.

2955 {
2956 get
2957 {
2958 double d = glArea.AllocatedWidth / Resolution;
2959 return d;
2960 }
2961 }

◆ LabelResolution

int? BioGTK.ImageView.LabelResolution
get

Definition at line 1123 of file ImageView.cs.

1123{ get { return SelectedImage.LabelResolution; } }

◆ Level

int BioGTK.ImageView.Level
getset

Definition at line 2461 of file ImageView.cs.

2462 {
2463 get
2464 {
2465 if (SelectedImage.Type == BioImage.ImageType.well)
2466 {
2467 return (int)SelectedImage.Level;
2468 }
2469 if (SelectedImage.isPyramidal)
2470 if (!openSlide)
2471 l = OpenSlideGTK.TileUtil.GetLevel(_slideBase.Schema.Resolutions, Resolution);
2472 else
2473 l = OpenSlideGTK.TileUtil.GetLevel(_openSlideBase.Schema.Resolutions, Resolution);
2474 return l;
2475 }
2476 set
2477 {
2478 if (value < 0)
2479 return;
2480 if (l != value)
2481 {
2482 UpdateLevel();
2483 }
2484 l = value;
2485 SelectedImage.Level = l;
2486 if (SelectedImage.Type == BioImage.ImageType.well)
2487 {
2488 SelectedImage.UpdateBuffersWells();
2489 UpdateView();
2490 }
2491 }
2492 }

◆ MacroResolution

int? BioGTK.ImageView.MacroResolution
get

Definition at line 1122 of file ImageView.cs.

1122{ get { return SelectedImage.MacroResolution; } }

◆ Mode

ViewMode BioGTK.ImageView.Mode
getset

Definition at line 2269 of file ImageView.cs.

2270 {
2271 get
2272 {
2273 return viewMode;
2274 }
2275 set
2276 {
2277 viewMode = value;
2278 if (viewMode == ViewMode.RGBImage)
2279 {
2280 rgbStack.VisibleChild = rgbStack.Children[1];
2281 }
2282 else
2283 if (viewMode == ViewMode.Filtered)
2284 {
2285 rgbStack.VisibleChild = rgbStack.Children[0];
2286 }
2287 else
2288 if (viewMode == ViewMode.Raw)
2289 {
2290 rgbStack.VisibleChild = rgbStack.Children[0];
2291 }
2292 else
2293 {
2294 rgbStack.VisibleChild = rgbStack.Children[0];
2295 }
2296 }
2297 }

◆ MouseDown

PointD BioGTK.ImageView.MouseDown
getset

Definition at line 2608 of file ImageView.cs.

2609 {
2610 get { return mouseDown; }
2611 set { mouseDown = value; }
2612 }

◆ MouseDownInt

PointD BioGTK.ImageView.MouseDownInt
getset

Definition at line 2593 of file ImageView.cs.

2594 {
2595 get { return mouseDownInt; }
2596 set { mouseDownInt = value; }
2597 }

◆ MouseMove

PointD BioGTK.ImageView.MouseMove
getset

Definition at line 2618 of file ImageView.cs.

2619 {
2620 get { return mouseMove; }
2621 set { mouseMove = value; }
2622 }

◆ MouseMoveInt

PointD BioGTK.ImageView.MouseMoveInt
getset

Definition at line 2598 of file ImageView.cs.

2599 {
2600 get { return mouseMoveInt; }
2601 set { mouseMoveInt = value; }
2602 }

◆ MouseUp

PointD BioGTK.ImageView.MouseUp
getset

Definition at line 2613 of file ImageView.cs.

2614 {
2615 get { return mouseUp; }
2616 set { mouseUp = value; }
2617 }

◆ MouseUpInt

PointD BioGTK.ImageView.MouseUpInt
getset

Definition at line 2603 of file ImageView.cs.

2604 {
2605 get { return mouseUpInt; }
2606 set { mouseUpInt = value; }
2607 }

◆ OpenSlide

bool BioGTK.ImageView.OpenSlide
getset

Definition at line 2247 of file ImageView.cs.

2248 {
2249 get { return openSlide; }
2250 set { openSlide = value; }
2251 }

◆ Origin

PointD BioGTK.ImageView.Origin
getset

Definition at line 2324 of file ImageView.cs.

2325 {
2326 get { return origin; }
2327 set
2328 {
2329 if (AllowNavigation)
2330 origin = value;
2331 if (sk != null)
2332 {
2333 UpdateImages();
2334 sk.QueueDraw();
2335 }
2336 }
2337 }

◆ PxHmicron

double BioGTK.ImageView.PxHmicron
getset

Definition at line 125 of file ImageView.cs.

126 {
127 get
128 {
129 if (SelectedImage.Type == BioImage.ImageType.pyramidal)
130 if (openSlide)
131 {
132 int lev = OpenSlideGTK.TileUtil.GetLevel(_openSlideBase.Schema.Resolutions, Resolution);
133 return _openSlideBase.Schema.Resolutions[lev].UnitsPerPixel * pxHmicron;
134 }
135 else
136 {
137 int lev = OpenSlideGTK.TileUtil.GetLevel(_slideBase.Schema.Resolutions, Resolution);
138 return _slideBase.Schema.Resolutions[lev].UnitsPerPixel * pxHmicron;
139 }
140 return pxHmicron;
141 }
142 set
143 {
144 pxHmicron = value;
145 }
146 }

◆ PxWmicron

double BioGTK.ImageView.PxWmicron
getset

Definition at line 102 of file ImageView.cs.

103 {
104 get
105 {
106 if (SelectedImage.Type == BioImage.ImageType.pyramidal)
107 if (openSlide)
108 {
109 int lev = OpenSlideGTK.TileUtil.GetLevel(_openSlideBase.Schema.Resolutions, Resolution);
110 return _openSlideBase.Schema.Resolutions[lev].UnitsPerPixel * pxWmicron;
111 }
112 else
113 {
114 int lev = OpenSlideGTK.TileUtil.GetLevel(_slideBase.Schema.Resolutions, Resolution);
115 return _slideBase.Schema.Resolutions[lev].UnitsPerPixel * pxWmicron;
116 }
117
118 return pxWmicron;
119 }
120 set
121 {
122 pxWmicron = value;
123 }
124 }

◆ PyramidalOrigin

PointD BioGTK.ImageView.PyramidalOrigin
getset

Definition at line 2353 of file ImageView.cs.

2354 {
2355 get
2356 {
2357 return SelectedImage.PyramidalOrigin;
2358 }
2359 set
2360 {
2361 if (!AllowNavigation)
2362 return;
2363 SelectedImage.PyramidalOrigin = value;
2364 if (sk != null)
2365 {
2366 UpdateImages();
2367 sk.QueueDraw();
2368 }
2369 }
2370 }

◆ PyramidalOriginTransformed

PointD BioGTK.ImageView.PyramidalOriginTransformed
getset

Definition at line 2346 of file ImageView.cs.

2347 {
2348 get { return new PointD(PyramidalOrigin.X * Resolution, PyramidalOrigin.Y * Resolution); }
2349 set { PyramidalOrigin = new PointD(value.X / Resolution, value.Y / Resolution); }
2350 }

◆ RChannel

Channel BioGTK.ImageView.RChannel
get

Definition at line 2299 of file ImageView.cs.

2300 {
2301 get
2302 {
2303 return SelectedImage.Channels[SelectedImage.rgbChannels[0]];
2304 }
2305 }

◆ Resolution

double BioGTK.ImageView.Resolution
getset

Definition at line 2411 of file ImageView.cs.

2412 {
2413 get
2414 {
2415 if (!SelectedImage.isPyramidal)
2416 return 1;
2417 return SelectedImage.Resolution;
2418 }
2419 set
2420 {
2421 if (SelectedImage.isPyramidal)
2422 SelectedImage.Resolution = value;
2423 if (sk != null)
2424 {
2425 UpdateImages();
2426 sk.QueueDraw();
2427 }
2428 }
2429 }

◆ Scale

SizeF BioGTK.ImageView.Scale
getset

Definition at line 2496 of file ImageView.cs.

2497 {
2498 get
2499 {
2500 return scale;
2501 }
2502 set
2503 {
2504 scale = value;
2505 }
2506 }

◆ SelectedAnnotation

ROI BioGTK.ImageView.SelectedAnnotation
staticget

Definition at line 2941 of file ImageView.cs.

2942 {
2943 get
2944 {
2945 foreach (var item in SelectedImage.Annotations)
2946 {
2947 if (item.Selected)
2948 return item;
2949 }
2950 return null;
2951 }
2952 }

◆ selectedAnnotations

List<ROI> BioGTK.ImageView.selectedAnnotations
staticget

Definition at line 176 of file ImageView.cs.

177 {
178 get
179 {
180 List<ROI> rois = new List<ROI>();
181 foreach (var item in SelectedImage.Annotations)
182 {
183 if (item.BoundingBox.IntersectsWith(App.viewer.MouseDown))
184 rois.Add(item);
185 }
186 return rois;
187 }
188 }

◆ SelectedBuffer

AForge.Bitmap BioGTK.ImageView.SelectedBuffer
staticget

Definition at line 157 of file ImageView.cs.

158 {
159 get
160 {
161 int ind = SelectedImage.GetFrameIndex(SelectedImage.Coordinate.Z, SelectedImage.Coordinate.C, SelectedImage.Coordinate.T);
162 return SelectedImage.Buffers[ind];
163 }
164 }

◆ SelectedImage

BioImage BioGTK.ImageView.SelectedImage
staticgetset

Definition at line 2252 of file ImageView.cs.

2253 {
2254 get
2255 {
2256 if (App.viewer == null)
2257 return null;
2258 if (App.viewer.Images.Count == 0)
2259 return null;
2260 return App.viewer.Images[App.viewer.SelectedIndex];
2261 }
2262 set
2263 {
2264 App.viewer.Images[App.viewer.SelectedIndex] = value;
2265 }
2266 }

◆ SelectedIndex

int BioGTK.ImageView.SelectedIndex
getset

Definition at line 166 of file ImageView.cs.

167 {
168 get { return selectedIndex; }
169 set
170 {
171 selectedIndex = value;
172 Images[selectedIndex] = SelectedImage;
173 }
174 }

◆ ShowMasks

bool BioGTK.ImageView.ShowMasks = true
getset

Definition at line 154 of file ImageView.cs.

154{ get; set; } = true;

◆ ShowOverview

bool BioGTK.ImageView.ShowOverview = true
getset

Definition at line 155 of file ImageView.cs.

155{ get; set; } = true;

◆ TopRightOrigin

PointD BioGTK.ImageView.TopRightOrigin
get

Definition at line 2339 of file ImageView.cs.

2340 {
2341 get
2342 {
2343 return new PointD((Origin.X - ((glArea.AllocatedWidth / 2) * pxWmicron)), (Origin.Y - ((glArea.AllocatedHeight / 2) * pxHmicron)));
2344 }
2345 }

The documentation for this class was generated from the following file: