Skip to content

Commit

Permalink
fix layout code
Browse files Browse the repository at this point in the history
  • Loading branch information
vcloarec committed Jan 16, 2020
1 parent 1c4a20f commit 23de310
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/3d/mesh/qgsmesh3dentity_p.cpp
Expand Up @@ -83,7 +83,7 @@ void QgsMesh3dEntity::buildGeometry()

void QgsMesh3dEntity::applyMaterial()
{
mMaterial = new QgsMesh3dMaterial( QgsMesh3dMaterial::ScalarDataSet, mSymbol );
mMaterial = new QgsMesh3dMaterial( mSymbol );
addComponent( mMaterial );
}

Expand Down Expand Up @@ -120,6 +120,6 @@ void QgsMesh3dTerrainTileEntity::buildGeometry()

void QgsMesh3dTerrainTileEntity::applyMaterial()
{
mMaterial = new QgsMesh3dMaterial( QgsMesh3dMaterial::ZValue, mSymbol );
mMaterial = new QgsMesh3dMaterial( mSymbol );
addComponent( mMaterial );
}
4 changes: 1 addition & 3 deletions src/3d/mesh/qgsmesh3dmaterial_p.cpp
Expand Up @@ -136,8 +136,7 @@ class ColorRampTexture: public Qt3DRender::QAbstractTextureImage
};


QgsMesh3dMaterial::QgsMesh3dMaterial( MagnitudeType magnitudeType, const QgsMesh3DSymbol &symbol ):
mMagnitudeType( magnitudeType ),
QgsMesh3dMaterial::QgsMesh3dMaterial( const QgsMesh3DSymbol &symbol ):
mSymbol( symbol )
{
Qt3DRender::QEffect *eff = new Qt3DRender::QEffect( this );
Expand All @@ -149,7 +148,6 @@ QgsMesh3dMaterial::QgsMesh3dMaterial( MagnitudeType magnitudeType, const QgsMesh

void QgsMesh3dMaterial::configure()
{

Qt3DRender::QTexture1D *colorRampTexture = new Qt3DRender::QTexture1D;
colorRampTexture->addTextureImage( new ColorRampTexture( mSymbol.colorRampShader() ) );
colorRampTexture->setMinificationFilter( Qt3DRender::QTexture1D::Linear );
Expand Down
10 changes: 5 additions & 5 deletions src/3d/mesh/qgsmesh3dmaterial_p.h
Expand Up @@ -46,28 +46,28 @@
class QgsMesh3dMaterial : public Qt3DRender::QMaterial
{
public:
//! enum used to defined wich type of value will be used to render the 3D entity
//! enum used to defined which type of value will be used to render the 3D entity
enum MagnitudeType
{

/**
* Only the z values of the mesh will be used to build the geometry and to render the color
* Used to render the terrain
*/
ZValue,

/**
* The datasets are used to build the geometry and to render the color
* For example, can be used to render the geometry of the water surface with color varying with velocity
*/
ScalarDataSet
};

//! Contructor
QgsMesh3dMaterial( MagnitudeType magnitudeType, const QgsMesh3DSymbol &symbol );
//! Constructor
QgsMesh3dMaterial( const QgsMesh3DSymbol &symbol );

private:
MagnitudeType mMagnitudeType;
QgsMesh3DSymbol mSymbol;
Qt3DRender::QBuffer *mColorsRampBuffer = nullptr;
Qt3DRender::QTechnique *mTechnique;

void configure();
Expand Down
19 changes: 18 additions & 1 deletion src/3d/mesh/qgsmeshterraingenerator.cpp
@@ -1,3 +1,20 @@
/***************************************************************************
qgsmeshterraingenerator.cpp
-------------------------
begin : january 2020
copyright : (C) 2020 by Vincent Cloarec
email : vcloarec at gmail dot com
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgsmeshterraingenerator.h"

#include <Qt3DRender/QMaterial>
Expand Down Expand Up @@ -39,7 +56,7 @@ QgsChunkLoader *QgsMeshTerrainGenerator::createChunkLoader( QgsChunkNode *node )

/*
* Force to create a triangularMesh by create a renderer, if it does not have been created yet
* Not very clean but could be improve when improvment of mesh triangulation handling
* Not very clean but could be improve with mesh triangulation handling in the future
*/
QgsRenderContext renderContext;
renderContext.setCoordinateTransform( terrainToMapTransform );
Expand Down
17 changes: 17 additions & 0 deletions src/3d/mesh/qgsmeshterraingenerator.h
@@ -1,3 +1,20 @@
/***************************************************************************
qgsmeshterraingenerator.h
-------------------------
begin : january 2020
copyright : (C) 2020 by Vincent Cloarec
email : vcloarec at gmail dot com
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSMESHTERRAINGENERATOR_H
#define QGSMESHTERRAINGENERATOR_H

Expand Down
5 changes: 0 additions & 5 deletions src/3d/qgs3dmapscene.cpp
Expand Up @@ -222,11 +222,6 @@ float Qgs3DMapScene::worldSpaceError( float epsilon, float distance )
return err;
}

void Qgs3DMapScene::setViewport( const QRect &viewportrect )
{
cameraController()->setViewport( viewportrect );
}

QgsChunkedEntity::SceneState _sceneState( QgsCameraController *cameraController )
{
Qt3DRender::QCamera *camera = cameraController->camera();
Expand Down
3 changes: 0 additions & 3 deletions src/3d/qgs3dmapscene.h
Expand Up @@ -90,9 +90,6 @@ class _3D_EXPORT Qgs3DMapScene : public Qt3DCore::QEntity
*/
float worldSpaceError( float epsilon, float distance );


void setViewport( const QRect &viewportrect );

signals:
//! Emitted when the current terrain entity is replaced by a new one
void terrainEntityChanged();
Expand Down
2 changes: 1 addition & 1 deletion src/app/3d/qgsmesh3dsymbolwidget.cpp
Expand Up @@ -87,7 +87,7 @@ void QgsMesh3dSymbolWidget::setLayer( QgsMeshLayer *meshLayer, bool updateSymbol
}
}
setSymbol( QgsMesh3DSymbol() );
reloadColorRampShaderMinMax(); //As the symbol is new, the Color ramp shader need to be initialise with min max value
reloadColorRampShaderMinMax(); //As the symbol is new, the Color ramp shader needs to be initialized with min max value
}

double QgsMesh3dSymbolWidget::lineEditValue( const QLineEdit *lineEdit ) const
Expand Down

0 comments on commit 23de310

Please sign in to comment.