1
//--------------------------------------------------------------------------------------
2
// LenMus Phonascus: The teacher of music
3
// Copyright (c) 2002-2010 LenMus project
5
// This program is free software; you can redistribute it and/or modify it under the
6
// terms of the GNU General Public License as published by the Free Software Foundation,
7
// either version 3 of the License, or (at your option) any later version.
9
// This program is distributed in the hope that it will be useful, but WITHOUT ANY
10
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11
// PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
// You should have received a copy of the GNU General Public License along with this
14
// program. If not, see <http://www.gnu.org/licenses/>.
16
// For any comment, suggestion or feature request, please contact the manager of
17
// the project at cecilios@users.sourceforge.net
19
//-------------------------------------------------------------------------------------
21
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
22
#pragma implementation "ScoreCommand.h"
25
// For compilers that support precompilation, includes <wx/wx.h>.
26
#include <wx/wxprec.h>
36
#include "../score/Score.h"
37
#include "../score/VStaff.h"
38
#include "../score/Instrument.h"
39
#include "../score/properties/DlgProperties.h"
40
#include "ScoreCommand.h"
43
#include "../graphic/GMObject.h"
44
#include "../graphic/ShapeArch.h"
45
#include "../graphic/ShapeBeam.h"
46
#include "../graphic/ShapeText.h"
47
#include "../app/Preferences.h"
48
#include "../ldp_parser/LDPParser.h"
49
#include "Processor.h"
52
#include "../app/Logger.h"
53
extern lmLogger* g_pLogger;
57
//----------------------------------------------------------------------------------------
58
// lmScoreCommand abstract class implementation
60
// Do() method will return true to indicate that the action has taken place, false
61
// otherwise. Returning false will indicate to the command processor that the action is
62
// not undoable and should not be added to the command history.
66
// true - Normal command. The command will be logged in the undo/redo chain and,
67
// if applicable, the score will be saved for undo.
68
// false - Hidden command. The command is executed but the command will not be
69
// added to the command history and, if applicable, the score will not
70
// be saved for undo. After command execution the screen is not updated.
71
// This option is usefull for building commands by chaining other
72
// commnads. The main command will be undoable and all atomic commands
73
// will not. See, for example, lmCmdDeleteSelection.
76
// true - the score is relayouted and the screen updated
77
// false - the score is not relayouted. Screen is updated just by rendering the
78
// existing boxes/shapes. This option is useful for commands that do
79
// not affect score layout. For instance, changing the color of an object.
80
//----------------------------------------------------------------------------------------
83
IMPLEMENT_ABSTRACT_CLASS(lmScoreCommand, wxCommand)
85
lmScoreCommand::lmScoreCommand(const wxString& sName, lmDocument *pDoc,
86
bool fNormalCmd, bool fDoLayout)
87
: wxCommand(true, sName)
89
, m_fDocModified(false)
90
, m_fUndoable(fNormalCmd)
91
, m_fDoLayout(fDoLayout)
92
, m_CursorState(pDoc->GetScore()->GetCursor()->GetState())
96
lmScoreCommand::~lmScoreCommand()
100
void lmScoreCommand::PrepareForRedo()
102
//move cursor to original position when the command was issued. This position
103
//was saved in m_CursorState.
104
//Then, save data for undoing the command.
112
//get score and save source code
113
m_sOldSource = m_pDoc->GetScore()->SourceLDP(true); //true: export cursor
114
LogForensicData(); //save data for forensic analysis if a crash
117
void lmScoreCommand::RestoreCursor()
119
//reposition cursor at saved state
121
m_pDoc->GetScore()->GetCursor()->SetState(&m_CursorState);
124
lmVStaff* lmScoreCommand::GetVStaff()
126
return m_pDoc->GetScore()->GetCursor()->GetVStaff();
129
lmScoreObj* lmScoreCommand::GetScoreObj(long nID)
131
return m_pDoc->GetScore()->GetScoreObj(nID);
134
bool lmScoreCommand::Undo()
136
//Default implementation: Restore previous state from LDP source code
137
//Returns true to indicate that the action has taken place, false otherwise.
138
//Returning false will indicate to the command processor that the action is
139
//not redoable and no change should be made to the command history.
141
//recover old score and cursor state (it is saved in the score)
143
lmScore* pScore = parser.ParseScoreFromText(m_sOldSource);
150
//ask document to replace current score by the old one
151
pScore->ResetUndoMode();
152
m_pDoc->ReplaceScore(pScore);
153
return true; //undo action has taken place
156
bool lmScoreCommand::CommandDone(bool fCmdSuccess, int nUpdateHints)
158
//common code after executing a command:
159
//- save document current modification status flag, to restore it if command undo
160
//- set document as 'modified'
161
//- update the views with the changes
163
// Returns false to indicate that the action must not be added to the
166
//if failure or hidden command, return 'false', meaning "Do not add this
167
//command to command history, and do not update views"
168
if (!fCmdSuccess || !m_fUndoable)
171
////DBG ---------------------------------------------
172
//wxLogMessage(_T("[lmScoreCommand::CommandDone] Dump of new score follows:"));
173
//wxLogMessage( m_pDoc->GetScore()->Dump() );
174
//wxLogMessage( m_pDoc->GetScore()->SourceLDP(true) );
175
//wxMessageBox(_T("[lmScoreCommand::CommandDone] Dump completed."));
176
////END DBG -----------------------------------------
178
//success. mark document as 'modified'
179
m_fDocModified = m_pDoc->IsModified();
180
m_pDoc->Modify(true);
184
nUpdateHints |= lmHINT_NO_LAYOUT;
185
m_pDoc->UpdateAllViews((wxView*)NULL, new lmUpdateHint(nUpdateHints));
187
return true; //success. Add command to command history
190
bool lmScoreCommand::CommandUndone(int nUpdateHints)
192
//common code after executing an Undo operation:
193
//- reset document to previous 'modified' state
194
//- update the views with the changes
196
//Returns true to indicate that the action has taken place, false otherwise.
197
//Returning false will indicate to the command processor that the action is
198
//not redoable and no change should be made to the command history.
202
m_pDoc->Modify(true); //set modified, so that the score is repainted
203
m_pDoc->UpdateAllViews((wxView*)NULL, new lmUpdateHint(nUpdateHints));
205
m_pDoc->Modify(m_fDocModified); //restore modified state
209
void lmScoreCommand::LogForensicData()
211
//save data for forensic analysis if a crash
213
g_pLogger->FlushForensicLog();
214
g_pLogger->LogForensic(
215
wxString::Format(_T("Command class: %s, Command name: '%s'"),
216
this->GetClassInfo()->GetClassName(),
217
this->GetName().c_str()
219
g_pLogger->LogScore(m_sOldSource);
223
//----------------------------------------------------------------------------------------
224
// lmCmdDeleteSelection implementation
225
//----------------------------------------------------------------------------------------
227
IMPLEMENT_CLASS(lmCmdDeleteSelection, lmScoreCommand)
229
lmCmdDeleteSelection::lmCmdDeleteSelection(bool fNormalCmd,
230
const wxString& sName,
232
lmGMSelection* pSelection)
233
: lmScoreCommand(sName, pDoc, fNormalCmd)
235
//loop to get affected ScoreObjs and add their ID to the ignore set
236
lmScoreCursor* pScoreCursor = m_pDoc->GetScore()->GetCursor();
237
lmGMObject* pGMO = pSelection->GetFirst();
240
lmScoreObj* pSCO = pGMO->GetScoreOwner(); //get affected ScoreObj
241
//For secondary & prolog shapes the StaffObj is not deleted
242
if (pGMO->IsMainShape())
244
bool fDelete = true; //default: delete this ScoreObj
245
if (pSCO->IsBarline() || pSCO->IsClef() || pSCO->IsKeySignature()
246
|| pSCO->IsTimeSignature())
248
//barlines, clefs, keys and time signatures will be deleted later.
249
//Move cursor to point barline to delete and create command to delete barline
251
pScoreCursor->MoveCursorToObject((lmStaffObj*)pSCO);
252
wxString sName = _T("Delete object");
253
if (pSCO->IsBarline())
254
sName = _T("Delete barline");
255
else if (pSCO->IsClef())
256
sName = _T("Delete clef");
257
else if (pSCO->IsKeySignature())
258
sName = _T("Delete key signature");
259
else if (pSCO->IsTimeSignature())
260
sName = _T("Delete time signature");
261
lmScoreCommand* pCmd = new lmCmdDeleteStaffObj(lmCMD_HIDDEN, sName, pDoc,
263
m_Commands.push_back( pCmd );
265
else if (pSCO->IsStaff() || pSCO->IsVStaff())
267
fDelete = false; //staves and VStaves are never deleted
269
else if (pSCO->IsInstrument())
271
//braces/brakes owner is the instrument. Do not delete instrument
272
if (pGMO->IsShapeBracket())
278
m_IgnoreSet.insert(pSCO->GetID());
281
pGMO = pSelection->GetNext();
285
lmCmdDeleteSelection::~lmCmdDeleteSelection()
287
std::list<lmScoreCommand*>::iterator it;
288
for (it = m_Commands.begin(); it != m_Commands.end(); ++it)
292
bool lmCmdDeleteSelection::Do()
294
//reposition cursor and save data for undoing the command
296
std::set<long>::iterator it;
297
for (it = m_IgnoreSet.begin(); it != m_IgnoreSet.end(); ++it)
298
g_pLogger->LogForensic(_T("IgnoreList: %d"), *it);
300
//re-parse the source ignoring objects to delete
301
if (m_IgnoreSet.size() > 0)
304
parser.SetIgnoreList(&m_IgnoreSet);
306
lmScore* pScore = parser.ParseScoreFromText(m_sOldSource);
313
//ask document to replace current score by the new one, but do not update views
314
pScore->ResetUndoMode();
315
m_pDoc->ReplaceScore(pScore, false); //false: do not update views
318
//now issue other delete commnads
319
std::list<lmScoreCommand*>::iterator itC;
320
for (itC = m_Commands.begin(); itC != m_Commands.end(); ++itC)
323
return CommandDone(true, lmHINT_NEW_SCORE);
328
//----------------------------------------------------------------------------------------
329
// lmCmdDeleteStaffObj implementation
330
//----------------------------------------------------------------------------------------
332
IMPLEMENT_CLASS(lmCmdDeleteStaffObj, lmScoreCommand)
334
lmCmdDeleteStaffObj::lmCmdDeleteStaffObj(bool fNormalCmd,
335
const wxString& sName,
336
lmDocument *pDoc, lmStaffObj* pSO, bool fAskUser)
337
: lmScoreCommand(sName, pDoc, fNormalCmd)
338
, m_nObjID(pSO->GetID())
339
, m_nAction(0) //0: Cancel operation
341
//if there are notes affected by clef or key removal, get user desired behaviour
344
if (fAskUser && pSO->GetVStaff()->CheckIfNotesAffectedByDeletingClef())
345
m_nAction = pSO->GetVStaff()->AskUserAboutClef();
347
m_nAction = 1; //keep pitch
349
else if (pSO->IsKeySignature())
351
if (fAskUser && pSO->GetVStaff()->CheckIfNotesAffectedByKey(true)) //true->skip this key
352
m_nAction = pSO->GetVStaff()->AskUserAboutKey();
354
m_nAction = 2; //do nothing. Pitch could change if affected by deleted accidentals
358
bool lmCmdDeleteStaffObj::Do()
360
//reposition cursor and save data for undoing the command
363
//Get pointer to object to delete
364
lmStaffObj* pSO = (lmStaffObj*)GetScoreObj(m_nObjID);
366
//Proceed to delete the object
369
fError = GetVStaff()->Cmd_DeleteClef((lmClef*)pSO, m_nAction);
370
else if (pSO->IsTimeSignature())
371
fError = GetVStaff()->Cmd_DeleteTimeSignature((lmTimeSignature*)pSO);
372
else if (pSO->IsKeySignature())
373
fError = GetVStaff()->Cmd_DeleteKeySignature((lmKeySignature*)pSO, m_nAction);
375
fError = GetVStaff()->Cmd_DeleteStaffObj(pSO);
377
return CommandDone(!fError);
382
//----------------------------------------------------------------------------------------
383
// lmCmdDeleteTie implementation
384
//----------------------------------------------------------------------------------------
386
IMPLEMENT_CLASS(lmCmdDeleteTie, lmScoreCommand)
388
lmCmdDeleteTie::lmCmdDeleteTie(bool fNormalCmd,
389
const wxString& sName, lmDocument *pDoc,
391
: lmScoreCommand(sName, pDoc, fNormalCmd)
393
m_nEndNoteID = pEndNote->GetID();
394
m_nStartNoteID = pEndNote->GetTiedNotePrev()->GetID();
395
lmTie* pTie = pEndNote->GetTiePrev();
396
m_nTieID = pTie->GetID();
397
m_Bezier[0] = pTie->GetBezier(0);
398
m_Bezier[1] = pTie->GetBezier(1);
401
bool lmCmdDeleteTie::Do()
403
//Direct command. NO UNDO LOG
408
//Get pointer to end note
409
lmNote* pEndNote = (lmNote*)GetScoreObj(m_nEndNoteID);
411
pEndNote->DeleteTiePrev();
413
return CommandDone(true);
416
bool lmCmdDeleteTie::Undo()
418
//Get pointers to start and end notes
419
lmNote* pEndNote = (lmNote*)GetScoreObj(m_nEndNoteID);
420
lmNote* pStartNote = (lmNote*)GetScoreObj(m_nStartNoteID);
422
pEndNote->CreateTie(pStartNote, pEndNote, m_nTieID);
423
lmTie* pTie = pStartNote->GetTieNext();
424
pTie->SetBezier(0, &m_Bezier[0]);
425
pTie->SetBezier(1, &m_Bezier[1]);
427
return CommandUndone();
432
//----------------------------------------------------------------------------------------
433
// lmCmdAddTie implementation
434
//----------------------------------------------------------------------------------------
436
IMPLEMENT_CLASS(lmCmdAddTie, lmScoreCommand)
438
lmCmdAddTie::lmCmdAddTie(bool fNormalCmd, const wxString& sName,
439
lmDocument *pDoc, lmNote* pStartNote, lmNote* pEndNote)
440
: lmScoreCommand(sName, pDoc, fNormalCmd)
442
m_nStartNoteID = pStartNote->GetID();
443
m_nEndNoteID = pEndNote->GetID();
446
bool lmCmdAddTie::Do()
448
//Direct command. NO UNDO LOG
453
//Get pointers to start and end notes
454
lmNote* pEndNote = (lmNote*)GetScoreObj(m_nEndNoteID);
455
lmNote* pStartNote = (lmNote*)GetScoreObj(m_nStartNoteID);
458
pEndNote->CreateTie(pStartNote, pEndNote);
460
return CommandDone(true);
463
bool lmCmdAddTie::Undo()
465
//Get pointers to start and end notes
466
lmNote* pEndNote = (lmNote*)GetScoreObj(m_nEndNoteID);
467
lmNote* pStartNote = (lmNote*)GetScoreObj(m_nStartNoteID);
470
pEndNote->DeleteTiePrev();
472
return CommandUndone();
477
//----------------------------------------------------------------------------------------
478
// lmCmdMoveObject implementation
479
//----------------------------------------------------------------------------------------
481
IMPLEMENT_CLASS(lmCmdMoveObject, lmScoreCommand)
483
lmCmdMoveObject::lmCmdMoveObject(bool fNormalCmd,
484
const wxString& sName, lmDocument *pDoc,
485
lmGMObject* pGMO, const lmUPoint& uPos)
486
: lmScoreCommand(sName, pDoc, fNormalCmd)
490
m_tPos.xUnits = lmLUNITS;
491
m_tPos.yUnits = lmLUNITS;
493
lmScoreObj* pSO = pGMO->GetScoreOwner();
494
m_nObjectID = pSO->GetID();
495
m_nShapeIdx = pGMO->GetOwnerIDX();
496
wxASSERT_MSG( pSO, _T("[lmCmdMoveObject::Do] No ScoreObj to move!"));
499
bool lmCmdMoveObject::Do()
501
//Direct command. NO UNDO LOG
506
lmScoreObj* pSO = GetScoreObj(m_nObjectID);
507
m_tOldPos = pSO->SetUserLocation(m_tPos, m_nShapeIdx);
508
return CommandDone(true);
511
bool lmCmdMoveObject::Undo()
513
//Direct command. NO UNDO LOG
515
lmScoreObj* pSO = GetScoreObj(m_nObjectID);
516
pSO->SetUserLocation(m_tOldPos, m_nShapeIdx);
517
return CommandUndone(0);
522
//----------------------------------------------------------------------------------------
523
// lmCmdInsertBarline: Insert a barline at current cursor position
524
//----------------------------------------------------------------------------------------
526
IMPLEMENT_CLASS(lmCmdInsertBarline, lmScoreCommand)
528
lmCmdInsertBarline::lmCmdInsertBarline(bool fNormalCmd,
529
const wxString& sName, lmDocument *pDoc,
531
: lmScoreCommand(sName, pDoc, fNormalCmd)
532
, m_nBarlineType(nType)
536
bool lmCmdInsertBarline::Do()
538
//reposition cursor and save data for undoing the command
542
lmBarline* pBL = GetVStaff()->Cmd_InsertBarline(m_nBarlineType);
544
return CommandDone(pBL != (lmBarline*)NULL);
550
//----------------------------------------------------------------------------------------
551
// lmCmdInsertClef: Insert a clef at current cursor position
552
//----------------------------------------------------------------------------------------
554
IMPLEMENT_CLASS(lmCmdInsertClef, lmScoreCommand)
556
lmCmdInsertClef::lmCmdInsertClef(bool fNormalCmd,
557
const wxString& sName,
558
lmDocument *pDoc, lmEClefType nClefType)
559
: lmScoreCommand(sName, pDoc, fNormalCmd)
560
, m_nClefType(nClefType)
564
bool lmCmdInsertClef::Do()
566
//reposition cursor and save data for undoing the command
570
lmClef* pClef = GetVStaff()->Cmd_InsertClef(m_nClefType);
571
return CommandDone(pClef != (lmClef*)NULL);
576
//----------------------------------------------------------------------------------------
577
// lmCmdInsertFiguredBass: Insert a figured bass symbol at current cursor timepos
578
//----------------------------------------------------------------------------------------
580
IMPLEMENT_CLASS(lmCmdInsertFiguredBass, lmScoreCommand)
582
lmCmdInsertFiguredBass::lmCmdInsertFiguredBass(bool fNormalCmd, lmDocument *pDoc,
584
: lmScoreCommand(_("Insert figured bass"), pDoc, fNormalCmd)
590
bool lmCmdInsertFiguredBass::Do()
592
//reposition cursor and save data for undoing the command
595
//insert the figured bass
596
lmFiguredBass* pFB = GetVStaff()->Cmd_InsertFiguredBass(&m_FBData);
598
//if not redo (first time Do() is invoked), edit the inserted figured bass
599
if (pFB && m_fFirstTime)
601
m_fFirstTime = false;
602
lmDlgProperties dlg((lmController*)NULL);
603
pFB->OnEditProperties(&dlg);
605
if (dlg.ShowModal() == wxID_OK)
607
//save the new figured bass data, for redo
608
m_FBData.CopyDataFrom( (lmFiguredBassData*)pFB );
612
//user has cancelled insertion. Remove object
613
GetVStaff()->Cmd_DeleteStaffObj(pFB);
617
//pFB->GetScore()->Dump(_T("dump.txt"));
618
return CommandDone(pFB != (lmFiguredBass*)NULL);
623
//----------------------------------------------------------------------------------------
624
// lmCmdInsertFBLine: Insert a figured bass line at current cursor timepos
625
//----------------------------------------------------------------------------------------
627
IMPLEMENT_CLASS(lmCmdInsertFBLine, lmScoreCommand)
629
lmCmdInsertFBLine::lmCmdInsertFBLine(bool fNormalCmd, lmDocument *pDoc)
630
: lmScoreCommand(_("Insert figured bass"), pDoc, fNormalCmd)
634
bool lmCmdInsertFBLine::Do()
636
//reposition cursor and save data for undoing the command
639
//insert the figured bass line
640
lmFiguredBassLine* pFBL = GetVStaff()->Cmd_InsertFBLine();
642
//pFB->GetScore()->Dump(_T("dump.txt"));
643
return CommandDone(pFBL != (lmFiguredBassLine*)NULL);
648
//----------------------------------------------------------------------------------------
649
// lmCmdInsertTimeSignature: Insert a time signature at current cursor position
650
//----------------------------------------------------------------------------------------
652
IMPLEMENT_CLASS(lmCmdInsertTimeSignature, lmScoreCommand)
654
lmCmdInsertTimeSignature::lmCmdInsertTimeSignature(bool fNormalCmd,
655
const wxString& sName,
656
lmDocument *pDoc, int nBeats,
657
int nBeatType, bool fVisible)
658
: lmScoreCommand(sName, pDoc, fNormalCmd)
660
, m_nBeatType(nBeatType)
661
, m_fVisible(fVisible)
665
bool lmCmdInsertTimeSignature::Do()
667
//reposition cursor and save data for undoing the command
671
lmTimeSignature* pTS = GetVStaff()
672
->Cmd_InsertTimeSignature(m_nBeats, m_nBeatType, m_fVisible);
673
return CommandDone(pTS != (lmTimeSignature*)NULL);
678
//----------------------------------------------------------------------------------------
679
// lmCmdInsertKeySignature: Insert a key signature at current cursor position
680
//----------------------------------------------------------------------------------------
682
IMPLEMENT_CLASS(lmCmdInsertKeySignature, lmScoreCommand)
684
lmCmdInsertKeySignature::lmCmdInsertKeySignature(bool fNormalCmd,
685
const wxString& sName,
686
lmDocument *pDoc, int nFifths, bool fMajor,
688
: lmScoreCommand(sName, pDoc, fNormalCmd)
691
, m_fVisible(fVisible)
695
bool lmCmdInsertKeySignature::Do()
697
//reposition cursor and save data for undoing the command
701
lmKeySignature* pKey = GetVStaff()->Cmd_InsertKeySignature(m_nFifths, m_fMajor, m_fVisible);
702
return CommandDone(pKey != (lmKeySignature*)NULL);
707
//----------------------------------------------------------------------------------------
708
// lmCmdInsertNote: Insert a note at current cursor position
709
//----------------------------------------------------------------------------------------
711
IMPLEMENT_CLASS(lmCmdInsertNote, lmScoreCommand)
713
lmCmdInsertNote::lmCmdInsertNote(bool fNormalCmd,
714
const wxString& sName,
716
lmEPitchType nPitchType,
717
int nStep, int nOctave,
718
lmENoteType nNoteType, float rDuration, int nDots,
719
lmENoteHeads nNotehead, lmEAccidentals nAcc,
720
int nVoice, lmNote* pBaseOfChord, bool fTiedPrev,
722
: lmScoreCommand(sName, pDoc, fNormalCmd)
723
, m_nNoteType(nNoteType)
724
, m_nPitchType(nPitchType)
729
, m_rDuration(rDuration)
730
, m_nNotehead(nNotehead)
733
, m_nBaseOfChordID(lmNULL_ID)
734
, m_fTiedPrev(fTiedPrev)
737
m_nBaseOfChordID = pBaseOfChord->GetID();
740
lmCmdInsertNote::~lmCmdInsertNote()
744
bool lmCmdInsertNote::Do()
746
//reposition cursor and save data for undoing the command
750
bool fAutoBar = lmPgmOptions::GetInstance()->GetBoolValue(lm_DO_AUTOBAR);
751
lmNote* pBaseOfChord = (lmNote*)GetScoreObj(m_nBaseOfChordID);
753
GetVStaff()->Cmd_InsertNote(m_nPitchType, m_nStep, m_nOctave, m_nNoteType,
754
m_rDuration, m_nDots, m_nNotehead, m_nAcc,
755
m_nVoice, pBaseOfChord, m_fTiedPrev,
758
return CommandDone(pNewNote != (lmNote*)NULL);
763
//----------------------------------------------------------------------------------------
764
// lmCmdInsertRest: Insert a rest at current cursor position
765
//----------------------------------------------------------------------------------------
767
IMPLEMENT_CLASS(lmCmdInsertRest, lmScoreCommand)
769
lmCmdInsertRest::lmCmdInsertRest(bool fNormalCmd,
770
const wxString& sName,
771
lmDocument *pDoc, lmENoteType nNoteType,
772
float rDuration, int nDots, int nVoice)
773
: lmScoreCommand(sName, pDoc, fNormalCmd)
774
, m_nNoteType(nNoteType)
776
, m_rDuration(rDuration)
781
lmCmdInsertRest::~lmCmdInsertRest()
785
bool lmCmdInsertRest::Do()
787
//reposition cursor and save data for undoing the command
791
bool fAutoBar = lmPgmOptions::GetInstance()->GetBoolValue(lm_DO_AUTOBAR);
792
lmRest* pRest = GetVStaff()->Cmd_InsertRest(m_nNoteType, m_rDuration,
793
m_nDots, m_nVoice, fAutoBar);
795
return CommandDone(pRest != (lmRest*)NULL);
800
//----------------------------------------------------------------------------------------
801
// lmCmdChangeNotePitch: Change pitch of note at current cursor position
802
//----------------------------------------------------------------------------------------
804
IMPLEMENT_CLASS(lmCmdChangeNotePitch, lmScoreCommand)
806
lmCmdChangeNotePitch::lmCmdChangeNotePitch(bool fNormalCmd,
807
const wxString& sName, lmDocument *pDoc,
808
lmNote* pNote, int nSteps)
809
: lmScoreCommand(sName, pDoc, fNormalCmd)
811
, m_nNoteID(pNote->GetID())
815
bool lmCmdChangeNotePitch::Do()
817
//Direct command. NO UNDO LOG
822
((lmNote*)GetScoreObj(m_nNoteID))->ChangePitch(m_nSteps);
824
return CommandDone(true);
827
bool lmCmdChangeNotePitch::Undo()
829
//Direct command. NO UNDO LOG
831
((lmNote*)GetScoreObj(m_nNoteID))->ChangePitch(-m_nSteps);
832
return CommandUndone();
837
//----------------------------------------------------------------------------------------
838
// lmCmdChangeNoteAccidentals: Change accidentals of notes in current selection
839
//----------------------------------------------------------------------------------------
841
IMPLEMENT_CLASS(lmCmdChangeNoteAccidentals, lmScoreCommand)
843
lmCmdChangeNoteAccidentals::lmCmdChangeNoteAccidentals(
845
const wxString& sName, lmDocument *pDoc,
846
lmGMSelection* pSelection, int nAcc)
847
: lmScoreCommand(sName, pDoc, fNormalCmd)
851
//loop to save notes to modify
852
lmGMObject* pGMO = pSelection->GetFirst();
855
if (pGMO->GetType() == eGMO_ShapeNote)
857
lmCmdNoteData* pData = new lmCmdNoteData;
858
lmNote* pNote = (lmNote*)pGMO->GetScoreOwner();
859
pData->nNoteID = pNote->GetID();
860
pData->nAcc = pNote->GetAPitch().Accidentals();
862
m_Notes.push_back( pData );
864
pGMO = pSelection->GetNext();
868
lmCmdChangeNoteAccidentals::~lmCmdChangeNoteAccidentals()
870
//delete selection data
871
std::list<lmCmdNoteData*>::iterator it;
872
for (it = m_Notes.begin(); it != m_Notes.end(); ++it)
879
bool lmCmdChangeNoteAccidentals::Do()
881
//Direct command. NO UNDO LOG
886
std::list<lmCmdNoteData*>::iterator it;
887
for (it = m_Notes.begin(); it != m_Notes.end(); ++it)
889
((lmNote*)GetScoreObj((*it)->nNoteID))->ChangeAccidentals(m_nAcc);
892
return CommandDone(true);
895
bool lmCmdChangeNoteAccidentals::Undo()
897
//Direct command. NO UNDO LOG
899
std::list<lmCmdNoteData*>::iterator it;
900
for (it = m_Notes.begin(); it != m_Notes.end(); ++it)
902
((lmNote*)GetScoreObj((*it)->nNoteID))->ChangeAccidentals( (*it)->nAcc );
905
return CommandUndone();
910
//----------------------------------------------------------------------------------------
911
// lmCmdChangeNoteRestDots: Change dots of notes in current selection
912
//----------------------------------------------------------------------------------------
914
IMPLEMENT_CLASS(lmCmdChangeNoteRestDots, lmScoreCommand)
916
lmCmdChangeNoteRestDots::lmCmdChangeNoteRestDots(bool fNormalCmd,
917
const wxString& sName,
919
lmGMSelection* pSelection,
921
: lmScoreCommand(sName, pDoc, fNormalCmd)
924
//loop to save data about note/rests to modify
925
lmGMObject* pGMO = pSelection->GetFirst();
928
if (pGMO->GetType() == eGMO_ShapeNote || pGMO->GetType() == eGMO_ShapeRest)
930
lmNoteRest* pNR = (lmNoteRest*)pGMO->GetScoreOwner();
931
m_NoteRests.push_back( pNR->GetID() );
933
pGMO = pSelection->GetNext();
937
lmCmdChangeNoteRestDots::~lmCmdChangeNoteRestDots()
939
//delete selection data
943
bool lmCmdChangeNoteRestDots::Do()
945
//reposition cursor and save data for undoing the command
948
//loop to change dots
949
std::list<long>::iterator it;
950
for (it = m_NoteRests.begin(); it != m_NoteRests.end(); ++it)
952
//Get pointer to object to delete
953
lmNoteRest* pNR = (lmNoteRest*)GetScoreObj(*it);
954
GetVStaff()->Cmd_ChangeDots(pNR, m_nDots);
957
return CommandDone(true);
962
//----------------------------------------------------------------------------------------
963
// lmCmdDeleteTuplet implementation
964
//----------------------------------------------------------------------------------------
966
IMPLEMENT_CLASS(lmCmdDeleteTuplet, lmScoreCommand)
968
lmCmdDeleteTuplet::lmCmdDeleteTuplet(bool fNormalCmd,
969
const wxString& sName, lmDocument *pDoc,
970
lmNoteRest* pStartNR)
971
: lmScoreCommand(sName, pDoc, fNormalCmd)
972
, m_nStartID(pStartNR->GetID())
976
bool lmCmdDeleteTuplet::Do()
978
//reposition cursor and save data for undoing the command
981
//Get pointer to object to delete
982
lmNoteRest* pNR = (lmNoteRest*)GetScoreObj(m_nStartID);
984
//Proceed to delete the tuplet
985
bool fError = GetVStaff()->Cmd_DeleteTuplet(pNR);
986
return CommandDone(!fError);
991
//----------------------------------------------------------------------------------------
992
// lmCmdAddTuplet implementation: Add a tuplet to notes in current selection
993
//----------------------------------------------------------------------------------------
995
IMPLEMENT_CLASS(lmCmdAddTuplet, lmScoreCommand)
997
lmCmdAddTuplet::lmCmdAddTuplet(bool fNormalCmd,
998
const wxString& sName, lmDocument *pDoc, lmGMSelection* pSelection,
999
bool fShowNumber, int nNumber, bool fBracket,
1000
lmEPlacement nAbove, int nActual, int nNormal)
1001
: lmScoreCommand(sName, pDoc, fNormalCmd)
1002
, m_fShowNumber(fShowNumber)
1003
, m_nNumber(nNumber)
1004
, m_fBracket(fBracket)
1006
, m_nActual(nActual)
1007
, m_nNormal(nNormal)
1009
//loop to save the ID for the notes/rests to include in the tuplet
1010
lmGMObject* pGMO = pSelection->GetFirst();
1013
if (pGMO->GetType() == eGMO_ShapeNote || pGMO->GetType() == eGMO_ShapeRest)
1015
m_NotesRests.push_back( ((lmNoteRest*)pGMO->GetScoreOwner())->GetID() );
1017
pGMO = pSelection->GetNext();
1021
lmCmdAddTuplet::~lmCmdAddTuplet()
1023
//delete selection data
1024
m_NotesRests.clear();
1027
bool lmCmdAddTuplet::Do()
1029
//reposition cursor and save data for undoing the command
1032
//Get pointers to notes/rest to include in tuplet
1033
std::vector<lmNoteRest*> notes;
1034
std::list<long>::iterator it;
1035
for (it = m_NotesRests.begin(); it != m_NotesRests.end(); ++it)
1037
notes.push_back((lmNoteRest*)GetScoreObj(*it));
1040
//Proceed to add the tuplet
1041
bool fError = GetVStaff()->Cmd_AddTuplet(notes, m_fShowNumber, m_nNumber, m_fBracket,
1042
m_nAbove, m_nActual, m_nNormal);
1045
return CommandDone(!fError);
1050
//----------------------------------------------------------------------------------------
1051
// lmCmdBreakBeam implementation
1052
//----------------------------------------------------------------------------------------
1054
IMPLEMENT_CLASS(lmCmdBreakBeam, lmScoreCommand)
1056
lmCmdBreakBeam::lmCmdBreakBeam(bool fNormalCmd,
1057
const wxString& sName, lmDocument *pDoc, lmNoteRest* pBeforeNR)
1058
: lmScoreCommand(sName, pDoc, fNormalCmd)
1059
, m_nBeforeNR(pBeforeNR->GetID())
1063
lmCmdBreakBeam::~lmCmdBreakBeam()
1067
bool lmCmdBreakBeam::Do()
1069
//reposition cursor and save data for undoing the command
1072
//Get pointer to note and issue the command
1073
GetVStaff()->Cmd_BreakBeam( (lmNoteRest*)GetScoreObj(m_nBeforeNR) );
1075
return CommandDone(true);
1080
//----------------------------------------------------------------------------------------
1081
// lmCmdJoinBeam implementation
1082
//----------------------------------------------------------------------------------------
1084
IMPLEMENT_CLASS(lmCmdJoinBeam, lmScoreCommand)
1086
lmCmdJoinBeam::lmCmdJoinBeam(bool fNormalCmd,
1087
const wxString& sName, lmDocument *pDoc,
1088
lmGMSelection* pSelection)
1089
: lmScoreCommand(sName, pDoc, fNormalCmd)
1091
//loop to save the IDs of the notes/rests to beam
1092
lmGMObject* pGMO = pSelection->GetFirst();
1095
if (pGMO->GetType() == eGMO_ShapeNote || pGMO->GetType() == eGMO_ShapeRest)
1097
lmNoteRest* pNR = (lmNoteRest*)pGMO->GetScoreOwner();
1098
//exclude notes in chord
1099
if (pNR->IsRest() || (pNR->IsNote() &&
1100
(!((lmNote*)pNR)->IsInChord() ||
1101
((lmNote*)pNR)->IsBaseOfChord() )) )
1102
m_NotesRests.push_back(pNR->GetID());
1104
pGMO = pSelection->GetNext();
1108
bool lmCmdJoinBeam::Do()
1110
//reposition cursor and save data for undoing the command
1113
//Get pointers to note/rests
1114
std::vector<lmNoteRest*> notes;
1115
std::vector<long>::iterator it;
1116
for (it = m_NotesRests.begin(); it != m_NotesRests.end(); ++it)
1118
notes.push_back( (lmNoteRest*)GetScoreObj(*it) );
1122
GetVStaff()->Cmd_JoinBeam(notes);
1124
return CommandDone(true);
1129
//----------------------------------------------------------------------------------------
1130
// lmCmdChangeText: Change ScoreText properties
1131
//----------------------------------------------------------------------------------------
1133
IMPLEMENT_CLASS(lmCmdChangeText, lmScoreCommand)
1135
lmCmdChangeText::lmCmdChangeText(bool fNormalCmd,
1136
const wxString& sName, lmDocument *pDoc, lmScoreText* pST,
1137
wxString& sText, lmEHAlign nHAlign, lmLocation tPos,
1138
lmTextStyle* pStyle, int nHintOptions)
1139
: lmScoreCommand(sName, pDoc, fNormalCmd)
1140
, m_nTextID(pST->GetID())
1143
, m_nHAlign(nHAlign)
1146
//get and save current values
1147
, m_sOldText(pST->GetText())
1148
, m_nOldHAlign(pST->GetAlignment())
1149
, m_tOldPos(pST->GetLocation())
1150
, m_OldStyle(*(pST->GetStyle()))
1154
bool lmCmdChangeText::Do()
1156
//Direct command. NO UNDO LOG
1161
lmScoreText* pST = (lmScoreText*)GetScoreObj(m_nTextID);
1162
lmTextStyle* pStyle = m_pDoc->GetScore()
1163
->AddStyle(m_Style.sName, m_Style.tFont, m_Style.nColor);
1164
pST->Cmd_ChangeText(m_sText, m_nHAlign, m_tPos, pStyle);
1166
return CommandDone(true);
1169
bool lmCmdChangeText::Undo()
1171
//Direct command. NO UNDO LOG
1173
lmScoreText* pST = (lmScoreText*)GetScoreObj(m_nTextID);
1174
lmTextStyle* pOldStyle = m_pDoc->GetScore()
1175
->AddStyle(m_OldStyle.sName, m_OldStyle.tFont, m_OldStyle.nColor);
1176
pST->Cmd_ChangeText(m_sOldText, m_nOldHAlign, m_tOldPos, pOldStyle);
1178
return CommandUndone();
1183
//----------------------------------------------------------------------------------------
1184
// lmCmdChangePageMargin implementation
1185
//----------------------------------------------------------------------------------------
1187
IMPLEMENT_CLASS(lmCmdChangePageMargin, lmScoreCommand)
1189
lmCmdChangePageMargin::lmCmdChangePageMargin(bool fNormalCmd,
1190
const wxString& sName, lmDocument *pDoc,
1191
lmGMObject* pGMO, int nIdx, int nPage,
1193
: lmScoreCommand(sName, pDoc, fNormalCmd)
1198
//save current position
1199
lmScore* pScore = m_pDoc->GetScore();
1203
m_uOldPos = pScore->GetPageTopMargin(nPage);
1206
case lmMARGIN_BOTTOM:
1207
m_uOldPos = pScore->GetMaximumY(nPage);
1211
m_uOldPos = pScore->GetLeftMarginXPos(nPage);
1214
case lmMARGIN_RIGHT:
1215
m_uOldPos = pScore->GetRightMarginXPos(nPage);
1223
bool lmCmdChangePageMargin::Do()
1225
//Direct command. NO UNDO LOG
1230
ChangeMargin(m_uNewPos);
1231
return CommandDone(true);
1234
bool lmCmdChangePageMargin::Undo()
1236
//Direct command. NO UNDO LOG
1238
ChangeMargin(m_uOldPos);
1239
return CommandUndone();
1242
void lmCmdChangePageMargin::ChangeMargin(lmLUnits uPos)
1244
lmScore* pScore = m_pDoc->GetScore();
1245
lmUSize size = pScore->GetPaperSize(m_nPage);
1250
pScore->SetPageTopMargin(uPos, m_nPage);
1253
case lmMARGIN_BOTTOM:
1254
pScore->SetPageBottomMargin(size.Height() - uPos, m_nPage);
1258
pScore->SetPageLeftMargin(uPos, m_nPage);
1261
case lmMARGIN_RIGHT:
1262
pScore->SetPageRightMargin(size.Width() - uPos, m_nPage);
1272
//----------------------------------------------------------------------------------------
1273
// lmCmdAttachText implementation
1274
//----------------------------------------------------------------------------------------
1276
IMPLEMENT_CLASS(lmCmdAttachText, lmScoreCommand)
1278
lmCmdAttachText::lmCmdAttachText(bool fNormalCmd, lmDocument *pDoc, wxString& sText,
1279
lmTextStyle* pStyle, lmEHAlign nAlign,
1280
lmComponentObj* pAnchor)
1281
: lmScoreCommand(_("attach text"), pDoc, fNormalCmd)
1282
, m_nAnchorID(pAnchor->GetID())
1286
, m_nTextID(lmNEW_ID)
1290
bool lmCmdAttachText::Do()
1292
//reposition cursor and save data for undoing the command
1295
lmTextStyle* pStyle = m_pDoc->GetScore()
1296
->AddStyle(m_Style.sName, m_Style.tFont, m_Style.nColor);
1297
lmScoreObj* pAnchor = GetScoreObj(m_nAnchorID);
1298
lmTextItem* pNewText = new lmTextItem(pAnchor, m_nTextID, m_sText, m_nAlign, pStyle);
1299
pAnchor->AttachAuxObj(pNewText);
1300
m_nTextID = pNewText->GetID();
1303
//It is necessary to ensure that if the command is redone, the text always
1304
//get assigned the same ID, as the text could be referenced in a subsequent
1306
//In normal commands, the same ID is assigned automatically. But in this
1307
//command, the text has been previously created in lmScoreCanvas::AttachNewText()
1308
//and then deleted, and this ID number n is discarded. Therefore, the first time
1309
//the command is executed the text will get ID = n+1. But in a redo operation,
1310
//the text will not be created and deleted in lmScoreCanvas::AttachNewText(), but
1311
//only here. Therefore, the ID that will be assigned in the redo operation will
1312
//be the initially deleted ID (n), instead of the correct one (n+1).
1313
//And this will invalidate any redo reference.
1314
//To avoid this problem, m_nTextID is initialized with lmNEW_ID so the first
1315
//time the command is executed, a new ID (n+1) is assigned and saved. And this
1316
//saved value is used in any subsequent redo operation, ensuring that
1317
//the text receives the right ID (n+1).
1319
return CommandDone(true);
1324
//----------------------------------------------------------------------------------------
1325
// lmCmdAddTitle implementation
1326
//----------------------------------------------------------------------------------------
1328
IMPLEMENT_CLASS(lmCmdAddTitle, lmScoreCommand)
1330
lmCmdAddTitle::lmCmdAddTitle(bool fNormalCmd, lmDocument *pDoc, wxString& sText,
1331
lmTextStyle* pStyle, lmEHAlign nAlign)
1332
: lmScoreCommand(_("add title"), pDoc, fNormalCmd)
1336
, m_nTitleID(lmNEW_ID)
1340
bool lmCmdAddTitle::Do()
1342
//reposition cursor and save data for undoing the command
1345
lmScore* pScore = m_pDoc->GetScore();
1346
lmTextStyle* pStyle = pScore->AddStyle(m_Style.sName, m_Style.tFont,
1348
lmScoreTitle* pNewTitle
1349
= new lmScoreTitle(pScore, m_nTitleID, m_sText, lmBLOCK_ALIGN_BOTH,
1350
lmHALIGN_DEFAULT, lmVALIGN_DEFAULT, pStyle);
1351
pScore->AttachAuxObj(pNewTitle);
1352
m_nTitleID = pNewTitle->GetID();
1354
//AWARE: See, in lmCmdAttachText command, an explanation for saving m_nTitleID
1356
return CommandDone(true);
1361
//----------------------------------------------------------------------------------------
1362
// lmCmdChangeBarline implementation
1363
//----------------------------------------------------------------------------------------
1365
IMPLEMENT_CLASS(lmCmdChangeBarline, lmScoreCommand)
1367
lmCmdChangeBarline::lmCmdChangeBarline(bool fNormalCmd, lmDocument *pDoc, lmBarline* pBL,
1368
lmEBarline nType, bool fVisible)
1369
: lmScoreCommand(_("change barline"), pDoc, fNormalCmd)
1370
, m_nBarlineID(pBL->GetID())
1372
, m_fVisible(fVisible)
1373
, m_nOldType(pBL->GetBarlineType())
1374
, m_fOldVisible(pBL->IsVisible())
1378
lmCmdChangeBarline::~lmCmdChangeBarline()
1382
bool lmCmdChangeBarline::Do()
1384
//Direct command. NO UNDO LOG
1389
lmBarline* pBL = (lmBarline*)GetScoreObj(m_nBarlineID);
1390
pBL->SetBarlineType(m_nType);
1391
pBL->SetVisible(m_fVisible);
1392
return CommandDone(true);
1395
bool lmCmdChangeBarline::Undo()
1397
//Direct command. NO UNDO LOG
1399
lmBarline* pBL = (lmBarline*)GetScoreObj(m_nBarlineID);
1400
pBL->SetBarlineType(m_nOldType);
1401
pBL->SetVisible(m_fOldVisible);
1402
return CommandUndone();
1407
//----------------------------------------------------------------------------------------
1408
// lmCmdChangeFiguredBass implementation
1409
//----------------------------------------------------------------------------------------
1411
IMPLEMENT_CLASS(lmCmdChangeFiguredBass, lmScoreCommand)
1413
lmCmdChangeFiguredBass::lmCmdChangeFiguredBass(bool fNormalCmd, lmDocument *pDoc,
1414
lmFiguredBass* pFB, wxString& sFigBass)
1415
: lmScoreCommand(_("Change figured bass"), pDoc, fNormalCmd)
1416
, m_nFigBasID(pFB->GetID())
1417
, m_sFigBass(sFigBass)
1419
m_FBData.CopyDataFrom( (lmFiguredBassData*)pFB );
1422
bool lmCmdChangeFiguredBass::Do()
1424
//Direct command. NO UNDO LOG
1429
lmFiguredBass* pFB = (lmFiguredBass*)GetScoreObj(m_nFigBasID);
1430
pFB->SetDataFromString(m_sFigBass);
1431
return CommandDone(true);
1434
bool lmCmdChangeFiguredBass::Undo()
1436
//Direct command. NO UNDO LOG
1438
lmFiguredBassData* pFBData = (lmFiguredBassData*)GetScoreObj(m_nFigBasID);
1439
pFBData->CopyDataFrom(&m_FBData);
1440
return CommandUndone();
1444
//----------------------------------------------------------------------------------------
1445
// lmCmdChangeMidiSettings implementation
1446
//----------------------------------------------------------------------------------------
1448
IMPLEMENT_CLASS(lmCmdChangeMidiSettings, lmScoreCommand)
1450
lmCmdChangeMidiSettings::lmCmdChangeMidiSettings(bool fNormalCmd, lmDocument *pDoc,
1451
lmInstrument* pInstr,
1454
: lmScoreCommand(_("change MIDI settings"), pDoc, fNormalCmd)
1455
, m_nInstrID(pInstr->GetID())
1456
, m_nMidiChannel(nMidiChannel)
1457
, m_nMidiInstr(nMidiInstr)
1458
, m_nOldMidiChannel(pInstr->GetMIDIChannel())
1459
, m_nOldMidiInstr(pInstr->GetMIDIInstrument())
1463
bool lmCmdChangeMidiSettings::Do()
1465
//Direct command. NO UNDO LOG
1470
lmInstrument* pInstr = (lmInstrument*)GetScoreObj(m_nInstrID);
1471
pInstr->SetMIDIChannel(m_nMidiChannel);
1472
pInstr->SetMIDIInstrument(m_nMidiInstr);
1473
return CommandDone(true, lmHINT_NO_LAYOUT);
1476
bool lmCmdChangeMidiSettings::Undo()
1478
//Direct command. NO UNDO LOG
1480
lmInstrument* pInstr = (lmInstrument*)GetScoreObj(m_nInstrID);
1481
pInstr->SetMIDIChannel(m_nOldMidiChannel);
1482
pInstr->SetMIDIInstrument(m_nOldMidiInstr);
1483
return CommandUndone(lmHINT_NO_LAYOUT);
1488
//----------------------------------------------------------------------------------------
1489
// lmCmdMoveNote implementation
1490
//----------------------------------------------------------------------------------------
1492
IMPLEMENT_CLASS(lmCmdMoveNote, lmScoreCommand)
1494
lmCmdMoveNote::lmCmdMoveNote(bool fNormalCmd, lmDocument *pDoc, lmNote* pNote,
1495
const lmUPoint& uPos, int nSteps)
1496
: lmScoreCommand(_("move note"), pDoc, fNormalCmd)
1498
, m_nNoteID(pNote->GetID())
1503
bool lmCmdMoveNote::Do()
1505
//Direct command. NO UNDO LOG
1510
lmNote* pNote = (lmNote*)GetScoreObj(m_nNoteID);
1511
pNote->ChangePitch(m_nSteps);
1512
m_uxOldPos = pNote->SetUserXLocation(m_uxPos);
1514
return CommandDone(true);
1517
bool lmCmdMoveNote::Undo()
1519
//Direct command. NO UNDO LOG
1521
lmNote* pNote = (lmNote*)GetScoreObj(m_nNoteID);
1522
pNote->SetUserXLocation(m_uxOldPos);
1523
pNote->ChangePitch(-m_nSteps);
1524
return CommandUndone();
1529
//----------------------------------------------------------------------------------------
1530
// lmCmdMoveObjectPoints implementation
1531
//----------------------------------------------------------------------------------------
1533
IMPLEMENT_CLASS(lmCmdMoveObjectPoints, lmScoreCommand)
1535
lmCmdMoveObjectPoints::lmCmdMoveObjectPoints(bool fNormalCmd, const wxString& name,
1536
lmDocument *pDoc, lmGMObject* pGMO,
1537
lmUPoint uShift[], int nNumPoints, bool fDoLayout)
1538
: lmScoreCommand(name, pDoc, fNormalCmd, fDoLayout)
1539
, m_nNumPoints(nNumPoints)
1540
, m_nObjID(pGMO->GetScoreOwner()->GetID())
1541
, m_nShapeIdx(pGMO->GetOwnerIDX())
1543
wxASSERT(nNumPoints > 0);
1545
//allocate a vector to save shifts
1546
m_pShifts = new lmUPoint[m_nNumPoints];
1547
for(int i=0; i < m_nNumPoints; i++)
1548
*(m_pShifts+i) = uShift[i];
1551
lmCmdMoveObjectPoints::~lmCmdMoveObjectPoints()
1556
bool lmCmdMoveObjectPoints::Do()
1558
//Direct command. NO UNDO LOG
1563
lmScoreObj* pSCO = GetScoreObj(m_nObjID);
1564
pSCO->MoveObjectPoints(m_nNumPoints, m_nShapeIdx, m_pShifts, true); //true->add shifts
1565
return CommandDone(true, lmHINT_NO_LAYOUT);
1568
bool lmCmdMoveObjectPoints::Undo()
1570
//Direct command. NO UNDO LOG
1572
lmScoreObj* pSCO = GetScoreObj(m_nObjID);
1573
pSCO->MoveObjectPoints(m_nNumPoints, m_nShapeIdx, m_pShifts, false); //false->substract shifts
1574
return CommandUndone(lmHINT_NO_LAYOUT);
1579
//----------------------------------------------------------------------------------------
1580
// lmCmdScoreProcessor implementation
1581
//----------------------------------------------------------------------------------------
1583
IMPLEMENT_CLASS(lmCmdScoreProcessor, lmScoreCommand)
1585
lmCmdScoreProcessor::lmCmdScoreProcessor(bool fNormalCmd, lmDocument *pDoc,
1586
lmScoreProcessor* pProc)
1587
: lmScoreCommand(_("Score processor"), pDoc, fNormalCmd)
1589
//copy score processor and inform that a copy is going to be used
1591
lmProcessorMngr::GetInstance()->IncrementReference(pProc);
1593
//get process options
1594
m_pOpt = pProc->GetProcessOptions();
1597
lmCmdScoreProcessor::~lmCmdScoreProcessor()
1599
lmProcessorMngr::GetInstance()->DeleteScoreProcessor(m_pProc);
1602
bool lmCmdScoreProcessor::Do()
1604
//reposition cursor and save data for undoing the command
1607
lmScore* pScore = m_pDoc->GetScore();
1608
bool fOK = m_pProc->ProcessScore(pScore, m_pOpt);
1610
return CommandDone(fOK);
1615
//----------------------------------------------------------------------------------------
1616
// lmCmdToggleNoteStem: Toggle stem of notes in current selection
1617
//----------------------------------------------------------------------------------------
1619
IMPLEMENT_CLASS(lmCmdToggleNoteStem, lmScoreCommand)
1621
lmCmdToggleNoteStem::lmCmdToggleNoteStem(bool fNormalCmd, lmDocument *pDoc,
1622
lmGMSelection* pSelection)
1623
: lmScoreCommand(_("Toggle stem"), pDoc, fNormalCmd)
1625
//loop to save data about note/rests to modify
1626
lmGMObject* pGMO = pSelection->GetFirst();
1629
if (pGMO->GetType() == eGMO_ShapeNote)
1631
lmNote* pNote = (lmNote*)pGMO->GetScoreOwner();
1632
m_Notes.push_back( pNote->GetID() );
1634
pGMO = pSelection->GetNext();
1638
lmCmdToggleNoteStem::~lmCmdToggleNoteStem()
1640
//delete selection data
1644
bool lmCmdToggleNoteStem::Do()
1646
//Direct command. NO UNDO LOG
1648
//loop to toggle stems
1649
std::list<long>::iterator it;
1650
for (it = m_Notes.begin(); it != m_Notes.end(); ++it)
1652
((lmNote*)GetScoreObj(*it))->ToggleStem();
1655
return CommandDone(true);
1658
bool lmCmdToggleNoteStem::Undo()
1660
//Direct command. NO UNDO LOG
1662
//loop to toggle stems
1663
std::list<long>::iterator it;
1664
for (it = m_Notes.begin(); it != m_Notes.end(); ++it)
1666
((lmNote*)GetScoreObj(*it))->ToggleStem();
1669
return CommandUndone();