BioGTK  6.0.0
A .NET library & program for annotating, editing various microscopy imaging formats using Bioformats supported images. Including whole slide, pyramidal, and series.
All Classes Namespaces Functions
BioGTK.Tools Class Reference
Inheritance diagram for BioGTK.Tools:

Classes

class  Tool
 

Public Member Functions

void UpdateView ()
 
void ToolDown (PointD e, ButtonPressEventArgs buts)
 
void ToolUp (PointD e, ButtonReleaseEventArgs buts)
 
void ToolMove (PointD e, MotionNotifyEventArgs buts)
 

Static Public Member Functions

static Tools Create ()
 
static Tool GetTool (string name)
 
static Tool GetTool (Tool.Type typ)
 

Static Public Attributes

static bool applyToStack = false
 
static ColorTool colorTool
 
static bool rEnabled = true
 
static bool gEnabled = true
 
static bool bEnabled = true
 
static ColorS drawColor = new ColorS(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)
 
static ColorS eraseColor = new ColorS(0, 0, 0)
 
static ColorS tolerance = new ColorS(0, 0, 0)
 
static Rectangle selectionRectangle
 
static Dictionary< string, Tooltools = new Dictionary<string, Tool>()
 
static Tool currentTool
 
static RectangleD selectionRect
 
static TextInput ti = null
 
static ROI selectedROI = null
 
static bool colorOne = true
 

Protected Member Functions

 Tools (Builder builder, IntPtr handle)
 
void SetupHandlers ()
 Sets up the handlers.
 

Properties

static ColorS DrawColor [get, set]
 
static ColorS EraseColor [get, set]
 
static int StrokeWidth [get, set]
 

Detailed Description

Definition at line 22 of file Tools.cs.

Constructor & Destructor Documentation

◆ Tools()

BioGTK.Tools.Tools ( Builder builder,
IntPtr handle )
protected

Definition at line 47 of file Tools.cs.

47 : base(handle)
48 {
49 selectColor.Red = 0;
50 selectColor.Green = 0;
51 selectColor.Blue = 150;
52 selectColor.Alpha= 255;
53 white.Blue = 255;
54 white.Green = 255;
55 white.Red = 255;
56 white.Alpha = 255;
57 _builder = builder;
58 builder.Autoconnect(this);
60 Tool.Init();
61 ColorS col = new ColorS(ushort.MaxValue);
62 //We initialize the tools
63 currentTool = GetTool(Tool.Type.move);
64 floodFiller = new QueueLinearFloodFiller(floodFiller);
65 magicSelect = MagicSelect.Create(0);
66 App.ApplyStyles(this);
67 }
static MagicSelect Create(int index)
static Tool GetTool(string name)
Definition Tools.cs:257
void SetupHandlers()
Sets up the handlers.
Definition Tools.cs:811

Member Function Documentation

◆ Create()

static Tools BioGTK.Tools.Create ( )
static

It creates a new instance of the Tools class, which is a class that inherits from the Gtk.Window class

Returns
A new instance of the Tools class.

Definition at line 40 of file Tools.cs.

41 {
42 Builder builder = new Builder(new FileStream(System.IO.Path.GetDirectoryName(Environment.ProcessPath) + "/" + "Glade/Tools.glade", FileMode.Open));
43 return new Tools(builder, builder.GetObject("tools").Handle);
44 }

◆ GetTool() [1/2]

static Tool BioGTK.Tools.GetTool ( string name)
static

If the tools dictionary contains the name of the tool, return the tool, otherwise return the move tool

Parameters
nameThe name of the tool to get.
Returns
The tool that is being returned is the tool that is being used.

Definition at line 257 of file Tools.cs.

258 {
259 if (tools.ContainsKey(name))
260 return (Tool)tools[name];
261 else
262 return GetTool(Tool.Type.move);
263 }

◆ GetTool() [2/2]

static Tool BioGTK.Tools.GetTool ( Tool.Type typ)
static

