Skip to content

Commit 067744f

Browse files
committed
improve plotting
1 parent 50e1ce1 commit 067744f

File tree

3 files changed

+148
-24
lines changed

3 files changed

+148
-24
lines changed

Clustering/MainWindow.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -902,13 +902,17 @@ protected void PlotClusters()
902902
if (string.IsNullOrEmpty(input))
903903
return;
904904

905-
if (ClusteringDone && SetupInputData(input))
905+
var feature1 = Convert.ToInt32(Feature1.Value);
906+
var feature2 = Convert.ToInt32(Feature2.Value);
907+
var features = Convert.ToInt32(Features.Value);
908+
909+
if (ClusteringDone && SetupInputData(input) && feature1 >= 0 && feature1 < features && feature2 >= 0 && feature2 < features && feature1 != feature2)
906910
{
907911
var clusters = Convert.ToInt32(NumClusters.Value, ci);
908912

909913
var result = KMeans.Result();
910914

911-
var pixbuf = Cluster.Plot(InputData, result.Clusters, PlotImage.WidthRequest, PlotImage.HeightRequest);
915+
var pixbuf = Cluster.Plot(InputData, result.Clusters, PlotImage.WidthRequest, PlotImage.HeightRequest, feature1, feature2);
912916

913917
if (pixbuf != null)
914918
{

Clustering/gtk-gui/MainWindow.cs

Lines changed: 80 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ public partial class MainWindow
129129

130130
private global::Gtk.Toolbar PlotToolbar;
131131

132+
private global::Gtk.Label LabelPlotFeatures;
133+
134+
private global::Gtk.Label LabelX;
135+
136+
private global::Gtk.SpinButton Feature1;
137+
138+
private global::Gtk.Label LabelY;
139+
140+
private global::Gtk.SpinButton Feature2;
141+
132142
private global::Gtk.Label LabelPagePlot;
133143

134144
private global::Gtk.Fixed PageLayoutAbout;
@@ -666,9 +676,57 @@ protected virtual void Build()
666676
global::Gtk.Fixed.FixedChild w54 = ((global::Gtk.Fixed.FixedChild)(this.LayoutPagePlot[this.PlotToolbar]));
667677
w54.X = 60;
668678
w54.Y = 440;
679+
// Container child LayoutPagePlot.Gtk.Fixed+FixedChild
680+
this.LabelPlotFeatures = new global::Gtk.Label();
681+
this.LabelPlotFeatures.Name = "LabelPlotFeatures";
682+
this.LabelPlotFeatures.LabelProp = global::Mono.Unix.Catalog.GetString("<b>Features</b>");
683+
this.LabelPlotFeatures.UseMarkup = true;
684+
this.LayoutPagePlot.Add(this.LabelPlotFeatures);
685+
global::Gtk.Fixed.FixedChild w55 = ((global::Gtk.Fixed.FixedChild)(this.LayoutPagePlot[this.LabelPlotFeatures]));
686+
w55.X = 270;
687+
w55.Y = 450;
688+
// Container child LayoutPagePlot.Gtk.Fixed+FixedChild
689+
this.LabelX = new global::Gtk.Label();
690+
this.LabelX.Name = "LabelX";
691+
this.LabelX.LabelProp = global::Mono.Unix.Catalog.GetString("X");
692+
this.LayoutPagePlot.Add(this.LabelX);
693+
global::Gtk.Fixed.FixedChild w56 = ((global::Gtk.Fixed.FixedChild)(this.LayoutPagePlot[this.LabelX]));
694+
w56.X = 350;
695+
w56.Y = 450;
696+
// Container child LayoutPagePlot.Gtk.Fixed+FixedChild
697+
this.Feature1 = new global::Gtk.SpinButton(0D, 100D, 1D);
698+
this.Feature1.WidthRequest = 100;
699+
this.Feature1.Name = "Feature1";
700+
this.Feature1.Adjustment.PageIncrement = 10D;
701+
this.Feature1.ClimbRate = 1D;
702+
this.Feature1.Numeric = true;
703+
this.LayoutPagePlot.Add(this.Feature1);
704+
global::Gtk.Fixed.FixedChild w57 = ((global::Gtk.Fixed.FixedChild)(this.LayoutPagePlot[this.Feature1]));
705+
w57.X = 370;
706+
w57.Y = 445;
707+
// Container child LayoutPagePlot.Gtk.Fixed+FixedChild
708+
this.LabelY = new global::Gtk.Label();
709+
this.LabelY.Name = "LabelY";
710+
this.LabelY.LabelProp = global::Mono.Unix.Catalog.GetString("Y");
711+
this.LayoutPagePlot.Add(this.LabelY);
712+
global::Gtk.Fixed.FixedChild w58 = ((global::Gtk.Fixed.FixedChild)(this.LayoutPagePlot[this.LabelY]));
713+
w58.X = 480;
714+
w58.Y = 450;
715+
// Container child LayoutPagePlot.Gtk.Fixed+FixedChild
716+
this.Feature2 = new global::Gtk.SpinButton(0D, 100D, 1D);
717+
this.Feature2.WidthRequest = 100;
718+
this.Feature2.Name = "Feature2";
719+
this.Feature2.Adjustment.PageIncrement = 10D;
720+
this.Feature2.ClimbRate = 1D;
721+
this.Feature2.Numeric = true;
722+
this.Feature2.Value = 1D;
723+
this.LayoutPagePlot.Add(this.Feature2);
724+
global::Gtk.Fixed.FixedChild w59 = ((global::Gtk.Fixed.FixedChild)(this.LayoutPagePlot[this.Feature2]));
725+
w59.X = 500;
726+
w59.Y = 445;
669727
this.MainNotebook.Add(this.LayoutPagePlot);
670-
global::Gtk.Notebook.NotebookChild w55 = ((global::Gtk.Notebook.NotebookChild)(this.MainNotebook[this.LayoutPagePlot]));
671-
w55.Position = 3;
728+
global::Gtk.Notebook.NotebookChild w60 = ((global::Gtk.Notebook.NotebookChild)(this.MainNotebook[this.LayoutPagePlot]));
729+
w60.Position = 3;
672730
// Notebook tab
673731
this.LabelPagePlot = new global::Gtk.Label();
674732
this.LabelPagePlot.Name = "LabelPagePlot";
@@ -685,9 +743,9 @@ protected virtual void Build()
685743
this.LabelAboutSoftware.LabelProp = global::Mono.Unix.Catalog.GetString("<b>GTK Clustering Software</b>");
686744
this.LabelAboutSoftware.UseMarkup = true;
687745
this.PageLayoutAbout.Add(this.LabelAboutSoftware);
688-
global::Gtk.Fixed.FixedChild w56 = ((global::Gtk.Fixed.FixedChild)(this.PageLayoutAbout[this.LabelAboutSoftware]));
689-
w56.X = 20;
690-
w56.Y = 20;
746+
global::Gtk.Fixed.FixedChild w61 = ((global::Gtk.Fixed.FixedChild)(this.PageLayoutAbout[this.LabelAboutSoftware]));
747+
w61.X = 20;
748+
w61.Y = 20;
691749
// Container child PageLayoutAbout.Gtk.Fixed+FixedChild
692750
this.AboutWindow = new global::Gtk.ScrolledWindow();
693751
this.AboutWindow.WidthRequest = 310;
@@ -716,18 +774,18 @@ P. Fränti and S. Sieranoja
716774
this.AboutView.WrapMode = ((global::Gtk.WrapMode)(2));
717775
this.AboutWindow.Add(this.AboutView);
718776
this.PageLayoutAbout.Add(this.AboutWindow);
719-
global::Gtk.Fixed.FixedChild w58 = ((global::Gtk.Fixed.FixedChild)(this.PageLayoutAbout[this.AboutWindow]));
720-
w58.X = 20;
721-
w58.Y = 40;
777+
global::Gtk.Fixed.FixedChild w63 = ((global::Gtk.Fixed.FixedChild)(this.PageLayoutAbout[this.AboutWindow]));
778+
w63.X = 20;
779+
w63.Y = 40;
722780
// Container child PageLayoutAbout.Gtk.Fixed+FixedChild
723781
this.LabelCredits = new global::Gtk.Label();
724782
this.LabelCredits.Name = "LabelCredits";
725783
this.LabelCredits.LabelProp = global::Mono.Unix.Catalog.GetString("<b>Credits</b>");
726784
this.LabelCredits.UseMarkup = true;
727785
this.PageLayoutAbout.Add(this.LabelCredits);
728-
global::Gtk.Fixed.FixedChild w59 = ((global::Gtk.Fixed.FixedChild)(this.PageLayoutAbout[this.LabelCredits]));
729-
w59.X = 20;
730-
w59.Y = 260;
786+
global::Gtk.Fixed.FixedChild w64 = ((global::Gtk.Fixed.FixedChild)(this.PageLayoutAbout[this.LabelCredits]));
787+
w64.X = 20;
788+
w64.Y = 260;
731789
// Container child PageLayoutAbout.Gtk.Fixed+FixedChild
732790
this.CreditsWindow = new global::Gtk.ScrolledWindow();
733791
this.CreditsWindow.WidthRequest = 310;
@@ -746,30 +804,30 @@ P. Fränti and S. Sieranoja
746804
this.CreditsView.WrapMode = ((global::Gtk.WrapMode)(2));
747805
this.CreditsWindow.Add(this.CreditsView);
748806
this.PageLayoutAbout.Add(this.CreditsWindow);
749-
global::Gtk.Fixed.FixedChild w61 = ((global::Gtk.Fixed.FixedChild)(this.PageLayoutAbout[this.CreditsWindow]));
750-
w61.X = 20;
751-
w61.Y = 280;
807+
global::Gtk.Fixed.FixedChild w66 = ((global::Gtk.Fixed.FixedChild)(this.PageLayoutAbout[this.CreditsWindow]));
808+
w66.X = 20;
809+
w66.Y = 280;
752810
// Container child PageLayoutAbout.Gtk.Fixed+FixedChild
753811
this.ClusteringImage = new global::Gtk.Image();
754812
this.ClusteringImage.Name = "ClusteringImage";
755813
this.ClusteringImage.Pixbuf = global::Gdk.Pixbuf.LoadFromResource("Clustering.atoms256.png");
756814
this.PageLayoutAbout.Add(this.ClusteringImage);
757-
global::Gtk.Fixed.FixedChild w62 = ((global::Gtk.Fixed.FixedChild)(this.PageLayoutAbout[this.ClusteringImage]));
758-
w62.X = 420;
759-
w62.Y = 80;
815+
global::Gtk.Fixed.FixedChild w67 = ((global::Gtk.Fixed.FixedChild)(this.PageLayoutAbout[this.ClusteringImage]));
816+
w67.X = 420;
817+
w67.Y = 80;
760818
this.MainNotebook.Add(this.PageLayoutAbout);
761-
global::Gtk.Notebook.NotebookChild w63 = ((global::Gtk.Notebook.NotebookChild)(this.MainNotebook[this.PageLayoutAbout]));
762-
w63.Position = 4;
819+
global::Gtk.Notebook.NotebookChild w68 = ((global::Gtk.Notebook.NotebookChild)(this.MainNotebook[this.PageLayoutAbout]));
820+
w68.Position = 4;
763821
// Notebook tab
764822
this.LabelPageAbout = new global::Gtk.Label();
765823
this.LabelPageAbout.Name = "LabelPageAbout";
766824
this.LabelPageAbout.LabelProp = global::Mono.Unix.Catalog.GetString("About");
767825
this.MainNotebook.SetTabLabel(this.PageLayoutAbout, this.LabelPageAbout);
768826
this.LabelPageAbout.ShowAll();
769827
this.MainLayout.Add(this.MainNotebook);
770-
global::Gtk.Fixed.FixedChild w64 = ((global::Gtk.Fixed.FixedChild)(this.MainLayout[this.MainNotebook]));
771-
w64.X = 20;
772-
w64.Y = 60;
828+
global::Gtk.Fixed.FixedChild w69 = ((global::Gtk.Fixed.FixedChild)(this.MainLayout[this.MainNotebook]));
829+
w69.X = 20;
830+
w69.Y = 60;
773831
this.Add(this.MainLayout);
774832
if ((this.Child != null))
775833
{

Clustering/gtk-gui/gui.stetic

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,68 @@
701701
<property name="Y">440</property>
702702
</packing>
703703
</child>
704+
<child>
705+
<widget class="Gtk.Label" id="LabelPlotFeatures">
706+
<property name="MemberName" />
707+
<property name="LabelProp" translatable="yes">&lt;b&gt;Features&lt;/b&gt;</property>
708+
<property name="UseMarkup">True</property>
709+
</widget>
710+
<packing>
711+
<property name="X">270</property>
712+
<property name="Y">450</property>
713+
</packing>
714+
</child>
715+
<child>
716+
<widget class="Gtk.Label" id="LabelX">
717+
<property name="MemberName" />
718+
<property name="LabelProp" translatable="yes">X</property>
719+
</widget>
720+
<packing>
721+
<property name="X">350</property>
722+
<property name="Y">450</property>
723+
</packing>
724+
</child>
725+
<child>
726+
<widget class="Gtk.SpinButton" id="Feature1">
727+
<property name="MemberName" />
728+
<property name="WidthRequest">100</property>
729+
<property name="Upper">100</property>
730+
<property name="PageIncrement">10</property>
731+
<property name="StepIncrement">1</property>
732+
<property name="ClimbRate">1</property>
733+
<property name="Numeric">True</property>
734+
</widget>
735+
<packing>
736+
<property name="X">370</property>
737+
<property name="Y">445</property>
738+
</packing>
739+
</child>
740+
<child>
741+
<widget class="Gtk.Label" id="LabelY">
742+
<property name="MemberName" />
743+
<property name="LabelProp" translatable="yes">Y</property>
744+
</widget>
745+
<packing>
746+
<property name="X">480</property>
747+
<property name="Y">450</property>
748+
</packing>
749+
</child>
750+
<child>
751+
<widget class="Gtk.SpinButton" id="Feature2">
752+
<property name="MemberName" />
753+
<property name="WidthRequest">100</property>
754+
<property name="Upper">100</property>
755+
<property name="PageIncrement">10</property>
756+
<property name="StepIncrement">1</property>
757+
<property name="ClimbRate">1</property>
758+
<property name="Numeric">True</property>
759+
<property name="Value">1</property>
760+
</widget>
761+
<packing>
762+
<property name="X">500</property>
763+
<property name="Y">445</property>
764+
</packing>
765+
</child>
704766
</widget>
705767
<packing>
706768
<property name="Position">3</property>

0 commit comments

Comments
 (0)