Skip to content

Commit b49d5c3

Browse files
committed
Coding - explicitly mention AIS_ViewController:: for sample code clarity
1 parent f4aa91b commit b49d5c3

2 files changed

Lines changed: 33 additions & 33 deletions

File tree

occt-qopenglwidget/OcctQOpenGLWidgetViewer.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -263,16 +263,16 @@ bool OcctQOpenGLWidgetViewer::event(QEvent* theEvent)
263263
&& aNewPos2i.minComp() >= 0)
264264
{
265265
hasUpdates = true;
266-
AddTouchPoint(aTouchId, aNewPos2d);
266+
AIS_ViewController::AddTouchPoint(aTouchId, aNewPos2d);
267267
}
268268
else if (aQTouch.state() == Qt::TouchPointMoved
269-
&& TouchPoints().Contains(aTouchId))
269+
&& AIS_ViewController::TouchPoints().Contains(aTouchId))
270270
{
271271
hasUpdates = true;
272-
UpdateTouchPoint(aTouchId, aNewPos2d);
272+
AIS_ViewController::UpdateTouchPoint(aTouchId, aNewPos2d);
273273
}
274274
else if (aQTouch.state() == Qt::TouchPointReleased
275-
&& RemoveTouchPoint(aTouchId))
275+
&& AIS_ViewController::RemoveTouchPoint(aTouchId))
276276
{
277277
hasUpdates = true;
278278
}
@@ -330,8 +330,9 @@ void OcctQOpenGLWidgetViewer::mousePressEvent(QMouseEvent* theEvent)
330330
return; // skip mouse events emulated by system from screen touches
331331

332332
const Graphic3d_Vec2i aPnt(theEvent->pos().x(), theEvent->pos().y());
333+
const Aspect_VKeyMouse aButtons = OcctQtTools::qtMouseButtons2VKeys(theEvent->buttons());
333334
const Aspect_VKeyFlags aFlags = OcctQtTools::qtMouseModifiers2VKeys(theEvent->modifiers());
334-
if (UpdateMouseButtons(aPnt, OcctQtTools::qtMouseButtons2VKeys(theEvent->buttons()), aFlags, false))
335+
if (AIS_ViewController::UpdateMouseButtons(aPnt, aButtons, aFlags, false))
335336
updateView();
336337
}
337338

@@ -345,8 +346,9 @@ void OcctQOpenGLWidgetViewer::mouseReleaseEvent(QMouseEvent* theEvent)
345346
return;
346347

347348
const Graphic3d_Vec2i aPnt(theEvent->pos().x(), theEvent->pos().y());
349+
const Aspect_VKeyMouse aButtons = OcctQtTools::qtMouseButtons2VKeys(theEvent->buttons());
348350
const Aspect_VKeyFlags aFlags = OcctQtTools::qtMouseModifiers2VKeys(theEvent->modifiers());
349-
if (UpdateMouseButtons(aPnt, OcctQtTools::qtMouseButtons2VKeys(theEvent->buttons()), aFlags, false))
351+
if (AIS_ViewController::UpdateMouseButtons(aPnt, aButtons, aFlags, false))
350352
updateView();
351353
}
352354

@@ -362,14 +364,11 @@ void OcctQOpenGLWidgetViewer::mouseMoveEvent(QMouseEvent* theEvent)
362364
if (myHasTouchInput && theEvent->source() == Qt::MouseEventSynthesizedBySystem)
363365
return; // skip mouse events emulated by system from screen touches
364366

365-
const Graphic3d_Vec2i aNewPos(theEvent->pos().x(), theEvent->pos().y());
366-
if (UpdateMousePosition(aNewPos,
367-
OcctQtTools::qtMouseButtons2VKeys(theEvent->buttons()),
368-
OcctQtTools::qtMouseModifiers2VKeys(theEvent->modifiers()),
369-
false))
370-
{
367+
const Graphic3d_Vec2i aNewPos(theEvent->pos().x(), theEvent->pos().y());
368+
const Aspect_VKeyMouse aButtons = OcctQtTools::qtMouseButtons2VKeys(theEvent->buttons());
369+
const Aspect_VKeyFlags aFlags = OcctQtTools::qtMouseModifiers2VKeys(theEvent->modifiers());
370+
if (AIS_ViewController::UpdateMousePosition(aNewPos, aButtons, aFlags, false))
371371
updateView();
372-
}
373372
}
374373

375374
// ==============================================================================
@@ -401,7 +400,7 @@ void OcctQOpenGLWidgetViewer::wheelEvent(QWheelEvent* theEvent)
401400
}
402401
#endif
403402

404-
if (UpdateZoom(Aspect_ScrollDelta(aPos, double(theEvent->angleDelta().y()) / 8.0)))
403+
if (AIS_ViewController::UpdateZoom(Aspect_ScrollDelta(aPos, double(theEvent->angleDelta().y()) / 8.0)))
405404
updateView();
406405
}
407406

@@ -484,7 +483,7 @@ void OcctQOpenGLWidgetViewer::paintGL()
484483
// flush pending input events and redraw the viewer
485484
Handle(V3d_View) aView = !myFocusView.IsNull() ? myFocusView : myView;
486485
aView->InvalidateImmediate();
487-
FlushViewEvents(myContext, aView, true);
486+
AIS_ViewController::FlushViewEvents(myContext, aView, true);
488487
}
489488

490489
// ================================================================

