Navigation Menu

Skip to content

Commit

Permalink
also do raster layer properties
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Oct 4, 2018
1 parent 3ffd72a commit e1f611b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/app/CMakeLists.txt
Expand Up @@ -543,6 +543,10 @@ IF (PROJ_HAS_INFO)
ADD_DEFINITIONS(-DPROJ_HAS_INFO)
ENDIF (PROJ_HAS_INFO)

# Test data dir for QgsAppScreenShots
ADD_DEFINITIONS(-DTEST_DATA_DIR="${TEST_DATA_DIR}")


SET(IMAGE_RCCS ../../images/images.qrc)

QT5_ADD_RESOURCES(IMAGE_RCC_SRCS ${IMAGE_RCCS})
Expand Down
37 changes: 36 additions & 1 deletion src/app/qgsappscreenshots.cpp
Expand Up @@ -34,6 +34,8 @@
#include "qgsoptions.h"
#include "qgsguiutils.h"
#include "qgsvectorlayerjoininfo.h"
#include "qgsrasterlayer.h"
#include "qgsrasterlayerproperties.h"


QgsAppScreenShots::QgsAppScreenShots( const QString &saveDirectory )
Expand All @@ -44,6 +46,11 @@ QgsAppScreenShots::QgsAppScreenShots( const QString &saveDirectory )
layerDef = QStringLiteral( "Polygon?crs=epsg:2056&field=pk:integer&field=my_text:string&field=my_integer:integer&field=height:double&key=pk" );
mPolygonLayer = new QgsVectorLayer( layerDef, QStringLiteral( "Polygon Layer" ), QStringLiteral( "memory" ) );

QString dataPath( TEST_DATA_DIR ); //defined in CmakeLists.txt
mRasterLayer = new QgsRasterLayer( dataPath + "/raster/with_color_table.tif", QStringLiteral( "raster" ), QStringLiteral( "gdal" ) );
Q_ASSERT( mRasterLayer->isValid() );

// add join
QgsVectorLayerJoinInfo join;
join.setTargetFieldName( "fk_polygon" );
join.setJoinLayer( mPolygonLayer );
Expand All @@ -53,9 +60,11 @@ QgsAppScreenShots::QgsAppScreenShots( const QString &saveDirectory )
join.setCascadedDelete( true );
mLineLayer->addJoin( join );

// add layers to project
QgsProject::instance()->addMapLayers( QList<QgsMapLayer *>()
<< mLineLayer
<< mPolygonLayer );
<< mPolygonLayer
<< mRasterLayer );
}

QPixmap QgsAppScreenShots::takeScreenshot( QWidget *widget, GrabMode mode, QRect crop, bool gradient )
Expand Down Expand Up @@ -208,6 +217,9 @@ void QgsAppScreenShots::takePicturesOf( Categories categories )
takeVectorLayerProperties25DSymbol();
takeVectorLayerProperties();
}

if ( !categories || categories.testFlag( RasterLayerProperties ) )
takeRasterLayerProperties();
}

void QgsAppScreenShots::setGradientSize( int size )
Expand Down Expand Up @@ -316,3 +328,26 @@ void QgsAppScreenShots::takeGlobalOptions()
dlg->close();
dlg->deleteLater();
}

//---------------

void QgsAppScreenShots::takeRasterLayerProperties()
{
QString folder = QLatin1String( "working_with_raster/img/auto_generated/raster_layer_properties" );
QgsRasterLayerProperties *dlg = new QgsRasterLayerProperties( mRasterLayer, QgisApp::instance()->mapCanvas() );
dlg->show();
// ----------------
// do all the pages
for ( int row = 0; row < dlg->mOptionsListWidget->count(); ++row )
{
dlg->mOptionsListWidget->setCurrentRow( row );
dlg->adjustSize();
QCoreApplication::processEvents();
QString name = dlg->mOptionsListWidget->item( row )[0].text().toLower();
name.replace( " ", "_" ).replace( "&", "and" );
takeScreenshot( name, folder, dlg );
}
// exit properly
dlg->close();
dlg->deleteLater();
}
5 changes: 5 additions & 0 deletions src/app/qgsappscreenshots.h
Expand Up @@ -21,7 +21,9 @@
#include <QRect>

class QScreen;

class QgsVectorLayer;
class QgsRasterLayer;

class QgsAppScreenShots
{
Expand All @@ -48,6 +50,7 @@ class QgsAppScreenShots
All = 0,
GlobalOptions = 1 << 0,
VectorLayerProperties = 1 << 1,
RasterLayerProperties = 1 << 2,
};
Q_ENUM( Category )
Q_DECLARE_FLAGS( Categories, Category )
Expand Down Expand Up @@ -81,11 +84,13 @@ class QgsAppScreenShots
void takeVectorLayerProperties();
void takeVectorLayerProperties25DSymbol();
void takeGlobalOptions();
void takeRasterLayerProperties();

QString mSaveDirectory;
int mGradientSize = 200;
QgsVectorLayer *mLineLayer = nullptr;
QgsVectorLayer *mPolygonLayer = nullptr;
QgsRasterLayer *mRasterLayer = nullptr;
};

Q_DECLARE_OPERATORS_FOR_FLAGS( QgsAppScreenShots::Categories )
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsrasterlayerproperties.h
Expand Up @@ -223,5 +223,7 @@ class APP_EXPORT QgsRasterLayerProperties : public QgsOptionsDialogBase, private
bool mDisableRenderTypeComboBoxCurrentIndexChanged = false;

bool mMetadataFilled;

friend class QgsAppScreenShots;
};
#endif

0 comments on commit e1f611b

Please sign in to comment.