//--------------------------------------------------------------------------------------------------

        public bool ScreenToPoint(Pln plane, int screenX, int screenY, out Pnt resultPnt)
        {
            try
            {
                double xv = 0, yv = 0, zv = 0;
                double vx = 0, vy = 0, vz = 0;

                V3dView.Convert(screenX, screenY, ref xv, ref yv, ref zv);
                V3dView.Proj(ref vx, ref vy, ref vz);

                gp_Lin line = new gp_Lin(new Pnt(xv, yv, zv), new Dir(vx, vy, vz));
                IntAna_IntConicQuad intersection = new IntAna_IntConicQuad(line, plane, Precision.Angular(), 0, 0);

                if (intersection.IsDone() &&
                    !intersection.IsParallel() &&
                    intersection.NbPoints() > 0)
                {
                    resultPnt = intersection.Point(1);
                    return(true);
                }
            }
            catch (Exception)
            {
                Debug.Assert(false);
            }

            resultPnt = new Pnt();
            return(false);
        }
        //--------------------------------------------------------------------------------------------------

        public Pnt ProjectToGrid(int screenX, int screenY)
        {
            double px = 0, py = 0, pz = 0;

            V3dView.ConvertToGrid(screenX, screenY, ref px, ref py, ref pz);
            return(new Pnt(px, py, pz));
        }
        //--------------------------------------------------------------------------------------------------

        public Pnt ProjectToGrid(Pnt point)
        {
            double px = 0, py = 0, pz = 0;

            V3dView.ConvertToGrid(point.X, point.Y, point.Z, ref px, ref py, ref pz);
            return(new Pnt(px, py, pz));
        }
        //--------------------------------------------------------------------------------------------------

        public void Init()
        {
            if (V3dView != null)
            {
                return;
            }

            V3dView = Workspace.V3dViewer.CreateView();

            AisAnimationCamera = new AIS_AnimationCamera(new TCollection_AsciiString("ViewCamera"), V3dView);

            V3dView.SetBgGradientColors(Quantity_NameOfColor.Quantity_NOC_SLATEGRAY3.ToColor(), Quantity_NameOfColor.Quantity_NOC_SLATEGRAY4.ToColor(), Aspect_GradientFillMethod.Aspect_GFM_VER, false);
            _ShowTriedron(true);

            var renderParams = V3dView.ChangeRenderingParams();

            renderParams.NbMsaaSamples         = 4;
            renderParams.IsAntialiasingEnabled = true;
            renderParams.TransparencyMethod    = Graphic3d_RenderTransparentMethod.Graphic3d_RTM_BLEND_OIT;
            renderParams.Method                     = Graphic3d_RenderingMode.Graphic3d_RM_RASTERIZATION;
            renderParams.RaytracingDepth            = 3;
            renderParams.IsShadowEnabled            = true;
            renderParams.IsReflectionEnabled        = true;
            renderParams.IsAntialiasingEnabled      = true;
            renderParams.IsTransparentShadowEnabled = true;

            // Reinit view parameters
            TargetPoint = _TargetPoint;
            EyePoint    = _EyePoint;
            Scale       = _Scale;
            Twist       = _Twist;
            UpdateRenderMode();
        }
 public ViewInput(V3dView view, V3dViewer viewer, Control control)
     : base(InputNames.View)
 {
     _view    = view;
     _viewer  = viewer;
     _manager = new OcLayer2DManager(view, control);
 }
        //--------------------------------------------------------------------------------------------------

        public Dir GetUpDirection()
        {
            double xUp = 0, yUp = 0, zUp = 0;

            V3dView.Up(ref xUp, ref yUp, ref zUp);
            return(new Dir(xUp, yUp, zUp));
        }
        //--------------------------------------------------------------------------------------------------

        public Ax1 ViewAxis(int screenX, int screenY)
        {
            double px = 0, py = 0, pz = 0;

            V3dView.Convert(screenX, screenY, ref px, ref py, ref pz);
            return(new Ax1(new Pnt(px, py, pz), GetViewDirection()));
        }
        //--------------------------------------------------------------------------------------------------

        public void Dispose()
        {
            AisAnimationCamera?.Dispose();
            AisAnimationCamera = null;

            V3dView?.Dispose();
            V3dView = null;
        }
