Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
QHyodaGLCell.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7#include <QHyodaGLCell.h>
8#include <QOpenGLFunctions>
9
10/******************************************************************************
11 * QHyodaGLCell class
12 *****************************************************************************/
13QHyodaGLCell::QHyodaGLCell(QWidget *parent):QHyodaGL(parent){
14 qDebug()<<"\33[36m[QHyodaGLCell::QHyodaGLCell] NEW\33[m";
15}
16
17
18void QHyodaGLCell::clear(){
19 nodes.clear();
20 colors.clear();
21}
22
23void QHyodaGLCell::add_node(const QVector3D &node_coords, const QColor color){
24 nodes.append(node_coords);
25 colors.append(QVector4D(color.redF(),color.greenF(),color.blueF(),color.alphaF()));
26}
27
28
29/******************************************************************************
30 * draw
31 *****************************************************************************/
32void QHyodaGLCell::draw() const{
33 //qDebug()<<"\t\33[36m[QHyodaGLCell:draw]\33[m";
34 const QColor color=QColor(Qt::green);
35
36 glEnableClientState(GL_VERTEX_ARRAY);
37 glEnableClientState(GL_COLOR_ARRAY);
38
39 // Loading vertices & colors
40 glVertexPointer(3, GL_FLOAT, 0, nodes.constData());
41 glColorPointer(4, GL_FLOAT, 0, colors.constData());
42
43 glPushMatrix();
44
45 // On fait les pointillés derrière
46 glLineWidth(1.0);
47 glEnable(GL_LINE_STIPPLE);
48 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
49 if (cell_nb_nodes==3) glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_BYTE, stdIdx);
50 if (cell_nb_nodes==4) glDrawElements(GL_QUADS, 4, GL_UNSIGNED_BYTE, stdIdx);
51 if (cell_nb_nodes==8) glDrawElements(GL_QUADS, 24, GL_UNSIGNED_BYTE, hexIdx);
52
53 // Et ou revient pour les arêtes du devant
54 glLineWidth(2.0);
55 glDisable(GL_LINE_STIPPLE);
56 glPolygonMode(GL_FRONT, GL_LINE);
57 glPolygonMode(GL_BACK, GL_POINT);
58 if (cell_nb_nodes==3) glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_BYTE, stdIdx);
59 if (cell_nb_nodes==4) glDrawElements(GL_QUADS, 4, GL_UNSIGNED_BYTE, stdIdx);
60 if (cell_nb_nodes==8) glDrawElements(GL_QUADS, 24, GL_UNSIGNED_BYTE, hexIdx);
61
62 // Les noeuds
63 glDisableClientState(GL_COLOR_ARRAY);
64 glColor4f(color.redF(), color.greenF(), color.blueF(), color.alphaF());
65 glDrawElements(GL_POINTS, 8, GL_UNSIGNED_BYTE, stdIdx);
66 glEnableClientState(GL_COLOR_ARRAY);
67
68 glPopMatrix();
69
70 glDisableClientState(GL_VERTEX_ARRAY);
71 glDisableClientState(GL_COLOR_ARRAY);
72}