OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
ot::Grid Class Reference

The Grid describes how a 2D Grid should look and behave like. More...

#include "Grid.h"

Inheritance diagram for ot::Grid:
ot::Serializable

Public Types

enum  GridFlag {
  NoGridFlags = 0x0000 , ShowNormalLines = 0x0001 , ShowWideLines = 0x0002 , ShowCenterCross = 0x0004 ,
  NoGridLineMask = 0xFFF0 , AutoScaleGrid = 0x0010
}
 A GridFlag describe the grid appearance. More...
 
enum  GridSnapMode { NoGridSnap , SnapTopLeft , SnapCenter }
 The GridSnapMode describe if and how the grid snapping should be performed. More...
 
typedef Flags< GridFlagGridFlags
 GridFlags are use describe the grid appearance.
 

Public Member Functions

 Grid ()
 
 Grid (double _defaultGridLineWidth, const GridFlags &_flags, GridSnapMode _snapMode)
 
 Grid (const Point2D &_gridStep, const Point2D &_gridWideEvery, const OutlineF &_gridLineStyle, const GridFlags &_flags, GridSnapMode _snapMode)
 
 Grid (const Grid &_other)
 
virtual ~Grid ()
 
Gridoperator= (const Grid &_other)
 
virtual void addToJsonObject (ot::JsonValue &_object, ot::JsonAllocator &_allocator) const override
 Add the object contents to the provided JSON object.
 
virtual void setFromJsonObject (const ot::ConstJsonObject &_object) override
 Set the object contents from the provided JSON object.
 
Point2D snapToGrid (const Point2D &_pt) const
 Snaps the provided point to the grid if snapping is enabled.
 
Point2DF snapToGrid (const Point2DF &_pt) const
 Snaps the provided point to the grid if snapping is enabled.
 
Point2DD snapToGrid (const Point2DD &_pt) const
 Snaps the provided point to the grid if snapping is enabled.
 
void setGridFlag (GridFlag _flag, bool _active=true)
 Sets/Unsets the provided flag.
 
void setGridFlags (const GridFlags &_flags)
 Sets the current GridFlags.
 
const GridFlagsgetGridFlags (void) const
 Returns the current GridFlags.
 
void setGridStep (int _step)
 Sets the current grid step size.
 
void setGridStep (const Point2D &_step)
 Sets the current grid step size.
 
const Point2DgetGridStep (void) const
 Returns the current grid step size. The current step is the distance between every grid line on the X and Y axis.
 
void setWideGridLineCounter (int _stepCount)
 Set the wide grid line counter.
 
void setWideGridLineCounter (const Point2D &_stepCount)
 Set the wide grid line counter.
 
const Point2DgetWideGridLineCounter (void) const
 Returns the counter limit for wide grid lines. The counter must be greater than 1 to be valid. For a counter of (2, 5) every 2nd vertical (-x to +x) and every 5th horizontal (-y to +y) grid line will be wide.
 
void setGridSnapMode (GridSnapMode _mode)
 Sets the current GridSnapMode.
 
GridSnapMode getGridSnapMode (void) const
 Returns the current GridSnapMode.
 
void setGridLineColor (int _r, int _g, int _b, int _a=255)
 
void setGridLineColor (const Color &_color)
 
void setGridLineStyle (const OutlineF &_style)
 
const OutlineFgetGridLineStyle (void) const
 
bool isGridLinesValid (void) const
 Returns true if at least one type of grid should be drawn according to the current flags.
 
bool isGridSnapValid (void) const
 Returns true if the grid snap is enabled and the grid step is greater than 0 for at least one axis.
 
- Public Member Functions inherited from ot::Serializable
 Serializable ()
 
virtual ~Serializable ()
 

Static Public Member Functions

static std::string toString (GridFlag _flag)
 
static GridFlag stringToGridFlag (const std::string &_flag)
 
static std::list< std::string > toStringList (const GridFlags &_flags)
 
static GridFlags stringListToGridFlags (const std::list< std::string > &_flags)
 
