Ejemplo n.º 1
0
        public override void OnStartEvent()
        {
            LineStyle lineStyle = new LineStyle();
            lineStyle.SetPatternStyle((int)EnumLinePattern.LP_DashedLine);
            lineStyle.SetColor(100, 0, 100);

            tempLineNode.SetLineStyle(lineStyle);

            this.ShowTempNode(tempLineNode);
            GetRenderer().RequestDraw(1);
        }
Ejemplo n.º 2
0
        public override void OnStartEvent()
        {
            LineStyle lineStyle = new LineStyle();

            lineStyle.SetPatternStyle((int)EnumLinePattern.LP_DashedLine);
            lineStyle.SetColor(100, 0, 100);

            tempLineNode.SetLineStyle(lineStyle);

            this.ShowTempNode(tempLineNode);
            GetRenderer().RequestDraw(1);
        }
Ejemplo n.º 3
0
        public DrawLineEditor(AddLineEvent callback)
        {
            SetId("AD::DrawLine");
            OnAddLineEvent = callback;

            LineStyle lineStyle = new LineStyle();

            lineStyle.SetPatternStyle((int)EnumLinePattern.LP_DashedLine);
            lineStyle.SetColor(255, 0, 100);
            lineStyle.SetLineWidth(2);

            tempLineNode.SetLineStyle(lineStyle);
        }
        public override bool Run(FeatureContext context)
        {
            TopoShape shape = GlobalInstance.BrepTools.MakeArc(Vector3.ZERO, 100, 10, 180, Vector3.UNIT_Z);
            SceneNode node  = context.ShowGeometry(shape);
            LineStyle ls    = new LineStyle();

            ls.SetLineWidth(2);
            ls.SetColor(0, 255, 0);
            ls.SetPatternStyle((int)EnumLinePattern.LP_DashedLine);
            node.SetLineStyle(ls);

            return(true);
        }
Ejemplo n.º 5
0
        private void queryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SelectedShapeQuery context = new SelectedShapeQuery();

            renderView.QuerySelection(context);

            TopoShape subShape = context.GetSubGeometry();
            SceneNode topoNode = context.GetSubNode();


            if (subShape != null)
            {
                Console.WriteLine(subShape.GetShapeType());
            }

            Matrix4 shapeTransform = topoNode.GetTransform();
            //surface
            GeomSurface surface = new GeomSurface();

            if (surface.Initialize(subShape))
            {
                List <Vector3> ptVecList  = new List <Vector3>();
                List <Vector3> norVecList = new List <Vector3>();
                Console.Write("surface");
                //double firstU = surface.FirstUParameter();
                //double lastU = surface.LastUParameter();
                //double firstV = surface.FirstVParameter();
                //double lastV = surface.LastVParameter();
                double firstU  = surface.FirstUParameter();
                double lastU   = surface.LastUParameter();
                double firstV  = surface.FirstVParameter();
                double lastV   = surface.LastVParameter();
                double offSetU = lastU - firstU;
                double offSetV = lastV - firstV;

                double stepU   = 0.10;
                double stepV   = 10;
                int    stepNoU = (int)(offSetU / stepU);
                int    stepNoV = (int)(offSetV / stepV);
                for (int v_i = 3; v_i < stepNoV - 5; v_i++)
                {
                    for (int u_i = 0; u_i < stepNoU; u_i++)
                    {
                        double tempV = firstV + stepV * v_i;
                        double tempU = firstU + stepU * (v_i % 2 == 0 ? u_i : stepNoU - u_i);
                        //double tempV = firstV + stepV * (u_i % 2 == 0 ? v_i : stepNoV - v_i);
                        Vector3 ptVec_1     = surface.Value(tempU, tempV);
                        Vector3 ptVec       = shapeTransform.Transform(ptVec_1);
                        Vector3 normalVec_1 = surface.GetNormal(tempU, tempV);
                        //Vector3 normalVec =shapeTransform.Transform(normalVec_1);//matrix3  3*3
                        Vector3 normalVec = RotateDirVector(shapeTransform, normalVec_1);
                        ptVecList.Add(ptVec);
                        norVecList.Add(normalVec);
                        pathPqList.Add(QuaternionFromTo(new Vector3(-1, 0, 0), normalVec, ptVec));
                        ShowStatusMessage("path pts No: " + pathPqList.Count);

                        //LineNode tempLineNode = new LineNode();
                        //LineStyle lineStyle = new LineStyle();
                        //lineStyle.SetPatternStyle((int)EnumLinePattern.LP_DashedLine);
                        //lineStyle.SetColor(100, 0, 100);
                        //tempLineNode.SetLineStyle(lineStyle);
                        //tempLineNode.Set(ptVec, ptVec + normalVec);
                        //tempLineNode.SetVisible(true);
                        //renderView.SceneManager.AddNode(tempLineNode);
                        //renderView.RequestDraw();
                    }
                }

                //for (int u_i = 0; u_i < stepNoU; u_i++)
                //{
                //    for (int v_i = 0; v_i < stepNoV-0; v_i++)
                //    {

                //        double tempU = firstU + stepU * u_i;
                //        double tempV = firstV + stepV * (u_i % 2 == 0 ? v_i : stepNoV - v_i);

                //        Vector3 ptVec =shapeTransform.Transform(surface.Value(tempU,tempV ));
                //        Vector3 normalVec = surface.GetNormal(tempU,tempV);
                //        ptVecList.Add(ptVec);
                //        norVecList.Add(normalVec);
                //        pathPqList.Add(QuaternionFromTo(new Vector3(-1, 0, 0), normalVec, ptVec));
                //    }
                //}
                int a = 0;
            }
            //curve
            GeomCurve curve = new GeomCurve();

            if (curve.Initialize(subShape))
            {
                Vector3 startPt = shapeTransform.Transform(curve.D0(curve.FirstParameter()));
                //Vector3 startPt_ = shapeTransform.Transform(startPt);
                Vector3 pt1   = curve.GetStartPoint();
                Vector3 endPt = shapeTransform.Transform(curve.D0(curve.LastParameter()));
                Vector3 pt2   = curve.GetEndPoint();
                switch ((EnumCurveType)curve.GetCurveType())
                {
                case EnumCurveType.CurveType_OtherCurve:
                    Console.Write("other");
                    break;

                case EnumCurveType.CurveType_BSplineCurve:
                    break;

                case EnumCurveType.CurveType_BezierCurve:
                    break;

                case EnumCurveType.CurveType_Parabola:
                    break;

                case EnumCurveType.CurveType_Hyperbola:
                    break;

                case EnumCurveType.CurveType_Ellipse:
                    break;

                case EnumCurveType.CurveType_Circle:
                    Console.Write("Circle");
                    break;

                case EnumCurveType.CurveType_Line:
                    Console.Write("Line");

                    //path
                    double[] startPt_ = new double[3] {
                        startPt.X, startPt.Y, startPt.Z
                    };
                    double[] endPt_ = new double[3] {
                        endPt.X, endPt.Y, endPt.Z
                    };
                    Path_U.Interpolation(startPt_, endPt_, 0.01, ref pathPtList);
                    //show pick result
                    LineNode  tempLineNode = new LineNode();
                    LineStyle lineStyle    = new LineStyle();
                    lineStyle.SetPatternStyle((int)EnumLinePattern.LP_DashedLine);
                    lineStyle.SetColor(100, 0, 100);
                    tempLineNode.SetLineStyle(lineStyle);
                    tempLineNode.Set(new Vector3(startPt.X + 0.1, startPt.Y + 10, startPt.Z + 0.1), endPt);
                    tempLineNode.SetVisible(true);
                    renderView.SceneManager.AddNode(tempLineNode);
                    renderView.RequestDraw();
                    break;

                default:
                    break;
                }



                ElementId id = context.GetNodeId();
                MessageBox.Show(id.AsInt().ToString());
                //...
            }
        }