It returns a Tool object from the tools dictionary, using the Tool.Type enum as the key

Parameters
typThe type of tool to get.
Returns
The tool object.

Definition at line 269 of file Tools.cs.

270 {
271 return (Tool)tools[typ.ToString()];
272 }

◆ SetupHandlers()

void BioGTK.Tools.SetupHandlers ( )
protected

Sets up the handlers.

It sets up the handlers for the buttons

Definition at line 811 of file Tools.cs.

812 {
813 this.ButtonPressEvent += Tools_ButtonPressEvent;
814 ti = TextInput.Create();
815 view.Drawn += View_Drawn;
816 view.DeleteEvent += View_DeleteEvent;
817 }
static TextInput Create(bool ROItype=true)
Definition TextInput.cs:36

◆ ToolDown()

void BioGTK.Tools.ToolDown ( PointD e,
ButtonPressEventArgs buts )

The function is called when the user clicks the mouse button.

The function checks the current tool and if it's a line, polygon, freeform, rectangle, ellipse, delete, or text tool, it does something.

If the tool is a line tool, it creates a new ROI object and adds it to the list of annotations.

If the tool is a polygon tool, it creates a new ROI object and adds it to the list of annotations.

If the tool is a freeform tool, it creates a new ROI object and adds it to the list of annotations.

If the tool is a rectangle tool, it creates a new ROI object and adds it to the list of annotations.

If the tool is an ellipse tool, it creates a new ROI object and adds it to the list of annotations.

Parameters
PointDA point with double precision
ButtonPressEventArgs
Returns
The return type is void.

Definition at line 315 of file Tools.cs.