Example #9
0
        public DirectCoordinateMouseEventsPipe(V3dView view)
            : base(InputNames.Mouse3DEventsPipe)
        {
            Plane = new gpPln(new gpAx3());

            var       wnd = view.Window();
            WNTWindow wnt = wnd.Convert <WNTWindow>();
        }
Example #10
0
        /// <summary>
        ///   Initializes the OpenCascade views and assigns them View handles.
        /// </summary>
        public static void Setup(ref Graphic3dWNTGraphicDevice device,
                                 ref V3dViewer viewer,
                                 ref AISInteractiveContext context,
                                 out V3dView view,
                                 IOccContainerMultiView attachedView)
        {
            // Initialize the Device
            try
            {
                device = new Graphic3dWNTGraphicDevice();
                Debug.Assert(device != null);
            }
            catch (Exception ex)
            {
                Debug.Assert(false, ex.Message);
            }

            // Create the V3d Viewer
            try
            {
                //QuantityColor color = new QuantityColor(70 / 255.0, 82 / 255.0, 102 / 255.0, QuantityTypeOfColor.Quantity_TOC_RGB);
                viewer = new V3dViewer(device, "Visu3D", "", 1000, V3dTypeOfOrientation.V3d_XposYnegZpos,
                                       QuantityNameOfColor.Quantity_NOC_GRAY30,
                                       V3dTypeOfVisualization.V3d_ZBUFFER, V3dTypeOfShadingModel.V3d_GOURAUD,
                                       V3dTypeOfUpdate.V3d_WAIT, true, true,
                                       V3dTypeOfSurfaceDetail.V3d_TEX_NONE);

                Debug.Assert(viewer != null);
                if (CreateLights(viewer))
                {
                    viewer.SetLightOn();
                }
            }
            catch (Exception ex)
            {
                Debug.Assert(false, ex.Message);
            }

            // Create the Interactive Context
            try
            {
                context = new AISInteractiveContext(viewer);
                Debug.Assert(context != null);
                context.HilightColor = (QuantityNameOfColor.Quantity_NOC_RED);
            }
            catch (Exception ex)
            {
                Debug.Assert(false, ex.Message);
            }

            // Create an OpenCascade view for each visible Custom controls
            CreateView(device, viewer, out view, attachedView);

            //PaintBackground(view, Color.LightBlue, Color.Blue);

            SetVisualMode(context);
        }
Example #11
0
 public OcLayer2DManager(V3dView view, Control control)
 {
     _control = control;
     _layer   = new Visual3dLayer(view.View.ViewManager, AspectTypeOfLayer.Aspect_TOL_OVERLAY, false);
     if (_control == null)
     {
         return;
     }
     control.Resize += ViewResize;
 }
Example #12
0
 protected override void OnReceiveInputData(string inputName, object data)
 {
     var dataPackage = (DataPackage) data;
     switch (inputName)
     {
         case InputNames.View:
             var viewItems = dataPackage.Get<ViewInput.Items>();
             View = viewItems.View;
             break;
     }
 }
        //--------------------------------------------------------------------------------------------------

        void _ShowTriedron(bool visible)
        {
            if (visible)
            {
                V3dView.TriedronDisplay(Aspect_TypeOfTriedronPosition.Aspect_TOTP_LEFT_LOWER, Quantity_NameOfColor.Quantity_NOC_ALICEBLUE.ToColor(), 0.1, V3d_TypeOfVisualization.V3d_ZBUFFER);
            }
            else
            {
                V3dView.TriedronErase();
            }
        }
        //--------------------------------------------------------------------------------------------------

        public gp_Sphere GetOrbitSphere()
        {
            double xEye = 0, yEye = 0, zEye = 0, xAt = 0, yAt = 0, zAt = 0;

            V3dView.Eye(ref xEye, ref yEye, ref zEye);
            V3dView.At(ref xAt, ref yAt, ref zAt);
            Pnt eyePoint  = new Pnt(xEye, yEye, zEye);
            Pnt atPoint   = new Pnt(xAt, yAt, zAt);
            var eyeVector = new Vec(eyePoint, atPoint);

            return(new gp_Sphere(new Ax3(atPoint, Dir.DZ, -Dir.DY.Rotated(Ax1.OZ, V3dView.Twist())), eyeVector.Magnitude()));
        }
