Esempio n. 1
0
        //--------------------------------------------------------------------------------------------------

        public override bool Start()
        {
            if (_SourceEntity != null)
            {
                _SelectionContext = WorkspaceController.Selection.OpenContext();
                _SelectionContext.Include(_SourceEntity);
            }
            else if (_Shapes != null)
            {
                _SelectionContext = WorkspaceController.Selection.OpenContext();

                _AisShapes = new List <AIS_Shape>(_Shapes.Count);
                foreach (var shape in _Shapes)
                {
                    var aisShape = new AIS_Shape(shape);
                    aisShape.SetColor(Colors.FilteredSubshapes);

                    aisShape.Attributes().SetPointAspect(Marker.CreateBitmapPointAspect(Marker.BallImage, Colors.FilteredSubshapes));
                    aisShape.Attributes().WireAspect().SetWidth(2);
                    aisShape.SetZLayer(-2);
                    WorkspaceController.Workspace.AisContext.Display(aisShape, false);
                    WorkspaceController.Workspace.AisContext.Activate(aisShape, 0, false);
                    WorkspaceController.Workspace.AisContext.SetSelectionSensitivity(aisShape, 0, 10);
                    _AisShapes.Add(aisShape);
                }
            }
            else
            {
                _SelectionContext = WorkspaceController.Selection.OpenContext(SelectionContext.Options.IncludeAll);
            }
            _SelectionContext.SetSubshapeSelection(_SubshapeTypes);
            _SelectionContext.SetSelectionFilter(_SelectionFilter);

            return(true);
        }
        //--------------------------------------------------------------------------------------------------

        void _InitVisualSettings()
        {
            var aisContext = Workspace.AisContext;

            _UpdateParameter();

            // Higlight Selected
            var selectionDrawer = new Prs3d_Drawer();

            selectionDrawer.SetColor(Colors.Selection);
            selectionDrawer.SetDisplayMode(0);
            selectionDrawer.SetZLayer(0); // Graphic3d_ZLayerId_Default
            selectionDrawer.SetTypeOfDeflection(Aspect_TypeOfDeflection.Aspect_TOD_RELATIVE);
            selectionDrawer.SetDeviationAngle(aisContext.DeviationAngle());
            selectionDrawer.SetDeviationCoefficient(aisContext.DeviationCoefficient());
            aisContext.SetSelectionStyle(selectionDrawer);
            aisContext.SetHighlightStyle(Prs3d_TypeOfHighlight.Prs3d_TypeOfHighlight_Selected, selectionDrawer);
            aisContext.SetHighlightStyle(Prs3d_TypeOfHighlight.Prs3d_TypeOfHighlight_LocalSelected, selectionDrawer);
            aisContext.SetHighlightStyle(Prs3d_TypeOfHighlight.Prs3d_TypeOfHighlight_SubIntensity, selectionDrawer);

            // Higlight Dynamic
            var hilightDrawer = new Prs3d_Drawer();

            hilightDrawer.SetColor(Colors.Highlight);
            hilightDrawer.SetDisplayMode(0);
            hilightDrawer.SetZLayer(-2); // Graphic3d_ZLayerId_Top
            hilightDrawer.SetTypeOfDeflection(Aspect_TypeOfDeflection.Aspect_TOD_RELATIVE);
            hilightDrawer.SetDeviationAngle(aisContext.DeviationAngle());
            hilightDrawer.SetDeviationCoefficient(aisContext.DeviationCoefficient());
            aisContext.SetHighlightStyle(Prs3d_TypeOfHighlight.Prs3d_TypeOfHighlight_Dynamic, hilightDrawer);

            // Higlight Local
            var hilightLocalDrawer = new Prs3d_Drawer();

            hilightLocalDrawer.SetColor(Colors.Highlight);
            hilightLocalDrawer.SetDisplayMode(1);
            hilightLocalDrawer.SetZLayer(-2); // Graphic3d_ZLayerId_Top
            hilightLocalDrawer.SetTypeOfDeflection(Aspect_TypeOfDeflection.Aspect_TOD_RELATIVE);
            hilightLocalDrawer.SetDeviationAngle(aisContext.DeviationAngle());
            hilightLocalDrawer.SetDeviationCoefficient(aisContext.DeviationCoefficient());

            var shadingAspect = new Prs3d_ShadingAspect();

            shadingAspect.SetColor(Colors.Highlight);
            shadingAspect.SetTransparency(0);

            var aspectFill = new Graphic3d_AspectFillArea3d(shadingAspect.Aspect());

            aspectFill.SetPolygonOffsets((int)Aspect_PolygonOffsetMode.Aspect_POM_Fill, 0.99f, 0.0f);
            shadingAspect.SetAspect(aspectFill);
            hilightLocalDrawer.SetShadingAspect(shadingAspect);

            var lineAspect = new Prs3d_LineAspect(Colors.Highlight, Aspect_TypeOfLine.Aspect_TOL_SOLID, 3.0);

            hilightLocalDrawer.SetLineAspect(lineAspect);
            hilightLocalDrawer.SetSeenLineAspect(lineAspect);
            hilightLocalDrawer.SetWireAspect(lineAspect);
            hilightLocalDrawer.SetFaceBoundaryAspect(lineAspect);
            hilightLocalDrawer.SetFreeBoundaryAspect(lineAspect);
            hilightLocalDrawer.SetUnFreeBoundaryAspect(lineAspect);
            hilightLocalDrawer.SetPointAspect(Marker.CreateBitmapPointAspect(Marker.BallImage, Colors.Highlight));

            aisContext.SetHighlightStyle(Prs3d_TypeOfHighlight.Prs3d_TypeOfHighlight_LocalDynamic, hilightLocalDrawer);
        }