Ejemplo n.º 1
0
        private void DefaultCanvas()
        {
            Line            horizontal      = new Line();
            Line            vertical        = new Line();
            TextBlock       min_X_TextBlock = new TextBlock();
            TextBlock       max_X_TextBlock = new TextBlock();
            TextBlock       max_Y_TextBlock = new TextBlock();
            TextBlock       min_Y_TextBlock = new TextBlock();
            SolidColorBrush color           = new SolidColorBrush();

            color.Color = Color.FromArgb(255, 170, 170, 0);

            horizontal.X1 = TransformCoordinates.WorldAreaToPlotAreaX(_worldArea.XMin, _plotArea, _worldArea);
            horizontal.Y1 = _waZeroPointInPACoordinates.Y;
            horizontal.X2 = TransformCoordinates.WorldAreaToPlotAreaX(_worldArea.XMax, _plotArea, _worldArea);
            horizontal.Y2 = _waZeroPointInPACoordinates.Y;

            vertical.X1 = _waZeroPointInPACoordinates.X;
            vertical.Y1 = TransformCoordinates.WorldAreaToPlotAreaY(_worldArea.YMin, _plotArea, _worldArea);
            vertical.X2 = _waZeroPointInPACoordinates.X;
            vertical.Y2 = TransformCoordinates.WorldAreaToPlotAreaY(_worldArea.YMax, _plotArea, _worldArea);


            horizontal.StrokeThickness = 1;
            vertical.StrokeThickness   = 1;
            horizontal.Stroke          = color;
            vertical.Stroke            = color;
            Canvas.SetZIndex(horizontal, 1);

            min_X_TextBlock.Text       = _worldArea.XMin.ToString();
            max_X_TextBlock.Text       = _worldArea.XMax.ToString();
            max_Y_TextBlock.Text       = _worldArea.YMax.ToString();
            min_Y_TextBlock.Text       = _worldArea.YMin.ToString();
            min_X_TextBlock.Height     = 14;
            max_X_TextBlock.Height     = 14;
            max_Y_TextBlock.Height     = 14;
            min_Y_TextBlock.Height     = 14;
            min_X_TextBlock.Width      = 30;
            max_X_TextBlock.Width      = 30;
            max_Y_TextBlock.Width      = 30;
            min_Y_TextBlock.Width      = 30;
            min_X_TextBlock.Foreground = color;
            max_X_TextBlock.Foreground = color;
            max_Y_TextBlock.Foreground = color;
            min_Y_TextBlock.Foreground = color;
            Canvas.SetLeft(min_X_TextBlock, _plotArea.XMin + 10);
            Canvas.SetLeft(max_X_TextBlock, _plotArea.XMax - 30);
            Canvas.SetLeft(max_Y_TextBlock, _plotArea.XMax / 2 + 12);
            Canvas.SetLeft(min_Y_TextBlock, _plotArea.XMax / 2 + 12);
            Canvas.SetTop(min_X_TextBlock, _plotArea.YMax / 2 - 23);
            Canvas.SetTop(max_X_TextBlock, _plotArea.YMax / 2 - 23);
            Canvas.SetTop(max_Y_TextBlock, _plotArea.YMin + 10);
            Canvas.SetTop(min_Y_TextBlock, _plotArea.YMax - 20);
            Canvas.SetZIndex(horizontal, 1);
            Canvas.SetZIndex(horizontal, 1);
            Canvas.SetZIndex(horizontal, 1);
            Canvas.SetZIndex(horizontal, 1);

            _dragInfoLabel            = new DragInfoLabel(CANVAS_TEXT_COLOR);
            _dragInfoLabel.Visibility = Visibility.Collapsed;

            canvas1.Children.Add(_dragInfoLabel);
            canvas1.Children.Add(horizontal);
            canvas1.Children.Add(vertical);
            canvas1.Children.Add(min_X_TextBlock);
            canvas1.Children.Add(min_Y_TextBlock);
            canvas1.Children.Add(max_X_TextBlock);
            canvas1.Children.Add(max_Y_TextBlock);
        }