316 {
317 if (App.viewer == null || currentTool == null || ImageView.SelectedImage == null)
318 return;
319 Plugins.MouseDown(ImageView.SelectedImage, e, buts);
320 Scripting.UpdateState(Scripting.State.GetDown(e, buts.Event.Button));
321 PointF p = new PointF((float)e.X, (float)e.Y);
322 if (currentTool.type == Tool.Type.line && buts.Event.Button == 1)
323 {
324 selectedROI = new ROI();
325 selectedROI.type = ROI.Type.Line;
326 selectedROI.AddPoint(new PointD(e.X, e.Y));
327 selectedROI.AddPoint(new PointD(e.X, e.Y));
328 selectedROI.coord = App.viewer.GetCoordinate();
329 if (ImageView.SelectedImage.isPyramidal)
330 selectedROI.serie = App.viewer.Level;
331 else
332 selectedROI.serie = ImageView.SelectedImage.series;
333 //ImageView.SelectedImage.Annotations.Add(selectedROI);
334 AddROI(selectedROI);
335 }
336 else
337 if (currentTool.type == Tool.Type.polygon && buts.Event.Button == 1)
338 {
339 if (selectedROI == null)
340 {
341 selectedROI = new ROI();
342 selectedROI.type = ROI.Type.Polygon;
343 selectedROI.AddPoint(new PointD(e.X, e.Y));
344 selectedROI.coord = App.viewer.GetCoordinate();
345 if (ImageView.SelectedImage.isPyramidal)
346 selectedROI.serie = App.viewer.Level;
347 else
348 selectedROI.serie = ImageView.SelectedImage.series;
349 AddROI(selectedROI);
350 }
351 else
352 {
353 //If we click on a point 1 we close this polygon
354 float width = (float)App.viewer.ToScreenScaleW(ROI.selectBoxSize);
355 RectangleD[] rds = selectedROI.GetSelectBoxes();
356 if (rds[0].IntersectsWith(new RectangleD(e.X,e.Y, 1,1)))
357 {
358 selectedROI.closed = true;
359 selectedROI.Selected = false;
360 selectedROI = null;
361 return;
362 }
363 else
364 {
365 if(selectedROI.closed == false)
366 selectedROI.AddPoint(new PointD(e.X, e.Y));
367 }
368 }
369 }
370 else
371 if (currentTool.type == Tool.Type.freeform && buts.Event.Button == 1)
372 {
373 if (selectedROI == null)
374 {
375 selectedROI = new ROI();
376 selectedROI.type = ROI.Type.Freeform;
377 selectedROI.AddPoint(new PointD(e.X, e.Y));
378 selectedROI.coord = App.viewer.GetCoordinate();
379 if (ImageView.SelectedImage.isPyramidal)
380 selectedROI.serie = App.viewer.Level;
381 else
382 selectedROI.serie = ImageView.SelectedImage.series;
383 AddROI(selectedROI);
384 }
385 else
386 {
387 selectedROI.AddPoint(new PointD(e.X, e.Y));
388 }
389 }
390 else
391 if (currentTool.type == Tool.Type.rect && buts.Event.Button == 1)
392 {
393 selectedROI = new ROI();
394 selectedROI.type = ROI.Type.Rectangle;
395 selectedROI.Rect = new RectangleD(e.X, e.Y, 1, 1);
396 selectedROI.coord = App.viewer.GetCoordinate();
397 if (ImageView.SelectedImage.isPyramidal)
398 selectedROI.serie = App.viewer.Level;
399 else
400 selectedROI.serie = ImageView.SelectedImage.series;
401 AddROI(selectedROI);
402 }
403 else
404 if (currentTool.type == Tool.Type.ellipse && buts.Event.Button == 1)
405 {
406 selectedROI = new ROI();
407 selectedROI.type = ROI.Type.Ellipse;
408 selectedROI.Rect = new RectangleD(e.X, e.Y, 1, 1);
409 selectedROI.coord = App.viewer.GetCoordinate();
410 if (ImageView.SelectedImage.isPyramidal)
411 selectedROI.serie = App.viewer.Level;
412 else
413 selectedROI.serie = ImageView.SelectedImage.series;
414 AddROI(selectedROI);
415 }
416 else
417 if (currentTool.type == Tool.Type.delete && buts.Event.Button == 1)
418 {
419 for (int i = 0; i < ImageView.SelectedImage.Annotations.Count; i++)
420 {
421 ROI an = ImageView.SelectedImage.Annotations[i];
422 if (an.BoundingBox.IntersectsWith(new RectangleD(e.X, e.Y, 1,1)))
423 {
424 if (an.selectedPoints.Count == 0)
425 {
426 ImageView.SelectedImage.Annotations.Remove(an);
427 break;
428 }
429 else
430 if (an.selectedPoints.Count == 1 && !(an.type == ROI.Type.Polygon || an.type == ROI.Type.Polyline || an.type == ROI.Type.Freeform))
431 {
432 ImageView.SelectedImage.Annotations.Remove(an);
433 break;
434 }
435 else
436 {
437 if (an.type == ROI.Type.Polygon ||
438 an.type == ROI.Type.Polyline ||
439 an.type == ROI.Type.Freeform)
440 {
441 an.closed = false;
442 an.RemovePoints(an.selectedPoints.ToArray());
443 break;
444 }
445 }
446 }
447 }
448
449 UpdateView();
450 }
451 else
452 if (currentTool.type == Tool.Type.text && buts.Event.Button == 1)
453 {
454 selectedROI = new ROI();
455 selectedROI.type = ROI.Type.Label;
456 if (selectedROI.PointsD.Count == 0)
457 selectedROI.AddPoint(new PointD(e.X, e.Y));
458 else
459 selectedROI.UpdatePoint(new PointD(e.X, e.Y), 0);
460 selectedROI.coord = App.viewer.GetCoordinate();
461 if (ImageView.SelectedImage.isPyramidal)
462 selectedROI.serie = App.viewer.Level;
463 else
464 selectedROI.serie = ImageView.SelectedImage.series;
465 ti = TextInput.Create();
466 ti.ShowAll();
467 ti.Run();
468 AddROI(selectedROI);
469 }
470 else
471 if (buts.Event.Button == 2)
472 {
473 currentTool = GetTool(Tool.Type.pan);
474 }
475 }
void UpdateView()
Definition Tools.cs:275

