Esempio n. 1
0
        void NuGenView_MouseRelease(object sender, MouseEventArgs e)
        {
            cursorLocation = new Point(e.X, e.Y);

            if (doc.DigitizeState == DigitizeState.SelectState)
            {
                if (dragged && selectedPointList.Count > 0)
                {
                    //Remove all the original points
                    foreach (NuGenPoint p in selectedPointGestatingList)
                    {
                        doc.RemovePoint(p);
                    }

                    //Clear them as well
                    selectedPointList.Clear();

                    //Add the new points to the list
                    selectedPointList.AddRange(selectedPointGestatingList);
                    selectedPointGestatingList.Clear();

                    List<NuGenPoint> tempList = new List<NuGenPoint>();

                    //And connect them internally
                    foreach (NuGenPoint p in selectedPointList)
                    {
                        NuGenPoint newPoint = doc.AddPoint(p);
                        //Add this point to a temp list so that selected items list stays up to date
                        tempList.Add(newPoint);

                        if (p.PointSet == doc.PointSets.Axes)
                        {                            
                            AxisPointDialog dlg = new AxisPointDialog();
                            if (dlg.ShowDialog() == DialogResult.OK)
                            {
                                GridMeshSettings settings = doc.GridDisplaySettings;
                                GridRemovalSettings removal = doc.GridRemovalSettings;

                                settings.initialized = false;
                                removal.gridMesh.initialized = false;

                                doc.GridRemovalSettings = removal;
                                doc.GridDisplaySettings = settings;

                                doc.SetAxisPoint(newPoint, dlg.XTheta, dlg.YR);
                            }
                            else
                            {
                                doc.RemovePoint(p);
                            }

                            DrawAll();
                        }
                        else if (p.PointSet == doc.PointSets.ScaleBar)
                        {

                            //Tests to see if there are two scale points in the selection
                            bool cont = false;
                            bool found = false;

                            foreach(NuGenPoint pNew in selectedPointList)
                            {
                                if (pNew.PointSet == doc.PointSets.ScaleBar)
                                {
                                    if (found == true)
                                    {
                                        cont = true;
                                        break;
                                    }

                                    found = true;
                                }
                            }

                            //No need to readjust scale point values if both were moved
                            if (cont)
                                continue;

                            ScaleBarDialog sdlg = new ScaleBarDialog();
                            if (sdlg.ShowDialog() == DialogResult.OK)
                            {
                                NuGenPoint other = new NuGenPoint(0,0);

                                //Get the other scale point, if it exists, which it should if you are moving the points
                                foreach (NuGenPoint p2 in doc.PointSets.ScaleBar.Points)
                                {
                                    if (p2 != p)
                                    {
                                        other = p;
                                        break;
                                    }
                                }

                                GridMeshSettings settings = doc.GridDisplaySettings;
                                GridRemovalSettings removal = doc.GridRemovalSettings;

                                settings.initialized = false;
                                removal.gridMesh.initialized = false;

                                doc.SetScalePoint(other, 0, 0);
                                doc.SetScalePoint(p, sdlg.Length, 0);
                                doc.Units = sdlg.Units;
                            }

                            DrawAll();
                        }

                    }

                    selectedPointList = tempList;

                    return;

                }

                if (selectionBox.Size.Width != 0 && selectionBox.Height != 0)
                {                                        
                    SelectRegion(selectionBox);
                    DrawAll();
                }

                dragged = false;
            }

            if (doc.DigitizeState == DigitizeState.MeasureState)
            {
                gestatingMeasurePoint = null;

                DrawAll();
                Refresh();
            }

            if (doc.DigitizeState != DigitizeState.ScaleState)
                return;

            if (doc.ProcessedImage.Width < e.X || doc.ProcessedImage.Height < e.Y)
                return;

            if (scaleStart == null || scaleEnd == null)
                return;

            if (scaleStart.XScreen == e.X && scaleStart.YScreen == e.Y)
            {
                MessageBox.Show("Scale bar is drawn by clicking and dragging. You must drag to a new point");

                doc.RemovePoint(scaleStart);
                doc.RemovePoint(scaleEnd);

                scaleStart = null;
                scaleEnd = null;

                DrawAll();

                return;
            }

            ScaleBarDialog sdlg2 = new ScaleBarDialog();
            sdlg2.ShowDialog();
            double length = sdlg2.Length;

            if (!(doc.SetScalePoint(scaleStart, 0.0, 0.0) && doc.SetScalePoint(scaleEnd, length, 0.0)))
            {
                sendStatusMessage("One or more scale points must be redefined");
            }
            else
            {
                doc.Units = sdlg2.Units;
            }

            scaleStart = null;
            scaleEnd = null;

            if (doc.ValidScale)
            {
                sendStatusMessage("Scale Bar Defined");
            }

            DrawScaleBar(Buffer);
            Refresh();
        }
Esempio n. 2
0
        void NuGenView_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            CheckForPointIntersection(e.X, e.Y);

            foreach (NuGenPoint p in selectedPointList)
            {
                if (p.PointSet == doc.PointSets.Axes)
                {
                    AxisPointDialog dlg = new AxisPointDialog();
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        GridMeshSettings settings = doc.GridDisplaySettings;
                        GridRemovalSettings removal = doc.GridRemovalSettings;

                        settings.initialized = false;
                        removal.gridMesh.initialized = false;

                        doc.GridRemovalSettings = removal;
                        doc.GridDisplaySettings = settings;

                        doc.SetAxisPoint(p, dlg.XTheta, dlg.YR);
                    }
                    else
                    {
                        doc.RemovePoint(p);
                    }

                    DrawAll();
                }
                else if (p.PointSet == doc.PointSets.ScaleBar)
                {
                    ScaleBarDialog sdlg = new ScaleBarDialog();
                    if (sdlg.ShowDialog() == DialogResult.OK)
                    {
                        NuGenPoint other = new NuGenPoint(0, 0);

                        //Get the other scale point, if it exists, which it should if you are moving the points
                        foreach (NuGenPoint p2 in doc.PointSets.ScaleBar.Points)
                        {
                            if (p2 != p)
                            {
                                other = p;
                                break;
                            }
                        }

                        GridMeshSettings settings = doc.GridDisplaySettings;
                        GridRemovalSettings removal = doc.GridRemovalSettings;

                        settings.initialized = false;
                        removal.gridMesh.initialized = false;

                        doc.SetScalePoint(other, 0, 0);
                        doc.SetScalePoint(p, sdlg.Length, 0);
                    }

                    DrawAll();
                }

            }
        }