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, 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...
 

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,
ProtectedCreationArg &&  a 
)

Definition at line 91 of file LabelTrack.cpp.

92 : Track(orig, std::move(a))
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 952 of file LabelTrack.cpp.

954{
955 LabelStruct l { selectedRegion, title };
956
957 int len = mLabels.size();
958 int pos = 0;
959
960 while (pos < len && mLabels[pos].getT0() < selectedRegion.t0())
961 pos++;
962
963 mLabels.insert(mLabels.begin() + pos, l);
964
965 LabelTrackEvent evt{
966 EVT_LABELTRACK_ADDITION, SharedPointer<LabelTrack>(), title, -1, pos
967 };
968 ProcessEvent( evt );
969
970 return pos;
971}
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:990

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:973

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 auto result = std::make_shared<LabelTrack>(*this, ProtectedCreationArg{});
373 result->Init(*this);
374 return result;
375}

◆ Copy()

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

Definition at line 714 of file LabelTrack.cpp.

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

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

692{
693 auto tmp = Copy(t0, t1);
694
695 Clear(t0, t1);
696
697 return tmp;
698}
Track::Holder Copy(double t0, double t1, bool forClipboard=true) const override
Definition: LabelTrack.cpp:714
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 973 of file LabelTrack.cpp.

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

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

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

References mLabels.

◆ FindNextLabel()

int LabelTrack::FindNextLabel ( const SelectedRegion currentSelection)

Definition at line 1044 of file LabelTrack.cpp.

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

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

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

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

948{
949 return &mLabels[index];
950}

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

943{
944 return mLabels.size();
945}

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:447

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

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

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

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

◆ HandleXMLTag()

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

Implements XMLTagHandler.

Definition at line 601 of file LabelTrack.cpp.

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

578{
579 int lines = in.GetLineCount();
580
581 mLabels.clear();
582 mLabels.reserve(lines);
583
584 //Currently, we expect a tag file to have two values and a label
585 //on each line. If the second token is not a number, we treat
586 //it as a single-value label.
587 bool error = false;
588 for (int index = 0; index < lines;) {
589 try {
590 // Let LabelStruct::Import advance index
591 LabelStruct l { LabelStruct::Import(in, index) };
592 mLabels.push_back(l);
593 }
594 catch(const LabelStruct::BadFormatException&) { error = true; }
595 }
596 if (error)
597 ::AudacityMessageBox( XO("One or more saved labels could not be read.") );
598 SortLabels();
599}
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:404

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

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

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

796{
797 bool bOk = src->TypeSwitch< bool >( [&](const LabelTrack *lt) {
798 double shiftAmt = lt->mClipLen > 0.0 ? lt->mClipLen : lt->GetEndTime();
799
800 ShiftLabelsOnInsert(shiftAmt, t);
801 PasteOver(t, src);
802
803 return true;
804 } );
805
806 if ( !bOk )
807 // THROW_INCONSISTENCY_EXCEPTION; // ?
808 (void)0;// intentionally do nothing
809}
void ShiftLabelsOnInsert(double length, double pt)
Definition: LabelTrack.cpp:231
bool PasteOver(double t, const Track *src)
Definition: LabelTrack.cpp:766
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 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 766 of file LabelTrack.cpp.

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

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

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

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

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

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

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

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

865{
866 if (newT1 > oldT1) {
867 // Insert space within the track
868
869 if (oldT1 > GetEndTime())
870 return;
871
872 //Clear(oldT1, newT1);
873 ShiftLabelsOnInsert(newT1 - oldT1, oldT1);
874 }
875 else if (newT1 < oldT1) {
876 // Remove from the track
877 Clear(newT1, oldT1);
878 }
879}
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 670 of file LabelTrack.cpp.

672{
673 int len = mLabels.size();
674
675 xmlFile.StartTag(wxT("labeltrack"));
676 this->Track::WriteCommonXMLAttributes( xmlFile );
677 xmlFile.WriteAttr(wxT("numlabels"), len);
678
679 for (auto &labelStruct: mLabels) {
680 xmlFile.StartTag(wxT("label"));
681 labelStruct.getSelectedRegion()
682 .WriteXMLAttributes(xmlFile, "t", "t1");
683 // PRL: to do: write other selection fields
684 xmlFile.WriteAttr(wxT("title"), labelStruct.title);
685 xmlFile.EndTag(wxT("label"));
686 }
687
688 xmlFile.EndTag(wxT("labeltrack"));
689}
void WriteCommonXMLAttributes(XMLWriter &xmlFile, bool includeNameAndSelected=true) const
Definition: Track.cpp:1274
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(), and wxT().

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: