Audacity 3.2.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
LabelTrack Class Referencefinal

A LabelTrack is a Track that holds labels (LabelStruct). More...

#include <LabelTrack.h>

Inheritance diagram for LabelTrack:
[legend]
Collaboration diagram for LabelTrack:
[legend]

Classes

struct  IntervalData
 

Public Types

using Holder = std::shared_ptr< LabelTrack >
 
- Public Types inherited from Track
enum class  LinkType : int { None = 0 , Group = 2 , Aligned }
 For two tracks describes the type of the linkage. More...
 
enum  ChannelType { LeftChannel = 0 , RightChannel = 1 , MonoChannel = 2 }
 
using ChannelGroupAttachments = ClientData::Site< ChannelGroupData, ClientData::Cloneable<>, ClientData::DeepCopying >
 Hosting of objects attached by higher level code. More...
 
using AttachedObjects = ::AttachedTrackObjects
 Alias for my base type. More...
 
using IntervalData = TrackIntervalData
 
using Interval = TrackInterval
 
using Intervals = std::vector< Interval >
 
using ConstInterval = ConstTrackInterval
 
using ConstIntervals = std::vector< ConstInterval >
 
using Holder = std::shared_ptr< Track >
 
template<typename R = void>
using Continuation = std::function< R() >
 Type of arguments passed as optional second parameter to TypeSwitch() cases. More...
 
using Fallthrough = Continuation<>
 Type of arguments passed as optional second parameter to TypeSwitch<void>() cases. More...
 
- Public Types inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
using DataType = ClientData
 
using DataPointer = Pointer< ClientData >
 
using DataFactory = std::function< DataPointer(Host &) >
 Type of function from which RegisteredFactory is constructed; it builds attachments. More...
 
- Public Types inherited from Observer::Publisher< struct LabelTrackEvent >
using message_type = struct LabelTrackEvent
 
using CallbackReturn = std::conditional_t< true, void, bool >
 
using Callback = std::function< CallbackReturn(const struct LabelTrackEvent &) >
 Type of functions that can be connected to the Publisher. More...
 

Public Member Functions

 LabelTrack ()
 
 LabelTrack (const LabelTrack &orig, ProtectedCreationArg &&)
 
virtual ~LabelTrack ()
 
void SetLabel (size_t iLabel, const LabelStruct &newLabel)
 
void SetOffset (double dOffset) override
 
void SetSelected (bool s) override
 
double GetOffset () const override
 
double GetStartTime () const override
 
double GetEndTime () const override
 
bool HandleXMLTag (const std::string_view &tag, const AttributesList &attrs) override
 
XMLTagHandlerHandleXMLChild (const std::string_view &tag) override
 
void WriteXML (XMLWriter &xmlFile) const override
 
Track::Holder Cut (double t0, double t1) override
 
Track::Holder Copy (double t0, double t1, bool forClipboard=true) const override
 
void Clear (double t0, double t1) override
 
void Paste (double t, const Track *src) override
 
bool Repeat (double t0, double t1, int n)
 
void SyncLockAdjust (double oldT1, double newT1) override
 
void Silence (double t0, double t1) override
 
void InsertSilence (double t, double len) override
 
void Import (wxTextFile &f)
 Import labels, handling files with or without end-times. More...
 
void Export (wxTextFile &f) const
 Export labels including label start and end-times. More...
 
int GetNumLabels () const
 
const LabelStructGetLabel (int index) const
 
const LabelArrayGetLabels () const
 
void OnLabelAdded (const wxString &title, int pos)
 
int AddLabel (const SelectedRegion &region, const wxString &title)
 
void DeleteLabel (int index)
 
bool PasteOver (double t, const Track *src)
 
void ShiftLabelsOnInsert (double length, double pt)
 
void ChangeLabelsOnReverse (double b, double e)
 
void ScaleLabels (double b, double e, double change)
 
double AdjustTimeStampOnScale (double t, double b, double e, double change)
 
void WarpLabels (const TimeWarper &warper)
 
wxString GetTextOfLabels (double t0, double t1) const
 
int FindNextLabel (const SelectedRegion &currentSelection)
 
int FindPrevLabel (const SelectedRegion &currentSelection)
 
const TypeInfoGetTypeInfo () const override
 
Track::Holder PasteInto (AudacityProject &) const override
 Find or create the destination track for a paste, maybe in a different project. More...
 
ConstInterval MakeInterval (size_t index) const
 
Interval MakeInterval (size_t index)
 
ConstIntervals GetIntervals () const override
 Report times on the track where important intervals begin and end, for UI to snap to. More...
 
Intervals GetIntervals () override
 
void SortLabels ()
 
- Public Member Functions inherited from Track
TrackId GetId () const
 
template<typename Subclass = Track>
std::shared_ptr< Subclass > SharedPointer ()
 
template<typename Subclass = const Track>
auto SharedPointer () const -> std::enable_if_t< std::is_const_v< Subclass >, std::shared_ptr< Subclass > >
 
std::shared_ptr< TrackSubstitutePendingChangedTrack ()
 
std::shared_ptr< const TrackSubstitutePendingChangedTrack () const
 
std::shared_ptr< const TrackSubstituteOriginalTrack () const
 
virtual const TypeInfoGetTypeInfo () const =0
 
virtual const TypeNamesGetTypeNames () const
 
virtual bool SupportsBasicEditing () const
 Whether this track type implements cut-copy-paste; by default, true. More...
 
virtual Holder PasteInto (AudacityProject &) const =0
 Find or create the destination track for a paste, maybe in a different project. More...
 
virtual ConstIntervals GetIntervals () const
 Report times on the track where important intervals begin and end, for UI to snap to. More...
 
virtual Intervals GetIntervals ()
 
int GetIndex () const
 
void SetIndex (int index)
 
virtual bool LinkConsistencyFix (bool doFix=true, bool completeList=true)
 Check consistency of channel groups, and maybe fix it. More...
 
bool LinkConsistencyCheck (bool completeList)
 Do the non-mutating part of consistency fix only and return status. More...
 
bool HasOwner () const
 
std::shared_ptr< TrackListGetOwner () const
 
LinkType GetLinkType () const noexcept
 
bool IsAlignedWithLeader () const
 Returns true if the leader track has link type LinkType::Aligned. More...
 
ChannelGroupDataGetGroupData ()
 
const ChannelGroupDataGetGroupData () const
 
 Track ()
 
 Track (const Track &orig, ProtectedCreationArg &&)
 
Trackoperator= (const Track &orig)=delete
 
virtual ~Track ()
 
void Init (const Track &orig)
 
virtual Holder Duplicate () const
 
virtual void Merge (const Track &orig)
 
wxString GetName () const
 
