Small fixes and tidy-ups spotted by cppcheck.
[dcpomatic.git] / src / wx / audio_plot.cc
index 69faf127e2db0404fa5192cf9f12d8a74510ec5b..16930ffd870ab55724d6753ea0e91eabcb8160ca 100644 (file)
@@ -40,7 +40,6 @@ AudioPlot::AudioPlot (wxWindow* parent)
        : wxPanel (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE)
        , _gain (0)
        , _smoothing (max_smoothing / 2)
-       , _message (_("Please wait; audio is being analysed..."))
 {
 #ifndef __WXOSX__      
        SetDoubleBuffered (true);
@@ -67,6 +66,8 @@ AudioPlot::AudioPlot (wxWindow* parent)
        _colours.push_back (wxColour (255,   0, 139));
        _colours.push_back (wxColour (139,   0, 255));
 
+       set_analysis (shared_ptr<AudioAnalysis> ());
+
 #if MAX_DCP_AUDIO_CHANNELS != 12
 #warning AudioPlot::AudioPlot is expecting the wrong MAX_DCP_AUDIO_CHANNELS
 #endif 
@@ -81,14 +82,10 @@ AudioPlot::set_analysis (shared_ptr<AudioAnalysis> a)
 {
        _analysis = a;
 
-       for (int i = 0; i < MAX_DCP_AUDIO_CHANNELS; ++i) {
-               _channel_visible[i] = false;
+       if (!a) {
+               _message = _("Please wait; audio is being analysed...");
        }
 
-       for (int i = 0; i < AudioPoint::COUNT; ++i) {
-               _type_visible[i] = false;
-       }
-       
        Refresh ();
 }
 
@@ -162,7 +159,7 @@ AudioPlot::paint ()
                gc->DrawText (std_to_wx (String::compose ("%1dB", i)), 0, y - (db_label_height / 2));
        }
 
-       gc->SetPen (*wxLIGHT_GREY_PEN);
+       gc->SetPen (wxPen (wxColour (200, 200, 200)));
        gc->StrokePath (grid);
 
        gc->DrawText (_("Time"), data_width, metrics.height - metrics.y_origin + db_label_height / 2);
@@ -174,7 +171,7 @@ AudioPlot::paint ()
                                plot_peak (p, c, metrics);
                        }
                        wxColour const col = _colours[c];
-                       gc->SetPen (*wxThePenList->FindOrCreatePen (wxColour (col.Red(), col.Green(), col.Blue(), col.Alpha() / 2), 1, wxPENSTYLE_SOLID));
+                       gc->SetPen (wxPen (wxColour (col.Red(), col.Green(), col.Blue(), col.Alpha() / 2), 1, wxPENSTYLE_SOLID));
                        gc->StrokePath (p);
                }
        }
@@ -186,7 +183,7 @@ AudioPlot::paint ()
                                plot_rms (p, c, metrics);
                        }
                        wxColour const col = _colours[c];
-                       gc->SetPen (*wxThePenList->FindOrCreatePen (col, 1, wxPENSTYLE_SOLID));
+                       gc->SetPen (wxPen (col, 1, wxPENSTYLE_SOLID));
                        gc->StrokePath (p);
                }
        }
@@ -195,7 +192,7 @@ AudioPlot::paint ()
        axes.MoveToPoint (metrics.db_label_width, 0);
        axes.AddLineToPoint (metrics.db_label_width, metrics.height - metrics.y_origin);
        axes.AddLineToPoint (metrics.db_label_width + data_width, metrics.height - metrics.y_origin);
-       gc->SetPen (*wxBLACK_PEN);
+       gc->SetPen (wxPen (wxColour (0, 0, 0)));
        gc->StrokePath (axes);
 
        delete gc;
@@ -283,7 +280,7 @@ AudioPlot::plot_rms (wxGraphicsPath& path, int channel, Metrics const & metrics)
                        p += pow (*j, 2);
                }
 
-               if (smoothing.size() > 0) {
+               if (!smoothing.empty ()) {
                        p = sqrt (p / smoothing.size ());
                }