Download the GLDisplayListWidget repository from 157support
From within Qt Designer:
Outside of Qt Designer
..\QtGLgraphics
, the additional entries to the *.pro file would be QT += opengl
DEFINES += _CRT_SECURE_NO_WARNINGS
DEFINES += _CRT_SECURE_NO_DEPRECATE
INCLUDEPATH += ../QtGLgraphics
HEADERS += ../QtGLgraphics/GLDisplayListWidget.h
HEADERS += ../QtGLgraphics/GLDriverQt.h
SOURCES += ../QtGLgraphics/GLDisplayListWidget.cpp
SOURCES += ../QtGLgraphics/GLDriverQt.cpp
The GLDisplayListWidget class implements a Qt based OpenGL widget that renders UCdriver and UCdriverEx graphics calls. This class is derived from QGLWidget. See the Qt reference guide for information about member functions associated with QGLwidget.
The UCdriver (UCdriverEx) interface is provided by an internal instance of a GLDriverQt. Access to this interface is through a pointer obtained with the getGLDriverQtPtr() member function.
When a code in which the user interface (*.ui) contains a GLDisplayListWidget is built, a data member is made in the corresponding user interface header file that points to the GLDisplayListWidget in the interface. The following code samples assume that the GLDisplayListWidget object is named glWidget
. If you don't know the name of the GLDisplayListWidget pointer in your program, you can look af the user interface header file.
A sample code snippet where the GLDriverQt pointer is used to call UCdriver or UCdriverEx routines whose output will be displayed in the graphics window.
// // In a response function in the window class that implements the plotting... // // Capture the GLDriverQt pointer // GLDriverQt* Gldriver = glWidget->getGLDriverQtPtr(); // Use the start() to open up a GL display list and then create // graphics by calling UCdriver or UCdriverEx methods. Close // the list and induce a repaint of glWidget by calling frame(). Gldriver->start(); Gldriver->point(...); // Gldriver->lines(...); // UCdriver or UCdriverEx calls Gldriver->pointEx(...); // Gldriver->frame();A sample code that uses a PlotData class to create plots. This PlotData class uses an associated UCdriver pointer to implement the graphics calls.
// // In a response function in the window class that implements the plotting... // // Extract the pointer to the low level driver (can be used in any class expecting a // UCdriver or UCdriverEx pointer). // GLDriverQt* Gldriver = glWidget->getGLDriverQtPtr(); // // A collection of GLDriverQt calls must be // prefaced by a start(..) call when using the OpenGL based // driver. // Gldriver->start(); // // read f(x) value (as a Qstring) // QString fxText = fxTextEdit->text(); // // create symbolic function, if in error then close frame and set error message DoubleSymbolicFunction symfun; int ierr = symfun.initialize(fxText.toStdString()); if(ierr == 1) { Gldriver->frame(); fxTextEdit->setText("Function Error"); return; } // // Create an instance of the PlotFunction class // PlotData Plot; Plot.setGraphicsDriver(Gldriver); // // Plot the function // Plot.plot(symfun,xMin,xMax,yMin,yMax); // // Draw a frame around the plot // Plot.drawFrame(); // // Call frame to display the plot and close the display list // Gldriver->frame();