protected override void OnNotification(string name, DataPackage dataPackage)
        {
            switch (name)
            {
            case NotificationNames.SetFace:
                SelectedItem = dataPackage.Get <SelectionInfo>();
                break;

            case NotificationNames.SetPlane:
                if (_ignorePlanes)
                {
                    return;
                }
                Plane = dataPackage.Get <gpPln>();
                break;

            case NotificationNames.ExcludedPlane:
                if (_ignorePlanes)
                {
                    return;
                }
                ExcludedPlane = dataPackage.Get <gpPln>();
                break;

            case NotificationNames.GetPlane:
                ReturnData = new DataPackage(Plane);
                break;

            case NotificationNames.GetFace:
                ReturnData = new DataPackage(SelectedItem);
                break;

            case NotificationNames.Suspend:
                _ignorePlanes = true;
                break;

            case NotificationNames.Resume:
                _ignorePlanes = false;
                break;
            }
        }
Example #2
0
        private void CorrectCoordinateOnSelectedFace(Mouse3DPosition mousePosition,
                                                     Mouse3DPosition correctedMousePosition)
        {
            var currentAction = this._document.Root.Get <ActionGraphInterpreter>().ActionsGraph.CurrentAction;

            if (_selectionContainer[TopAbsShapeEnum.TopAbs_FACE].Count <= 0)
            {
                if (currentAction.Name == ModifierNames.StartSketch)
                {
                    SelectionInfo selInfo = null;
                    Inputs[InputNames.Mouse3DEventsPipe].Send(NotificationNames.SetFace, selInfo);
                }
                return;
            }
            var face  = _selectionContainer[TopAbsShapeEnum.TopAbs_FACE][0].TargetShape();
            var plane = GeomUtils.ExtractPlane(face);

            if (plane == null)
            {
                return;
            }
            Inputs[InputNames.Mouse3DEventsPipe].Send(NotificationNames.SetPlane, plane);


            if (currentAction.Name == ModifierNames.StartSketch)
            {
                var selectionInfo = new SelectionInfo
                {
                    selectedNode = _selectionContainer[TopAbsShapeEnum.TopAbs_FACE][0].Node,
                    face         = _selectionContainer[TopAbsShapeEnum.TopAbs_FACE][0].ShapeCount - 1
                };
                var nb    = new NodeBuilder(_selectionContainer[TopAbsShapeEnum.TopAbs_FACE][0].Node);
                var faces = GeomUtils.ExtractFaces(nb.Shape);
                int count = 0;
                foreach (var face1 in faces)
                {
                    var direction = GeomUtils.ExtractPlane(face1);
                    if (direction == null)
                    {
                        count++;
                        continue;
                    }
                    if (direction.Axis.Direction.IsEqual(plane.Axis.Direction, Precision.Confusion) &&
                        direction.Axis.Location.IsEqual(plane.Axis.Location, Precision.Confusion))
                    {
                        break;
                    }
                    count++;
                }

                selectionInfo.face = count;
                Inputs[InputNames.Mouse3DEventsPipe].Send(NotificationNames.SetFace, selectionInfo);
            }
            double x         = 0;
            double y         = 0;
            double z         = 0;
            var    isOnPlane = GeomUtils.ConvertToPlane(ViewItems.View, plane, mousePosition.Initial2Dx,
                                                        mousePosition.Initial2Dy, ref x, ref y, ref z);

            if (isOnPlane)
            {
                correctedMousePosition.Point = new Point3D(x, y, z);
            }
        }