1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00
occt/src/OpenGl/OpenGl_Window.hxx
kgv 879768fbf2 0032886: Visualization, V3d_View - introduce interface for creating a subview
V3d_View/Graphic3d_CView pair has been extended to define subview within the other V3d_View instance.
The initialization is done in form of V3d_View::SetWindow() taking parent V3d_View instance on input.

Subview definition includes dimensions defined as a fraction of a parent view and offset from a corner.
This scheme allows splitting window into several subviews automatically occupying entire viewport,
like splitting window into two vertial subviews (100%x50% + 100%x50%),
three horizontal subviews (33%x100% + 30%x100% + 30%x100%),
1 + 2 stacked subviews (50%x100% + 50%x50% + 50%x50%),
as well as thumbnail-alike subviews displayed on top of another larger view.

OpenGl_View::Redraw() blits content of subviews into the window within immediate redraw step.

AIS_ViewController::FlushViewEvents() has been extended
to re-calculate mouse input into local subview coordinates.
AIS_ViewController::handleViewRedraw() first redraws subviews and then parent views.
Introduced new callback AIS_ViewController::OnSubviewChanged()
to switch input focus to another subview on mouse click,
implemented by ViewerTest_EventManager (has to be done at application level).

vinit command has been extended with parameters -subview and -parent to create a subview.
In addition, view dimension arguments now can be defined as a fraction of screen size instead of pixels.
2022-04-15 18:23:16 +03:00

109 lines
3.7 KiB
C++

// Created on: 2011-09-20
// Created by: Sergey ZERCHANINOV
// Copyright (c) 2011-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef OpenGl_Window_HeaderFile
#define OpenGl_Window_HeaderFile
#include <Aspect_RenderingContext.hxx>
#include <Aspect_Window.hxx>
#include <OpenGl_GlCore11.hxx>
#include <OpenGl_Caps.hxx>
#include <Standard_Transient.hxx>
#if defined(__APPLE__)
#import <TargetConditionals.h>
#endif
#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
#ifdef __OBJC__
@class UIView;
#else
struct UIView;
#endif
#endif
class OpenGl_Context;
class OpenGl_GraphicDriver;
DEFINE_STANDARD_HANDLE(OpenGl_Window,Standard_Transient)
//! This class represents low-level wrapper over window with GL context.
//! The window itself should be provided to constructor.
class OpenGl_Window : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(OpenGl_Window, Standard_Transient)
public:
//! Empty constructor.
Standard_EXPORT OpenGl_Window();
//! Initialize the new window - prepare GL context for specified window.
//! Throws exception in case of failure.
Standard_EXPORT void Init (const Handle(OpenGl_GraphicDriver)& theDriver,
const Handle(Aspect_Window)& thePlatformWindow,
const Handle(Aspect_Window)& theSizeWindow,
Aspect_RenderingContext theGContext,
const Handle(OpenGl_Caps)& theCaps,
const Handle(OpenGl_Context)& theShareCtx);
//! Destructor
Standard_EXPORT virtual ~OpenGl_Window();
//! Resizes the window.
Standard_EXPORT virtual void Resize();
//! Return platform window.
const Handle(Aspect_Window)& PlatformWindow() { return myPlatformWindow; }
//! Return window object defining dimensions.
const Handle(Aspect_Window)& SizeWindow() { return mySizeWindow; }
Standard_Integer Width() const { return mySize.x(); }
Standard_Integer Height() const { return mySize.y(); }
//! Return OpenGL context.
const Handle(OpenGl_Context)& GetGlContext() const { return myGlContext; }
//! Makes GL context for this window active in current thread
Standard_EXPORT virtual Standard_Boolean Activate();
//! Sets swap interval for this window according to the context's settings.
Standard_EXPORT void SetSwapInterval (Standard_Boolean theToForceNoSync);
protected:
//! Activates GL context and setup viewport.
Standard_EXPORT void init();
protected:
Handle(OpenGl_Context) myGlContext;
Standard_Boolean myOwnGContext; //!< set to TRUE if GL context was not created by this class
Handle(Aspect_Window) myPlatformWindow; //!< software platform window wrapper
Handle(Aspect_Window) mySizeWindow; //!< window object defining dimensions
#if defined(__APPLE__)
#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
UIView* myUIView;
#endif
Graphic3d_Vec2i mySizePt; //!< window width x height in logical units
#endif
Graphic3d_Vec2i mySize; //!< window width x height in pixels
Standard_Integer mySwapInterval;//!< last assigned swap interval (VSync) for this window
};
#endif //_OpenGl_Window_Header