GUIDOLib  1.7.7
Guido Engine Internal Documentation
GObject.h
1 #ifndef GObject_H
2 #define GObject_H
3 
4 /*
5  GUIDO Library
6  Copyright (C) 2002 Holger Hoos, Juergen Kilian, Kai Renz
7  Copyright (C) 2002-2017 Grame
8 
9  This Source Code Form is subject to the terms of the Mozilla Public
10  License, v. 2.0. If a copy of the MPL was not distributed with this
11  file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 
13  Grame Research Laboratory, 11, cours de Verdun Gensoul 69002 Lyon - France
14  research@grame.fr
15 
16 */
17 
18 #include <map>
19 
20 #include "NVPoint.h"
21 #include "NVRect.h"
22 #include "MusicalSymbols.h"
23 #include "GUIDOScoreMap.h"
24 #include "GuidoDefs.h"
25 #include "defines.h"
26 
27 class NVstring;
28 class VGDevice;
29 class VGColor;
30 
31 enum GDirection // was STEMDIR
32 {
33  dirOFF = 0,
34  dirUP = 1,
35  dirDOWN = -1,
36  dirAUTO = 10
37 };
38 
39 
42 class MapInfos
43 {
44  public:
47 
48  MapInfos() : fPos(0,0), fScale(1,1) {}
49  virtual ~MapInfos() {}
50 };
51 
54 class GObject
55 {
56  public:
57  virtual ~GObject() {}
58 
59  virtual void addToOffset(const NVPoint &) { }
60 
61  virtual const NVPoint & getOffset() const { return sRefposNone; }
62  virtual const char * getFont() const { return 0; }
63  virtual const char * getFontAttrib() const { return 0; }
64  virtual const unsigned char * getColRef() const { return 0; }
65 
66  virtual int getFontSize() const { return (int)(1.5f * LSPACE); } // default
67  virtual float getSize() const { return 1.0f; }
68 
76  virtual const NVPoint & getReferencePosition() const { return sRefposNone; }
77 
78  virtual void setPosition( const NVPoint & pos ) { mPosition = pos; }
79  virtual void setHPosition( float nx ) { mPosition.x = nx; }
80  const NVPoint & getPosition() const { return mPosition; }
81  virtual void tellPosition( GObject * caller, const NVPoint & newPosition );
82 
83  // it could be, that we do not need this ...
84  // we should have a bounding-polygon instead
85  // ((JB) or many rectangles)
86  const NVRect & getBoundingBox() const { return mBoundingBox; }
87  void addToBoundingBox( const NVRect & in );
88 
89  // this is not constant! Can be changed!
91 
92  virtual bool isGREventClass() const { return false; }
93 
94  virtual void OnDraw( VGDevice & hdc ) const = 0;
95  virtual void GetMap( GuidoElementSelector sel, MapCollector& f, MapInfos& infos) const {};
96  virtual void DrawBoundingBox( VGDevice & hdc, const VGColor & inBrushColor ) const; // debug
97 
98  static bool positionIsOnStaffLine( float inPositionY, float inLSpace );
99  static float GetSymbolExtent( unsigned int inSymbol );
100 
101  protected:
105 
106  // this is an abstract base class. No direct initialization.
107  GObject() {}
108  GObject( const GObject & in );
109 
110  static std::map<ConstMusicalSymbolID, float> sSymbolExtentMap;
112 };
113 
114 #endif
GObject::GObject
GObject()
Definition: GObject.h:107
GObject::addToBoundingBox
void addToBoundingBox(const NVRect &in)
MapCollector
an abstract class to be provided by clients to collect mappings
Definition: GUIDOScoreMap.h:109
MapInfos::fPos
NVPoint fPos
Definition: GObject.h:45
GObject::getFont
virtual const char * getFont() const
Definition: GObject.h:62
MapInfos::fScale
NVPoint fScale
Definition: GObject.h:46
GObject
The base class for all graphic objects.
Definition: GObject.h:54
NVPoint::x
float x
Definition: NVPoint.h:68
GObject::getFontAttrib
virtual const char * getFontAttrib() const
Definition: GObject.h:63
GObject::isGREventClass
virtual bool isGREventClass() const
Definition: GObject.h:92
GObject::DrawBoundingBox
virtual void DrawBoundingBox(VGDevice &hdc, const VGColor &inBrushColor) const
GObject::getColRef
virtual const unsigned char * getColRef() const
Definition: GObject.h:64
MapInfos::MapInfos
MapInfos()
Definition: GObject.h:48
NVPoint
Definition: NVPoint.h:20
GObject::getBoundingBox
const NVRect & getBoundingBox() const
Definition: GObject.h:86
MapInfos::~MapInfos
virtual ~MapInfos()
Definition: GObject.h:49
MapInfos
A class to propagate device related information.
Definition: GObject.h:42
GObject::getReferenceBoundingBox
NVRect & getReferenceBoundingBox()
Definition: GObject.h:90
GObject::~GObject
virtual ~GObject()
Definition: GObject.h:57
GObject::setHPosition
virtual void setHPosition(float nx)
Definition: GObject.h:79
VGDevice
Generic platform independant drawing device.
Definition: VGDevice.h:68
VGColor
Generic class to manipulate device independant colors.
Definition: VGColor.h:34
GObject::GetSymbolExtent
static float GetSymbolExtent(unsigned int inSymbol)
GObject::positionIsOnStaffLine
static bool positionIsOnStaffLine(float inPositionY, float inLSpace)
GObject::sSymbolExtentMap
static std::map< ConstMusicalSymbolID, float > sSymbolExtentMap
Definition: GObject.h:110
GObject::addToOffset
virtual void addToOffset(const NVPoint &)
Definition: GObject.h:59
GObject::setPosition
virtual void setPosition(const NVPoint &pos)
Definition: GObject.h:78
NVstring
Definition: nvstring.h:21
GObject::sRefposNone
static NVPoint sRefposNone
Definition: GObject.h:111
NVRect
Definition: NVRect.h:22
GObject::mPosition
NVPoint mPosition
Definition: GObject.h:102
GObject::getPosition
const NVPoint & getPosition() const
Definition: GObject.h:80
GObject::mMapping
NVRect mMapping
Definition: GObject.h:104
GuidoElementSelector
GuidoElementSelector
Definition: GUIDOScoreMap.h:40
GObject::mBoundingBox
NVRect mBoundingBox
Definition: GObject.h:103
GObject::tellPosition
virtual void tellPosition(GObject *caller, const NVPoint &newPosition)
GObject::getOffset
virtual const NVPoint & getOffset() const
Definition: GObject.h:61
GObject::getSize
virtual float getSize() const
Definition: GObject.h:67
GObject::getReferencePosition
virtual const NVPoint & getReferencePosition() const
Retrieves the Symbol-reference-position with respect to the GUIDO-reference-position.
Definition: GObject.h:76
GObject::OnDraw
virtual void OnDraw(VGDevice &hdc) const =0
GObject::GetMap
virtual void GetMap(GuidoElementSelector sel, MapCollector &f, MapInfos &infos) const
Definition: GObject.h:95
GObject::getFontSize
virtual int getFontSize() const
Definition: GObject.h:66

Guido Project Copyright © 2019 Grame-CNCM