Audacity  3.0.3
Public Member Functions | Static Public Attributes | Private Attributes | Friends | List of all members
SelectedRegion Class Reference

Defines a selected portion of a project. More...

#include <SelectedRegion.h>

Public Member Functions

 SelectedRegion ()
 
 SelectedRegion (double t0, double t1)
 
 SelectedRegion (const SelectedRegion &x)
 
SelectedRegionoperator= (const SelectedRegion &x)
 
double t0 () const
 
double t1 () const
 
double duration () const
 
bool isPoint () const
 
bool setT0 (double t, bool maySwap=true)
 
bool setT1 (double t, bool maySwap=true)
 
bool setTimes (double t0, double t1)
 
bool moveT0 (double delta, bool maySwap=true)
 
bool moveT1 (double delta, bool maySwap=true)
 
void move (double delta)
 
void collapseToT0 ()
 
void collapseToT1 ()
 
void WriteXMLAttributes (XMLWriter &xmlFile, const wxChar *legacyT0Name=sDefaultT0Name, const wxChar *legacyT1Name=sDefaultT1Name) const
 
bool HandleXMLAttribute (const wxChar *attr, const wxChar *value, const wxChar *legacyT0Name=sDefaultT0Name, const wxChar *legacyT1Name=sDefaultT1Name)
 
bool ensureOrdering ()
 

Static Public Attributes

static const int UndefinedFrequency = -1
 
static const wxChar * sDefaultT0Name = wxT("selStart")
 
static const wxChar * sDefaultT1Name = wxT("selEnd")
 

Private Attributes

double mT0
 
double mT1
 

Friends

bool operator== (const SelectedRegion &lhs, const SelectedRegion &rhs)
 

Detailed Description

Defines a selected portion of a project.

This includes starting and ending times, and other optional information such as a frequency range, but not the set of selected tracks.

Maintains the invariants that ending time is not less than starting time and that starting and ending frequencies, when both defined, are also correctly ordered.

Definition at line 38 of file SelectedRegion.h.

Constructor & Destructor Documentation

◆ SelectedRegion() [1/3]

SelectedRegion::SelectedRegion ( )
inline

Definition at line 46 of file SelectedRegion.h.

47  : mT0(0.0)
48  , mT1(0.0)
49 #ifdef EXPERIMENTAL_SPECTRAL_EDITING
50  , mF0(UndefinedFrequency)
51  , mF1(UndefinedFrequency)
52 #endif
53  {}

◆ SelectedRegion() [2/3]

SelectedRegion::SelectedRegion ( double  t0,
double  t1 
)
inline

Definition at line 55 of file SelectedRegion.h.

56  : mT0(t0)
57  , mT1(t1)
58 #ifdef EXPERIMENTAL_SPECTRAL_EDITING
59  , mF0(UndefinedFrequency)
60  , mF1(UndefinedFrequency)
61 #endif
62  { ensureOrdering(); }

◆ SelectedRegion() [3/3]

SelectedRegion::SelectedRegion ( const SelectedRegion x)
inline

Definition at line 70 of file SelectedRegion.h.

71  : mT0(x.mT0)
72  , mT1(x.mT1)
73 #ifdef EXPERIMENTAL_SPECTRAL_EDITING
74  , mF0(x.mF0)
75  , mF1(x.mF1)
76 #endif
77  {}

Member Function Documentation

◆ collapseToT0()

void SelectedRegion::collapseToT0 ( )
inline

Definition at line 160 of file SelectedRegion.h.

160 { mT1 = mT0; }

Referenced by NotifyingSelectedRegion::collapseToT0().

Here is the caller graph for this function:

◆ collapseToT1()

void SelectedRegion::collapseToT1 ( )
inline

Definition at line 162 of file SelectedRegion.h.

162 { mT0 = mT1; }

Referenced by NotifyingSelectedRegion::collapseToT1().

Here is the caller graph for this function:

◆ duration()

double SelectedRegion::duration ( ) const
inline

Definition at line 96 of file SelectedRegion.h.

96 { return mT1 - mT0; }

Referenced by NotifyingSelectedRegion::duration(), and LabelStruct::getDuration().

Here is the caller graph for this function:

◆ ensureOrdering()

bool SelectedRegion::ensureOrdering ( )
inline

Definition at line 226 of file SelectedRegion.h.

227  {
228  if (mT1 < mT0) {
229  const double t = mT1;
230  mT1 = mT0;
231  mT0 = t;
232  return true;
233  }
234  else
235  return false;
236  }

