28 : QGLWidget(QGLFormat(QGL::DepthBuffer | QGL::NoAlphaChannel | QGL::SampleBuffers), parent),
29 m_display_object(
std::shared_ptr<
Mantid::Geometry::CSGObject>()), m_x_rot(0.0), m_y_rot(0.0), m_z_rot(0.0),
31 setAutoFillBackground(
false);
57 double bbox[6] = {boundingBox.xMax(), boundingBox.yMax(), boundingBox.zMax(),
58 boundingBox.xMin(), boundingBox.yMin(), boundingBox.zMin()};
61 for (
int i = 0; i < 3; ++i) {
66 if (std::fabs(bbox[i]) < 1e10 && std::fabs(bbox[i + 3]) < 1e10) {
75 GLdouble aspect_ratio((GLdouble)this->width() / (GLdouble)this->
height());
90 glClearColor(0.0, 0.0, 0.0, 0.0);
91 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
93 setCursor(Qt::PointingHandCursor);
95 glEnable(GL_DEPTH_TEST);
96 glShadeModel(GL_SMOOTH);
97 glEnable(GL_LINE_SMOOTH);
101 glEnable(GL_LIGHTING);
103 glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,
107 GLfloat lamp_ambient[4] = {0.40f, 0.0f, 1.0f, 0.0f};
108 GLfloat lamp_diffuse[4] = {1.0f, 1.0f, 1.0f, 1.0f};
109 GLfloat lamp_specular[4] = {1.0f, 1.0f, 1.0f, 1.0f};
111 glLightfv(GL_LIGHT0, GL_AMBIENT, lamp_ambient);
112 glLightfv(GL_LIGHT0, GL_DIFFUSE, lamp_diffuse);
113 glLightfv(GL_LIGHT0, GL_SPECULAR, lamp_specular);
114 GLfloat lamp_pos[4] = {0.0f, 0.0f, 1.0f, 0.0};
115 glLightfv(GL_LIGHT0, GL_POSITION, lamp_pos);
125 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
127 glMatrixMode(GL_MODELVIEW);
133 glRotated(
m_x_rot / 16.0, 1.0, 0.0, 0.0);
134 glRotated(
m_y_rot / 16.0, 0.0, 1.0, 0.0);
135 glRotated(
m_z_rot / 16.0, 0.0, 0.0, 1.0);
140 QMessageBox::information(
this,
"MantidGLWidget",
141 QString(
"An error occurred while attempting to render the shape.\n") +
142 "Please check that all objects intersect each other.");
153 glViewport(0, 0, (GLsizei)width, (GLsizei)
height);
157 GLdouble aspect_ratio = (GLdouble)width / (GLdouble)
height;
175 int x_rot =
static_cast<int>(
m_x_rot);
177 if (event->buttons() & Qt::LeftButton) {
180 }
else if (event->buttons() & Qt::RightButton) {
235 if (ratio < aspect_ratio) {
256 glMatrixMode(GL_PROJECTION);
259 glMatrixMode(GL_MODELVIEW);
270 while (*angle > 360 * 16)
Helper class which provides the Collimation Length for SANS instruments.