Ejemplo n.º 6
0
        private void customGridToolStripMenuItem_Click(object sender, EventArgs e)
        {
            WorkingPlane wp = renderView.Renderer.GetWorkingPlane();
            GridNode gridNode = new GridNode();
            Vector3 modelSize = renderView.SceneManager.GetBBox().Size();
            Vector2 cellSize = gridNode.GetCellSize();
            int nCountX = (int)(modelSize.X / cellSize.X + 0.5f) + 1;
            int nCountY = (int)(modelSize.Y / cellSize.Y + 0.5f) + 1;
            if (nCountX < 2)
                nCountX = 2;
            if (nCountY < 2)
                nCountY = 2;

            gridNode.SetCellCount(nCountX, nCountY);

            LineStyle lineStyle = new LineStyle();
            lineStyle.SetColor(new ColorValue(1.0f, 1.0f, 1.0f));
            lineStyle.SetPatternStyle((int)EnumLinePattern.LP_DotLine);
            {
                //Z
                LineNode lineNode = new LineNode();
                lineNode.Set(new Vector3(0, 0, -1000), new Vector3(0, 0, 1000));
                lineNode.SetLineStyle(lineStyle);
                gridNode.AddNode(lineNode);
            }
            {
                //X
                LineNode lineNode = new LineNode();
                lineNode.Set(new Vector3(-1000, 0, 0), new Vector3(1000, 0, 0));
                lineNode.SetLineStyle(lineStyle);
                gridNode.AddNode(lineNode);
            }
            {
                //Y
                LineNode lineNode = new LineNode();
                lineNode.Set(new Vector3(0, -1000, 0), new Vector3(0, 1000, 0));
                lineNode.SetLineStyle(lineStyle);
                gridNode.AddNode(lineNode);
            }

            lineStyle = new LineStyle();
            lineStyle.SetColor(new ColorValue(0.9f, 0.9f, 0.9f));
            gridNode.SetLineStyle(lineStyle);
            for (int ii = -1; ii <= nCountX; ++ii)
            {
                if (ii == 0)
                    continue;

                LineNode lineNode = new LineNode();
                lineNode.Set(new Vector3(ii * cellSize.X, cellSize.Y, 0), new Vector3(ii * cellSize.X, -nCountY * cellSize.Y, 0));

                gridNode.AddNode(lineNode);
            }
            for (int ii = -1; ii <= nCountY; ++ii)
            {
                if (ii == 0)
                    continue;

                LineNode lineNode = new LineNode();
                lineNode.Set(new Vector3(-cellSize.X, -ii * cellSize.Y, 0), new Vector3(nCountX * cellSize.X, -ii * cellSize.Y, 0));
                gridNode.AddNode(lineNode);
            }
            gridNode.Update();
            wp.SetGridNode(gridNode);



            {
                AxesWidget xwh = new AxesWidget();
                xwh.EnableLeftHandCS();
                xwh.SetArrowText((int)EnumAxesDirection.Axes_Y, "w");
                xwh.SetArrowText((int)EnumAxesDirection.Axes_Z, "h");
                ScreenWidget coordWidget = new ScreenWidget();
                coordWidget.SetNode(xwh);
                coordWidget.SetWidgetPosition((int)EnumWidgetPosition.WP_BottomLeft);
                renderView.Renderer.AddWidgetNode(coordWidget);
            }
            {
                AxesWidget yz = new AxesWidget();
                yz.ShowArrow((int)EnumAxesDirection.Axes_X, false);
                ScreenWidget coordWidget = new ScreenWidget();
                coordWidget.SetNode(yz);
                coordWidget.SetWidgetPosition((int)EnumWidgetPosition.WP_BottomRight);
                renderView.Renderer.AddWidgetNode(coordWidget);
            }

            renderView.ShowCoordinateAxis(false);

            renderView.RequestDraw();
        }
