Audacity  3.0.3
Functions
anonymous_namespace{TimeTrackView.cpp} Namespace Reference

Functions

void DrawHorzRulerAndCurve (TrackPanelDrawingContext &context, const wxRect &r, const TimeTrack &track, Ruler &ruler)
 
void DrawTimeTrack (TrackPanelDrawingContext &context, const TimeTrack &track, Ruler &ruler, const wxRect &rect)
 

Function Documentation

◆ DrawHorzRulerAndCurve()

void anonymous_namespace{TimeTrackView.cpp}::DrawHorzRulerAndCurve ( TrackPanelDrawingContext context,
const wxRect &  r,
const TimeTrack track,
Ruler ruler 
)

Definition at line 71 of file TimeTrackView.cpp.

74 {
75  auto &dc = context.dc;
76  const auto artist = TrackArtist::Get( context );
77  const auto &zoomInfo = *artist->pZoomInfo;
78 
79  bool highlight = false;
80 #ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
81  auto target = dynamic_cast<EnvelopeHandle*>(context.target.get());
82  highlight = target && target->GetEnvelope() == this->GetEnvelope();
83 #endif
84 
85  double min = zoomInfo.PositionToTime(0);
86  double max = zoomInfo.PositionToTime(r.width);
87  if (min > max)
88  {
89  wxASSERT(false);
90  min = max;
91  }
92 
93  AColor::UseThemeColour( &dc, clrUnselected );
94  dc.DrawRectangle(r);
95 
96  //copy this rectangle away for future use.
97  wxRect mid = r;
98 
99  // Draw the Ruler
100  ruler.SetBounds(r.x, r.y, r.x + r.width - 1, r.y + r.height - 1);
101  ruler.SetRange(min, max);
102  ruler.SetFlip(true); // tick marks at top of track.
103  ruler.Invalidate(); // otherwise does not redraw.
104  ruler.SetTickColour( theTheme.Colour( clrTrackPanelText ));
105  ruler.Draw(dc, track.GetEnvelope());
106 
107  Doubles envValues{ size_t(mid.width) };
109  0, 0, envValues.get(), mid.width, 0, zoomInfo );
110 
111  wxPen &pen = highlight ? AColor::uglyPen : AColor::envelopePen;
112  dc.SetPen( pen );
113 
114  auto rangeLower = track.GetRangeLower(), rangeUpper = track.GetRangeUpper();
115  double logLower = log(std::max(1.0e-7, rangeLower)),
116  logUpper = log(std::max(1.0e-7, rangeUpper));
117 
118  for (int x = 0; x < mid.width; x++)
119  {
120  double y;
121  if ( track.GetDisplayLog() )
122  y = (double)mid.height * (logUpper - log(envValues[x])) / (logUpper - logLower);
123  else
124  y = (double)mid.height * (rangeUpper - envValues[x]) / (rangeUpper - rangeLower);
125  int thisy = r.y + (int)y;
126  AColor::Line(dc, mid.x + x, thisy - 1, mid.x + x, thisy+2);
127  }
128 }

References ThemeBase::Colour(), TrackPanelDrawingContext::dc, Ruler::Draw(), AColor::envelopePen, TrackArtist::Get(), TimeTrack::GetDisplayLog(), TimeTrack::GetEnvelope(), EnvelopeHandle::GetEnvelope(), TimeTrack::GetRangeLower(), TimeTrack::GetRangeUpper(), Envelope::GetValues(), Ruler::Invalidate(), AColor::Line(), min(), anonymous_namespace{TimeTrackVRulerControls.cpp}::ruler(), Ruler::SetBounds(), Ruler::SetFlip(), Ruler::SetRange(), Ruler::SetTickColour(), TrackPanelDrawingContext::target, theTheme, AColor::uglyPen, and AColor::UseThemeColour().

Referenced by DrawTimeTrack().

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

◆ DrawTimeTrack()

void anonymous_namespace{TimeTrackView.cpp}::DrawTimeTrack ( TrackPanelDrawingContext context,
const TimeTrack track,
Ruler ruler,
const wxRect &  rect 
)

Definition at line 130 of file TimeTrackView.cpp.

