Skip to content
Permalink
Browse files

Trigger repaints instead of explicitly refreshing canvas

Inspired by work by @manisandro
  • Loading branch information
nyalldawson committed Jun 6, 2016
1 parent 787d206 commit 4e10c5be0f4785b9482d19fc6f7002c2dd19ff65
@@ -502,7 +502,7 @@ void QgsMapToolNodeTool::canvasReleaseEvent( QgsMapMouseEvent* e )
}

mSelectedFeature->moveSelectedVertexes( releaseLayerCoords - pressLayerCoords );
mCanvas->refresh();
vlayer->triggerRepaint();
}
else // selecting vertexes by rubberband
{
@@ -646,7 +646,7 @@ void QgsMapToolNodeTool::canvasDoubleClickEvent( QgsMapMouseEvent* e )
vlayer->endEditCommand();

// make sure that new node gets its vertex marker
mCanvas->refresh();
vlayer->triggerRepaint();
}

void QgsMapToolNodeTool::deleteNodeSelection()
@@ -674,7 +674,7 @@ void QgsMapToolNodeTool::deleteNodeSelection()

safeSelectVertex( nextVertexToSelect );
}
mCanvas->refresh();
mSelectedFeature->vlayer()->triggerRepaint();
}
}

@@ -230,7 +230,7 @@ bool QgsNodeEditorModel::setData( const QModelIndex& index, const QVariant& valu
mLayer->beginEditCommand( QObject::tr( "Moved vertices" ) );
mLayer->moveVertex( p, mSelectedFeature->featureId(), index.row() );
mLayer->endEditCommand();
mCanvas->refresh();
mLayer->triggerRepaint();

return false;
}
@@ -5859,7 +5859,7 @@ void QgisApp::fieldCalculator()
QgsFieldCalculator calc( myLayer, this );
if ( calc.exec() )
{
mMapCanvas->refresh();
myLayer->triggerRepaint();
}
}

@@ -6865,7 +6865,7 @@ void QgisApp::mergeAttributesOfSelectedFeatures()

if ( mapCanvas() )
{
mapCanvas()->refresh();
vl->triggerRepaint();
}
}

@@ -7045,7 +7045,7 @@ void QgisApp::mergeSelectedFeatures()

if ( mapCanvas() )
{
mapCanvas()->refresh();
vl->triggerRepaint();
}
}

@@ -7367,7 +7367,7 @@ void QgisApp::editPaste( QgsMapLayer *destinationLayer )
QgsMessageBar::WARNING, messageTimeout() );
}

mMapCanvas->refresh();
pasteVectorLayer->triggerRepaint();
}

void QgisApp::pasteAsNewVector()
@@ -7600,8 +7600,7 @@ void QgisApp::pasteStyle( QgsMapLayer * destinationLayer )
}

mLayerTreeView->refreshLayerSymbology( selectionLayer->id() );
mMapCanvas->clearCache();
mMapCanvas->refresh();
selectionLayer->triggerRepaint();
}
}
}
@@ -8056,7 +8055,7 @@ void QgisApp::layerSubsetString()
{
if ( subsetBefore != qb->sql() )
{
mMapCanvas->refresh();
vlayer->triggerRepaint();
if ( mLayerTreeView )
{
mLayerTreeView->refreshLayerSymbology( vlayer->id() );
@@ -8878,7 +8877,7 @@ void QgisApp::histogramStretch( bool visibleAreaOnly, QgsRaster::ContrastEnhance

myRasterLayer->setContrastEnhancement( QgsContrastEnhancement::StretchToMinimumMaximum, theLimits, myRectangle );

mMapCanvas->refresh();
myRasterLayer->triggerRepaint();
}

void QgisApp::increaseBrightness()
@@ -828,12 +828,8 @@ void QgsDiagramProperties::apply()
mLayer->setDiagramLayerSettings( dls );

// refresh
if ( mMapCanvas )
{
QgisApp::instance()->markDirty();
if ( mMapCanvas )
mMapCanvas->refresh();
}
QgisApp::instance()->markDirty();
mLayer->triggerRepaint();
}

void QgsDiagramProperties::showAddAttributeExpressionDialog()
@@ -891,10 +891,7 @@ void QgsLabelingGui::apply()
mFontMissingLabel->setVisible( false );
QgisApp::instance()->markDirty();
// trigger refresh
if ( mMapCanvas )
{
mMapCanvas->refresh();
}
mLayer->triggerRepaint();
}

void QgsLabelingGui::writeSettingsToLayer()
@@ -139,10 +139,7 @@ void QgsLabelingWidget::apply()
writeSettingsToLayer();
QgisApp::instance()->markDirty();
// trigger refresh
if ( mCanvas )
{
mCanvas->refresh();
}
mLayer->triggerRepaint();
}

void QgsLabelingWidget::labelModeChanged( int index )
@@ -170,7 +170,7 @@ void QgsMapToolAddFeature::cadCanvasReleaseEvent( QgsMapMouseEvent* e )

addFeature( vlayer, &f, false );

mCanvas->refresh();
vlayer->triggerRepaint();
}
}

@@ -192,7 +192,7 @@ void QgsMapToolAddPart::cadCanvasReleaseEvent( QgsMapMouseEvent * e )

vlayer->endEditCommand();

mCanvas->refresh();
vlayer->triggerRepaint();
return;
}

@@ -93,7 +93,7 @@ void QgsMapToolChangeLabelProperties::applyChanges( const QgsAttributeMap& chang
}

vlayer->endEditCommand();
mCanvas->refresh();
vlayer->triggerRepaint();
}
}

@@ -107,7 +107,7 @@ void QgsMapToolDeletePart::canvasReleaseEvent( QgsMapMouseEvent* e )
vlayer->beginEditCommand( tr( "Part of multipart feature deleted" ) );
vlayer->changeGeometry( f.id(), g );
vlayer->endEditCommand();
mCanvas->refresh();
vlayer->triggerRepaint();
}
else
{
@@ -115,7 +115,7 @@ void QgsMapToolDeleteRing::canvasReleaseEvent( QgsMapMouseEvent* e )
vlayer->beginEditCommand( tr( "Ring deleted" ) );
vlayer->changeGeometry( mPressedFid, g );
vlayer->endEditCommand();
mCanvas->refresh();
vlayer->triggerRepaint();
}
}

@@ -197,7 +197,7 @@ void QgsMapToolDeleteRing::deleteRing( QgsFeatureId fId, int beforeVertexNr, Qgs
vlayer->beginEditCommand( tr( "Ring deleted" ) );
vlayer->changeGeometry( fId, editableGeom );
vlayer->endEditCommand();
mCanvas->refresh();
vlayer->triggerRepaint();
}

}
@@ -166,8 +166,8 @@ void QgsMapToolMoveFeature::canvasReleaseEvent( QgsMapMouseEvent* e )
}
delete mRubberBand;
mRubberBand = nullptr;
mCanvas->refresh();
vlayer->endEditCommand();
vlayer->triggerRepaint();
}

//! called when map tool is being deactivated
@@ -169,8 +169,7 @@ void QgsMapToolMoveLabel::canvasReleaseEvent( QgsMapMouseEvent* e )
}
vlayer->endEditCommand();

if ( mCanvas )
mCanvas->refresh();
vlayer->triggerRepaint();
}


@@ -186,7 +186,7 @@ void QgsMapToolOffsetCurve::applyOffset()
delete mSnapVertexMarker;
mSnapVertexMarker = nullptr;
mForceCopy = false;
mCanvas->refresh();
layer->triggerRepaint();
}

void QgsMapToolOffsetCurve::placeOffsetCurveToValue()
@@ -164,7 +164,8 @@ void QgsMapToolOffsetPointSymbol::canvasReleaseEvent( QgsMapMouseEvent* e )
mOffsetting = false;
delete mOffsetItem;
mOffsetItem = nullptr;
mCanvas->refresh();
if ( mActiveLayer )
mActiveLayer->triggerRepaint();
}

void QgsMapToolOffsetPointSymbol::createPreviewItem( QgsMarkerSymbolV2* markerSymbol )
@@ -400,8 +400,8 @@ void QgsMapToolRotateFeature::applyRotation( double rotation )
deleteRotationWidget();
deleteRubberband();

mCanvas->refresh();
vlayer->endEditCommand();
vlayer->triggerRepaint();
}

void QgsMapToolRotateFeature::activate()
@@ -173,7 +173,7 @@ void QgsMapToolRotateLabel::canvasReleaseEvent( QgsMapMouseEvent* e )
vlayer->beginEditCommand( tr( "Rotated label" ) + QString( " '%1'" ).arg( currentLabelText( 24 ) ) );
vlayer->changeAttributeValue( mCurrentLabel.pos.featureId, rotationCol, rotation );
vlayer->endEditCommand();
mCanvas->refresh();
vlayer->triggerRepaint();
}

int QgsMapToolRotateLabel::roundTo15Degrees( double n )
@@ -199,7 +199,8 @@ void QgsMapToolRotatePointSymbols::canvasReleaseEvent( QgsMapMouseEvent* e )
mRotating = false;
delete mRotationItem;
mRotationItem = nullptr;
mCanvas->refresh();
if ( mActiveLayer )
mActiveLayer->triggerRepaint();
}

double QgsMapToolRotatePointSymbols::calculateAzimut( QPoint mousePos )
@@ -179,7 +179,7 @@ void QgsMapToolShowHideLabels::showHideLabels( QMouseEvent * e )
if ( labelChanged )
{
vlayer->endEditCommand();
mCanvas->refresh();
vlayer->triggerRepaint();
}
else
{
@@ -182,7 +182,7 @@ void QgsMapToolSimplify::storeSimplified()

clearSelection();

mCanvas->refresh();
vlayer->triggerRepaint();
}


0 comments on commit 4e10c5b

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