void applyRenderer(IStorm3D &storm, const ProceduralProperties &properties) { IStorm3D_ProceduralManager &manager = storm.getProceduralManager(); int effectAmount = properties.getEffectAmount(); for(int i = 0; i < effectAmount; ++i) { const ProceduralProperties::Effect &source = properties.getEffect(i); IStorm3D_ProceduralManager::Effect effect; mapLayer(effect.source1, source.source1); mapLayer(effect.source2, source.source2); mapDistortion(effect.distortion1, source.distortion1); mapDistortion(effect.distortion2, source.distortion2); effect.enableDistortion = source.enableDistortion; effect.fallback = source.fallback; manager.addEffect(source.name, effect); } }
void QgsHtmlAnnotation::setAssociatedFeature( const QgsFeature &feature ) { QgsAnnotation::setAssociatedFeature( feature ); QString newText; QgsVectorLayer *vectorLayer = qobject_cast< QgsVectorLayer * >( mapLayer() ); if ( feature.isValid() && vectorLayer ) { QgsExpressionContext context( QgsExpressionContextUtils::globalProjectLayerScopes( vectorLayer ) ); context.setFeature( feature ); newText = QgsExpression::replaceExpressionText( mHtmlSource, &context ); } else { newText = mHtmlSource; } mWebPage->mainFrame()->setHtml( newText ); emit appearanceChanged(); }
void QgsHtmlAnnotation::readXml( const QDomElement &itemElem, const QgsReadWriteContext &context ) { mHtmlFile = itemElem.attribute( QStringLiteral( "htmlfile" ), QString() ); QDomElement annotationElem = itemElem.firstChildElement( QStringLiteral( "AnnotationItem" ) ); if ( !annotationElem.isNull() ) { _readXml( annotationElem, context ); } // upgrade old layer if ( !mapLayer() && itemElem.hasAttribute( QStringLiteral( "vectorLayer" ) ) ) { setMapLayer( QgsProject::instance()->mapLayer( itemElem.attribute( QStringLiteral( "vectorLayer" ) ) ) ); } if ( mWebPage ) { setSourceFile( mHtmlFile ); } }
QWidget *QgsFormAnnotation::createDesignerWidget( const QString &filePath ) { QFile file( filePath ); if ( !file.open( QFile::ReadOnly ) ) { return nullptr; } QUiLoader loader; QFileInfo fi( file ); loader.setWorkingDirectory( fi.dir() ); QWidget *widget = loader.load( &file, nullptr ); file.close(); //get feature and set attribute information QgsAttributeEditorContext context; QgsVectorLayer *vectorLayer = qobject_cast< QgsVectorLayer * >( mapLayer() ); if ( vectorLayer && associatedFeature().isValid() ) { QgsFields fields = vectorLayer->fields(); QgsAttributes attrs = associatedFeature().attributes(); for ( int i = 0; i < attrs.count(); ++i ) { if ( i < fields.count() ) { QWidget *attWidget = widget->findChild<QWidget *>( fields.at( i ).name() ); if ( attWidget ) { QgsEditorWidgetWrapper *eww = QgsGui::editorWidgetRegistry()->create( vectorLayer, i, attWidget, widget, context ); if ( eww ) { eww->setValue( attrs.at( i ) ); } } } } } return widget; }
void QgsFormAnnotation::readXml( const QDomElement &itemElem, const QgsReadWriteContext &context ) { mDesignerForm = itemElem.attribute( QStringLiteral( "designerForm" ), QString() ); QDomElement annotationElem = itemElem.firstChildElement( QStringLiteral( "AnnotationItem" ) ); if ( !annotationElem.isNull() ) { _readXml( annotationElem, context ); } // upgrade old layer if ( !mapLayer() && itemElem.hasAttribute( QStringLiteral( "vectorLayer" ) ) ) { setMapLayer( QgsProject::instance()->mapLayer( itemElem.attribute( QStringLiteral( "vectorLayer" ) ) ) ); } mDesignerWidget.reset( createDesignerWidget( mDesignerForm ) ); if ( mDesignerWidget && fillSymbol() ) { QgsFillSymbol *newFill = fillSymbol()->clone(); newFill->setColor( mDesignerWidget->palette().color( QPalette::Window ) ); setFillSymbol( newFill ); } }
void QgsHtmlAnnotation::javascript() { QWebFrame *frame = mWebPage->mainFrame(); frame->addToJavaScriptWindowObject( QStringLiteral( "layer" ), mapLayer() ); }