void SetName (const wxString &n)
 
bool GetSelected () const
 
virtual void SetSelected (bool s)
 
void EnsureVisible (bool modifyState=false)
 
virtual ChannelType GetChannel () const
 
virtual double GetOffset () const =0
 
void Offset (double t)
 
virtual void SetOffset (double o)
 
virtual void SetPan (float)
 
virtual void SetPanFromChannelType ()
 
virtual Holder Cut (double WXUNUSED(t0), double WXUNUSED(t1))=0
 
virtual Holder Copy (double WXUNUSED(t0), double WXUNUSED(t1), bool forClipboard=true) const =0
 
virtual void Clear (double WXUNUSED(t0), double WXUNUSED(t1))=0
 
virtual void Paste (double WXUNUSED(t), const Track *WXUNUSED(src))=0
 
virtual void SyncLockAdjust (double oldT1, double newT1)
 
virtual void Silence (double WXUNUSED(t0), double WXUNUSED(t1))=0
 
virtual void InsertSilence (double WXUNUSED(t), double WXUNUSED(len))=0
 
bool SameKindAs (const Track &track) const
 
template<typename R = void, typename ... Functions>
TypeSwitch (const Functions &...functions)
 Use this function rather than testing track type explicitly and making down-casts. More...
 
template<typename R = void, typename ... Functions>
TypeSwitch (const Functions &...functions) const
 Use this function rather than testing track type explicitly and making down-casts. More...
 
virtual void WriteXML (XMLWriter &xmlFile) const =0
 
virtual bool GetErrorOpening ()
 
virtual double GetStartTime () const =0
 
virtual double GetEndTime () const =0
 
void Notify (int code=-1)
 
bool Any () const
 
bool IsSelected () const
 
bool IsLeader () const
 
bool IsSelectedLeader () const
 
void AdjustPositions ()
 
void WriteCommonXMLAttributes (XMLWriter &xmlFile, bool includeNameAndSelected=true) const
 
bool HandleCommonXMLAttribute (const std::string_view &attr, const XMLAttributeValueView &valueView)
 
- Public Member Functions inherited from XMLTagHandler
 XMLTagHandler ()
 
virtual ~XMLTagHandler ()
 
virtual bool HandleXMLTag (const std::string_view &tag, const AttributesList &attrs)=0
 
virtual void HandleXMLEndTag (const std::string_view &WXUNUSED(tag))
 
virtual void HandleXMLContent (const std::string_view &WXUNUSED(content))
 
virtual XMLTagHandlerHandleXMLChild (const std::string_view &tag)=0
 
void ReadXMLEndTag (const char *tag)
 
void ReadXMLContent (const char *s, int len)
 
XMLTagHandlerReadXMLChild (const char *tag)
 
- Public Member Functions inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
 ~Site ()
 
 Site ()
 
 Site (const Site &other)
 
Siteoperator= (const Site &other)
 
 Site (Site &&other)
 
Siteoperator= (Site &&other)
 
size_t size () const
 How many attachment pointers are in the Site. More...
 
template<typename Subclass = ClientData>
Subclass & Get (const RegisteredFactory &key)
 Get reference to an attachment, creating on demand if not present, down-cast it to Subclass. More...
 
template<typename Subclass = const ClientData>
auto Get (const RegisteredFactory &key) const -> std::enable_if_t< std::is_const< Subclass >::value, Subclass & >
 Get reference to an attachment, creating on demand if not present, down-cast it to Subclass. More...
 
template<typename Subclass = ClientData>
Subclass * Find (const RegisteredFactory &key)
 Get a (bare) pointer to an attachment, or null, down-cast it to Subclass *; will not create on demand. More...
 
template<typename Subclass = const ClientData>
auto Find (const RegisteredFactory &key) const -> std::enable_if_t< std::is_const< Subclass >::value, Subclass * >
 Get a (bare) pointer to an attachment, or null, down-cast it to Subclass *; will not create on demand. More...
 
template<typename ReplacementPointer >
void Assign (const RegisteredFactory &key, ReplacementPointer &&replacement)
 Reassign Site's pointer to ClientData. More...
 
- Public Member Functions inherited from Observer::Publisher< struct LabelTrackEvent >
 Publisher (ExceptionPolicy *pPolicy=nullptr, Alloc a={})
 Constructor supporting type-erased custom allocation/deletion. More...
 
 Publisher (Publisher &&)=default
 
Publisheroperator= (Publisher &&)=default
 
Subscription Subscribe (Callback callback)
 Connect a callback to the Publisher; later-connected are called earlier. More...
 
Subscription Subscribe (Object &obj, Return(Object::*callback)(Args...))
 Overload of Subscribe takes an object and pointer-to-member-function. More...
 

Static Public Member Functions

static wxString GetDefaultName ()
 
static LabelTrackNew (AudacityProject &project)
 
static LabelTrackCreate (TrackList &trackList, const wxString &name)
 Create a new LabelTrack with specified name and append it to the trackList. More...
 
static LabelTrackCreate (TrackList &trackList)
 Create a new LabelTrack with unique default name and append it to the trackList. More...
 
static const TypeInfoClassTypeInfo ()
 
- Static Public Member Functions inherited from Track
template<typename Subclass = Track>
static std::shared_ptr< Subclass > SharedPointer (Track *pTrack)
 
template<typename Subclass = const Track>
static std::shared_ptr< Subclass > SharedPointer (const Track *pTrack)
 
static const TypeInfoClassTypeInfo ()
 
static void FinishCopy (const Track *n, Track *dest)
 
template<typename TrackType >
static void checkTrackType ()
 
template<typename R , typename TrackType , typename... Functions>
static R CallExecutor (R *, std::tuple<> *, TrackType &, const Functions &...)
 
template<typename R , typename TrackType , typename... Functions, typename Executor , typename... Executors>
static R CallExecutor (R *, std::tuple< Executor, Executors... > *, TrackType &track, const Functions &...functions)
 
template<typename ... Executors>
static constexpr unsigned UsedCases (std::tuple< Executors... > *)
 
template<typename Tag , bool IsConst, typename R , typename ... TrackTypes, typename ... Functions>
static R DoTypeSwitch (std::conditional_t< IsConst, const Track, Track > &track, std::tuple< TrackTypes... > *, const Functions &...functions)
 
- Static Public Member Functions inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
static size_t slots ()
 How many static factories have been registered with this specialization of Site. More...
 

Private Member Functions

Track::Holder Clone () const override
 

Private Attributes

LabelArray mLabels
 
double mClipLen
 
int miLastLabel
 

Additional Inherited Members

- Public Attributes inherited from Track
std::pair< int, int > vrulerSize
 
