--- /dev/null
+// Created on: 2020-07-05
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2020 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 _AIS_DragItem_HeaderFile
+#define _AIS_DragItem_HeaderFile
+
+#include <AIS_DragItem.hxx>
+
+class V3d_View;
+
+//! Interface to provide drag processing.
+//! To use this interface, inherit AIS_InteractiveObject from it. After, implement functionality to
+//! happen by drag action.
+//! To perform transformation of an object use next code in your event processing chain:
+//! @code
+//! // catch mouse button down event
+//! if (aDraggedObject->HasActiveMode())
+//! {
+//! aDraggedObject->StartTransform (anXPix, anYPix, aV3dView);
+//! }
+//! ...
+//! // or track mouse move event
+//! if (aDraggedObject->HasActiveMode())
+//! {
+//! aDraggedObject->Transform (anXPix, anYPix, aV3dView);
+//! aV3dView->Redraw();
+//! }
+//! ...
+//! // or catch mouse button up event (apply) or escape event (cancel)
+//! aDraggedObject->StopTransform(/*Standard_Boolean toApply*/);
+//! @endcode
+class AIS_DragItem
+{
+public:
+ //! Constructs a drag item.
+ Standard_EXPORT AIS_DragItem() {}
+
+public:
+ //! @return true if this drag item participates in dragging
+ virtual Standard_Boolean HasActiveMode() const = 0;
+
+ //! Init start (reference) transformation.
+ //! @warning It is used in chain with StartTransform-Transform(gp_Trsf)-StopTransform
+ virtual void StartTransform (const Standard_Integer theX,
+ const Standard_Integer theY,
+ const Handle(V3d_View)& theView) = 0;
+
+ //! Reset start (reference) transformation.
+ //! @param theToApply [in] option to apply or to cancel the started transformation.
+ virtual void StopTransform (const Standard_Boolean theToApply = Standard_True) = 0;
+
+ //! Apply transformation made from mouse moving from start position
+ virtual gp_Trsf Transform (const Standard_Integer theX,
+ const Standard_Integer theY,
+ const Handle(V3d_View)& theView) = 0;
+};
+
+#endif // _AIS_DragItem_HeaderFile
#define _AIS_Manipulator_HeaderFile
#include <AIS_InteractiveObject.hxx>
+#include <AIS_DragItem.hxx>
#include <AIS_ManipulatorMode.hxx>
#include <gp.hxx>
#include <gp_Ax1.hxx>
//! On construction an instance of AIS_Manipulator object is bound to Graphic3d_ZLayerId_Topmost layer,
//! so make sure to call for your AIS_InteractiveContext the method MainSelector()->SetPickClosest (Standard_False)
//! otherwise you may notice issues with activation of modes.
-class AIS_Manipulator : public AIS_InteractiveObject
+class AIS_Manipulator : public AIS_InteractiveObject, public AIS_DragItem
{
public:
//! @warning It is used in chain with StartTransform-Transform(gp_Trsf)-StopTransform
//! and is used only for custom transform set. If Transform(const Standard_Integer, const Standard_Integer) is used,
//! initial data is set automatically, and it is reset on DeactivateCurrentMode call if it is not reset yet.
- Standard_EXPORT void StartTransform (const Standard_Integer theX, const Standard_Integer theY, const Handle(V3d_View)& theView);
+ Standard_EXPORT void StartTransform (const Standard_Integer theX,
+ const Standard_Integer theY,
+ const Handle(V3d_View)& theView) Standard_OVERRIDE;
//! Apply to the owning objects the input transformation.
//! @remark The transformation is set using SetLocalTransformation for owning objects.
//! @param theToApply [in] option to apply or to cancel the started transformation.
//! @warning It is used in chain with StartTransform-Transform(gp_Trsf)-StopTransform
//! and is used only for custom transform set.
- Standard_EXPORT void StopTransform (const Standard_Boolean theToApply = Standard_True);
+ Standard_EXPORT void StopTransform (const Standard_Boolean theToApply = Standard_True) Standard_OVERRIDE;
//! Apply transformation made from mouse moving from start position
//! (save on the first Tranform() call and reset on DeactivateCurrentMode() call.)
//! to the in/out mouse position (theX, theY)
Standard_EXPORT gp_Trsf Transform (const Standard_Integer theX, const Standard_Integer theY,
- const Handle(V3d_View)& theView);
+ const Handle(V3d_View)& theView) Standard_OVERRIDE;
//! Computes transformation of parent object according to the active mode and input motion vector.
//! You can use this method to get object transformation according to current mode or use own algorithm
Standard_Boolean IsAttached() const { return HasOwner(); }
//! @return true if some part of manipulator is selected (transformation mode is active, and owning object can be transformed).
- Standard_Boolean HasActiveMode() const { return IsAttached() && myCurrentMode != AIS_MM_None; }
+ Standard_Boolean HasActiveMode() const Standard_OVERRIDE { return IsAttached() && myCurrentMode != AIS_MM_None; }
Standard_Boolean HasActiveTransformation() { return myHasStartedTransformation; }
#include <AIS_AnimationCamera.hxx>
#include <AIS_InteractiveContext.hxx>
-#include <AIS_Manipulator.hxx>
+#include <AIS_DragItem.hxx>
#include <AIS_Point.hxx>
#include <AIS_RubberBand.hxx>
#include <AIS_XRTrackedDevice.hxx>
}
Handle(AIS_InteractiveObject) aPrs = theCtx->DetectedInteractive();
- if (Handle(AIS_Manipulator) aManip = Handle(AIS_Manipulator)::DownCast (aPrs))
+ if (AIS_DragItem* aDragItem = dynamic_cast<AIS_DragItem*>(aPrs.get()))
{
- if (aManip->HasActiveMode())
+ if (aDragItem->HasActiveMode())
{
- myDragObject = aManip;
- aManip->StartTransform (myGL.Dragging.PointStart.x(), myGL.Dragging.PointStart.y(), theView);
+ myDragObject = aPrs;
+ aDragItem->StartTransform (myGL.Dragging.PointStart.x(), myGL.Dragging.PointStart.y(), theView);
}
}
return;
{
theCtx->SetSelectedState (aGlobOwner, true);
}
- if (Handle(AIS_Manipulator) aManip = Handle(AIS_Manipulator)::DownCast (myDragObject))
+ if (AIS_DragItem* aDragItem = dynamic_cast<AIS_DragItem*>(myDragObject.get()))
{
- aManip->Transform (myGL.Dragging.PointTo.x(), myGL.Dragging.PointTo.y(), theView);
+ aDragItem->Transform (myGL.Dragging.PointTo.x(), myGL.Dragging.PointTo.y(), theView);
}
theView->Invalidate();
return;
myGL.Dragging.PointTo = myGL.Dragging.PointStart;
OnObjectDragged (theCtx, theView, AIS_DragAction_Update);
- if (Handle(AIS_Manipulator) aManip = Handle(AIS_Manipulator)::DownCast (myDragObject))
+ if (AIS_DragItem* aDragItem = dynamic_cast<AIS_DragItem*>(myDragObject.get()))
{
- aManip->StopTransform (false);
+ aDragItem->StopTransform (false);
}
Standard_FALLTHROUGH
}
theCtx->SetSelectedState (aGlobOwner, false);
}
+ if (AIS_DragItem* aDragItem = dynamic_cast<AIS_DragItem*>(myDragObject.get()))
+ {
+ aDragItem->StopTransform (false);
+ }
theView->Invalidate();
myDragObject.Nullify();
return;
AIS_DisplayMode.hxx
AIS_DisplayStatus.hxx
AIS_DragAction.hxx
+AIS_DragItem.hxx
AIS_ExclusionFilter.cxx
AIS_ExclusionFilter.hxx
AIS_ExclusionFilter.lxx