Exemple #1
0
        protected override bool OnClickStart(ScreenPoint cursorPos, Line cursorRay)
        {
            var iDesignFace = InteractionContext.Preselection as IDesignFace;

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

            SurfaceEvaluation eval = iDesignFace.Shape.GetSingleRayIntersection(cursorRay);

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

            double defaultHeight = 0.02;

            WriteBlock.ExecuteTask("Create Oscillator", () => {
                OscillatorPart.Create(HandleTypeEnum.Shaft, iDesignFace, eval.Param, defaultHeight, 0);
                OscillatorPart.Create(HandleTypeEnum.Base, iDesignFace, eval.Param, defaultHeight, 0);
                OscillatorPart.Create(HandleTypeEnum.Start, iDesignFace, eval.Param, defaultHeight, 0);
                OscillatorPart.Create(HandleTypeEnum.End, iDesignFace, eval.Param, defaultHeight, 0);
            });

            return(false);
        }
Exemple #2
0
        protected override bool OnDragStart(ScreenPoint cursorPos, Line cursorRay)
        {
            //SelectionTypes = new Type[0]; // disable preselection while dragging

            OscillatorPart oscillatorPart = OscillatorPart.GetWrapper(InteractionContext.Preselection as CustomObject);

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

            Point?pointOnCustom = InteractionContext.PreselectionPoint;

            if (pointOnCustom == null)
            {
                oscillatorPart = null;
                return(false);
            }

            switch (oscillatorPart.HandleType)
            {
            case HandleTypeEnum.Base:
                var iDesignFace = InteractionContext.Preselection as IDesignFace;
                if (iDesignFace == null)
                {
                    return(false);
                }

                SurfaceEvaluation eval = iDesignFace.Shape.GetSingleRayIntersection(cursorRay);
                if (eval == null)
                {
                    return(false);
                }

                oscillatorIDesignFace = iDesignFace;
                oscillatorPointUV     = eval.Param;

                StatusText = "Drag to move the oscillator.";
                break;

            case HandleTypeEnum.Start:
            case HandleTypeEnum.End:
                break;
            }

            return(false);
        }
Exemple #3
0
        protected override bool OnMouseMove(ScreenPoint cursorPos, Line cursorRay, MouseButtons button)
        {
            if (button != MouseButtons.None)
            {
                return(false);
            }

            IDocObject  preselection = InteractionContext.Preselection;
            IDesignFace iDesignFace  = null;

            OscillatorPart existingOscillatorHandle = OscillatorPart.GetWrapper(preselection as CustomObject);

            if (existingOscillatorHandle != null)
            {
                iDesignFace = existingOscillatorHandle.IDesignFace;
            }
            if (iDesignFace == null)
            {
                iDesignFace = preselection as DesignFace;
            }
            if (iDesignFace == null)             // selection filtering is not applied if you (pre)select in the tree
            {
                return(false);
            }

            SurfaceEvaluation eval = iDesignFace.Shape.GetSingleRayIntersection(cursorRay);

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

            Rendering = Graphic.Create(null, null, OscillatorPart.GetGraphics(iDesignFace, eval.Param, 0.05, 0, HandleTypeEnum.All));

            return(false);            // if we return true, the preselection won't update
        }