/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// #ifndef OD_SR_CAMERA_MOVEMENT_RECOGNIZER #define OD_SR_CAMERA_MOVEMENT_RECOGNIZER #include "Gs/GsViewImpl.h" #include class OdGsSrVectorizerDevice; class OdGsSrVectorizeView; /* * Camera movement type with associated data */ class CameraMovementType final { public: enum Type { None, PanAlongScreen, AnotherMovement }; /** * Movement-specific data */ struct PanData { int pixelsX; int pixelsY; inline bool isZero() { return pixelsX == 0 && pixelsY == 0; } }; public: static CameraMovementType createPan(int pixelsX, int pixelsY); static CameraMovementType createAnother(); static CameraMovementType createNone(); const PanData& panData() const; operator CameraMovementType::Type() const; bool operator!=(const CameraMovementType& other) const = delete; bool operator==(const CameraMovementType& other) const = delete; bool hasSameType(const CameraMovementType& other); private: CameraMovementType(); Type m_type; union { PanData m_panData; }; }; class ViewportChangingType final { public: enum Type { None, Movement, Resizing, BorderChanged }; /** * Movement-specific data */ struct MovementData { int pixelsX; int pixelsY; }; struct ResizingData { OdGeVector2d shiftLL; OdGeVector2d shiftUR; }; public: static ViewportChangingType createMovement(int pixelsX, int pixelsY); static ViewportChangingType createResizing(); static ViewportChangingType createBorderChanged(); static ViewportChangingType createNone(); const MovementData& movementData() const; bool operator!=(const ViewportChangingType& other) const = delete; operator ViewportChangingType::Type() const; private: ViewportChangingType(); Type m_type; union { ResizingData m_resizingData; MovementData m_movementData; }; }; /** * Complete camera state parameters */ struct CameraState { OdGePoint3d position; // Camera position OdGePoint3d target; // Look-at target point OdGeVector3d upVector; // Camera up vector double fieldWidth; // View field width double fieldHeight; // View field height OdGsView::Projection projectionType; // Parallel/Perspective CameraState(); }; /** * Recognizes camera movements and notifies update context */ bool getExactViewBounds(const OdGsSrVectorizeView* pView, OdGsDCRect& extentsRect); class OdSrCameraMovementRecognizer { private: OdGsSrVectorizerDevice* m_device; CameraMovementType m_lastMovementType; std::map m_postUpdateStateStorage; CameraMovementType::PanData getScreenDiff(const OdGsViewImpl* view, int idxView) const; public: static CameraState calcCameraState(const OdGsSrVectorizeView* pView); bool isBoundsOffscreen(const OdGsSrVectorizeView* pView, int shiftX, int shiftY) const; /** * Constructor * @param device Target vectorizer device * @param context Update context for notifications */ OdSrCameraMovementRecognizer( OdGsSrVectorizerDevice* device); ~OdSrCameraMovementRecognizer() = default; /** * Determines current camera movement type based on state change * @return Type of detected camera movement */ CameraMovementType recognizeMovementType(const OdGsSrVectorizeView* view, int viewIdx) const; void postUpdate(); }; #endif // OD_SR_CAMERA_MOVEMENT_RECOGNIZER