- Static Public Attributes inherited from Observer::Publisher< struct LabelTrackEvent >
static constexpr bool notifies_all
 
- Protected Member Functions inherited from Track
void SetLinkType (LinkType linkType, bool completeList=true)
 
void SetChannel (ChannelType c) noexcept
 
- Protected Member Functions inherited from ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >
template<typename Function >
void ForEach (const Function &function)
 Invoke function on each ClientData object that has been created in this. More...
 
template<typename Function >
void ForEach (const Function &function) const
 Invoke function on each ClientData object that has been created in this. More...
 
template<typename Function >
ClientData * FindIf (const Function &function)
 Return pointer to first attachment in this that is not null and satisfies a predicate, or nullptr. More...
 
template<typename Function >
const ClientData * FindIf (const Function &function) const
 Return pointer to first attachment in this that is not null and satisfies a predicate, or nullptr. More...
 
void BuildAll ()
 For each RegisteredFactory, if the corresponding attachment is absent in this, build and store it. More...
 
- Protected Member Functions inherited from Observer::Publisher< struct LabelTrackEvent >
CallbackReturn Publish (const struct LabelTrackEvent &message)
 Send a message to connected callbacks. More...
 
- Protected Attributes inherited from Track
std::weak_ptr< TrackListmList
 
TrackNodePointer mNode {}
 Holds iterator to self, so that TrackList::Find can be constant-time. More...
 
int mIndex
 0-based position of this track in its TrackList More...
 
wxString mName
 
ChannelType mChannel
 
double mOffset
 

Detailed Description

A LabelTrack is a Track that holds labels (LabelStruct).

These are used to annotate a waveform. Each label has a start time and an end time. The text of the labels is editable and the positions of the end points are draggable.

Definition at line 84 of file LabelTrack.h.

Member Typedef Documentation

◆ Holder

using LabelTrack::Holder = std::shared_ptr<LabelTrack>

Definition at line 121 of file LabelTrack.h.

Constructor & Destructor Documentation

◆ LabelTrack() [1/2]

LabelTrack::LabelTrack ( )

Definition at line 79 of file LabelTrack.cpp.

79 :
80 Track(),
81 mClipLen(0.0),
82 miLastLabel(-1)
83{
84}
double mClipLen
Definition: LabelTrack.h:195
int miLastLabel
Definition: LabelTrack.h:197
Track()
Definition: Track.cpp:44

◆ LabelTrack() [2/2]

LabelTrack::LabelTrack ( const LabelTrack orig,
ProtectedCreationArg &&  a 
)

Definition at line 86 of file LabelTrack.cpp.

87 : Track(orig, std::move(a))
88 , mClipLen(0.0)
89{
90 for (auto &original: orig.mLabels) {
91 LabelStruct l { original.selectedRegion, original.title };
92 mLabels.push_back(l);
93 }
94}
A LabelStruct holds information for ONE label in a LabelTrack.
Definition: LabelTrack.h:29
SelectedRegion selectedRegion
Definition: LabelTrack.h:69
LabelArray mLabels
Definition: LabelTrack.h:192

References mLabels, and LabelStruct::selectedRegion.

◆ ~LabelTrack()

LabelTrack::~LabelTrack ( )
virtual

Definition at line 167 of file LabelTrack.cpp.

168{
169}

Member Function Documentation

◆ AddLabel()

int LabelTrack::AddLabel ( const SelectedRegion region,
const wxString &  title 
)

Definition at line 944 of file LabelTrack.cpp.

946{
947 LabelStruct l { selectedRegion, title };
948
949 int len = mLabels.size();
950 int pos = 0;
951
952 while (pos < len && mLabels[pos].getT0() < selectedRegion.t0())
953 pos++;
954
955 mLabels.insert(mLabels.begin() + pos, l);
956
958 this->SharedPointer<LabelTrack>(), title, -1, pos });
959
960 return pos;
961}
static const auto title
CallbackReturn Publish(const struct LabelTrackEvent &message)
Send a message to connected callbacks.
Definition: Observer.h:207

References LabelTrackEvent::Addition, mLabels, Observer::Publisher< struct LabelTrackEvent >::Publish(), SelectedRegion::t0(), and title.

Referenced by VampEffect::AddFeatures(), and EffectFindClipping::ProcessOne().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AdjustTimeStampOnScale()

double LabelTrack::AdjustTimeStampOnScale ( double  t,
double  b,
double  e,
double  change 
)

Definition at line 263 of file LabelTrack.cpp.

264{
265//t is the time stamp we'll be changing
266//b and e are the selection start and end
267
268 if (t < b){
269 return t;
270 }else if (t > e){
271 double shift = (e-b)*change - (e-b);
272 return t + shift;
273 }else{
274 double shift = (t-b)*change - (t-b);
275 return t + shift;
276 }
277}

Referenced by ScaleLabels().

Here is the caller graph for this function:

◆ ChangeLabelsOnReverse()

void LabelTrack::ChangeLabelsOnReverse ( double  b,
double  e 
)

Definition at line 239 of file LabelTrack.cpp.

