//Initializes a new document and its corresponding view when importing or opening a document public NuGenDocument NewDocument() { NuGenDocument doc = null; if (docViewMap.Count == 0) { form.EnableControls(); } if (ActiveDocument != null) { // this document is not the first so start up in same state as previous document for continuity doc = new NuGenDocument(ActiveDocument.DigitizeState); } else { doc = new NuGenDocument(NuGenDefaultSettings.GetInstance().SessionsSettings.initialDigitizeState); } NuGenView view = new NuGenView(form, doc, this.SendStatusMessage); activeView = view; activeView.Focus(); view.Activate(); view.FormClosing += new FormClosingEventHandler(View_Closing); docViewMap.Add(doc, view); doc.UpdateListeners(); form.StatusPermanentMessage("Three axis points or the scale bar must be defined."); activeView.ShowCoordinates += new NuGenView.Show_Coordinates(this.Show_Coordinates); return(doc); }
//Constructs the document and places it in the provided state public NuGenDocument(DigitizeState state) { listeners = new List <NuGenImageListener>(); pointSets = new NuGenPointSetCollection(); segments = new NuGenSegmentCollection(); transform = new NuGenScreenTranslate(this); gridDisplay = new List <GridlineScreen>(); digitizeState = state; matchSet = new NuGenMatchSet(pointMatchSettings); //load all of the settings NuGenDefaultSettings rSettings = NuGenDefaultSettings.GetInstance(); coordSettings = rSettings.CoordSettings; exportSettings = rSettings.ExportSettings; segmentSettings = rSettings.SegmentSettings; pointMatchSettings = rSettings.PointMatchSettings; gridRemovalSettings = rSettings.GridRemovalSettings; gridDisplaySettings.initialized = false; gridDisplaySettings.gridSetX = rSettings.GridDisplayGridSetX; gridDisplaySettings.gridSetY = rSettings.GridDisplayGridSetY; discretizeSettings = rSettings.DiscretizeSettings; backgroundSelection = rSettings.BackgroundSelection; }
public NuGenTransform() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); form = new NuGenForm(this); form.IsMdiContainer = true; form.CurveCombo.Items.Add(NuGenPointSetCollection.DefaultCurveName); form.CurveCombo.Enabled = false; form.CurveCombo.SelectedIndex = 0; form.MeasureCombo.Items.Add(NuGenPointSetCollection.DefaultMeasureName); form.MeasureCombo.SelectedIndex = 0; form.MeasureCombo.Enabled = false; form.CurveCombo.SelectedIndexChanged += new EventHandler(CurveCombo_SelectedIndexChanged); form.MeasureCombo.SelectedIndexChanged += new EventHandler(MeasureCombo_SelectedIndexChanged); NuGenDefaultSettings settings = NuGenDefaultSettings.GetInstance(); mainWindowPos = settings.WindowMainPosition; mainWindowSize = settings.WindowMainSize; curveWindowPos = settings.WindowCurvePosition; curveWindowSize = settings.WindowCurveSize; measureWindowPos = settings.WindowMeasurePosition; measureWindowSize = settings.WindowMeasureSize; otherWindowPos = curveWindowPos; otherWindowSize = curveWindowSize; System.Windows.Forms.Application.Run(form); }
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 static NuGenDefaultSettings GetInstance() { if (instance == null) { instance = new NuGenDefaultSettings(); } return(instance); }
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); }
private static void TestDiscretize() { Image img = Image.FromFile("samples\\gridlines.gif"); NuGenDiscretize discretize = new NuGenDiscretize(img, NuGenDefaultSettings.GetInstance().DiscretizeSettings); discretize.Discretize(); Form f = new Form(); f.Size = new Size(img.Width, img.Height); f.BackgroundImage = discretize.GetImage(); f.ShowDialog(); System.Threading.Thread.Sleep(10000); }
public static NuGenDefaultSettings GetInstance() { if (instance == null) { instance = new NuGenDefaultSettings(); } return instance; }
// given an x value, return the corresponding y value, interpolating if necessary public string ExportCurvePoint(double x, CoordSettings coord, bool useInterpolation, int yPrecision) { string yNew = ""; // initial empty value might be returned if interpolation is disabled if (Points.Count == 0) { return(yNew); } if (!useInterpolation) { // x value has to exactly match one of the points in this curve foreach (NuGenPoint p in Points) { if (x == p.XThetaGraph) { return(Math.Round(p.YRGraph, yPrecision).ToString()); } } return(yNew); } if (Points.Count == 1) { foreach (NuGenPoint p in Points) { return(Math.Round(p.YRGraph, yPrecision).ToString()); } } IEnumerator <NuGenPoint> lEnum = Points.GetEnumerator(); IEnumerator <NuGenPoint> rEnum = Points.GetEnumerator(); rEnum.MoveNext(); rEnum.MoveNext(); lEnum.MoveNext(); NuGenPoint pLeft = lEnum.Current; NuGenPoint pRight = rEnum.Current; while (x > rEnum.Current.XThetaGraph) { rEnum.MoveNext(); lEnum.MoveNext(); if (rEnum.Current != null) { pLeft = lEnum.Current; pRight = rEnum.Current; } else { break; } } double leftPointX = pLeft.XThetaGraph; double rightPointX = pRight.XThetaGraph; double leftPointY = pLeft.YRGraph; double rightPointY = pRight.YRGraph; if (AdjustForLogScale(coord.xThetaScale, ref leftPointX) && AdjustForLogScale(coord.xThetaScale, ref rightPointX) && AdjustForLogScale(coord.xThetaScale, ref x) && AdjustForLogScale(coord.yRScale, ref leftPointY) && AdjustForLogScale(coord.yRScale, ref rightPointY)) { double denominator = rightPointX - leftPointX; if (denominator < NuGenDefaultSettings.GetInstance().DoubleMin) { yNew = Math.Round(leftPointX, yPrecision).ToString(); } else { // if x value is between the points this is an interpolation (0<s<1), otherwise an extrapolation double s = (x - leftPointX) / denominator; // interpolate or extrapolate double otherPoint = (1.0 - s) * leftPointY + s * rightPointY; // adjust for log scale if (coord.yRScale == Scale.Log) { otherPoint = Math.Pow((double)10.0, otherPoint); } yNew = Math.Round(otherPoint, yPrecision).ToString(); } } return(yNew); }
protected override void OnClosing(CancelEventArgs e) { base.OnClosing(e); NuGenDefaultSettings.GetInstance().SaveSettings(); }
private static void TestDefaultSettings() { NuGenDefaultSettings s = NuGenDefaultSettings.GetInstance(); GridRemovalSettings settings = s.GridRemovalSettings; }
public void ProcessedImage_Click(object sender, System.EventArgs args) { ActiveDocument.BackgroundSelection = BackgroundSelection.ProcessedImage; NuGenDefaultSettings.GetInstance().BackgroundSelection = BackgroundSelection.ProcessedImage; }
public void OriginalBackground_Click(object sender, System.EventArgs args) { ActiveDocument.BackgroundSelection = BackgroundSelection.OriginalImage; NuGenDefaultSettings.GetInstance().BackgroundSelection = BackgroundSelection.OriginalImage; }
public void NoBackground_Click(object sender, System.EventArgs args) { ActiveDocument.BackgroundSelection = BackgroundSelection.BlankBackground; NuGenDefaultSettings.GetInstance().BackgroundSelection = BackgroundSelection.BlankBackground; }
public void AllPointsView_Click(object sender, System.EventArgs args) { docViewMap.GetView(ActiveDocument).ViewPointSelection = ViewPointSelection.ViewAllPoints; NuGenDefaultSettings.GetInstance().ViewPointSelection = ViewPointSelection.ViewAllPoints; }