umbrello 26.03.70-f7b1fd3
Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
AlignmentGuide Class Reference

Manages alignment guides and snapping for widget movement. More...

#include <alignmentguide.h>

Classes

struct  AlignmentPoints
 
struct  GuideLine
 

Public Types

enum class  GuideType {
  None , LeftEdge , RightEdge , HorizontalCenter ,
  TopEdge , BottomEdge , VerticalCenter
}
 

Public Member Functions

 AlignmentGuide (UMLScene *scene)
 
 ~AlignmentGuide ()
 
QPointF snapPosition (UMLWidget *widget, const QPointF &proposedPos)
 
void snapResize (UMLWidget *widget, qreal proposedWidth, qreal proposedHeight, qreal &newWidth, qreal &newHeight)
 
QList< GuideLineactiveGuides () const
 
void clear ()
 
void setSnapThreshold (qreal threshold)
 
qreal snapThreshold () const
 
void setEnabled (bool enabled)
 
bool isEnabled () const
 

Private Member Functions

AlignmentPoints getAlignmentPoints (UMLWidget *widget, const QPointF &pos) const
 
void findBestSnap (qreal position, const QList< qreal > &candidates, qreal &minDistance, qreal &bestSnap, qreal &offset, GuideType &bestGuideType, GuideType guideType) const
 

Private Attributes

UMLScenem_scene
 
QList< GuideLinem_activeGuides
 
qreal m_snapThreshold
 
bool m_enabled
 

Detailed Description

Manages alignment guides and snapping for widget movement.

This class provides visual alignment guides and automatic snapping when dragging widgets near alignment points of other widgets.

Alignment points include:

Member Enumeration Documentation

◆ GuideType

enum class AlignmentGuide::GuideType
strong

Types of alignment guides.

Enumerator
None 
LeftEdge 
RightEdge 
HorizontalCenter 
TopEdge 
BottomEdge 
VerticalCenter 

Constructor & Destructor Documentation

◆ AlignmentGuide()

AlignmentGuide::AlignmentGuide ( UMLScene scene)
explicit

◆ ~AlignmentGuide()

AlignmentGuide::~AlignmentGuide ( )

Member Function Documentation

◆ activeGuides()

QList< AlignmentGuide::GuideLine > AlignmentGuide::activeGuides ( ) const

Get the list of active guide lines to render.

Returns
List of guide lines

Get the list of active guide lines.

◆ clear()

void AlignmentGuide::clear ( )

Clear all active guides.

◆ findBestSnap()

void AlignmentGuide::findBestSnap ( qreal  position,
const QList< qreal > &  candidates,
qreal &  minDistance,
qreal &  bestSnap,
qreal &  offset,
GuideType bestGuideType,
GuideType  guideType 
) const
private

Find the best snap among candidates for a given position.

Parameters
positionThe position to check
candidatesList of candidate alignment values
minDistanceIn/out parameter for minimum distance found
bestSnapOut parameter for the best snap position
offsetOut parameter for the offset to apply
bestGuideTypeIn/out parameter for tracking the best guide type
guideTypeThe guide type to set if this is the best match

Find the best snap among candidates for a given position.

◆ getAlignmentPoints()

AlignmentGuide::AlignmentPoints AlignmentGuide::getAlignmentPoints ( UMLWidget widget,
const QPointF &  pos 
) const
private

Calculate alignment points for a widget at a given position.

◆ isEnabled()

bool AlignmentGuide::isEnabled ( ) const

Check if alignment guides are enabled.

Returns
True if enabled

Check if alignment guides are enabled.

◆ setEnabled()

void AlignmentGuide::setEnabled ( bool  enabled)

Enable or disable alignment guides.

Parameters
enabledTrue to enable, false to disable

Enable or disable alignment guides.

◆ setSnapThreshold()

void AlignmentGuide::setSnapThreshold ( qreal  threshold)

Set the snap threshold distance in pixels (screen coordinates).

Parameters
thresholdDistance within which snapping occurs

Set the snap threshold.

◆ snapPosition()

QPointF AlignmentGuide::snapPosition ( UMLWidget widget,
const QPointF &  proposedPos 
)

Check for alignment opportunities and snap the position if near an alignment.

Parameters
widgetThe widget being moved
proposedPosThe proposed new position
Returns
The snapped position (may be same as proposedPos if no snap)

Snap the proposed position to nearby alignment guides.

◆ snapResize()

void AlignmentGuide::snapResize ( UMLWidget widget,
qreal  proposedWidth,
qreal  proposedHeight,
qreal &  newWidth,
qreal &  newHeight 
)

Check for alignment opportunities and snap the size during resize.

Parameters
widgetThe widget being resized
proposedWidthThe proposed new width
proposedHeightThe proposed new height
newWidthOutput parameter for snapped width
newHeightOutput parameter for snapped height

Snap the size during resize operations.

◆ snapThreshold()

qreal AlignmentGuide::snapThreshold ( ) const

Get the current snap threshold in scene coordinates. This is adjusted based on the current zoom level to maintain a consistent screen-space distance.

Returns
Snap threshold in scene coordinates

Get the snap threshold in scene coordinates. Adjusts for zoom level to maintain consistent screen-space distance.

Member Data Documentation

◆ m_activeGuides

QList<GuideLine> AlignmentGuide::m_activeGuides
private

◆ m_enabled

bool AlignmentGuide::m_enabled
private

◆ m_scene

UMLScene* AlignmentGuide::m_scene
private

◆ m_snapThreshold

qreal AlignmentGuide::m_snapThreshold
private

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