Example #1
0
        /// <summary>
        /// Might need Refresh () afterwards!
        /// </summary>
        /// <param name="table2D">
        /// A <see cref="Table2D"/>
        /// </param>
        public void Draw(Tables.Denso.Table2D table2D)
        {
            float[] valuesY = table2D.GetValuesYasFloats ();

            // clear everything. reset fonts. remove plot components etc.
            // including Florence interactions
            this.plotSurface2D.Clear ();

            // Florence interactions, N/A in original NPlot library
            // guideline disadvantage: not optimized - does not use bitmap buffer, refreshes every time a line has to move
            plotSurface2D.AddInteraction (new VerticalGuideline (Color.Gray));
            plotSurface2D.AddInteraction (new HorizontalGuideline (Color.Gray));

            //plotSurface2D.AddInteraction (new PlotSelection (Color.Green));
            plotSurface2D.AddInteraction (new PlotDrag (true, true));

            plotSurface2D.AddInteraction (new AxisDrag ());
            // PlotZoom: mouse wheel zoom
            plotSurface2D.AddInteraction (new PlotZoom ());
            plotSurface2D.AddInteraction (new KeyActions ());

            plotSurface2D.SurfacePadding = 0;
            plotSurface2D.SmoothingMode = SmoothingMode;

            // y-values, x-values (!)
            LinePlot lp = new LinePlot (valuesY, table2D.ValuesX);
            lp.Pen = pen;

            PointPlot pp = new PointPlot (marker);
            pp.AbscissaData = table2D.ValuesX;
            pp.OrdinateData = valuesY;

            Grid myGrid = new Grid ();
            myGrid.VerticalGridType = Grid.GridType.Coarse;
            myGrid.HorizontalGridType = Grid.GridType.Coarse;

            plotSurface2D.Add (myGrid);
            plotSurface2D.Add (pp);
            plotSurface2D.Add (lp);

            plotSurface2D.TitleFont = titleFont;
            plotSurface2D.Title = table2D.Title;

            plotSurface2D.XAxis1.LabelFont = labelFont;
            plotSurface2D.XAxis1.Label = AxisText (table2D.NameX, table2D.UnitX);
            // could use ex: plotSurface2D.YAxis1.NumberFormat = "0.000";
            plotSurface2D.XAxis1.TickTextFont = tickTextFont;

            plotSurface2D.YAxis1.LabelFont = labelFont;
            plotSurface2D.YAxis1.Label = AxisText (table2D.Title, table2D.UnitY);
            plotSurface2D.YAxis1.TickTextFont = tickTextFont;

            // Florence surface has Refresh () method vs. NPlot: Refresh () not part of surface interface
            plotSurface2D.Refresh ();
        }
Example #2
0
    void Show2D(Tables.Denso.Table2D table)
    {
        if (table == null)
            return;

        navbarwidget.CurrentPos = table.Location;
        navbarwidget.SetMarkedPositions (new int[] { table.RangeX.Pos, table.RangeY.Pos });

        // plot
        plot2D.Draw (table);

        // table data as text
        var values = table.GetValuesYasFloats ();
        var tableUI = new GtkWidgets.TableWidget2D (coloring, table.ValuesX, values, table.Xmin, table.Xmax, table.Ymin, table.Ymax);
        tableUI.HeaderAxisMarkup = Util.Markup.Unit (table.UnitX);
        tableUI.HeaderValuesMarkup = Util.Markup.Unit (table.UnitY);
        tableUI.AxisXMarkup = Util.Markup.NameUnit (table.NameX, table.UnitX);
        tableUI.ValuesMarkup = Util.Markup.NameUnit (table.Title, table.UnitY);
        tableUI.FormatValues = ScoobyRom.Data.AutomaticValueFormat (values, table.Ymin, table.Ymax);

        // Viewport needed for ScrolledWindow to work as generated table widget has no scroll support
        var viewPort = new Gtk.Viewport ();
        viewPort.Add (tableUI.Create ());

        Gtk.Widget previous = this.scrolledwindowTable2D.Child;
        if (previous != null)
            this.scrolledwindowTable2D.Remove (previous);
        // previous.Dispose () or previous.Destroy () cause NullReferenceException!

        this.scrolledwindowTable2D.Add (viewPort);
        this.scrolledwindowTable2D.ShowAll ();
    }