private void DragCSplineRightDerivation(MouseEventArgs e) { var cursorPositionY = CursorPositionY(e); _selectedEllipse.SetValue(Canvas.TopProperty, cursorPositionY); var yCursorPositionInWA = TransformCoordinates.PlotAreaToWorldAreaY(cursorPositionY + H_DIV_2, _plotArea, _worldArea); var xCursorPositionInWA = _selectedClampedSpline.Knots.Last() + SplineDrawer.DERIVATIVE_AUX_KNOT_DISTANCE; _selectedClampedSpline.Derivations[_selectedClampedSpline.Derivations.Count - 1] = MathOperations.DirectionOfLinearFunction(_selectedClampedSpline.Knots.Last(), _selectedClampedSpline.ControlPoints.Last(), xCursorPositionInWA, yCursorPositionInWA); var xCursorPosition = TransformCoordinates.WorldAreaToPlotAreaX(xCursorPositionInWA, _plotArea, _worldArea); _dragInfoLabel.WriteAndSetCoordinates(_selectedClampedSpline.Derivations[_selectedClampedSpline.Derivations.Count - 1], xCursorPositionInWA, yCursorPositionInWA, xCursorPosition + AVOID_CURSOR_X, cursorPositionY + H_DIV_2); _dragInfoLabel.Visibility = Visibility.Visible; _canvasUtilities.RefreshClampedSplineInCanvas(_selectedClampedSpline, canvas1, _engine); }
private void DragGBSplineLeftDerivation(MouseEventArgs e) { var yCursorPosition = CursorPositionY(e); _selectedEllipse.SetValue(Canvas.TopProperty, yCursorPosition); var degree = _selectedGlobalBSpline.Degree; var yCursorPositionInWA = TransformCoordinates.PlotAreaToWorldAreaY(yCursorPosition + H_DIV_2, _plotArea, _worldArea); var xCursorPositionInWA = _selectedGlobalBSpline.Knots[degree] - SplineDrawer.DERIVATIVE_AUX_KNOT_DISTANCE; var xCursorPosition = TransformCoordinates.WorldAreaToPlotAreaX(xCursorPositionInWA, _plotArea, _worldArea); _selectedGlobalBSpline.LeftDerivation = MathOperations.DirectionOfLinearFunction(xCursorPositionInWA, yCursorPositionInWA, _selectedGlobalBSpline.Knots[degree], _selectedGlobalBSpline.FunctionValues[0]); _dragInfoLabel.WriteAndSetCoordinates(_selectedGlobalBSpline.LeftDerivation, xCursorPositionInWA, yCursorPositionInWA, xCursorPosition + AVOID_CURSOR_X, yCursorPosition + H_DIV_2); _dragInfoLabel.Visibility = Visibility.Visible; _canvasUtilities.RefreshGlobalBSplineInCanvas(_selectedGlobalBSpline, canvas1, _engine); }
private void DragHSplineDerivation(MouseEventArgs e) { var yCursorPosition = CursorPositionY(e); _selectedEllipse.SetValue(Canvas.TopProperty, yCursorPosition); var yCursorPositionInWA = TransformCoordinates.PlotAreaToWorldAreaY(yCursorPosition, _plotArea, _worldArea); var xCursorPositionInWA = _selectedHermiteSpline.Knots[_changedPointIndex] - SplineDrawer.DERIVATIVE_AUX_KNOT_DISTANCE; _selectedHermiteSpline.Derivations[_changedPointIndex] = MathOperations.DirectionOfLinearFunction(xCursorPositionInWA, yCursorPositionInWA, _selectedHermiteSpline.Knots[_changedPointIndex], _selectedHermiteSpline.ControlPoints[_changedPointIndex]); var selectedKnotPositionInPA = TransformCoordinates.WorldAreaToPlotAreaX(_selectedHermiteSpline.Knots[_changedPointIndex], _plotArea, _worldArea); _dragInfoLabel.WriteAndSetCoordinates(_changedPointIndex, _selectedHermiteSpline.Derivations[_changedPointIndex], xCursorPositionInWA, yCursorPositionInWA, selectedKnotPositionInPA + AVOID_CURSOR_X, yCursorPosition + H_DIV_2); _dragInfoLabel.Visibility = Visibility.Visible; _canvasUtilities.RefreshHermiteSplineInCanvas(_selectedHermiteSpline, canvas1, _engine); }
private void DragHSpline(MouseEventArgs e) { // yCursorPosition = e.GetPosition(LayoutRoot).Y - _point.Y; // _lastClickedPositionX = e.GetPosition(LayoutRoot).X - _point.X; var cursorPosition = CursorPosition(e); var xCursorPositionInWA = TransformCoordinates.PlotAreaToWorldAreaX(cursorPosition.X + W_DIV_2, _plotArea, _worldArea); var yCursorPositionInWA = TransformCoordinates.PlotAreaToWorldAreaY(cursorPosition.Y + H_DIV_2, _plotArea, _worldArea); if (HermiteRegularCheckBox.IsChecked.Value) { if (cursorPosition.X <= _leftEllipseX + DEFAULT_REDRAWING_PRECISION) { cursorPosition.X = _leftEllipseX + DEFAULT_REDRAWING_PRECISION; // CanvasMyUtils.RemoveCPFromHermiteSpline(_redrawedHermiteSpline,_changedCPPos,canvas1,_engine); return; } else if (cursorPosition.X >= _rightEllipseX - DEFAULT_REDRAWING_PRECISION && _rightEllipseX != -1) { cursorPosition.X = _rightEllipseX - DEFAULT_REDRAWING_PRECISION; //CanvasMyUtils.RemoveCPFromHermiteSpline(_redrawedHermiteSpline, _changedCPPos, canvas1, _engine); return; } } _selectedEllipse.SetValue(Canvas.TopProperty, cursorPosition.Y); _selectedEllipse.SetValue(Canvas.LeftProperty, cursorPosition.X); // try //{ _selectedHermiteSpline.ControlPoints[_changedPointIndex] = yCursorPositionInWA; _selectedHermiteSpline.Knots[_changedPointIndex] = xCursorPositionInWA; //} //catch (Exception) { } // _selectedEllipse.SetValue(Canvas.TopProperty, e.GetPosition(LayoutRoot).controlPoints - _point.controlPoints); _dragInfoLabel.WriteAndSetCoordinates(_changedPointIndex, xCursorPositionInWA, yCursorPositionInWA, cursorPosition.X + AVOID_CURSOR_X, cursorPosition.Y + H_DIV_2); _dragInfoLabel.Visibility = Visibility.Visible; _canvasUtilities.RefreshHermiteSplineInCanvas(_selectedHermiteSpline, canvas1, _engine); //_canvasUtilities.TotalRefreshHermiteSplineInCanvas(_selectedHermiteSpline, canvas1, _engine); // } }
private void DragCSpline(MouseEventArgs e) { var cursorPositionY = CursorPositionY(e); _selectedEllipse.SetValue(Canvas.TopProperty, cursorPositionY); //_selectedEllipse.SetValue(Canvas.LeftProperty, _lastClickedPositionX); var yCursorPositionInWA = TransformCoordinates.PlotAreaToWorldAreaY(cursorPositionY + H_DIV_2, _plotArea, _worldArea); _selectedClampedSpline.ControlPoints[_changedPointIndex] = yCursorPositionInWA; var xCursorPositionInWA = _selectedClampedSpline.Knots[_changedPointIndex]; var xCursorPosition = TransformCoordinates.WorldAreaToPlotAreaX(xCursorPositionInWA, _plotArea, _worldArea); _dragInfoLabel.WriteAndSetCoordinates(_changedPointIndex, _selectedClampedSpline.Knots[_changedPointIndex], yCursorPositionInWA, xCursorPosition + AVOID_CURSOR_X, cursorPositionY + H_DIV_2); _dragInfoLabel.Visibility = Visibility.Visible; _canvasUtilities.RefreshClampedSplineInCanvas(_selectedClampedSpline, canvas1, _engine); // } }
private void DragGBSpline(MouseEventArgs e) { var yCursorPosition = CursorPositionY(e); _selectedEllipse.SetValue(Canvas.TopProperty, yCursorPosition); //try //{ var yCursorPositionInWA = TransformCoordinates.PlotAreaToWorldAreaY(yCursorPosition + H_DIV_2, _plotArea, _worldArea); _selectedGlobalBSpline.FunctionValues[_changedPointIndex] = yCursorPositionInWA; //} //catch (Exception) { } // _selectedEllipse.SetValue(Canvas.TopProperty, e.GetPosition(LayoutRoot).controlPoints - _point.controlPoints); var selectedKnotPositionInPA = TransformCoordinates.WorldAreaToPlotAreaX(_selectedGlobalBSpline.Knots[_changedPointIndex], _plotArea, _worldArea); _dragInfoLabel.WriteAndSetCoordinates(_changedPointIndex, _selectedGlobalBSpline.Knots[_changedPointIndex] + _selectedGlobalBSpline.Degree, yCursorPositionInWA, selectedKnotPositionInPA + AVOID_CURSOR_X, yCursorPosition + H_DIV_2); _dragInfoLabel.Visibility = Visibility.Visible; _canvasUtilities.RefreshGlobalBSplineInCanvas(_selectedGlobalBSpline, canvas1, _engine); // } }
public new Tuple <double, double, double, double> Range_MinX_MaxX_MinY_MaxY(PlotArea plotArea, WorldArea worldArea) { double minX = double.MaxValue; double maxX = double.MinValue; double minY = double.MaxValue; double maxY = double.MinValue; for (int i = 0; i < LinesOfSpline.Count; i++) { var X1 = TransformCoordinates.PlotAreaToWorldAreaX(LinesOfSpline[i].X1, plotArea, worldArea); var X2 = TransformCoordinates.PlotAreaToWorldAreaX(LinesOfSpline[i].X2, plotArea, worldArea); var Y1 = TransformCoordinates.PlotAreaToWorldAreaY(LinesOfSpline[i].Y1, plotArea, worldArea); var Y2 = TransformCoordinates.PlotAreaToWorldAreaY(LinesOfSpline[i].Y2, plotArea, worldArea); if (X1 < minX) { minX = X1; } if (X2 > maxX) { maxX = X2; } if (Y1 < minY) { minY = Y1; } if (Y2 > maxY) { maxY = Y2; } } //for (int i = 0; i < DragEllipses.Count; i++) //{ // var X = TransformCoordinates.PlotAreaToWorldAreaX(DragEllipses[i]., plotArea, worldArea); // var Y = TransformCoordinates.PlotAreaToWorldAreaY(DragEllipses[i].X2, plotArea, worldArea); //} return(Tuple.Create(minX, maxX, minY, maxY)); }
private void DragBSpline(MouseEventArgs e) { if (!UniformBSpline_CheckBox.IsChecked.Value) { // _lastClickedPositionX = e.GetPosition(LayoutRoot).X - _point.X; // yCursorPosition = e.GetPosition(LayoutRoot).Y - _point.Y; var cursorPosition = CursorPosition(e); var xCursorPositionInWA = TransformCoordinates.PlotAreaToWorldAreaX(cursorPosition.X + W_DIV_2, _plotArea, _worldArea); var yCursorPositionInWA = TransformCoordinates.PlotAreaToWorldAreaY(cursorPosition.Y + H_DIV_2, _plotArea, _worldArea); if (cursorPosition.X <= _leftEllipseX + DEFAULT_REDRAWING_PRECISION) { cursorPosition.X = _leftEllipseX + DEFAULT_REDRAWING_PRECISION; // CanvasMyUtils.RemoveCPFromHermiteSpline(_redrawedHermiteSpline,_changedCPPos,canvas1,_engine); return; } // else if (cursorPosition.X >= _rightEllipseX - DEFAULT_REDRAWING_PRECISION && _rightEllipseX != -1) else if (cursorPosition.X >= _rightEllipseX - DEFAULT_REDRAWING_PRECISION)// && _stupidFastHackToResolveBugWithBSplineWhenLastEllipseIsDragged) { cursorPosition.X = _rightEllipseX - DEFAULT_REDRAWING_PRECISION; //CanvasMyUtils.RemoveCPFromHermiteSpline(_redrawedHermiteSpline, _changedCPPos, canvas1, _engine); return; } _selectedEllipse.SetValue(Canvas.LeftProperty, cursorPosition.X); _selectedEllipse.SetValue(Canvas.TopProperty, cursorPosition.Y); //try //{ _selectedBSpline.Knots[_changedKnotPos] = xCursorPositionInWA; _selectedBSpline.ControlPoints[_changedPointIndex] = yCursorPositionInWA; //if (_selectedBSpline.Knots[_changedKnotPos] >= _selectedBSpline.Knots[_changedKnotPos + 1]) //{ // var swap = _selectedBSpline.Knots[_changedKnotPos + 1]; // _selectedBSpline.Knots[_changedKnotPos + 1] = _selectedBSpline.Knots[_changedKnotPos]; // _selectedBSpline.Knots[_changedKnotPos] = swap; // var idx= _selectedBSpline.DragEllipses.IndexOf(_selectedEllipse as Ellipse); // var swapEl = _selectedBSpline.DragEllipses[idx + 1]; // _selectedBSpline.DragEllipses[idx + 1] = _selectedBSpline.DragEllipses[idx]; // _selectedBSpline.DragEllipses[idx] = swapEl; //} //} //catch (Exception) { } _dragInfoLabel.WriteAndSetCoordinates(_changedPointIndex, xCursorPositionInWA, yCursorPositionInWA, cursorPosition.X + AVOID_CURSOR_X, cursorPosition.Y + H_DIV_2); _dragInfoLabel.Visibility = Visibility.Visible; //CanvasMyUtils.OptimizedRefreshBSplineInCanvas(_selectedBSpline, _changedCPPos, canvas1, _engine, false); _canvasUtilities.RefreshBSplineInCanvas(_selectedBSpline, canvas1, _engine); } else { // yCursorPositionInWA = TransformCoordinates.PlotAreaToWorldAreaY(yCursorPosition + H_DIV_2, _plotArea, _worldArea); //yCursorPosition = e.GetPosition(LayoutRoot).Y - _point.Y; var yCursorPosition = CursorPositionY(e); _selectedEllipse.SetValue(Canvas.TopProperty, yCursorPosition); //try //{ var yCursorPositionInWA = TransformCoordinates.PlotAreaToWorldAreaY(yCursorPosition + H_DIV_2, _plotArea, _worldArea); _selectedBSpline.ControlPoints[_changedPointIndex] = yCursorPositionInWA; //} //catch (Exception) { } var selectedKnotPositionInPA = TransformCoordinates.WorldAreaToPlotAreaX(_selectedBSpline.Knots[_changedKnotPos], _plotArea, _worldArea); _dragInfoLabel.WriteAndSetCoordinates(_changedPointIndex, _selectedBSpline.Knots[_changedKnotPos], yCursorPositionInWA, selectedKnotPositionInPA + AVOID_CURSOR_X, yCursorPosition + H_DIV_2); _dragInfoLabel.Visibility = Visibility.Visible; _canvasUtilities.RefreshBSplineInCanvas(_selectedBSpline, canvas1, _engine); } }