What I did is creating a InteractiveObject class, the BIM_InteractiveObject, inhereting AIS_Shape. I override the virtual method ProcessDragging(...) to enable mouse dragging object interaction. The interaction is done by setting the local transformation of the selected BIM_InteractiveObject class object to calculated drag position.
Now the interaction works okay for the BIM_InteractiveObject class object when dragging it first time. However, when dragging again the object starts from previous position. What is more, after the second drag, the object stops responding to mouse interaction all together.
Code:
Standard_Boolean BIM_InteractiveObject::ProcessDragging(const Handle(AIS_InteractiveContext)& theCtx, const Handle(V3d_View)& theView, const Handle(SelectMgr_EntityOwner)& theOwner, const Graphic3d_Vec2i & theDragFrom, const Graphic3d_Vec2i & theDragTo, const AIS_DragAction theAction)
{
if (theAction == AIS_DragAction_Update)
{
Handle(StdSelect_ViewerSelector3d) aSelector = this->InteractiveContext()->MainSelector();
SelectMgr_SortCriterion aPickPnt;
for (int aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
{
if (aSelector->Picked(aPickIter) == theOwner) // filter out other SelectMgr_EntityOwner
{
aPickPnt = aSelector->PickedData(aPickIter);
break;
}
}
gp_Trsf DirTrans;
DirTrans.SetTranslation(gp_Pnt(aPickPnt.Point.X(), aPickPnt.Point.Y(), aPickPnt.Point.Z()), gp_Pnt(position_in_view.x(), position_in_view.y(), position_in_view.z()));
this->SetLocalTransformation(DirTrans);
}
return true;
}
Now the interaction works okay for the BIM_InteractiveObject class object when dragging it first time. However, when dragging again the object starts from previous position. What is more, after the second drag, the object stops responding to mouse interaction all together.