#ifndef GLWIDGET_H
#define GLWIDGET_H
enum ListTypes {
POINTLIST,
EDGELIST,
SURFACELIST,
SURFACEMESHLIST,
SHARPEDGELIST,
VOLUMEMESHLIST,
UNKNOWNLIST
};
#ifndef WIN32
#ifndef __APPLE__
#include <GL/glu.h>
#else
#include <OpenGL/glu.h>
#endif
#endif
#ifdef __MINGW32__
#include <GL/glu.h>
#endif
#ifdef WIN32
#ifndef __MINGW32__
#ifdef _CONSOLE
#include <GL/glut.h>
#endif
#endif
#endif
#if WITH_QT6
#include <QOpenGLWidget>
#else
#include <QGLWidget>
#endif
#include <QHash>
#include <QMap>
#include <QVector>
#include "helpers.h"
#include "meshutils.h"
#define DUMMY_NAME 0xffffffff
class list_t {
public:
list_t();
~list_t();
void setNature(int);
int getNature() const;
void setType(int);
int getType() const;
void setIndex(int);
int getIndex() const;
void setObject(GLuint);
GLuint getObject() const;
void setChild(int);
int getChild() const;
void setParent(int);
int getParent() const;
void setSelected(bool);
bool isSelected() const;
void setVisible(bool);
bool isVisible() const;
private:
int nature;
int type;
int index;
GLuint object;
int child;
int parent;
bool selected;
bool visible;
};
#if WITH_QT6
class GLWidget : public QOpenGLWidget, protected QOpenGLFunctions
{
Q_OBJECT
public:
void updateGL();
void renderText(double x, double y, double z, const QString & str, const QFont & font = QFont(), int listBase = 2000);
inline GLint project(GLdouble objx, GLdouble objy, GLdouble objz,
const GLdouble model[16], const GLdouble proj[16],
const GLint viewport[4],
GLdouble * winx, GLdouble * winy, GLdouble * winz);
inline void transformPoint(GLdouble out[4], const GLdouble m[16], const GLdouble in[4]);
#else
class GLWidget : public QGLWidget
{
Q_OBJECT
#endif
public:
GLWidget(QWidget *parent = 0);
~GLWidget();
QSize minimumSizeHint() const;
QSize sizeHint() const;
void setMesh(mesh_t*);
mesh_t* getMesh() const;
void newMesh();
void deleteMesh();
bool hasMesh() const;
list_t* getList(int) const;
int getLists() const;
void rebuildLists();
void rebuildSurfaceLists();
void rebuildEdgeLists();
void changeProjection();
bool toggleCoordinates();
static void indexColors(double *, int);
static void indexColors(int *, int);
bool stateOrtho;
bool stateFlatShade;
bool stateDrawSurfaceMesh;
bool stateDrawVolumeMesh;
bool stateDrawSharpEdges;
bool stateDrawSurfaceElements;
bool stateDrawEdgeElements;
bool stateDrawCoordinates;
bool stateDrawSurfaceNumbers;
bool stateDrawEdgeNumbers;
bool stateDrawNodeNumbers;
bool stateDrawBoundaryIndex;
bool stateDrawBodyIndex;
bool stateBcColors;
bool stateBodyColors;
bool bodyEditActive;
bool stateUseBgImage;
bool stateStretchBgImage;
bool stateAlignRightBgImage;
QString bgImageFileName;
int currentlySelectedBody;
QColor backgroundColor;
QColor surfaceColor;
QColor edgeColor;
QColor surfaceMeshColor;
QColor sharpEdgeColor;
QColor selectionColor;
QMap<int, int> boundaryMap;
QMap<int, int> bodyMap;
public slots:
signals:
void signalBoundarySelected(list_t*, Qt::KeyboardModifiers);
void escPressed();
protected:
void initializeGL();
void paintGL();
void resizeGL(int, int);
void focusInEvent(QFocusEvent*);
void mouseDoubleClickEvent(QMouseEvent*);
void mousePressEvent(QMouseEvent*);
void mouseReleaseEvent(QMouseEvent*);
void mouseMoveEvent(QMouseEvent*);
void wheelEvent(QWheelEvent*);
void keyPressEvent(QKeyEvent*);
void keyReleaseEvent(QKeyEvent*);
private:
QVector<list_t*> list;
mesh_t *mesh;
Helpers *helpers;
Meshutils *meshutils;
GLuint makeLists();
QREAL_OR_FLOAT matrix[16];
QREAL_OR_FLOAT invmatrix[16];
void getMatrix();
QPoint lastPos;
QPoint lastPressPos;
GLuint generateSurfaceList(int, QColor);
GLuint generateSurfaceMeshList(int, QColor);
GLuint generateVolumeMeshList(QColor);
GLuint generateEdgeList(int, QColor);
GLuint generateSharpEdgeList(QColor);
GLUquadricObj *quadric_axis;
void drawCoordinates();
double drawTranslate[3];
double drawScale;
int bgSizeX;
int bgSizeY;
GLuint bgTexture;
void drawBgImage();
void changeNormalDirection(double*, double*);
void setMeshVisibility(bool, bool, bool);
public:
int mostVisibleBody(int, bool*);
};
#endif