コード例 #1
0
        //--------------------------------------------------------------------------------------------------

        #endregion

        #region Updating

        public void UpdateShape()
        {
            if (_AisShape == null)
            {
                _EnsureAisObject();
                _UpdateInteractivityStatus();
            }
            else
            {
                var ocShape = OverrideBrep ?? _ShapeSource.GetTransformedBRep();
                if (ocShape != null)
                {
                    if (_AisShape.Shape().ShapeType() != ocShape.ShapeType())
                    {
                        // If shape type changes, recompute can lead to crashes. It's better to redisplay AIS_Shape
                        Remove();
                        UpdateShape();
                    }
                    else
                    {
                        _AisShape.Set(ocShape);
                        _UpdatePresentation();
                        AisContext.RecomputeSelectionOnly(_AisShape);
                        _UpdateSelectionSensitivity();
                    }
                }
                else
                {
                    _UpdateMarker();
                }
            }
        }
コード例 #2
0
        //--------------------------------------------------------------------------------------------------

        bool _EnsureAisObject()
        {
            if (_AisCircle != null)
            {
                return(true);
            }

            if (_Circle == null)
            {
                return(false);
            }

            if (_Circle.Radius() <= 0)
            {
                return(false);
            }

            _AisCircle = new AIS_Circle(_Circle);

            SetAspects(_AisCircle, _Style);

            AisContext.Display(_AisCircle, false);
            AisContext.Deactivate(_AisCircle);
            return(true);
        }
コード例 #3
0
        //--------------------------------------------------------------------------------------------------

        bool _EnsureAisObject()
        {
            if (_AisShape != null)
            {
                return(true);
            }

            if ((_ShapeSource == null) || (AisContext == null))
            {
                return(false);
            }

            var brep = OverrideBrep ?? _ShapeSource.GetTransformedBRep();

            if (brep == null)
            {
                return(false);
            }

            _AisShape = new AIS_Shape(brep);

            _UpdatePresentation();
            _UpdateInteractivityStatus();

            if (WorkspaceController.Selection.SelectedEntities.Contains(_ShapeSource) && !IsHidden)
            {
                AisContext.AddOrRemoveSelected(_AisShape, false);
            }

            return(true);
        }
コード例 #4
0
        //--------------------------------------------------------------------------------------------------

        public override void Update()
        {
            bool isValid = true;

            if (_GeomLine == null)
            {
                isValid = _P1.Distance(_P2) > Double.Epsilon;
            }
            if (!isValid)
            {
                Remove();
                return;
            }

            if (_AisLine == null)
            {
                if (!_EnsureAisObject())
                {
                    return;
                }
            }
            else
            {
                if (_GeomLine != null)
                {
                    _AisLine.SetLine(_GeomLine);
                }
                else
                {
                    _AisLine.SetPoints(_P1, _P2);
                }
                AisContext.RecomputePrsOnly(_AisLine, false);
            }
        }
コード例 #5
0
        //--------------------------------------------------------------------------------------------------

        public override void Update()
        {
            bool isValid = _Circle.Radius() > Double.Epsilon;

            if (!isValid)
            {
                Remove();
                return;
            }

            if (_AisCircle == null)
            {
                if (!_EnsureAisObject())
                {
                    return;
                }
            }
            else
            {
                _AisCircle.SetCircle(_Circle);
                _AisCircle.SetFirstParam(_StartParam);
                _AisCircle.SetLastParam(_EndParam);
                AisContext.RecomputePrsOnly(_AisCircle, false);
            }
        }
コード例 #6
0
        //--------------------------------------------------------------------------------------------------

        public void InitAisContext()
        {
            if (V3dViewer == null)
            {
                InitV3dViewer();
            }

            if (AisContext == null)
            {
                AisContext = new AIS_InteractiveContext(V3dViewer);
                AisContext.UpdateCurrentViewer();
            }

            AisContext.SetAutoActivateSelection(true);
            AisContext.SetPickingStrategy(SelectMgr_PickingStrategy.SelectMgr_PickingStrategy_OnlyTopmost);
            AisContext.SetDisplayMode((int)AIS_DisplayMode.AIS_Shaded, false);
            V3dViewer.DisplayPrivilegedPlane(true, 1.0);
            AisContext.EnableDrawHiddenLine();

            // Reinit ais parameters
            _ApplyWorkingContext();
            AisContext?.SetPixelTolerance(2);

            var drawer = AisContext.DefaultDrawer();

            drawer.SetWireAspect(new Prs3d_LineAspect(Colors.Selection, Aspect_TypeOfLine.Aspect_TOL_SOLID, 1.0));
            //drawer.SetTypeOfHLR(Prs3d_TypeOfHLR.Prs3d_TOH_Algo);
            drawer.SetTypeOfHLR(Prs3d_TypeOfHLR.Prs3d_TOH_PolyAlgo);
        }
