// return coordinate range for specified pointset public void SinglePointSetGraphLimits(NuGenPointSet p, ref bool first, ref double xThetaMin, ref double xThetaMax, ref double yRMin, ref double yRMax) { double xtmin = 0.0, xtmax = 0.0, yrmin = 0.0, yrmax = 0.0; if (p.PointSetGraphLimits(ref xtmin, ref xtmax, ref yrmin, ref yrmax)) { if (first || (xtmin < xThetaMin)) { xThetaMin = xtmin; } if (first || (xtmax > xThetaMax)) { xThetaMax = xtmax; } if (first || (yrmin < yRMin)) { yRMin = yrmin; } if (first || (yrmax > yRMax)) { yRMax = yrmax; } first = false; } }
public PointsetsDialog(List<NuGenPointSet> pointSets, bool curve) { InitializeComponent(); if (curve) listLabel.Text = "Curves"; else listLabel.Text = "Measures"; this.curve = curve; foreach (NuGenPointSet pointSet in pointSets) { NuGenPointSet newPointSet = new NuGenPointSet(); newPointSet.Style = pointSet.Style; newPointSet.Name = pointSet.Name; this.pointSets.Add(newPointSet); } this.pointSets = pointSets; foreach (NuGenPointSet pointSet in pointSets) { listBox1.Items.Add(pointSet.Name); } this.MaximumSize = Size; }
public PointsetsDialog(List <NuGenPointSet> pointSets, bool curve) { InitializeComponent(); if (curve) { listLabel.Text = "Curves"; } else { listLabel.Text = "Measures"; } this.curve = curve; foreach (NuGenPointSet pointSet in pointSets) { NuGenPointSet newPointSet = new NuGenPointSet(); newPointSet.Style = pointSet.Style; newPointSet.Name = pointSet.Name; this.pointSets.Add(newPointSet); } this.pointSets = pointSets; foreach (NuGenPointSet pointSet in pointSets) { listBox1.Items.Add(pointSet.Name); } this.MaximumSize = Size; }
public NuGenPointSetCollection() { axesPointSet = new NuGenPointSet(); axesPointSet.Style = NuGenDefaultSettings.GetInstance().AxesStyle; scalePointSet = new NuGenPointSet(); scalePointSet.Style = NuGenDefaultSettings.GetInstance().ScaleStyle; curveList = new List <NuGenPointSet>(); measureList = new List <NuGenPointSet>(); }
public NuGenPoint(int xScreen, int yScreen) { this.xScreen = xScreen; this.yScreen = yScreen; xThetaGraph = 0.0; yRGraph = 0.0; xThetaDefined = false; yRDefined = false; pointSet = new NuGenPointSet(); }
public NuGenPoint(NuGenPoint other) { this.xScreen = other.xScreen; this.yScreen = other.yScreen; xThetaGraph = other.XThetaGraph; yRGraph = other.yRGraph; xThetaDefined = other.xThetaDefined; yRDefined = other.yRDefined; pointSet = new NuGenPointSet(); }
public NuGenPoint(int xScreen, int yScreen, double xThetaGraph, double yRGraph) { this.xScreen = xScreen; this.yScreen = yScreen; this.xThetaGraph = xThetaGraph; this.yRGraph = yRGraph; xThetaDefined = true; yRDefined = true; pointSet = new NuGenPointSet(); }
private void propertiesButton_Click(object sender, EventArgs e) { NuGenPointSet pointSet = GetPointsFromName((string)listBox1.SelectedItem); PointSettingsDialog dlg = new PointSettingsDialog(pointSet.Style, false); if (dlg.ShowDialog() == DialogResult.OK) { pointSet.Style = dlg.Style; } }
// add axis or curve point, depending on state. axis point graph coordinates are set later by // setAxisPoint so user can see where the new axis point lies while editing the graph coordinatees public NuGenPoint AddPoint(int xScreen, int yScreen, NuGenPointSet destination) { double xThetaGraph = 0.0, yRGraph = 0.0; NuGenPoint p; if ((digitizeState == DigitizeState.CurveState) || (digitizeState == DigitizeState.MeasureState)) { ScreenToXThetaYR(xScreen, yScreen, out xThetaGraph, out yRGraph); p = new NuGenPoint(xScreen, yScreen, xThetaGraph, yRGraph); } else { p = new NuGenPoint(xScreen, yScreen); } switch (digitizeState) { case DigitizeState.AxisState: dirtyAxesTransformation = true; pointSets.AddPointAxes(p); break; case DigitizeState.CurveState: case DigitizeState.SegmentState: pointSets.AddPointCurve(p, currentCurveName); break; case DigitizeState.MeasureState: pointSets.AddPointMeasure(p, currentMeasureName); break; case DigitizeState.ScaleState: dirtyScaleTransformation = true; pointSets.AddPointScale(p); break; case DigitizeState.SelectState: //Could be any type of point, so decide if (destination != null) { destination.AddPoint(p); } break; } PointSets.UpdateGraphCoordinates(coordSettings, transform); return(p); }
private void addButton_Click(object sender, EventArgs e) { NameDialog dlg = new NameDialog(); if (dlg.ShowDialog() == DialogResult.OK) { NuGenPointSet pointSet = new NuGenPointSet(); pointSet.Name = dlg.PointSetName; pointSet.Style = curve ? NuGenDefaultSettings.GetInstance().DefaultCurveStyle : NuGenDefaultSettings.GetInstance().DefaultMeasureStyle; pointSets.Add(pointSet); } UpdateListBox(); }
public void AddMeasure(string name) { NuGenPointSet pointSet = new NuGenPointSet(); pointSet.Name = name; foreach (NuGenPointSet p in measureList) { if (p.Name == name) { throw new ArgumentException("Can not create another curve set with the name " + name); } } pointSet.Style = NuGenDefaultSettings.GetInstance().DefaultMeasureStyle; measureList.Add(pointSet); }
// update the axes and scale bar transformations, and use whichever works. if there is incomplete // (insufficient points) or inconsistent information (collocated or collinear points), this exits // gracefully. if successful, all curve and measure point coordinates are updated and the gridMeshSettings lines are moved public int ComputeTransformation() { NuGenPointSet pointSet = pointSets.Axes; int result = NuGenMath.SUCCESS; if (dirtyAxesTransformation) { dirtyAxesTransformation = false; result = transform.ComputeAxesTransformation(coordSettings, pointSet); } bool success = transform.ValidAxes; if (!success) { // axes transformation failed so try scale bar transformation pointSet = pointSets.ScaleBar; if (dirtyScaleTransformation) { dirtyScaleTransformation = false; result = transform.ComputeScaleTransformation(coordSettings, pointSet); } success = transform.ValidScale; } if (success) { if (!gridRemovalSettings.gridMesh.initialized) { InitGridRemovalMesh(); } if (!gridDisplaySettings.initialized) { InitGridDisplayMesh(); } } // graph coordinates are updated even if transform is invalid, since graph coordinates // are just set to screen coordinates pointSets.UpdateGraphCoordinates(CoordSettings, transform); return(result); }
//deserialize public void SerializeRead(System.Runtime.Serialization.SerializationInfo info) { axesPointSet.SerializeRead(info, "axes"); scalePointSet.SerializeRead(info, "scale"); for (int i = 0; i < (int)info.GetValue("curves.count", typeof(int)); i++) { NuGenPointSet curve = new NuGenPointSet(); curve.SerializeRead(info, "curve" + i); curveList.Add(curve); } for (int i = 0; i < (int)info.GetValue("measures.count", typeof(int)); i++) { NuGenPointSet measure = new NuGenPointSet(); measure.SerializeRead(info, "measure" + i); measureList.Add(measure); } }
//Computes the graph area based on the defined axis points, returns a value corresponding // to the result of the calculation public int ComputeAxesTransformation(CoordSettings coordSettings, NuGenPointSet pointSet) { double[][] r_graph = { new double[3], new double[3], new double[3] }; double[,] r_screen = new double[3,3]; List<NuGenPoint> points = pointSet.Points; axisPointCount = 0; validAxes = false; foreach(NuGenPoint p in points) { if(axisPointCount == 3) throw new InvalidOperationException("We have three axis points, can not compute more"); if(p.GraphCoordsAreDefined()) { double xGraph, yGraph; ConvertToCartesian(NuGenMath.mmUnitize(coordSettings), p.XThetaGraph, p.YRGraph, out xGraph, out yGraph); r_graph[0][axisPointCount] = xGraph; r_graph[1][axisPointCount] = yGraph; r_graph[2][axisPointCount] = 1.0; r_screen[0, axisPointCount] = p.XScreen; r_screen[1, axisPointCount] = p.YScreen; r_screen[2, axisPointCount] = 1.0; axisPointCount++; } } if(axisPointCount == 3) { AdjustMidValuedLogCoords(coordSettings, r_graph); int rtnS2G = NuGenMath.ScreenToGraph(r_graph, r_screen, screenToGraph, graphToScreen); validAxes = false; if(rtnS2G == NuGenMath.SUCCESS) { int rtnL2L = ComputeLogToFromLinear(coordSettings, r_graph); switch(rtnL2L) { case NuGenMath.SUCCESS: break; case NuGenMath.NONPOSITIVE_COORDINATE: return NuGenMath.NONPOSITIVE_COORDINATE; case NuGenMath.NO_SPREAD: return NuGenMath.NO_SPREAD; } } validAxes = (rtnS2G == NuGenMath.SUCCESS); switch (rtnS2G) { case NuGenMath.SUCCESS: return NuGenMath.SUCCESS; case NuGenMath.BAD_GRAPH_COORDINATES: return NuGenMath.BAD_GRAPH_COORDINATES; case NuGenMath.BAD_SCREEN_COORDINATES: return NuGenMath.BAD_SCREEN_COORDINATES; } } return NuGenMath.SUCCESS; }
private void DrawPoints(NuGenPointSet pointSet, Graphics g) { DrawPoints(pointSet.Points, g); }
//Computes the graph area based on the scale bar definition public int ComputeScaleTransformation(CoordSettings coordSettings, NuGenPointSet pointSet) { double[][] r_graph = { new double[3], new double[3], new double[3] }; double[,] r_screen = new double[3, 3]; List<NuGenPoint> points = pointSet.Points; scalePointCount = 0; validScale = false; foreach (NuGenPoint point in points) { if (scalePointCount == 2) throw new InvalidOperationException("Can not define more scale bar points"); if (point.GraphCoordsAreDefined()) { double xGraph, yGraph; ConvertToCartesian(NuGenMath.mmUnitize(coordSettings), point.XThetaGraph, point.YRGraph, out xGraph, out yGraph); r_graph[0][scalePointCount] = xGraph; r_graph[1][scalePointCount] = yGraph; r_graph[2][scalePointCount] = 1.0; r_screen[0, scalePointCount] = point.XScreen; r_screen[1, scalePointCount] = point.YScreen; r_screen[2, scalePointCount] = 1.0; scalePointCount++; } } if (scalePointCount == 2) { // create virtual third point along a virtual axis which is just orthogonal to the virtual // axis between the other two points. assumes all points are in same z-value (which is 1.0) plane double[] axis1 = new double[3]; double[] axis2 = new double[3]; double[] z = { 0.0, 0.0, 1.0 }; axis1[0] = r_graph[0][1] - r_graph[0][0]; axis1[1] = r_graph[1][1] - r_graph[1][0]; axis1[2] = r_graph[2][1] - r_graph[2][0]; NuGenMath.VectorCrossProduct(z, axis1, axis2); r_graph[0][2] = r_graph[0][0] + axis2[0]; r_graph[1][2] = r_graph[1][0] + axis2[1]; r_graph[2][2] = 1.0; axis1[0] = r_screen[0, 1] - r_screen[0, 0]; axis1[1] = r_screen[1, 1] - r_screen[1, 0]; axis1[2] = r_screen[2, 1] - r_screen[2, 0]; NuGenMath.VectorCrossProduct(z, axis1, axis2); r_screen[0, 2] = r_screen[0, 0] + axis2[0]; r_screen[1, 2] = r_screen[1, 0] + axis2[1]; r_screen[2, 2] = 1.0; int rtnS2G = NuGenMath.ScreenToGraph(r_graph, r_screen, screenToGraph, graphToScreen); // log to linear transformation is not allowed when using scale bar since it would // be such an extremely rare special case that its benefit would be minimal, especially // since it would only confuse the majority of users who would not be expecting it validScale = (rtnS2G == NuGenMath.SUCCESS); switch (rtnS2G) { case NuGenMath.SUCCESS: return NuGenMath.SUCCESS; case NuGenMath.BAD_GRAPH_COORDINATES: return NuGenMath.BAD_GRAPH_COORDINATES; case NuGenMath.BAD_SCREEN_COORDINATES: return NuGenMath.BAD_SCREEN_COORDINATES; } } return NuGenMath.SUCCESS; }
//Computes the graph area based on the scale bar definition public int ComputeScaleTransformation(CoordSettings coordSettings, NuGenPointSet pointSet) { double[][] r_graph = { new double[3], new double[3], new double[3] }; double[,] r_screen = new double[3, 3]; List <NuGenPoint> points = pointSet.Points; scalePointCount = 0; validScale = false; foreach (NuGenPoint point in points) { if (scalePointCount == 2) { throw new InvalidOperationException("Can not define more scale bar points"); } if (point.GraphCoordsAreDefined()) { double xGraph, yGraph; ConvertToCartesian(NuGenMath.mmUnitize(coordSettings), point.XThetaGraph, point.YRGraph, out xGraph, out yGraph); r_graph[0][scalePointCount] = xGraph; r_graph[1][scalePointCount] = yGraph; r_graph[2][scalePointCount] = 1.0; r_screen[0, scalePointCount] = point.XScreen; r_screen[1, scalePointCount] = point.YScreen; r_screen[2, scalePointCount] = 1.0; scalePointCount++; } } if (scalePointCount == 2) { // create virtual third point along a virtual axis which is just orthogonal to the virtual // axis between the other two points. assumes all points are in same z-value (which is 1.0) plane double[] axis1 = new double[3]; double[] axis2 = new double[3]; double[] z = { 0.0, 0.0, 1.0 }; axis1[0] = r_graph[0][1] - r_graph[0][0]; axis1[1] = r_graph[1][1] - r_graph[1][0]; axis1[2] = r_graph[2][1] - r_graph[2][0]; NuGenMath.VectorCrossProduct(z, axis1, axis2); r_graph[0][2] = r_graph[0][0] + axis2[0]; r_graph[1][2] = r_graph[1][0] + axis2[1]; r_graph[2][2] = 1.0; axis1[0] = r_screen[0, 1] - r_screen[0, 0]; axis1[1] = r_screen[1, 1] - r_screen[1, 0]; axis1[2] = r_screen[2, 1] - r_screen[2, 0]; NuGenMath.VectorCrossProduct(z, axis1, axis2); r_screen[0, 2] = r_screen[0, 0] + axis2[0]; r_screen[1, 2] = r_screen[1, 0] + axis2[1]; r_screen[2, 2] = 1.0; int rtnS2G = NuGenMath.ScreenToGraph(r_graph, r_screen, screenToGraph, graphToScreen); // log to linear transformation is not allowed when using scale bar since it would // be such an extremely rare special case that its benefit would be minimal, especially // since it would only confuse the majority of users who would not be expecting it validScale = (rtnS2G == NuGenMath.SUCCESS); switch (rtnS2G) { case NuGenMath.SUCCESS: return(NuGenMath.SUCCESS); case NuGenMath.BAD_GRAPH_COORDINATES: return(NuGenMath.BAD_GRAPH_COORDINATES); case NuGenMath.BAD_SCREEN_COORDINATES: return(NuGenMath.BAD_SCREEN_COORDINATES); } } return(NuGenMath.SUCCESS); }
//Computes the graph area based on the defined axis points, returns a value corresponding // to the result of the calculation public int ComputeAxesTransformation(CoordSettings coordSettings, NuGenPointSet pointSet) { double[][] r_graph = { new double[3], new double[3], new double[3] }; double[,] r_screen = new double[3, 3]; List <NuGenPoint> points = pointSet.Points; axisPointCount = 0; validAxes = false; foreach (NuGenPoint p in points) { if (axisPointCount == 3) { throw new InvalidOperationException("We have three axis points, can not compute more"); } if (p.GraphCoordsAreDefined()) { double xGraph, yGraph; ConvertToCartesian(NuGenMath.mmUnitize(coordSettings), p.XThetaGraph, p.YRGraph, out xGraph, out yGraph); r_graph[0][axisPointCount] = xGraph; r_graph[1][axisPointCount] = yGraph; r_graph[2][axisPointCount] = 1.0; r_screen[0, axisPointCount] = p.XScreen; r_screen[1, axisPointCount] = p.YScreen; r_screen[2, axisPointCount] = 1.0; axisPointCount++; } } if (axisPointCount == 3) { AdjustMidValuedLogCoords(coordSettings, r_graph); int rtnS2G = NuGenMath.ScreenToGraph(r_graph, r_screen, screenToGraph, graphToScreen); validAxes = false; if (rtnS2G == NuGenMath.SUCCESS) { int rtnL2L = ComputeLogToFromLinear(coordSettings, r_graph); switch (rtnL2L) { case NuGenMath.SUCCESS: break; case NuGenMath.NONPOSITIVE_COORDINATE: return(NuGenMath.NONPOSITIVE_COORDINATE); case NuGenMath.NO_SPREAD: return(NuGenMath.NO_SPREAD); } } validAxes = (rtnS2G == NuGenMath.SUCCESS); switch (rtnS2G) { case NuGenMath.SUCCESS: return(NuGenMath.SUCCESS); case NuGenMath.BAD_GRAPH_COORDINATES: return(NuGenMath.BAD_GRAPH_COORDINATES); case NuGenMath.BAD_SCREEN_COORDINATES: return(NuGenMath.BAD_SCREEN_COORDINATES); } } return(NuGenMath.SUCCESS); }