8 #ifndef __VRV_EDITOR_TOOLKIT_NEUME_H__
9 #define __VRV_EDITOR_TOOLKIT_NEUME_H__
18 #include "editortoolkit.h"
43 bool AddSyl(std::string elementId, std::string sylText);
44 bool Chain(jsonxx::Array actions);
45 bool DisplaceClefOctave(std::string elementId, std::string direction);
46 bool Drag(std::string elementId,
int x,
int y,
bool topLevel =
true);
47 bool Insert(std::string elementType, std::string staffId,
int ulx,
int uly,
int lrx,
int lry,
48 std::vector<std::pair<std::string, std::string>> attributes);
49 bool InsertToSyllable(std::string elementId);
50 bool MatchHeight(std::string elementId);
51 bool Merge(std::vector<std::string> elementIds);
52 bool MoveOutsideSyllable(std::string elementId);
53 bool Set(std::string elementId, std::string attrType, std::string attrValue);
54 bool SetText(std::string elementId,
const std::string &text);
55 bool SetClef(std::string elementId, std::string shape);
56 bool SetLiquescent(std::string elementId, std::string shape);
57 bool SetAquitanianElement(std::string elementId, std::string shape);
59 bool Split(std::string elementId,
int x);
60 bool SplitNeume(std::string elementId, std::string ncId);
61 bool Remove(std::string elementId);
62 bool Resize(std::string elementId,
int ulx,
int uly,
int lrx,
int lry,
float resize = NAN);
63 bool Group(std::string groupType, std::vector<std::string> elementIds);
64 void UnlinkSyllable(
Syllable *syllable);
65 bool Ungroup(std::string groupType, std::vector<std::string> elementIds);
66 bool ChangeGroup(std::string elementId, std::string contour);
67 bool ToggleLigature(std::vector<std::string> elementIds);
68 bool ChangeStaff(std::string elementId);
69 bool ChangeStaffTo(std::string elementId, std::string staffId);
70 bool ClefMovementHandler(
Clef *clef,
int x,
int y);
78 bool ParseDisplaceClefAction(jsonxx::Object param, std::string *elementId, std::string *direction);
79 bool ParseDragAction(jsonxx::Object param, std::string *elementId,
int *x,
int *y);
80 bool ParseInsertAction(jsonxx::Object param, std::string *elementType, std::string *startId, std::string *endId);
81 bool ParseInsertAction(jsonxx::Object param, std::string *elementType, std::string *staffId,
int *ulx,
int *uly,
82 int *lrx,
int *lry, std::vector<std::pair<std::string, std::string>> *attributes);
83 bool ParseInsertToSyllableAction(jsonxx::Object param, std::string *elementId);
84 bool ParseMatchHeightAction(jsonxx::Object param, std::string *elementId);
85 bool ParseMergeAction(jsonxx::Object param, std::vector<std::string> *elementIds);
86 bool ParseMoveOutsideSyllableAction(jsonxx::Object param, std::string *elementId);
87 bool ParseSetAction(jsonxx::Object param, std::string *elementId, std::string *attrType, std::string *attrValue);
88 bool ParseSetTextAction(jsonxx::Object param, std::string *elementId, std::string *text);
89 bool ParseSetClefAction(jsonxx::Object param, std::string *elementId, std::string *shape);
90 bool ParseSetLiquescentAction(jsonxx::Object param, std::string *elementId, std::string *shape);
91 bool ParseSetAquitanianElementAction(jsonxx::Object param, std::string *elementId, std::string *shape);
92 bool ParseSplitAction(jsonxx::Object param, std::string *elementId,
int *x);
93 bool ParseSplitNeumeAction(jsonxx::Object param, std::string *elementId, std::string *ncId);
94 bool ParseRemoveAction(jsonxx::Object param, std::string *elementId);
95 bool ParseResizeAction(jsonxx::Object param, std::string *elementId,
int *ulx,
int *uly,
int *lrx,
int *lry);
96 bool ParseResizeRotateAction(
97 jsonxx::Object param, std::string *elementId,
int *ulx,
int *uly,
int *lrx,
int *lry,
float *rotate);
98 bool ParseGroupAction(jsonxx::Object param, std::string *groupType, std::vector<std::string> *elementIds);
99 bool ParseUngroupAction(jsonxx::Object param, std::string *groupType, std::vector<std::string> *elementIds);
100 bool ParseChangeGroupAction(jsonxx::Object param, std::string *elementId, std::string *contour);
101 bool ParseToggleLigatureAction(jsonxx::Object param, std::vector<std::string> *elementIds);
102 bool ParseChangeStaffAction(jsonxx::Object param, std::string *elementId);
103 bool ParseChangeStaffToAction(jsonxx::Object param, std::string *elementId, std::string *staffId);
111 bool AdjustPitchFromPosition(
Object *obj);
112 bool AdjustClefLineFromPosition(
Clef *clef,
Staff *staff = NULL);
126 int distanceToBB(
int ulx,
int uly,
int lrx,
int lry,
double rotate = 0)
128 int offset = (x - ulx) * tan(rotate * M_PI / 180.0);
131 int xDiff = std::max((ulx > x ? ulx - x : 0), (x > lrx ? x - lrx : 0));
132 int yDiff = std::max((uly > y ? uly - y : 0), (y > lry ? y - lry : 0));
134 return sqrt(xDiff * xDiff + yDiff * yDiff);
139 if (!a->GetFacsimileInterface() || !b->GetFacsimileInterface())
return true;
140 Zone *zoneA = a->GetFacsimileInterface()->
GetZone();
141 Zone *zoneB = b->GetFacsimileInterface()->
GetZone();
143 int distA = distanceToBB(zoneA->GetUlx(), zoneA->GetUly(), zoneA->GetLrx(), zoneA->GetLry(),
144 zoneA->HasRotate() ? zoneA->GetRotate() : 0);
145 int distB = distanceToBB(zoneB->GetUlx(), zoneB->GetUly(), zoneB->GetLrx(), zoneB->GetLry(),
146 zoneB->HasRotate() ? zoneB->GetRotate() : 0);
147 return (distA < distB);
160 if (!a->GetFirst(NC)) {
161 LogError(
"Neume %s doesn't have neume components.", a->GetID().c_str());
164 if (!b->GetFirst(NC)) {
165 LogError(
"Neume %s doesn't have neume components.", b->GetID().c_str());
168 if (!a->GetFirst(NC)->GetFacsimileInterface()) {
169 LogError(
"Neume component %s doesn't have facsimile.", a->GetFirst(NC)->GetID().c_str());
172 if (!b->GetFirst(NC)->GetFacsimileInterface()) {
173 LogError(
"Neume component %s doesn't have facsimile.", b->GetFirst(NC)->GetID().c_str());
176 Zone *zoneA = a->GetFirst(NC)->GetFacsimileInterface()->
GetZone();
177 Zone *zoneB = b->GetFirst(NC)->GetFacsimileInterface()->
GetZone();
179 int distA = std::abs(x - zoneA->GetUlx());
180 int distB = std::abs(x - zoneB->GetUlx());
182 return (distA < distB);
199 if (!a->Is(SYSTEM) || !b->Is(SYSTEM))
return false;
211 if (staffA->HasType() && staffB->HasType()) {
213 std::string typeA = staffA->GetType();
214 std::string typeB = staffB->GetType();
216 if (staffA->GetType().find(
"column") == 0 && staffB->GetType().find(
"column") == 0) {
217 int columnA = std::stoi(typeA.substr(6));
218 int columnB = std::stoi(typeB.substr(6));
219 if (columnA != columnB) {
220 return columnA < columnB;
226 Zone *zoneA = staffA->GetFacsimileInterface()->
GetZone();
227 Zone *zoneB = staffB->GetFacsimileInterface()->
GetZone();
231 int aLowest, bLowest, aHighest, bHighest;
233 aLowest = zoneA->GetRotate() < 0
235 : zoneA->GetLry() + (zoneA->GetLrx() - zoneA->GetUlx()) * tan(zoneA->GetRotate() * M_PI / 180.0);
237 aHighest = zoneA->GetRotate() < 0
239 : zoneA->GetUly() - (zoneA->GetLrx() - zoneA->GetUlx()) * tan(zoneA->GetRotate() * M_PI / 180.0);
241 bLowest = zoneB->GetRotate() < 0
243 : zoneB->GetLry() + (zoneB->GetLrx() - zoneB->GetUlx()) * tan(zoneB->GetRotate() * M_PI / 180.0);
245 bHighest = zoneB->GetRotate() < 0
247 : zoneB->GetUly() - (zoneB->GetLrx() - zoneB->GetUlx()) * tan(zoneB->GetRotate() * M_PI / 180.0);
252 if (((aLowest <= bLowest && aLowest >= bHighest) || (aHighest <= bLowest && aHighest >= bHighest)
253 || (bLowest <= aLowest && bLowest >= aHighest) || (bHighest <= aLowest && bHighest >= aHighest))
254 && (zoneA->GetLrx() - zoneB->GetUlx() <= 0.5 * (zoneA->GetLrx() - zoneA->GetUlx()))) {
256 return (zoneA->GetUlx() < zoneB->GetUlx());
259 return (zoneA->GetUly() < zoneB->GetUly());
This class models the MEI <clef> element.
Definition: clef.h:39
This class is a hold the data and corresponds to the model of a MVC design pattern.
Definition: doc.h:41
Zone * GetZone()
Get the zone.
Definition: facsimileinterface.h:58
This class represents a measure in a page-based score (Doc).
Definition: measure.h:46
bool IsNeumeLine() const
Return true if the measure represents a neume (section) line.
Definition: measure.h:87
This class represents a basic object.
Definition: object.h:62
Object * FindDescendantByType(ClassId classId, int deepness=UNLIMITED_DEPTH, bool direction=FORWARD)
Look for a descendant with the specified type (returns NULL if not found) This method is a wrapper fo...
This class represents a staff in a laid-out score (Doc).
Definition: staff.h:107
This class models the MEI <mensur> element.
Definition: syllable.h:25
This class is a drawing context and corresponds to the view of a MVC design pattern.
Definition: view.h:106
Implements the zone element in MEI.
Definition: zone.h:30
Definition: editortoolkit_neume.h:122
Definition: editortoolkit_neume.h:153
Definition: editortoolkit_neume.h:188