240{
241 for (auto &labelStruct: mLabels) {
242 if (labelStruct.RegionRelation(b, e, this) ==
244 {
245 double aux = b + (e - labelStruct.getT1());
246 labelStruct.selectedRegion.setTimes(
247 aux,
248 e - (labelStruct.getT0() - b));
249 }
250 }
251 SortLabels();
252}
@ SURROUNDS_LABEL
Definition: LabelTrack.h:55
void SortLabels()
Definition: LabelTrack.cpp:978

References mLabels, SortLabels(), and LabelStruct::SURROUNDS_LABEL.

Here is the call graph for this function:

◆ ClassTypeInfo()

auto LabelTrack::ClassTypeInfo ( )
static

Definition at line 108 of file LabelTrack.cpp.

109{
110 return typeInfo();
111}
static const Track::TypeInfo & typeInfo()
Definition: LabelTrack.cpp:96

References typeInfo().

Here is the call graph for this function:

◆ Clear()

void LabelTrack::Clear ( double  t0,
double  t1 
)
override

Definition at line 177 of file LabelTrack.cpp.

178{
179 // May DELETE labels, so use subscripts to iterate
180 for (size_t i = 0; i < mLabels.size(); ++i) {
181 auto &labelStruct = mLabels[i];
183 labelStruct.RegionRelation(b, e, this);
184 if (relation == LabelStruct::BEFORE_LABEL)
185 labelStruct.selectedRegion.move(- (e-b));
186 else if (relation == LabelStruct::SURROUNDS_LABEL) {
187 DeleteLabel( i );
188 --i;
189 }
190 else if (relation == LabelStruct::ENDS_IN_LABEL)
191 labelStruct.selectedRegion.setTimes(
192 b,
193 labelStruct.getT1() - (e - b));
194 else if (relation == LabelStruct::BEGINS_IN_LABEL)
195 labelStruct.selectedRegion.setT1(b);
196 else if (relation == LabelStruct::WITHIN_LABEL)
197 labelStruct.selectedRegion.moveT1( - (e-b));
198 }
199}
TimeRelations
Relationships between selection region and labels.
Definition: LabelTrack.h:52
@ BEGINS_IN_LABEL
Definition: LabelTrack.h:57
void DeleteLabel(int index)
Definition: LabelTrack.cpp:963

References LabelStruct::BEFORE_LABEL, LabelStruct::BEGINS_IN_LABEL, DeleteLabel(), LabelStruct::ENDS_IN_LABEL, mLabels, LabelStruct::SURROUNDS_LABEL, and LabelStruct::WITHIN_LABEL.

Referenced by Cut(), anonymous_namespace{EditMenus.cpp}::OnPaste(), and SyncLockAdjust().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Clone()

Track::Holder LabelTrack::Clone ( ) const
overrideprivatevirtual

Implements Track.

Definition at line 362 of file LabelTrack.cpp.

363{
364 auto result = std::make_shared<LabelTrack>(*this, ProtectedCreationArg{});
365 result->Init(*this);
366 return result;
367}

◆ Copy()

Track::Holder LabelTrack::Copy ( double  t0,
double  t1,
bool  forClipboard = true 
) const
override

Definition at line 706 of file LabelTrack.cpp.

707{
708 auto tmp = std::make_shared<LabelTrack>();
709 tmp->Init(*this);
710 const auto lt = static_cast<LabelTrack*>(tmp.get());
711
712 for (auto &labelStruct: mLabels) {
714 labelStruct.RegionRelation(t0, t1, this);
715 if (relation == LabelStruct::SURROUNDS_LABEL) {
716 LabelStruct l {
717 labelStruct.selectedRegion,
718 labelStruct.getT0() - t0,
719 labelStruct.getT1() - t0,
720 labelStruct.title
721 };
722 lt->mLabels.push_back(l);
723 }
724 else if (relation == LabelStruct::WITHIN_LABEL) {
725 LabelStruct l {
726 labelStruct.selectedRegion,
727 0,
728 t1-t0,
729 labelStruct.title
730 };
731 lt->mLabels.push_back(l);
732 }
733 else if (relation == LabelStruct::BEGINS_IN_LABEL) {
734 LabelStruct l {
735 labelStruct.selectedRegion,
736 0,
737 labelStruct.getT1() - t0,
738 labelStruct.title
739 };
740 lt->mLabels.push_back(l);
741 }
742 else if (relation == LabelStruct::ENDS_IN_LABEL) {
743 LabelStruct l {
744 labelStruct.selectedRegion,
745 labelStruct.getT0() - t0,
746 t1 - t0,
747 labelStruct.title
748 };
749 lt->mLabels.push_back(l);
750 }
751 }
752 lt->mClipLen = (t1 - t0);
753
754 return tmp;
755}
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:87

References LabelStruct::BEGINS_IN_LABEL, LabelStruct::ENDS_IN_LABEL, mLabels, LabelStruct::selectedRegion, LabelStruct::SURROUNDS_LABEL, and LabelStruct::WITHIN_LABEL.

Referenced by Cut(), Effect::ModifiedAnalysisTrack::ModifiedAnalysisTrack(), and EffectRepeat::Process().

Here is the caller graph for this function:

◆ Create() [1/2]

LabelTrack * LabelTrack::Create ( TrackList trackList)
static

Create a new LabelTrack with unique default name and append it to the trackList.

Returns
New LabelTrack with unique default name

Definition at line 74 of file LabelTrack.cpp.

75{
76 return Create(trackList, trackList.MakeUniqueTrackName(GetDefaultName()));
77}
static LabelTrack * Create(TrackList &trackList, const wxString &name)
Create a new LabelTrack with specified name and append it to the trackList.
Definition: LabelTrack.cpp:66
static wxString GetDefaultName()
Definition: LabelTrack.cpp:53
wxString MakeUniqueTrackName(const wxString &baseTrackName) const
Returns string that contains baseTrackName, but is guaranteed to be unique among other tracks in that...
Definition: Track.cpp:543

References Create(), GetDefaultName(), and TrackList::MakeUniqueTrackName().

Here is the call graph for this function:

◆ Create() [2/2]

LabelTrack * LabelTrack::Create ( TrackList trackList,
const wxString &  name 
)
static

Create a new LabelTrack with specified name and append it to the trackList.

Returns
New LabelTrack with custom name

Definition at line 66 of file LabelTrack.cpp.

67{
68 auto track = std::make_shared<LabelTrack>();
69 track->SetName(name);
70 trackList.Add(track);
71 return track.get();
72}
const TranslatableString name
Definition: Distortion.cpp:74
TrackKind * Add(const std::shared_ptr< TrackKind > &t)
Definition: Track.h:1564

References TrackList::Add(), and name.

Referenced by Effect::AddedAnalysisTrack::AddedAnalysisTrack(), Create(), anonymous_namespace{LabelMenus.cpp}::DoAddLabel(), anonymous_namespace{DropoutDetector.cpp}::DropoutSubscription::DropoutSubscription(), anonymous_namespace{LabelMenus.cpp}::OnNewLabelTrack(), and anonymous_namespace{LabelMenus.cpp}::OnPasteNewLabel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cut()

Track::Holder LabelTrack::Cut ( double  t0,
double  t1 
)
override

Definition at line 683 of file LabelTrack.cpp.

684{
685 auto tmp = Copy(t0, t1);
686
687 Clear(t0, t1);
688
689 return tmp;
690}
Track::Holder Copy(double t0, double t1, bool forClipboard=true) const override
Definition: LabelTrack.cpp:706
void Clear(double t0, double t1) override
Definition: LabelTrack.cpp:177

References Clear(), and Copy().

Here is the call graph for this function:

◆ DeleteLabel()

void LabelTrack::DeleteLabel ( int  index)

Definition at line 963 of file LabelTrack.cpp.

964{
965 wxASSERT((index < (int)mLabels.size()));
966 auto iter = mLabels.begin() + index;
967 const auto title = iter->title;
968 mLabels.erase(iter);
969
971 this->SharedPointer<LabelTrack>(), title, index, -1 });
972}

References LabelTrackEvent::Deletion, mLabels, Observer::Publisher< struct LabelTrackEvent >::Publish(), and title.

Referenced by Clear(), and Silence().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Export()

void LabelTrack::Export ( wxTextFile &  f) const

Export labels including label start and end-times.

