1 2 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 3 4 /* 5 Rosegarden 6 A MIDI and audio sequencer and musical notation editor. 7 Copyright 2000-2021 the Rosegarden development team. 8 9 Other copyrights also apply to some parts of this work. Please 10 see the AUTHORS file and individual file headers for details. 11 12 This program is free software; you can redistribute it and/or 13 modify it under the terms of the GNU General Public License as 14 published by the Free Software Foundation; either version 2 of the 15 License, or (at your option) any later version. See the file 16 COPYING included with this distribution for more information. 17 */ 18 19 #ifndef RG_SEGMENTSPLITBYPITCHCOMMAND_H 20 #define RG_SEGMENTSPLITBYPITCHCOMMAND_H 21 22 #include "base/Segment.h" 23 #include "document/Command.h" 24 #include <QString> 25 #include <QCoreApplication> 26 #include "gui/general/ClefIndex.h" 27 28 29 30 31 namespace Rosegarden 32 { 33 34 class Composition; 35 36 37 class SegmentSplitByPitchCommand : public NamedCommand 38 { 39 Q_DECLARE_TR_FUNCTIONS(Rosegarden::SegmentSplitByPitchCommand) 40 41 public: 42 enum ClefHandling { 43 LeaveClefs, 44 RecalculateClefs, 45 UseTrebleAndBassClefs 46 }; 47 enum SplitStrategy { 48 ConstantPitch, 49 Ranging, 50 LowestTone, 51 HighestTone, 52 ChordToneOfInitialPitch, 53 }; 54 55 SegmentSplitByPitchCommand(Segment *segment, 56 int splitPitch, 57 SplitStrategy splitStrategy, 58 bool duplicateNonNoteEvents, 59 ClefHandling clefHandling); 60 ~SegmentSplitByPitchCommand() override; 61 getGlobalName()62 static QString getGlobalName() 63 { return tr("Split by &Pitch..."); } 64 65 void execute() override; 66 void unexecute() override; 67 68 private: 69 int getSplitPitchAt(Segment::iterator i); 70 int 71 getNewRangingSplitPitch(Segment::iterator i, 72 int lastSplitPitch, 73 std::vector<int>& c0p); 74 75 Composition *m_composition; 76 Segment *m_segment; 77 Segment *m_newSegmentA; 78 Segment *m_newSegmentB; 79 int m_splitPitch; 80 SplitStrategy m_splitStrategy; 81 int m_toneIndex; // Used for strategy ChordToneOfInitialPitch 82 bool m_dupNonNoteEvents; 83 ClefHandling m_clefHandling; 84 bool m_executed; 85 }; 86 87 88 } 89 90 #endif 91