1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-21 10:13:43 +03:00
occt/src/ViewerTest/ViewerTest_EventManager.hxx
aba 2108d9a25b 0028954: Visualization - implement interactive object for camera manipulations
Added new class AIS_ViewCube implementing interactive cube
displaying orientation of the main axes of the model space in the viewer.
Each side, edge, or corner of the cube corresponds to particular orientation of the camera,
and the class provides methods to move the camera to corresponding position (with animation if needed).

AIS_InteractiveContext::LastActiveView(), added new property returning the last View processed by MoveTo() event.
AIS_InteractiveContext::BoundingBoxOfSelection(), added method returning bounding box of selected objects.
SelectMgr_EntityOwner::HandleMouseClick(), added new callback for handling
mouse clicks by owner itself without automatic highlighting and clearing previous selection.
Called by AIS_InteractiveContext::Select() method.

AIS_ViewController::ViewAnimation() has been extened with camera animation propery,
which can be bound to AIS_ViewCube for smooth embedding into event loop.

Prs3d_ToolDisk has been extended with parameters specifying angle range.
Graphic3d_MaterialAspect now initializes all coefficients to 1.0
when Graphic3d_NOM_UserDefined is passed to class constructor.
AIS_AnimationCamera::update() now sets the end camera position if animation duration is 0.
Prs3d_DatumAspect, added missing setters.

New command vviewcube has been added.
2019-07-19 12:23:01 +03:00

108 lines
3.7 KiB
C++

// Created on: 1998-08-27
// Created by: Robert COUBLANC
// Copyright (c) 1998-1999 Matra Datavision
// Copyright (c) 1999-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 _ViewerTest_EventManager_HeaderFile
#define _ViewerTest_EventManager_HeaderFile
#include <AIS_ViewController.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TCollection_AsciiString.hxx>
class AIS_InteractiveContext;
class V3d_View;
DEFINE_STANDARD_HANDLE(ViewerTest_EventManager, Standard_Transient)
//! used to manage mouse event (move,select,shiftselect)
//! By default the events are transmitted to interactive context.
class ViewerTest_EventManager : public Standard_Transient, public AIS_ViewController
{
DEFINE_STANDARD_RTTIEXT(ViewerTest_EventManager, Standard_Transient)
public:
//! Return TRUE if View should be closed on escape.
static Standard_Boolean& ToCloseViewOnEscape()
{
static Standard_Boolean Draw_ToCloseViewOnEsc = Standard_False;
return Draw_ToCloseViewOnEsc;
}
//! Return TRUE if Draw Harness should exit on closing View.
static Standard_Boolean& ToExitOnCloseView()
{
static Standard_Boolean Draw_ToExitOnCloseView = Standard_False;
return Draw_ToExitOnCloseView;
}
//! Use global camera animation object shared across all Views in ViewerTest.
Standard_EXPORT static const Handle(AIS_AnimationCamera)& GlobalViewAnimation();
public:
//! Main constructor.
Standard_EXPORT ViewerTest_EventManager(const Handle(V3d_View)& aView, const Handle(AIS_InteractiveContext)& aCtx);
//! Destructor.
Standard_EXPORT virtual ~ViewerTest_EventManager();
//! Return interactive context.
const Handle(AIS_InteractiveContext)& Context() const { return myCtx; }
//! Returns TRUE if picking point mode has been enabled (for VPick command).
Standard_Boolean ToPickPoint() const { return myToPickPnt; }
//! Start picking point for VPick command.
void StartPickPoint (const char* theArgX,
const char* theArgY,
const char* theArgZ)
{
myToPickPnt = Standard_True;
myPickPntArgVec[0] = theArgX;
myPickPntArgVec[1] = theArgY;
myPickPntArgVec[2] = theArgZ;
}
//! Handle mouse button press/release event.
Standard_EXPORT virtual bool UpdateMouseButtons (const Graphic3d_Vec2i& thePoint,
Aspect_VKeyMouse theButtons,
Aspect_VKeyFlags theModifiers,
bool theIsEmulated) Standard_OVERRIDE;
//! Release key.
Standard_EXPORT virtual void KeyUp (Aspect_VKey theKey,
double theTime) Standard_OVERRIDE;
//! Redraw the View on an Expose Event
Standard_EXPORT virtual void ProcessExpose();
//! Resize View.
Standard_EXPORT virtual void ProcessConfigure();
//! Handle KeyPress event.
Standard_EXPORT void ProcessKeyPress (Aspect_VKey theKey);
private:
Handle(AIS_InteractiveContext) myCtx;
Handle(V3d_View) myView;
TCollection_AsciiString myPickPntArgVec[3];
Standard_Boolean myToPickPnt;
};
#endif // _ViewerTest_EventManager_HeaderFile