diff --git a/BioGTK.csproj b/BioGTK.csproj
index 3ff41ca..5f7cb31 100644
--- a/BioGTK.csproj
+++ b/BioGTK.csproj
@@ -4,25 +4,25 @@
net6.0
Library
osx-x64;linux-x64;win7-x64;linux-arm64;osx-arm64
- 2.9.0
- 2.9.0
+ 3.0.0
+ 3.0.0
True
BioGTK
BioGTK
https://github.com/BiologyTools/BioGTK
banner.jpg
README.md
- 2.9.0
+ 3.0.0
https://github.com/BiologyTools/BioGTK
Biology; GTK; ImageJ; Bio-Formats; Image-Stacks; Microscopy;
GPL-3.0-only
True
A .NET application & library for editing & annotating various microscopy image formats. Supports all bioformats supported images. Integrates with ImageJ, running ImageJ filters & macro functions. Supports Windows, Linux and Mac.
- 2.9.0
+ 3.0.0
AnyCPU;x64;ARM64
True
x64
- GUI bug fixes.
+ Added Plotting functionality, and find focus function.
ErikRepo
diff --git a/Glade/Plot.glade b/Glade/Plot.glade
index 99e27bc..8ca2138 100644
--- a/Glade/Plot.glade
+++ b/Glade/Plot.glade
@@ -4,10 +4,103 @@
diff --git a/Source/Plot.cs b/Source/Plot.cs
index 57ad2b9..0eb861b 100644
--- a/Source/Plot.cs
+++ b/Source/Plot.cs
@@ -12,6 +12,7 @@
using org.checkerframework.checker.units.qual;
using ScottPlot;
using System.Threading;
+using System.IO;
namespace BioGTK
{
@@ -23,6 +24,19 @@ public class Plot : Gtk.Window
Bitmap bitmap;
List data = new List();
static Dictionary plots = new Dictionary();
+
+ public enum PlotType
+ {
+ Bar,
+ Signal,
+ Scatter
+ }
+ PlotType type;
+ public PlotType Type
+ {
+ get { return type; }
+ set { type = value; }
+ }
public static Dictionary Plots
{
get { return plots; }
@@ -42,11 +56,15 @@ public void UpdateImage()
plot = new ScottPlot.Plot(AllocatedWidth, AllocatedHeight);
foreach (double[] val in data)
{
- plot.AddBar(val);
+ if(type == PlotType.Bar)
+ plot.AddBar(val);
+ else
+ plot.AddSignal(val);
}
file = plot.SaveFig(name + ".png");
this.Title = name;
pixbuf = new Pixbuf(file);
+ image.QueueDraw();
}
#region Properties
@@ -56,7 +74,17 @@ public void UpdateImage()
[Builder.Object]
private Gtk.DrawingArea image;
[Builder.Object]
- private Gtk.Label label;
+ private Gtk.MenuItem saveImageMenu;
+ [Builder.Object]
+ private Gtk.MenuItem saveCSVMenu;
+
+ [Builder.Object]
+ private Gtk.CheckMenuItem barMenu;
+ [Builder.Object]
+ private Gtk.CheckMenuItem signalMenu;
+ [Builder.Object]
+ private Gtk.CheckMenuItem scatterMenu;
+
#pragma warning restore 649
#endregion
@@ -68,18 +96,31 @@ public void UpdateImage()
public static Plot Create(double[] vals, string name)
{
Builder builder = new Builder(null, "BioGTK.Glade.Plot.glade", null);
- return new Plot(builder, builder.GetObject("plot").Handle, vals, name);
+ return new Plot(builder, builder.GetObject("plot").Handle, vals, name, PlotType.Bar);
+ }
+ /// It creates a new instance of the Plot class.
+ ///
+ /// @return A new instance of the Plot class.
+ public static Plot Create(double[] vals, string name, PlotType typ)
+ {
+ Builder builder = new Builder(null, "BioGTK.Glade.Plot.glade", null);
+ return new Plot(builder, builder.GetObject("plot").Handle, vals, name, typ);
}
-
/* It's the constructor of the class. */
- protected Plot(Builder builder, IntPtr handle, double[] vals, string name) : base(handle)
+ protected Plot(Builder builder, IntPtr handle, double[] vals, string name, PlotType typ) : base(handle)
{
_builder = builder;
builder.Autoconnect(this);
this.Title = name;
image.Drawn += Image_Drawn;
image.SizeAllocated += Image_SizeAllocated;
+ image.ButtonPressEvent += Image_ButtonPressEvent;
+ barMenu.ButtonPressEvent += BarMenu_ButtonPressEvent;
+ signalMenu.ButtonPressEvent += SignalMenu_ButtonPressEvent;
+ scatterMenu.ButtonPressEvent += ScatterMenu_ButtonPressEvent;
+ saveImageMenu.ButtonPressEvent += SaveImageMenu_ButtonPressEvent;
+ saveCSVMenu.ButtonPressEvent += SaveCSVMenu_ButtonPressEvent;
this.DeleteEvent += About_DeleteEvent;
data.Add(vals);
this.name = name;
@@ -89,6 +130,81 @@ protected Plot(Builder builder, IntPtr handle, double[] vals, string name) : bas
else
plots.Add(name,this);
}
+
+ private void SaveCSVMenu_ButtonPressEvent(object o, ButtonPressEventArgs args)
+ {
+ Gtk.FileChooserDialog filechooser =
+ new Gtk.FileChooserDialog("Save CSV Plot data.",
+ this,
+ FileChooserAction.Save,
+ "Cancel", ResponseType.Cancel,
+ "Save", ResponseType.Accept);
+ if (filechooser.Run() != (int)ResponseType.Accept)
+ return;
+
+ string s = "";
+ foreach (double[] item in data)
+ {
+ for (int i = 0; i < data.Count; i++)
+ {
+ s += i + ",";
+ }
+ s += Environment.NewLine;
+ foreach (double d in item)
+ {
+ s += d + "," + Environment.NewLine;
+ }
+ }
+ File.WriteAllText(filechooser.Filename, s);
+ filechooser.Destroy();
+
+ }
+
+ private void SaveImageMenu_ButtonPressEvent(object o, ButtonPressEventArgs args)
+ {
+ Gtk.FileChooserDialog filechooser =
+ new Gtk.FileChooserDialog("Save PNG Image of Plot.",
+ this,
+ FileChooserAction.Save,
+ "Cancel", ResponseType.Cancel,
+ "Save", ResponseType.Accept);
+ if (filechooser.Run() != (int)ResponseType.Accept)
+ return;
+ pixbuf.Save(filechooser.Filename,"png");
+ filechooser.Destroy();
+
+ }
+
+ private void ScatterMenu_ButtonPressEvent(object o, ButtonPressEventArgs args)
+ {
+ signalMenu.Active = false;
+ barMenu.Active = false;
+ type = PlotType.Scatter;
+ UpdateImage();
+ }
+
+ private void SignalMenu_ButtonPressEvent(object o, ButtonPressEventArgs args)
+ {
+ scatterMenu.Active = false;
+ barMenu.Active = false;
+ type = PlotType.Signal;
+ UpdateImage();
+ }
+
+ private void BarMenu_ButtonPressEvent(object o, ButtonPressEventArgs args)
+ {
+ signalMenu.Active = false;
+ scatterMenu.Active = false;
+ type = PlotType.Bar;
+ UpdateImage();
+ }
+
+ private void Image_ButtonPressEvent(object o, ButtonPressEventArgs args)
+ {
+ selected = this;
+ Recorder.AddLine("Plot.SelectedPlot = Plot.Plots[" + name + "];");
+ }
+
System.Threading.Thread th;
static Plot selected;
public static Plot SelectedPlot
@@ -98,7 +214,6 @@ public static Plot SelectedPlot
static void ShowPlot()
{
selected.Show();
- selected.Present();
}
private void Image_SizeAllocated(object o, SizeAllocatedArgs args)
diff --git a/Source/TabsView.cs b/Source/TabsView.cs
index acc750b..83865b2 100644
--- a/Source/TabsView.cs
+++ b/Source/TabsView.cs
@@ -620,7 +620,7 @@ protected void addOMEImagesToTabClick(object sender, EventArgs a)
protected void saveSelectedTiffClick(object sender, EventArgs a)
{
Gtk.FileChooserDialog filechooser =
- new Gtk.FileChooserDialog("Choose the file to open",
+ new Gtk.FileChooserDialog("Save File",
this,
FileChooserAction.Save,
"Cancel", ResponseType.Cancel,