コード例 #7
0
        //--------------------------------------------------------------------------------------------------

        public override void Remove()
        {
            if (_AisCircle != null)
            {
                AisContext.Erase(_AisCircle, false);
                _AisCircle = null;
            }
        }
コード例 #8
0
        //--------------------------------------------------------------------------------------------------

        public override void Remove()
        {
            if (_AisAxis != null)
            {
                AisContext.Erase(_AisAxis, false);
                _AisAxis = null;
            }
        }
コード例 #9
0
        //--------------------------------------------------------------------------------------------------

        public override void Remove()
        {
            if (_AisPoint != null)
            {
                AisContext.Erase(_AisPoint, false);
                _AisPoint = null;
            }
        }
コード例 #10
0
        //--------------------------------------------------------------------------------------------------

        public void SetColor(Quantity_Color color)
        {
            if (!_EnsureAisObject())
            {
                return;
            }

            _AisAxis.SetColor(color);
            AisContext.RecomputePrsOnly(_AisAxis, false);
        }
コード例 #11
0
        //--------------------------------------------------------------------------------------------------

        public void SetLength(double length)
        {
            if (!_EnsureAisObject())
            {
                return;
            }

            _AisAxis.SetLength(length);
            AisContext.RecomputePrsOnly(_AisAxis, false);
        }
コード例 #12
0
        //--------------------------------------------------------------------------------------------------

        public override void Update()
        {
            if (_AisAxis == null)
            {
                _EnsureAisObject();
            }
            else
            {
                AisContext.RecomputePrsOnly(_AisAxis, false);
            }
        }
コード例 #13
0
        //--------------------------------------------------------------------------------------------------

        public override void Update()
        {
            if (_AisPoint == null)
            {
                _EnsureAisObject();
            }
            else
            {
                AisContext.Redisplay(_AisPoint, false);
            }
        }
コード例 #14
0
        //--------------------------------------------------------------------------------------------------

        public void SetColor(Quantity_Color color)
        {
            _Color = color ?? Colors.BallMarker;

            if (!_EnsureAisObject())
            {
                return;
            }

            _AisPoint.SetColor(_Color);
            AisContext.RecomputePrsOnly(_AisPoint, false);
        }
コード例 #15
0
        //--------------------------------------------------------------------------------------------------

        public void Set(Geom_CartesianPoint p)
        {
            _P = p;

            if (!_EnsureAisObject())
            {
                return;
            }

            _AisPoint.SetComponent(_P);
            AisContext.Redisplay(_AisPoint, false);
        }
コード例 #16
0
        //--------------------------------------------------------------------------------------------------

        public void Dispose()
        {
            AisContext?.Dispose();
            AisContext = null;
            if (V3dViewer != null && !V3dViewer.IsDisposed())
            {
                V3dViewer.SetViewOff();
                V3dViewer.Dispose();
                V3dViewer = null;
            }

            Model = null;
        }
コード例 #17
0
        //--------------------------------------------------------------------------------------------------

        void _UpdateInteractivityStatus()
        {
            if (_AisShape == null)
            {
                return;
            }

            if (_Options.HasFlag(Options.Ghosting))
            {
                AisContext.Display(_AisShape, false);
                AisContext.Deactivate(_AisShape);
                return;
            }

            var layer = _ShapeSource?.GetLayer();

            if (layer == null)
            {
                return;
            }

            bool isVisible = !_IsHidden && layer.IsVisible;

            if (WorkspaceController.VisualShapes.EntityIsolationEnabled)
            {
                isVisible &= WorkspaceController.VisualShapes.GetIsolatedEntities().Contains(_ShapeSource);
            }

            if (isVisible)
            {
                if (AisContext.IsDisplayed(_AisShape))
                {
                    AisContext.Update(_AisShape, false);
                }
                else
                {
                    AisContext.Display(_AisShape, false);
                }

                _UpdateSelectionSensitivity();
            }
            else
            {
                if (AisContext.IsDisplayed(_AisShape))
                {
                    AisContext.Erase(_AisShape, false);
                }
            }

            _RaiseAisObjectChanged();
        }
