Skip to content
Permalink
Browse files

Fix some 2.5D renderer issues

 * Fixed height now works
 * Add some GUI elements to access the configuration options
  • Loading branch information
m-kuhn committed Jan 18, 2016
1 parent 911caaa commit 9a2f46eb1ac9865e235b42a1d101389538d08fe0
@@ -84,7 +84,7 @@ Qgs25DRenderer::Qgs25DRenderer()
setShadowSpread( 4 );
setShadowColor( QColor( "#1111111" ) );

setHeight( "20" );
setHeight( QString( "20" ) );
setAngle( 40 );

QgsFeatureRequest::OrderBy orderBy;
@@ -122,7 +122,7 @@ QgsFeatureRendererV2* Qgs25DRenderer::create( QDomElement& element )
void Qgs25DRenderer::startRender( QgsRenderContext& context, const QgsFields& fields )
{
QgsExpressionContextScope* scope = new QgsExpressionContextScope( "2.5D Renderer" );
scope->setVariable( "qgis_25d_height", mHeight.field() );
scope->setVariable( "qgis_25d_height", mHeight.expressionOrField() );
scope->setVariable( "qgis_25d_angle", mAngle );
context.expressionContext().appendScope( scope );
mSymbol->startRender( context, &fields );
@@ -197,6 +197,16 @@ QgsOuterGlowEffect* Qgs25DRenderer::glowEffect() const
return static_cast<QgsOuterGlowEffect*>( mSymbol->symbolLayer( 0 )->paintEffect() );
}

bool Qgs25DRenderer::shadowEnabled() const
{
return glowEffect()->enabled();
}

void Qgs25DRenderer::setShadowEnabled( bool value )
{
glowEffect()->setEnabled( value );
}

QColor Qgs25DRenderer::shadowColor() const
{
return glowEffect()->color();
@@ -107,6 +107,15 @@ class CORE_EXPORT Qgs25DRenderer : public QgsFeatureRendererV2
*/
static Qgs25DRenderer* convertFromRenderer( QgsFeatureRendererV2* renderer );

/**
* Is the shadow enabled
*/
bool shadowEnabled() const;
/**
* Enable or disable the shadow
*/
void setShadowEnabled( bool value );

private:

QgsFillSymbolLayerV2* roofLayer() const;
@@ -46,11 +46,17 @@ Qgs25DRendererWidget::Qgs25DRendererWidget( QgsVectorLayer* layer, QgsStyleV2* s
mAngleWidget->setValue( mRenderer->angle() );
mWallColorButton->setColor( mRenderer->wallColor() );
mRoofColorButton->setColor( mRenderer->roofColor() );
mShadowColorButton->setColor( mRenderer->shadowColor() );
mShadowEnabledWidget->setEnabled( mRenderer->shadowEnabled() );
mShadowSizeWidget->setValue( mRenderer->shadowSpread() );

connect( mAngleWidget, SIGNAL( valueChanged( int ) ), this, SLOT( updateRenderer() ) );
connect( mHeightWidget, SIGNAL( fieldChanged( QString ) ), this, SLOT( updateRenderer() ) );
connect( mWallColorButton, SIGNAL( colorChanged( QColor ) ), this, SLOT( updateRenderer() ) );
connect( mRoofColorButton, SIGNAL( colorChanged( QColor ) ), this, SLOT( updateRenderer() ) );
connect( mShadowColorButton, SIGNAL( colorChanged( QColor ) ), this, SLOT( updateRenderer() ) );
connect( mShadowEnabledWidget, SIGNAL( toggled( bool ) ), this, SLOT( updateRenderer() ) );
connect( mShadowSizeWidget, SIGNAL( valueChanged( double ) ), this, SLOT( updateRenderer() ) );
}

QgsFeatureRendererV2* Qgs25DRendererWidget::renderer()
@@ -64,6 +70,9 @@ void Qgs25DRendererWidget::updateRenderer()
mRenderer->setAngle( mAngleWidget->value() );
mRenderer->setRoofColor( mRoofColorButton->color() );
mRenderer->setWallColor( mWallColorButton->color() );
mRenderer->setShadowColor( mShadowColorButton->color() );
mRenderer->setShadowEnabled( mShadowEnabledWidget->isChecked() );
mRenderer->setShadowSpread( mShadowSizeWidget->value() );
}

