umbrello 26.03.70-f7b1fd3 Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

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< GuideLine > | activeGuides () 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

UMLScene * | m_scene
QList< GuideLine > | m_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:

- Horizontal guides: top edge, bottom edge, vertical center
- Vertical guides: left edge, right edge, horizontal center

## 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

  position | The position to check
  candidates | List of candidate alignment values
  minDistance | In/out parameter for minimum distance found
  bestSnap | Out parameter for the best snap position
  offset | Out parameter for the offset to apply
  bestGuideType | In/out parameter for tracking the best guide type
  guideType | The 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

  enabled | True 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

  threshold | Distance 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

  widget | The widget being moved
  proposedPos | The 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

  widget | The widget being resized
  proposedWidth | The proposed new width
  proposedHeight | The proposed new height
  newWidth | Output parameter for snapped width
  newHeight | Output 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:

- umbrello/umlwidgets/alignmentguide.h
- umbrello/umlwidgets/alignmentguide.cpp