コード例 #18
0
        //--------------------------------------------------------------------------------------------------

        void _Update()
        {
            if (_AisCircle == null)
            {
                if (!_EnsureAisObject())
                    return;
            }
            else
            {
                _AisCircle.SetCircle(_Circle);
                _AisCircle.SetFirstParam(_StartParam);
                _AisCircle.SetLastParam(_EndParam);
                AisContext.RecomputePrsOnly(_AisCircle, false);
            }
        }
コード例 #19
0
        //--------------------------------------------------------------------------------------------------

        #region Selection

        void _UpdateActivation()
        {
            if (_AisPoint == null)
            {
                return;
            }

            if (_IsSelectable)
            {
                AisContext.Activate(_AisPoint, 0, false);
            }
            else
            {
                AisContext.Deactivate(_AisPoint);
            }
        }
コード例 #20
0
        //--------------------------------------------------------------------------------------------------

        public void SetAxis(Ax1 axis)
        {
            if (!_EnsureAisObject())
            {
                return;
            }

            if ((_Style & HintStyle.NoResize) > 0)
            {
                _AisAxis.SetComponent(new Geom_Line(Pnt.Origin, axis.Direction));
                _AisAxis.SetTransformPersistence(new Graphic3d_TransformPers(Graphic3d_TransModeFlags.Graphic3d_TMF_ZoomPers, axis.Location));
            }
            else
            {
                _AisAxis.SetComponent(new Geom_Line(axis));
            }
            AisContext.RecomputePrsOnly(_AisAxis, false);
        }
コード例 #21
0
        //--------------------------------------------------------------------------------------------------

        public override void Remove()
        {
            if (_AisShape == null)
            {
                return;
            }

            if (AisContext.IsHilighted(_AisShape))
            {
                AisContext.Unhilight(_AisShape, false);
            }
            AisContext.Remove(_AisShape, false);

            AisContext.Erase(_AisShape, false);
            _AisShape = null;

            _UpdateMarker();
        }
コード例 #22
0
        //--------------------------------------------------------------------------------------------------

        void _Update()
        {
            if (_AisLine == null)
            {
                if (!_EnsureAisObject())
                {
                    return;
                }
            }
            else
            {
                if (_GeomLine != null)
                {
                    _AisLine.SetLine(_GeomLine);
                }
                else
                {
                    _AisLine.SetPoints(_P1, _P2);
                }
                AisContext.RecomputePrsOnly(_AisLine, false);
            }
        }
コード例 #23
0
        //--------------------------------------------------------------------------------------------------

        bool _EnsureAisObject()
        {
            if (_AisAxis != null)
            {
                return(true);
            }

            _AisAxis = new AIS_AxisEx(new Geom_Line(Ax1.OX));
            _AisAxis.SetWidth(3);
            _AisAxis.SetColor(new Quantity_Color(Quantity_NameOfColor.Quantity_NOC_RED));

            var datumAspect = new Prs3d_DatumAspect();

            datumAspect.LineAspect(Prs3d_DatumParts.Prs3d_DP_XArrow).SetTypeOfLine(Aspect_TypeOfLine.Aspect_TOL_SOLID);
            datumAspect.ArrowAspect().SetLength(5);

            SetAspects(_AisAxis, _Style);

            AisContext.Display(_AisAxis, false);
            AisContext.Deactivate(_AisAxis);
            return(true);
        }
コード例 #24
0
        //--------------------------------------------------------------------------------------------------

        void _UpdatePresentation()
        {
            _UpdateMarker();

            if (_AisShape == null)
            {
                return;
            }

            var layer = _ShapeSource?.GetLayer();

            if (layer == null)
            {
                return;
            }

            AttributeSet attributeSet;

            if (!_DrawerCache.TryGetValue(layer, out attributeSet))
            {
                attributeSet = new AttributeSet();
                _UpdateAttributesForLayer(layer, ref attributeSet);
                _DrawerCache.SetValue(layer, attributeSet);
            }

            _AisShape.SetAttributes(attributeSet.Drawer);
            //_AisShape.SetHilightAttributes(attributeSet.HilightDrawer);

            _AisShape.SynchronizeAspects();

            if (_Options.HasFlag(Options.Ghosting))
            {
                _UpdatePresentationForGhost();
            }

            //TODO maybe not needed due to call to SynchronizeAspects
            AisContext.RecomputePrsOnly(_AisShape, false, true);
        }
