Skip to content
Permalink
Browse files

Dxf: possibility to export only the features overlapping the map extent

  • Loading branch information
mhugent committed Dec 10, 2013
1 parent b6f7a99 commit b1b7904e14f592e7f4f05d3d97bf693e132728a4
@@ -3846,7 +3846,14 @@ void QgisApp::dxfExport()
{
dxfExport.setMapUnits( r->mapUnits() );
}

//extent
if ( d.exportMapExtent() )
{
dxfExport.setExtent( mapCanvas()->extent() );
}
}

QFile dxfFile( d.saveFile() );
if ( dxfExport.writeToFile( &dxfFile ) == 0 )
{
@@ -140,6 +140,11 @@ void QgsDxfExportDialog::setOkEnabled()
btn->setEnabled( fi.absoluteDir().exists() );
}

bool QgsDxfExportDialog::exportMapExtent() const
{
return mMapExtentCheckBox->isChecked();
}

void QgsDxfExportDialog::saveSettings()
{
QSettings s;
@@ -32,6 +32,7 @@ class QgsDxfExportDialog: public QDialog, private Ui::QgsDxfExportDialogBase
double symbologyScale() const;
QgsDxfExport::SymbologyExport symbologyMode() const;
QString saveFile() const;
bool exportMapExtent() const;

public slots:
/** change the selection of layers in the list */
@@ -565,9 +565,13 @@ void QgsDxfExport::writeEntities()
renderer->stopRender( ctx );
}


QgsFeatureIterator featureIt = vl->getFeatures( QgsFeatureRequest().setSubsetOfAttributes(
renderer->usedAttributes(), dp->fields() ) );
QgsFeatureRequest freq = QgsFeatureRequest().setSubsetOfAttributes(
renderer->usedAttributes(), dp->fields() );
if ( !mExtent.isEmpty() )
{
freq.setFilterRect( mExtent );
}
QgsFeatureIterator featureIt = vl->getFeatures( freq );
QgsFeature fet;
while ( featureIt.nextFeature( fet ) )
{
@@ -625,6 +629,10 @@ void QgsDxfExport::writeEntitiesSymbolLevels( QgsVectorLayer* layer )
req.setFlags( QgsFeatureRequest::NoGeometry );
}
req.setSubsetOfAttributes( QStringList( renderer->usedAttributes() ), layer->pendingFields() );
if ( !mExtent.isEmpty() )
{
req.setFilterRect( mExtent );
}
QgsFeatureIterator fit = layer->getFeatures( req );

//fetch features
@@ -56,6 +56,9 @@ class CORE_EXPORT QgsDxfExport
void setSymbologyExport( SymbologyExport e ) { mSymbologyExport = e; }
SymbologyExport symbologyExport() const { return mSymbologyExport; }

void setExtent( const QgsRectangle& r ) { mExtent = r; }
QgsRectangle extent() const { return mExtent; }

//get closest entry in dxf palette
static int closestColorMatch( QRgb pixel );

@@ -83,6 +86,8 @@ class CORE_EXPORT QgsDxfExport
private:

QList< QgsMapLayer* > mLayers;
/**Extent for export, only intersecting features are exported. If the extent is an empty rectangle, all features are exported*/
QgsRectangle mExtent;
/**Scale for symbology export (used if symbols units are mm)*/
double mSymbologyScaleDenominator;
SymbologyExport mSymbologyExport;
@@ -115,6 +115,13 @@
</item>
</layout>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="mMapExtentCheckBox">
<property name="text">
<string>Export features intersecting the current map extent</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>

0 comments on commit b1b7904

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