Skip to content

Commit b1b7904

Browse files
committedDec 10, 2013
Dxf: possibility to export only the features overlapping the map extent
1 parent b6f7a99 commit b1b7904

File tree

6 files changed

+36
-3
lines changed

6 files changed

+36
-3
lines changed
 

‎src/app/qgisapp.cpp‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3846,7 +3846,14 @@ void QgisApp::dxfExport()
38463846
{
38473847
dxfExport.setMapUnits( r->mapUnits() );
38483848
}
3849+
3850+
//extent
3851+
if ( d.exportMapExtent() )
3852+
{
3853+
dxfExport.setExtent( mapCanvas()->extent() );
3854+
}
38493855
}
3856+
38503857
QFile dxfFile( d.saveFile() );
38513858
if ( dxfExport.writeToFile( &dxfFile ) == 0 )
38523859
{

‎src/app/qgsdxfexportdialog.cpp‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ void QgsDxfExportDialog::setOkEnabled()
140140
btn->setEnabled( fi.absoluteDir().exists() );
141141
}
142142

143+
bool QgsDxfExportDialog::exportMapExtent() const
144+
{
145+
return mMapExtentCheckBox->isChecked();
146+
}
147+
143148
void QgsDxfExportDialog::saveSettings()
144149
{
145150
QSettings s;

‎src/app/qgsdxfexportdialog.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class QgsDxfExportDialog: public QDialog, private Ui::QgsDxfExportDialogBase
3232
double symbologyScale() const;
3333
QgsDxfExport::SymbologyExport symbologyMode() const;
3434
QString saveFile() const;
35+
bool exportMapExtent() const;
3536

3637
public slots:
3738
/** change the selection of layers in the list */

‎src/core/dxf/qgsdxfexport.cpp‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,9 +565,13 @@ void QgsDxfExport::writeEntities()
565565
renderer->stopRender( ctx );
566566
}
567567

568-
569-
QgsFeatureIterator featureIt = vl->getFeatures( QgsFeatureRequest().setSubsetOfAttributes(
570-
renderer->usedAttributes(), dp->fields() ) );
568+
QgsFeatureRequest freq = QgsFeatureRequest().setSubsetOfAttributes(
569+
renderer->usedAttributes(), dp->fields() );
570+
if ( !mExtent.isEmpty() )
571+
{
572+
freq.setFilterRect( mExtent );
573+
}
574+
QgsFeatureIterator featureIt = vl->getFeatures( freq );
571575
QgsFeature fet;
572576
while ( featureIt.nextFeature( fet ) )
573577
{
@@ -625,6 +629,10 @@ void QgsDxfExport::writeEntitiesSymbolLevels( QgsVectorLayer* layer )
625629
req.setFlags( QgsFeatureRequest::NoGeometry );
626630
}
627631
req.setSubsetOfAttributes( QStringList( renderer->usedAttributes() ), layer->pendingFields() );
632+
if ( !mExtent.isEmpty() )
633+
{
634+
req.setFilterRect( mExtent );
635+
}
628636
QgsFeatureIterator fit = layer->getFeatures( req );
629637

630638
//fetch features

‎src/core/dxf/qgsdxfexport.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ class CORE_EXPORT QgsDxfExport
5656
void setSymbologyExport( SymbologyExport e ) { mSymbologyExport = e; }
5757
SymbologyExport symbologyExport() const { return mSymbologyExport; }
5858

59+
void setExtent( const QgsRectangle& r ) { mExtent = r; }
60+
QgsRectangle extent() const { return mExtent; }
61+
5962
//get closest entry in dxf palette
6063
static int closestColorMatch( QRgb pixel );
6164

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

8588
QList< QgsMapLayer* > mLayers;
89+
/**Extent for export, only intersecting features are exported. If the extent is an empty rectangle, all features are exported*/
90+
QgsRectangle mExtent;
8691
/**Scale for symbology export (used if symbols units are mm)*/
8792
double mSymbologyScaleDenominator;
8893
SymbologyExport mSymbologyExport;

‎src/ui/qgsdxfexportdialogbase.ui‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@
115115
</item>
116116
</layout>
117117
</item>
118+
<item row="3" column="1">
119+
<widget class="QCheckBox" name="mMapExtentCheckBox">
120+
<property name="text">
121+
<string>Export features intersecting the current map extent</string>
122+
</property>
123+
</widget>
124+
</item>
118125
</layout>
119126
</widget>
120127
<resources/>

0 commit comments

Comments
 (0)
Please sign in to comment.