GUIDOLib  1.7.7
Guido Engine Internal Documentation
GRSpring.h
1 #ifndef GRSpring_H
2 #define GRSpring_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 <typeinfo>
19 #include <iostream>
20 
21 #include "kf_ilist.h"
22 #include "GRNotationElement.h"
23 #include "GRVoice.h"
24 
25 typedef KF_IPointerList<GRNotationElement> GROList; // TODO: replace by std::vector (easy)
26 typedef KF_IPointerList<GRVoice> GRVList;// TODO: replace by std::vector (easy)
27 
28 class GRRod;
29 class GRSystem;
30 class GRStaff;
31 
33 class GRSpringCollider;
34 
35 
38 class GRSpring
39 {
40  friend class GRSpaceForceFunction2;
41  friend class GRRod;
42  friend class GRSystem;
43 public:
44 
45  GRSpring(const TYPE_TIMEPOSITION & vtp, const TYPE_DURATION & vdur, float spring, float propRender);
46  GRSpring( GRNotationElement *, GRVoice *, float spring, float propRender );
47 
48  virtual ~GRSpring();
49 
50  void OnDraw( VGDevice & hdc ) const;
51  bool containsBar() const;
52 
53  // A routine to check local collisions
54  void checkLocalCollisions ();
55 
56  // this routine looks at the GRSpringCollider of this instance of GRSpring and
57  // at the GRSpringCollider of nextspring.
58  // It finds matching poslists and returns the maximum needed distance ...
59  float GetMaxDistance(GRSpring * nextspring);
60 
61  float stretchWithForce(float newforce);
62  bool hasStaffAndType(const GRStaff * grstaff, const std::type_info & ti);
63  float set_const(float dc);
64  float recalcConstant();
65  void addElement(GRNotationElement * el,GRVoice * vce);
66  bool hasType(const std::type_info & ti);
67  bool hasGraceNote();
68  void setNoExtent();
70  int setGRPositionX(float p_posx);
71  void setGRSpringID();
72 
73  float getExtent() const { return fX; }
74  void setID(int _id);
75  int getID() const;
76  float getForce() const { return fForce; }
77  float getConstant() const { return fSconst; }
78 
79  virtual const GRNotationElement * getFirstGRO() const;
80  virtual GuidoPos getFirstGROPosition();
81  virtual const GRNotationElement * getNextGRO(GuidoPos & pos) const;
82  virtual float apply_force(float df);
83  virtual float change_x(float dx);
84  virtual float change_force(float df);
85  virtual float change_const(float dc);
86  virtual float change_dur(const TYPE_DURATION & ndur );
87  virtual float setlength(float dx);
88 
89 
90  virtual const TYPE_DURATION & getTimePosition() const { return fTp; }
91  virtual const TYPE_DURATION & getDuration() const { return fDur; }
92 
93  int operator<(const GRSpring & spr) const;
94 
95 
96  static float defconst(const TYPE_DURATION &, float spring);
97  static float defconst(float dur, float spring );
98 
99  int isCommonSpring(int numvoices) const;
100 
101  // this flag is set to true, if the spring really has an element of its duration
102  // this helps in spacing-issues.
103  // (if the spring has no element of this type the average building process during the neighbourhoodcheck is made easier)
105 
107  float fPosx; // (JB) was int
108 
109  float setProportionalForce();
110  void print(std::ostream& out) const;
111 
112 protected:
113  float calcconst(GRNotationElement * grn);
116  int fId; // a definite ID
117 
119  float fFuncpar;
121 
122 private:
123  float fForce;
124  float fX;
125  float fSconst; // spring-constants
126  bool fIsProportionalElement;
127 
128  // a routine to check the accidental-collisions ...
129  void checkAccidentalCollisions();
130 
131  // A list of GObjects, that this spring includes
132  GROList fGrolst; //
133  GRVList fGrvlst;
134 };
135 
136 int sprcomp(const GRSpring &gr1,const GRSpring &gr2);
137 int sprpcomp(const GRSpring *gr1,const GRSpring *gr2);
138 
139 inline std::ostream & operator << ( std::ostream & os, const GRSpring* spr ) { spr->print(os); return os; }
140 
141 
142 #endif
GRSpring::getFirstGRO
virtual const GRNotationElement * getFirstGRO() const
GRSpring::containsBar
bool containsBar() const
GRSpring::setGRSpringID
void setGRSpringID()
GRSpring::removeElement
int removeElement(GRNotationElement *el)
GRSpring::getNextGRO
virtual const GRNotationElement * getNextGRO(GuidoPos &pos) const
GRSpring::getID
int getID() const
GRSpring::defconst
static float defconst(const TYPE_DURATION &, float spring)
GRSpring::fPosx
float fPosx
Definition: GRSpring.h:107
GRSpring
Used with rods and space fore functions.
Definition: GRSpring.h:38
GRSpring::getFirstGROPosition
virtual GuidoPos getFirstGROPosition()
GRSpringCollider
not yet documented
Definition: GRSpringCollider.h:35
GRSpring::GRSpring
GRSpring(const TYPE_TIMEPOSITION &vtp, const TYPE_DURATION &vdur, float spring, float propRender)
Fraction
Numerator and denominator.
Definition: Fraction.h:23
GRSpring::stretchWithForce
float stretchWithForce(float newforce)
GRSpring::calcconst
float calcconst(GRNotationElement *grn)
GRSpring::fProportionalRendering
float fProportionalRendering
Definition: GRSpring.h:120
GRSpring::getForce
float getForce() const
Definition: GRSpring.h:76
GRSpring::fHasDurElement
bool fHasDurElement
Definition: GRSpring.h:104
GRNotationElement
parent class for all notation elements.
Definition: GRNotationElement.h:54
GRSpring::change_dur
virtual float change_dur(const TYPE_DURATION &ndur)
GRSpring::set_const
float set_const(float dc)
GRRod
Used with springs and space-force functions.
Definition: GRRod.h:33
GRSpring::getConstant
float getConstant() const
Definition: GRSpring.h:77
GRSpring::GetMaxDistance
float GetMaxDistance(GRSpring *nextspring)
GRSpring::hasType
bool hasType(const std::type_info &ti)
GRSpring::OnDraw
void OnDraw(VGDevice &hdc) const
GRSpring::setNoExtent
void setNoExtent()
GRSpring::fSprcol
GRSpringCollider * fSprcol
Definition: GRSpring.h:118
GRSpring::isCommonSpring
int isCommonSpring(int numvoices) const
GRSpring::getDuration
virtual const TYPE_DURATION & getDuration() const
Definition: GRSpring.h:91
GRSpring::operator<
int operator<(const GRSpring &spr) const
GRStaff
A GRStaff represents a single line of music.
Definition: GRStaff.h:181
GRSpring::getTimePosition
virtual const TYPE_DURATION & getTimePosition() const
Definition: GRSpring.h:90
KF_IPointerList< GRNotationElement >
GRSpring::fIsfrozen
int fIsfrozen
Definition: GRSpring.h:106
GRSpring::checkLocalCollisions
void checkLocalCollisions()
GRSpring::print
void print(std::ostream &out) const
GRSpaceForceFunction2
This class realizes the second implementation of the space-force-function.
Definition: GRSpringForceIndex.h:99
GRSpring::fTp
TYPE_TIMEPOSITION fTp
Definition: GRSpring.h:114
GRSpring::setID
void setID(int _id)
GRVoice
Graphical representation of a voice.
Definition: GRVoice.h:49
GRSpring::setGRPositionX
int setGRPositionX(float p_posx)
VGDevice
Generic platform independant drawing device.
Definition: VGDevice.h:68
GRSpring::setProportionalForce
float setProportionalForce()
GRSpring::change_const
virtual float change_const(float dc)
GRSpring::recalcConstant
float recalcConstant()
GRSpring::hasGraceNote
bool hasGraceNote()
GRSpring::getExtent
float getExtent() const
Definition: GRSpring.h:73
GRSpring::change_x
virtual float change_x(float dx)
GRSpring::fId
int fId
Definition: GRSpring.h:116
GRSpring::setlength
virtual float setlength(float dx)
GRSpring::fDur
TYPE_DURATION fDur
Definition: GRSpring.h:115
GRSystem
Manages a number of staffs and has a given start and end timeposition. GRSystem is the grafical repre...
Definition: GRSystem.h:52
GRSpring::apply_force
virtual float apply_force(float df)
operator<<
std::ostream & operator<<(std::ostream &os, const svgendl &eol)
GRSpring::fFuncpar
float fFuncpar
Definition: GRSpring.h:119
GRSpring::change_force
virtual float change_force(float df)
GRSpring::hasStaffAndType
bool hasStaffAndType(const GRStaff *grstaff, const std::type_info &ti)
GRSpring::addElement
void addElement(GRNotationElement *el, GRVoice *vce)
GRSpring::~GRSpring
virtual ~GRSpring()

Guido Project Copyright © 2019 Grame-CNCM