◆ ToolMove()

void BioGTK.Tools.ToolMove ( PointD e,
MotionNotifyEventArgs buts )

This function is called when the mouse is moved. It is used to update the view when the user is panning, drawing a line, drawing a freeform, drawing a rectangle, drawing an ellipse, selecting a rectangle, deleting an annotation, drawing a magic wand selection, and erasing

Parameters
PointDA point in the image space
MotionNotifyEventArgs
Returns
The return type is void.

Definition at line 646 of file Tools.cs.

647 {
648 if (App.viewer == null)
649 return;
650 Plugins.MouseMove(ImageView.SelectedImage, e, buts);
651 if (buts.Event.State == ModifierType.Button1Mask)
652 Scripting.UpdateState(Scripting.State.GetMove(e, 1));
653 if (buts.Event.State == ModifierType.Button2Mask)
654 Scripting.UpdateState(Scripting.State.GetMove(e, 2));
655 if (buts.Event.State == ModifierType.Button3Mask)
656 Scripting.UpdateState(Scripting.State.GetMove(e, 3));
657 if (buts.Event.State == ModifierType.Button4Mask)
658 Scripting.UpdateState(Scripting.State.GetMove(e, 4));
659 if (buts.Event.State == ModifierType.Button5Mask)
660 Scripting.UpdateState(Scripting.State.GetMove(e, 5));
661 if (buts.Event.State == ModifierType.None)
662 Scripting.UpdateState(Scripting.State.GetMove(e, 0));
663 if ((Tools.currentTool.type == Tools.Tool.Type.pan && buts.Event.State.HasFlag(Gdk.ModifierType.Button1Mask)) || buts.Event.State.HasFlag(Gdk.ModifierType.Button2Mask))
664 {
665 if (ImageView.SelectedImage.isPyramidal)
666 {
667 if (App.viewer.MouseMoveInt.X != 0 || App.viewer.MouseMoveInt.Y != 0)
668 {
669 App.viewer.PyramidalOriginTransformed = new PointD(App.viewer.PyramidalOriginTransformed.X + (App.viewer.MouseDown.X - e.X), App.viewer.PyramidalOriginTransformed.Y + (App.viewer.MouseDown.Y - e.Y));
670 }
671 }
672 else
673 {
674 PointD pf = new PointD(e.X - App.viewer.MouseDown.X, e.Y - App.viewer.MouseDown.Y);
675 App.viewer.Origin = new PointD(App.viewer.Origin.X + pf.X, App.viewer.Origin.Y + pf.Y);
676 }
677 UpdateView();
678 }
679 if (ImageView.SelectedImage == null)
680 return;
681 if (Tools.currentTool.type == Tools.Tool.Type.magic && !buts.Event.State.HasFlag(Gdk.ModifierType.Button1Mask))
682 {
683 //First we draw the selection rectangle
684 PointD d = new PointD(e.X - App.viewer.MouseDown.X, e.Y - App.viewer.MouseDown.Y);
685 Tools.GetTool(Tools.Tool.Type.select).Rectangle = new RectangleD(App.viewer.MouseDown.X, App.viewer.MouseDown.Y, d.X, d.Y);
686 UpdateView();
687 }
688
689 if (currentTool.type == Tool.Type.move && buts.Event.State.HasFlag(Gdk.ModifierType.Button1Mask))
690 {
691 if(selectedROI!=null)
692 for (int i = 0; i < selectedROI.PointsD.Count; i++)
693 {
694 PointD pd = new PointD(e.X - App.viewer.MouseDown.X, e.Y - App.viewer.MouseDown.Y);
695 selectedROI.UpdatePoint(new PointD(selectedROI.PointsD[i].X + pd.X, selectedROI.PointsD[i].Y + pd.Y), i);
696 }
697 UpdateView();
698 }
699 if (currentTool.type == Tool.Type.line && buts.Event.State.HasFlag(Gdk.ModifierType.Button1Mask))
700 {
701 selectedROI.UpdatePoint(new PointD(e.X, e.Y), 1);
702 UpdateView();
703 }
704 else
705 if (currentTool.type == Tool.Type.freeform && buts.Event.State.HasFlag(Gdk.ModifierType.Button1Mask))
706 {
707 if (selectedROI.GetPointCount() == 0)
708 {
709 selectedROI.type = ROI.Type.Freeform;
710 selectedROI.AddPoint(new PointD(e.X, e.Y));
711 selectedROI.coord = App.viewer.GetCoordinate();
712 selectedROI.closed = true;
713 //ImageView.SelectedImage.Annotations.Add(selectedROI);
714 AddROI(selectedROI);
715 }
716 else
717 {
718 selectedROI.AddPoint(new PointD(e.X, e.Y));
719 }
720 UpdateView();
721 }
722 else
723 if (currentTool.type == Tool.Type.rect)
724 {
725 if (selectedROI != null)
726 if (selectedROI.GetPointCount() == 4)
727 {
728 selectedROI.Rect = new RectangleD(selectedROI.X, selectedROI.Y, e.X - selectedROI.X, e.Y - selectedROI.Y);
729 }
730 }
731 else
732 if (currentTool.type == Tool.Type.ellipse && selectedROI.type == ROI.Type.Ellipse)
733 {
734 if (selectedROI.GetPointCount() == 4)
735 {
736 selectedROI.Rect = new RectangleD(selectedROI.X, selectedROI.Y, e.X - selectedROI.X, e.Y - selectedROI.Y);
737 UpdateView();
738 }
739 }
740 else
741 if (currentTool.type == Tool.Type.select && buts.Event.State.HasFlag(Gdk.ModifierType.Button1Mask))
742 {
743 PointD d = new PointD(e.X - App.viewer.MouseDown.X, e.Y - App.viewer.MouseDown.Y);
744 Tools.GetTool(Tools.Tool.Type.select).Rectangle = new RectangleD(App.viewer.MouseDown.X, App.viewer.MouseDown.Y,Math.Abs(d.X),Math.Abs(d.Y));
745 RectangleD r = Tools.GetTool(Tools.Tool.Type.select).Rectangle;
746 List<ROI> rois = ImageView.SelectedImage.Annotations;
747 foreach (ROI an in rois)
748 {
749 if (an.GetSelectBound(ROI.selectBoxSize * ImageView.SelectedImage.PhysicalSizeX, ROI.selectBoxSize * ImageView.SelectedImage.PhysicalSizeY).IntersectsWith(r))
750 {
751 an.selectedPoints.Clear();
752 an.Selected = true;
753 RectangleD[] sels = an.GetSelectBoxes();
754 for (int i = 0; i < sels.Length; i++)
755 {
756 if (sels[i].IntersectsWith(r))
757 {
758 an.selectedPoints.Add(i);
759 }
760 }
761 }
762 }
763 App.viewer.UpdateView();
764 }
765 else if(currentTool.type == Tool.Type.brush)
766 {
767 App.viewer.UpdateImages();
768 App.viewer.UpdateView();
769 }
770 else
771 if (ImageView.keyDown == Gdk.Key.Delete)
772 {
773 foreach (ROI an in ImageView.selectedAnnotations)
774 {
775 if (an != null)
776 {
777 if (an.selectedPoints.Count == 0)
778 {
779 ImageView.SelectedImage.Annotations.Remove(an);
780 }
781 else
782 {
783 if (an.type == ROI.Type.Polygon ||
784 an.type == ROI.Type.Polyline ||
785 an.type == ROI.Type.Freeform)
786 {
787 an.closed = false;
788 an.RemovePoints(an.selectedPoints.ToArray());
789 }
790 }
791 }
792 }
793 UpdateView();
794 }
795 if (Tools.currentTool.type == Tools.Tool.Type.magic && buts.Event.State.HasFlag(Gdk.ModifierType.Button1Mask))
796 {
797 //First we draw the selection rectangle
798 PointD d = new PointD(e.X - App.viewer.MouseDown.X, e.Y - App.viewer.MouseDown.Y);
799 Tools.GetTool(Tools.Tool.Type.select).Rectangle = new RectangleD(App.viewer.MouseDown.X, App.viewer.MouseDown.Y, d.X, d.Y);
800 UpdateView();
801 }
802 }

