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.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright 2015 Haye Hinrichsen, Christoph Wick
3  *
4  * This file is part of Entropy Piano Tuner.
5  *
6  * Entropy Piano Tuner is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * Entropy Piano Tuner is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * Entropy Piano Tuner. If not, see http://www.gnu.org/licenses/.
18  *****************************************************************************/
19 
20 //============================================================================
21 // Abstract class of a Graphics Item
22 //============================================================================
23 
24 #ifndef GRAPHICSITEM_H
25 #define GRAPHICSITEM_H
26 
27 #include <list>
28 #include <cstdint>
29 
31 
54 
56 {
57 public:
58 
62  using RoleType = std::uint32_t;
63 
70  GraphicsItem(GraphicsViewAdapter *graphicsView);
71 
77  virtual ~GraphicsItem();
78 
86  void setKeyIndexAndItemRole(int index, RoleType role);
87 
92  void setKeyIndex(int index) {mKeyIndex = index;}
93 
98  int getKeyIndex() const {return mKeyIndex;}
99 
104  void setItemRole(RoleType role) {mRole = role;}
105 
110  void addItemRole(RoleType role) {mRole |= role;}
111 
116  RoleType getItemRole() const {return mRole;}
117 
123 
132  virtual void setPosition(double x, double y) = 0;
133 
138  virtual void setZOrder(double z) { (void)z; }
139 
140 protected:
141 
143  int mKeyIndex;
145 };
146 
147 
148 using GraphicItemsList = std::list<GraphicsItem*>;
149 
150 #endif // GRAPHICSITEM_H
151 
std::uint32_t RoleType
Type of a user role that can be set in a GraphicsItem (bitwise flag).
Definition: graphicsitem.h:62
void setItemRole(RoleType role)
Setter function for mRole.
Definition: graphicsitem.h:104
void addItemRole(RoleType role)
Bitwise add of role and mRole.
Definition: graphicsitem.h:110
virtual void setPosition(double x, double y)=0
Function to set the position of the element.
virtual void setZOrder(double z)
Set the z order of the element (here implemented without function)
Definition: graphicsitem.h:138
int getKeyIndex() const
Getter for mKeyIndex.
Definition: graphicsitem.h:98
std::list< GraphicsItem * > GraphicItemsList
A list of GraphicItem (global)
Definition: graphicsitem.h:148
RoleType mRole
The index of this item to identify it with a key.
Definition: graphicsitem.h:144
virtual ~GraphicsItem()
Virtual Destructor.
RoleType getItemRole() const
Getter for mRole.
Definition: graphicsitem.h:116
GraphicsItem(GraphicsViewAdapter *graphicsView)
Constructor.
GraphicsViewAdapter * mGraphicsView
Pointer to the parent GraphicsViewAdapter.
Definition: graphicsitem.h:142
Abstract base class for implementations rendering graphics.
Class for a single item in a graphics view.
Definition: graphicsitem.h:55
void setKeyIndexAndItemRole(int index, RoleType role)
Short function for setting the key index and the role.
void setKeyIndex(int index)
Setter for mKeyIndex.
Definition: graphicsitem.h:92
GraphicsViewAdapter * getGraphicsView()
Getter for mGraphicsView.
Definition: graphicsitem.h:122