コード例 #1
0
ファイル: ExpansionEditor.cs プロジェクト: suvjunmd/Moritz
        private void GetPlanetCandidates(RectangleF mouseR, List<ExpansionFieldPointInfo> candidates, List<Planet> planets, bool inputPlanets)
        {
            PointF testPoint;
            //uint[] flatInputValues = _outputKrystal.PointsInputKrystal.AlignedValues;
            for (int planetIndex = 0; planetIndex < planets.Count; planetIndex++)
            {
                for (int spi = 0; spi < planets[planetIndex].Subpaths.Count; spi++)
                {
                    for (int pointIndex = 0; pointIndex < planets[planetIndex].Subpaths[spi].Count; pointIndex++)
                    {
                        PointGroup pointGroup = planets[planetIndex].Subpaths[spi];
                        testPoint = pointGroup.WindowsPixelCoordinates[pointIndex];
                        if (mouseR.Contains(testPoint))
                        {
                            ExpansionFieldPointInfo ppi = new ExpansionFieldPointInfo();
                            ppi.location = testPoint;
                            ppi.isPlanet = true;
                            if (!inputPlanets || pointGroup.Value[0] == _strandNodeList[(int)(pointIndex + pointGroup.StartMoment - 1)].strandPoint)
                                ppi.isUsed = true;
                            else ppi.isUsed = false;
                            if (inputPlanets)
                            {
                                ppi.comboBoxName = "Input Planet " + (planetIndex + 1).ToString();
                                ppi.isInput = true;
                            }
                            else
                            {
                                ppi.comboBoxName = "Output Planet " + (planetIndex + 1).ToString();
                                ppi.isInput = false;
                            }
                            ppi.subPathName = "Subpath " + (spi + 1).ToString();
                            ppi.momentNumber = (uint)pointIndex + pointGroup.StartMoment;
                            ppi.value = planets[planetIndex].Value;

                            candidates.Add(ppi);
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: ExpansionEditor.cs プロジェクト: suvjunmd/Moritz
 /// <summary>
 /// Creates a single point marker (displayed while the right-mouse button point-info
 /// message box is displayed).
 /// </summary>
 /// <param name="centre">The centre of the new marker</param>
 /// <param name="pointValue">The value of the point (its label)</param>
 /// <param name="highlight"> null for an output point, true for a used input point, false for an unused input point.</param>
 public void CreateSinglePointMarker(ExpansionFieldPointInfo pointInfo)
 {
     _singlePointMarker = new PointMarker(pointInfo.location.X, pointInfo.location.Y, pointInfo.value.ToString(),
                                         _scale, _fieldPanelCentreX, _fieldPanelCentreY,
                                         pointInfo.isInput, pointInfo.isUsed);
 }
コード例 #3
0
ファイル: ExpansionEditor.cs プロジェクト: suvjunmd/Moritz
        private void GetFixedPointCandidates(RectangleF mouseR, List<ExpansionFieldPointInfo> candidates, List<PointGroup> pointGroups, bool inputGroup)
        {
            PointF testPoint;

            for (int pgi = 0; pgi < pointGroups.Count; pgi++)
            {
                for (int pointIndex = 0; pointIndex < pointGroups[pgi].Count; pointIndex++)
                {
                    testPoint = pointGroups[pgi].WindowsPixelCoordinates[pointIndex];
                    if (mouseR.Contains(testPoint))
                    {
                        ExpansionFieldPointInfo ppi = new ExpansionFieldPointInfo();
                        ppi.location = testPoint;
                        ppi.isPlanet = false;
                        ppi.isUsed = true;
                        if (inputGroup)
                        {
                            ppi.comboBoxName = "Input Group " + (pgi + 1).ToString();
                            ppi.isInput = true;
                        }
                        else
                        {
                            ppi.comboBoxName = "Output Group " + (pgi + 1).ToString();
                            ppi.isInput = false;
                        }
                        ppi.subPathName = "";
                        ppi.momentNumber = 0;
                        ppi.value = pointGroups[pgi].Value[pointIndex];

                        candidates.Add(ppi);
                    }
                }
            }
        }
コード例 #4
0
ファイル: ExpansionEditor.cs プロジェクト: suvjunmd/Moritz
        /// <summary>
        /// Displays a message box with information about the point at the given coordinate
        /// (which has just been clicked with the right mouse key).
        /// </summary>
        /// <param name="mousePoint"></param>
        private void ShowPointInfo(PointF mousePoint)
        {
            RectangleF mouseRect = new RectangleF((float)mousePoint.X - 3f, (float)mousePoint.Y - 3f, 6f, 6f);
            List<ExpansionFieldPointInfo> candidates = new List<ExpansionFieldPointInfo>();
            GetPlanetCandidates(mouseRect, candidates, _expander.InputGamete.Planets, true);
            GetPlanetCandidates(mouseRect, candidates, _expander.OutputGamete.Planets, false);
            GetFixedPointCandidates(mouseRect, candidates, _expander.InputGamete.FixedPointGroups, true);
            GetFixedPointCandidates(mouseRect, candidates, _expander.OutputGamete.FixedPointGroups, false);
            ExpansionFieldPointInfo pointInfo = new ExpansionFieldPointInfo();
            string msg = "Point not found";
            if (candidates.Count > 0)
            {
                //PointF mousePoint = new PointF((float)e.X, (float)e.Y);
                float currentDistanceSquared = float.MaxValue;
                foreach (ExpansionFieldPointInfo efpi in candidates)
                {
                    float deltaX = mousePoint.X - efpi.location.X;
                    float deltaY = mousePoint.Y - efpi.location.Y;
                    float distanceSquared = (deltaX * deltaX) + (deltaY * deltaY);
                    if (distanceSquared < currentDistanceSquared)
                    {
                        currentDistanceSquared = distanceSquared;
                        pointInfo = efpi;
                    }
                }
                if (pointInfo.isPlanet)
                {
                    PointR userCoordinates = _painter.UserCoordinates(pointInfo.location);
                    msg = String.Format("{0}\n{1}\n\nsection: {2}\nmoment: {3}\n\nradius: {4:f3}\nangle: {5:f2}\n\nvalue: {6}",
                        pointInfo.comboBoxName, pointInfo.subPathName,
                        _expansionTreeView.SectionNumberString((int)pointInfo.momentNumber),
                        pointInfo.momentNumber,
                        userCoordinates.Radius, userCoordinates.AngleDegrees, pointInfo.value);
                    msg = msg.Replace(",", ".");
                    _expansionTreeView.SelectMoment((int)pointInfo.momentNumber);
                }
                else // is fixed point
                {
                    PointR userCoordinates = _painter.UserCoordinates(pointInfo.location);
                    msg = String.Format("{0}\n\nradius: {1:f3}\nangle: {2:f2}\n\nvalue: {3}",
                        pointInfo.comboBoxName, userCoordinates.Radius, userCoordinates.AngleDegrees, pointInfo.value);
                    msg = msg.Replace(",", ".");
                }

                float scalePercent = float.Parse(this.ZoomComboBox.Text);
                _painter.CreateSinglePointMarker(pointInfo);
                RedrawFieldPanel();
            }

            MessageBox.Show(msg, "Point information", MessageBoxButtons.OK, MessageBoxIcon.None);

            _painter.ClearAllPointMarkers();
            RedrawFieldPanel();
        }