Skip to content

Commit 2d4a284

Browse files
authored
Adhere to latest core renderer upgrade (#42)
* Fix build * Reset view * init navigator * Use helper functions
1 parent 6835403 commit 2d4a284

2 files changed

Lines changed: 15 additions & 16 deletions

File tree

ExampleViewOpenGL/src/ExampleGLWidget.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
#include <util/Exception.h>
44

55
#include <QPainter>
6+
#include <QRectF>
67

78
ExampleGLWidget::ExampleGLWidget() :
89
QOpenGLWidget(),
910
_isInitialized(false),
1011
_backgroundColor(235, 235, 235, 255),
11-
_pointRenderer(),
12+
_pointRenderer(this),
1213
_pixelRatio(1.0f),
1314
_points(),
14-
_colors(),
15-
_bounds()
15+
_colors()
1616
{
1717
setAcceptDrops(true);
1818

@@ -39,7 +39,6 @@ ExampleGLWidget::ExampleGLWidget() :
3939
surfaceFormat.setSamples(16);
4040

4141
setFormat(surfaceFormat);
42-
4342
}
4443

4544
ExampleGLWidget::~ExampleGLWidget()
@@ -59,29 +58,31 @@ void ExampleGLWidget::setData(const std::vector<mv::Vector2f>& points, float poi
5958
constexpr mv::Vector3f pointColor = {0.f, 0.f, 0.f};
6059

6160
for(unsigned long i = 0; i < numPoints; i++)
62-
_colors.emplace_back(pointColor);
61+
_colors.push_back(pointColor);
6362

64-
_bounds = Bounds::Max;
63+
Bounds bounds = Bounds::Max;
6564

66-
for (const Vector2f& point : _points)
65+
for (const Vector2f& point : points)
6766
{
68-
_bounds.setLeft(std::min(point.x, _bounds.getLeft()));
69-
_bounds.setRight(std::max(point.x, _bounds.getRight()));
70-
_bounds.setBottom(std::min(point.y, _bounds.getBottom()));
71-
_bounds.setTop(std::max(point.y, _bounds.getTop()));
67+
bounds.setLeft(std::min(point.x, bounds.getLeft()));
68+
bounds.setRight(std::max(point.x, bounds.getRight()));
69+
bounds.setBottom(std::min(point.y, bounds.getBottom()));
70+
bounds.setTop(std::max(point.y, bounds.getTop()));
7271
}
7372

74-
_bounds.makeSquare();
75-
_bounds.expand(0.1f);
73+
bounds.makeSquare();
74+
bounds.expand(0.1f);
7675

7776
// Send the data to the renderer
78-
_pointRenderer.setBounds(_bounds);
77+
_pointRenderer.setDataBounds(QRectF(QPointF(bounds.getLeft(), bounds.getBottom()), QSizeF(bounds.getWidth(), bounds.getHeight())));
7978
_pointRenderer.setData(_points);
8079
_pointRenderer.setColors(_colors);
8180

8281
_pointRenderer.setPointSize(pointSize);
8382
_pointRenderer.setAlpha(pointOpacity);
8483

84+
_pointRenderer.initView();
85+
8586
// Calls paintGL()
8687
update();
8788
}

ExampleViewOpenGL/src/ExampleGLWidget.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <renderers/PointRenderer.h>
44
#include <graphics/Vector2f.h>
55
#include <graphics/Vector3f.h>
6-
#include <graphics/Bounds.h>
76

87
#include <QOpenGLWidget>
98
#include <QOpenGLFunctions>
@@ -42,7 +41,6 @@ class ExampleGLWidget : public QOpenGLWidget, protected QOpenGLFunctions
4241
float _pixelRatio; /* device pixel ratio */
4342
std::vector<Vector2f> _points; /* 2D coordinates of points */
4443
std::vector<Vector3f> _colors; /* Color of points - here we use a constant color for simplicity */
45-
Bounds _bounds; /* Min and max point coordinates for camera placement */
4644
QColor _backgroundColor; /* Background color */
4745
bool _isInitialized; /* Whether OpenGL is initialized */
4846
};

0 commit comments

Comments
 (0)