mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-07 00:15:48 -04:00
Avoid needless extra method
This commit is contained in:
parent
052d48e558
commit
53adb99721
@ -87,19 +87,6 @@ Returns the current combination of flags set for the scene.
|
||||
virtual void mousePressEvent( QGraphicsSceneMouseEvent *event );
|
||||
|
||||
|
||||
QRectF modelBounds( double margin = 0.0 ) const;
|
||||
%Docstring
|
||||
Calculates the bounding rectangle of all components of the model.
|
||||
|
||||
:param margin: optional margin (absolute value in scene coordinates) to
|
||||
add around items.
|
||||
|
||||
:return: model bounds, in scene units.
|
||||
|
||||
.. versionadded:: 3.44
|
||||
%End
|
||||
|
||||
|
||||
void createItems( QgsProcessingModelAlgorithm *model, QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Populates the scene by creating items representing the specified
|
||||
@ -191,7 +178,10 @@ Requests a complete rebuild of a model by emitting the according signal
|
||||
|
||||
void updateBounds();
|
||||
%Docstring
|
||||
Updates the scene bounds of the model.
|
||||
Updates the scene rect based on the bounds of the model.
|
||||
|
||||
The bounding rectangle of the model is calculated off all components of
|
||||
the model, with an additional margin arounds items.
|
||||
|
||||
.. versionadded:: 3.44
|
||||
%End
|
||||
|
@ -87,19 +87,6 @@ Returns the current combination of flags set for the scene.
|
||||
virtual void mousePressEvent( QGraphicsSceneMouseEvent *event );
|
||||
|
||||
|
||||
QRectF modelBounds( double margin = 0.0 ) const;
|
||||
%Docstring
|
||||
Calculates the bounding rectangle of all components of the model.
|
||||
|
||||
:param margin: optional margin (absolute value in scene coordinates) to
|
||||
add around items.
|
||||
|
||||
:return: model bounds, in scene units.
|
||||
|
||||
.. versionadded:: 3.44
|
||||
%End
|
||||
|
||||
|
||||
void createItems( QgsProcessingModelAlgorithm *model, QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Populates the scene by creating items representing the specified
|
||||
@ -191,7 +178,10 @@ Requests a complete rebuild of a model by emitting the according signal
|
||||
|
||||
void updateBounds();
|
||||
%Docstring
|
||||
Updates the scene bounds of the model.
|
||||
Updates the scene rect based on the bounds of the model.
|
||||
|
||||
The bounding rectangle of the model is calculated off all components of
|
||||
the model, with an additional margin arounds items.
|
||||
|
||||
.. versionadded:: 3.44
|
||||
%End
|
||||
|
@ -63,11 +63,6 @@ void QgsModelGraphicsScene::mousePressEvent( QGraphicsSceneMouseEvent *event )
|
||||
}
|
||||
|
||||
void QgsModelGraphicsScene::updateBounds()
|
||||
{
|
||||
setSceneRect( modelBounds( SCENE_COMPONENT_MARGIN ) );
|
||||
}
|
||||
|
||||
QRectF QgsModelGraphicsScene::modelBounds( double margin ) const
|
||||
{
|
||||
//start with an empty rectangle
|
||||
QRectF bounds;
|
||||
@ -81,12 +76,12 @@ QRectF QgsModelGraphicsScene::modelBounds( double margin ) const
|
||||
bounds = bounds.united( componentItem->sceneBoundingRect() );
|
||||
}
|
||||
|
||||
if ( bounds.isValid() && margin > 0.0 )
|
||||
if ( bounds.isValid() )
|
||||
{
|
||||
bounds.adjust( -margin, -margin, margin, margin );
|
||||
bounds.adjust( -SCENE_COMPONENT_MARGIN, -SCENE_COMPONENT_MARGIN, SCENE_COMPONENT_MARGIN, SCENE_COMPONENT_MARGIN );
|
||||
}
|
||||
|
||||
return bounds;
|
||||
setSceneRect( bounds );
|
||||
}
|
||||
|
||||
QgsModelComponentGraphicItem *QgsModelGraphicsScene::createParameterGraphicItem( QgsProcessingModelAlgorithm *model, QgsProcessingModelParameter *param ) const
|
||||
|
@ -98,15 +98,6 @@ class GUI_EXPORT QgsModelGraphicsScene : public QGraphicsScene
|
||||
|
||||
void mousePressEvent( QGraphicsSceneMouseEvent *event ) override;
|
||||
|
||||
/**
|
||||
* Calculates the bounding rectangle of all components of the model.
|
||||
* \param margin optional margin (absolute value in scene coordinates) to add around items.
|
||||
* \returns model bounds, in scene units.
|
||||
* \since QGIS 3.44
|
||||
*/
|
||||
QRectF modelBounds( double margin = 0.0 ) const;
|
||||
|
||||
|
||||
/**
|
||||
* Populates the scene by creating items representing the specified \a model.
|
||||
*/
|
||||
@ -191,8 +182,10 @@ class GUI_EXPORT QgsModelGraphicsScene : public QGraphicsScene
|
||||
void requestRebuildRequired();
|
||||
|
||||
/**
|
||||
* Updates the scene bounds of the model.
|
||||
*
|
||||
* Updates the scene rect based on the bounds of the model.
|
||||
|
||||
* The bounding rectangle of the model is calculated off all components of the model, with an additional margin arounds items.
|
||||
*
|
||||
* \since QGIS 3.44
|
||||
*/
|
||||
void updateBounds();
|
||||
|
@ -11456,14 +11456,15 @@ void TestProcessingGui::testModelGraphicsView()
|
||||
QVERIFY( !layerCommentItem );
|
||||
|
||||
//check model bounds
|
||||
QRectF modelBounds = scene2.modelBounds( 50 );
|
||||
QGSCOMPARENEAR( modelBounds.height(), 624.4, 3 ); // Sligtly higher threeshold because of various font size can marginally change the bounding rect
|
||||
QGSCOMPARENEAR( modelBounds.width(), 655.00, 0.01 );
|
||||
QGSCOMPARENEAR( modelBounds.left(), -252.0, 0.01 );
|
||||
QGSCOMPARENEAR( modelBounds.top(), -232.0, 0.01 );
|
||||
scene2.updateBounds();
|
||||
QRectF modelRect = scene2.sceneRect();
|
||||
QGSCOMPARENEAR( modelRect.height(), 624.4, 3 ); // Sligtly higher threeshold because of various font size can marginally change the bounding rect
|
||||
QGSCOMPARENEAR( modelRect.width(), 655.00, 0.01 );
|
||||
QGSCOMPARENEAR( modelRect.left(), -252.0, 0.01 );
|
||||
QGSCOMPARENEAR( modelRect.top(), -232.0, 0.01 );
|
||||
|
||||
|
||||
// test model large modelBounds
|
||||
// test model large modelRect
|
||||
QgsProcessingModelAlgorithm model2;
|
||||
|
||||
QgsProcessingModelChildAlgorithm algc2;
|
||||
@ -11483,11 +11484,12 @@ void TestProcessingGui::testModelGraphicsView()
|
||||
scene3.setModel( &model2 );
|
||||
scene3.createItems( &model2, context );
|
||||
|
||||
QRectF modelBounds2 = scene3.modelBounds( 50 );
|
||||
QGSCOMPARENEAR( modelBounds2.height(), 4505.4, 3 ); // Sligtly higher threeshold because of various font size can marginally change the bounding rect
|
||||
QGSCOMPARENEAR( modelBounds2.width(), 4603.0, 0.01 );
|
||||
QGSCOMPARENEAR( modelBounds2.left(), -201.0, 0.01 );
|
||||
QGSCOMPARENEAR( modelBounds2.top(), -150.0, 0.01 );
|
||||
scene3.updateBounds();
|
||||
QRectF modelRect2 = scene3.sceneRect();
|
||||
QGSCOMPARENEAR( modelRect2.height(), 4505.4, 3 ); // Sligtly higher threeshold because of various font size can marginally change the bounding rect
|
||||
QGSCOMPARENEAR( modelRect2.width(), 4603.0, 0.01 );
|
||||
QGSCOMPARENEAR( modelRect2.left(), -201.0, 0.01 );
|
||||
QGSCOMPARENEAR( modelRect2.top(), -150.0, 0.01 );
|
||||
|
||||
|
||||
QgsModelGraphicsScene scene;
|
||||
|
Loading…
x
Reference in New Issue
Block a user