QElectroTech 0.200.1-dev
Loading...
Searching...
No Matches
DiagramEventAddShape Class Reference

The DiagramEventAddShape class This event manage the creation of a shape. More...

#include <diagrameventaddshape.h>

Inheritance diagram for DiagramEventAddShape:
Inheritance graph
Collaboration diagram for DiagramEventAddShape:
Collaboration graph

Public Member Functions

 DiagramEventAddShape (Diagram *diagram, QetShapeItem::ShapeType shape_type)
 DiagramEventAddShape::DiagramEventAddShape Default constructor.
 ~DiagramEventAddShape () override
 DiagramEventAddShape::~DiagramEventAddShape.
void mousePressEvent (QGraphicsSceneMouseEvent *event) override
 DiagramEventAddShape::mousePressEvent Action when mouse is pressed.
void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override
 DiagramEventAddShape::mouseMoveEvent Action when mouse move.
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override
 DiagramEventAddShape::mouseReleaseEvent Action when mouse button is released.
void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event) override
 DiagramEventAddShape::mouseDoubleClickEvent Action when mouse button is double clicked.
void keyPressEvent (QKeyEvent *event) override
 DiagramEventAddShape::keyPressEvent / keyReleaseEvent Pressing or releasing Shift (the square/circle lock) does nothing visible on its own – applyPosition() only ever runs from mouseMoveEvent, so without this, a keyboard-only change just sits there until the next, often incidental, pixel of mouse movement brings the shape in line with it. That's exactly what looked like a freeze: holding Shift while the mouse is genuinely still produces no visible change (correctly – nothing has moved), and it only "unsticks" once the mouse moves again, which released keys tend to coincide with purely by hand tremor, not because releasing itself did anything. Re-running the last known mouse position through applyPosition() here makes the key press or release itself the trigger, giving immediate feedback instead of waiting on chance.
void keyReleaseEvent (QKeyEvent *event) override
void init () override
Public Member Functions inherited from DiagramEventInterface
 DiagramEventInterface (Diagram *diagram)
 ~DiagramEventInterface () override=0
virtual void wheelEvent (QGraphicsSceneWheelEvent *event)
virtual bool isRunning () const

Protected Attributes

QetShapeItem::ShapeType m_shape_type
QetShapeItemm_shape_item
QGraphicsLineItem * m_help_horiz
QGraphicsLineItem * m_help_verti
QPointF m_anchor_point
QGraphicsEllipseItem * m_center_marker = nullptr
bool m_center_anchored = false
QPointF m_last_mouse_scene_pos
Protected Attributes inherited from DiagramEventInterface
QPointer< Diagramm_diagram
bool m_running {false}
bool m_abort {false}

Private Member Functions

void updateHelpCross (const QPointF &p)
 DiagramEventAddShape::updateHelpCross Create and update the position of the cross to help user for draw new shape.
void applyPosition (const QPointF &pos, Qt::KeyboardModifiers mods)
 DiagramEventAddShape::applyPosition Applies a drag/click position to the in-progress shape, honouring two modifiers that mirror how the very same shape can already be edited afterward, once placed:
void updateCreationHint () const
 DiagramEventAddShape::updateCreationHint Shows whichever of beforeClickHint()/afterClickHint() matches the current phase – there was previously either no message at all (Line/Rectangle/Ellipse) or a single static one that never changed regardless of progress (Polygon, set externally in QETDiagramEditor::addItemGroupTriggered()); this replaces both with one phase-aware message per shape type, managed by the tool itself.
QString beforeClickHint () const
QString afterClickHint () const
void showCenterMarker (const QPointF &scenePos)
 DiagramEventAddShape::showCenterMarker Small, filled marker at the anchor point, shown only while Ctrl- anchoring is actually in effect right now (see applyPosition()) – doubling as live confirmation that it is, rather than leaving the user to infer it purely from how the shape happens to be growing.
void hideCenterMarker ()
void reapplyLastPosition (QKeyEvent *event)

Additional Inherited Members

Signals inherited from DiagramEventInterface
void finish ()

Detailed Description

The DiagramEventAddShape class This event manage the creation of a shape.

Constructor & Destructor Documentation

◆ DiagramEventAddShape()

DiagramEventAddShape::DiagramEventAddShape ( Diagram * diagram,
QetShapeItem::ShapeType shape_type )

DiagramEventAddShape::DiagramEventAddShape Default constructor.

Parameters
diagram: the diagram where this event must operate
shape_type: the type of shape to draw
Here is the call graph for this function:

◆ ~DiagramEventAddShape()

DiagramEventAddShape::~DiagramEventAddShape ( )
override

DiagramEventAddShape::~DiagramEventAddShape.

Here is the call graph for this function:

Member Function Documentation

◆ afterClickHint()

QString DiagramEventAddShape::afterClickHint ( ) const
private
Here is the caller graph for this function:

◆ applyPosition()

void DiagramEventAddShape::applyPosition ( const QPointF & pos,
Qt::KeyboardModifiers mods )
private

DiagramEventAddShape::applyPosition Applies a drag/click position to the in-progress shape, honouring two modifiers that mirror how the very same shape can already be edited afterward, once placed:

  • Ctrl, for Rectangle/Ellipse only: the first click becomes the shape's center rather than a corner, growing symmetrically as the cursor moves away from it – the same meaning Ctrl already has on a Resize handle (anchor at center). Deliberately not offered for Line: unlike the Rectangle/Ellipse case, there's no established convention for "a line grows symmetrically from its middle" to justify it by, so Ctrl for Line means only free positioning (see the plain grid-snap check above), nothing more.
  • Shift, for Rectangle/Ellipse only: forces the bounding box square (so Ellipse becomes a true circle), using whichever of the two dragged dimensions is currently larger and mirroring that onto the other, preserving the direction the user is actually dragging in. Both can combine (Ctrl+Shift: a centered square/circle). Whether or not Ctrl is currently held, the non-anchored branch always rebuilds from m_anchor_point rather than nudging the existing rect/line – otherwise, if Ctrl had been held earlier in the same drag (moving the shape's own first point to a mirrored position), releasing it would leave that point stuck there instead of actually restoring it.
Here is the caller graph for this function:

◆ beforeClickHint()

QString DiagramEventAddShape::beforeClickHint ( ) const
private
Here is the caller graph for this function:

◆ hideCenterMarker()

void DiagramEventAddShape::hideCenterMarker ( )
private
Here is the caller graph for this function:

◆ init()

void DiagramEventAddShape::init ( )
overridevirtual

Reimplemented from DiagramEventInterface.

Here is the caller graph for this function:

◆ keyPressEvent()

void DiagramEventAddShape::keyPressEvent ( QKeyEvent * event)
overridevirtual

DiagramEventAddShape::keyPressEvent / keyReleaseEvent Pressing or releasing Shift (the square/circle lock) does nothing visible on its own – applyPosition() only ever runs from mouseMoveEvent, so without this, a keyboard-only change just sits there until the next, often incidental, pixel of mouse movement brings the shape in line with it. That's exactly what looked like a freeze: holding Shift while the mouse is genuinely still produces no visible change (correctly – nothing has moved), and it only "unsticks" once the mouse moves again, which released keys tend to coincide with purely by hand tremor, not because releasing itself did anything. Re-running the last known mouse position through applyPosition() here makes the key press or release itself the trigger, giving immediate feedback instead of waiting on chance.

Reimplemented from DiagramEventInterface.

Here is the call graph for this function:

◆ keyReleaseEvent()

void DiagramEventAddShape::keyReleaseEvent ( QKeyEvent * event)
overridevirtual

Reimplemented from DiagramEventInterface.

Here is the call graph for this function:

◆ mouseDoubleClickEvent()

void DiagramEventAddShape::mouseDoubleClickEvent ( QGraphicsSceneMouseEvent * event)
overridevirtual

DiagramEventAddShape::mouseDoubleClickEvent Action when mouse button is double clicked.

Parameters
event: event of mouse double click

Reimplemented from DiagramEventInterface.

Here is the call graph for this function:

◆ mouseMoveEvent()

void DiagramEventAddShape::mouseMoveEvent ( QGraphicsSceneMouseEvent * event)
overridevirtual

DiagramEventAddShape::mouseMoveEvent Action when mouse move.

Parameters
event: event of mouse move

Reimplemented from DiagramEventInterface.

Here is the call graph for this function:

◆ mousePressEvent()

void DiagramEventAddShape::mousePressEvent ( QGraphicsSceneMouseEvent * event)
overridevirtual

DiagramEventAddShape::mousePressEvent Action when mouse is pressed.

Parameters
event: event of mouse press

Reimplemented from DiagramEventInterface.

Here is the call graph for this function:

◆ mouseReleaseEvent()

void DiagramEventAddShape::mouseReleaseEvent ( QGraphicsSceneMouseEvent * event)
overridevirtual

DiagramEventAddShape::mouseReleaseEvent Action when mouse button is released.

Parameters
event: event of mouse release

Reimplemented from DiagramEventInterface.

Here is the call graph for this function:

◆ reapplyLastPosition()

void DiagramEventAddShape::reapplyLastPosition ( QKeyEvent * event)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ showCenterMarker()

void DiagramEventAddShape::showCenterMarker ( const QPointF & scenePos)
private

DiagramEventAddShape::showCenterMarker Small, filled marker at the anchor point, shown only while Ctrl- anchoring is actually in effect right now (see applyPosition()) – doubling as live confirmation that it is, rather than leaving the user to infer it purely from how the shape happens to be growing.

Here is the caller graph for this function:

◆ updateCreationHint()

void DiagramEventAddShape::updateCreationHint ( ) const
private

DiagramEventAddShape::updateCreationHint Shows whichever of beforeClickHint()/afterClickHint() matches the current phase – there was previously either no message at all (Line/Rectangle/Ellipse) or a single static one that never changed regardless of progress (Polygon, set externally in QETDiagramEditor::addItemGroupTriggered()); this replaces both with one phase-aware message per shape type, managed by the tool itself.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateHelpCross()

void DiagramEventAddShape::updateHelpCross ( const QPointF & p)
private

DiagramEventAddShape::updateHelpCross Create and update the position of the cross to help user for draw new shape.

Parameters
p: the center of the cross
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_anchor_point

QPointF DiagramEventAddShape::m_anchor_point
protected

◆ m_center_anchored

bool DiagramEventAddShape::m_center_anchored = false
protected

◆ m_center_marker

QGraphicsEllipseItem* DiagramEventAddShape::m_center_marker = nullptr
protected

◆ m_help_horiz

QGraphicsLineItem* DiagramEventAddShape::m_help_horiz
protected

◆ m_help_verti

QGraphicsLineItem * DiagramEventAddShape::m_help_verti
protected

◆ m_last_mouse_scene_pos

QPointF DiagramEventAddShape::m_last_mouse_scene_pos
protected

◆ m_shape_item

QetShapeItem* DiagramEventAddShape::m_shape_item
protected

◆ m_shape_type

QetShapeItem::ShapeType DiagramEventAddShape::m_shape_type
protected

The documentation for this class was generated from the following files: