Ejemplo n.º 1
0
 /// <summary> btnOrientView is a routine for orienting the view to the current drawing plane </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnOrientView_Click(object sender, EventArgs e)
 {
     //set camera target to center of global drawing plane
     mRhinoDoc.Views.ActiveView.MainViewport.SetCameraLocations(plane1.PointAt(0, 0), plane1.PointAt(0, 0, 100));
     //set camera vector to the reverse of the normal at that point
     //redraw view
     view3.Redraw();
 }
Ejemplo n.º 2
0
        /// <summary> btnBegin3d opens new perspective viewport for 3D drawing </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnBegin3d_Click(object sender, EventArgs e)
        {
            IntPtr hwnd = RhinoApp.MainWindowHandle();

            view3 = mRhinoDoc.Views.ActiveView;
            Rhino.DocObjects.Tables.ViewTable viewTable = mRhinoDoc.Views;
            var newDisplaymode = Rhino.Display.DisplayModeDescription.FindByName("Ghosted");

            Rhino.Display.DisplayModeDescription.UpdateDisplayMode(newDisplaymode);
            view3 = viewTable.Add("squid2", Rhino.Display.DefinedViewportProjection.Perspective, System.Drawing.Rectangle.FromLTRB(1000, 300, 1700, 1000), true);
            view3.Redraw();
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            Rhino.Display.RhinoView view = doc.Views.ActiveView;
            if (null == view)
            {
                return(Result.Failure);
            }

            Rhino.Display.RhinoViewport          viewport           = view.ActiveViewport;
            Rhino.Display.DisplayModeDescription currentDisplayMode = viewport.DisplayMode;
            Rhino.RhinoApp.WriteLine("Viewport in {0} display.", currentDisplayMode.EnglishName);

            Rhino.Display.DisplayModeDescription[] displayModes = Rhino.Display.DisplayModeDescription.GetDisplayModes();

            Rhino.Input.Custom.GetOption go = new Rhino.Input.Custom.GetOption();
            go.SetCommandPrompt("Select new display mode");
            go.AcceptNothing(true);

            foreach (Rhino.Display.DisplayModeDescription displayMode in displayModes)
            {
                string displayName = FormatValidDisplayName(displayMode.EnglishName);
                go.AddOption(displayName);
            }

            Rhino.Input.GetResult rc = go.Get();
            switch (rc)
            {
            case Rhino.Input.GetResult.Option:
            {
                int optionIndex = go.Option().Index;
                if (optionIndex > 0 && optionIndex <= displayModes.Length)
                {
                    Rhino.Display.DisplayModeDescription newDisplayMode = displayModes[optionIndex - 1];
                    if (newDisplayMode.Id != currentDisplayMode.Id)
                    {
                        viewport.DisplayMode = newDisplayMode;
                        view.Redraw();
                        Rhino.RhinoApp.WriteLine("Viewport set to {0} display.", viewport.DisplayMode.EnglishName);
                    }
                }
            }
            break;

            case Rhino.Input.GetResult.Cancel:
                return(Result.Cancel);

            default:
                break;
            }

            return(Result.Success);
        }
Ejemplo n.º 4
0
    public static Rhino.Commands.Result MoveCPlane(Rhino.RhinoDoc doc)
    {
        Rhino.Display.RhinoView view = doc.Views.ActiveView;
        if (view == null)
        {
            return(Rhino.Commands.Result.Failure);
        }

        Rhino.DocObjects.ConstructionPlane cplane = view.ActiveViewport.GetConstructionPlane();
        Point3d origin = cplane.Plane.Origin;

        MoveCPlanePoint gp = new MoveCPlanePoint(cplane);

        gp.SetCommandPrompt("CPlane origin");
        gp.SetBasePoint(origin, true);
        gp.DrawLineFromPoint(origin, true);
        gp.Get();

        if (gp.CommandResult() != Rhino.Commands.Result.Success)
        {
            return(gp.CommandResult());
        }

        Point3d  point = gp.Point();
        Vector3d v     = origin - point;

        if (v.IsTiny())
        {
            return(Rhino.Commands.Result.Nothing);
        }

        Plane pl = cplane.Plane;

        pl.Origin    = point;
        cplane.Plane = pl;
        view.ActiveViewport.SetConstructionPlane(cplane);
        view.Redraw();
        return(Rhino.Commands.Result.Success);
    }
    public static Rhino.Commands.Result AddBackgroundBitmap(Rhino.RhinoDoc doc)
    {
        Rhino.RhinoApp.WriteLine("hey");
        // Allow the user to select a bitmap file
        Rhino.UI.OpenFileDialog fd = new Rhino.UI.OpenFileDialog();
        fd.Filter = "Image Files (*.bmp;*.png;*.jpg)|*.bmp;*.png;*.jpg";
        if (!fd.ShowDialog())
        {
            return(Rhino.Commands.Result.Cancel);
        }

        // Verify the file that was selected
        System.Drawing.Image image;
        try
        {
            image = System.Drawing.Image.FromFile(fd.FileName);
        }
        catch (Exception)
        {
            return(Rhino.Commands.Result.Failure);
        }

        // Allow the user to pick the bitmap origin
        Rhino.Input.Custom.GetPoint gp = new Rhino.Input.Custom.GetPoint();
        gp.SetCommandPrompt("Bitmap Origin");
        gp.ConstrainToConstructionPlane(true);
        gp.Get();
        if (gp.CommandResult() != Rhino.Commands.Result.Success)
        {
            return(gp.CommandResult());
        }

        // Get the view that the point was picked in.
        // This will be the view that the bitmap appears in.
        Rhino.Display.RhinoView view = gp.View();
        if (view == null)
        {
            view = doc.Views.ActiveView;
            if (view == null)
            {
                return(Rhino.Commands.Result.Failure);
            }
        }

        // Allow the user to specify the bitmap with in model units
        Rhino.Input.Custom.GetNumber gn = new Rhino.Input.Custom.GetNumber();
        gn.SetCommandPrompt("Bitmap width");
        gn.SetLowerLimit(1.0, false);
        gn.Get();
        if (gn.CommandResult() != Rhino.Commands.Result.Success)
        {
            return(gn.CommandResult());
        }

        // Cook up some scale factors
        double w            = gn.Number();
        double image_width  = image.Width;
        double image_height = image.Height;
        double h            = w * (image_height / image_width);

        Rhino.Geometry.Plane plane = view.ActiveViewport.ConstructionPlane();
        plane.Origin = gp.Point();
        view.ActiveViewport.SetTraceImage(fd.FileName, plane, w, h, false, false);
        view.Redraw();
        return(Rhino.Commands.Result.Success);
    }
Ejemplo n.º 6
0
        /// <summary> btnBegin3d opens new perspective viewport for 3D drawing </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnBegin3d_Click(object sender, EventArgs e)
        {
            IntPtr hwnd = RhinoApp.MainWindowHandle();

            view3 = mRhinoDoc.Views.ActiveView;
            Rhino.DocObjects.Tables.ViewTable viewTable = mRhinoDoc.Views;
            var newDisplaymode = Rhino.Display.DisplayModeDescription.FindByName("Ghosted");
            Rhino.Display.DisplayModeDescription.UpdateDisplayMode(newDisplaymode);
            view3 = viewTable.Add("squid2", Rhino.Display.DefinedViewportProjection.Perspective, System.Drawing.Rectangle.FromLTRB(1000, 300, 1700, 1000), true);
            view3.Redraw();
        }