Entropy Piano Tuner  1.1.3 (documentation not yet complete)
An open-source experimental software for piano tuning by entropy minimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
GraphicsItem Class Referenceabstract

Class for a single item in a graphics view. More...

#include <graphicsitem.h>

+ Inheritance diagram for GraphicsItem:
+ Collaboration diagram for GraphicsItem:

Public Types

using RoleType = std::uint32_t
 Type of a user role that can be set in a GraphicsItem (bitwise flag). More...
 

Public Member Functions

 GraphicsItem (GraphicsViewAdapter *graphicsView)
 Constructor. More...
 
virtual ~GraphicsItem ()
 Virtual Destructor. More...
 
void setKeyIndexAndItemRole (int index, RoleType role)
 Short function for setting the key index and the role. More...
 
void setKeyIndex (int index)
 Setter for mKeyIndex. More...
 
int getKeyIndex () const
 Getter for mKeyIndex. More...
 
void setItemRole (RoleType role)
 Setter function for mRole. More...
 
void addItemRole (RoleType role)
 Bitwise add of role and mRole. More...
 
RoleType getItemRole () const
 Getter for mRole. More...
 
GraphicsViewAdaptergetGraphicsView ()
 Getter for mGraphicsView. More...
 
virtual void setPosition (double x, double y)=0
 Function to set the position of the element. More...
 
virtual void setZOrder (double z)
 Set the z order of the element (here implemented without function) More...
 

Protected Attributes

GraphicsViewAdaptermGraphicsView
 Pointer to the parent GraphicsViewAdapter. More...
 
int mKeyIndex
 
RoleType mRole
 The index of this item to identify it with a key. More...
 

Detailed Description

Class for a single item in a graphics view.

Whenever a new element is drawn in the GraphicsViewAdapter a new GraphicItem has to be created. This item will be usful whenever a single item has to be changed. For example, the tuning marks have to be moved during the calculation process.

You can set a key index to identify an item with a key and you can set a user-defined role that will be treated as bitwise flag. All of this is useful if you want to find a single item in the list of all items in a GraphicsViewAdapter.

A key index of -1 is allowed to indicate no link with a key. This is normally a global item.

The GUI implementation should define its own GraphicsItem and reimplement setPosition(float, float)

Whenever the GraphicsItem is changed the GraphicsViewAdapter implementation should redraw the corresponding element, but not the complete panel.

Definition at line 55 of file graphicsitem.h.

Member Typedef Documentation

using GraphicsItem::RoleType = std::uint32_t

Type of a user role that can be set in a GraphicsItem (bitwise flag).

Definition at line 62 of file graphicsitem.h.

Constructor & Destructor Documentation

GraphicsItem::GraphicsItem ( GraphicsViewAdapter graphicsView)

Constructor.

It will automatically add this as new element to the GraphicsViewAdapter.

Parameters
graphicsView: The parent GraphicsViewAdapter

Definition at line 31 of file graphicsitem.cpp.

+ Here is the call graph for this function:

GraphicsItem::~GraphicsItem ( )
virtual

Virtual Destructor.

It will automatically remove this as element from the GraphicsViewAdapter.

Definition at line 44 of file graphicsitem.cpp.

+ Here is the call graph for this function:

Member Function Documentation

void GraphicsItem::addItemRole ( RoleType  role)
inline

Bitwise add of role and mRole.

Parameters
role: The role to add

Definition at line 110 of file graphicsitem.h.

GraphicsViewAdapter* GraphicsItem::getGraphicsView ( )
inline

Getter for mGraphicsView.

Returns
mGraphicsView.

Definition at line 122 of file graphicsitem.h.

RoleType GraphicsItem::getItemRole ( ) const
inline

Getter for mRole.

Returns
mRole

Definition at line 116 of file graphicsitem.h.

int GraphicsItem::getKeyIndex ( ) const
inline

Getter for mKeyIndex.

Returns
mKeyIndex

Definition at line 98 of file graphicsitem.h.

void GraphicsItem::setItemRole ( RoleType  role)
inline

Setter function for mRole.

Parameters
role: The user defined role of the item

Definition at line 104 of file graphicsitem.h.

void GraphicsItem::setKeyIndex ( int  index)
inline

Setter for mKeyIndex.

Parameters
index: The key index of the item

Definition at line 92 of file graphicsitem.h.

void GraphicsItem::setKeyIndexAndItemRole ( int  index,
RoleType  role 
)

Short function for setting the key index and the role.

The function will all setItemRole(RoleType) and setKeyIndex(int).

Parameters
index: The key index of the item
role: The user defined item role

Definition at line 53 of file graphicsitem.cpp.

+ Here is the call graph for this function:

virtual void GraphicsItem::setPosition ( double  x,
double  y 
)
pure virtual

Function to set the position of the element.

This function should be reimplemented by an actual implementation of the element.

Parameters
x: The relative x coord
y: The relative y coord

Implemented in GraphicsItemForQt.

virtual void GraphicsItem::setZOrder ( double  z)
inlinevirtual

Set the z order of the element (here implemented without function)

Parameters
z: The z order

Reimplemented in GraphicsItemForQt.

Definition at line 138 of file graphicsitem.h.

Member Data Documentation

GraphicsViewAdapter* GraphicsItem::mGraphicsView
protected

Pointer to the parent GraphicsViewAdapter.

Definition at line 142 of file graphicsitem.h.

int GraphicsItem::mKeyIndex
protected

Definition at line 143 of file graphicsitem.h.

RoleType GraphicsItem::mRole
protected

The index of this item to identify it with a key.

Definition at line 144 of file graphicsitem.h.


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