Additional XYPlot cleanup
This commit is contained in:
+180
-224
@@ -20,7 +20,6 @@ namespace XYPlots
|
|||||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
#endregion
|
#endregion
|
||||||
public static string MyFontFamily { get; set; } = "Letter Gothic Tall";
|
public static string MyFontFamily { get; set; } = "Letter Gothic Tall";
|
||||||
private static Color _BlackColor = Color.Red;
|
|
||||||
public static Color BlackColor
|
public static Color BlackColor
|
||||||
{
|
{
|
||||||
get { return VG.VG.BlackColor; }
|
get { return VG.VG.BlackColor; }
|
||||||
@@ -30,25 +29,24 @@ namespace XYPlots
|
|||||||
public float Height => 72 * (TopMargin + BottomMargin) + printerunits[1] * .05F;
|
public float Height => 72 * (TopMargin + BottomMargin) + printerunits[1] * .05F;
|
||||||
public float PlotWidth => (float)userunits[X];
|
public float PlotWidth => (float)userunits[X];
|
||||||
public float PlotHeight => (float)userunits[Y];
|
public float PlotHeight => (float)userunits[Y];
|
||||||
private double ConvertToTwips = 4.8;
|
private readonly double ConvertToTwips = 4.8;
|
||||||
static int MAX_XY_STACK = 8; /* this is max of CIE cursor/font stack */
|
static readonly int MAX_XY_STACK = 8; /* this is max of CIE cursor/font stack */
|
||||||
static int DPI = 1440; //300;
|
static readonly int DPI = 1440; //300;
|
||||||
static int CWIDEDOTS = 120; //25;
|
static readonly int CWIDEDOTS = 120; //25;
|
||||||
static int CHIGHDOTS = 240; //50;
|
static readonly int CHIGHDOTS = 240; //50;
|
||||||
static int STRAIGHT = 0;
|
static readonly int STRAIGHT = 0;
|
||||||
static int CURVE = 1;
|
static readonly int CURVE = 1;
|
||||||
static int X = 0;
|
static readonly int X = 0;
|
||||||
static int Y = 1;
|
static readonly int Y = 1;
|
||||||
static int Dimensions = 2;
|
static readonly int Dimensions = 2;
|
||||||
static int USER = 0;
|
static readonly int USER = 0;
|
||||||
static int PLOT = 1;
|
static readonly int PLOT = 1;
|
||||||
static double PI = 3.141592653;
|
static readonly double PI = 3.141592653;
|
||||||
static double Zero = 0.0;
|
static readonly double Zero = 0.0;
|
||||||
static double ANGLELIMIT = 1.0;
|
static readonly double ANGLELIMIT = 1.0;
|
||||||
// !!!! NEED REAL SUPERSCRIPT ON/OFF TOKENS
|
// !!!! NEED REAL SUPERSCRIPT ON/OFF TOKENS
|
||||||
static string[] SuperScript = { "##", "##" };
|
static readonly string[] SuperScript = { "##", "##" };
|
||||||
static string[] SubScript = { "~~", "~~" };
|
static readonly string[] SubScript = { "~~", "~~" };
|
||||||
FileStream XYPlotFile;
|
|
||||||
private int[] SavedX;
|
private int[] SavedX;
|
||||||
private int[] SavedY;
|
private int[] SavedY;
|
||||||
private int stack;
|
private int stack;
|
||||||
@@ -106,27 +104,27 @@ namespace XYPlots
|
|||||||
private string valuestring;
|
private string valuestring;
|
||||||
private string powerstring;
|
private string powerstring;
|
||||||
private int GridOnFlag, Visible, ShadowFlag;
|
private int GridOnFlag, Visible, ShadowFlag;
|
||||||
private char[] type = new char[Dimensions];
|
private readonly char[] type = new char[Dimensions];
|
||||||
private double FontPitch = 10.0;
|
private readonly double FontPitch = 10.0;
|
||||||
private double[] minimum = new double[Dimensions];
|
private readonly double[] minimum = new double[Dimensions];
|
||||||
private double[] maximum = new double[Dimensions];
|
private readonly double[] maximum = new double[Dimensions];
|
||||||
private double[] userunits = new double[Dimensions];
|
private readonly double[] userunits = new double[Dimensions];
|
||||||
private int[] printerunits = new int[Dimensions];
|
private readonly int[] printerunits = new int[Dimensions];
|
||||||
private int[] Position = new int[Dimensions];
|
private readonly int[] Position = new int[Dimensions];
|
||||||
private double[,] Scale = new double[2, Dimensions];
|
private readonly double[,] Scale = new double[2, Dimensions];
|
||||||
private double[,] Offset = new double[2, Dimensions];
|
private readonly double[,] Offset = new double[2, Dimensions];
|
||||||
private double[] delta = new double[Dimensions];
|
private readonly double[] delta = new double[Dimensions];
|
||||||
private int[] cycles = new int[Dimensions];
|
private readonly int[] cycles = new int[Dimensions];
|
||||||
private int[] onecycle = new int[Dimensions];
|
private readonly int[] onecycle = new int[Dimensions];
|
||||||
private int[] minor = new int[Dimensions];
|
private readonly int[] minor = new int[Dimensions];
|
||||||
private int[] spcminor = new int[Dimensions];
|
private readonly int[] spcminor = new int[Dimensions];
|
||||||
private string[] AxisTitles = new string[Dimensions];
|
private readonly string[] AxisTitles = new string[Dimensions];
|
||||||
private int[] AxisLabel = new int[Dimensions];// 1 for YES(default), 0 for NO
|
private readonly int[] AxisLabel = new int[Dimensions];// 1 for YES(default), 0 for NO
|
||||||
private int CurPenWidth, DrawDirection, LineFlag, LineDiv;
|
private int CurPenWidth, DrawDirection, LineFlag, LineDiv;
|
||||||
private int EndFlag = 0;
|
private int EndFlag = 0;
|
||||||
public string Buff;
|
public string Buff;
|
||||||
private int BuffPtr = 0;
|
private int BuffPtr = 0;
|
||||||
private bool[,] doLOG10 = { { false, false }, { false, false } };
|
private readonly bool[,] doLOG10 = { { false, false }, { false, false } };
|
||||||
public struct point
|
public struct point
|
||||||
{
|
{
|
||||||
public int[] xyValue;
|
public int[] xyValue;
|
||||||
@@ -141,8 +139,8 @@ namespace XYPlots
|
|||||||
public class XyBoxes : List<XyBox>
|
public class XyBoxes : List<XyBox>
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
private XyBoxes AllBoxes = new XyBoxes();
|
private readonly XyBoxes AllBoxes = new XyBoxes();
|
||||||
private XyBoxes ActiveBoxes = new XyBoxes();
|
private readonly XyBoxes ActiveBoxes = new XyBoxes();
|
||||||
public class DataPoint
|
public class DataPoint
|
||||||
{
|
{
|
||||||
// Make it easier to Debug
|
// Make it easier to Debug
|
||||||
@@ -165,7 +163,8 @@ namespace XYPlots
|
|||||||
public int PlotDivisions;
|
public int PlotDivisions;
|
||||||
public DataPoints PlotDataPoints;
|
public DataPoints PlotDataPoints;
|
||||||
};
|
};
|
||||||
private List<PlotLine> AllPlots = new List<PlotLine>();
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
|
||||||
|
private List<PlotLine> AllPlots = new List<PlotLine>();
|
||||||
private int YLandScape = 0; /* y axis title is horizontal */
|
private int YLandScape = 0; /* y axis title is horizontal */
|
||||||
private point YTitleOrigin; /* y axis title origin if vertical */
|
private point YTitleOrigin; /* y axis title origin if vertical */
|
||||||
private double FixAngle(double a1)
|
private double FixAngle(double a1)
|
||||||
@@ -234,72 +233,6 @@ namespace XYPlots
|
|||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
private bool LoadBuff(string FileName)
|
|
||||||
{
|
|
||||||
if (!File.Exists(FileName))
|
|
||||||
{
|
|
||||||
if (!BaseLnSettings.blBaseLine) // B2026-056 suppress messages when running baseline.
|
|
||||||
{
|
|
||||||
// File does not exist, show error message
|
|
||||||
MessageBox.Show(String.Format("X/Y Plot File {0} Does Not Exist", FileName), "Error Opening X/Y Plot File");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Open the X/Y Plot file
|
|
||||||
try
|
|
||||||
{
|
|
||||||
XYPlotFile = File.OpenRead(FileName);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
if (!BaseLnSettings.blBaseLine) // B2026-056 suppress messages when running baseline.
|
|
||||||
{
|
|
||||||
// cannot open the x/y plot file
|
|
||||||
MessageBox.Show(e.Message, String.Format("Error Opening {0} for Reading", FileName));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int blen = (int)XYPlotFile.Length;
|
|
||||||
int bread = 0;
|
|
||||||
// initialize a byte array to read into
|
|
||||||
byte[] bbuf = new byte[blen + 1];
|
|
||||||
for (int i = 0; i < blen; i++) bbuf[i] = 0;
|
|
||||||
// Read the contents of the x/y plot file into the byte array
|
|
||||||
try
|
|
||||||
{
|
|
||||||
bread = XYPlotFile.Read(bbuf, 0, blen);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
if (!BaseLnSettings.blBaseLine) // B2026-056 suppress messages when running baseline.
|
|
||||||
{
|
|
||||||
MessageBox.Show(e.Message, String.Format("Error Reading {0}", FileName));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
XYPlotFile.Close();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
if (!BaseLnSettings.blBaseLine) // B2026-056 suppress messages when running baseline.
|
|
||||||
{
|
|
||||||
MessageBox.Show(e.Message, String.Format("Error Closing {0}", FileName));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
for (int i = 0; i < bbuf.Length; i++)
|
|
||||||
{
|
|
||||||
if (bbuf[i] == '\r' && bbuf[i - 1] == ' ')
|
|
||||||
sb.Remove(i - 1, 1);
|
|
||||||
sb.Append(Convert.ToChar(bbuf[i]));
|
|
||||||
}
|
|
||||||
Buff = sb.ToString();
|
|
||||||
BuffPtr = 0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
private void LoadBuffFromString(string str) => Buff = str;
|
private void LoadBuffFromString(string str) => Buff = str;
|
||||||
private int getint()
|
private int getint()
|
||||||
{
|
{
|
||||||
@@ -356,9 +289,11 @@ namespace XYPlots
|
|||||||
public string XYPlotIssue { get; set; }
|
public string XYPlotIssue { get; set; }
|
||||||
private point GetPair(int flag)
|
private point GetPair(int flag)
|
||||||
{
|
{
|
||||||
point retval = new point();
|
point retval = new point
|
||||||
retval.xyValue = new int[Dimensions];
|
{
|
||||||
double x, y;
|
xyValue = new int[Dimensions]
|
||||||
|
};
|
||||||
|
double x, y;
|
||||||
char[] sepchar = { ',' };
|
char[] sepchar = { ',' };
|
||||||
string nextPiece = NextPiece(); // Plot Definition
|
string nextPiece = NextPiece(); // Plot Definition
|
||||||
string[] xystr = nextPiece.Split(sepchar);
|
string[] xystr = nextPiece.Split(sepchar);
|
||||||
@@ -413,7 +348,7 @@ namespace XYPlots
|
|||||||
if (retval == ' ')
|
if (retval == ' ')
|
||||||
{
|
{
|
||||||
Lbuff.Append('\n');
|
Lbuff.Append('\n');
|
||||||
retval = NextChar();
|
_ = NextChar();
|
||||||
retval = NextChar();
|
retval = NextChar();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -484,7 +419,7 @@ namespace XYPlots
|
|||||||
if (LinesUsed == 0)
|
if (LinesUsed == 0)
|
||||||
LinesUsed = (int)(1.5 * CHIGHDOTS); /* adjust for x axis tics */
|
LinesUsed = (int)(1.5 * CHIGHDOTS); /* adjust for x axis tics */
|
||||||
LinesUsed += printerunits[Y];
|
LinesUsed += printerunits[Y];
|
||||||
LinesUsed = LinesUsed / CHIGHDOTS;
|
LinesUsed /= CHIGHDOTS;
|
||||||
}
|
}
|
||||||
private void GetScaleInfo()
|
private void GetScaleInfo()
|
||||||
{
|
{
|
||||||
@@ -560,24 +495,27 @@ namespace XYPlots
|
|||||||
}
|
}
|
||||||
private point DetermineBoxMax(XyBox boxptr)
|
private point DetermineBoxMax(XyBox boxptr)
|
||||||
{
|
{
|
||||||
point newval = new point();
|
point newval = new point
|
||||||
newval.xyValue = new int[Dimensions];
|
{
|
||||||
string tmp;
|
xyValue = new int[Dimensions]
|
||||||
|
};
|
||||||
|
string tmp;
|
||||||
int pos = 0, prevPos = 0;
|
int pos = 0, prevPos = 0;
|
||||||
int nl = 0, xmax = 0, ilen = 0;
|
int nl = 0, xmax = 0;
|
||||||
tmp = stripSuperSub(boxptr.BoxText);
|
tmp = stripSuperSub(boxptr.BoxText);
|
||||||
tmp = tmp.Replace("\r\n", "\n");
|
tmp = tmp.Replace("\r\n", "\n");
|
||||||
while ((pos = tmp.IndexOf('\n', pos)) > -1)
|
int ilen;
|
||||||
{
|
while ((pos = tmp.IndexOf('\n', pos)) > -1)
|
||||||
ilen = pos - prevPos;
|
{
|
||||||
xmax = Math.Max(xmax, ilen);
|
ilen = pos - prevPos;
|
||||||
// OLD: prevPos = pos;
|
xmax = Math.Max(xmax, ilen);
|
||||||
prevPos = pos + 1;
|
// OLD: prevPos = pos;
|
||||||
pos++;
|
prevPos = pos + 1;
|
||||||
nl++;
|
pos++;
|
||||||
}
|
nl++;
|
||||||
// OLD: ilen = tmp.Substring(prevPos + 1).Length;
|
}
|
||||||
ilen = tmp.Length - prevPos; // tmp.Substring(prevPos).Length;
|
// OLD: ilen = tmp.Substring(prevPos + 1).Length;
|
||||||
|
ilen = tmp.Length - prevPos; // tmp.Substring(prevPos).Length;
|
||||||
xmax = Math.Max(xmax, ilen) + 2;
|
xmax = Math.Max(xmax, ilen) + 2;
|
||||||
newval.xyValue[X] = boxptr.BoxMinimum.xyValue[X] + (xmax * CWIDEDOTS);
|
newval.xyValue[X] = boxptr.BoxMinimum.xyValue[X] + (xmax * CWIDEDOTS);
|
||||||
// OLD: newval.xyValue[Y] = boxptr.BoxMinimum.xyValue[Y] - (nl * CHIGHDOTS) - (int)(30 * ConvertToTwips);
|
// OLD: newval.xyValue[Y] = boxptr.BoxMinimum.xyValue[Y] - (nl * CHIGHDOTS) - (int)(30 * ConvertToTwips);
|
||||||
@@ -596,11 +534,15 @@ namespace XYPlots
|
|||||||
NewBox.Shadow = ShadowFlag;
|
NewBox.Shadow = ShadowFlag;
|
||||||
ShadowFlag = 0;
|
ShadowFlag = 0;
|
||||||
NewBox.BoxMaximum = DetermineBoxMax(NewBox);
|
NewBox.BoxMaximum = DetermineBoxMax(NewBox);
|
||||||
point minPoint = new point();
|
point minPoint = new point
|
||||||
minPoint.xyValue = new int[Dimensions];
|
{
|
||||||
point maxPoint = new point();
|
xyValue = new int[Dimensions]
|
||||||
maxPoint.xyValue = new int[Dimensions];
|
};
|
||||||
minPoint.xyValue[X] = Origin.xyValue[X];
|
point maxPoint = new point
|
||||||
|
{
|
||||||
|
xyValue = new int[Dimensions]
|
||||||
|
};
|
||||||
|
minPoint.xyValue[X] = Origin.xyValue[X];
|
||||||
minPoint.xyValue[Y] = NewBox.BoxMaximum.xyValue[Y];
|
minPoint.xyValue[Y] = NewBox.BoxMaximum.xyValue[Y];
|
||||||
maxPoint.xyValue[X] = NewBox.BoxMaximum.xyValue[X];
|
maxPoint.xyValue[X] = NewBox.BoxMaximum.xyValue[X];
|
||||||
maxPoint.xyValue[Y] = Origin.xyValue[Y];
|
maxPoint.xyValue[Y] = Origin.xyValue[Y];
|
||||||
@@ -618,9 +560,11 @@ namespace XYPlots
|
|||||||
pointcount = EndFlag = 0;
|
pointcount = EndFlag = 0;
|
||||||
while (EndFlag == 0)
|
while (EndFlag == 0)
|
||||||
{
|
{
|
||||||
DataPoint pl = new DataPoint();
|
DataPoint pl = new DataPoint
|
||||||
pl.APoint = new point();
|
{
|
||||||
pl.APoint = GetPair(PLOT);
|
APoint = new point()
|
||||||
|
};
|
||||||
|
pl.APoint = GetPair(PLOT);
|
||||||
pointcount++;
|
pointcount++;
|
||||||
dataPoints.Add(pl);
|
dataPoints.Add(pl);
|
||||||
}
|
}
|
||||||
@@ -662,7 +606,6 @@ namespace XYPlots
|
|||||||
DataPoint thispt, prevpt, firstpt;
|
DataPoint thispt, prevpt, firstpt;
|
||||||
long yval, y1, y3;
|
long yval, y1, y3;
|
||||||
int PlAryIdx = 0;
|
int PlAryIdx = 0;
|
||||||
int PlAryNumItems = dataPoints.Count;
|
|
||||||
prevpt = dataPoints[PlAryIdx];
|
prevpt = dataPoints[PlAryIdx];
|
||||||
PlAryIdx++;
|
PlAryIdx++;
|
||||||
thispt = dataPoints[PlAryIdx];
|
thispt = dataPoints[PlAryIdx];
|
||||||
@@ -684,11 +627,13 @@ namespace XYPlots
|
|||||||
}
|
}
|
||||||
private void AddAPlot(DataPoints ptr)
|
private void AddAPlot(DataPoints ptr)
|
||||||
{
|
{
|
||||||
PlotLine NewLine = new PlotLine();
|
PlotLine NewLine = new PlotLine
|
||||||
NewLine.PlotType = LineFlag;
|
{
|
||||||
NewLine.PlotDivisions = LineDiv;
|
PlotType = LineFlag,
|
||||||
NewLine.PlotDataPoints = ptr;
|
PlotDivisions = LineDiv,
|
||||||
AllPlots.Insert(0, NewLine);
|
PlotDataPoints = ptr
|
||||||
|
};
|
||||||
|
AllPlots.Insert(0, NewLine);
|
||||||
}
|
}
|
||||||
private void GenerateGrid(VG.Page pg, IVGOutput vgOutput)
|
private void GenerateGrid(VG.Page pg, IVGOutput vgOutput)
|
||||||
{
|
{
|
||||||
@@ -899,7 +844,7 @@ namespace XYPlots
|
|||||||
{
|
{
|
||||||
int tlen;
|
int tlen;
|
||||||
powerstring = string.Format("x10{0}{1}{2}", SuperScript[0], i.ToString(), SuperScript[1]);
|
powerstring = string.Format("x10{0}{1}{2}", SuperScript[0], i.ToString(), SuperScript[1]);
|
||||||
valuestring = valuestring + powerstring;
|
valuestring += powerstring;
|
||||||
tlen = SuperScript[0].Length + SuperScript[1].Length;
|
tlen = SuperScript[0].Length + SuperScript[1].Length;
|
||||||
return (powerstring.Length - tlen);
|
return (powerstring.Length - tlen);
|
||||||
}
|
}
|
||||||
@@ -917,7 +862,9 @@ namespace XYPlots
|
|||||||
LinesUsed += (3 * CHIGHDOTS);
|
LinesUsed += (3 * CHIGHDOTS);
|
||||||
AxisTitles[X] = null;
|
AxisTitles[X] = null;
|
||||||
}
|
}
|
||||||
if ((AxisTitles[Y] != null) && (len = AxisTitles[Y].Length) > 0)
|
#pragma warning disable IDE0059 // Unnecessary assignment of a value
|
||||||
|
//Keeping len = AxisTitles[Y].Length for Debugging
|
||||||
|
if ((AxisTitles[Y] != null) && (len = AxisTitles[Y].Length) > 0)
|
||||||
{
|
{
|
||||||
if (YLandScape > 0)
|
if (YLandScape > 0)
|
||||||
{
|
{
|
||||||
@@ -938,7 +885,8 @@ namespace XYPlots
|
|||||||
}
|
}
|
||||||
AxisTitles[Y] = null;
|
AxisTitles[Y] = null;
|
||||||
}
|
}
|
||||||
RecallPosition();
|
#pragma warning restore IDE0059 // Unnecessary assignment of a value
|
||||||
|
RecallPosition();
|
||||||
}
|
}
|
||||||
private void DoBoxes(VG.Page pg, IVGOutput vgOutput)
|
private void DoBoxes(VG.Page pg, IVGOutput vgOutput)
|
||||||
{
|
{
|
||||||
@@ -1040,9 +988,11 @@ namespace XYPlots
|
|||||||
}
|
}
|
||||||
private point FindModifiedCenter(double rprime, point PtOnArc, double ang)
|
private point FindModifiedCenter(double rprime, point PtOnArc, double ang)
|
||||||
{
|
{
|
||||||
point newcenter = new point();
|
point newcenter = new point
|
||||||
newcenter.xyValue = new int[Dimensions];
|
{
|
||||||
newcenter.xyValue[X] = (int)(PtOnArc.xyValue[X] - rprime * cos_deg(ang));
|
xyValue = new int[Dimensions]
|
||||||
|
};
|
||||||
|
newcenter.xyValue[X] = (int)(PtOnArc.xyValue[X] - rprime * cos_deg(ang));
|
||||||
newcenter.xyValue[Y] = (int)(PtOnArc.xyValue[Y] - rprime * sin_deg(ang));
|
newcenter.xyValue[Y] = (int)(PtOnArc.xyValue[Y] - rprime * sin_deg(ang));
|
||||||
return (newcenter);
|
return (newcenter);
|
||||||
}
|
}
|
||||||
@@ -1060,9 +1010,11 @@ namespace XYPlots
|
|||||||
x2 = pt2.APoint.xyValue[X];
|
x2 = pt2.APoint.xyValue[X];
|
||||||
y2 = pt2.APoint.xyValue[Y];
|
y2 = pt2.APoint.xyValue[Y];
|
||||||
midpt = new DataPoint();
|
midpt = new DataPoint();
|
||||||
pt = new point();
|
pt = new point
|
||||||
pt.xyValue = new int[Dimensions];
|
{
|
||||||
so = FindSlope(pt1.APoint, pt2.APoint);
|
xyValue = new int[Dimensions]
|
||||||
|
};
|
||||||
|
so = FindSlope(pt1.APoint, pt2.APoint);
|
||||||
midpt.slope = (4.0 * so - pt1.slope - pt2.slope) / 2.0;
|
midpt.slope = (4.0 * so - pt1.slope - pt2.slope) / 2.0;
|
||||||
pt.xyValue[X] = x1 + (x2 - x1) / 2;
|
pt.xyValue[X] = x1 + (x2 - x1) / 2;
|
||||||
pt.xyValue[Y] = y1 + (y2 - y1) / 2;
|
pt.xyValue[Y] = y1 + (y2 - y1) / 2;
|
||||||
@@ -1173,9 +1125,11 @@ namespace XYPlots
|
|||||||
double c1, c2, s1, s2;
|
double c1, c2, s1, s2;
|
||||||
double t3a, t4a;
|
double t3a, t4a;
|
||||||
point cp1, cp2;
|
point cp1, cp2;
|
||||||
t3 = FixAngle(t3a=GetAngle(pt1.slope));
|
#pragma warning disable IDE0059 // Unnecessary assignment of a value - Keeping t3a,t4a for Debugging
|
||||||
t4 = FixAngle(t4a=GetAngle(pt2.slope));
|
t3 = FixAngle(t3a=GetAngle(pt1.slope));
|
||||||
thetaa = GetAngleBetweenPoints(pt1.APoint, pt2.APoint);
|
t4 = FixAngle(t4a=GetAngle(pt2.slope));
|
||||||
|
#pragma warning restore IDE0059 // Unnecessary assignment of a value
|
||||||
|
thetaa = GetAngleBetweenPoints(pt1.APoint, pt2.APoint);
|
||||||
if ((t3 - thetaa) * (t4 - thetaa) >= 0.0)
|
if ((t3 - thetaa) * (t4 - thetaa) >= 0.0)
|
||||||
{
|
{
|
||||||
double tprime;
|
double tprime;
|
||||||
@@ -1417,7 +1371,6 @@ namespace XYPlots
|
|||||||
y = Position[Y] - pty;
|
y = Position[Y] - pty;
|
||||||
DrawGridRelative(x, y, pg, vgOutput);
|
DrawGridRelative(x, y, pg, vgOutput);
|
||||||
}
|
}
|
||||||
private void relval(string ptr, int i) => ptr = string.Format("+{0}", i.ToString());
|
|
||||||
private void MoveRelative(int x, int y)
|
private void MoveRelative(int x, int y)
|
||||||
{
|
{
|
||||||
Position[X] += x;
|
Position[X] += x;
|
||||||
@@ -1450,7 +1403,6 @@ namespace XYPlots
|
|||||||
private void DrawArc(double radius, double Sangle, double Eangle, point cp, int x, int y, VG.Page pg, IVGOutput vgOutput)
|
private void DrawArc(double radius, double Sangle, double Eangle, point cp, int x, int y, VG.Page pg, IVGOutput vgOutput)
|
||||||
{
|
{
|
||||||
DebugOutput("r={0} sAngle={1} eAngle={2} cp={3},{4} x={5} y={6}", radius, Sangle, Eangle, cp.xyValue[0], cp.xyValue[1], x, y);
|
DebugOutput("r={0} sAngle={1} eAngle={2} cp={3},{4} x={5} y={6}", radius, Sangle, Eangle, cp.xyValue[0], cp.xyValue[1], x, y);
|
||||||
int dx, dy;
|
|
||||||
long radchk;
|
long radchk;
|
||||||
radchk = (long)radius;
|
radchk = (long)radius;
|
||||||
if (radchk > 72000L)
|
if (radchk > 72000L)
|
||||||
@@ -1458,8 +1410,9 @@ namespace XYPlots
|
|||||||
DrawAbsolute(x, y, pg, vgOutput);
|
DrawAbsolute(x, y, pg, vgOutput);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dx = x - cp.xyValue[X]; //jj
|
//For Debugging
|
||||||
dy = Math.Abs(cp.xyValue[Y] - Position[Y]); //jj
|
//int dx = x - cp.xyValue[X]; //jj
|
||||||
|
//int dy = Math.Abs(cp.xyValue[Y] - Position[Y]); //jj
|
||||||
float x1 = cp.xyValue[X] - (float)radius;
|
float x1 = cp.xyValue[X] - (float)radius;
|
||||||
float y1 = cp.xyValue[Y] - (float)radius;
|
float y1 = cp.xyValue[Y] - (float)radius;
|
||||||
float w1 = (float)radius * 2;
|
float w1 = (float)radius * 2;
|
||||||
@@ -1648,9 +1601,8 @@ namespace XYPlots
|
|||||||
else if (wn > DPI / 5) dn = dd / 5;
|
else if (wn > DPI / 5) dn = dd / 5;
|
||||||
else dn = dd / 2;
|
else dn = dd / 2;
|
||||||
GenGrid(flag, n - dd, n, dn, wn, lw - 1, val, pg, vgOutput);
|
GenGrid(flag, n - dd, n, dn, wn, lw - 1, val, pg, vgOutput);
|
||||||
wn = 0;
|
}
|
||||||
}
|
val = valn;
|
||||||
val = valn;
|
|
||||||
if (flag == Y)
|
if (flag == Y)
|
||||||
val = printerunits[Y] - val; //jj
|
val = printerunits[Y] - val; //jj
|
||||||
MoveAbsolute((flag == X ? val : 0), (flag == Y ? val : 0));
|
MoveAbsolute((flag == X ? val : 0), (flag == Y ? val : 0));
|
||||||
@@ -1763,72 +1715,72 @@ namespace XYPlots
|
|||||||
// - break up the string (if needed) and change the font pitch
|
// - break up the string (if needed) and change the font pitch
|
||||||
// for the text that is to be super/subscripted
|
// for the text that is to be super/subscripted
|
||||||
VG_Text drawText;
|
VG_Text drawText;
|
||||||
string tstr = "";
|
int Xpos, Ypos;
|
||||||
int Xpos, Ypos;
|
int sidx = 0; // beginning of string
|
||||||
int sidx = 0; // beginning of string
|
|
||||||
int idx = 0; // current position in string
|
int idx = 0; // current position in string
|
||||||
Xpos = Position[X];
|
Xpos = Position[X];
|
||||||
Ypos = Position[Y];
|
Ypos = Position[Y];
|
||||||
while (idx < txt.Length)
|
string tstr;
|
||||||
{
|
while (idx < txt.Length)
|
||||||
int tidx;
|
{
|
||||||
if ((tidx = txt.IndexOf(SuperScript[0], idx)) > -1)
|
int tidx;
|
||||||
{
|
if ((tidx = txt.IndexOf(SuperScript[0], idx)) > -1)
|
||||||
// print text up to the superscript
|
{
|
||||||
tstr = txt.Substring(sidx, tidx - sidx);
|
// print text up to the superscript
|
||||||
drawText = new VG_Text(Xpos, Ypos, (int)FontPitch, tstr, MyFontFamily, "", "", "", pg);
|
tstr = txt.Substring(sidx, tidx - sidx);
|
||||||
drawText.Draw(vgOutput);
|
drawText = new VG_Text(Xpos, Ypos, (int)FontPitch, tstr, MyFontFamily, "", "", "", pg);
|
||||||
Xpos += (CWIDEDOTS * tstr.Length);
|
drawText.Draw(vgOutput);
|
||||||
tidx += SuperScript[0].Length;
|
Xpos += (CWIDEDOTS * tstr.Length);
|
||||||
idx = tidx;
|
tidx += SuperScript[0].Length;
|
||||||
sidx = idx;
|
idx = tidx;
|
||||||
tidx = txt.IndexOf(SuperScript[1], idx);
|
sidx = idx;
|
||||||
if (tidx > 0)
|
tidx = txt.IndexOf(SuperScript[1], idx);
|
||||||
{
|
if (tidx > 0)
|
||||||
// switch font pitch, move up some, and print the superscript text
|
{
|
||||||
tstr = txt.Substring(sidx, tidx - sidx);
|
// switch font pitch, move up some, and print the superscript text
|
||||||
Ypos -= (CHIGHDOTS / 2); // move up half a char heigth
|
tstr = txt.Substring(sidx, tidx - sidx);
|
||||||
drawText = new VG_Text(Xpos, Ypos, (int)(FontPitch / 2), tstr, MyFontFamily, "", "", "", pg);
|
Ypos -= (CHIGHDOTS / 2); // move up half a char heigth
|
||||||
drawText.Draw(vgOutput);
|
drawText = new VG_Text(Xpos, Ypos, (int)(FontPitch / 2), tstr, MyFontFamily, "", "", "", pg);
|
||||||
Ypos += (CHIGHDOTS / 2); // move back down
|
drawText.Draw(vgOutput);
|
||||||
Xpos += ((CWIDEDOTS / 2) * tstr.Length); // positon half the width of the string
|
Ypos += (CHIGHDOTS / 2); // move back down
|
||||||
tidx += SuperScript[1].Length;
|
Xpos += ((CWIDEDOTS / 2) * tstr.Length); // positon half the width of the string
|
||||||
idx = tidx;
|
tidx += SuperScript[1].Length;
|
||||||
sidx = idx;
|
idx = tidx;
|
||||||
continue; // go back to beginning of while loop
|
sidx = idx;
|
||||||
}
|
continue; // go back to beginning of while loop
|
||||||
}
|
}
|
||||||
else if ((tidx = txt.IndexOf(SubScript[0], idx)) > -1)
|
}
|
||||||
{
|
else if ((tidx = txt.IndexOf(SubScript[0], idx)) > -1)
|
||||||
// print text up to the superscript
|
{
|
||||||
tstr = txt.Substring(sidx, tidx - sidx);
|
// print text up to the superscript
|
||||||
drawText = new VG_Text(Xpos, Ypos, (int)FontPitch, tstr, MyFontFamily, "", "", "", pg);
|
tstr = txt.Substring(sidx, tidx - sidx);
|
||||||
drawText.Draw(vgOutput);
|
drawText = new VG_Text(Xpos, Ypos, (int)FontPitch, tstr, MyFontFamily, "", "", "", pg);
|
||||||
Xpos += (CWIDEDOTS * tstr.Length);
|
drawText.Draw(vgOutput);
|
||||||
tidx += SubScript[0].Length;
|
Xpos += (CWIDEDOTS * tstr.Length);
|
||||||
idx = tidx;
|
tidx += SubScript[0].Length;
|
||||||
sidx = idx;
|
idx = tidx;
|
||||||
tidx = txt.IndexOf(SubScript[1], idx);
|
sidx = idx;
|
||||||
if (tidx > 0)
|
tidx = txt.IndexOf(SubScript[1], idx);
|
||||||
{
|
if (tidx > 0)
|
||||||
// switch font pitch, move up some, and print the superscript text
|
{
|
||||||
tstr = txt.Substring(sidx, tidx - sidx);
|
// switch font pitch, move up some, and print the superscript text
|
||||||
drawText = new VG_Text(Xpos, Ypos, (int)(FontPitch / 2), tstr, MyFontFamily, "", "", "", pg);
|
tstr = txt.Substring(sidx, tidx - sidx);
|
||||||
drawText.Draw(vgOutput);
|
drawText = new VG_Text(Xpos, Ypos, (int)(FontPitch / 2), tstr, MyFontFamily, "", "", "", pg);
|
||||||
Xpos += ((CWIDEDOTS / 2) * tstr.Length); // positon half the width of the string
|
drawText.Draw(vgOutput);
|
||||||
tidx += SubScript[1].Length;
|
Xpos += ((CWIDEDOTS / 2) * tstr.Length); // positon half the width of the string
|
||||||
idx = tidx;
|
tidx += SubScript[1].Length;
|
||||||
sidx = idx;
|
idx = tidx;
|
||||||
continue; // go back to beginning of while loop
|
sidx = idx;
|
||||||
}
|
continue; // go back to beginning of while loop
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
idx++;
|
{
|
||||||
}
|
idx++;
|
||||||
} // end while
|
}
|
||||||
|
} // end while
|
||||||
|
|
||||||
if (sidx < txt.Length)
|
if (sidx < txt.Length)
|
||||||
{
|
{
|
||||||
tstr = txt.Substring(sidx);
|
tstr = txt.Substring(sidx);
|
||||||
drawText = new VG_Text(Xpos, Ypos, (int)FontPitch, tstr, MyFontFamily, "", "", "", pg);
|
drawText = new VG_Text(Xpos, Ypos, (int)FontPitch, tstr, MyFontFamily, "", "", "", pg);
|
||||||
@@ -1943,7 +1895,9 @@ namespace XYPlots
|
|||||||
throw new Exception(String.Format("X/Y Plot Error - {0} - {1}",step,XYPlotIssue ?? "Unknown Issue"));
|
throw new Exception(String.Format("X/Y Plot Error - {0} - {1}",step,XYPlotIssue ?? "Unknown Issue"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ShowPoints(DataPoints dataPoints)
|
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Kept for Debugging")]
|
||||||
|
private void ShowPoints(DataPoints dataPoints)
|
||||||
{
|
{
|
||||||
//#if DEBUG
|
//#if DEBUG
|
||||||
//foreach (DataPoint pl in dataPoints)
|
//foreach (DataPoint pl in dataPoints)
|
||||||
@@ -1953,7 +1907,8 @@ namespace XYPlots
|
|||||||
//#endif
|
//#endif
|
||||||
}
|
}
|
||||||
public static string Key = "";
|
public static string Key = "";
|
||||||
private void DebugOutput(string format, params object[] args)
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping args for future use/Debugging")]
|
||||||
|
private void DebugOutput(string format, params object[] args)
|
||||||
{
|
{
|
||||||
//#if DEBUG
|
//#if DEBUG
|
||||||
//if (args.Length == 0)
|
//if (args.Length == 0)
|
||||||
@@ -1961,7 +1916,8 @@ namespace XYPlots
|
|||||||
//Console.WriteLine(format, args);
|
//Console.WriteLine(format, args);
|
||||||
//#endif
|
//#endif
|
||||||
}
|
}
|
||||||
private void DebugShowLocation(string command)
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping command for Debugging")]
|
||||||
|
private void DebugShowLocation(string command)
|
||||||
{
|
{
|
||||||
//Console.WriteLine("'{0}',{1},{2}", command, Position[X], Position[Y]);
|
//Console.WriteLine("'{0}',{1},{2}", command, Position[X], Position[Y]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user