Definition at line 561 of file LabelTrack.cpp.

562{
563 // PRL: to do: export other selection fields
564 for (auto &labelStruct: mLabels)
565 labelStruct.Export(f);
566}

References mLabels.

◆ FindNextLabel()

int LabelTrack::FindNextLabel ( const SelectedRegion currentSelection)

Definition at line 1029 of file LabelTrack.cpp.

1030{
1031 int i = -1;
1032
1033 if (!mLabels.empty()) {
1034 int len = (int) mLabels.size();
1035 if (miLastLabel >= 0 && miLastLabel + 1 < len
1036 && currentRegion.t0() == mLabels[miLastLabel].getT0()
1037 && currentRegion.t0() == mLabels[miLastLabel + 1].getT0() ) {
1038 i = miLastLabel + 1;
1039 }
1040 else {
1041 i = 0;
1042 if (currentRegion.t0() < mLabels[len - 1].getT0()) {
1043 while (i < len &&
1044 mLabels[i].getT0() <= currentRegion.t0()) {
1045 i++;
1046 }
1047 }
1048 }
1049 }
1050
1051 miLastLabel = i;
1052 return i;
1053}

References miLastLabel, mLabels, and SelectedRegion::t0().

Referenced by anonymous_namespace{TransportMenus.cpp}::DoMoveToLabel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindPrevLabel()

int LabelTrack::FindPrevLabel ( const SelectedRegion currentSelection)

Definition at line 1055 of file LabelTrack.cpp.

1056{
1057 int i = -1;
1058
1059 if (!mLabels.empty()) {
1060 int len = (int) mLabels.size();
1061 if (miLastLabel > 0 && miLastLabel < len
1062 && currentRegion.t0() == mLabels[miLastLabel].getT0()
1063 && currentRegion.t0() == mLabels[miLastLabel - 1].getT0() ) {
1064 i = miLastLabel - 1;
1065 }
1066 else {
1067 i = len - 1;
1068 if (currentRegion.t0() > mLabels[0].getT0()) {
1069 while (i >=0 &&
1070 mLabels[i].getT0() >= currentRegion.t0()) {
1071 i--;
1072 }
1073 }
1074 }
1075 }
1076
1077 miLastLabel = i;
1078 return i;
1079}

References miLastLabel, mLabels, and SelectedRegion::t0().

Referenced by anonymous_namespace{TransportMenus.cpp}::DoMoveToLabel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDefaultName()

wxString LabelTrack::GetDefaultName ( )
static

Definition at line 53 of file LabelTrack.cpp.

54{
55 return _("Labels");
56}
#define _(s)
Definition: Internat.h:75

References _.

Referenced by Create(), and NyquistEffect::ProcessOne().

Here is the caller graph for this function:

◆ GetEndTime()

double LabelTrack::GetEndTime ( ) const
overridevirtual

Implements Track.

Definition at line 346 of file LabelTrack.cpp.

347{
348 //we need to scan through all the labels, because the last
349 //label might not have the right-most end (if there is overlap).
350 if (mLabels.empty())
351 return 0.0;
352
353 double end = 0.0;
354 for (auto &labelStruct: mLabels) {
355 const double t1 = labelStruct.getT1();
356 if(t1 > end)
357 end = t1;
358 }
359 return end;
360}
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159

References PackedArray::end(), and mLabels.

Referenced by Effect::ModifiedAnalysisTrack::ModifiedAnalysisTrack(), and SyncLockAdjust().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetIntervals() [1/2]

auto LabelTrack::GetIntervals ( ) const
overridevirtual

Report times on the track where important intervals begin and end, for UI to snap to.

Some intervals may be empty, and no ordering of the intervals is assumed.

Reimplemented from Track.

Definition at line 148 of file LabelTrack.cpp.

149{
150 return DoMakeIntervals<ConstIntervals>(*this);
151}

◆ GetIntervals() [2/2]

auto LabelTrack::GetIntervals ( )
overridevirtual

This overload exposes the extra data of the intervals as non-const This overload exposes the extra data of the intervals as non-const

Reimplemented from Track.

Definition at line 153 of file LabelTrack.cpp.

154{
155 return DoMakeIntervals<Intervals>(*this);
156}

◆ GetLabel()

const LabelStruct * LabelTrack::GetLabel ( int  index) const

Definition at line 939 of file LabelTrack.cpp.

940{
941 return &mLabels[index];
942}

References mLabels.

Referenced by LyricsPanel::AddLabels(), LabelDialog::AddLabels(), anonymous_namespace{TransportMenus.cpp}::DoMoveToLabel(), and ExportMultipleDialog::ExportMultipleByLabel().

Here is the caller graph for this function:

◆ GetLabels()

const LabelArray & LabelTrack::GetLabels ( ) const
inline

Definition at line 146 of file LabelTrack.h.

146{ return mLabels; }

Referenced by LabelTrackView::OverATextBox(), LabelTrackView::OverGlyph(), and GetInfoCommand::SendLabels().

Here is the caller graph for this function:

◆ GetNumLabels()

int LabelTrack::GetNumLabels ( ) const

Definition at line 934 of file LabelTrack.cpp.

935{
936 return mLabels.size();
937}

References mLabels.

Referenced by LyricsPanel::AddLabels(), LabelDialog::AddLabels(), ExportMultipleDialog::CountTracksAndLabels(), DoMakeIntervals(), and anonymous_namespace{TransportMenus.cpp}::DoMoveToLabel().

Here is the caller graph for this function:

◆ GetOffset()

double LabelTrack::GetOffset ( ) const
overridevirtual

Implements Track.

Definition at line 333 of file LabelTrack.cpp.

334{
335 return mOffset;
336}
double mOffset
Definition: Track.h:447

References Track::mOffset.

◆ GetStartTime()

double LabelTrack::GetStartTime ( ) const
overridevirtual

Implements Track.

Definition at line 338 of file LabelTrack.cpp.

339{
340 if (mLabels.empty())
341 return 0.0;
342 else
343 return mLabels[0].getT0();
344}

References mLabels.

Referenced by Effect::ModifiedAnalysisTrack::ModifiedAnalysisTrack(), and EffectFindClipping::Process().

Here is the caller graph for this function:

◆ GetTextOfLabels()

wxString LabelTrack::GetTextOfLabels ( double  t0,
double  t1 
) const

Definition at line 1010 of file LabelTrack.cpp.

1011{
1012 bool firstLabel = true;
1013 wxString retVal;
1014
1015 for (auto &labelStruct: mLabels) {
1016 if (labelStruct.getT0() >= t0 &&
1017 labelStruct.getT1() <= t1)
1018 {
1019 if (!firstLabel)
1020 retVal += '\t';
1021 firstLabel = false;
1022 retVal += labelStruct.title;
1023 }
1024 }
1025
1026 return retVal;
1027}

