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
Bio.ROIManager Class Reference
Inheritance diagram for Bio.ROIManager:

Public Member Functions

void CopySelection ()
 It takes the selected ROIs and copies them to the clipboard.
 
void PasteSelection ()
 
void InitItems ()
 
void UpdateAnnotationList ()
 
void updateROI (int index, ROI an)
 
void UpdatePointBox ()
 

Static Public Member Functions

static ROIManager Create ()
 

Public Attributes

BioImage image
 
ROI anno = new ROI()
 
bool autoUpdate = true
 

Static Public Attributes

static bool showBounds = true
 
static bool showText = false
 
static bool showR = true
 
static bool showG = true
 
static bool showB = true
 

Protected Member Functions

 ROIManager (Builder builder, IntPtr handle)
 

Properties

static Dictionary< string, ROI > rois [get, set]
 

Detailed Description

Definition at line 16 of file ROIManager.cs.

Constructor & Destructor Documentation

◆ ROIManager()

Bio.ROIManager.ROIManager ( Builder builder,
IntPtr handle )
protected

Definition at line 119 of file ROIManager.cs.

119 : base(handle)
120 {
121 _builder = builder;
122 builder.Autoconnect(this);
123 xBox.ValueChanged += xBox_ValueChanged;
124 yBox.ValueChanged += yBox_ValueChanged;
125 wBox.ValueChanged += wBox_ValueChanged;
126 hBox.ValueChanged += hBox_ValueChanged;
127 rBox.ValueChanged += rBox_ValueChanged;
128 gBox.ValueChanged += gBox_ValueChanged;
129 bBox.ValueChanged += bBox_ValueChanged;
130 zBox.ValueChanged += zBox_ValueChanged;
131 cBox.ValueChanged += cBox_ValueChanged;
132 tBox.ValueChanged += tBox_ValueChanged;
133 widthBox.ValueChanged += strokeWBox_ValueChanged;
134 pointXBox.ValueChanged += pointXBox_ValueChanged;
135 pointYBox.ValueChanged += pointYBox_ValueChanged;
136 pointBox.ValueChanged += pointBox_ValueChanged;
137 selBox.ValueChanged += selectBoxSize_ValueChanged;
138 widthBox.ValueChanged += strokeWBox_ValueChanged;
139 textBox.Changed += textBox_TextChanged;
140 idBox.Changed += idBox_TextChanged;
141 boundsBox.Clicked += showBoundsBox_ActiveChanged;
142 showTextBox.Clicked += showTextBox_ActiveChanged;
143 showRBox.Clicked += showRBox_ActiveChanged;
144 showGBox.Clicked += showGBox_ActiveChanged;
145 showBBox.Clicked += showBBox_ActiveChanged;
146 showMasksBox.Clicked += ShowMasksBox_Clicked;
147 this.DeleteEvent += ROIManager_DeleteEvent;
148 menuDelete.ButtonPressEvent += MenuDelete_ButtonPressEvent;
149 menuCopy.ButtonPressEvent += MenuCopy_ButtonPressEvent;
150 menuPaste.ButtonPressEvent += MenuPaste_ButtonPressEvent;
151
152 //roiView.Selection.Changed += roiView_SelectedIndexChanged;
153 roiView.RowActivated += RoiView_RowActivated;
154 this.FocusInEvent += ROIManager_FocusInEvent;
155 this.FocusActivated += ROIManager_Activated;
156 roiView.ButtonPressEvent += RoiView_ButtonPressEvent;
157
158 xBox.Adjustment.Upper = PointD.MaxX;
159 xBox.Adjustment.StepIncrement= 0.1;
160 xBox.Adjustment.PageIncrement= 1;
161 yBox.Adjustment.Upper = PointD.MaxY;
162 yBox.Adjustment.StepIncrement = 0.1;
163 yBox.Adjustment.PageIncrement = 1;
164 wBox.Adjustment.Upper = PointD.MaxX;
165 wBox.Adjustment.StepIncrement = 0.1;
166 wBox.Adjustment.PageIncrement = 1;
167 hBox.Adjustment.Upper = PointD.MaxY;
168 xBox.Adjustment.StepIncrement = 0.1;
169 xBox.Adjustment.PageIncrement = 1;
170 rBox.Adjustment.Upper = byte.MaxValue;
171 rBox.Adjustment.StepIncrement = 1;
172 rBox.Adjustment.PageIncrement = 1;
173 gBox.Adjustment.Upper = byte.MaxValue;
174 gBox.Adjustment.StepIncrement = 1;
175 gBox.Adjustment.PageIncrement = 1;
176 bBox.Adjustment.Upper = byte.MaxValue;
177 bBox.Adjustment.StepIncrement = 1;
178 bBox.Adjustment.PageIncrement = 1;
179 zBox.Adjustment.Upper = 10000;
180 zBox.Adjustment.StepIncrement = 1;
181 zBox.Adjustment.PageIncrement = 1;
182 cBox.Adjustment.Upper = 10000;
183 cBox.Adjustment.StepIncrement = 1;
184 cBox.Adjustment.PageIncrement = 1;
185 tBox.Adjustment.Upper = 10000;
186 tBox.Adjustment.StepIncrement = 1;
187 tBox.Adjustment.PageIncrement = 1;
188 widthBox.Adjustment.Upper = 100;
189 widthBox.Adjustment.StepIncrement = 1;
190 widthBox.Adjustment.PageIncrement = 1;
191 pointBox.Adjustment.Upper = 100000;
192 pointBox.Adjustment.StepIncrement = 1;
193 pointBox.Adjustment.PageIncrement = 1;
194 pointXBox.Adjustment.Upper = PointD.MaxX;
195 pointXBox.Adjustment.StepIncrement = 0.1;
196 pointXBox.Adjustment.PageIncrement = 1;
197 pointYBox.Adjustment.Upper = PointD.MaxY;
198 pointYBox.Adjustment.StepIncrement = 0.1;
199 pointYBox.Adjustment.PageIncrement = 1;
200 selBox.Value = ROI.selectBoxSize;
201 selBox.Adjustment.Upper = 100;
202 selBox.Adjustment.StepIncrement = 1;
203 roiView.ActivateOnSingleClick = true;
204 InitItems();
205 App.ApplyStyles(this);
206 }