133 {
134  // Ruler and curve...
135  DrawHorzRulerAndCurve( context, rect, track, ruler );
136 
137  // ... then the control points
138  wxRect envRect = rect;
139  envRect.height -= 2;
140  double lower = track.GetRangeLower(), upper = track.GetRangeUpper();
141  const auto artist = TrackArtist::Get( context );
142  const auto dbRange = artist->mdBrange;
143  if(track.GetDisplayLog()) {
144  // MB: silly way to undo the work of GetWaveYPos while still getting a logarithmic scale
145  lower = LINEAR_TO_DB(std::max(1.0e-7, lower)) / dbRange + 1.0;
146  upper = LINEAR_TO_DB(std::max(1.0e-7, upper)) / dbRange + 1.0;
147  }
149  context, envRect,
150  track.GetDisplayLog(), dbRange, lower, upper, false );
151 }

References DrawHorzRulerAndCurve(), EnvelopeEditor::DrawPoints(), TrackArtist::Get(), TimeTrack::GetDisplayLog(), TimeTrack::GetEnvelope(), TimeTrack::GetRangeLower(), TimeTrack::GetRangeUpper(), LINEAR_TO_DB, and anonymous_namespace{TimeTrackVRulerControls.cpp}::ruler().

Referenced by TimeTrackView::Draw().

Here is the call graph for this function:
Here is the caller graph for this function:
AColor::UseThemeColour
static void UseThemeColour(wxDC *dc, int iBrush, int iPen=-1, int alpha=255)
Definition: AColor.cpp:280
TimeTrack::GetRangeLower
double GetRangeLower() const
Definition: TimeTrack.cpp:116
EnvelopeHandle::GetEnvelope
Envelope * GetEnvelope() const
Definition: EnvelopeHandle.h:59
TimeTrack::GetRangeUpper
double GetRangeUpper() const
Definition: TimeTrack.cpp:121
EnvelopeEditor::DrawPoints
static void DrawPoints(const Envelope &env, TrackPanelDrawingContext &context, const wxRect &r, bool dB, double dBRange, float zoomMin, float zoomMax, bool mirrored, int origin=0)
Definition: EnvelopeEditor.cpp:35
AColor::Line
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:109
Ruler::SetTickColour
void SetTickColour(const wxColour &colour)
Definition: Ruler.h:148
Ruler::Draw
void Draw(wxDC &dc) const
Definition: Ruler.cpp:1428
TrackPanelDrawingContext::dc
wxDC & dc
Definition: TrackPanelDrawingContext.h:23
EnvelopeHandle
Definition: EnvelopeHandle.h:28
AColor::envelopePen
static wxPen envelopePen
Definition: AColor.h:104
anonymous_namespace{TimeTrackVRulerControls.cpp}::ruler
Ruler & ruler()
Definition: TimeTrackVRulerControls.cpp:34
TimeTrack::GetDisplayLog
bool GetDisplayLog() const
Definition: TimeTrack.h:94
Ruler::SetFlip
void SetFlip(bool flip)
Definition: Ruler.cpp:239
TrackArtist::Get
static TrackArtist * Get(TrackPanelDrawingContext &)
Definition: TrackArtist.cpp:80
TimeTrack::GetEnvelope
BoundedEnvelope * GetEnvelope()
Definition: TimeTrack.h:83
Ruler::Invalidate
void Invalidate()
Definition: Ruler.cpp:345
Ruler::SetRange
void SetRange(double min, double max)
Definition: Ruler.cpp:188
AColor::uglyPen
static wxPen uglyPen
Definition: AColor.h:130
theTheme
THEME_API Theme theTheme
Definition: Theme.cpp:82
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
Ruler::SetBounds
void SetBounds(int left, int top, int right, int bottom)
Definition: Ruler.cpp:332
TrackPanelDrawingContext::target
UIHandlePtr target
Definition: TrackPanelDrawingContext.h:24
LINEAR_TO_DB
#define LINEAR_TO_DB(x)
Definition: MemoryX.h:631
ThemeBase::Colour
wxColour & Colour(int iIndex)
anonymous_namespace{TimeTrackView.cpp}::DrawHorzRulerAndCurve
void DrawHorzRulerAndCurve(TrackPanelDrawingContext &context, const wxRect &r, const TimeTrack &track, Ruler &ruler)
Definition: TimeTrackView.cpp:72
ArrayOf< double >
Envelope::GetValues
static void GetValues(const Envelope &env, double aligned_time, double sampleDur, double *buffer, int bufferLen, int leftOffset, const ZoomInfo &zoomInfo)
Get many envelope points for pixel columns at once, but don't assume uniform time per pixel.
Definition: Envelope.cpp:1470