static std::string toString (GridSnapMode _snapMode)
 
static GridSnapMode stringToGridSnapMode (const std::string &_snapMode)
 
static Point2D snapToGrid (const Point2D &_pt, const Point2D &_gridStep)
 Snaps the provided point to the specified grid.
 
static Point2DF snapToGrid (const Point2DF &_pt, const Point2D &_gridStep)
 Snaps the provided point to the specified grid.
 
static Point2DD snapToGrid (const Point2DD &_pt, const Point2D &_gridStep)
 Snaps the provided point to the specified grid.
 

Detailed Description

The Grid describes how a 2D Grid should look and behave like.

Member Typedef Documentation

◆ GridFlags

Grid< T >::GridFlags

GridFlags are use describe the grid appearance.

Member Enumeration Documentation

◆ GridFlag

A GridFlag describe the grid appearance.

Enumerator
NoGridFlags 
ShowNormalLines 

No grid flags.

ShowWideLines 

Basic lines should be drawn.

ShowCenterCross 

Wide lines should be drawn.

NoGridLineMask 

Center cross should be drawn.

AutoScaleGrid 

Mask used to check if no grid line flags are set.

Auto scaling is enabled.

◆ GridSnapMode

The GridSnapMode describe if and how the grid snapping should be performed.

Enumerator
NoGridSnap 
SnapTopLeft 

No grid snapping.

SnapCenter 

Items will snap to the grid. The top left corner of an item will be used as source for snapping.

Items will snap to the grid. The center point of an item will be used as source for snapping.

Constructor & Destructor Documentation

◆ Grid() [1/4]

Grid< T >::Grid ( )

◆ Grid() [2/4]

Grid< T >::Grid ( double _defaultGridLineWidth,
const GridFlags & _flags,
GridSnapMode _snapMode )

◆ Grid() [3/4]

Grid< T >::Grid ( const Point2D & _gridStep,
const Point2D & _gridWideEvery,
const OutlineF & _gridLineStyle,
const GridFlags & _flags,
GridSnapMode _snapMode )

◆ Grid() [4/4]

Grid< T >::Grid ( const Grid & _other)

◆ ~Grid()

Grid< T >::~Grid ( )
virtual

Member Function Documentation

◆ addToJsonObject()

void Grid< T >::addToJsonObject ( ot::JsonValue & _object,
ot::JsonAllocator & _allocator ) const
overridevirtual

Add the object contents to the provided JSON object.

Parameters
_objectJson object reference to write the data to.
_allocatorAllocator.

Implements ot::Serializable.

◆ getGridFlags()

const GridFlags & ot::Grid::getGridFlags ( void ) const
inline

Returns the current GridFlags.

See also
GridFlags

◆ getGridLineStyle()

const OutlineF & ot::Grid::getGridLineStyle ( void ) const
inline

◆ getGridSnapMode()

GridSnapMode ot::Grid::getGridSnapMode ( void ) const
inline

Returns the current GridSnapMode.

See also
GridSnapMode

◆ getGridStep()

const Point2D & ot::Grid::getGridStep ( void ) const
inline

Returns the current grid step size. The current step is the distance between every grid line on the X and Y axis.

◆ getWideGridLineCounter()

const Point2D & ot::Grid::getWideGridLineCounter ( void ) const
inline

Returns the counter limit for wide grid lines. The counter must be greater than 1 to be valid. For a counter of (2, 5) every 2nd vertical (-x to +x) and every 5th horizontal (-y to +y) grid line will be wide.

◆ isGridLinesValid()

bool ot::Grid::isGridLinesValid ( void ) const
inline

Returns true if at least one type of grid should be drawn according to the current flags.

◆ isGridSnapValid()

bool ot::Grid::isGridSnapValid ( void ) const
inline

Returns true if the grid snap is enabled and the grid step is greater than 0 for at least one axis.

◆ operator=()

ot::Grid & Grid< T >::operator= ( const Grid & _other)

◆ setFromJsonObject()