コード例 #25
0
        //--------------------------------------------------------------------------------------------------

        void _UpdateSelectionSensitivity()
        {
            // Check if shape is activated
            var modes = new TColStd_ListOfInteger();

            AisContext.ActivatedModes(_AisShape, modes);
            var modeList = modes.ToList();

            if (!modeList.Contains(0))
            {
                return;
            }

            if ((_ShapeSource as Body)?.Shape.ShapeType == ShapeType.Sketch)
            {
                var paramSet = InteractiveContext.Current.Parameters.Get <ViewportParameterSet>();
                AisContext.SetSelectionSensitivity(_AisShape, 0, (int)(paramSet.SketchSelectionSensitivity * 10.0));
            }
            else
            {
                AisContext.SetSelectionSensitivity(_AisShape, 0, 2);
            }
        }
コード例 #26
0
        //--------------------------------------------------------------------------------------------------

        bool _EnsureAisObject()
        {
            if (_AisLine != null)
            {
                return(true);
            }

            if (((_P1 == null) || (_P2 == null)) &&
                (_GeomLine == null))
            {
                return(false);
            }

            _AisLine = (_GeomLine != null)
                ? new AIS_Line(_GeomLine)
                : new AIS_Line(_P1, _P2);

            SetAspects(_AisLine, _Style);

            AisContext.Display(_AisLine, false);
            AisContext.Deactivate(_AisLine);
            return(true);
        }
コード例 #27
0
        //--------------------------------------------------------------------------------------------------

        bool _EnsureAisObject()
        {
            if (_AisPoint != null)
            {
                return(true);
            }

            if (_P == null)
            {
                return(false);
            }

            Prs3d_PointAspect pointAspect;

            _AisPoint = new AIS_PointEx(_P);

            switch (_Styles & Styles.ModeMask)
            {
            case Styles.Bitmap:
                _AisPoint.SetMarker(Aspect_TypeOfMarker.Aspect_TOM_USERDEFINED);
                _AisPoint.SetColor(_Color);

                pointAspect = CreateBitmapPointAspect(_Image, Colors.BallMarker);
                _AisPoint.Attributes().SetPointAspect(pointAspect);
                _AisPoint.HilightAttributes().SetPointAspect(pointAspect);
                _AisPoint.HilightAttributes().SetColor(Colors.Highlight);
                _AisPoint.DynamicHilightAttributes().SetPointAspect(pointAspect);
                _AisPoint.DynamicHilightAttributes().SetColor(Colors.Highlight);
                break;

            case Styles.Image:
                _AisPoint.SetMarker(Aspect_TypeOfMarker.Aspect_TOM_USERDEFINED);

                pointAspect = CreateImagePointAspect(_Image);
                _AisPoint.Attributes().SetPointAspect(pointAspect);
                _AisPoint.HilightAttributes().SetPointAspect(pointAspect);
                _AisPoint.HilightAttributes().SetColor(Colors.Highlight);
                _AisPoint.DynamicHilightAttributes().SetPointAspect(pointAspect);
                _AisPoint.DynamicHilightAttributes().SetColor(Colors.Highlight);

                if (_Styles.HasFlag(Styles.Background))
                {
                    _AisPoint.EnableBackground(0.75);
                }
                break;
            }

            if (_Styles.HasFlag(Styles.Topmost))
            {
                _AisPoint.SetZLayer(-4); // TopOSD
                _AisPoint.HilightAttributes().SetZLayer(-4);
                _AisPoint.DynamicHilightAttributes().SetZLayer(-4);
            }

            AisContext.Display(_AisPoint, 0, _Styles.HasFlag(Styles.Selectable) ? 0 : -1, false);
            AisContext.SetSelectionSensitivity(_AisPoint, 0, Math.Min(_Image.Height, _Image.Width));

            _UpdateActivation();

            return(true);
        }