28void DrawPoint(wxDC & dc,
const wxRect & r,
int x,
int y,
bool top)
30 if (y >= 0 && y <= r.height) {
31 wxRect circle(r.x + x, r.y + (top ? y - 1: y - 2), 4, 4);
32 dc.DrawEllipse(circle);
39 bool dB,
double dBRange,
40 float zoomMin,
float zoomMax,
bool mirrored,
int origin)
42 auto &dc = context.
dc;
44 const auto &zoomInfo = *artist->pZoomInfo;
46 bool highlight =
false;
47#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
49 highlight = target && target->
GetEnvelope() == &env;
53 dc.SetBrush(*wxWHITE_BRUSH);
56 const double time = env[i].GetT() + env.
GetOffset();
57 const wxInt64 position = zoomInfo.TimeToPosition(time, origin);
58 if (position >= 0 && position < r.width) {
65 double v = env[i].GetVal();
66 int x = (int)(position);
70 true, dBRange,
false);
75 y2 =
GetWaveYPos(-v-.000000001, zoomMin, zoomMax, r.height, dB,
76 true, dBRange,
false);
82 int value = (int)((zoomMax / (zoomMax - zoomMin)) * r.height);
92 false, dBRange,
false);
93 y2 =
GetWaveYPos(-v-.000000001, zoomMin, zoomMax, r.height, dB,
94 false, dBRange,
false);
104 dc.SetBrush(*wxWHITE_BRUSH);
111 : mEnvelope(envelope)
112 , mMirrored(mirrored)
117 , mButton(wxMOUSE_BTN_NONE)
128inline int SQR(
int x) {
return x * x; }
139 bool dB,
double dBRange,
140 float zoomMin,
float zoomMax)
160 bool dB,
double dBRange,
161 float zoomMin,
float zoomMax)
163 int ctr = (int)(r.height * zoomMax / (zoomMax - zoomMin));
164 bool upper = !
mMirrored || (zoomMin >= 0.0) || (event.m_y - r.y < ctr);
166 int clip_y =
event.m_y - r.y;
167 if(clip_y < 0) clip_y = 0;
168 if(clip_y > r.GetBottom()) clip_y = r.GetBottom();
171 int bestDistSqr = 100;
182 for (
int i = 0; i < len; i++) {
185 if (position >= 0 && position < r.width) {
187 int x = (int)(position);
189 int numControlPoints;
193 y[0] =
GetWaveYPos(value, zoomMin, zoomMax, r.height,
194 dB,
true, dBRange,
false);
195 y[1] =
GetWaveYPos(-value, zoomMin, zoomMax, r.height,
196 dB,
true, dBRange,
false);
199 y[2] =
GetWaveYPos(value, zoomMin, zoomMax, r.height,
200 dB,
false, dBRange,
false);
201 y[3] =
GetWaveYPos(-value -.00000001, zoomMin, zoomMax,
202 r.height, dB,
false, dBRange,
false);
204 numControlPoints = 4;
207 numControlPoints = 2;
210 numControlPoints = 1;
212 const int deltaXSquared =
SQR(x - (event.m_x - r.x));
213 for(
int j=0; j<numControlPoints; j++){
215 const int dSqr = deltaXSquared +
SQR(y[j] - (event.m_y - r.y));
216 if (dSqr < bestDistSqr) {
237 int ct =
GetWaveYPos( v, zoomMin, zoomMax, r.height, dB,
238 false, dBRange,
false) ;
239 int cb =
GetWaveYPos( -v-.000000001, zoomMin, zoomMax, r.height, dB,
240 false, dBRange,
false) ;
242 int t =
GetWaveYPos( v, zoomMin, zoomMax, r.height, dB,
243 true, dBRange,
false) ;
244 int b =
GetWaveYPos( -v, zoomMin, zoomMax, r.height, dB,
245 true, dBRange,
false) ;
251 (event.m_y - r.y) > ct &&
252 ((
event.m_y - r.y) < cb))
258 double newVal =
ValueOfPixel(clip_y, r.height, upper, dB, dBRange,
275 const ZoomInfo &zoomInfo,
bool dB,
double dBRange,
276 float zoomMin,
float zoomMax)
278 int clip_y =
event.m_y - r.y;
279 if(clip_y < 0) clip_y = 0;
280 if(clip_y > r.height) clip_y = r.height;
294 const ZoomInfo &zoomInfo,
bool dB,
double dBRange,
295 float zoomMin,
float zoomMax,
296 float WXUNUSED(eMin),
float WXUNUSED(eMax))
301 larger.Inflate(10, 10);
303 if (larger.Contains(event.m_x, event.m_y))
307 MoveDragPoint( event, r, zoomInfo, dB, dBRange, zoomMin, zoomMax);
330 const ZoomInfo &zoomInfo,
bool dB,
double dBRange,
331 float zoomMin,
float zoomMax)
333 if (event.ButtonDown() &&
mButton == wxMOUSE_BTN_NONE)
339 if (event.ButtonUp() && event.GetButton() ==
mButton)
int GetWaveYPos(float value, float min, float max, int height, bool dB, bool outer, float dBr, bool clip)
static wxBrush envelopeBrush
EnvelopeEditor(Envelope &envelope, bool mirrored)
bool HandleDragging(const wxMouseEvent &event, wxRect &r, const ZoomInfo &zoomInfo, bool dB, double dBRange, float zoomMin=-1.0, float zoomMax=1.0, float eMin=0., float eMax=2.)
bool MouseEvent(const wxMouseEvent &event, wxRect &r, const ZoomInfo &zoomInfo, bool dB, double dBRange, float zoomMin=-1.0, float zoomMax=1.0)
void MoveDragPoint(const wxMouseEvent &event, wxRect &r, const ZoomInfo &zoomInfo, bool dB, double dBRange, float zoomMin, float zoomMax)
bool HandleMouseButtonDown(const wxMouseEvent &event, wxRect &r, const ZoomInfo &zoomInfo, bool dB, double dBRange, float zoomMin=-1.0, float zoomMax=1.0)
bool HandleMouseButtonUp()
int mContourOffset
Number of pixels contour is from the true envelope.
float ValueOfPixel(int y, int height, bool upper, bool dB, double dBRange, float zoomMin, float zoomMax)
static void DrawPoints(const Envelope &env, TrackPanelDrawingContext &context, const wxRect &r, bool dB, double dBRange, float zoomMin, float zoomMax, bool mirrored, int origin=0)
Envelope * GetEnvelope() const
Piecewise linear or piecewise exponential function from double to double.
double GetValue(double t, double sampleDur=0) const
Get envelope value at time t.
int InsertOrReplace(double when, double value)
Add a point at a particular absolute time coordinate.
void SetDragPoint(int dragPoint)
double ClampValue(double value)
size_t GetNumberOfPoints() const
Return number of points.
void MoveDragPoint(double newWhen, double value)
bool GetDragPointValid() const
void SetDragPointValid(bool valid)
static TrackArtist * Get(TrackPanelDrawingContext &)
double PositionToTime(int64 position, int64 origin=0, bool ignoreFisheye=false) const
int64 TimeToPosition(double time, int64 origin=0, bool ignoreFisheye=false) const
STM: Converts a project time to screen x position.
void DrawPoint(wxDC &dc, const wxRect &r, int x, int y, bool top)