32 #include <qgenericmatrix.h>
34 #include <qmatrix4x4.h>
35 #include <qnamespace.h>
36 #include <qopengltexture.h>
38 #include <qtransform.h>
39 #include <qvector2d.h>
40 #include <qvector3d.h>
43 #pragma warning(disable : 4284)
60 #define IMG(id) OLocalizator::getPicture("TYAltimetrieGraphic", (id))
67 float hueRange[2] = {0.4f, 0.15f};
68 float saturationRange[2] = {1.0f, 0.8f};
69 float valueRange[2] = {0.5f, 0.25f};
82 float minSaturation = 255.0f;
83 float minValue = 255.0f;
84 float maxHue = 120.0f;
85 float maxSaturation = 255.0f;
86 float maxValue = 112.0f;
94 minSaturation, minValue);
97 maxSaturation, maxValue);
102 minSaturation, minValue);
104 maxSaturation, maxValue);
108 float adjustedMaxHue = minHue + 180 - abs(abs(maxHue - minHue) - 180);
109 float hueRange[2] = {minHue / 360.f, adjustedMaxHue / 360.f};
110 float saturationRange[2] = {minSaturation / 255.f, maxSaturation / 255.f};
111 float valueRange[2] = {minValue / 255.f, maxValue / 255.f};
112 qDebug() << hueRange << saturationRange << valueRange;
121 for (
int i = 0; i < getElement()->getListFaces().size(); i++)
123 TYElementGraphic* pTYElementGraphic = getElement()->getFace(i)->getGraphicObject();
124 childs.push_back(pTYElementGraphic);
127 pTYElementGraphic->
getChilds(childs, recursif);
136 for (
int i = 0; i < getElement()->getListFaces().size(); i++)
139 (
float)(getElement()->getFace(i)->getPoints()[0]._y),
140 (
float)(getElement()->getFace(i)->getPoints()[0]._z));
142 (
float)(getElement()->getFace(i)->getPoints()[1]._y),
143 (
float)(getElement()->getFace(i)->getPoints()[1]._z));
145 (
float)(getElement()->getFace(i)->getPoints()[2]._y),
146 (
float)(getElement()->getFace(i)->getPoints()[2]._z));
153 if (getElement() == NULL)
163 for (
int i = 0; i < getElement()->getListFaces().size(); i++)
165 TYElementGraphic* pTYElementGraphic = getElement()->getFace(i)->getGraphicObject();
167 if (pPolygonGraphic != NULL)
169 pPolygonGraphic->display(renderContext);
200 bool renderBackgroundImage =
_image !=
nullptr;
207 if (vecOrientation.
norme() != 0)
210 angle =
SIGNE(vecOrientation.
_y) * acos(vecOrientation.
_x / vecOrientation.
norme());
211 angle = (
M_PI / 2.0) - angle;
213 QMatrix4x4 backgroundImageTransform;
214 backgroundImageTransform.translate(0.5, 0.5);
215 backgroundImageTransform.scale(1. /
_semiX / 2, 1. /
_semiY / 2, 1);
217 backgroundImageTransform.rotate(-angle * 180 /
M_PI, 0, 0, 1);
219 std::vector<QVector3D> vertices;
220 std::vector<QVector3D> normals;
221 std::vector<QVector2D> textureCoordinates;
222 std::vector<QColor> verticesColors;
223 float zmin = NAN, zmax = NAN, zrange = NAN;
226 zrange = zmax - zmin;
227 for (
auto face : getElement()->getListFaces())
230 for (
int i : {0, 1, 2})
233 vertices.emplace_back(point.
_x, point.
_y, point.
_z);
234 normals.emplace_back(normal.
_x, normal.
_y, normal.
_z);
237 float scalar = (point.
_z - zmin) / zrange;
238 verticesColors.emplace_back(
_oColorMap[scalar * 255]);
240 textureCoordinates.emplace_back(backgroundImageTransform * QVector3D(point.
_x, point.
_y, 1));
243 if (renderBackgroundImage)
250 _mesh->material().image =
nullptr;
253 _mesh->setNormals(normals);
254 _mesh->setVertices(vertices);
255 std::vector<unsigned int> indices(vertices.size());
256 std::iota(indices.begin(), indices.end(), 0);
257 _mesh->setIndices(indices);
258 _mesh->setVerticesColors(verticesColors);
259 _mesh->setTextureCoordinates(textureCoordinates);
All base classes related to 3D manipulation.
double SIGNE(double a)
Return the number sign.
Representation graphique de l'altimetrie (fichier header)
list< TYElementGraphic * > TYListPtrTYElementGraphic
List de pointeur de TYElement.
#define TYDIRPREFERENCEMANAGER
Gestion de la table de correspondance indice/element pour le picking (fichier header)
Contexte de rendu utilisé par les fonctions d'affichage.
@ Picking
The current render is only done for picking purpose.
Classe Modeler specialisee pour l'edition des sites (fichier header)
virtual void Enlarge(const OPoint3D &pt)
Enlarge the box with the point if the point is outside the box.
OPoint3D _min
Minimal coordinates of the OBox.
OPoint3D _max
Maximal coordinates of the OBox.
double _y
y coordinate of OCoord3D
double _z
z coordinate of OCoord3D
double _x
x coordinate of OCoord3D
double norme() const
Computes the length of this vector.
OVector3D normal(const OVector3D &vector2, const OVector3D &vector3) const
Computes the normal with this vector and 2 others.
void setBackgroundImage(std::shared_ptr< QImage > &image, int semiX, int semiY, TYPoint ptPosition, OVector3D bgImageOrientation)
OVector3D _bgImageOrientation
virtual ~TYAltimetrieGraphic()
virtual OBox computeBoundingBox() const
std::shared_ptr< QImage > _image
TYAltimetrieGraphic(TYAltimetrie *pElement)
virtual void getChilds(TYListPtrTYElementGraphic &childs, bool recursif=true)
virtual void update(bool force=false)
void collectMeshInstances(std::vector< OGLMeshInstance > &meshInstances, TYRenderContext *renderContext) const override
std::shared_ptr< OGLArrayMesh > _mesh
virtual void display(TYRenderContext &renderContext)
void unsetBackgroundImage()
Assigne une altitude a chaque point de l'espace.
static void getLinearColorTable(const unsigned int &nbColors, const float *hueRange, const float *saturationRange, const float *valueRange, OLookupTable &outColors)
Generation de la table de couleurs basee sur une rampe lineaire ( y = x+0.5/255 )
classe graphique pour un element de base
bool _visible
Inique si l'element est visible.
virtual void update(bool force=false)
virtual void getChilds(TYListPtrTYElementGraphic &childs, bool recursif=true)
QMatrix4x4 globalMatrix() const
static void addElement(TYElement *pElt)
classe graphique pour un polygone