Ejemplo n.º 7
0
        public void UpdateWorkingGrid()
        {
            m_RenderView.SceneManager.ComputeBBox();

            WorkingPlane wp = m_RenderView.Renderer.GetWorkingPlane();

            GridNode gridNode  = new GridNode();
            Vector3  modelSize = m_RenderView.SceneManager.GetBBox().Size();
            Vector2  cellSize  = gridNode.GetCellSize();
            int      nCountX   = (int)(modelSize.X / cellSize.X + 0.5f) + 1;
            int      nCountY   = (int)(modelSize.Y / cellSize.Y + 0.5f) + 1;

            if (nCountX < 2)
            {
                nCountX = 2;
            }
            if (nCountY < 2)
            {
                nCountY = 2;
            }

            gridNode.SetCellCount(nCountX, nCountY);

            LineStyle lineStyle = new LineStyle();

            lineStyle.SetColor(new ColorValue(1.0f, 1.0f, 1.0f));
            lineStyle.SetPatternStyle((int)EnumLinePattern.LP_DotLine);
            {
                //Z
                LineNode lineNode = new LineNode();
                lineNode.Set(new Vector3(0, 0, -1000), new Vector3(0, 0, 1000));
                lineNode.SetLineStyle(lineStyle);
                gridNode.AddNode(lineNode);
            }
            {
                //X
                LineNode lineNode = new LineNode();
                lineNode.Set(new Vector3(-1000, 0, 0), new Vector3(1000, 0, 0));
                lineNode.SetLineStyle(lineStyle);
                gridNode.AddNode(lineNode);
            }
            {
                //Y
                LineNode lineNode = new LineNode();
                lineNode.Set(new Vector3(0, -1000, 0), new Vector3(0, 1000, 0));
                lineNode.SetLineStyle(lineStyle);
                gridNode.AddNode(lineNode);
            }

            lineStyle = new LineStyle();
            lineStyle.SetColor(new ColorValue(0.9f, 0.9f, 0.9f));
            gridNode.SetLineStyle(lineStyle);
            for (int ii = -1; ii <= nCountX; ++ii)
            {
                if (ii == 0)
                {
                    continue;
                }

                LineNode lineNode = new LineNode();
                lineNode.Set(new Vector3(ii * cellSize.X, cellSize.Y, 0), new Vector3(ii * cellSize.X, -nCountY * cellSize.Y, 0));

                gridNode.AddNode(lineNode);
            }
            for (int ii = -1; ii <= nCountY; ++ii)
            {
                if (ii == 0)
                {
                    continue;
                }

                LineNode lineNode = new LineNode();
                lineNode.Set(new Vector3(-cellSize.X, -ii * cellSize.Y, 0), new Vector3(nCountX * cellSize.X, -ii * cellSize.Y, 0));
                gridNode.AddNode(lineNode);
            }
            gridNode.Update();
            wp.SetGridNode(gridNode);
            m_RenderView.ShowWorkingGrid(true);
        }