Example #15
0
        //--------------------------------------------------------------------------------------------------

        public bool PointToScreen(Pnt pnt, out int screenX, out int screenY)
        {
            try
            {
                int x = 0, y = 0;
                V3dView.Convert(pnt.X, pnt.Y, pnt.Z, ref x, ref y);
                screenX = x;
                screenY = y;
                return(true);
            }
            catch (Exception)
            {
                Debug.Assert(false);
            }

            screenX = 0;
            screenY = 0;
            return(false);
        }
        //--------------------------------------------------------------------------------------------------

        internal void UpdateRenderMode()
        {
            if (V3dView == null)
            {
                return;
            }

            V3dView.SetComputedMode(_RenderMode == RenderModes.HLR);

            var renderParams = V3dView.ChangeRenderingParams();

            if (_RenderMode == RenderModes.Raytraced)
            {
                renderParams.Method = Graphic3d_RenderingMode.Graphic3d_RM_RAYTRACING;
            }
            else
            {
                renderParams.Method = Graphic3d_RenderingMode.Graphic3d_RM_RASTERIZATION;
            }
        }
        //--------------------------------------------------------------------------------------------------

        #endregion

        #region Screen Space Conversions

        public bool ScreenToPoint(int screenX, int screenY, out Pnt resultPnt)
        {
            try
            {
                var    viewPlane = GetViewPlane();
                double x = 0, y = 0, z = 0;
                V3dView.Convert(screenX, screenY, ref x, ref y, ref z);
                Pnt   convertedPoint        = new Pnt(x, y, z);
                Pnt2d convertedPointOnPlane = ProjLib.Project(viewPlane, convertedPoint);

                resultPnt = ElSLib.Value(convertedPointOnPlane.X, convertedPointOnPlane.Y, viewPlane);
                return(true);
            }
            catch (Exception)
            {
                Debug.Assert(false);
            }

            resultPnt = Pnt.Origin;
            return(false);
        }
        public CutDialog(Document document, V3dView view, SceneSelectedEntity sceneSelectedEntity)
        {
            InitializeComponent();
            _document = document;
            _view     = view;

            var selNode    = sceneSelectedEntity.Node;
            var sketchNode = AutoGroupLogic.FindSketchNode(selNode);

            _cutNode = new NodeBuilder(document, FunctionNames.Cut);
            _cutNode[0].Reference = sketchNode;

            cutTypeComboBox.Items.Add(CutThroughAll);
            cutTypeComboBox.Items.Add(CutToDepth);
            cutTypeComboBox.SelectedIndex = 0;

            CutDepth = 100;


            UpdateView();
        }
Example #19
0
        private static void CreateView(WNTGraphicDevice device, V3dViewer viewer, out V3dView view,
                                       IOccContainerMultiView attachedView)
        {
            // Assign to each Custom control an OpenCascade View

            view = null;
            Ensure.AreEqual(attachedView.VisibleViewCount, 1);
            for (var i = 0; i < attachedView.VisibleViewCount; i++)
            {
                view = viewer.CreateView;
                Debug.Assert(view != null);
                view.SetDegenerateModeOn();
                view.Transparency = true;

                view.SurfaceDetail = V3dTypeOfSurfaceDetail.V3d_TEX_ALL;

                // Attach to the OpenCascade view a Custom control
                var control = attachedView.GetView(i);
                if (control == null)
                {
                    continue;
                }
                //IntPtr attachedViewHandle = (attachedView as Form).Handle;
                var aWntWindow = new WNTWindow(device, control.Handle, QuantityNameOfColor.Quantity_NOC_MATRAGRAY);
                Debug.Assert(aWntWindow != null);

                view.SetWindow(aWntWindow);
                view.TriedronDisplay(AspectTypeOfTriedronPosition.Aspect_TOTP_LEFT_LOWER,
                                     QuantityNameOfColor.Quantity_NOC_WHITE, 0.02,
                                     V3dTypeOfVisualization.V3d_WIREFRAME);

                if (!aWntWindow.IsMapped)
                {
                    aWntWindow.Map();
                }
                //view[i].SetAntialiasingOn();
                //view[i].Redraw();
                view.MustBeResized();
            }
        }
Example #20
0
        private bool CreateView3D()
        {
            if (viewer3d != null)
            {
                view3d = viewer3d.CreateView;
                Debug.Assert(view3d != null);
                if (view3d != null)
                {
                    //view3d.SetDegenerateModeOn();
                    //view3d.SetTransparency(true);

                    //view3d.SetSurfaceDetail(OCV3d_TypeOfSurfaceDetail.V3d_TEX_ALL);

                    // Attach to the OpenCascade view a Custom control
                    Control control = ocView;    // attachedView.GetView(i);
                    if (control != null)
                    {
                        //IntPtr attachedViewHandle = (attachedView as Form).Handle;
                        var aWNTWindow = new WNTWindow(device3d, control.Handle, QuantityNameOfColor.Quantity_NOC_MATRAGRAY);     // manual default
                        Debug.Assert(aWNTWindow != null);
                        if (aWNTWindow != null)
                        {
                            view3d.Window = aWNTWindow;
                            view3d.TriedronDisplay(AspectTypeOfTriedronPosition.Aspect_TOTP_LEFT_LOWER, QuantityNameOfColor.Quantity_NOC_WHITE, 0.02, V3dTypeOfVisualization.V3d_WIREFRAME);     // manual default

                            if (!aWNTWindow.IsMapped)
                            {
                                aWNTWindow.Map();
                            }
                        }
                        view3d.Redraw();
                        view3d.MustBeResized();
                    }
                }
                return(true);
            }

            return(false);
        }
        //--------------------------------------------------------------------------------------------------

        #endregion

        #region Image

        public Bitmap RenderToBitmap(uint width, uint height)
        {
            if (V3dView == null || width == 0 || height == 0)
            {
                return(null);
            }

            try
            {
                _ShowTriedron(false);
                var pixmap = new Image_AlienPixMap();
                pixmap.InitZero(Image_Format.Image_Format_RGB, width, height);
                V3dView.ToPixMap(pixmap, (int)width, (int)height);
                _ShowTriedron(true);

                return(Occt.Helper.PixMapHelper.ConvertToBitmap(pixmap));
            }
            catch (Exception)
            {
                _ShowTriedron(true);
                return(null);
            }
        }
Example #22
0
 public bool SeeOrHide(V3dView aView)
 {
     return(V3d_PositionLight_SeeOrHide36A6FAB7(Instance, aView.Instance));
 }
 public void Display(V3dView aView, QuantityColor aColor)
 {
     V3d_Plane_Display8A383826(Instance, aView.Instance, aColor.Instance);
 }
Example #24
0
 public void ClearSensitive(V3dView aView)
 {
     StdSelect_ViewerSelector3d_ClearSensitive36A6FAB7(Instance, aView.Instance);
 }
Example #25
0
 public void DisplayAreas(SelectMgrSelection aSel, V3dView aView, bool ClearOthers)
 {
     StdSelect_ViewerSelector3d_DisplayAreasE07C6821(Instance, aSel.Instance, aView.Instance, ClearOthers);
 }
Example #26
0
 public void DisplaySensitive(V3dView aView)
 {
     StdSelect_ViewerSelector3d_DisplaySensitive36A6FAB7(Instance, aView.Instance);
 }
Example #27
0
 public void ClearAreas(V3dView aView)
 {
     StdSelect_ViewerSelector3d_ClearAreas36A6FAB7(Instance, aView.Instance);
 }
Example #28
0
 public void DisplayAreas(V3dView aView)
 {
     StdSelect_ViewerSelector3d_DisplayAreas36A6FAB7(Instance, aView.Instance);
 }
Example #29
0
 public void Pick(int XPMin, int YPMin, int XPMax, int YPMax, V3dView aView)
 {
     StdSelect_ViewerSelector3d_Pick12E48EEC(Instance, XPMin, YPMin, XPMax, YPMax, aView.Instance);
 }
Example #30
0
 public void Pick(int XPix, int YPix, V3dView aView)
 {
     StdSelect_ViewerSelector3d_Pick556D776C(Instance, XPix, YPix, aView.Instance);
 }