◆ ToolUp()

void BioGTK.Tools.ToolUp ( PointD e,
ButtonReleaseEventArgs buts )

The function is called when the mouse button is released

Parameters
PointDA point with double precision
ButtonReleaseEventArgs
Returns
The return type is void.

Definition at line 482 of file Tools.cs.

483 {
484 Plugins.MouseUp(ImageView.SelectedImage, e, buts);
485 PointD p = new PointD((float)e.X, (float)e.Y);
486 PointD MouseU = ImageView.SelectedImage.ToImageSpace(p);
487 PointD MouseD = ImageView.SelectedImage.ToImageSpace(new PointD(App.viewer.MouseDown.X,App.viewer.MouseDown.Y));
488 if (App.viewer == null || currentTool == null || ImageView.SelectedImage == null)
489 return;
490 Scripting.UpdateState(Scripting.State.GetUp(e, buts.Event.Button));
491 if (currentTool.type == Tool.Type.pan && buts.Event.Button == 2)
492 currentTool = GetTool(Tool.Type.move);
493 if (currentTool.type == Tool.Type.point && buts.Event.Button == 1)
494 {
495 ROI an = new ROI();
496 an.AddPoint(new PointD(e.X, e.Y));
497 an.type = ROI.Type.Point;
498 an.coord = App.viewer.GetCoordinate();
499 an.Selected = true;
500 selectedROI = an;
501 //ImageView.SelectedImage.Annotations.Add(an);
502 AddROI(an);
503 }
504 else
505 if (Tools.currentTool.type == Tools.Tool.Type.bucket && buts.Event.Button == 1)
506 {
507 if (MouseU.X >= ImageView.SelectedImage.SizeX && MouseU.Y >= ImageView.SelectedImage.SizeY)
508 return;
509 floodFiller.FillColor = DrawColor;
510 floodFiller.Tolerance = new ColorS(0, 0, 0);
511 floodFiller.Bitmap = ImageView.SelectedBuffer;
512 floodFiller.FloodFill(new AForge.Point((int)MouseU.X, (int)MouseU.Y));
513 App.viewer.UpdateImages();
514 App.viewer.UpdateView();
515 }
516 else
517 if (Tools.currentTool.type == Tools.Tool.Type.dropper && buts.Event.Button == 1)
518 {
519 if (MouseU.X < ImageView.SelectedImage.SizeX && MouseU.Y < ImageView.SelectedImage.SizeY)
520 {
521 DrawColor = ImageView.SelectedBuffer.GetPixel((int)MouseU.X, (int)MouseU.Y);
522 }
523 }
524 else
525 if (Tools.currentTool.type == Tools.Tool.Type.magic && buts.Event.Button == 1)
526 {
527 // Define the rectangle from mouse coordinates
528 RectangleD rectangle = new RectangleD(
529 App.viewer.MouseDown.X,
530 App.viewer.MouseDown.Y,
531 Math.Abs(App.viewer.MouseUp.X - App.viewer.MouseDown.X),
532 Math.Abs(App.viewer.MouseUp.Y - App.viewer.MouseDown.Y)
533 );
534
535 // Convert to image space coordinates
536 AForge.RectangleF rectInImageSpace = ImageView.SelectedImage.ToImageSpace(rectangle);
537 ZCT coord = App.viewer.GetCoordinate();
538 Bitmap bitmap;
539
540 // Check the number of RGB channels to choose filtering method
541 if (ImageView.SelectedImage.Buffers[0].RGBChannelsCount > 1)
542 {
543 bitmap = ImageView.SelectedImage.GetFiltered(
544 coord,
545 new IntRange((int)ImageView.SelectedBuffer.Stats[0].Min, (int)ImageView.SelectedBuffer.Stats[0].Max),
546 new IntRange((int)ImageView.SelectedBuffer.Stats[1].Min, (int)ImageView.SelectedBuffer.Stats[1].Max),
547 new IntRange((int)ImageView.SelectedBuffer.Stats[2].Min, (int)ImageView.SelectedBuffer.Stats[2].Max)
548 );
549 }
550 else
551 {
552 bitmap = ImageView.SelectedImage.GetFiltered(
553 coord,
554 new IntRange((int)ImageView.SelectedBuffer.Stats[0].Min, (int)ImageView.SelectedBuffer.Stats[0].Max),
555 new IntRange((int)ImageView.SelectedBuffer.Stats[0].Min, (int)ImageView.SelectedBuffer.Stats[0].Max),
556 new IntRange((int)ImageView.SelectedBuffer.Stats[0].Min, (int)ImageView.SelectedBuffer.Stats[0].Max)
557 );
558 }
559
560 // Crop the image to the selected rectangle
561 bitmap.Crop(rectInImageSpace.ToRectangleInt());
562 // Determine the threshold based on magicSelect settings
563 Statistics[] st = Statistics.FromBytes(bitmap.Bytes, bitmap.SizeX, bitmap.Height, bitmap.RGBChannelsCount, bitmap.BitsPerPixel, bitmap.Stride, bitmap.PixelFormat);
564 int threshold = magicSelect.Numeric ? magicSelect.Threshold : CalculateThreshold(magicSelect.Index, st[0]);
565 BlobCounter blobCounter = new BlobCounter();
566 OtsuThreshold th = new OtsuThreshold();
567 th.ApplyInPlace(bitmap);
568 blobCounter.FilterBlobs = true;
569 blobCounter.MinWidth = 2;
570 blobCounter.MinHeight = 2;
571 blobCounter.ProcessImage(bitmap);
572 // Retrieve detected blobs
573 Blob[] blobs = blobCounter.GetObjectsInformation();
574 double pixelSizeX = ImageView.SelectedImage.PhysicalSizeX;
575 double pixelSizeY = ImageView.SelectedImage.PhysicalSizeY;
576 // Annotate detected blobs in the original image
577 foreach (Blob blob in blobs)
578 {
579 AForge.RectangleD blobRectangle = new AForge.RectangleD(
580 blob.Rectangle.X * pixelSizeX,
581 blob.Rectangle.Y * pixelSizeY,
582 blob.Rectangle.Width * pixelSizeX,
583 blob.Rectangle.Height * pixelSizeY
584 );
585 // Calculate the location of the detected blob
586 PointD location = new PointD(rectangle.X + blobRectangle.X, rectangle.Y + blobRectangle.Y);
587 // Create and add ROI annotation
588 ROI annotation = ROI.CreateRectangle(coord, location.X, location.Y, blobRectangle.W, blobRectangle.H);
589 ImageView.SelectedImage.Annotations.Add(annotation);
590 }
591 App.viewer.UpdateView(true);
592 }
593
594 if (selectedROI == null)
595 return;
596 if (currentTool.type == Tool.Type.line && selectedROI.type == ROI.Type.Line && buts.Event.Button == 1)
597 {
598 if (selectedROI.GetPointCount() > 0)
599 {
600 selectedROI.UpdatePoint(new PointD(e.X, e.Y), 1);
601 selectedROI = null;
602 }
603 }
604 else
605 if (currentTool.type == Tool.Type.rect && selectedROI.type == ROI.Type.Rectangle && buts.Event.Button == 1)
606 {
607 if (selectedROI.GetPointCount() == 4)
608 {
609 selectedROI = null;
610 }
611 }
612 else
613 if (currentTool.type == Tool.Type.ellipse && selectedROI.type == ROI.Type.Ellipse && buts.Event.Button == 1)
614 {
615 if (selectedROI.GetPointCount() == 4)
616 {
617 selectedROI = null;
618 }
619 }
620 else
621 if (currentTool.type == Tool.Type.freeform && selectedROI.type == ROI.Type.Freeform && buts.Event.Button == 1)
622 {
623 selectedROI = null;
624 }
625
626 }

