예제 #1
0
        private bool ApplyConstraint(FunctionDependency dependency, ref AISInteractiveObject interactive,
                                     Point3D destinationPoint, Point3D sourcePoint, Point3D distancePoint)
        {
            var transform           = dependency[1].Reference.Set <TransformationInterpreter>();
            var substractedDistance = destinationPoint.SubstractCoordinate(sourcePoint);

            if (dependency[0].Reference.Index != dependency[1].Reference.Index)
            {
                if (distancePoint.IsEqual(substractedDistance))
                {
                    interactive = UpdateInteractive(sourcePoint);
                    return(true);
                }

                var translateVal = new Point3D(transform.Translate);
                transform.Translate =
                    translateVal.AddCoordinate(distancePoint.SubstractCoordinate(substractedDistance)).GpPnt;
            }
            else
            {
                var origin           = new Point3D();
                var pointDistance    = distancePoint.Distance(origin);
                var expectedDistance = substractedDistance.Distance(origin);
                if (Math.Abs(pointDistance - expectedDistance) < Precision.Confusion)
                {
                    interactive = UpdateInteractive(sourcePoint);
                    return(true);
                }
                transform.Scale = transform.Scale * pointDistance / expectedDistance;
            }
            return(false);
        }
예제 #2
0
        /// <summary>
        ///   Called when the user moves the mouse over an item from the object tree view.
        /// </summary>
        /// <param name = "label"></param>
        private void TreeViewHoverLabel(Node label)
        {
            var interpreter = label.Get <NamedShapeInterpreter>();

            if (interpreter != null)
            {
                var interactiveObject = interpreter.Interactive;
                if (interactiveObject == null)
                {
                    return;
                }
                var status = _context.DisplayStatus(interactiveObject);
                if (status != AISDisplayStatus.AIS_DS_Displayed)
                {
                    return;
                }
                _context.SetSelected(interactiveObject, true);
                _lastHighlightedinteractiveObject = interactiveObject;
            }
            else
            {
                if (_lastHighlightedinteractiveObject == null)
                {
                    return;
                }
                _context.SetSelected(_lastHighlightedinteractiveObject, true);
                _lastHighlightedinteractiveObject = null;
            }
        }
예제 #3
0
        private void Remove()
        {
            var shapeManager = Parent.Root.Set <DocumentContextInterpreter>().ShapeManager;

            shapeManager.RemoveShapeFromContext(Parent);
            _interactive = null;
        }
        public override void OnRemove()
        {
            var shapeManager = Parent.Root.Set <DocumentContextInterpreter>().ShapeManager;

            shapeManager.RemoveShapeFromContext(Parent);
            _interactive = null;
            if (_registered)
            {
                Parent.OnModified -= OnReferencedModified;
            }
        }
예제 #5
0
        private static void UpdateTransparency(AISInteractiveContext context, Node parent,
                                               AISInteractiveObject interactive)
        {
            // If the label has transparency information display the object with that transparency
            var value = 0.0;

            if (parent.Get <DrawingAttributesInterpreter>().HasTransparency)
            {
                value = parent.Get <DrawingAttributesInterpreter>().Transparency;
            }

            context.SetTransparency(interactive, value, false);
        }
        private void ApplyColor(NodeBuilder builder, AISInteractiveObject aisShape)
        {
            var parent           = builder.Node;
            var col              = Color.DarkTurquoise;
            var colorInterpreter = parent.Get <DrawingAttributesInterpreter>();

            if (colorInterpreter.HasColorSet)
            {
                col = colorInterpreter.Color;
            }
            var color = ShapeUtils.GetOccColor(col);

            _context.SetColor(aisShape, color, false);
        }
예제 #7
0
        private static void UpdateInteractiveColor(AISInteractiveContext context, Node parent,
                                                   AISInteractiveObject interactive, bool setWireAspect)
        {
            var col = Color.DarkTurquoise;
            var colorInterpreter = parent.Get <DrawingAttributesInterpreter>();

            if (colorInterpreter.HasNoColor)
            {
                context.Display(interactive, false);
                return;
            }
            if (colorInterpreter.HasColorSet)
            {
                col = colorInterpreter.Color;
            }
            var color = ShapeUtils.GetOccColor(col);

            var layerContainer = parent.Root.Get <LayerContainerInterpreter>();

            if (layerContainer.UseLayerColors)
            {
                var layerIndex = parent.Get <LayerVisibilityInterpreter>().TagIndex;
                color = ShapeUtils.GetOccColor(layerContainer.LayerColors[layerIndex]);
            }

            context.SetColor(interactive, color, false);
            var drawer = interactive.Attributes;

            if (setWireAspect)
            {
                var wireAspect = drawer.WireAspect;
                wireAspect.SetColor(color.Name());
                wireAspect.Width  = (1.5);
                drawer.LineAspect = (new Prs3dLineAspect(QuantityNameOfColor.Quantity_NOC_GRAY70,
                                                         AspectTypeOfLine.Aspect_TOL_DOT, 0.5));
                var pointAspect = drawer.PointAspect;
                pointAspect.SetColor(color.Name());
                pointAspect.Scale = (1);
                context.SetDisplayMode(interactive, (int)colorInterpreter.DisplayMode, false);
            }
            if (colorInterpreter.EnableSelection == false)
            {
                interactive.UnsetSelectionMode();
                interactive.HilightMode = (3);
            }
            context.Display(interactive, false);
        }
예제 #8
0
        public override bool Execute()
        {
            if (_blockUpdate)
            {
                return(true);
            }
            var builder          = Builder;
            var sourcePoint      = NodeUtils.GetReferencePoint(builder, 0);
            var destinationPoint = NodeUtils.GetReferencePoint(builder, 1);
            var distancePoint    = Dependency[2].TransformedPoint3D;

            _blockUpdate = true;
            AISInteractiveObject interactive = null;

            if (ApplyConstraint(Dependency, ref interactive, destinationPoint, sourcePoint, distancePoint))
            {
                Interactive  = interactive;
                _blockUpdate = false;
                return(true);
            }
            _blockUpdate = false;
            Interactive  = UpdateInteractive(sourcePoint);
            return(true);
        }
        public void RegenerateInteractive()
        {
            var shapeManager = Parent.Root.Set <DocumentContextInterpreter>().ShapeManager;

            _interactive = shapeManager.UpdateNodesInteractive(Parent);
        }