QgsRendererV2Widget* Qgs25DRendererWidget::create( QgsVectorLayer* layer, QgsStyleV2* style, QgsFeatureRendererV2* renderer )
@@ -62,6 +62,42 @@
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QGroupBox" name="mShadowEnabledWidget">
<property name="title">
<string>Shadow</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QFormLayout" name="formLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QgsColorButtonV2" name="mShadowColorButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="mShadowSizeWidget"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Size</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>

13 comments on commit 9a2f46e

@nirvn

This comment has been minimized.

Copy link
Contributor

@nirvn nirvn replied Jan 19, 2016

@m-kuhn fantastic, the shadow options are great.

Allow me to drop in a last suggestion: allow for data-defined color settings. It's a very important implementation detail that IMO should be in when the feature is released to make sure the symbology isn't a "one trick pony" ;)

With data-defined colors, users will be able to do color highlight of feature(s). Thinking for e.g. of a building layer rendered with the 2.5D symbology, with one or two buildings colored differently to highlight them.

@m-kuhn

This comment has been minimized.

Copy link
Member Author

@m-kuhn m-kuhn replied Jan 19, 2016

Yes, there are a lot of interesting options left.

One thing: you can convert this to any other renderer and you will have full control. (Still need to promote the variables to layer variables manually though)
So adding it here would be nice, but everything is only a shorthand for features achievable otherwise.

One question for you, @nirvn, do you know what needs to be changed to make classification work after converting it to such a renderer? Some locking, unlocking of symbols? where?

@nirvn

This comment has been minimized.

Copy link
Contributor

@nirvn nirvn replied Jan 19, 2016

@m-kuhn , yeah I noticed that switching to single symbol kept the individual layers, and bumped into the @variable issue :) On that point, would it not be better for the 2.5d symbology code to set the variables as layer variables (instead of being created at rendering time)? That way, you could switch back to simple symbol and have it working instantaneously without requiring to manually edit half a dozen data-defined expressions.

If that can be fixed, then I'd be happy to go down that road to highlight individual features / buildings :)

@nirvn

This comment has been minimized.

Copy link
Contributor

@nirvn nirvn replied Jan 19, 2016

@m-kuhn teasing you as a transparent way to incite this:
cool-25d

😄

@m-kuhn

This comment has been minimized.

Copy link
Member Author

@m-kuhn m-kuhn replied Jan 19, 2016

The variable issue is on my todo list, no worries. But having more control from inside the configuration interface is definitely nice as well

@m-kuhn

This comment has been minimized.

Copy link
Member Author

@m-kuhn m-kuhn replied Jan 19, 2016

Can we use this image for the visual changelog?

@nirvn

This comment has been minimized.

Copy link
Contributor

@nirvn nirvn replied Jan 19, 2016

@m-kuhn of course.

@m-kuhn

This comment has been minimized.

Copy link
Member Author

@m-kuhn m-kuhn replied Jan 19, 2016

@nirvn was the image above generated with layer variables or with editing the expression?

@nirvn

This comment has been minimized.

Copy link
Contributor

@nirvn nirvn replied Jan 19, 2016

@m-kuhn with layer variables which duplicates the variable set by the 2.5D symbology. IMO the symbology should set variables at the layer level so no editing is needed, as per our discussion.

@m-kuhn

This comment has been minimized.

Copy link
Member Author

@m-kuhn m-kuhn replied Jan 19, 2016

There are some strange ordering z-index issues which I wonder why they happen

@nirvn

This comment has been minimized.

Copy link
Contributor

@nirvn nirvn replied Jan 19, 2016

@m-kuhn I can share the full building footprint dataset I'm using here if you want to test things around.

@m-kuhn

This comment has been minimized.

Copy link
Member Author

@m-kuhn m-kuhn replied Jan 19, 2016

That would be nice

@m-kuhn

This comment has been minimized.

Copy link
Member Author

@m-kuhn m-kuhn replied Jan 19, 2016

uster

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