//Dynamic Object Draw void RefObjDraw(object sender, Rhino.Input.Custom.GetPointDrawEventArgs e) { double factorTemp = (scaleCenter.DistanceTo(e.CurrentPoint)) / (scaleCenter.DistanceTo(scaleRefPoint)); if (dimensionIndex == 0) { for (int i = 0; i < goList.Count; i++) { Rhino.Geometry.Vector3d vec = (centers[i] - scaleCenter) * (factorTemp - 1); Rhino.DocObjects.RhinoObject rhobj = goList[i] as Rhino.DocObjects.RhinoObject; var xform = Rhino.Geometry.Transform.Translation(vec); e.Display.DrawObject(rhobj, xform); } } //Translate 2d else if (dimensionIndex == 1) { for (int i = 0; i < goList.Count; i++) { Rhino.Geometry.Vector3d vec = (centers[i] - scaleCenter) * (factorTemp - 1); Rhino.DocObjects.RhinoObject rhobj = goList[i] as Rhino.DocObjects.RhinoObject; Vector3d planeNormal = plane2D.Normal; if (planeNormal[0] != 0) { vec.X = 0; } else if (planeNormal[1] != 0) { vec.Y = 0; } else if (planeNormal[2] != 0) { vec.Z = 0; } var xform = Rhino.Geometry.Transform.Translation(vec); e.Display.DrawObject(rhobj, xform); } } //Translate 1d else if (dimensionIndex == 2) { for (int i = 0; i < goList.Count; i++) { Vector3d vecEach = (centers[i] - scaleCenter); double vecEachLength = vecEach.Length * (factorTemp - 1); Vector3d vec = (scaleRefPoint - scaleCenter); double angleVec = Vector3d.VectorAngle(vecEach, vec); int pol = 1; if (angleVec > 1.57) { pol = -1; } vec.Unitize(); vec = vec * vecEachLength * pol; var xform = Transform.Translation(vec); Rhino.DocObjects.RhinoObject rhobj = goList[i] as Rhino.DocObjects.RhinoObject; e.Display.DrawObject(rhobj, xform); } } }
// Dynamic Draw void RefObjDraw(object sender, Rhino.Input.Custom.GetPointDrawEventArgs e) { Rhino.DocObjects.RhinoObject rhobj = e.Source.Tag as Rhino.DocObjects.RhinoObject; if (rhobj == null) { return; } double u, v; var currentPoint = e.CurrentPoint; Vector3d direction = new Vector3d(); Plane currentPlane = new Plane(); if (surface != null) { surface.ClosestPoint(currentPoint, out u, out v); direction = surface.NormalAt(u, v); currentPlane = new Plane(currentPoint, direction); Transform xform = Rhino.Geometry.Transform.PlaneToPlane(sourcePlane, currentPlane); e.Display.DrawObject(rhobj, xform); } else if (surface == null) { surface2.ClosestPoint(currentPoint, out u, out v); direction = surface2.NormalAt(u, v); currentPlane = new Plane(currentPoint, direction); Transform xform = Rhino.Geometry.Transform.PlaneToPlane(instancePlane, currentPlane); e.Display.DrawObject(rhobj, xform); } }
protected override void OnDynamicDraw(GetPointDrawEventArgs e) { base.OnDynamicDraw(e); var cplane = e.RhinoDoc.Views.ActiveView.ActiveViewport.ConstructionPlane(); var radius = m_center_point.DistanceTo(e.CurrentPoint); var circle = new Circle(cplane, m_center_point, radius); e.Display.DrawCircle(circle, System.Drawing.Color.Black); }
protected override void OnDynamicDraw(GetPointDrawEventArgs e) { base.OnDynamicDraw(e); var xform = e.Viewport.GetTransform(CoordinateSystem.World, CoordinateSystem.Screen); var current_point = e.CurrentPoint; current_point.Transform(xform); var screen_point = new Point2d(current_point.X, current_point.Y); var msg = string.Format("screen {0:F}, {1:F}", current_point.X, current_point.Y); e.Display.Draw2dText(msg, System.Drawing.Color.Blue, screen_point, false); }
// Dynamic Draw void DynDrawCurve(object sender, Rhino.Input.Custom.GetPointDrawEventArgs e) { int curve_degree = points.Count; if (points.Count > 3) { curve_degree = 3; } List <Point3d> pointsDyn = new List <Point3d>(points); Point3d pt0 = e.CurrentPoint; Point3d pt0M = new Point3d(xm * pt0.X, ym * pt0.Y, pt0.Z); int insert = points.Count / 2; pointsDyn.Insert(insert, pt0); pointsDyn.Insert(insert + 1, pt0M); NurbsCurve dnc = NurbsCurve.Create(clamped, curve_degree, pointsDyn); e.Display.DrawCurve(dnc, System.Drawing.Color.DarkRed); }
// Dynamic Draw void RefCircleDraw(object sender, Rhino.Input.Custom.GetPointDrawEventArgs e) { Point3d closestPoint; ComponentIndex compIndex; double u, v; Vector3d vtCurr; brepSurf.ClosestPoint(e.CurrentPoint, out closestPoint, out compIndex, out u, out v, 0.01, out vtCurr); Plane planeCircle = new Plane(e.CurrentPoint, vtCurr); Point3d centerCircleOff = e.CurrentPoint + vtCurr * diamStone / 2; Circle dynCircle = new Circle(planeCircle, e.CurrentPoint, diamStone / 2); e.Display.DrawCircle(dynCircle, System.Drawing.Color.Blue); Circle crOff1 = new Circle(planeCircle, e.CurrentPoint, (diamStone / 2) + offSetStone); e.Display.DrawCircle(crOff1, System.Drawing.Color.Red); Line dynLineNormal = new Line(e.CurrentPoint, centerCircleOff); e.Display.DrawLine(dynLineNormal, System.Drawing.Color.Blue); e.Display.Draw3dText(diamStone.ToString("F2"), System.Drawing.Color.Black, planeCircle, diamStone / 4, "Arial", false, false, Rhino.DocObjects.TextHorizontalAlignment.Center, Rhino.DocObjects.TextVerticalAlignment.Middle); }
void DynamicDraw(object sender, GetPointDrawEventArgs e) { try { Point3d to = e.CurrentPoint; if (to.IsValid) { int toIndex = _crvTopology.GetClosestNode(to); if (toIndex != -1) { e.Display.DrawPoint(_crvTopology.VertexAt(toIndex), PointStyle.X, 7, Color.Azure); if (_fromIndex != -1 && toIndex != _fromIndex) { var c = _pathSearchMethod.Cross(_fromIndex, toIndex); if (c != null) e.Display.DrawCurve(c, Color.Black, 3); } } } if(_fromIndex != -1) e.Display.DrawPoint(_crvTopology.VertexAt(_fromIndex), PointStyle.X, 7, Color.Azure); } catch (Exception ex) { _getPoint.DynamicDraw -= DynamicDraw; RhinoApp.WriteLine("An error happened in the display pipeline: {0}, {1}", ex.GetType().Name, ex.Message); } }
/// <summary>Default calls the DynamicDraw event.</summary> /// <param name="e">Current argument for the event.</param> protected virtual void OnDynamicDraw(GetPointDrawEventArgs e) { if (DynamicDraw != null) DynamicDraw(this, e); m_baseOnDynamicDrawCalled = true; }
private static int CustomDrawCallback(IntPtr pDisplayPipeline, Point3d point) { if (null == m_active_gp) return 0; m_active_gp.m_baseOnDynamicDrawCalled = false; int rc = 0; try { GetPointDrawEventArgs e = new GetPointDrawEventArgs(m_active_gp, pDisplayPipeline, point); m_active_gp.OnDynamicDraw(e); rc = m_active_gp.m_baseOnDynamicDrawCalled ? 1 : 0; m_active_gp.m_baseOnDynamicDrawCalled = false; } catch (Exception ex) { Runtime.HostUtils.ExceptionReport(ex); } return rc; }
private void Getter_DynamicDraw(object sender, GetPointDrawEventArgs e) { if (_plane.IsValid) DrawPlane(e.Display, e.Viewport, _plane); }
//Dynamic Object Draw void RefObjDraw(object sender, Rhino.Input.Custom.GetPointDrawEventArgs e) { double factorTemp = (scaleCenter.DistanceTo(e.CurrentPoint)) / (scaleCenter.DistanceTo(scaleRefPoint)); //Translate 3d if (dimensionIndex == 0) { for (int i = 0; i < dynRef.Count; i++) { Rhino.DocObjects.ObjRef objref = dynRef[i] as Rhino.DocObjects.ObjRef; var xform = Transform.Scale(centers[i], factorTemp); Brep brep = objref.Brep(); var index = objref.GeometryComponentIndex.Index; if (index > 0) { brep.TransformComponent(new[] { objref.GeometryComponentIndex }, xform, 0.01, 0, true); //doc.Objects.Replace(objref.ObjectId, brep); e.Display.DrawBrepWires(brep, System.Drawing.Color.Gray); } else { Rhino.DocObjects.RhinoObject rhobj = objref.Object(); e.Display.DrawObject(rhobj, xform); } } } //Translate 2d else if (dimensionIndex == 1) { for (int i = 0; i < dynRef.Count; i++) { Rhino.DocObjects.ObjRef objref = dynRef[i] as Rhino.DocObjects.ObjRef; plane2D.Origin = centers[i]; var xform = Rhino.Geometry.Transform.Scale(plane2D, factorTemp, factorTemp, 1); Brep brep = objref.Brep(); var index = objref.GeometryComponentIndex.Index; if (index > 0) { brep.TransformComponent(new[] { objref.GeometryComponentIndex }, xform, 0.01, 0, true); //doc.Objects.Replace(objref.ObjectId, brep); e.Display.DrawBrepWires(brep, System.Drawing.Color.Gray); } else { Rhino.DocObjects.RhinoObject rhobj = objref.Object(); e.Display.DrawObject(rhobj, xform); } } } //Translate 1d else if (dimensionIndex == 2) { for (int i = 0; i < dynRef.Count; i++) { Vector3d vec = (scaleRefPoint - scaleCenter); Plane scalePlane = new Plane(centers[i], vec); var xform = Transform.Scale(scalePlane, 1, 1, factorTemp); Rhino.DocObjects.ObjRef objref = dynRef[i] as Rhino.DocObjects.ObjRef; Brep brep = objref.Brep(); var index = objref.GeometryComponentIndex.Index; if (index > 0) { brep.TransformComponent(new[] { objref.GeometryComponentIndex }, xform, 0.01, 0, true); //doc.Objects.Replace(objref.ObjectId, brep); e.Display.DrawBrepWires(brep, System.Drawing.Color.Gray); } else { Rhino.DocObjects.RhinoObject rhobj = objref.Object(); e.Display.DrawObject(rhobj, xform); } } } }