Exemple #1
0
        /// <summary>
        /// The rectangle is based on the location of Point2d objects and this method writes the X and Y
        /// values of those objects to the array used in creating the interaction graphics rectangle
        /// </summary>
        protected void WriteToInteractionPointCoords()
        {
            if (_rectanglePointCoords == null)
            {
                _rectanglePointCoords = new Double[12]; /* new double[12];*/
            }

            List <Point> graphicPoints = new List <Point>();

            if (_planarSketch != null)
            {
                //In a part document, the sketch could be located anywhere in 3D space so this algorithm
                //provides a mechanism to make sure the interaction graphics gets drawn on the same plane
                //and in the same location as the sketch.
                graphicPoints.Add(_planarSketch.SketchToModelSpace(_upperRightPoint2d));
                graphicPoints.Add(_planarSketch.SketchToModelSpace(_upperLeftPoint2d));
                graphicPoints.Add(_planarSketch.SketchToModelSpace(_lowerLeftPoint2d));
                graphicPoints.Add(_planarSketch.SketchToModelSpace(_lowerRightPoint2d));

                _rectanglePointCoords[0] = graphicPoints[0].X;
                _rectanglePointCoords[1] = graphicPoints[0].Y;
                _rectanglePointCoords[2] = graphicPoints[0].Z;

                _rectanglePointCoords[3] = graphicPoints[1].X;
                _rectanglePointCoords[4] = graphicPoints[1].Y;
                _rectanglePointCoords[5] = graphicPoints[1].Z;

                _rectanglePointCoords[6] = graphicPoints[2].X;
                _rectanglePointCoords[7] = graphicPoints[2].Y;
                _rectanglePointCoords[8] = graphicPoints[2].Z;

                _rectanglePointCoords[9]  = graphicPoints[3].X;
                _rectanglePointCoords[10] = graphicPoints[3].Y;
                _rectanglePointCoords[11] = graphicPoints[3].Z;

                graphicPoints.Clear();
            }
            else if (_drawingSketch != null)
            {
                _rectanglePointCoords[0] = _upperRightPoint2d.X;
                _rectanglePointCoords[1] = _upperRightPoint2d.Y;
                _rectanglePointCoords[2] = 0.0;

                _rectanglePointCoords[3] = _upperLeftPoint2d.X;
                _rectanglePointCoords[4] = _upperLeftPoint2d.Y;
                _rectanglePointCoords[5] = 0.0;

                _rectanglePointCoords[6] = _lowerLeftPoint2d.X;
                _rectanglePointCoords[7] = _lowerLeftPoint2d.Y;
                _rectanglePointCoords[8] = 0.0;

                _rectanglePointCoords[9]  = _lowerRightPoint2d.X;
                _rectanglePointCoords[10] = _lowerRightPoint2d.Y;
                _rectanglePointCoords[11] = 0.0;
            }
        }