@@ -111,64 +111,6 @@ OcctQOpenGLWidgetViewer::~OcctQOpenGLWidgetViewer()
111111 aDisp.Nullify ();
112112}
113113
114- // ================================================================
115- // Function : dumpGlInfo
116- // ================================================================
117- void OcctQOpenGLWidgetViewer::dumpGlInfo (bool theIsBasic, bool theToPrint)
118- {
119- TColStd_IndexedDataMapOfStringString aGlCapsDict;
120- myView->DiagnosticInformation (aGlCapsDict,
121- theIsBasic ? Graphic3d_DiagnosticInfo_Basic : Graphic3d_DiagnosticInfo_Complete);
122- TCollection_AsciiString anInfo;
123- for (TColStd_IndexedDataMapOfStringString::Iterator aValueIter (aGlCapsDict); aValueIter.More (); aValueIter.Next ())
124- {
125- if (!aValueIter.Value ().IsEmpty ())
126- {
127- if (!anInfo.IsEmpty ())
128- anInfo += " \n " ;
129-
130- anInfo += aValueIter.Key () + " : " + aValueIter.Value ();
131- }
132- }
133-
134- if (theToPrint)
135- Message::SendInfo (anInfo);
136-
137- myGlInfo = QString::fromUtf8 (anInfo.ToCString ());
138- }
139-
140- // ================================================================
141- // Function : initializeGL
142- // ================================================================
143- void OcctQOpenGLWidgetViewer::initializeGL ()
144- {
145- Handle (OpenGl_GraphicDriver) aDriver = Handle (OpenGl_GraphicDriver)::DownCast (myViewer->Driver ());
146- OcctQtTools::qtGlCapsFromSurfaceFormat (aDriver->ChangeOptions (), format ());
147-
148- const Aspect_Drawable aNativeWin = (Aspect_Drawable)winId ();
149- const Graphic3d_Vec2i aViewSize (rect ().right () - rect ().left (), rect ().bottom () - rect ().top ());
150-
151- const bool isFirstInit = myView->Window ().IsNull ();
152- if (!OcctGlTools::InitializeGlWindow (myView, aNativeWin, aViewSize, devicePixelRatioF ()))
153- {
154- QMessageBox::critical (0 , " Failure" , " OpenGl_Context is unable to wrap OpenGL context" );
155- QApplication::exit (1 );
156- return ;
157- }
158-
159- makeCurrent (); // restore Qt framebuffer
160- dumpGlInfo (true , true );
161- if (isFirstInit)
162- {
163- myContext->Display (myViewCube, 0 , 0 , false );
164-
165- // dummy shape for testing
166- TopoDS_Shape aBox = BRepPrimAPI_MakeBox (100.0 , 50.0 , 90.0 ).Shape ();
167- Handle (AIS_Shape) aShape = new AIS_Shape (aBox);
168- myContext->Display (aShape, AIS_Shaded, 0 , false );
169- }
170- }
171-
172114// ================================================================
173115// Function : event
174116// ================================================================
@@ -354,6 +296,87 @@ void OcctQOpenGLWidgetViewer::updateView()
354296 // if (window() != NULL) { window()->update(); }
355297}
356298
299+ // ================================================================
300+ // Function : handleViewRedraw
301+ // ================================================================
302+ void OcctQOpenGLWidgetViewer::handleViewRedraw (const Handle (AIS_InteractiveContext)& theCtx,
303+ const Handle(V3d_View)& theView)
304+ {
305+ AIS_ViewController::handleViewRedraw (theCtx, theView);
306+ if (myToAskNextFrame)
307+ updateView (); // ask more frames for animation
308+ }
309+
310+ #if (OCC_VERSION_HEX >= 0x070700)
311+ // ================================================================
312+ // Function : OnSubviewChanged
313+ // ================================================================
314+ void OcctQOpenGLWidgetViewer::OnSubviewChanged (const Handle (AIS_InteractiveContext)&,
315+ const Handle(V3d_View)&,
316+ const Handle(V3d_View)& theNewView)
317+ {
318+ myFocusView = theNewView;
319+ }
320+ #endif
321+
322+ // ================================================================
323+ // Function : dumpGlInfo
324+ // ================================================================
325+ void OcctQOpenGLWidgetViewer::dumpGlInfo (bool theIsBasic, bool theToPrint)
326+ {
327+ TColStd_IndexedDataMapOfStringString aGlCapsDict;
328+ myView->DiagnosticInformation (aGlCapsDict,
329+ theIsBasic ? Graphic3d_DiagnosticInfo_Basic : Graphic3d_DiagnosticInfo_Complete);
330+ TCollection_AsciiString anInfo;
331+ for (TColStd_IndexedDataMapOfStringString::Iterator aValueIter (aGlCapsDict); aValueIter.More (); aValueIter.Next ())
332+ {
333+ if (!aValueIter.Value ().IsEmpty ())
334+ {
335+ if (!anInfo.IsEmpty ())
336+ anInfo += " \n " ;
337+
338+ anInfo += aValueIter.Key () + " : " + aValueIter.Value ();
339+ }
340+ }
341+
342+ if (theToPrint)
343+ Message::SendInfo (anInfo);
344+
345+ myGlInfo = QString::fromUtf8 (anInfo.ToCString ());
346+ }
347+
348+ // ================================================================
349+ // Function : initializeGL
350+ // ================================================================
351+ void OcctQOpenGLWidgetViewer::initializeGL ()
352+ {
353+ Handle (OpenGl_GraphicDriver) aDriver = Handle (OpenGl_GraphicDriver)::DownCast (myViewer->Driver ());
354+ OcctQtTools::qtGlCapsFromSurfaceFormat (aDriver->ChangeOptions (), format ());
355+
356+ const Aspect_Drawable aNativeWin = (Aspect_Drawable)winId ();
357+ const Graphic3d_Vec2i aViewSize (rect ().right () - rect ().left (), rect ().bottom () - rect ().top ());
358+
359+ const bool isFirstInit = myView->Window ().IsNull ();
360+ if (!OcctGlTools::InitializeGlWindow (myView, aNativeWin, aViewSize, devicePixelRatioF ()))
361+ {
362+ QMessageBox::critical (0 , " Failure" , " OpenGl_Context is unable to wrap OpenGL context" );
363+ QApplication::exit (1 );
364+ return ;
365+ }
366+
367+ makeCurrent (); // restore Qt framebuffer
368+ dumpGlInfo (true , true );
369+ if (isFirstInit)
370+ {
371+ myContext->Display (myViewCube, 0 , 0 , false );
372+
373+ // dummy shape for testing
374+ TopoDS_Shape aBox = BRepPrimAPI_MakeBox (100.0 , 50.0 , 90.0 ).Shape ();
375+ Handle (AIS_Shape) aShape = new AIS_Shape (aBox);
376+ myContext->Display (aShape, AIS_Shaded, 0 , false );
377+ }
378+ }
379+
357380// ================================================================
358381// Function : paintGL
359382// ================================================================
@@ -399,26 +422,3 @@ void OcctQOpenGLWidgetViewer::paintGL()
399422 // reset global GL state after OCCT before redrawing Qt
400423 OcctGlTools::ResetGlStateAfterOcct (myView);
401424}
402-
403- // ================================================================
404- // Function : handleViewRedraw
405- // ================================================================
406- void OcctQOpenGLWidgetViewer::handleViewRedraw (const Handle (AIS_InteractiveContext)& theCtx,
407- const Handle(V3d_View)& theView)
408- {
409- AIS_ViewController::handleViewRedraw (theCtx, theView);
410- if (myToAskNextFrame)
411- updateView (); // ask more frames for animation
412- }
413-
414- #if (OCC_VERSION_HEX >= 0x070700)
415- // ================================================================
416- // Function : OnSubviewChanged
417- // ================================================================
418- void OcctQOpenGLWidgetViewer::OnSubviewChanged (const Handle (AIS_InteractiveContext)&,
419- const Handle(V3d_View)&,
420- const Handle(V3d_View)& theNewView)
421- {
422- myFocusView = theNewView;
423- }
424- #endif
0 commit comments