References mLabels.

◆ GetTypeInfo()

auto LabelTrack::GetTypeInfo ( ) const
overridevirtual

Implements Track.

Definition at line 103 of file LabelTrack.cpp.

104{
105 return typeInfo();
106}

References typeInfo().

Here is the call graph for this function:

◆ HandleXMLChild()

XMLTagHandler * LabelTrack::HandleXMLChild ( const std::string_view &  tag)
overridevirtual

Implements XMLTagHandler.

Definition at line 654 of file LabelTrack.cpp.

655{
656 if (tag == "label")
657 return this;
658 else
659 return NULL;
660}

◆ HandleXMLTag()

bool LabelTrack::HandleXMLTag ( const std::string_view &  tag,
const AttributesList attrs 
)
overridevirtual

Implements XMLTagHandler.

Definition at line 593 of file LabelTrack.cpp.

594{
595 if (tag == "label") {
596
597 SelectedRegion selectedRegion;
598 wxString title;
599
600 // loop through attrs, which is a null-terminated list of
601 // attribute-value pairs
602 for (auto pair : attrs)
603 {
604 auto attr = pair.first;
605 auto value = pair.second;
606
607 if (selectedRegion.HandleXMLAttribute(attr, value, "t", "t1"))
608 ;
609 // Bug 1905 no longer applies, as valueView has no limits anyway
610 else if (attr == "title")
611 title = value.ToWString();
612
613 } // while
614
615 // Handle files created by Audacity 1.1. Labels in Audacity 1.1
616 // did not have separate start- and end-times.
617 // PRL: this superfluous now, given class SelectedRegion's internal
618 // consistency guarantees
619 //if (selectedRegion.t1() < 0)
620 // selectedRegion.collapseToT0();
621
622 LabelStruct l { selectedRegion, title };
623 mLabels.push_back(l);
624
625 return true;
626 }
627 else if (tag == "labeltrack") {
628 long nValue = -1;
629 for (auto pair : attrs)
630 {
631 auto attr = pair.first;
632 auto value = pair.second;
633
634 if (this->Track::HandleCommonXMLAttribute(attr, value))
635 ;
636 else if (attr == "numlabels" && value.TryGet(nValue))
637 {
638 if (nValue < 0)
639 {
640 wxLogWarning(wxT("Project shows negative number of labels: %d"), nValue);
641 return false;
642 }
643 mLabels.clear();
644 mLabels.reserve(nValue);
645 }
646 }
647
648 return true;
649 }
650
651 return false;
652}
wxT("CloseDown"))
Defines a selected portion of a project.
bool HandleXMLAttribute(const std::string_view &attr, const XMLAttributeValueView &value, const char *legacyT0Name=sDefaultT0Name, const char *legacyT1Name=sDefaultT1Name)
bool HandleCommonXMLAttribute(const std::string_view &attr, const XMLAttributeValueView &valueView)
Definition: Track.cpp:1287

References Track::HandleCommonXMLAttribute(), SelectedRegion::HandleXMLAttribute(), mLabels, title, and wxT().

Here is the call graph for this function:

◆ Import()

void LabelTrack::Import ( wxTextFile &  f)

Import labels, handling files with or without end-times.

Definition at line 569 of file LabelTrack.cpp.

570{
571 int lines = in.GetLineCount();
572
573 mLabels.clear();
574 mLabels.reserve(lines);
575
576 //Currently, we expect a tag file to have two values and a label
577 //on each line. If the second token is not a number, we treat
578 //it as a single-value label.
579 bool error = false;
580 for (int index = 0; index < lines;) {
581 try {
582 // Let LabelStruct::Import advance index
583 LabelStruct l { LabelStruct::Import(in, index) };
584 mLabels.push_back(l);
585 }
586 catch(const LabelStruct::BadFormatException&) { error = true; }
587 }
588 if (error)
589 ::AudacityMessageBox( XO("One or more saved labels could not be read.") );
590 SortLabels();
591}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
XO("Cut/Copy/Paste")
static LabelStruct Import(wxTextFile &file, int &index)
Definition: LabelTrack.cpp:396

References AudacityMessageBox(), LabelStruct::Import(), mLabels, SortLabels(), and XO().

Here is the call graph for this function:

◆ InsertSilence()

void LabelTrack::InsertSilence ( double  t,
double  len 
)
override

Definition at line 920 of file LabelTrack.cpp.

921{
922 for (auto &labelStruct: mLabels) {
923 double t0 = labelStruct.getT0();
924 double t1 = labelStruct.getT1();
925 if (t0 >= t)
926 t0 += len;
927
928 if (t1 >= t)
929 t1 += len;
930 labelStruct.selectedRegion.setTimes(t0, t1);
931 }
932}

References mLabels.

◆ MakeInterval() [1/2]

auto LabelTrack::MakeInterval ( size_t  index)

Definition at line 134 of file LabelTrack.cpp.

135{
136 return DoMakeInterval<Interval>(mLabels[index], index);
137}

◆ MakeInterval() [2/2]

auto LabelTrack::MakeInterval ( size_t  index) const

Definition at line 129 of file LabelTrack.cpp.

130{
131 return DoMakeInterval<ConstInterval>(mLabels[index], index);
132}

Referenced by DoMakeIntervals().

Here is the caller graph for this function:

◆ New()

LabelTrack * LabelTrack::New ( AudacityProject project)
static

Definition at line 58 of file LabelTrack.cpp.

59{
60 auto &tracks = TrackList::Get( project );
61 auto result = tracks.Add(std::make_shared<LabelTrack>());
62 result->AttachedTrackObjects::BuildAll();
63 return result;
64}
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:486

References TrackList::Get().

Here is the call graph for this function:

◆ OnLabelAdded()

void LabelTrack::OnLabelAdded ( const wxString &  title,
int  pos 
)

◆ Paste()

void LabelTrack::Paste ( double  t,
const Track src 
)
override

Definition at line 787 of file LabelTrack.cpp.

788{
789 bool bOk = src->TypeSwitch< bool >( [&](const LabelTrack *lt) {
790 double shiftAmt = lt->mClipLen > 0.0 ? lt->mClipLen : lt->GetEndTime();
791
792 ShiftLabelsOnInsert(shiftAmt, t);
793 PasteOver(t, src);
794
795 return true;
796 } );
797
798 if ( !bOk )
799 // THROW_INCONSISTENCY_EXCEPTION; // ?
800 (void)0;// intentionally do nothing
801}
void ShiftLabelsOnInsert(double length, double pt)
Definition: LabelTrack.cpp:226
bool PasteOver(double t, const Track *src)
Definition: LabelTrack.cpp:758
R TypeSwitch(const Functions &...functions)
Use this function rather than testing track type explicitly and making down-casts.
Definition: Track.h:832

