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); }
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 }