void Grid< T >::setFromJsonObject ( const ot::ConstJsonObject & _object)
overridevirtual

Set the object contents from the provided JSON object.

Parameters
_objectThe JSON object containing the information.
Exceptions
Maythrow an exception if the provided object is not valid (members missing or invalid types).

Implements ot::Serializable.

◆ setGridFlag()

void ot::Grid::setGridFlag ( GridFlag _flag,
bool _active = true )
inline

Sets/Unsets the provided flag.

Parameters
_flagFlag to set/unset.
_activeIf true the flag will be set, otherwise unset.
See also
GridFlags

◆ setGridFlags()

void ot::Grid::setGridFlags ( const GridFlags & _flags)
inline

Sets the current GridFlags.

See also
GridFlags

◆ setGridLineColor() [1/2]

void ot::Grid::setGridLineColor ( const Color & _color)
inline

◆ setGridLineColor() [2/2]

void ot::Grid::setGridLineColor ( int _r,
int _g,
int _b,
int _a = 255 )
inline

◆ setGridLineStyle()

void ot::Grid::setGridLineStyle ( const OutlineF & _style)
inline

◆ setGridSnapMode()

void ot::Grid::setGridSnapMode ( GridSnapMode _mode)
inline

Sets the current GridSnapMode.

See also
GridSnapMode

◆ setGridStep() [1/2]

void ot::Grid::setGridStep ( const Point2D & _step)
inline

Sets the current grid step size.

See also
getGridStep

◆ setGridStep() [2/2]

void ot::Grid::setGridStep ( int _step)
inline

Sets the current grid step size.

Parameters
_stepThe step distance that will be set for X and Y.

◆ setWideGridLineCounter() [1/2]

void ot::Grid::setWideGridLineCounter ( const Point2D & _stepCount)
inline

Set the wide grid line counter.

See also
getWideGridLineCounter

◆ setWideGridLineCounter() [2/2]

void ot::Grid::setWideGridLineCounter ( int _stepCount)
inline

Set the wide grid line counter.

Parameters
_stepCountThe step count for the X and Y axis.
See also
getWideGridLineCounter

◆ snapToGrid() [1/6]

ot::Point2D Grid< T >::snapToGrid ( const Point2D & _pt) const

Snaps the provided point to the grid if snapping is enabled.

◆ snapToGrid() [2/6]

ot::Point2D Grid< T >::snapToGrid ( const Point2D & _pt,
const Point2D & _gridStep )
static

Snaps the provided point to the specified grid.

◆ snapToGrid() [3/6]

ot::Point2DD Grid< T >::snapToGrid ( const Point2DD & _pt) const

Snaps the provided point to the grid if snapping is enabled.

◆ snapToGrid() [4/6]

ot::Point2DD Grid< T >::snapToGrid ( const Point2DD & _pt,
const Point2D & _gridStep )
static

Snaps the provided point to the specified grid.

◆ snapToGrid() [5/6]

ot::Point2DF Grid< T >::snapToGrid ( const Point2DF & _pt) const

Snaps the provided point to the grid if snapping is enabled.

◆ snapToGrid() [6/6]

ot::Point2DF Grid< T >::snapToGrid ( const Point2DF & _pt,
const Point2D & _gridStep )
static

Snaps the provided point to the specified grid.

◆ stringListToGridFlags()

ot::Grid::GridFlags Grid< T >::stringListToGridFlags ( const std::list< std::string > & _flags)
static

◆ stringToGridFlag()

ot::Grid::GridFlag Grid< T >::stringToGridFlag ( const std::string & _flag)
static

◆ stringToGridSnapMode()

ot::Grid::GridSnapMode Grid< T >::stringToGridSnapMode ( const std::string & _snapMode)
static

◆ toString() [1/2]

std::string Grid< T >::toString ( GridFlag _flag)
static

◆ toString() [2/2]

std::string Grid< T >::toString ( GridSnapMode _snapMode)
static

◆ toStringList()

std::list< std::string > Grid< T >::toStringList ( const GridFlags & _flags)
static

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