protected override void DrawForeground(Rhino.Display.DrawEventArgs e) { var bounds = e.Viewport.Bounds; var pt = new Rhino.Geometry.Point2d(bounds.Right - 100, bounds.Bottom - 30); e.Display.Draw2dText("Hello", System.Drawing.Color.Red, pt, false); }
/// <summary> /// Generate a layout with a single detail view that zooms to a list of objects /// </summary> /// <param name="doc"></param> /// <returns></returns> public static Rhino.Commands.Result AddLayout(Rhino.RhinoDoc doc) { doc.PageUnitSystem = Rhino.UnitSystem.Millimeters; var page_views = doc.Views.GetPageViews(); int page_number = (page_views == null) ? 1 : page_views.Length + 1; var pageview = doc.Views.AddPageView(string.Format("A0_{0}", page_number), 1189, 841); if (pageview != null) { Rhino.Geometry.Point2d top_left = new Rhino.Geometry.Point2d(20, 821); Rhino.Geometry.Point2d bottom_right = new Rhino.Geometry.Point2d(1169, 20); var detail = pageview.AddDetailView("ModelView", top_left, bottom_right, Rhino.Display.DefinedViewportProjection.Top); if (detail != null) { pageview.SetActiveDetail(detail.Id); detail.Viewport.ZoomExtents(); detail.DetailGeometry.IsProjectionLocked = true; detail.DetailGeometry.SetScale(1, doc.ModelUnitSystem, 10, doc.PageUnitSystem); // Commit changes tells the document to replace the document's detail object // with the modified one that we just adjusted detail.CommitChanges(); } pageview.SetPageAsActive(); doc.Views.ActiveView = pageview; doc.Views.Redraw(); return(Rhino.Commands.Result.Success); } return(Rhino.Commands.Result.Failure); }
/// <summary> /// Generate a layout with a single detail view that zooms to a list of objects /// </summary> /// <param name="doc"></param> /// <returns></returns> public static Rhino.Commands.Result AddLayout(Rhino.RhinoDoc doc) { doc.PageUnitSystem = Rhino.UnitSystem.Millimeters; var page_views = doc.Views.GetPageViews(); int page_number = (page_views==null) ? 1 : page_views.Length + 1; var pageview = doc.Views.AddPageView(string.Format("A0_{0}",page_number), 1189, 841); if( pageview!=null ) { Rhino.Geometry.Point2d top_left = new Rhino.Geometry.Point2d(20,821); Rhino.Geometry.Point2d bottom_right = new Rhino.Geometry.Point2d(1169, 20); var detail = pageview.AddDetailView("ModelView", top_left, bottom_right, Rhino.Display.DefinedViewportProjection.Top); if (detail != null) { pageview.SetActiveDetail(detail.Id); detail.Viewport.ZoomExtents(); detail.DetailGeometry.IsProjectionLocked = true; detail.DetailGeometry.SetScale(1, doc.ModelUnitSystem, 10, doc.PageUnitSystem); // Commit changes tells the document to replace the document's detail object // with the modified one that we just adjusted detail.CommitChanges(); } pageview.SetPageAsActive(); doc.Views.ActiveView = pageview; doc.Views.Redraw(); return Rhino.Commands.Result.Success; } return Rhino.Commands.Result.Failure; }
protected override void DrawForeground(DrawEventArgs e) { var bounds = e.Viewport.Bounds; var pt = new Rhino.Geometry.Point2d(bounds.Right - 100, bounds.Bottom - 30); e.Display.Draw2dText(Text, Color, pt, false); }
protected override void DrawForeground(DrawEventArgs e) { int index = 0; if (Dir != null) { e.Display.DrawLineArrow(Dir, System.Drawing.Color.Red, 3, .1); } foreach (Guid G in m_id_list) { //Rhino.DocObjects.RhinoObject rhobj = m_pChannelAttrs.m_pObject; Rhino.DocObjects.RhinoObject rhobj = Rhino.RhinoDoc.ActiveDoc.Objects.Find(G); if (rhobj == null) { m_id_list.Remove(G); continue; } // Draw our own representation of the object Rhino.Geometry.Point2d screen_pt = e.Display.Viewport.WorldToClient(rhobj.Geometry.GetBoundingBox(true).Min); if ((rhobj.IsSelected(false) != 0)) { e.Display.DrawSprite(RS, rhobj.Geometry.GetBoundingBox(true).Min, 0.5f, true);// screen_pt, 32.0f); e.Display.Draw2dText(index.ToString(), Color.Yellow, new Rhino.Geometry.Point2d((int)screen_pt.X, (int)screen_pt.Y + 40), false, 12, "Arial"); } else { e.Display.DrawSprite(RU, rhobj.Geometry.GetBoundingBox(true).Min, 0.5f, true);// screen_pt, 32.0f); e.Display.Draw2dText(index.ToString(), Color.Black, new Rhino.Geometry.Point2d((int)screen_pt.X, (int)screen_pt.Y + 40), false, 12, "Arial"); } index++; } }
public Rhino.Geometry.Point2d ClientToScreen(Rhino.Geometry.Point2d clientPoint) { System.Drawing.Rectangle screen = ScreenRectangle; double x = clientPoint.X + screen.Left; double y = clientPoint.Y + screen.Top; return(new Rhino.Geometry.Point2d(x, y)); }
/// <summary> /// Creates a detail view object that is displayed on this page and adds it to the doc. /// </summary> /// <param name="title">The detail view title.</param> /// <param name="corner0">Corners of the detail view in world coordinates.</param> /// <param name="corner1">Corners of the detail view in world coordinates.</param> /// <param name="initialProjection">The defined initial projection type.</param> /// <returns>Newly created detail view on success. null on error.</returns> /// <example> /// <code source='examples\vbnet\ex_addlayout.vb' lang='vbnet'/> /// <code source='examples\cs\ex_addlayout.cs' lang='cs'/> /// <code source='examples\py\ex_addlayout.py' lang='py'/> /// </example> public Rhino.DocObjects.DetailViewObject AddDetailView(string title, Rhino.Geometry.Point2d corner0, Rhino.Geometry.Point2d corner1, DefinedViewportProjection initialProjection) { IntPtr pThis = NonConstPointer(); IntPtr pDetail = UnsafeNativeMethods.CRhinoPageView_AddDetailView(pThis, corner0, corner1, title, (int)initialProjection); Rhino.DocObjects.DetailViewObject rc = null; if (pDetail != IntPtr.Zero) { uint sn = UnsafeNativeMethods.CRhinoObject_RuntimeSN(pDetail); rc = new Rhino.DocObjects.DetailViewObject(sn); } return(rc); }
public static Rhino.Commands.Result Splop(Rhino.RhinoDoc doc) { ObjectType filter = SpaceMorphObjectFilter(); Rhino.DocObjects.ObjRef objref; Rhino.Commands.Result rc = Rhino.Input.RhinoGet.GetOneObject("Select object to splop", false, filter, out objref); if (rc != Rhino.Commands.Result.Success || objref == null) { return(rc); } Rhino.Geometry.Plane plane = doc.Views.ActiveView.ActiveViewport.ConstructionPlane(); Rhino.Input.Custom.GetObject go = new Rhino.Input.Custom.GetObject(); go.SetCommandPrompt("Surface to splop on"); go.GeometryFilter = Rhino.DocObjects.ObjectType.Surface; go.SubObjectSelect = false; go.EnablePreSelect(false, true); go.DeselectAllBeforePostSelect = false; go.Get(); if (go.CommandResult() != Rhino.Commands.Result.Success) { return(go.CommandResult()); } Rhino.DocObjects.ObjRef srfref = go.Object(0); double u, v; srfref.SurfaceParameter(out u, out v); Rhino.Geometry.Point2d uv = new Rhino.Geometry.Point2d(u, v); Rhino.Geometry.Morphs.SplopSpaceMorph morph = new Rhino.Geometry.Morphs.SplopSpaceMorph(plane, srfref.Surface(), uv); Rhino.Geometry.GeometryBase geom = objref.Geometry().Duplicate(); if (morph.Morph(geom)) { doc.Objects.Add(geom); doc.Views.Redraw(); } return(Rhino.Commands.Result.Success); }
internal static FemDesign.Geometry.FdPoint2d FromRhino(this Rhino.Geometry.Point2d point) { return(new FemDesign.Geometry.FdPoint2d(point.X, point.Y)); }
public static Rhino.Commands.Result Splop(Rhino.RhinoDoc doc) { ObjectType filter = SpaceMorphObjectFilter(); Rhino.DocObjects.ObjRef objref; Rhino.Commands.Result rc = Rhino.Input.RhinoGet.GetOneObject("Select object to splop", false, filter, out objref); if (rc != Rhino.Commands.Result.Success || objref == null) return rc; Rhino.Geometry.Plane plane = doc.Views.ActiveView.ActiveViewport.ConstructionPlane(); Rhino.Input.Custom.GetObject go = new Rhino.Input.Custom.GetObject(); go.SetCommandPrompt("Surface to splop on"); go.GeometryFilter = Rhino.DocObjects.ObjectType.Surface; go.SubObjectSelect = false; go.EnablePreSelect(false, true); go.DeselectAllBeforePostSelect = false; go.Get(); if (go.CommandResult() != Rhino.Commands.Result.Success) return go.CommandResult(); Rhino.DocObjects.ObjRef srfref = go.Object(0); double u, v; srfref.SurfaceParameter(out u, out v); Rhino.Geometry.Point2d uv = new Rhino.Geometry.Point2d(u,v); Rhino.Geometry.Morphs.SplopSpaceMorph morph = new Rhino.Geometry.Morphs.SplopSpaceMorph(plane, srfref.Surface(), uv); Rhino.Geometry.GeometryBase geom = objref.Geometry().Duplicate(); if (morph.Morph(geom)) { doc.Objects.Add(geom); doc.Views.Redraw(); } return Rhino.Commands.Result.Success; }
/// <summary>Utility for picking meshes</summary> /// <param name="mesh">mesh to test</param> /// <param name="pickStyle">mode used for pick test</param> /// <param name="hitPoint">location returned here for point picks</param> /// <param name="hitSurfaceUV"> /// If the mesh has surface parameters, set to the surface parameters of the hit point /// </param> /// <param name="hitTextureCoordinate"> /// If the mesh has texture coordinates, set to the texture coordinate of the hit /// point. Note that the texture coodinates can be set in many different ways /// and this information is useless unless you know how the texture coordinates /// are set on this particular mesh. /// </param> /// <param name="depth"> /// depth returned here for point picks /// LARGER values are NEARER to the camera. /// SMALLER values are FARTHER from the camera. /// </param> /// <param name="distance"> /// planar distance returned here for point picks. /// SMALLER values are CLOSER to the pick point /// </param> /// <param name="hitFlag"> /// For point picks, How to interpret the hitIndex (vertex hit, edge hit, or face hit) /// </param> /// <param name="hitIndex"> /// index of vertex/edge/face that was hit. Use hitFlag to determine what this index /// corresponds to /// </param> /// <returns></returns> public bool PickFrustumTest(Rhino.Geometry.Mesh mesh, MeshPickStyle pickStyle, out Rhino.Geometry.Point3d hitPoint, out Rhino.Geometry.Point2d hitSurfaceUV, out Rhino.Geometry.Point2d hitTextureCoordinate, out double depth, out double distance, out MeshHitFlag hitFlag, out int hitIndex) { hitPoint = Rhino.Geometry.Point3d.Unset; hitSurfaceUV = Rhino.Geometry.Point2d.Unset; hitTextureCoordinate = Rhino.Geometry.Point2d.Unset; depth = -1; distance = -1; hitIndex = -1; IntPtr pConstThis = ConstPointer(); IntPtr pConstMesh = mesh.ConstPointer(); int vef_flag = -1; bool rc = UnsafeNativeMethods.CRhinoPickContext_PickMesh(pConstThis, pConstMesh, (int)pickStyle, ref hitPoint, ref hitSurfaceUV, ref hitTextureCoordinate, ref depth, ref distance, ref vef_flag, ref hitIndex); hitFlag = (MeshHitFlag)vef_flag; return(rc); }
private void pictureBox1_Click(object sender, EventArgs e) { if (String.IsNullOrWhiteSpace(filename)) { return; } string ext = Path.GetExtension(filename).ToUpperInvariant(); if (FileUtils.ImageExtensions.Contains(ext)) { if (ModifierKeys.HasFlag(Keys.Control)) { string script = "!_-PictureFrame \"" + filename + "\""; Rhino.RhinoApp.RunScript(script, true); } else { using (Image image = Image.FromFile(filename)) { var clientRect = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ClientRectangle; var lineUpperLeft = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.ClientToWorld(new Point(clientRect.X, clientRect.Y)); var lineLowerRight = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.ClientToWorld(new Point(clientRect.X + clientRect.Width, clientRect.Y + clientRect.Height)); var lineLowerLeft = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.ClientToWorld(new Point(clientRect.X, clientRect.Y + clientRect.Height)); var plane = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.ConstructionPlane(); double lineParam = 0; Rhino.Geometry.Intersect.Intersection.LinePlane(lineLowerLeft, plane, out lineParam); plane.Origin = lineLowerLeft.PointAt(lineParam); double distanceScreen = lineUpperLeft.DistanceTo(lineLowerRight.PointAt(0), false); double distanceImage = new Rhino.Geometry.Point2d(image.Width, image.Height).DistanceTo(Rhino.Geometry.Point2d.Origin); double scale = distanceScreen / distanceImage; Rhino.RhinoDoc.ActiveDoc.Objects.AddPictureFrame(plane, filename, false, image.Width * scale, image.Height * scale, false, false); Rhino.RhinoDoc.ActiveDoc.Views.Redraw(); } } } if (ext.CompareTo(".GH") == 0) { string script = @"-grasshopper editor load document open """ + filename + @""""; Rhino.RhinoApp.RunScript(script, true); } if (ext.CompareTo(".RVB") == 0) { string file = File.ReadAllText(filename); if (file.IndexOf("Rhino.AddAlias") > 0) { string script = @"-_LoadScript """ + filename + @""""; Rhino.RhinoApp.RunScript(script, true); script = @"_RunScript"; Rhino.RhinoApp.RunScript(script, true); } else { string script = @"-_Runscript (" + file + ")"; Rhino.RhinoApp.RunScript(script, true); } } if (ext.CompareTo(".PY") == 0) { string script = @"-_RunPythonScript """ + filename + @""""; Rhino.RhinoApp.RunScript(script, true); } if (ext.CompareTo(".TXT") == 0) { System.Diagnostics.Process.Start(filename); } if (FileUtils.CadExtensions.Contains(ext)) { if (this.import) { Rhino.FileIO.FileReadOptions readOptions = new Rhino.FileIO.FileReadOptions(); readOptions.ImportMode = true; Rhino.RhinoDoc.ReadFile(filename, readOptions); } else { Rhino.FileIO.FileReadOptions readOptions = new Rhino.FileIO.FileReadOptions(); readOptions.ImportMode = false; readOptions.OpenMode = true; Rhino.RhinoDoc.ReadFile(filename, readOptions); } } }
public void SetValue(Rhino.Geometry.Point2d p) { var value = new Geometry.Vector2d(p.X, p.Y); UnsafeNativeMethods.Rdk_Variant_Set2dVectorValue(NonConstPointer(), value); }
/// <summary> /// Blend color with the decal color at a given point. /// </summary> /// <param name="point">The point in space or, if the decal is uv-mapped, the uv-coordinate of that point.</param> /// <param name="normal">The face normal of the given point.</param> /// <param name="colInOut">The color to blend the decal color to.</param> /// <param name="uvOut">the UV on the texture that the color point was read from.</param> /// <returns>true if the given point hits the decal, else false.</returns> public bool Color(Rhino.Geometry.Point3d point, Rhino.Geometry.Vector3d normal, ref Rhino.Display.Color4f colInOut, ref Rhino.Geometry.Point2d uvOut) { return(1 == UnsafeNativeMethods.Rdk_Decal_Color(ConstPointer(), point, normal, ref colInOut, ref uvOut)); }