Skip to content

Commit 49ae4f2

Browse files
committed
Escape OCCT 7.7+ subview API into macros d
1 parent b98e5d3 commit 49ae4f2

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

occt-qopenglwidget/OcctQOpenGLWidgetViewer.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,8 @@ void OcctQOpenGLWidgetViewer::wheelEvent(QWheelEvent* theEvent)
332332
#else
333333
const Graphic3d_Vec2i aPos(theEvent->pos().x(), theEvent->pos().y());
334334
#endif
335+
336+
#if (OCC_VERSION_HEX >= 0x070700)
335337
if (!myView->Subviews().IsEmpty())
336338
{
337339
Handle(V3d_View) aPickedView = myView->PickSubview(aPos);
@@ -343,6 +345,7 @@ void OcctQOpenGLWidgetViewer::wheelEvent(QWheelEvent* theEvent)
343345
return;
344346
}
345347
}
348+
#endif
346349

347350
if (UpdateZoom(Aspect_ScrollDelta(aPos, double(theEvent->angleDelta().y()) / 8.0)))
348351
updateView();
@@ -414,12 +417,14 @@ void OcctQOpenGLWidgetViewer::paintGL()
414417
myView->Invalidate();
415418
dumpGlInfo(true, false);
416419

420+
#if (OCC_VERSION_HEX >= 0x070700)
417421
for (const Handle(V3d_View)& aSubviewIter : myView->Subviews())
418422
{
419423
aSubviewIter->MustBeResized();
420424
aSubviewIter->Invalidate();
421425
aDefaultFbo->SetupViewport(aGlCtx);
422426
}
427+
#endif
423428
}
424429

425430
// flush pending input events and redraw the viewer
@@ -439,6 +444,7 @@ void OcctQOpenGLWidgetViewer::handleViewRedraw(const Handle(AIS_InteractiveConte
439444
updateView(); // ask more frames for animation
440445
}
441446

447+
#if (OCC_VERSION_HEX >= 0x070700)
442448
// ================================================================
443449
// Function : OnSubviewChanged
444450
// ================================================================
@@ -448,3 +454,4 @@ void OcctQOpenGLWidgetViewer::OnSubviewChanged(const Handle(AIS_InteractiveConte
448454
{
449455
myFocusView = theNewView;
450456
}
457+
#endif

occt-qopenglwidget/OcctQOpenGLWidgetViewer.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <AIS_InteractiveContext.hxx>
1111
#include <AIS_ViewController.hxx>
1212
#include <V3d_View.hxx>
13+
#include <Standard_Version.hxx>
1314

1415
class AIS_ViewCube;
1516

@@ -50,11 +51,12 @@ class OcctQOpenGLWidgetViewer : public QOpenGLWidget, public AIS_ViewController
5051
virtual QSize sizeHint() const override { return QSize(720, 480); }
5152

5253
public:
54+
#if (OCC_VERSION_HEX >= 0x070700)
5355
//! Handle subview focus change.
5456
virtual void OnSubviewChanged(const Handle(AIS_InteractiveContext)&,
5557
const Handle(V3d_View)&,
5658
const Handle(V3d_View)& theNewView) override;
57-
59+
#endif
5860
protected: // OpenGL events
5961
virtual void initializeGL() override;
6062
virtual void paintGL() override;

occt-qopenglwidget/main.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,14 @@ class MyMainWindow : public QMainWindow
4444
{
4545
QMenuBar* aMenuBar = new QMenuBar();
4646
QMenu* aMenuWindow = aMenuBar->addMenu("&File");
47+
#if (OCC_VERSION_HEX >= 0x070700)
4748
{
4849
QAction* anActionSplit = new QAction(aMenuWindow);
4950
anActionSplit->setText("Split Views");
5051
aMenuWindow->addAction(anActionSplit);
5152
connect(anActionSplit, &QAction::triggered, [this]() { splitSubviews(); });
5253
}
54+
#endif
5355
{
5456
QAction* anActionQuit = new QAction(aMenuWindow);
5557
anActionQuit->setText("Quit");
@@ -104,12 +106,13 @@ class MyMainWindow : public QMainWindow
104106
connect(aSlider, &QSlider::valueChanged, [this](int theValue) {
105107
const float aVal = theValue / 255.0f;
106108
const Quantity_Color aColor(aVal, aVal, aVal, Quantity_TOC_sRGB);
107-
109+
#if (OCC_VERSION_HEX >= 0x070700)
108110
for (const Handle(V3d_View)& aSubviewIter : myViewer->View()->Subviews())
109111
{
110112
aSubviewIter->SetBgGradientColors(aColor, Quantity_NOC_BLACK, Aspect_GradientFillMethod_Elliptical);
111113
aSubviewIter->Invalidate();
112114
}
115+
#endif
113116
// myViewer->View()->SetBackgroundColor(aColor);
114117
myViewer->View()->SetBgGradientColors(aColor, Quantity_NOC_BLACK, Aspect_GradientFillMethod_Elliptical);
115118
myViewer->View()->Invalidate();
@@ -120,6 +123,7 @@ class MyMainWindow : public QMainWindow
120123
}
121124
}
122125

126+
#if (OCC_VERSION_HEX >= 0x070700)
123127
//! Advanced method splitting 3D Viewer into sub-views.
124128
void splitSubviews()
125129
{
@@ -157,6 +161,7 @@ class MyMainWindow : public QMainWindow
157161
myViewer->View()->Invalidate();
158162
myViewer->update();
159163
}
164+
#endif
160165
};
161166

162167
int main(int theNbArgs, char** theArgVec)

0 commit comments

Comments
 (0)