Skip to content
Permalink
Browse files

fix review items from Nyall

  • Loading branch information
PeterPetrik committed Sep 5, 2018
1 parent 47d541a commit c89b7722a3f03bbaa0192a12f3cb6d8c478c6662
@@ -286,11 +286,11 @@ Sets ratio of the head length of the arrow (range 0-1)

bool isOnUserDefinedGrid() const;
%Docstring
Returns if vectors are drawn on user-defined grid
Returns whether vectors are drawn on user-defined grid
%End
void setOnUserDefinedGrid( bool enabled );
%Docstring
Toggle drawing of vectors on user defined grid
Toggles drawing of vectors on user defined grid
%End
int userGridCellWidth() const;
%Docstring
@@ -26,7 +26,6 @@ QgsMeshRendererVectorSettingsWidget::QgsMeshRendererVectorSettingsWidget( QWidge

{
setupUi( this );
addValidators( );

mShaftLengthComboBox->setCurrentIndex( -1 );

@@ -46,26 +45,15 @@ QgsMeshRendererVectorSettingsWidget::QgsMeshRendererVectorSettingsWidget( QWidge
widgets << mMinMagLineEdit << mMaxMagLineEdit
<< mHeadWidthLineEdit << mHeadLengthLineEdit
<< mMinimumShaftLineEdit << mMaximumShaftLineEdit
<< mScaleShaftByFactorOfLineEdit << mShaftLengthLineEdit
<< mXSpacingLineEdit << mYSpacingLineEdit;
<< mScaleShaftByFactorOfLineEdit << mShaftLengthLineEdit;

for ( auto widget : widgets )
{
connect( widget, &QLineEdit::textChanged, this, &QgsMeshRendererVectorSettingsWidget::widgetChanged );
}
}

void QgsMeshRendererVectorSettingsWidget::addValidators()
{
QIntValidator *validatorX = new QIntValidator();
validatorX->setBottom( 0 );
validatorX->setParent( mXSpacingLineEdit );
mXSpacingLineEdit->setValidator( validatorX );

QIntValidator *validatorY = new QIntValidator();
validatorY->setBottom( 0 );
validatorY->setParent( mYSpacingLineEdit );
mYSpacingLineEdit->setValidator( validatorY );
connect( mXSpacingSpinBox, qgis::overload<int>::of( &QgsSpinBox::valueChanged ), this, &QgsMeshRendererVectorSettingsWidget::widgetChanged );
connect( mYSpacingSpinBox, qgis::overload<int>::of( &QgsSpinBox::valueChanged ), this, &QgsMeshRendererVectorSettingsWidget::widgetChanged );
}

void QgsMeshRendererVectorSettingsWidget::setLayer( QgsMeshLayer *layer )
@@ -98,12 +86,8 @@ QgsMeshRendererVectorSettings QgsMeshRendererVectorSettingsWidget::settings() co
// user grid
bool enabled = mDisplayVectorsOnGridGroupBox->isChecked();
settings.setOnUserDefinedGrid( enabled );

val = filterValue( mXSpacingLineEdit->text(), settings.userGridCellWidth() );
settings.setUserGridCellWidth( static_cast<int>( val ) );

val = filterValue( mYSpacingLineEdit->text(), settings.userGridCellHeight() );
settings.setUserGridCellHeight( static_cast<int>( val ) );
settings.setUserGridCellWidth( mXSpacingSpinBox->value() );
settings.setUserGridCellHeight( mYSpacingSpinBox->value() );

// shaft length
auto method = static_cast<QgsMeshRendererVectorSettings::ArrowScalingMethod>( mShaftLengthComboBox->currentIndex() );
@@ -61,9 +61,6 @@ class APP_EXPORT QgsMeshRendererVectorSettingsWidget : public QWidget, private U

private:

//! Add validators to line edits
void addValidators();

/**
* convert text to double, return err_val if
* text is not possible to convert or the value is negative
@@ -248,9 +248,9 @@ class CORE_EXPORT QgsMeshRendererVectorSettings
//! Sets ratio of the head length of the arrow (range 0-1)
void setArrowHeadLengthRatio( double arrowHeadLengthRatio );

//! Returns if vectors are drawn on user-defined grid
//! Returns whether vectors are drawn on user-defined grid
bool isOnUserDefinedGrid() const;
//! Toggle drawing of vectors on user defined grid
//! Toggles drawing of vectors on user defined grid
void setOnUserDefinedGrid( bool enabled );
//! Returns width in pixels of user grid cell
int userGridCellWidth() const;
@@ -253,9 +253,6 @@ void QgsMeshVectorRenderer::drawVectorDataOnGrid()
const QgsPoint p1 = vertices[v1], p2 = vertices[v2], p3 = vertices[v3];

const int nativeFaceIndex = mTriangularMesh.trianglesToNativeFaces()[i];
//const bool isActive = mActiveFaceFlagValues[nativeFaceIndex];
//if ( !isActive )
// continue;

QgsRectangle bbox = QgsMeshLayerUtils::triangleBoundingBox( p1, p2, p3 );
if ( !mContext.extent().intersects( bbox ) )
@@ -82,44 +82,48 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="mXSpacingLineEdit">
<property name="text">
<string>10</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="pxLabel_2">
<property name="text">
<string>px</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="ySpacingLabel">
<property name="text">
<string>Y Spacing</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="mYSpacingLineEdit">
<property name="text">
<string>10</string>
<item row="0" column="1">
<widget class="QgsSpinBox" name="mXSpacingSpinBox">
<property name="suffix">
<string> px</string>
</property>
<property name="maximum">
<number>8000</number>
</property>
<property name="singleStep">
<number>100</number>
</property>
<property name="value">
<number>100</number>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="pxLabel_3">
<property name="text">
<item row="1" column="1">
<widget class="QSpinBox" name="mYSpacingSpinBox">
<property name="suffix">
<string>px</string>
</property>
<property name="maximum">
<number>5000</number>
</property>
<property name="singleStep">
<number>100</number>
</property>
<property name="value">
<number>100</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<item row="2" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
@@ -301,6 +305,11 @@
<extends>QDoubleSpinBox</extends>
<header>qgsdoublespinbox.h</header>
</customwidget>
<customwidget>
<class>QgsSpinBox</class>
<extends>QSpinBox</extends>
<header>qgsspinbox.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
@@ -277,8 +277,9 @@ void TestQgsMeshRenderer::test_face_vector_on_user_grid()
QgsMeshRendererSettings rendererSettings = mMemoryLayer->rendererSettings();
QgsMeshRendererVectorSettings settings = rendererSettings.vectorSettings( ds.group() );
settings.setOnUserDefinedGrid( true );
settings.setUserGridCellWidth( 22 );
settings.setUserGridCellHeight( 11 );
settings.setUserGridCellWidth( 30 );
settings.setUserGridCellHeight( 20 );
settings.setLineWidth( 0.8 );
rendererSettings.setVectorSettings( ds.group(), settings );
rendererSettings.setActiveVectorDataset( ds );
mMemoryLayer->setRendererSettings( rendererSettings );
@@ -295,8 +296,9 @@ void TestQgsMeshRenderer::test_vertex_vector_on_user_grid()
QgsMeshRendererSettings rendererSettings = mMemoryLayer->rendererSettings();
QgsMeshRendererVectorSettings settings = rendererSettings.vectorSettings( ds.group() );
settings.setOnUserDefinedGrid( true );
settings.setUserGridCellWidth( 40 );
settings.setUserGridCellWidth( 60 );
settings.setUserGridCellHeight( 40 );
settings.setLineWidth( 0.9 );
rendererSettings.setVectorSettings( ds.group(), settings );
rendererSettings.setActiveVectorDataset( ds );
mMemoryLayer->setRendererSettings( rendererSettings );
Binary file not shown.
Binary file not shown.

0 comments on commit c89b772

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