Skip to content
Permalink
Browse files

fix layout code

  • Loading branch information
vcloarec committed Jan 16, 2020
1 parent 1c4a20f commit 23de3109cc052d700e45ea18862f4bb216edf544
@@ -83,7 +83,7 @@ void QgsMesh3dEntity::buildGeometry()

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

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

void QgsMesh3dTerrainTileEntity::applyMaterial()
{
mMaterial = new QgsMesh3dMaterial( QgsMesh3dMaterial::ZValue, mSymbol );
mMaterial = new QgsMesh3dMaterial( mSymbol );
addComponent( mMaterial );
}
@@ -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 );
@@ -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 );
@@ -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();
@@ -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>
@@ -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 );
@@ -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

@@ -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();
@@ -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();
@@ -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

0 comments on commit 23de310

Please sign in to comment.
You can’t perform that action at this time.