References PasteOver(), ShiftLabelsOnInsert(), and Track::TypeSwitch().

Referenced by EffectRepeat::Process().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PasteInto()

Track::Holder LabelTrack::PasteInto ( AudacityProject ) const
overridevirtual

Find or create the destination track for a paste, maybe in a different project.

Returns
A smart pointer to the track; its use_count() can tell whether it is new

Implements Track.

Definition at line 113 of file LabelTrack.cpp.

114{
115 auto pNewTrack = std::make_shared<LabelTrack>();
116 pNewTrack->Init(*this);
117 pNewTrack->Paste(0.0, this);
118 return pNewTrack;
119}

◆ PasteOver()

bool LabelTrack::PasteOver ( double  t,
const Track src 
)

Definition at line 758 of file LabelTrack.cpp.

759{
760 auto result = src->TypeSwitch< bool >( [&](const LabelTrack *sl) {
761 int len = mLabels.size();
762 int pos = 0;
763
764 while (pos < len && mLabels[pos].getT0() < t)
765 pos++;
766
767 for (auto &labelStruct: sl->mLabels) {
768 LabelStruct l {
769 labelStruct.selectedRegion,
770 labelStruct.getT0() + t,
771 labelStruct.getT1() + t,
772 labelStruct.title
773 };
774 mLabels.insert(mLabels.begin() + pos++, l);
775 }
776
777 return true;
778 } );
779
780 if (! result )
781 // THROW_INCONSISTENCY_EXCEPTION; // ?
782 (void)0;// intentionally do nothing
783
784 return result;
785}

References mLabels, LabelStruct::selectedRegion, and Track::TypeSwitch().

Referenced by Paste().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Repeat()

bool LabelTrack::Repeat ( double  t0,
double  t1,
int  n 
)

Definition at line 804 of file LabelTrack.cpp.

805{
806 // Sanity-check the arguments
807 if (n < 0 || t1 < t0)
808 return false;
809
810 double tLen = t1 - t0;
811
812 // Insert space for the repetitions
813 ShiftLabelsOnInsert(tLen * n, t1);
814
815 // mLabels may resize as we iterate, so use subscripting
816 for (unsigned int i = 0; i < mLabels.size(); ++i)
817 {
819 mLabels[i].RegionRelation(t0, t1, this);
820 if (relation == LabelStruct::SURROUNDS_LABEL)
821 {
822 // Label is completely inside the selection; duplicate it in each
823 // repeat interval
824 unsigned int pos = i; // running label insertion position in mLabels
825
826 for (int j = 1; j <= n; j++)
827 {
828 const LabelStruct &label = mLabels[i];
829 LabelStruct l {
830 label.selectedRegion,
831 label.getT0() + j * tLen,
832 label.getT1() + j * tLen,
833 label.title
834 };
835
836 // Figure out where to insert
837 while (pos < mLabels.size() &&
838 mLabels[pos].getT0() < l.getT0())
839 pos++;
840 mLabels.insert(mLabels.begin() + pos, l);
841 }
842 }
843 else if (relation == LabelStruct::BEGINS_IN_LABEL)
844 {
845 // Label ends inside the selection; ShiftLabelsOnInsert() hasn't touched
846 // it, and we need to extend it through to the last repeat interval
847 mLabels[i].selectedRegion.moveT1(n * tLen);
848 }
849
850 // Other cases have already been handled by ShiftLabelsOnInsert()
851 }
852
853 return true;
854}
TranslatableString label
Definition: TagsEditor.cpp:164

References LabelStruct::BEGINS_IN_LABEL, label, mLabels, ShiftLabelsOnInsert(), and LabelStruct::SURROUNDS_LABEL.

Referenced by EffectRepeat::Process().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ScaleLabels()

void LabelTrack::ScaleLabels ( double  b,
double  e,
double  change 
)

Definition at line 254 of file LabelTrack.cpp.

255{
256 for (auto &labelStruct: mLabels) {
257 labelStruct.selectedRegion.setTimes(
258 AdjustTimeStampOnScale(labelStruct.getT0(), b, e, change),
259 AdjustTimeStampOnScale(labelStruct.getT1(), b, e, change));
260 }
261}
double AdjustTimeStampOnScale(double t, double b, double e, double change)
Definition: LabelTrack.cpp:263

References AdjustTimeStampOnScale(), and mLabels.

Here is the call graph for this function:

◆ SetLabel()

void LabelTrack::SetLabel ( size_t  iLabel,
const LabelStruct newLabel 
)

Definition at line 158 of file LabelTrack.cpp.

159{
160 if( iLabel >= mLabels.size() ) {
161 wxASSERT( false );
162 mLabels.resize( iLabel + 1 );
163 }
164 mLabels[ iLabel ] = newLabel;
165}

References mLabels.

◆ SetOffset()

void LabelTrack::SetOffset ( double  dOffset)
overridevirtual

Reimplemented from Track.

Definition at line 171 of file LabelTrack.cpp.

172{
173 for (auto &labelStruct: mLabels)
174 labelStruct.selectedRegion.move(dOffset);
175}

References mLabels.

Referenced by Effect::ModifiedAnalysisTrack::ModifiedAnalysisTrack().

Here is the caller graph for this function:

◆ SetSelected()

void LabelTrack::SetSelected ( bool  s)
overridevirtual

Reimplemented from Track.

Definition at line 324 of file LabelTrack.cpp.

325{
326 bool selected = GetSelected();
328 if ( selected != GetSelected() )
330 this->SharedPointer<LabelTrack>(), {}, -1, -1 });
331}
bool GetSelected() const
Definition: Track.h:469
virtual void SetSelected(bool s)
Definition: Track.cpp:87

References Track::GetSelected(), Observer::Publisher< struct LabelTrackEvent >::Publish(), LabelTrackEvent::Selection, and Track::SetSelected().

Here is the call graph for this function:

◆ ShiftLabelsOnInsert()

void LabelTrack::ShiftLabelsOnInsert ( double  length,
double  pt 
)

Definition at line 226 of file LabelTrack.cpp.

227{
228 for (auto &labelStruct: mLabels) {
230 labelStruct.RegionRelation(pt, pt, this);
231
232 if (relation == LabelStruct::BEFORE_LABEL)
233 labelStruct.selectedRegion.move(length);
234 else if (relation == LabelStruct::WITHIN_LABEL)
235 labelStruct.selectedRegion.moveT1(length);
236 }
237}

