[chronojump] CairoBars can be passed number of decimals. Implemented on encoder.
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] CairoBars can be passed number of decimals. Implemented on encoder.
- Date: Thu, 17 Mar 2022 09:14:53 +0000 (UTC)
commit 18063ec1b9a5d577c8c26c0adbfc42fc8818653a
Author: Xavier de Blas <xaviblas gmail com>
Date: Thu Mar 17 10:14:21 2022 +0100
CairoBars can be passed number of decimals. Implemented on encoder.
src/gui/cairo/bars.cs | 26 ++++++++++++++++----------
src/gui/eventExecute.cs | 30 +++++++++++++++---------------
2 files changed, 31 insertions(+), 25 deletions(-)
---
diff --git a/src/gui/cairo/bars.cs b/src/gui/cairo/bars.cs
index 5b24db37b..c395dbf4b 100644
--- a/src/gui/cairo/bars.cs
+++ b/src/gui/cairo/bars.cs
@@ -41,14 +41,6 @@ public abstract class CairoBars : CairoGeneric
protected Cairo.Context g;
protected int lineWidthDefault = 1; //was 2;
- protected string xVariable = "";
- protected string yVariable = "Height";
- protected string xUnits = "";
- protected string yUnits = "cm";
-
- //used when there are two series (for legend)
- protected string variableSerieA = "";
- protected string variableSerieB = "";
protected double minX = 1000000;
protected double maxX = 0;
@@ -63,6 +55,17 @@ public abstract class CairoBars : CairoGeneric
protected Cairo.Color bluePlots;
protected Cairo.Color yellow;
+ // ---- values can be passed from outside via accessors ---->
+ protected string xVariable = "";
+ protected string yVariable = "Height";
+ protected string xUnits = "";
+ protected string yUnits = "cm";
+
+ //used when there are two series (for legend)
+ protected string variableSerieA = "";
+ protected string variableSerieB = "";
+ protected int decs;
+ // <---- end of passed variables
public virtual void GraphInit (string font, bool usePersonGuides, bool useGroupGuides) //needed to
set rightMargin
{
@@ -70,6 +73,7 @@ public abstract class CairoBars : CairoGeneric
this.useGroupGuides = useGroupGuides;
textHeight = 14;
+ decs = 2;
initGraph(font, 1); //.8 if writeTextAtRight
}
@@ -494,7 +498,6 @@ public abstract class CairoBars : CairoGeneric
//TODO: at the moment we are not lowering decs, make resultsFontHeight and decs global variables
protected int getBarsResultFontHeight (double maxWidth)
{
- int decs = 2; //can be 1 if need more space
double maxLengthNumber = 9.99;
if(maxY >= 10)
maxLengthNumber = 99.99;
@@ -525,7 +528,6 @@ public abstract class CairoBars : CairoGeneric
protected double plotResultOnBar(double x, double y, double alto, double result,
int resultFontHeight, double barWidth, double yStartPointA)
{
- int decs = 2; //can be 1 if need more space
g.SetFontSize(resultFontHeight);
double maxLengthNumber = 9.99;
@@ -657,6 +659,10 @@ public abstract class CairoBars : CairoGeneric
public string VariableSerieB {
set { variableSerieB = value; }
}
+
+ public int Decs {
+ set { decs = value; }
+ }
}
public class CairoBars1Series : CairoBars
diff --git a/src/gui/eventExecute.cs b/src/gui/eventExecute.cs
index b16a065a8..f4d945012 100644
--- a/src/gui/eventExecute.cs
+++ b/src/gui/eventExecute.cs
@@ -3412,21 +3412,6 @@ public class CairoPaintBarplotPreEncoder : CairoPaintBarsPre
bool lastIsEcc = false;
//int count = 0;
- string units = "";
- int decimals;
-
- if(pegbe.mainVariable == Constants.MeanSpeed || pegbe.mainVariable == Constants.MaxSpeed) {
- units = "m/s";
- decimals = 2;
- } else if(pegbe.mainVariable == Constants.MeanForce || pegbe.mainVariable ==
Constants.MaxForce) {
- units = "N";
- decimals = 1;
- }
- else { //powers
- units = "W";
- decimals = 1;
- }
-
names_l = new List<string>();
//discard repetitions according to showNRepetitions
@@ -3469,6 +3454,21 @@ public class CairoPaintBarplotPreEncoder : CairoPaintBarsPre
//cb.GraphInit(fontStr, true, false); //usePersonGuides, useGroupGuides
cb.GraphInit(fontStr, false, false); //usePersonGuides, useGroupGuides
+ string units = "";
+ int decs;
+ if(pegbe.mainVariable == Constants.MeanSpeed || pegbe.mainVariable == Constants.MaxSpeed) {
+ units = "m/s";
+ decs = 2;
+ } else if(pegbe.mainVariable == Constants.MeanForce || pegbe.mainVariable ==
Constants.MaxForce) {
+ units = "N";
+ decs = 0;
+ }
+ else { //powers
+ units = "W";
+ decs = 0;
+ }
+ cb.Decs = decs;
+
if(pegbe.eccon == "c")
cb.GraphDo (dataA_l, new List<PointF>(), names_l,
14, 8, "my title");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]