Made decode an optional feature disabled by default.
[pulseview.git] / pv / view / view.cpp
index 3137dd0c6686b4b9a947e7a708ba14868c16d631..18ce679df877f030b2f35a11e208f9ef72e63bcd 100644 (file)
@@ -18,7 +18,9 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+#ifdef ENABLE_DECODE
 #include <libsigrokdecode/libsigrokdecode.h>
+#endif
 
 #include <assert.h>
 #include <limits.h>
@@ -52,9 +54,6 @@ namespace view {
 const double View::MaxScale = 1e9;
 const double View::MinScale = 1e-15;
 
-const int View::LabelMarginWidth = 70;
-const int View::RulerHeight = 30;
-
 const int View::MaxScrollValue = INT_MAX / 2;
 
 const int View::SignalHeight = 30;
@@ -95,6 +94,8 @@ View::View(SigSession &session, QWidget *parent) :
        connect(_cursors.second().get(), SIGNAL(time_changed()),
                this, SLOT(marker_time_changed()));
 
+       connect(_header, SIGNAL(geometry_updated()),
+               this, SLOT(on_geometry_updated()));
        connect(_header, SIGNAL(signals_moved()),
                this, SLOT(on_signals_moved()));
 
@@ -108,7 +109,6 @@ View::View(SigSession &session, QWidget *parent) :
        connect(_ruler, SIGNAL(selection_changed()),
                this, SIGNAL(selection_changed()));
 
-       setViewportMargins(LabelMarginWidth, RulerHeight, 0, 0);
        setViewport(_viewport);
 
        _viewport->installEventFilter(this);
@@ -238,14 +238,20 @@ vector< shared_ptr<Trace> > View::get_traces() const
 {
        const vector< shared_ptr<Signal> > sigs(
                session().get_signals());
+#ifdef ENABLE_DECODE
        const vector< shared_ptr<DecodeTrace> > decode_sigs(
                session().get_decode_signals());
        vector< shared_ptr<Trace> > traces(
                sigs.size() + decode_sigs.size());
+#else
+       vector< shared_ptr<Trace> > traces(sigs.size());
+#endif
 
        vector< shared_ptr<Trace> >::iterator i = traces.begin();
        i = copy(sigs.begin(), sigs.end(), i);
+#ifdef ENABLE_DECODE
        i = copy(decode_sigs.begin(), decode_sigs.end(), i);
+#endif
 
        stable_sort(traces.begin(), traces.end(), compare_trace_v_offsets);
        return traces;
@@ -381,6 +387,17 @@ void View::update_scroll()
                areaSize.height());
 }
 
+void View::update_layout()
+{
+       setViewportMargins(_header->sizeHint().width(),
+               _ruler->sizeHint().height(), 0, 0);
+       _ruler->setGeometry(_viewport->x(), 0,
+               _viewport->width(), _viewport->y());
+       _header->setGeometry(0, _viewport->y(),
+               _viewport->x(), _viewport->height());
+       update_scroll();
+}
+
 bool View::compare_trace_v_offsets(const shared_ptr<Trace> &a,
        const shared_ptr<Trace> &b)
 {
@@ -432,11 +449,7 @@ bool View::viewportEvent(QEvent *e)
 
 void View::resizeEvent(QResizeEvent*)
 {
-       _ruler->setGeometry(_viewport->x(), 0,
-               _viewport->width(), _viewport->y());
-       _header->setGeometry(0, _viewport->y(),
-               _viewport->x(), _viewport->height());
-       update_scroll();
+       update_layout();
 }
 
 void View::h_scroll_value_changed(int value)
@@ -474,6 +487,7 @@ void View::signals_changed()
                offset += SignalHeight + 2 * SignalMargin;
        }
 
+       update_layout();
        normalize_layout();
 }
 
@@ -510,5 +524,10 @@ void View::on_signals_moved()
        signals_moved();
 }
 
+void View::on_geometry_updated()
+{
+       update_layout();
+}
+
 } // namespace view
 } // namespace pv