Ejemplo n.º 2
0
        // private object _selectedSpline;
        //private FunctionComboBoxViewModel functionComboBoxViewModel;
        /**********************/

        public MainPage()
        {
            InitializeComponent();
            this.DrawPrecision      = DEFAULT_DRAW_PRECISION;
            this.RedrawingPrecision = DEFAULT_REDRAWING_PRECISION;
            //functionComboBoxViewModel = new FunctionComboBoxViewModel();
            _plotArea  = new PlotArea(PLOT_AREA_MIN_X, PLOT_AREA_MAX_X, PLOT_AREA_MIN_Y, PLOT_AREA_MAX_Y);
            _worldArea = new WorldArea(WORLD_AREA_DEFAULT_MIN_XY, WORLD_AREA_DEFAULT_MAX_XY, WORLD_AREA_DEFAULT_MIN_XY, WORLD_AREA_DEFAULT_MAX_XY);
            // _pa.x_min = 0; _pa.x_max = 775; _pa.y_min = 0; _pa.y_max = 575; _wa.x_min = -10; _wa.x_max = 10; _wa.y_min = -10; _wa.y_max = 10;
            _engine = new SplineDrawer(canvas1, _plotArea, _worldArea, DrawPrecision);
            //_auxiliaryEngine = new AuxiliaryDrawer(canvas1);
            _isMoving = false;
            _waZeroPointInPACoordinates = TransformCoordinates.WorldAreaToPlotArea(0, 0, _plotArea, _worldArea);

            _parser = new Parser();
            InitSplineLists();
            _canvasUtilities = new CanvasUtilities(_plotArea, _worldArea);

            _openFileDialog = new OpenFileDialog();
            _saveFileDialog = new SaveFileDialog();
            InitColors();
            FunctionSelect_ComboBox.SelectedIndex = 0;
            _dragInfoLabel = new DragInfoLabel(CANVAS_TEXT_COLOR);
            //_dragInfoLabel.Margin = new Thickness(20, 30, 0, 0);
            //_dragInfoLabel.Content = "SDAS";
            canvas1.Children.Add(_dragInfoLabel);
            _dragInfoLabel.Visibility = Visibility.Collapsed;
            VersionLabel.Content      = Version();

            try
            {
                this._saveFileDialog.DefaultExt  = ".spline";
                this._openFileDialog.Filter      = "Spline Files|*.spline";
                this._openFileDialog.FilterIndex = 2;
                this._saveFileDialog.Filter      = "Spline Files|*.spline";
                this._saveFileDialog.FilterIndex = 2;
                // this._saveFileDialog.DefaultFileName = "newSplines.spline";
            }
            catch (Exception)
            {
            }
            DefaultCanvas();
            //var s = BSpline.ServiceKnots(new double[] {2,3.75,5},3,true);

            // _engine.BellFunctionOfDegree3(0, 1, 2, 3, 4);
            // _engine.BSplineBasisFunctionsOfDegree3(0, 1, 2, 3, 4, 5, 6, 7);
            //_engine.BSplineBasisFunction(new double[]{0, 1, 2, 3, 4, 5, 6, 7});
            // double[] knots = new double[] {-1,1,2,2.5, 3, 4, 5, 6};
            // Tuple<double[][], double[]> A = GlobalBSplineMatrix(3, knots);
            // double[][] B = A.Item1; //MathMyUtils.MatrixInvert(A.Item1);
            // //double[][] F = MathMyUtils.MatrixInvert(B);
            //// double[][] C = MathMyUtils.TransposeMatrix(B);

            //// //double[][] D = MathMyUtils.MatrixInvert(MathMyUtils.MultiplyMatrices(C, B));
            //// //double[][] E = MathMyUtils.MultiplyMatrices(B, C);
            ////// double[][] YMatrix = MathMyUtils.ArrayToMatrix(knotsFunctionValues);
            // for (int i = 0; i < B.Length; i++)
            // {
            //     String s = "";
            //     for (int j = 0; j < B[i].Length; j++)
            //     {

            //         s += B[i][j].ToString() + " | ";
            //     }
            //     System.Diagnostics.Debug.WriteLine(s);
            // }
        }
Ejemplo n.º 3
0
 private void resetDragInfoLabel()
 {
     _dragInfoLabel            = new DragInfoLabel(CANVAS_TEXT_COLOR);
     _dragInfoLabel.Visibility = Visibility.Collapsed;
     canvas1.Children.Add(_dragInfoLabel);
 }