Skip to content
Permalink
Browse files

also do raster layer properties

  • Loading branch information
3nids committed Oct 4, 2018
1 parent 3ffd72a commit e1f611bae58a1a4e5d6de411933ca5605a1e7151
Showing with 47 additions and 1 deletion.
  1. +4 −0 src/app/CMakeLists.txt
  2. +36 −1 src/app/qgsappscreenshots.cpp
  3. +5 −0 src/app/qgsappscreenshots.h
  4. +2 −0 src/app/qgsrasterlayerproperties.h
@@ -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})
@@ -34,6 +34,8 @@
#include "qgsoptions.h"
#include "qgsguiutils.h"
#include "qgsvectorlayerjoininfo.h"
#include "qgsrasterlayer.h"
#include "qgsrasterlayerproperties.h"


QgsAppScreenShots::QgsAppScreenShots( const QString &saveDirectory )
@@ -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 );
@@ -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 )
@@ -208,6 +217,9 @@ void QgsAppScreenShots::takePicturesOf( Categories categories )
takeVectorLayerProperties25DSymbol();
takeVectorLayerProperties();
}

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

void QgsAppScreenShots::setGradientSize( int size )
@@ -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();
}
@@ -21,7 +21,9 @@
#include <QRect>

class QScreen;

class QgsVectorLayer;
class QgsRasterLayer;

class QgsAppScreenShots
{
@@ -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 )
@@ -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 )
@@ -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.
You can’t perform that action at this time.