◆ UpdateView()

void BioGTK.Tools.UpdateView ( )

UpdateView() is a function that updates the view of the viewer.

Definition at line 275 of file Tools.cs.

276 {
277 App.viewer.UpdateView();
278 }

Member Data Documentation

◆ applyToStack

bool BioGTK.Tools.applyToStack = false
static

Definition at line 71 of file Tools.cs.

◆ bEnabled

bool BioGTK.Tools.bEnabled = true
static

Definition at line 75 of file Tools.cs.

◆ colorOne

bool BioGTK.Tools.colorOne = true
static

Definition at line 908 of file Tools.cs.

◆ colorTool

ColorTool BioGTK.Tools.colorTool
static

Definition at line 72 of file Tools.cs.

◆ currentTool

Tool BioGTK.Tools.currentTool
static

Definition at line 208 of file Tools.cs.

◆ drawColor

ColorS BioGTK.Tools.drawColor = new ColorS(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)
static

Definition at line 76 of file Tools.cs.

◆ eraseColor

ColorS BioGTK.Tools.eraseColor = new ColorS(0, 0, 0)
static

Definition at line 77 of file Tools.cs.

◆ gEnabled

bool BioGTK.Tools.gEnabled = true
static

Definition at line 74 of file Tools.cs.

◆ rEnabled

