本文整理汇总了C++中QgsSymbolV2::type方法的典型用法代码示例。如果您正苦于以下问题:C++ QgsSymbolV2::type方法的具体用法?C++ QgsSymbolV2::type怎么用?C++ QgsSymbolV2::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QgsSymbolV2
的用法示例。
在下文中一共展示了QgsSymbolV2::type方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
QgsSymbolV2* QgsCategorizedSymbolRendererV2::symbolForFeature( QgsFeature& feature )
{
QgsSymbolV2* symbol = originalSymbolForFeature( feature );
if ( !symbol )
return 0;
if ( !mRotation.data() && !mSizeScale.data() )
return symbol; // no data-defined rotation/scaling - just return the symbol
// find out rotation, size scale
const double rotation = mRotation.data() ? mRotation->evaluate( feature ).toDouble() : 0;
const double sizeScale = mSizeScale.data() ? mSizeScale->evaluate( feature ).toDouble() : 1.;
// take a temporary symbol (or create it if doesn't exist)
QgsSymbolV2* tempSymbol = mTempSymbols[symbol];
// modify the temporary symbol and return it
if ( tempSymbol->type() == QgsSymbolV2::Marker )
{
QgsMarkerSymbolV2* markerSymbol = static_cast<QgsMarkerSymbolV2*>( tempSymbol );
if ( mRotation.data() ) markerSymbol->setAngle( rotation );
markerSymbol->setSize( sizeScale * static_cast<QgsMarkerSymbolV2*>( symbol )->size() );
markerSymbol->setScaleMethod( mScaleMethod );
}
else if ( tempSymbol->type() == QgsSymbolV2::Line )
{
QgsLineSymbolV2* lineSymbol = static_cast<QgsLineSymbolV2*>( tempSymbol );
lineSymbol->setWidth( sizeScale * static_cast<QgsLineSymbolV2*>( symbol )->width() );
}
return tempSymbol;
}
示例2: if
QgsSymbolV2* QgsCategorizedSymbolRendererV2::symbolForFeature( QgsFeature& feature )
{
const QgsAttributeMap& attrMap = feature.attributeMap();
QgsAttributeMap::const_iterator ita = attrMap.find( mAttrNum );
if ( ita == attrMap.end() )
{
QgsDebugMsg( "attribute '" + mAttrName + "' (index " + QString::number( mAttrNum ) + ") required by renderer not found" );
return NULL;
}
// find the right symbol for the category
QgsSymbolV2* symbol = symbolForValue( *ita );
if ( symbol == NULL )
{
// if no symbol found use default one
//return symbolForValue( QVariant( "" ) );
// What is default? Empty string may be a legal value, and features not found
// should not be rendered using empty string value category symbology.
// We also need to get NULL in that case so that willRenderFeature()
// may be used to count features.
return 0;
}
if ( mRotationFieldIdx == -1 && mSizeScaleFieldIdx == -1 )
return symbol; // no data-defined rotation/scaling - just return the symbol
// find out rotation, size scale
double rotation = 0;
double sizeScale = 1;
if ( mRotationFieldIdx != -1 )
rotation = attrMap[mRotationFieldIdx].toDouble();
if ( mSizeScaleFieldIdx != -1 )
sizeScale = attrMap[mSizeScaleFieldIdx].toDouble();
// take a temporary symbol (or create it if doesn't exist)
QgsSymbolV2* tempSymbol = mTempSymbols[ita->toString()];
// modify the temporary symbol and return it
if ( tempSymbol->type() == QgsSymbolV2::Marker )
{
QgsMarkerSymbolV2* markerSymbol = static_cast<QgsMarkerSymbolV2*>( tempSymbol );
if ( mRotationFieldIdx != -1 )
markerSymbol->setAngle( rotation );
if ( mSizeScaleFieldIdx != -1 )
markerSymbol->setSize( sizeScale * static_cast<QgsMarkerSymbolV2*>( symbol )->size() );
markerSymbol->setScaleMethod( mScaleMethod );
}
else if ( tempSymbol->type() == QgsSymbolV2::Line )
{
QgsLineSymbolV2* lineSymbol = static_cast<QgsLineSymbolV2*>( tempSymbol );
if ( mSizeScaleFieldIdx != -1 )
lineSymbol->setWidth( sizeScale * static_cast<QgsLineSymbolV2*>( symbol )->width() );
}
return tempSymbol;
}
示例3: if
QgsSymbolV2* QgsGraduatedSymbolRendererV2::symbolForFeature( QgsFeature& feature )
{
const QgsAttributes& attrs = feature.attributes();
if ( mAttrNum < 0 || mAttrNum >= attrs.count() )
{
QgsDebugMsg( "attribute required by renderer not found: " + mAttrName + "(index " + QString::number( mAttrNum ) + ")" );
return NULL;
}
// Null values should not be categorized
if ( attrs[mAttrNum].isNull() )
return NULL;
// find the right category
QgsSymbolV2* symbol = symbolForValue( attrs[mAttrNum].toDouble() );
if ( symbol == NULL )
return NULL;
if ( mRotationFieldIdx == -1 && mSizeScaleFieldIdx == -1 )
return symbol; // no data-defined rotation/scaling - just return the symbol
// find out rotation, size scale
double rotation = 0;
double sizeScale = 1;
if ( mRotationFieldIdx != -1 )
rotation = attrs[mRotationFieldIdx].toDouble();
if ( mSizeScaleFieldIdx != -1 )
sizeScale = attrs[mSizeScaleFieldIdx].toDouble();
// take a temporary symbol (or create it if doesn't exist)
QgsSymbolV2* tempSymbol = mTempSymbols[symbol];
// modify the temporary symbol and return it
if ( tempSymbol->type() == QgsSymbolV2::Marker )
{
QgsMarkerSymbolV2* markerSymbol = static_cast<QgsMarkerSymbolV2*>( tempSymbol );
if ( mRotationFieldIdx != -1 )
markerSymbol->setAngle( rotation );
if ( mSizeScaleFieldIdx != -1 )
markerSymbol->setSize( sizeScale * static_cast<QgsMarkerSymbolV2*>( symbol )->size() );
markerSymbol->setScaleMethod( mScaleMethod );
}
else if ( tempSymbol->type() == QgsSymbolV2::Line )
{
QgsLineSymbolV2* lineSymbol = static_cast<QgsLineSymbolV2*>( tempSymbol );
if ( mSizeScaleFieldIdx != -1 )
lineSymbol->setWidth( sizeScale * static_cast<QgsLineSymbolV2*>( symbol )->width() );
}
return tempSymbol;
}
示例4: symbolForValue
QgsSymbolV2* QgsCategorizedSymbolRendererV2::symbolForFeature( QgsFeature& feature )
{
const QgsAttributes& attrs = feature.attributes();
QVariant value;
if ( mAttrNum == -1 )
{
Q_ASSERT( mExpression.data() );
value = mExpression->evaluate( &feature );
}
else
{
value = attrs[mAttrNum];
}
// find the right symbol for the category
QgsSymbolV2* symbol = symbolForValue( value );
if ( symbol == NULL )
{
// if no symbol found use default one
return symbolForValue( QVariant( "" ) );
}
if ( !mRotation.data() && !mSizeScale.data() )
return symbol; // no data-defined rotation/scaling - just return the symbol
// find out rotation, size scale
const double rotation = mRotation.data() ? mRotation->evaluate( feature ).toDouble() : 0;
const double sizeScale = mSizeScale.data() ? mSizeScale->evaluate( feature ).toDouble() : 1.;
// take a temporary symbol (or create it if doesn't exist)
QgsSymbolV2* tempSymbol = mTempSymbols[value.toString()];
// modify the temporary symbol and return it
if ( tempSymbol->type() == QgsSymbolV2::Marker )
{
QgsMarkerSymbolV2* markerSymbol = static_cast<QgsMarkerSymbolV2*>( tempSymbol );
if ( mRotation.data() ) markerSymbol->setAngle( rotation );
markerSymbol->setSize( sizeScale * static_cast<QgsMarkerSymbolV2*>( symbol )->size() );
markerSymbol->setScaleMethod( mScaleMethod );
}
else if ( tempSymbol->type() == QgsSymbolV2::Line )
{
QgsLineSymbolV2* lineSymbol = static_cast<QgsLineSymbolV2*>( tempSymbol );
lineSymbol->setWidth( sizeScale * static_cast<QgsLineSymbolV2*>( symbol )->width() );
}
return tempSymbol;
}
示例5: p
void QgsSymbolV2SelectorDialog::populateSymbolView()
{
QSize previewSize = viewSymbols->iconSize();
QPixmap p( previewSize );
QPainter painter;
QStandardItemModel* model = qobject_cast<QStandardItemModel*>( viewSymbols->model() );
if ( !model )
{
return;
}
model->clear();
QStringList names = mStyle->symbolNames();
for ( int i = 0; i < names.count(); i++ )
{
QgsSymbolV2* s = mStyle->symbol( names[i] );
if ( s->type() != mSymbol->type() )
{
delete s;
continue;
}
QStandardItem* item = new QStandardItem( names[i] );
item->setData( names[i], Qt::UserRole ); //so we can show a label when it is clicked
item->setText( "" ); //set the text to nothing and show in label when clicked rather
item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
// create preview icon
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon( s, previewSize );
item->setIcon( icon );
// add to model
model->appendRow( item );
delete s;
}
}
示例6: currentItemType
void QgsStyleV2ManagerDialog::populateSymbols( const QStringList& symbolNames, bool check )
{
QStandardItemModel* model = qobject_cast<QStandardItemModel*>( listItems->model() );
model->clear();
int type = currentItemType();
for ( int i = 0; i < symbolNames.count(); ++i )
{
QString name = symbolNames[i];
QgsSymbolV2* symbol = mStyle->symbol( name );
if ( symbol && symbol->type() == type )
{
QStandardItem* item = new QStandardItem( name );
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon( symbol, listItems->iconSize() );
item->setIcon( icon );
item->setData( name ); // used to find out original name when user edited the name
item->setCheckable( check );
item->setToolTip( name );
// add to model
model->appendRow( item );
}
delete symbol;
}
selectedSymbolsChanged( QItemSelection(), QItemSelection() );
symbolSelected( listItems->currentIndex() );
}
示例7: if
QgsSymbolV2* QgsGraduatedSymbolRendererV2::symbolForFeature( QgsFeature& feature )
{
const QgsAttributes& attrs = feature.attributes();
QVariant value;
if ( mAttrNum < 0 || mAttrNum >= attrs.count() )
{
value = mExpression->evaluate( &feature );
}
else
{
value = attrs[mAttrNum];
}
// Null values should not be categorized
if ( value.isNull() )
return NULL;
// find the right category
QgsSymbolV2* symbol = symbolForValue( value.toDouble() );
if ( symbol == NULL )
return NULL;
if ( !mRotation.data() && !mSizeScale.data() )
return symbol; // no data-defined rotation/scaling - just return the symbol
// find out rotation, size scale
const double rotation = mRotation.data() ? mRotation->evaluate( feature ).toDouble() : 0;
const double sizeScale = mSizeScale.data() ? mSizeScale->evaluate( feature ).toDouble() : 1.;
// take a temporary symbol (or create it if doesn't exist)
QgsSymbolV2* tempSymbol = mTempSymbols[symbol];
// modify the temporary symbol and return it
if ( tempSymbol->type() == QgsSymbolV2::Marker )
{
QgsMarkerSymbolV2* markerSymbol = static_cast<QgsMarkerSymbolV2*>( tempSymbol );
if ( mRotation.data() ) markerSymbol->setAngle( rotation );
markerSymbol->setSize( sizeScale * static_cast<QgsMarkerSymbolV2*>( symbol )->size() );
markerSymbol->setScaleMethod( mScaleMethod );
}
else if ( tempSymbol->type() == QgsSymbolV2::Line )
{
QgsLineSymbolV2* lineSymbol = static_cast<QgsLineSymbolV2*>( tempSymbol );
lineSymbol->setWidth( sizeScale * static_cast<QgsLineSymbolV2*>( symbol )->width() );
}
return tempSymbol;
}
示例8: if
QgsSymbolV2* QgsCategorizedSymbolRendererV2::symbolForFeature( QgsFeature& feature )
{
const QgsAttributeMap& attrMap = feature.attributeMap();
QgsAttributeMap::const_iterator ita = attrMap.find( mAttrNum );
if ( ita == attrMap.end() )
{
QgsDebugMsg( "attribute '" + mAttrName + "' (index " + QString::number( mAttrNum ) + ") required by renderer not found" );
return NULL;
}
// find the right symbol for the category
QgsSymbolV2* symbol = symbolForValue( *ita );
if ( symbol == NULL )
return NULL;
if ( mRotationFieldIdx == -1 && mSizeScaleFieldIdx == -1 )
return symbol; // no data-defined rotation/scaling - just return the symbol
// find out rotation, size scale
double rotation = 0;
double sizeScale = 1;
if ( mRotationFieldIdx != -1 )
rotation = attrMap[mRotationFieldIdx].toDouble();
if ( mSizeScaleFieldIdx != -1 )
sizeScale = attrMap[mSizeScaleFieldIdx].toDouble();
// take a temporary symbol (or create it if doesn't exist)
QgsSymbolV2* tempSymbol = mTempSymbols[ita->toString()];
// modify the temporary symbol and return it
if ( tempSymbol->type() == QgsSymbolV2::Marker )
{
QgsMarkerSymbolV2* markerSymbol = static_cast<QgsMarkerSymbolV2*>( tempSymbol );
if ( mRotationFieldIdx != -1 )
markerSymbol->setAngle( rotation );
if ( mSizeScaleFieldIdx != -1 )
markerSymbol->setSize( sizeScale * static_cast<QgsMarkerSymbolV2*>( symbol )->size() );
}
else if ( tempSymbol->type() == QgsSymbolV2::Line )
{
QgsLineSymbolV2* lineSymbol = static_cast<QgsLineSymbolV2*>( tempSymbol );
if ( mSizeScaleFieldIdx != -1 )
lineSymbol->setWidth( sizeScale * static_cast<QgsLineSymbolV2*>( symbol )->width() );
}
return tempSymbol;
}