occt-qwidget/OcctQWidgetViewer.cpp

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,16 @@ bool OcctQWidgetViewer::event(QEvent* theEvent)
176176
&& aNewPos2i.minComp() >= 0)
177177
{
178178
hasUpdates = true;
179-
AddTouchPoint(aTouchId, aNewPos2d);
179+
AIS_ViewController::AddTouchPoint(aTouchId, aNewPos2d);
180180
}
181181
else if (aQTouch.state() == Qt::TouchPointMoved
182-
&& TouchPoints().Contains(aTouchId))
182+
&& AIS_ViewController::TouchPoints().Contains(aTouchId))
183183
{
184184
hasUpdates = true;
185-
UpdateTouchPoint(aTouchId, aNewPos2d);
185+
AIS_ViewController::UpdateTouchPoint(aTouchId, aNewPos2d);
186186
}
187187
else if (aQTouch.state() == Qt::TouchPointReleased
188-
&& RemoveTouchPoint(aTouchId))
188+
&& AIS_ViewController::RemoveTouchPoint(aTouchId))
189189
{
190190
hasUpdates = true;
191191
}
@@ -217,11 +217,13 @@ void OcctQWidgetViewer::keyPressEvent(QKeyEvent* theEvent)
217217
const Aspect_VKey aKey = OcctQtTools::qtKey2VKey(theEvent->key());
218218
switch (aKey)
219219
{
220-
case Aspect_VKey_Escape: {
220+
case Aspect_VKey_Escape:
221+
{
221222
QApplication::exit();
222223
return;
223224
}
224-
case Aspect_VKey_F: {
225+
case Aspect_VKey_F:
226+
{
225227
myView->FitAll(0.01, false);
226228
update();
227229
return;
@@ -243,8 +245,9 @@ void OcctQWidgetViewer::mousePressEvent(QMouseEvent* theEvent)
243245
return; // skip mouse events emulated by system from screen touches
244246

245247
const Graphic3d_Vec2i aPnt(theEvent->pos().x(), theEvent->pos().y());
248+
const Aspect_VKeyMouse aButtons = OcctQtTools::qtMouseButtons2VKeys(theEvent->buttons());
246249
const Aspect_VKeyFlags aFlags = OcctQtTools::qtMouseModifiers2VKeys(theEvent->modifiers());
247-
if (UpdateMouseButtons(aPnt, OcctQtTools::qtMouseButtons2VKeys(theEvent->buttons()), aFlags, false))
250+
if (AIS_ViewController::UpdateMouseButtons(aPnt, aButtons, aFlags, false))
248251
updateView();
249252
}
250253

@@ -258,8 +261,9 @@ void OcctQWidgetViewer::mouseReleaseEvent(QMouseEvent* theEvent)
258261
return;
259262

260263
const Graphic3d_Vec2i aPnt(theEvent->pos().x(), theEvent->pos().y());
264+
const Aspect_VKeyMouse aButtons = OcctQtTools::qtMouseButtons2VKeys(theEvent->buttons());
261265
const Aspect_VKeyFlags aFlags = OcctQtTools::qtMouseModifiers2VKeys(theEvent->modifiers());
262-
if (UpdateMouseButtons(aPnt, OcctQtTools::qtMouseButtons2VKeys(theEvent->buttons()), aFlags, false))
266+
if (AIS_ViewController::UpdateMouseButtons(aPnt, aButtons, aFlags, false))
263267
updateView();
264268
}
265269

@@ -275,14 +279,11 @@ void OcctQWidgetViewer::mouseMoveEvent(QMouseEvent* theEvent)
275279
if (myHasTouchInput && theEvent->source() == Qt::MouseEventSynthesizedBySystem)
276280
return; // skip mouse events emulated by system from screen touches
277281

278-
const Graphic3d_Vec2i aNewPos(theEvent->pos().x(), theEvent->pos().y());
279-
if (UpdateMousePosition(aNewPos,
280-
OcctQtTools::qtMouseButtons2VKeys(theEvent->buttons()),
281-
OcctQtTools::qtMouseModifiers2VKeys(theEvent->modifiers()),
282-
false))
283-
{
282+
const Graphic3d_Vec2i aNewPos(theEvent->pos().x(), theEvent->pos().y());
283+
const Aspect_VKeyMouse aButtons = OcctQtTools::qtMouseButtons2VKeys(theEvent->buttons());
284+
const Aspect_VKeyFlags aFlags = OcctQtTools::qtMouseModifiers2VKeys(theEvent->modifiers());
285+
if (AIS_ViewController::UpdateMousePosition(aNewPos, aButtons, aFlags, false))
284286
updateView();
285-
}
286287
}
287288

288289
// ==============================================================================
@@ -314,7 +315,7 @@ void OcctQWidgetViewer::wheelEvent(QWheelEvent* theEvent)
314315
}
315316
#endif
316317

317-
if (UpdateZoom(Aspect_ScrollDelta(aPos, double(theEvent->angleDelta().y()) / 8.0)))
318+
if (AIS_ViewController::UpdateZoom(Aspect_ScrollDelta(aPos, double(theEvent->angleDelta().y()) / 8.0)))
318319
updateView();
319320
}
320321

@@ -323,7 +324,7 @@ void OcctQWidgetViewer::wheelEvent(QWheelEvent* theEvent)
323324
// =======================================================================
324325
void OcctQWidgetViewer::updateView()
325326
{
326-
update();
327+
QWidget::update();
327328
// if (window() != NULL) { window()->update(); }
328329
}
329330

@@ -369,7 +370,7 @@ void OcctQWidgetViewer::paintEvent(QPaintEvent* )
369370
// flush pending input events and redraw the viewer
370371
Handle(V3d_View) aView = !myFocusView.IsNull() ? myFocusView : myView;
371372
aView->InvalidateImmediate();
372-
FlushViewEvents(myContext, aView, true);
373+
AIS_ViewController::FlushViewEvents(myContext, aView, true);
373374
}
374375

375376
// ================================================================

0 commit comments

Comments
 (0)