-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create rubber band classes for layout views
c++ QgsLayoutItem metadata classes can directly register a function which creates a QgsLayoutViewRubberBand for the item subclass. Python code cannot utilise this shortcut (due to inaccessibility of forward declared gui classes from core Python classes), so there's a separate gui registry utility class added for registering prototypes for rubber bands for already registered item types.
- Loading branch information
1 parent
4ebea75
commit 3843b5e
Showing
14 changed files
with
751 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/layout/qgslayoutitemregistryguiutils.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
class QgsLayoutItemRegistryGuiUtils | ||
{ | ||
%Docstring | ||
A group of static utilities for working with the gui based portions of | ||
QgsLayoutItemRegistry. | ||
|
||
This class is designed to allow Python item subclasses to override the | ||
default GUI based QgsLayoutItemAbstractMetadata methods, which | ||
cannot be directly overridden from Python subclasses. | ||
|
||
.. versionadded:: 3.0 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgslayoutitemregistryguiutils.h" | ||
%End | ||
public: | ||
|
||
static void setItemRubberBandPrototype( int type, QgsLayoutViewRubberBand *prototype /Transfer/ ); | ||
%Docstring | ||
Sets a ``prototype`` for the rubber bands for the layout item with specified ``type``. | ||
Python subclasses of QgsLayoutItem must call this method to register their prototypes, | ||
as the usual c++ QgsLayoutItemAbstractMetadata are not accessible via the Python bindings. | ||
%End | ||
|
||
|
||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/layout/qgslayoutitemregistryguiutils.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/layout/qgslayoutviewrubberband.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
|
||
class QgsLayoutViewRubberBand | ||
{ | ||
%Docstring | ||
QgsLayoutViewRubberBand is an abstract base class for temporary rubber band items | ||
in various shapes, for use within QgsLayoutView widgets. | ||
.. versionadded:: 3.0 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgslayoutviewrubberband.h" | ||
%End | ||
|
||
%ConvertToSubClassCode | ||
if ( dynamic_cast<QgsLayoutViewMouseEvent *>( sipCpp ) ) | ||
sipType = sipType_QgsLayoutViewMouseEvent; | ||
else | ||
sipType = 0; | ||
%End | ||
public: | ||
|
||
QgsLayoutViewRubberBand( QgsLayoutView *view ); | ||
%Docstring | ||
Constructor for QgsLayoutViewRubberBand. | ||
%End | ||
|
||
virtual ~QgsLayoutViewRubberBand(); | ||
|
||
virtual QgsLayoutViewRubberBand *create( QgsLayoutView *view ) const = 0 /Factory/; | ||
%Docstring | ||
Creates a new instance of the QgsLayoutViewRubberBand subclass. | ||
:rtype: QgsLayoutViewRubberBand | ||
%End | ||
|
||
virtual void start( QPointF position, Qt::KeyboardModifiers modifiers ) = 0; | ||
%Docstring | ||
Called when a rubber band should be created at the specified | ||
starting ``position`` (in layout coordinate space). | ||
%End | ||
|
||
virtual void update( QPointF position, Qt::KeyboardModifiers modifiers ) = 0; | ||
%Docstring | ||
Called when a rubber band should be updated to reflect a temporary | ||
ending ``position`` (in layout coordinate space). | ||
%End | ||
|
||
virtual void finish( QPointF position, Qt::KeyboardModifiers modifiers ) = 0; | ||
%Docstring | ||
Called when a rubber band use has finished and the rubber | ||
band is no longer required. | ||
%End | ||
|
||
QgsLayoutView *view() const; | ||
%Docstring | ||
Returns the view associated with the rubber band. | ||
.. seealso:: layout() | ||
:rtype: QgsLayoutView | ||
%End | ||
|
||
QgsLayout *layout() const; | ||
%Docstring | ||
Returns the layout associated with the rubber band. | ||
.. seealso:: view() | ||
:rtype: QgsLayout | ||
%End | ||
|
||
protected: | ||
|
||
QRectF updateRect( QPointF start, QPointF position, bool constrainSquare, bool fromCenter ); | ||
%Docstring | ||
Calculates an updated bounding box rectangle from a original ``start`` position | ||
and new ``position``. If ``constrainSquare`` is true then the bounding box will be | ||
forced to a square shape. If ``fromCenter`` is true then the original ``start`` | ||
position will form the center point of the returned rectangle. | ||
:rtype: QRectF | ||
%End | ||
|
||
}; | ||
|
||
|
||
class QgsLayoutViewRectangularRubberBand : QgsLayoutViewRubberBand | ||
{ | ||
%Docstring | ||
QgsLayoutViewRectangularRubberBand is rectangular rubber band for use within QgsLayoutView widgets. | ||
.. versionadded:: 3.0 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgslayoutviewrubberband.h" | ||
%End | ||
public: | ||
|
||
QgsLayoutViewRectangularRubberBand( QgsLayoutView *view ); | ||
%Docstring | ||
Constructor for QgsLayoutViewRectangularRubberBand. | ||
%End | ||
virtual QgsLayoutViewRectangularRubberBand *create( QgsLayoutView *view ) const /Factory/; | ||
|
||
|
||
~QgsLayoutViewRectangularRubberBand(); | ||
|
||
virtual void start( QPointF position, Qt::KeyboardModifiers modifiers ); | ||
|
||
virtual void update( QPointF position, Qt::KeyboardModifiers modifiers ); | ||
|
||
virtual void finish( QPointF, Qt::KeyboardModifiers ); | ||
|
||
|
||
}; | ||
|
||
class QgsLayoutViewEllipticalRubberBand : QgsLayoutViewRubberBand | ||
{ | ||
%Docstring | ||
QgsLayoutViewEllipseRubberBand is elliptical rubber band for use within QgsLayoutView widgets. | ||
.. versionadded:: 3.0 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgslayoutviewrubberband.h" | ||
%End | ||
public: | ||
|
||
QgsLayoutViewEllipticalRubberBand( QgsLayoutView *view ); | ||
%Docstring | ||
Constructor for QgsLayoutViewEllipticalRubberBand. | ||
%End | ||
virtual QgsLayoutViewEllipticalRubberBand *create( QgsLayoutView *view ) const /Factory/; | ||
|
||
|
||
~QgsLayoutViewEllipticalRubberBand(); | ||
|
||
virtual void start( QPointF position, Qt::KeyboardModifiers modifiers ); | ||
|
||
virtual void update( QPointF position, Qt::KeyboardModifiers modifiers ); | ||
|
||
virtual void finish( QPointF, Qt::KeyboardModifiers ); | ||
|
||
|
||
}; | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/layout/qgslayoutviewrubberband.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,6 @@ | |
|
||
|
||
|
||
|
||
class QgsLayoutViewToolAddItem : QgsLayoutViewTool | ||
{ | ||
%Docstring | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/*************************************************************************** | ||
qgslayoutitemregistryguiutils.h | ||
------------------------------- | ||
Date : July 2017 | ||
Copyright : (C) 2017 Nyall Dawson | ||
Email : nyall dot dawson at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
|
||
#include "qgslayoutitemregistryguiutils.h" | ||
#include "qgslayoutviewrubberband.h" | ||
|
||
void QgsLayoutItemRegistryGuiUtils::setItemRubberBandPrototype( int type, QgsLayoutViewRubberBand *prototype ) | ||
{ | ||
auto create = [prototype]( QgsLayoutView * view )->QgsLayoutViewRubberBand * | ||
{ | ||
return prototype->create( view ); | ||
}; | ||
QgsApplication::layoutItemRegistry()->mRubberBandFunctions.insert( type, create ); | ||
} |
Oops, something went wrong.