
Tue, 11/22/2022 - 14:29
Hello OCCT Community,
I would like to handle on our Qt project with multi touch screens. I've tried that CAD Assistant application works very well with multi-touch screens and I've investigated some multi-touch methods on OCCT side. However, I couldn't overcome multi-touch problems on our project. I would like to zoom in/out on multi-touch screens and manage it.
Firstly, I've added below code line for Qt can catch the touch events:
setAttribute(Qt::WA_AcceptTouchEvents, true);
Then, I have overrided some Open CASCADE methods such as AddTouchPoint, RemoveTouchPoint, UpdateTouchPoint. Most likely my usage below is wrong, but I don't know exactly how it should be correct.
void OCCTVisualizerWidget::AddTouchPoint(Standard_Size theId, const Graphic3d_Vec2d &thePnt, Standard_Boolean theClearBefore)
{
AIS_ViewController::AddTouchPoint(theId, thePnt, theClearBefore);
if (myToAskNextFrame) //myToAskNextFrame: OCCT specific flag, indicating that another frame should be drawn right after this one
{
// ask more frames for animation
updateView();
}
}
bool OCCTVisualizerWidget::RemoveTouchPoint(Standard_Size theId, Standard_Boolean theClearSelectPnts)
{
auto result = AIS_ViewController::RemoveTouchPoint(theId, theClearSelectPnts);
if (myToAskNextFrame) //myToAskNextFrame: OCCT specific flag, indicating that another frame should be drawn right after this one
{
// ask more frames for animation
updateView();
}
return result;
}
void OCCTVisualizerWidget::UpdateTouchPoint(Standard_Size theId, const Graphic3d_Vec2d &thePnt)
{
AIS_ViewController::UpdateTouchPoint(theId, thePnt);
if (myToAskNextFrame) //myToAskNextFrame: OCCT specific flag, indicating that another frame should be drawn right after this one
{
// ask more frames for animation
updateView();
}
}
Lastly, I've tried to manage it some mouse gesture mapping methods but I couldn't figure out true implementation yet:
void OCCTVisualizerWidget::setMouseGestureMappingOptions()
{
// clear map from defaults
ais_mouse_gesture_map_.Clear();
ais_mouse_gesture_map_.Bind (Aspect_VKeyMouse_RightButton, AIS_MouseGesture_RotateOrbit);
ais_mouse_gesture_map_.Bind (Aspect_VKeyMouse_LeftButton, AIS_MouseGesture_Pan);
// For synchronous inputs (i.e.If users would like to zoom, press CTRL key and click right mouse button)
ais_mouse_gesture_map_.Bind (Aspect_VKeyMouse_RightButton | Aspect_VKeyFlags_CTRL, AIS_MouseGesture_Zoom);
ais_mouse_gesture_map_.Bind (Aspect_VKeyMouse_LeftButton | Aspect_VKeyFlags_ALT | Aspect_VKeyFlags_SHIFT, AIS_MouseGesture_SelectRectangle);
}
How I can use "AIS_MouseGesture_Zoom" with multi-touch events?
Thank you in advance! Best regards,
Nezihe