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 Member Functions

 LabelTrack ()
 
 LabelTrack (const LabelTrack &orig)
 
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)
 
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...
 

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
 
- 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 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 86 of file LabelTrack.h.

Member Typedef Documentation

◆ Holder

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

Definition at line 123 of file LabelTrack.h.

Constructor & Destructor Documentation

◆ LabelTrack() [1/2]

LabelTrack::LabelTrack ( )

Definition at line 84 of file LabelTrack.cpp.

84 :
85 Track(),
86 mClipLen(0.0),
87 miLastLabel(-1)
88{
89}
double mClipLen
Definition: LabelTrack.h:197
int miLastLabel
Definition: LabelTrack.h:199
Track()
Definition: Track.cpp:44

◆ LabelTrack() [2/2]

LabelTrack::LabelTrack ( const LabelTrack orig)

Definition at line 91 of file LabelTrack.cpp.

91 :
92 Track(orig),
93 mClipLen(0.0)
94{
95 for (auto &original: orig.mLabels) {
96 LabelStruct l { original.selectedRegion, original.title };
97 mLabels.push_back(l);
98 }
99}
A LabelStruct holds information for ONE label in a LabelTrack.
Definition: LabelTrack.h:31
SelectedRegion selectedRegion
Definition: LabelTrack.h:71
LabelArray mLabels
Definition: LabelTrack.h:194

References mLabels, and LabelStruct::selectedRegion.

◆ ~LabelTrack()

LabelTrack::~LabelTrack ( )
virtual

Definition at line 172 of file LabelTrack.cpp.

173{
174}

Member Function Documentation

◆ AddLabel()

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

Definition at line 950 of file LabelTrack.cpp.

952{
953 LabelStruct l { selectedRegion, title };
954
955 int len = mLabels.size();
956 int pos = 0;
957
958 while (pos < len && mLabels[pos].getT0() < selectedRegion.t0())
959 pos++;
960
961 mLabels.insert(mLabels.begin() + pos, l);
962
963 LabelTrackEvent evt{
964 EVT_LABELTRACK_ADDITION, SharedPointer<LabelTrack>(), title, -1, pos
965 };
966 ProcessEvent( evt );
967
968 return pos;
969}
static const auto title

References mLabels, 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 268 of file LabelTrack.cpp.

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

Referenced by ScaleLabels().

Here is the caller graph for this function:

◆ ChangeLabelsOnReverse()

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

Definition at line 244 of file LabelTrack.cpp.