Member Function Documentation

◆ CopySelection()

void Bio.ROIManager.CopySelection ( )

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

Definition at line 216 of file ROIManager.cs.

217 {
218 copys.Clear();
219 string s = "";
220 List<ROI> rois = new List<ROI>();
221 rois.AddRange(ImageView.SelectedImage.AnnotationsR);
222 rois.AddRange(ImageView.SelectedImage.AnnotationsG);
223 rois.AddRange(ImageView.SelectedImage.AnnotationsB);
224 foreach (ROI item in rois)
225 {
226 if (item.Selected)
227 {
228 copys.Add(item);
229 s += BioImage.ROIToString(item);
230 }
231 }
232 Clipboard clipboard = Clipboard.Get(Gdk.Selection.Clipboard);
233 clipboard.Text = s;
234 }

◆ Create()

static ROIManager Bio.ROIManager.Create ( )
static

Definition at line 113 of file ROIManager.cs.

114 {
115 Builder builder = new Builder(new FileStream(System.IO.Path.GetDirectoryName(Environment.ProcessPath) + "/" + "Glade/ROIManager.glade", FileMode.Open));
116 return new ROIManager(builder, builder.GetObject("roiManager").Handle);
117 }

◆ InitItems()

void Bio.ROIManager.InitItems ( )

It creates a treeview with 4 columns, and then populates the treeview with the data from the Images class

Definition at line 359 of file ROIManager.cs.

360 {
361 Gtk.TreeViewColumn typeCol = new Gtk.TreeViewColumn();
362 typeCol.Title = "Type";
363 Gtk.CellRendererText typeCell = new Gtk.CellRendererText();
364 typeCol.PackStart(typeCell, true);
365
366 Gtk.TreeViewColumn idCol = new Gtk.TreeViewColumn();
367 idCol.Title = "ID";
368 Gtk.CellRendererText idCell = new Gtk.CellRendererText();
369 idCol.PackStart(idCell, true);
370
371 Gtk.TreeViewColumn textCol = new Gtk.TreeViewColumn();
372 textCol.Title = "Text";
373 Gtk.CellRendererText textCell = new Gtk.CellRendererText();
374 textCol.PackStart(textCell, true);
375
376 Gtk.TreeViewColumn rectCol = new Gtk.TreeViewColumn();
377 rectCol.Title = "Bounds";
378 Gtk.CellRendererText rectCell = new Gtk.CellRendererText();
379 rectCol.PackStart(rectCell, true);
380
381
382 roiView.AppendColumn(typeCol);
383 roiView.AppendColumn(idCol);
384 roiView.AppendColumn(textCol);
385 roiView.AppendColumn(rectCol);
386
387 typeCol.AddAttribute(typeCell, "text", 0);
388 idCol.AddAttribute(idCell, "text", 1);
389 textCol.AddAttribute(textCell, "text", 2);
390 rectCol.AddAttribute(rectCell, "text", 3);
391
392 Gtk.TreeStore store = new Gtk.TreeStore(typeof(string), typeof(string), typeof(string), typeof(string));
393
394 foreach (BioImage b in Images.images)
395 {
396 Gtk.TreeIter iter = store.AppendValues(System.IO.Path.GetFileName(b.Filename));
397 foreach (ROI r in b.Annotations)
398 {
399 store.AppendValues(iter, r.type.ToString(), r.id, r.Text, r.BoundingBox.ToString());
400 }
401 }
402 roiView.Model = store;
403
404 }

◆ PasteSelection()

void Bio.ROIManager.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 237 of file ROIManager.cs.

238 {
239 Clipboard clipboard = Clipboard.Get(Gdk.Selection.Clipboard);
240 string text = clipboard.WaitForText();
241 string[] sts = text.Split(BioImage.NewLine);
242 foreach (string line in sts)
243 {
244 if (line.Length > 8)
245 {
246 ROI an = BioImage.StringToROI(line);
247 //We set the coordinates of the ROI's we are pasting
248 an.coord = App.viewer.GetCoordinate();
249 ImageView.SelectedImage.Annotations.Add(an);
250 }
251 }
252 UpdateView();
253 }

◆ UpdateAnnotationList()

void Bio.ROIManager.UpdateAnnotationList ( )

It takes a list of images, and for each image, it takes a list of annotations, and for each annotation, it adds the annotation to a dictionary, and then adds the annotation to a treeview

Definition at line 408 of file ROIManager.cs.

409 {
410 rois.Clear();
411 Gtk.TreeStore store = new Gtk.TreeStore(typeof(string), typeof(string), typeof(string), typeof(string));
412 foreach (BioImage b in Images.images)
413 {
414 Gtk.TreeIter iter = store.AppendValues(System.IO.Path.GetFileName(b.Filename));
415 foreach (ROI r in b.Annotations)
416 {
417 if (r.id == "")
418 {
419 store.AppendValues(iter, r.type.ToString(), rng.Next(), r.Text, r.BoundingBox.ToString());
420 }
421 else
422 {
423 if(!rois.ContainsKey(r.id))
424 rois.Add(r.id, r);
425 store.AppendValues(iter, r.type.ToString(), r.id, r.Text, r.BoundingBox.ToString());
426 }
427 }
428 }
429 roiView.Model = store;
430 }

◆ UpdatePointBox()

void Bio.ROIManager.UpdatePointBox ( )

This function updates the point box with the current point

Returns
The point of the annotation.

Definition at line 716 of file ROIManager.cs.

717 {
718 if (anno == null)
719 return;
720 PointD d = anno.GetPoint((int)pointBox.Value);
721 pointXBox.Value = (int)d.X;
722 pointYBox.Value = (int)d.Y;
723 }

◆ updateROI()

void Bio.ROIManager.updateROI ( int index,
ROI an )

‍Update the ROI at the specified index with the specified ROI

Parameters
indexthe index of the annotation to be updated
ROIThe ROI object to be updated
Returns
The ROI object is being returned.

Definition at line 443 of file ROIManager.cs.

444 {
445 if (ImageView.SelectedImage == null)
446 return;
447 ImageView.SelectedImage.Annotations[index] = an;
448 UpdateView();
449 }

Member Data Documentation

◆ anno

ROI Bio.ROIManager.anno = new ROI()

Definition at line 301 of file ROIManager.cs.

◆ autoUpdate

bool Bio.ROIManager.autoUpdate = true

Definition at line 712 of file ROIManager.cs.

◆ image

BioImage Bio.ROIManager.image

Definition at line 91 of file ROIManager.cs.

◆ showB

bool Bio.ROIManager.showB = true
static

Definition at line 660 of file ROIManager.cs.

◆ showBounds

bool Bio.ROIManager.showBounds = true
static

Definition at line 656 of file ROIManager.cs.

◆ showG

bool Bio.ROIManager.showG = true
static

Definition at line 659 of file ROIManager.cs.

◆ showR

bool Bio.ROIManager.showR = true
static

Definition at line 658 of file ROIManager.cs.

◆ showText

bool Bio.ROIManager.showText = false
static

Definition at line 657 of file ROIManager.cs.

Property Documentation

◆ rois

Dictionary<string, ROI> Bio.ROIManager.rois
staticgetset

Definition at line 93 of file ROIManager.cs.

94 {
95 get
96 {
97 foreach (var item in ImageView.SelectedImage.Annotations)
98 {
99 if(!rts.ContainsKey(item.id))
100 {
101 if (item.id == "" || item.id == null)
102 item.id = rng.Next(0,999999).ToString();
103 rts.Add(item.id, item);
104 }
105 }
106 return rts;
107 }
108 set
109 {
110 rts = value;
111 }
112 }

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