| 35 | } |
| 36 | |
| 37 | void EnvelopeEditor::DrawPoints(const Envelope &env, |
| 38 | TrackPanelDrawingContext &context, const wxRect & r, |
| 39 | bool dB, double dBRange, |
| 40 | float zoomMin, float zoomMax, bool mirrored, int origin) |
| 41 | { |
| 42 | auto &dc = context.dc; |
| 43 | const auto artist = TrackArtist::Get( context ); |
| 44 | const auto &zoomInfo = *artist->pZoomInfo; |
| 45 | |
| 46 | bool highlight = false; |
| 47 | #ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING |
| 48 | auto target = dynamic_cast<EnvelopeHandle*>(context.target.get()); |
| 49 | highlight = target && target->GetEnvelope() == &env; |
| 50 | #endif |
| 51 | wxPen &pen = highlight ? AColor::uglyPen : AColor::envelopePen; |
| 52 | dc.SetPen( pen ); |
| 53 | dc.SetBrush(*wxWHITE_BRUSH); |
| 54 | |
| 55 | for (int i = 0; i < (int)env.GetNumberOfPoints(); i++) { |
| 56 | const double time = env[i].GetT() + env.GetOffset(); |
| 57 | const wxInt64 position = zoomInfo.TimeToPosition(time, origin); |
| 58 | if (position >= 0 && position < r.width) { |
| 59 | // Change colour if this is the draggable point... |
| 60 | if (i == env.GetDragPoint()) { |
| 61 | dc.SetPen( pen ); |
| 62 | dc.SetBrush(AColor::envelopeBrush); |
| 63 | } |
| 64 | |
| 65 | double v = env[i].GetVal(); |
| 66 | int x = (int)(position); |
| 67 | int y, y2; |
| 68 | |
| 69 | y = GetWaveYPos(v, zoomMin, zoomMax, r.height, dB, |
| 70 | true, dBRange, false); |
| 71 | if (!mirrored) { |
| 72 | DrawPoint(dc, r, x, y, true); |
| 73 | } |
| 74 | else { |
| 75 | y2 = GetWaveYPos(-v-.000000001, zoomMin, zoomMax, r.height, dB, |
| 76 | true, dBRange, false); |
| 77 | |
| 78 | // This follows the same logic as the envelop drawing in |
| 79 | // TrackArt::DrawEnvelope(). |
| 80 | // TODO: make this calculation into a reusable function. |
| 81 | if (y2 - y < 9) { |
| 82 | int value = (int)((zoomMax / (zoomMax - zoomMin)) * r.height); |
| 83 | y = value - 4; |
| 84 | y2 = value + 4; |
| 85 | } |
| 86 | |
| 87 | DrawPoint(dc, r, x, y, true); |
| 88 | DrawPoint(dc, r, x, y2, false); |
| 89 | |
| 90 | // Contour |
| 91 | y = GetWaveYPos(v, zoomMin, zoomMax, r.height, dB, |
| 92 | false, dBRange, false); |
| 93 | y2 = GetWaveYPos(-v-.000000001, zoomMin, zoomMax, r.height, dB, |
| 94 | false, dBRange, false); |
nothing calls this directly
no test coverage detected