◆ HandleXMLAttribute()

bool SelectedRegion::HandleXMLAttribute ( const wxChar *  attr,
const wxChar *  value,
const wxChar *  legacyT0Name = sDefaultT0Name,
const wxChar *  legacyT1Name = sDefaultT1Name 
)

Definition at line 40 of file SelectedRegion.cpp.

43 {
44  typedef bool (SelectedRegion::*Setter)(double, bool);
45  Setter setter = 0;
46  if (!wxStrcmp(attr, legacyT0Name))
47  setter = &SelectedRegion::setT0;
48  else if (!wxStrcmp(attr, legacyT1Name))
49  setter = &SelectedRegion::setT1;
50 #ifdef EXPERIMENTAL_SPECTRAL_EDITING
51  else if (!wxStrcmp(attr, sDefaultF0Name))
52  setter = &SelectedRegion::setF0;
53  else if (!wxStrcmp(attr, sDefaultF1Name))
54  setter = &SelectedRegion::setF1;
55 #endif
56  else
57  return false;
58 
59  double dblValue;
60  if (!Internat::CompatibleToDouble(value, &dblValue))
61  return false;
62 
63  // False means don't flip time or frequency boundaries
64  (void)(this->*setter)(dblValue, false);
65  return true;
66 }

References Internat::CompatibleToDouble(), anonymous_namespace{SelectedRegion.cpp}::sDefaultF0Name, anonymous_namespace{SelectedRegion.cpp}::sDefaultF1Name, setT0(), and setT1().

Referenced by NotifyingSelectedRegion::HandleXMLAttribute(), and LabelTrack::HandleXMLTag().

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

◆ isPoint()

bool SelectedRegion::isPoint ( ) const
inline

Definition at line 97 of file SelectedRegion.h.

97 { return mT1 <= mT0; }

Referenced by ExportMultipleDialog::ExportMultipleByLabel(), and NotifyingSelectedRegion::isPoint().

Here is the caller graph for this function:

◆ move()

void SelectedRegion::move ( double  delta)
inline

Definition at line 155 of file SelectedRegion.h.

155  {
156  mT0 += delta;
157  mT1 += delta;
158  }

Referenced by NotifyingSelectedRegion::move().

Here is the caller graph for this function:

◆ moveT0()

bool SelectedRegion::moveT0 ( double  delta,
bool  maySwap = true 
)
inline

Definition at line 146 of file SelectedRegion.h.

146  {
147  return setT0(mT0 + delta, maySwap);
148  }

◆ moveT1()

bool SelectedRegion::moveT1 ( double  delta,
bool  maySwap = true 
)
inline

Definition at line 151 of file SelectedRegion.h.

151  {
152  return setT1(mT1 + delta, maySwap);
153  }

◆ operator=()

SelectedRegion& SelectedRegion::operator= ( const SelectedRegion x)
inline

Definition at line 79 of file SelectedRegion.h.

80  {
81  if (this != &x) {
82  mT0 = x.mT0;
83  mT1 = x.mT1;
84 #ifdef EXPERIMENTAL_SPECTRAL_EDITING
85  mF0 = x.mF0;
86  mF1 = x.mF1;
87 #endif
88  }
89  return *this;
90  }

References mT0, and mT1.

◆ setT0()

bool SelectedRegion::setT0 ( double  t,
bool  maySwap = true 
)
inline

Definition at line 115 of file SelectedRegion.h.

115  {
116  mT0 = t;
117  if (maySwap)
118  return ensureOrdering();
119  else {
120  if (mT1 < mT0)
121  mT1 = mT0;
122  return false;
123  }
124  }

Referenced by LabelStruct::AdjustEdge(), HandleXMLAttribute(), LabelDialog::OnChangeStime(), and NotifyingSelectedRegion::setT0().

Here is the caller graph for this function:

◆ setT1()

bool SelectedRegion::setT1 ( double  t,
bool  maySwap = true 
)
inline

Definition at line 127 of file SelectedRegion.h.

127  {
128  mT1 = t;
129  if (maySwap)
130  return ensureOrdering();
131  else {
132  if (mT1 < mT0)
133  mT0 = mT1;
134  return false;
135  }
136  }

Referenced by LabelStruct::AdjustEdge(), HandleXMLAttribute(), LabelDialog::OnChangeEtime(), and NotifyingSelectedRegion::setT1().

Here is the caller graph for this function:

◆ setTimes()

bool SelectedRegion::setTimes ( double  t0,
double  t1 
)
inline

Definition at line 139 of file SelectedRegion.h.

139  {
140  mT0 = t0;
141  mT1 = t1;
142  return ensureOrdering();
143  }

Referenced by LabelStruct::Import(), LabelStruct::LabelStruct(), LabelStruct::MoveLabel(), EffectUIHost::OnPlay(), and NotifyingSelectedRegion::setTimes().

Here is the caller graph for this function:

◆ t0()

double SelectedRegion::t0 ( ) const
inline

◆ t1()

double SelectedRegion::t1 ( ) const
inline

◆ WriteXMLAttributes()

void SelectedRegion::WriteXMLAttributes ( XMLWriter xmlFile,
const wxChar *  legacyT0Name = sDefaultT0Name,
const wxChar *  legacyT1Name = sDefaultT1Name 
) const

Definition at line 25 of file SelectedRegion.cpp.

29 {
30  xmlFile.WriteAttr(legacyT0Name, t0(), 10);
31  xmlFile.WriteAttr(legacyT1Name, t1(), 10);
32 #ifdef EXPERIMENTAL_SPECTRAL_EDITING
33  if (f0() >= 0)
34  xmlFile.WriteAttr(sDefaultF0Name, f0(), 10);
35  if (f1() >= 0)
36  xmlFile.WriteAttr(sDefaultF1Name, f1(), 10);
37 #endif
38 }

References anonymous_namespace{SelectedRegion.cpp}::sDefaultF0Name, and anonymous_namespace{SelectedRegion.cpp}::sDefaultF1Name.

Referenced by NotifyingSelectedRegion::WriteXMLAttributes().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator==

bool operator== ( const SelectedRegion lhs,
const SelectedRegion rhs 
)
friend

Definition at line 261 of file SelectedRegion.h.

263  {
264  return
265  lhs.mT0 == rhs.mT0
266  && lhs.mT1 == rhs.mT1
267 #ifdef EXPERIMENTAL_SPECTRAL_EDITING
268  && lhs.mF0 == rhs.mF0
269  && lhs.mF1 == rhs.mF1
270 #endif
271  ;
272  }

Member Data Documentation

◆ mT0

double SelectedRegion::mT0
private

Definition at line 274 of file SelectedRegion.h.

Referenced by operator=().

◆ mT1

double SelectedRegion::mT1
private

Definition at line 275 of file SelectedRegion.h.

Referenced by operator=().

◆ sDefaultT0Name

const wxChar * SelectedRegion::sDefaultT0Name = wxT("selStart")
static

Definition at line 209 of file SelectedRegion.h.

◆ sDefaultT1Name

const wxChar * SelectedRegion::sDefaultT1Name = wxT("selEnd")
static

Definition at line 210 of file SelectedRegion.h.

◆ UndefinedFrequency

const int SelectedRegion::UndefinedFrequency = -1
static

The documentation for this class was generated from the following files:
SelectedRegion::t1
double t1() const
Definition: SelectedRegion.h:95
SelectedRegion::UndefinedFrequency
static const int UndefinedFrequency
Definition: SelectedRegion.h:44
SelectedRegion::setT0
bool setT0(double t, bool maySwap=true)
Definition: SelectedRegion.h:115
anonymous_namespace{SelectedRegion.cpp}::sDefaultF1Name
const wxChar * sDefaultF1Name
Definition: SelectedRegion.cpp:22
SelectedRegion::ensureOrdering
bool ensureOrdering()
Definition: SelectedRegion.h:226
SelectedRegion::t0
double t0() const
Definition: SelectedRegion.h:94
anonymous_namespace{SelectedRegion.cpp}::sDefaultF0Name
const wxChar * sDefaultF0Name
Definition: SelectedRegion.cpp:21
XMLWriter::WriteAttr
void WriteAttr(const wxString &name, const Identifier &value)
Definition: XMLWriter.h:34
SelectedRegion::mT1
double mT1
Definition: SelectedRegion.h:275
SelectedRegion::setT1
bool setT1(double t, bool maySwap=true)
Definition: SelectedRegion.h:127
SelectedRegion::mT0
double mT0
Definition: SelectedRegion.h:274
Internat::CompatibleToDouble
static bool CompatibleToDouble(const wxString &stringToConvert, double *result)
Convert a string to a number.
Definition: Internat.cpp:139
SelectedRegion
Defines a selected portion of a project.
Definition: SelectedRegion.h:38