Adress comments

This commit is contained in:
Valentin Buira 2025-05-13 22:37:09 +02:00 committed by Nyall Dawson
parent 082f82baab
commit 10897ff3a9
6 changed files with 18 additions and 20 deletions

View File

@ -87,14 +87,16 @@ Returns the current combination of flags set for the scene.
virtual void mousePressEvent( QGraphicsSceneMouseEvent *event ); virtual void mousePressEvent( QGraphicsSceneMouseEvent *event );
QRectF modelBounds( double margin ) const; QRectF modelBounds( double margin = 0.0 ) const;
%Docstring %Docstring
Calculates the bouding bounds of all components of the model. Calculates the bounding rectangle of all components of the model.
:param margin: optional marginal ( absolute value in scene coordinate) :param margin: optional margin (absolute value in scene coordinates) to
to add around items add around items.
:return: model bounds, in scene units. :return: model bounds, in scene units.
.. versionadded:: 3.44
%End %End

View File

@ -87,14 +87,16 @@ Returns the current combination of flags set for the scene.
virtual void mousePressEvent( QGraphicsSceneMouseEvent *event ); virtual void mousePressEvent( QGraphicsSceneMouseEvent *event );
QRectF modelBounds( double margin ) const; QRectF modelBounds( double margin = 0.0 ) const;
%Docstring %Docstring
Calculates the bouding bounds of all components of the model. Calculates the bounding rectangle of all components of the model.
:param margin: optional marginal ( absolute value in scene coordinate) :param margin: optional margin (absolute value in scene coordinates) to
to add around items add around items.
:return: model bounds, in scene units. :return: model bounds, in scene units.
.. versionadded:: 3.44
%End %End

View File

@ -75,10 +75,7 @@ QRectF QgsModelGraphicsScene::modelBounds( double margin ) const
for ( QGraphicsItem *item : constItems ) for ( QGraphicsItem *item : constItems )
{ {
QgsModelComponentGraphicItem *componentItem = dynamic_cast<QgsModelComponentGraphicItem *>( item ); QgsModelComponentGraphicItem *componentItem = dynamic_cast<QgsModelComponentGraphicItem *>( item );
if ( !componentItem ) if ( componentItem )
{
continue;
}
bounds = bounds.united( componentItem->sceneBoundingRect() ); bounds = bounds.united( componentItem->sceneBoundingRect() );
} }

View File

@ -99,12 +99,12 @@ class GUI_EXPORT QgsModelGraphicsScene : public QGraphicsScene
void mousePressEvent( QGraphicsSceneMouseEvent *event ) override; void mousePressEvent( QGraphicsSceneMouseEvent *event ) override;
/** /**
* Calculates the bouding bounds of all components of the model. * Calculates the bounding rectangle of all components of the model.
* \param margin optional marginal ( absolute value in scene coordinate) to add around items * \param margin optional margin (absolute value in scene coordinates) to add around items.
* \returns model bounds, in scene units. * \returns model bounds, in scene units.
* * \since QGIS 3.44
*/ */
QRectF modelBounds( double margin ) const; QRectF modelBounds( double margin = 0.0 ) const;
/** /**

View File

@ -397,7 +397,6 @@ void QgsModelGraphicsView::setModelScene( QgsModelGraphicsScene *scene )
{ {
setScene( scene ); setScene( scene );
mPreviousSceneRect = sceneRect();
// IMPORTANT! // IMPORTANT!
// previous snap markers, snap lines are owned by previous layout - so don't delete them here! // previous snap markers, snap lines are owned by previous layout - so don't delete them here!
mSnapMarker = new QgsModelViewSnapMarker(); mSnapMarker = new QgsModelViewSnapMarker();

View File

@ -244,8 +244,6 @@ class GUI_EXPORT QgsModelGraphicsView : public QGraphicsView
QgsModelSnapper mSnapper; QgsModelSnapper mSnapper;
QgsModelViewSnapMarker *mSnapMarker = nullptr; QgsModelViewSnapMarker *mSnapMarker = nullptr;
QRectF mPreviousSceneRect;
}; };