From fb23c8d47f6dcef429423256d8dddcc0f7184fc4 Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Sun, 4 Jun 2023 13:02:14 +0200 Subject: Further advances in nuklear port. Rendering now looks similar to Qt version, needs a few tweaks: * Proper multisampling * Background Missing features: * Barcharts * Interactivity (e.g. brushing/linking in all objects) * History view of interactions --- geometry.cpp | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'geometry.cpp') diff --git a/geometry.cpp b/geometry.cpp index 101911e..1b514f0 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -4,13 +4,6 @@ static const float PI = 3.1415f; -Point2D::Point2D() -{} - -void Point2D::set(float x, float y) -{ -} - RectF::RectF(float x, float y, float width, float height) : m_x(x) , m_y(y) @@ -25,11 +18,11 @@ RectF::RectF(const RectF &other) , m_height(other.m_height) {} -RectF::RectF(const Point2D &p1, const Point2D &p2) - : m_x(fmin(p1.x(), p2.x())) - , m_y(fmin(p1.y(), p2.y())) - , m_width(fabs(p1.x() - p2.x())) - , m_height(fabs(p1.y() - p2.y())) +RectF::RectF(const vec2 &p1, const vec2 &p2) + : m_x(fmin(p1.x, p2.x)) + , m_y(fmin(p1.y, p2.y)) + , m_width(fabs(p1.x - p2.x)) + , m_height(fabs(p1.y - p2.y)) {} bool RectF::contains(float x, float y) const @@ -38,6 +31,11 @@ bool RectF::contains(float x, float y) const && (y > m_y && y < m_y + m_height); } +bool RectF::contains(const vec2 &p) const +{ + return contains(p.x, p.y); +} + bool RectF::intersects(const RectF &other) const { // TODO @@ -52,7 +50,7 @@ int Geometry::vertexCount() const return 0; } -Point2D *Geometry::vertexDataAsPoint2D() +vec2 *Geometry::vertexDataAsPoint2D() { return nullptr; } @@ -73,7 +71,7 @@ void updateCircleGeometry(Geometry *geometry, float diameter, float cx, float cy float x = diameter / 2; float y = 0; - Point2D *vertexData = geometry->vertexDataAsPoint2D(); + vec2 *vertexData = geometry->vertexDataAsPoint2D(); for (int i = 0; i < vertexCount; i++) { vertexData[i].set(x + cx, y + cy); @@ -85,7 +83,7 @@ void updateCircleGeometry(Geometry *geometry, float diameter, float cx, float cy void updateRectGeometry(Geometry *geometry, float x, float y, float w, float h) { - Point2D *vertexData = geometry->vertexDataAsPoint2D(); + vec2 *vertexData = geometry->vertexDataAsPoint2D(); vertexData[0].set(x, y); vertexData[1].set(x + w, y); @@ -99,7 +97,7 @@ void updateCrossHairGeometry(Geometry *geometry, float thickness, float length) { - Point2D *vertexData = geometry->vertexDataAsPoint2D(); + vec2 *vertexData = geometry->vertexDataAsPoint2D(); if (geometry->vertexCount() != 12) { return; } -- cgit v1.2.3