References LabelStruct::BEFORE_LABEL, mLabels, and LabelStruct::WITHIN_LABEL.

Referenced by anonymous_namespace{EditMenus.cpp}::OnPaste(), Paste(), Repeat(), and SyncLockAdjust().

Here is the caller graph for this function:

◆ Silence()

void LabelTrack::Silence ( double  t0,
double  t1 
)
override

Definition at line 874 of file LabelTrack.cpp.

875{
876 int len = mLabels.size();
877
878 // mLabels may resize as we iterate, so use subscripting
879 for (int i = 0; i < len; ++i) {
881 mLabels[i].RegionRelation(t0, t1, this);
882 if (relation == LabelStruct::WITHIN_LABEL)
883 {
884 // Split label around the selection
885 const LabelStruct &label = mLabels[i];
886 LabelStruct l {
887 label.selectedRegion,
888 t1,
889 label.getT1(),
890 label.title
891 };
892
893 mLabels[i].selectedRegion.setT1(t0);
894
895 // This might not be the right place to insert, but we sort at the end
896 ++i;
897 mLabels.insert(mLabels.begin() + i, l);
898 }
899 else if (relation == LabelStruct::ENDS_IN_LABEL)
900 {
901 // Beginning of label to selection end
902 mLabels[i].selectedRegion.setT0(t1);
903 }
904 else if (relation == LabelStruct::BEGINS_IN_LABEL)
905 {
906 // End of label to selection beginning
907 mLabels[i].selectedRegion.setT1(t0);
908 }
909 else if (relation == LabelStruct::SURROUNDS_LABEL)
910 {
911 DeleteLabel( i );
912 len--;
913 i--;
914 }
915 }
916
917 SortLabels();
918}

References LabelStruct::BEGINS_IN_LABEL, DeleteLabel(), LabelStruct::ENDS_IN_LABEL, label, mLabels, SortLabels(), LabelStruct::SURROUNDS_LABEL, and LabelStruct::WITHIN_LABEL.

Here is the call graph for this function:

◆ SortLabels()

void LabelTrack::SortLabels ( )

Sorts the labels in order of their starting times. This function is called often (whilst dragging a label) We expect them to be very nearly in order, so insertion sort (with a linear search) is a reasonable choice.

Definition at line 978 of file LabelTrack.cpp.

979{
980 const auto begin = mLabels.begin();
981 const auto nn = (int)mLabels.size();
982 int i = 1;
983 while (true)
984 {
985 // Find the next disorder
986 while (i < nn && mLabels[i - 1].getT0() <= mLabels[i].getT0())
987 ++i;
988 if (i >= nn)
989 break;
990
991 // Where must element i sink to? At most i - 1, maybe less
992 int j = i - 2;
993 while( (j >= 0) && (mLabels[j].getT0() > mLabels[i].getT0()) )
994 --j;
995 ++j;
996
997 // Now fix the disorder
998 std::rotate(
999 begin + j,
1000 begin + i,
1001 begin + i + 1
1002 );
1003
1004 // Let listeners update their stored indices
1006 this->SharedPointer<LabelTrack>(), mLabels[j].title, i, j });
1007 }
1008}
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:150

References PackedArray::begin(), mLabels, LabelTrackEvent::Permutation, and Observer::Publisher< struct LabelTrackEvent >::Publish().

Referenced by ChangeLabelsOnReverse(), Import(), Silence(), and WarpLabels().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SyncLockAdjust()

void LabelTrack::SyncLockAdjust ( double  oldT1,
double  newT1 
)
overridevirtual

Reimplemented from Track.

Definition at line 856 of file LabelTrack.cpp.

857{
858 if (newT1 > oldT1) {
859 // Insert space within the track
860
861 if (oldT1 > GetEndTime())
862 return;
863
864 //Clear(oldT1, newT1);
865 ShiftLabelsOnInsert(newT1 - oldT1, oldT1);
866 }
867 else if (newT1 < oldT1) {
868 // Remove from the track
869 Clear(newT1, oldT1);
870 }
871}
double GetEndTime() const override
Definition: LabelTrack.cpp:346

References Clear(), GetEndTime(), and ShiftLabelsOnInsert().

Here is the call graph for this function:

◆ WarpLabels()

void LabelTrack::WarpLabels ( const TimeWarper warper)

Definition at line 282 of file LabelTrack.cpp.

282 {
283 for (auto &labelStruct: mLabels) {
284 labelStruct.selectedRegion.setTimes(
285 warper.Warp(labelStruct.getT0()),
286 warper.Warp(labelStruct.getT1()));
287 }
288
289 // This should not be needed, assuming the warper is nondecreasing, but
290 // let's not assume too much.
291 SortLabels();
292}
virtual double Warp(double originalTime) const =0

References mLabels, SortLabels(), and TimeWarper::Warp().

Referenced by EffectChangeSpeed::ProcessLabelTrack(), and EffectSBSMS::ProcessLabelTrack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteXML()

void LabelTrack::WriteXML ( XMLWriter xmlFile) const
overridevirtual

Implements Track.

Definition at line 662 of file LabelTrack.cpp.

664{
665 int len = mLabels.size();
666
667 xmlFile.StartTag(wxT("labeltrack"));
668 this->Track::WriteCommonXMLAttributes( xmlFile );
669 xmlFile.WriteAttr(wxT("numlabels"), len);
670
671 for (auto &labelStruct: mLabels) {
672 xmlFile.StartTag(wxT("label"));
673 labelStruct.getSelectedRegion()
674 .WriteXMLAttributes(xmlFile, "t", "t1");
675 // PRL: to do: write other selection fields
676 xmlFile.WriteAttr(wxT("title"), labelStruct.title);
677 xmlFile.EndTag(wxT("label"));
678 }
679
680 xmlFile.EndTag(wxT("labeltrack"));
681}
void WriteCommonXMLAttributes(XMLWriter &xmlFile, bool includeNameAndSelected=true) const
Definition: Track.cpp:1274
virtual void StartTag(const wxString &name)
Definition: XMLWriter.cpp:79
void WriteAttr(const wxString &name, const Identifier &value)
Definition: XMLWriter.h:37
virtual void EndTag(const wxString &name)
Definition: XMLWriter.cpp:102

References Track::WriteCommonXMLAttributes(), and wxT().

Here is the call graph for this function:

Member Data Documentation

◆ mClipLen

double LabelTrack::mClipLen
private

Definition at line 195 of file LabelTrack.h.

◆ miLastLabel

int LabelTrack::miLastLabel
private

Definition at line 197 of file LabelTrack.h.

Referenced by FindNextLabel(), and FindPrevLabel().

◆ mLabels

LabelArray LabelTrack::mLabels
private

The documentation for this class was generated from the following files: