Ipelib: ipe::Snap Class Reference

Ipelib

Public Types | Public Member Functions | Public Attributes | List of all members
ipe::Snap Class Reference
Ipe Utilities

`#include <ipesnap.h>`

## Public Types
enum | TSnapModes { ESnapNone = 0, ESnapVtx = 1, ESnapCtl = 2, ESnapBd = 4, ESnapInt = 8, ESnapGrid = 0x10, ESnapAngle = 0x20, ESnapAuto = 0x40, ESnapCustom = 0x80 }

## Public Member Functions
void | intersectionSnap (const Vector &pos, Vector &fifi, const Page *page, int view, double &snapDist) const noexcept
bool | snapAngularIntersection (Vector &pos, const Line &l, const Page *page, int view, double snapDist) const noexcept
TSnapModes | simpleSnap (Vector &pos, const Page *page, int view, double snapDist, Tool *tool=nullptr) const noexcept
TSnapModes | snap (Vector &pos, const Page *page, int view, double snapDist, Tool *tool=nullptr, Vector *autoOrg=nullptr) const noexcept
Line | getLine (const Vector &mouse, const Vector &base) const noexcept
bool | setEdge (const Vector &pos, const Page *page, int view) noexcept

## Public Attributes
int | iSnap
bool | iGridVisible
int | iGridSize
double | iAngleSize
int | iSnapDistance
bool | iWithAxes
Vector | iOrigin
Angle | iDir

## Detailed Description

Performs snapping operations, and stores snapping state.

## Member Enumeration Documentation

## ◆ TSnapModes

enum ipe::Snap::TSnapModes

The different snap modes as bitmasks.

Enumerator
ESnapNone |
ESnapVtx |
ESnapCtl |
ESnapBd |
ESnapInt |
ESnapGrid |
ESnapAngle |
ESnapAuto |
ESnapCustom |

## Member Function Documentation

## ◆ intersectionSnap()

void Snap::intersectionSnap | ( | const Vector & | pos,
|  | Vector & | fifi,
|  | const Page * | page,
|  | int | view,
|  | double & | snapDist
| ) |  | const
| noexcept

Perform intersection snapping.

References ipe::size().

## ◆ snapAngularIntersection()

bool Snap::snapAngularIntersection | ( | Vector & | pos,
|  | const Line & | l,
|  | const Page * | page,
|  | int | view,
|  | double | snapDist
| ) |  | const
| noexcept

Perform snapping to intersection of angular line and pos.

## ◆ simpleSnap()

Snap::TSnapModes Snap::simpleSnap | ( | Vector & | pos,
|  | const Page * | page,
|  | int | view,
|  | double | snapDist,
|  | Tool * | tool = `nullptr`
| ) |  | const
| noexcept

Tries vertex, intersection, boundary, and grid snapping.

If snapping occurred, pos is set to the new user space position.

References ipe::Page::count(), ipe::Page::objSnapsInView(), ipe::Page::snapBnd(), ipe::Page::snapCtl(), ipe::Page::snapVtx(), ipe::Vector::x, and ipe::Vector::y.

## ◆ snap()

Snap::TSnapModes Snap::snap | ( | Vector & | pos,
|  | const Page * | page,
|  | int | view,
|  | double | snapDist,
|  | Tool * | tool = `nullptr`,
|  | Vector * | autoOrg = `nullptr`
| ) |  | const
| noexcept

Performs snapping of position pos.

Returns `true` if snapping occurred. In that case pos is set to the new user space position.

Automatic angular snapping occurs if autoOrg is not null — the value is then used as the origin for automatic angular snapping.

References ipe::Line::intersects(), ipe::Line::project(), and ipe::Vector::sqLen().

## ◆ getLine()

Line Snap::getLine | ( | const Vector & | mouse,
|  | const Vector & | base
| ) |  | const
| noexcept

Find line through base with slope determined by angular snap size and direction.

References ipe::Vector::angle(), ipe::Vector::len(), and ipe::Angle::normalize().

## ◆ setEdge()

bool Snap::setEdge | ( | const Vector & | pos,
|  | const Page * | page,
|  | int | view
| ) |  |
| noexcept

Set axis origin and direction from edge near mouse.

Returns `true` if successful.

References ipe::Vector::angle(), ipe::Line::dir(), ipe::Arc::distance(), ipe::Arc::iM, ipe::Segment::iP, ipe::Segment::iQ, ipe::Segment::line(), ipe::Matrix::linear(), ipe::Line::project(), ipe::Bezier::snap(), and ipe::Bezier::tangent().

## Member Data Documentation

## ◆ iSnap

int ipe::Snap::iSnap

Activated snapping modes (TSnapModes)

## ◆ iGridVisible

bool ipe::Snap::iGridVisible

Is the grid visible?

## ◆ iGridSize

int ipe::Snap::iGridSize

Snap grid spacing.

## ◆ iAngleSize

double ipe::Snap::iAngleSize

Angle for angular snapping.

## ◆ iSnapDistance

int ipe::Snap::iSnapDistance

Snap distance (in pixels).

## ◆ iWithAxes

bool ipe::Snap::iWithAxes

Show coordinate system?

Referenced by ipe::TransformTool::TransformTool().

## ◆ iOrigin

Vector ipe::Snap::iOrigin

Origin of coordinate system.

Referenced by ipe::TransformTool::TransformTool().

## ◆ iDir

Angle ipe::Snap::iDir

Direction of x-axis.

Referenced by ipe::TransformTool::TransformTool().

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

- ipesnap.h
- ipesnap.cpp