* 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>
#include "pv/data/logic.h"
#include "pv/data/logicsnapshot.h"
-using namespace boost;
-using namespace std;
+using boost::shared_ptr;
+using boost::weak_ptr;
+using std::deque;
+using std::list;
+using std::max;
+using std::min;
+using std::set;
+using std::vector;
namespace pv {
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;
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()));
connect(_ruler, SIGNAL(selection_changed()),
this, SIGNAL(selection_changed()));
- setViewportMargins(LabelMarginWidth, RulerHeight, 0, 0);
setViewport(_viewport);
_viewport->installEventFilter(this);
void View::zoom(double steps)
{
- zoom(steps, (width() - LabelMarginWidth) / 2);
+ zoom(steps, _viewport->width() / 2);
}
void View::zoom(double steps, int offset)
{
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;
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)
{
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)
offset += SignalHeight + 2 * SignalMargin;
}
+ update_layout();
normalize_layout();
}
signals_moved();
}
+void View::on_geometry_updated()
+{
+ update_layout();
+}
+
} // namespace view
} // namespace pv