Use libdcp's warnings.h
[dcpomatic.git] / src / wx / audio_plot.cc
index 7c9dae6a557c9061ea7fa1006af3a088b6679aaa..fbcd9047fbf034b717968f12b40a44f7343df939 100644 (file)
 
 
 #include "audio_plot.h"
-#include "wx_util.h"
 #include "film_viewer.h"
+#include "wx_util.h"
 #include "lib/audio_decoder.h"
 #include "lib/audio_analysis.h"
 #include "lib/compose.hpp"
+#include "lib/maths_util.h"
+#include <dcp/warnings.h>
+LIBDCP_DISABLE_WARNINGS
 #include <wx/graphics.h>
+LIBDCP_ENABLE_WARNINGS
 #include <boost/bind/bind.hpp>
-#include <iostream>
 #include <cfloat>
 
 
-using std::cout;
-using std::vector;
 using std::list;
+using std::map;
 using std::max;
 using std::min;
-using std::map;
-using boost::bind;
-using boost::optional;
 using std::shared_ptr;
+using std::vector;
 using std::weak_ptr;
+using boost::bind;
+using boost::optional;
 #if BOOST_VERSION >= 106100
 using namespace boost::placeholders;
 #endif
@@ -439,21 +441,6 @@ AudioPlot::colour (int n) const
 }
 
 
-void
-AudioPlot::search (map<int, PointList> const & search, wxMouseEvent const & ev, double& min_dist, Point& min_point) const
-{
-       for (auto const& i: search) {
-               for (auto const& j: i.second) {
-                       double const dist = pow(ev.GetX() - j.draw.x, 2) + pow(ev.GetY() - j.draw.y, 2);
-                       if (dist < min_dist) {
-                               min_dist = dist;
-                               min_point = j;
-                       }
-               }
-       }
-}
-
-
 void
 AudioPlot::left_down ()
 {
@@ -471,10 +458,28 @@ AudioPlot::mouse_moved (wxMouseEvent& ev)
        double min_dist = DBL_MAX;
        Point min_point;
 
-       search (_rms, ev, min_dist, min_point);
-       search (_peak, ev, min_dist, min_point);
+       auto search = [this](map<int, PointList> const & search, wxMouseEvent const & ev, double& min_dist, Point& min_point) {
+               for (auto const& i: search) {
+                       if (_channel_visible[i.first]) {
+                               for (auto const& j: i.second) {
+                                       double const dist = pow(ev.GetX() - j.draw.x, 2) + pow(ev.GetY() - j.draw.y, 2);
+                                       if (dist < min_dist) {
+                                               min_dist = dist;
+                                               min_point = j;
+                                       }
+                               }
+                       }
+               }
+       };
+
+       if (_type_visible[AudioPoint::RMS]) {
+               search (_rms, ev, min_dist, min_point);
+       }
+       if (_type_visible[AudioPoint::PEAK]) {
+               search (_peak, ev, min_dist, min_point);
+       }
 
-       _cursor = {};
+       _cursor = boost::none;
 
        if (min_dist < DBL_MAX) {
                wxRect before (min_point.draw.x - _cursor_size / 2, min_point.draw.y - _cursor_size / 2, _cursor_size, _cursor_size);
@@ -490,7 +495,7 @@ AudioPlot::mouse_moved (wxMouseEvent& ev)
 void
 AudioPlot::mouse_leave (wxMouseEvent &)
 {
-       _cursor = {};
+       _cursor = boost::none;
        Refresh ();
        Cursor (optional<DCPTime>(), optional<float>());
 }