Example #1
0
        public void InsertVariation(PhysicalAndPanelPoint selectedPoint, CriticalityVariation variationToInsert)
        {
            int selectedPointIndex = points.IndexOf(selectedPoint);

            this.Insert(selectedPointIndex, variationToInsert);
            this.CalculateCharacteristicValues();
            this.CalculatePoints();
        }
Example #2
0
        public void deleteVariation(PhysicalAndPanelPoint selectedPoint)
        {
            int selectedPointIndex = points.IndexOf(selectedPoint);

            if (selectedPointIndex == 0)
            {
            }
            else
            {
                this.RemoveAt(selectedPointIndex - 1);
                this.CalculateCharacteristicValues();
            }

            this.CalculatePoints();
        }
Example #3
0
        public void updateVariations(PhysicalAndPanelPoint selectedPoint)
        {
            int selectedPointIndex = points.IndexOf(selectedPoint);

            if (selectedPointIndex >= 0)
            {
                if (selectedPointIndex == 0)
                {
                    this.CalculateCharacteristicValues(CharacteristicValues.initial - offset.Y / heigthScale);
                }
                else  //selectedPointIndex > 0
                {
                    CriticalityVariation selectedCv = this[selectedPointIndex - 1];
                    selectedCv.length    += offset.X / widthScale;
                    selectedCv.variation -= offset.Y / heigthScale;
                    this.CalculateCharacteristicValues();
                }
                this.CalculatePoints();
            }
        }
Example #4
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (criticalityVariationsPoints != null)
            {
                if (draging)
                {
                    draggingPoint = e.Location;
                    criticalityVariationsPoints.calculateMovingPoints(selectedPoint, e.Location);
                    this.Refresh();
                }
                else
                {
                    double                range;
                    double                shorterRange   = this.Height + this.Width;
                    const double          rangeDetection = 8;
                    PhysicalAndPanelPoint closestPoint   = new PhysicalAndPanelPoint(0, 0, new Point(0, 0));
                    bool onePointWasClose;

                    onePointWasClose = onePointIsClose;
                    onePointIsClose  = false;
                    foreach (PhysicalAndPanelPoint point in criticalityVariationsPoints.Points)
                    {
                        range = Math.Sqrt(Math.Pow(e.X - point.PanelPoint.X, 2) + Math.Pow(e.Y - point.PanelPoint.Y, 2));
                        if (range < rangeDetection && range < shorterRange)
                        {
                            shorterRange    = range;
                            closestPoint    = point;
                            onePointIsClose = true;
                        }
                    }
                    if ((onePointIsClose != onePointWasClose) || (selectedPoint != closestPoint))
                    {
                        selectedPoint = closestPoint;
                        this.Refresh();
                    }
                }
            }
        }
Example #5
0
        public void calculateMovingPoints(PhysicalAndPanelPoint selectedPoint, Point mouse)
        {
            PhysicalAndPanelPoint previousPoint;
            Point offsetPoint;

            movingPoints = new List <PhysicalAndPanelPoint>();

            int selectedPointIndex = points.IndexOf(selectedPoint);

            offset.Y = mouse.Y - selectedPoint.PanelPoint.Y;

            if (selectedPointIndex <= 0)
            {
                previousPoint = points[0];
                offset.X      = 0;
            }
            else
            {
                previousPoint = points[selectedPointIndex - 1];
                offset.X      = Math.Max(mouse.X - selectedPoint.PanelPoint.X,
                                         previousPoint.PanelPoint.X - selectedPoint.PanelPoint.X);
            }


            foreach (PhysicalAndPanelPoint p in points)
            {
                if (points.IndexOf(p) < selectedPointIndex)
                {
                    movingPoints.Add(p);
                }
                else
                {
                    offsetPoint = new Point(p.PanelPoint.X + offset.X,
                                            p.PanelPoint.Y + mouse.Y - selectedPoint.PanelPoint.Y);
                    movingPoints.Add(new PhysicalAndPanelPoint(offsetPoint));
                }
                previousPoint = p;
            }
        }
Example #6
0
        private void WriteXYAxis(Graphics g, PhysicalAndPanelPoint criticalityPoint)
        {
            const int LegendXMargin = 6;
            string    legend        = ((int)criticalityPoint.PhysicalY).ToString();
            SizeF     legendSizeF   = g.MeasureString(legend, SystemFonts.DefaultFont);

            //legendSizeF.Height trop élevé, réduit de 25
            g.DrawString(legend,
                         SystemFonts.DefaultFont, Brushes.Black,
                         new Point(chartSize.LeftTopMargins.X - (int)(legendSizeF.Width) - LegendXMargin,
                                   criticalityPoint.PanelPoint.Y + (int)((legendSizeF.Height - 25) / 2)));

            legend      = (criticalityPoint.PhysicalX).ToString("0.0");
            legendSizeF = g.MeasureString(legend, SystemFonts.DefaultFont);
            //legendSizeF.Height trop élevé, réduit de 7
            const int LegendYMargin = -7;

            g.DrawString(legend,
                         SystemFonts.DefaultFont, Brushes.Black,
                         new Point(criticalityPoint.PanelPoint.X - (int)(legendSizeF.Width / 2),
                                   this.Height - chartSize.RightBottomMargins.Y + (int)legendSizeF.Height + LegendYMargin));
        }