bool BioGTK.Tools.rEnabled = true
static

Definition at line 73 of file Tools.cs.

◆ selectedROI

ROI BioGTK.Tools.selectedROI = null
static

Definition at line 281 of file Tools.cs.

◆ selectionRect

RectangleD BioGTK.Tools.selectionRect
static

Definition at line 248 of file Tools.cs.

◆ selectionRectangle

Rectangle BioGTK.Tools.selectionRectangle
static

Definition at line 82 of file Tools.cs.

◆ ti

TextInput BioGTK.Tools.ti = null
static

Definition at line 249 of file Tools.cs.

◆ tolerance

ColorS BioGTK.Tools.tolerance = new ColorS(0, 0, 0)
static

Definition at line 78 of file Tools.cs.

◆ tools

Dictionary<string,Tool> BioGTK.Tools.tools = new Dictionary<string, Tool>()
static

Definition at line 83 of file Tools.cs.

Property Documentation

◆ DrawColor

ColorS BioGTK.Tools.DrawColor
staticgetset

Definition at line 210 of file Tools.cs.

211 {
212 get
213 {
214 return drawColor;
215 }
216 set
217 {
218 drawColor = value;
219 tools[Tool.Type.color1.ToString()].color = drawColor;
220 }
221 }

◆ EraseColor

ColorS BioGTK.Tools.EraseColor
staticgetset

Definition at line 223 of file Tools.cs.

224 {
225 get
226 {
227 return eraseColor;
228 }
229 set
230 {
231 eraseColor = value;
232 tools[Tool.Type.color2.ToString()].color = eraseColor;
233 }
234 }

◆ StrokeWidth

int BioGTK.Tools.StrokeWidth
staticgetset

Definition at line 237 of file Tools.cs.

238 {
239 get
240 {
241 return width;
242 }
243 set
244 {
245 width = value;
246 }
247 }

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