245{
246 for (auto &labelStruct: mLabels) {
247 if (labelStruct.RegionRelation(b, e, this) ==
249 {
250 double aux = b + (e - labelStruct.getT1());
251 labelStruct.selectedRegion.setTimes(
252 aux,
253 e - (labelStruct.getT0() - b));
254 }
255 }
256 SortLabels();
257}
@ SURROUNDS_LABEL
Definition: LabelTrack.h:57
void SortLabels()
Definition: LabelTrack.cpp:988

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

Here is the call graph for this function:

◆ ClassTypeInfo()

auto LabelTrack::ClassTypeInfo ( )
static

Definition at line 113 of file LabelTrack.cpp.

114{
115 return typeInfo();
116}
static const Track::TypeInfo & typeInfo()
Definition: LabelTrack.cpp:101

References typeInfo().

Here is the call graph for this function:

◆ Clear()

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

Definition at line 182 of file LabelTrack.cpp.

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

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

Referenced by Cut(), EditActions::Handler::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 370 of file LabelTrack.cpp.

371{
372 return std::make_shared<LabelTrack>( *this );
373}

◆ Copy()

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

Definition at line 712 of file LabelTrack.cpp.

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

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 79 of file LabelTrack.cpp.

80{
81 return Create(trackList, trackList.MakeUniqueTrackName(GetDefaultName()));
82}
static LabelTrack * Create(TrackList &trackList, const wxString &name)
Create a new LabelTrack with specified name and append it to the trackList.
Definition: LabelTrack.cpp:71
static wxString GetDefaultName()
Definition: LabelTrack.cpp:58
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:524

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 71 of file LabelTrack.cpp.

72{
73 auto track = std::make_shared<LabelTrack>();
74 track->SetName(name);
75 trackList.Add(track);
76 return track.get();
77}
const TranslatableString name
Definition: Distortion.cpp:82
TrackKind * Add(const std::shared_ptr< TrackKind > &t)
Definition: Track.h:1556

References TrackList::Add(), and name.

Referenced by Effect::AddedAnalysisTrack::AddedAnalysisTrack(), Create(), anonymous_namespace{LabelMenus.cpp}::DoAddLabel(), LabelEditActions::Handler::OnNewLabelTrack(), and LabelEditActions::Handler::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 689 of file LabelTrack.cpp.

690{
691 auto tmp = Copy(t0, t1);
692
693 Clear(t0, t1);
694
695 return tmp;
696}
Track::Holder Copy(double t0, double t1, bool forClipboard=true) const override
Definition: LabelTrack.cpp:712
void Clear(double t0, double t1) override
Definition: LabelTrack.cpp:182

References Clear(), and Copy().

Here is the call graph for this function:

◆ DeleteLabel()

void LabelTrack::DeleteLabel ( int  index)

Definition at line 971 of file LabelTrack.cpp.

972{
973 wxASSERT((index < (int)mLabels.size()));
974 auto iter = mLabels.begin() + index;
975 const auto title = iter->title;
976 mLabels.erase(iter);
977
978 LabelTrackEvent evt{
979 EVT_LABELTRACK_DELETION, SharedPointer<LabelTrack>(), title, index, -1
980 };
981 ProcessEvent( evt );
982}

References mLabels, and title.

Referenced by Clear(), and Silence().

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 567 of file LabelTrack.cpp.

568{
569 // PRL: to do: export other selection fields
570 for (auto &labelStruct: mLabels)
571 labelStruct.Export(f);
572}

References mLabels.

◆ FindNextLabel()

int LabelTrack::FindNextLabel ( const SelectedRegion currentSelection)

Definition at line 1042 of file LabelTrack.cpp.

1043{
1044 int i = -1;
1045
1046 if (!mLabels.empty()) {
1047 int len = (int) mLabels.size();
1048 if (miLastLabel >= 0 && miLastLabel + 1 < len
1049 && currentRegion.t0() == mLabels[miLastLabel].getT0()
1050 && currentRegion.t0() == mLabels[miLastLabel + 1].getT0() ) {
1051 i = miLastLabel + 1;
1052 }
1053 else {
1054 i = 0;
1055 if (currentRegion.t0() < mLabels[len - 1].getT0()) {
1056 while (i < len &&
1057 mLabels[i].getT0() <= currentRegion.t0()) {
1058 i++;
1059 }
1060 }
1061 }
1062 }
1063
1064 miLastLabel = i;
1065 return i;
1066}

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 1068 of file LabelTrack.cpp.

1069{
1070 int i = -1;
1071
1072 if (!mLabels.empty()) {
1073 int len = (int) mLabels.size();
1074 if (miLastLabel > 0 && miLastLabel < len
1075 && currentRegion.t0() == mLabels[miLastLabel].getT0()
1076 && currentRegion.t0() == mLabels[miLastLabel - 1].getT0() ) {
1077 i = miLastLabel - 1;
1078 }
1079 else {
1080 i = len - 1;
1081 if (currentRegion.t0() > mLabels[0].getT0()) {
1082 while (i >=0 &&
1083 mLabels[i].getT0() >= currentRegion.t0()) {
1084 i--;
1085 }
1086 }
1087 }
1088 }
1089
1090 miLastLabel = i;
1091 return i;
1092}

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 58 of file LabelTrack.cpp.

59{
60 return _("Labels");
61}
#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 354 of file LabelTrack.cpp.

355{
356 //we need to scan through all the labels, because the last
357 //label might not have the right-most end (if there is overlap).
358 if (mLabels.empty())
359 return 0.0;
360
361 double end = 0.0;
362 for (auto &labelStruct: mLabels) {
363 const double t1 = labelStruct.getT1();
364 if(t1 > end)
365 end = t1;
366 }
367 return end;
368}
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for, if Traits<Type>::iterated_type is defined.
Definition: PackedArray.h:126

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 153 of file LabelTrack.cpp.

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

◆ 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 158 of file LabelTrack.cpp.

159{
160 return DoMakeIntervals<Intervals>(*this);
161}

◆ GetLabel()

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

Definition at line 945 of file LabelTrack.cpp.

946{
947 return &mLabels[index];
948}

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 148 of file LabelTrack.h.

148{ 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 940 of file LabelTrack.cpp.

941{
942 return mLabels.size();
943}

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 341 of file LabelTrack.cpp.

342{
343 return mOffset;
344}
double mOffset
Definition: Track.h:440

References Track::mOffset.

◆ GetStartTime()

double LabelTrack::GetStartTime ( ) const
overridevirtual

Implements Track.

Definition at line 346 of file LabelTrack.cpp.

347{
348 if (mLabels.empty())
349 return 0.0;
350 else
351 return mLabels[0].getT0();
352}

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 1023 of file LabelTrack.cpp.

1024{
1025 bool firstLabel = true;
1026 wxString retVal;
1027
1028 for (auto &labelStruct: mLabels) {
1029 if (labelStruct.getT0() >= t0 &&
1030 labelStruct.getT1() <= t1)
1031 {
1032 if (!firstLabel)
1033 retVal += '\t';
1034 firstLabel = false;
1035 retVal += labelStruct.title;
1036 }
1037 }
1038
1039 return retVal;
1040}

References mLabels.

◆ GetTypeInfo()

auto LabelTrack::GetTypeInfo ( ) const
overridevirtual

Implements Track.

Definition at line 108 of file LabelTrack.cpp.

109{
110 return typeInfo();
111}

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 660 of file LabelTrack.cpp.

661{
662 if (tag == "label")
663 return this;
664 else
665 return NULL;
666}

◆ HandleXMLTag()

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

Implements XMLTagHandler.

Definition at line 599 of file LabelTrack.cpp.

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

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

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 575 of file LabelTrack.cpp.

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

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 926 of file LabelTrack.cpp.

927{
928 for (auto &labelStruct: mLabels) {
929 double t0 = labelStruct.getT0();
930 double t1 = labelStruct.getT1();
931 if (t0 >= t)
932 t0 += len;
933
934 if (t1 >= t)
935 t1 += len;
936 labelStruct.selectedRegion.setTimes(t0, t1);
937 }
938}

References mLabels.

◆ MakeInterval() [1/2]

auto LabelTrack::MakeInterval ( size_t  index)

Definition at line 139 of file LabelTrack.cpp.

140{
141 return DoMakeInterval<Interval>(mLabels[index], index);
142}

◆ MakeInterval() [2/2]

auto LabelTrack::MakeInterval ( size_t  index) const

Definition at line 134 of file LabelTrack.cpp.

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

Referenced by DoMakeIntervals().

Here is the caller graph for this function:

◆ New()

LabelTrack * LabelTrack::New ( AudacityProject project)
static

Definition at line 63 of file LabelTrack.cpp.

64{
65 auto &tracks = TrackList::Get( project );
66 auto result = tracks.Add(std::make_shared<LabelTrack>());
67 result->AttachedTrackObjects::BuildAll();
68 return result;
69}
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:467

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 793 of file LabelTrack.cpp.

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

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 118 of file LabelTrack.cpp.

119{
120 auto pNewTrack = std::make_shared<LabelTrack>();
121 pNewTrack->Init(*this);
122 pNewTrack->Paste(0.0, this);
123 return pNewTrack;
124}

◆ PasteOver()

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

Definition at line 764 of file LabelTrack.cpp.

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

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 810 of file LabelTrack.cpp.

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

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 259 of file LabelTrack.cpp.

260{
261 for (auto &labelStruct: mLabels) {
262 labelStruct.selectedRegion.setTimes(
263 AdjustTimeStampOnScale(labelStruct.getT0(), b, e, change),
264 AdjustTimeStampOnScale(labelStruct.getT1(), b, e, change));
265 }
266}
double AdjustTimeStampOnScale(double t, double b, double e, double change)
Definition: LabelTrack.cpp:268

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 163 of file LabelTrack.cpp.

164{
165 if( iLabel >= mLabels.size() ) {
166 wxASSERT( false );
167 mLabels.resize( iLabel + 1 );
168 }
169 mLabels[ iLabel ] = newLabel;
170}

References mLabels.

◆ SetOffset()

void LabelTrack::SetOffset ( double  dOffset)
overridevirtual

Reimplemented from Track.

Definition at line 176 of file LabelTrack.cpp.

177{
178 for (auto &labelStruct: mLabels)
179 labelStruct.selectedRegion.move(dOffset);
180}

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 329 of file LabelTrack.cpp.

330{
331 bool selected = GetSelected();
333 if ( selected != GetSelected() ) {
334 LabelTrackEvent evt{
335 EVT_LABELTRACK_SELECTION, SharedPointer<LabelTrack>(), {}, -1, -1
336 };
337 ProcessEvent( evt );
338 }
339}
bool GetSelected() const
Definition: Track.h:461
virtual void SetSelected(bool s)
Definition: Track.cpp:88

References Track::GetSelected(), and Track::SetSelected().

Here is the call graph for this function:

◆ ShiftLabelsOnInsert()

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

Definition at line 231 of file LabelTrack.cpp.

232{
233 for (auto &labelStruct: mLabels) {
235 labelStruct.RegionRelation(pt, pt, this);
236
237 if (relation == LabelStruct::BEFORE_LABEL)
238 labelStruct.selectedRegion.move(length);
239 else if (relation == LabelStruct::WITHIN_LABEL)
240 labelStruct.selectedRegion.moveT1(length);
241 }
242}

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

Referenced by EditActions::Handler::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 880 of file LabelTrack.cpp.

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

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 988 of file LabelTrack.cpp.

989{
990 const auto begin = mLabels.begin();
991 const auto nn = (int)mLabels.size();
992 int i = 1;
993 while (true)
994 {
995 // Find the next disorder
996 while (i < nn && mLabels[i - 1].getT0() <= mLabels[i].getT0())
997 ++i;
998 if (i >= nn)
999 break;
1000
1001 // Where must element i sink to? At most i - 1, maybe less
1002 int j = i - 2;
1003 while( (j >= 0) && (mLabels[j].getT0() > mLabels[i].getT0()) )
1004 --j;
1005 ++j;
1006
1007 // Now fix the disorder
1008 std::rotate(
1009 begin + j,
1010 begin + i,
1011 begin + i + 1
1012 );
1013
1014 // Let listeners update their stored indices
1015 LabelTrackEvent evt{
1016 EVT_LABELTRACK_PERMUTED, SharedPointer<LabelTrack>(),
1017 mLabels[j].title, i, j
1018 };
1019 ProcessEvent( evt );
1020 }
1021}
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for, if Traits<Type>::iterated_type is defined.
Definition: PackedArray.h:112

References PackedArray::begin(), and mLabels.

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 862 of file LabelTrack.cpp.

863{
864 if (newT1 > oldT1) {
865 // Insert space within the track
866
867 if (oldT1 > GetEndTime())
868 return;
869
870 //Clear(oldT1, newT1);
871 ShiftLabelsOnInsert(newT1 - oldT1, oldT1);
872 }
873 else if (newT1 < oldT1) {
874 // Remove from the track
875 Clear(newT1, oldT1);
876 }
877}
double GetEndTime() const override
Definition: LabelTrack.cpp:354

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

Here is the call graph for this function:

◆ WarpLabels()

void LabelTrack::WarpLabels ( const TimeWarper warper)

Definition at line 287 of file LabelTrack.cpp.

287 {
288 for (auto &labelStruct: mLabels) {
289 labelStruct.selectedRegion.setTimes(
290 warper.Warp(labelStruct.getT0()),
291 warper.Warp(labelStruct.getT1()));
292 }
293
294 // This should not be needed, assuming the warper is nondecreasing, but
295 // let's not assume too much.
296 SortLabels();
297}
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 668 of file LabelTrack.cpp.

670{
671 int len = mLabels.size();
672
673 xmlFile.StartTag(wxT("labeltrack"));
674 this->Track::WriteCommonXMLAttributes( xmlFile );
675 xmlFile.WriteAttr(wxT("numlabels"), len);
676
677 for (auto &labelStruct: mLabels) {
678 xmlFile.StartTag(wxT("label"));
679 labelStruct.getSelectedRegion()
680 .WriteXMLAttributes(xmlFile, "t", "t1");
681 // PRL: to do: write other selection fields
682 xmlFile.WriteAttr(wxT("title"), labelStruct.title);
683 xmlFile.EndTag(wxT("label"));
684 }
685
686 xmlFile.EndTag(wxT("labeltrack"));
687}
void WriteCommonXMLAttributes(XMLWriter &xmlFile, bool includeNameAndSelected=true) const
Definition: Track.cpp:1251
virtual void StartTag(const wxString &name)
Definition: XMLWriter.cpp:80
void WriteAttr(const wxString &name, const Identifier &value)
Definition: XMLWriter.h:37
virtual void EndTag(const wxString &name)
Definition: XMLWriter.cpp:103

References Track::WriteCommonXMLAttributes().

Here is the call graph for this function:

Member Data Documentation

◆ mClipLen

double LabelTrack::mClipLen
private

Definition at line 197 of file LabelTrack.h.

◆ miLastLabel

int LabelTrack::miLastLabel
private

Definition at line 199 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: