Added an argument to OpenGl_GraphicDriver::GetSharedContext() for returning only currently bound OpenGL context.
SelectMgr_SelectingVolumeManager::GetMousePosition() - added getter returning mouse coordinates.
// function : GetSharedContext
// purpose :
// =======================================================================
-const Handle(OpenGl_Context)& OpenGl_GraphicDriver::GetSharedContext() const
+const Handle(OpenGl_Context)& OpenGl_GraphicDriver::GetSharedContext (bool theBound) const
{
if (myMapOfView.IsEmpty())
{
return TheNullGlCtx;
}
- NCollection_Map<Handle(OpenGl_View)>::Iterator anIter (myMapOfView);
- for (; anIter.More(); anIter.Next())
+ for (NCollection_Map<Handle(OpenGl_View)>::Iterator aViewIter (myMapOfView); aViewIter.More(); aViewIter.Next())
{
- Handle(OpenGl_Window) aWindow = anIter.Value()->GlWindow();
- if (aWindow.IsNull())
+ if (const Handle(OpenGl_Window)& aWindow = aViewIter.Value()->GlWindow())
{
- continue;
+ if (!theBound)
+ {
+ return aWindow->GetGlContext();
+ }
+ else if (aWindow->GetGlContext()->IsCurrent())
+ {
+ return aWindow->GetGlContext();
+ }
}
-
- return aWindow->GetGlContext();
}
return TheNullGlCtx;
//! Method to retrieve valid GL context.
//! Could return NULL-handle if no window created by this driver.
- Standard_EXPORT const Handle(OpenGl_Context)& GetSharedContext() const;
+ //! @param theBound if TRUE then currently bound context will be returned,
+ //! any context will be returned otherwise
+ Standard_EXPORT const Handle(OpenGl_Context)& GetSharedContext (bool theBound = false) const;
#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__)
Aspect_Display getRawGlDisplay() const { return myEglDisplay; }
//! correspondingly) onto far view frustum plane
virtual gp_Pnt GetFarPickedPnt() const = 0;
+ //! Return mouse coordinates for Point selection mode.
+ virtual gp_Pnt2d GetMousePosition() const = 0;
+
//! Stores plane equation coefficients (in the following form:
//! Ax + By + Cz + D = 0) to the given vector
virtual void GetPlanes (NCollection_Vector<NCollection_Vec4<Standard_Real> >& thePlaneEquations) const = 0;
//! correspondingly) onto far view frustum plane
inline const gp_Pnt& GetFarPnt() const { return myFarPickedPnt; }
+ //! Return mouse coordinates.
+ const gp_Pnt2d& GetMousePosition() const { return myMousePos; }
+
//! Stores plane equation coefficients (in the following form:
//! Ax + By + Cz + D = 0) to the given vector
Standard_EXPORT virtual void GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const Standard_OVERRIDE;
//! correspondingly) onto far view frustum plane
Standard_EXPORT virtual gp_Pnt GetFarPickedPnt() const Standard_OVERRIDE;
+ //! Return mouse coordinates for Point selection mode.
+ virtual gp_Pnt2d GetMousePosition() const Standard_OVERRIDE
+ {
+ if (myActiveSelectionType != Point)
+ {
+ return gp_Pnt2d (RealLast(), RealLast());
+ }
+ const SelectMgr_RectangularFrustum* aFr = reinterpret_cast<const SelectMgr_RectangularFrustum*> (mySelectingVolumes[myActiveSelectionType / 2].get());
+ return aFr->GetMousePosition();
+ }
+
//! Returns active selecting volume that was built during last
//! run of OCCT selection mechanism
Handle(SelectMgr_BaseFrustum) ActiveVolume() const