QElectroTech
0.8-dev
|
#include <elementprimitivedecorator.h>
Inherits QGraphicsObject.
Public Types | |
enum | { Type = UserType + 2200 } |
Public Slots | |
void | adjust () |
Signals | |
void | actionFinished (ElementEditionCommand *) |
Public Member Functions | |
ElementPrimitiveDecorator (QGraphicsItem *=nullptr) | |
~ElementPrimitiveDecorator () override | |
QRectF | internalBoundingRect () const |
QRectF | boundingRect () const override |
void | paint (QPainter *, const QStyleOptionGraphicsItem *, QWidget *=nullptr) override |
ElementPrimitiveDecorator::paint Paint the contents of an item in local coordinates, using painter, with respect to option and. More... | |
int | type () const override |
void | setItems (const QList< QGraphicsItem * > &) |
void | setItems (const QList< CustomElementPart * > &) |
QList< CustomElementPart * > | items () const |
QList< QGraphicsItem * > | graphicsItems () const |
Protected Member Functions | |
void | mousePressEvent (QGraphicsSceneMouseEvent *) override |
void | mouseMoveEvent (QGraphicsSceneMouseEvent *) override |
void | mouseReleaseEvent (QGraphicsSceneMouseEvent *) override |
void | keyPressEvent (QKeyEvent *) override |
ElementPrimitiveDecorator::keyPressEvent. More... | |
void | keyReleaseEvent (QKeyEvent *) override |
ElementPrimitiveDecorator::keyReleaseEvent. More... | |
QPointF | deltaForRoundScaling (const QRectF &, const QRectF &, qreal) |
QPointF | snapConstPointToGrid (const QPointF &) const |
void | snapPointToGrid (QPointF &) const |
bool | mustSnapToGrid (QGraphicsSceneMouseEvent *) |
QET::ScalingMethod | scalingMethod (QGraphicsSceneMouseEvent *) |
QVariant | itemChange (GraphicsItemChange change, const QVariant &value) override |
ElementPrimitiveDecorator::itemChange. More... | |
bool | sceneEventFilter (QGraphicsItem *watched, QEvent *event) override |
ElementPrimitiveDecorator::sceneEventFilter. More... | |
Private Attributes | |
QList< CustomElementPart * > | decorated_items_ |
QRectF | effective_bounding_rect_ |
actual, effective bounding rect – never shrinks More... | |
QRectF | original_bounding_rect_ |
original bounding rect More... | |
QRectF | modified_bounding_rect_ |
new bounding rect, after the user moved or resized items More... | |
int | current_operation_square_ |
int | grid_step_x_ |
Grid horizontal step. More... | |
int | grid_step_y_ |
Grid horizontal step. More... | |
QPointF | first_pos_ |
First point involved within the current resizing operation. More... | |
QPointF | latest_pos_ |
Latest point involved within the current resizing operation. More... | |
QPointF | mouse_offset_ |
Offset between the mouse position and the point to be snapped to grid when moving selection. More... | |
bool | moving_by_keys_ |
Whether we are currently moving our decorated items using the arrow keys. More... | |
QPointF | keys_movement_ |
Movement applied to our decorated items using the arrow keys. More... | |
QVector< QetGraphicsHandlerItem * > | m_handler_vector |
int | m_vector_index = -1 |
This class represents a decorator rendered above selected items so users can manipulate (move, resize, ...) them.
The implementation considers four kinds of bounding rects:
ElementPrimitiveDecorator::ElementPrimitiveDecorator | ( | QGraphicsItem * | parent = nullptr | ) |
Constructor
parent | Parent QGraphicsItem |
|
override |
Destructor
|
signal |
|
private |
ElementPrimitiveDecorator::addHandler Add handlers for this item.
|
slot |
Adjust the visual decorator according to the currently assigned items. It is notably called by setItems().
|
private |
Adjust the effective bounding rect. This method should be called after the modified_bouding_rect_ attribute was modified.
|
private |
ElementPrimitiveDecorator::adjusteHandlerPos.
|
private |
Apply the movement described by movement_type and movement to rect.
|
override |
|
protected |
Receive two rects, assuming they share a common corner and current is a scaled version of original. Calculate the scale ratios implied by this assumption, round them to the nearest multiple of epsilon, then return the horizontal and vertical offsets to be applied in order to pass from current to original scaled by the rounded factors. This method can be used to adjust a mouse movement so that it inputs a round scaling operation.
|
private |
|
private |
QList< QGraphicsItem * > ElementPrimitiveDecorator::graphicsItems | ( | ) | const |
|
private |
ElementPrimitiveDecorator::handlerMouseMoveEvent.
qghi | |
event |
|
private |
ElementPrimitiveDecorator::handlerMousePressEvent.
qghi | |
event |
|
private |
ElementPrimitiveDecorator::handlerMouseReleaseEvent.
qghi | |
event |
|
private |
QRectF ElementPrimitiveDecorator::internalBoundingRect | ( | ) | const |
|
overrideprotected |
ElementPrimitiveDecorator::itemChange.
change | |
value |
QList< CustomElementPart * > ElementPrimitiveDecorator::items | ( | ) | const |
|
overrideprotected |
ElementPrimitiveDecorator::keyPressEvent.
e |
|
overrideprotected |
ElementPrimitiveDecorator::keyReleaseEvent.
e |
|
overrideprotected |
Handle event generated when the mouse is moved and the decorator is the mouse grabber item.
event | Object describing the mouse event |
|
overrideprotected |
Handle event generated when mouse buttons are pressed.
event | Object describing the mouse event |
|
overrideprotected |
Handle event generated when a mouse buttons are releaseis moved and the decorator is the mouse grabber item.
event | Object describing the mouse event |
|
protected |
|
override |
ElementPrimitiveDecorator::paint Paint the contents of an item in local coordinates, using painter, with respect to option and.
painter | : |
option | : The option parameter provides style options for the item, such as its state, exposed area and its level-of-detail hints. |
widget | : The widget argument is optional. If provided, it points to the widget that is being painted on; otherwise, it is 0. For cached painting, widget is always 0. |
|
private |
ElementPrimitiveDecorator::removeHandler Remove the handlers of this item.
|
private |
Save the original bounding rectangle.
|
private |
Scale the managed items, provided they originally fit within original_rect and they should now fit new_rect
|
protected |
event | Mouse event during the scale operations – simply passed to mustSnapToGrid() |
|
overrideprotected |
ElementPrimitiveDecorator::sceneEventFilter.
watched | |
event |
void ElementPrimitiveDecorator::setItems | ( | const QList< CustomElementPart * > & | items | ) |
items | the new list of items this decorator is suposed to manipulate. |
void ElementPrimitiveDecorator::setItems | ( | const QList< QGraphicsItem * > & | items | ) |
items | the new list of items this decorator is suposed to manipulate. |
|
private |
|
protected |
Round the coordinates of point so it is snapped to the grid defined by the grid_step_x_ and grid_step_y_ attributes.
|
protected |
Round the coordinates of point so it is snapped to the grid defined by the grid_step_x_ and grid_step_y_ attributes.
|
private |
Start a movement (i.e. either a move or scaling operation)
|
private |
Translated the managed items by the movement
|
inlineoverride |
|
private |
Index of the square leading the current operation (resizing, etc.) or -1 if no operation is occurring, -2 for a move operation.
|
private |
|
private |
actual, effective bounding rect – never shrinks
|
private |
First point involved within the current resizing operation.
|
private |
Grid horizontal step.
|
private |
Grid horizontal step.
|
private |
Movement applied to our decorated items using the arrow keys.
|
private |
Latest point involved within the current resizing operation.
|
private |
|
private |
|
private |
new bounding rect, after the user moved or resized items
|
private |
Offset between the mouse position and the point to be snapped to grid when moving selection.
|
private |
Whether we are currently moving our decorated items using the arrow keys.
|
private |
original bounding rect