Example #1
0
 public void AddNormalLine(Layer aLayer)
 {
     foreach (var item in this.STLMeasurent_Objects)
     {
         if (item is STLMeasuringTool_CMM)
         {
             ISTLMeasurement_NeedNormals aSTLMeasurement_CMM = item as ISTLMeasurement_NeedNormals;
             for (int i = 0; i < item.MeasurePoints.Count; i++)
             {
                 aLayer.AddEntity(new Line(item.MeasurePoints[i], item.MeasurePoints[i] + aSTLMeasurement_CMM.MeasurePointNormals[i]));
             }
         }
     }
 }
Example #2
0
        protected virtual void GanerateGridLayer(Color gridColor1, Color gridColor2, Color graduationColor)
        {
            //清空格線
            this.gridLayer       = new Layer("Grid");
            this.graduationLayer = new Layer("Graduation");

            //計算格線範圍
            CalculateViewBoundary();

            //計算格線密度
            CalculateGridPitch();

            #region 計算格線
            //設定範圍
            Double   X1, X2, Y1, Y2;
            PointD[] gridBoundary = new PointD[2];
            if (this.GraduationOutside == false)
            {
                gridBoundary[0] = viewBoundary[0];
                gridBoundary[1] = viewBoundary[1];
            }
            else
            {
                double xSpace = (viewBoundary[1].X - viewBoundary[0].X) / this.openGLWindow.Width * GraduationHeight;
                double ySpace = (viewBoundary[1].Y - viewBoundary[0].Y) / this.openGLWindow.Height * GraduationHeight;
                gridBoundary[0] = viewBoundary[0] + new PointD(2.0 * xSpace, ySpace, 0);
                gridBoundary[1] = viewBoundary[1] - new PointD(xSpace, ySpace, 0);
            }
            //移動格線位置至內容的最後方,避免格線擋住顯示內容
            if (gridBoundary != null)
            {
                if (geometryBoundary[0] != null)
                {
                    gridBoundary[0].Z = geometryBoundary[0].Z - geometrySize.Z * 0.05;
                    gridBoundary[1].Z = geometryBoundary[0].Z - geometrySize.Z * 0.05;
                }
            }


            X1 = System.Math.Ceiling(gridBoundary[0].X / xGridPitch) * xGridPitch;
            X2 = System.Math.Floor(gridBoundary[1].X / xGridPitch) * xGridPitch;
            Y1 = System.Math.Ceiling(gridBoundary[0].Y / yGridPitch) * yGridPitch;
            Y2 = System.Math.Floor(gridBoundary[1].Y / yGridPitch) * yGridPitch;

            String decFormat = "G4";

            //文字、格線
            Line tLine;
            for (double x = X1; x <= X2; x += xGridPitch)
            {
                tLine = new Line(new PointD(x, gridBoundary[0].Y, gridBoundary[0].Z),
                                 new PointD(x, gridBoundary[1].Y, gridBoundary[0].Z));
                //粗格線
                if (Abs(x % (xGridPitch * 5.0)) < (xGridPitch * 0.5) || Abs(x % (xGridPitch * 5.0)) > (xGridPitch * 4.5))
                {
                    tLine.Color     = gridColor1;
                    tLine.LineType  = LineType.Solid;
                    tLine.LineWidth = 0.5f;
                    //座標文字
                    if (this.GraduationOutside == false)
                    {
                        graduationLayer.AddEntity(new Text(x.ToString(decFormat),
                                                           new PointD(x + (gridBoundary[1].X - gridBoundary[0].X) / this.OpenGLWindow.Width * 5.0,
                                                                      gridBoundary[0].Y + (gridBoundary[1].Y - gridBoundary[0].Y) / this.OpenGLWindow.Height * 5.0,
                                                                      gridBoundary[0].Z),
                                                           graduationColor));
                    }
                    else
                    {
                        graduationLayer.AddEntity(new Text(x.ToString(decFormat),
                                                           new PointD(x,
                                                                      viewBoundary[0].Y + (viewBoundary[1].Y - viewBoundary[0].Y) / this.OpenGLWindow.Height * 5.0,
                                                                      gridBoundary[0].Z),
                                                           graduationColor));
                    }
                }
                //細格線
                else
                {
                    tLine.Color     = gridColor2;
                    tLine.LineType  = LineType.Solid;
                    tLine.LineWidth = 0.3f;
                }
                //加入格線
                gridLayer.AddEntity(tLine);
            }
            for (double y = Y1; y <= Y2; y += yGridPitch)
            {
                //格線
                tLine = new Line(new PointD(gridBoundary[0].X, y, gridBoundary[0].Z),
                                 new PointD(gridBoundary[1].X, y, gridBoundary[0].Z));
                //粗格線
                if (Abs(y % (yGridPitch * 5.0)) < (yGridPitch * 0.5) || Abs(y % (yGridPitch * 5.0)) > (yGridPitch * 4.5))
                {
                    tLine.Color     = gridColor1;
                    tLine.LineType  = LineType.Solid;
                    tLine.LineWidth = 0.5f;
                    //座標文字
                    if (this.GraduationOutside == false)
                    {
                        graduationLayer.AddEntity(new Text(y.ToString(decFormat),
                                                           new PointD(gridBoundary[0].X + (gridBoundary[1].X - gridBoundary[0].X) / this.OpenGLWindow.Width * 5.0,
                                                                      y + (gridBoundary[1].Y - gridBoundary[0].Y) / this.OpenGLWindow.Height * 5.0,
                                                                      gridBoundary[0].Z),
                                                           graduationColor));
                    }
                    else
                    {
                        graduationLayer.AddEntity(new Text(y.ToString(decFormat),
                                                           new PointD(viewBoundary[0].X + (viewBoundary[1].X - viewBoundary[0].X) / this.OpenGLWindow.Width * 5.0,
                                                                      y,
                                                                      gridBoundary[0].Z),
                                                           graduationColor));
                    }
                }
                //細格線
                else
                {
                    tLine.Color     = gridColor2;
                    tLine.LineType  = LineType.Solid;
                    tLine.LineWidth = 0.3f;
                }
                //加入格線
                gridLayer.AddEntity(tLine);
            }

            //邊框
            //下
            tLine = new Line(new PointD(gridBoundary[0].X,
                                        gridBoundary[0].Y,
                                        gridBoundary[0].Z),
                             new PointD(gridBoundary[1].X,
                                        gridBoundary[0].Y,
                                        gridBoundary[1].Z));
            tLine.Color     = gridColor1;
            tLine.LineType  = LineType.Solid;
            tLine.LineWidth = 0.5f;
            gridLayer.AddEntity(tLine);
            //右
            tLine = new Line(new PointD(gridBoundary[1].X,
                                        gridBoundary[0].Y,
                                        gridBoundary[1].Z),
                             new PointD(gridBoundary[1].X,
                                        gridBoundary[1].Y,
                                        gridBoundary[1].Z));
            tLine.Color     = gridColor1;
            tLine.LineType  = LineType.Solid;
            tLine.LineWidth = 0.5f;
            gridLayer.AddEntity(tLine);
            //上
            tLine = new Line(new PointD(gridBoundary[1].X,
                                        gridBoundary[1].Y,
                                        gridBoundary[1].Z),
                             new PointD(gridBoundary[0].X,
                                        gridBoundary[1].Y,
                                        gridBoundary[0].Z));
            tLine.Color     = gridColor1;
            tLine.LineType  = LineType.Solid;
            tLine.LineWidth = 0.5f;
            gridLayer.AddEntity(tLine);
            //左
            tLine = new Line(new PointD(gridBoundary[0].X,
                                        gridBoundary[1].Y,
                                        gridBoundary[0].Z),
                             new PointD(gridBoundary[0].X,
                                        gridBoundary[0].Y,
                                        gridBoundary[0].Z));
            tLine.Color     = gridColor1;
            tLine.LineType  = LineType.Solid;
            tLine.LineWidth = 0.5f;
            gridLayer.AddEntity(tLine);
            #endregion 計算格線
        }