Exemplo n.º 1
0
        protected override void OnMouseClick3DAction(Mouse3DPosition mouseData)
        {
            if (!mouseData.MouseDown)
            {
                return;
            }

            if (_currentSelectedEntity == null)
            {
                var selectedEntities =
                    Inputs[InputNames.SelectionContainerPipe].GetData(NotificationNames.GetEntities).Get
                    <List <SceneSelectedEntity> >();
                if (selectedEntities.Count <= 0)
                {
                    return;
                }
                var shape = selectedEntities[0].TargetShape();
                if (shape.ShapeType == TopAbsShapeEnum.TopAbs_EDGE)
                {
                    _currentSelectedEntity = selectedEntities[0];
                    Inputs[InputNames.FacePickerPlane].Send(NotificationNames.Resume);
                }
            }
            else
            {
                InitSession();

                var builder = DrawDimension(mouseData.Point.GpPnt);
                builder[3].Integer = 1;
                builder.ExecuteFunction();
                // The Dimension node is not visible in the tree view
                builder.Node.Set <TreeViewVisibilityInterpreter>();

                Context.CloseAllContexts(true);

                if (!builder.ExecuteFunction())
                {
                    Document.Revert();
                    BackToNeutralModifier();
                    return;
                }

                if (builder.Dependency[0].ReferenceBuilder.FunctionName == FunctionNames.LineTwoPoints)
                {
                    NodeBuilderUtils.AddLengthConstraint(Document, builder.Dependency[0].ReferenceBuilder);
                }

                if (builder.Dependency[0].ReferenceBuilder.FunctionName == FunctionNames.Circle)
                {
                    NodeBuilderUtils.AddRadiusConstraint(Document, builder.Dependency[0].ReferenceBuilder.Node);
                }

                // Finish the transaction
                Inputs[InputNames.FacePickerPlane].Send(NotificationNames.Suspend);
                Inputs[InputNames.FacePickerPlane].Send(NotificationNames.Cleanup);
                CommitFinal("Apply dimension");

                // Prepare for a new dimension
                Reset();
            }
        }