_data(data)
{
assert(_probe_index >= 0);
+ _colour = LogicSignalColours[
+ _probe_index % countof(LogicSignalColours)];
}
void LogicSignal::paint(QPainter &p, const QRect &rect, double scale,
p.drawLines(lines, line - lines);
}
-QColor LogicSignal::get_colour() const
-{
- return LogicSignalColours[_probe_index % countof(LogicSignalColours)];
-}
-
int LogicSignal::get_nominal_offset(const QRect &rect) const
{
return rect.bottom() - Margin;
bool level, double samples_per_pixel, double pixels_offset,
float x_offset, float y_offset);
- /**
- * Get the colour of the logic signal
- */
- QColor get_colour() const;
-
/**
* When painting into the rectangle, calculate the y
* offset of the zero point.
_name = name;
}
+QColor Signal::get_colour() const
+{
+ return _colour;
+}
+
+void Signal::set_colour(QColor colour)
+{
+ _colour = colour;
+}
+
void Signal::paint_label(QPainter &p, const QRect &rect, bool hover)
{
- p.setBrush(get_colour());
+ p.setBrush(_colour);
const QColor colour = get_colour();
const float nominal_offset = get_nominal_offset(rect);
#include <boost/shared_ptr.hpp>
+#include <QColor>
#include <QPainter>
#include <QRect>
#include <QString>
*/
void set_name(QString name);
+ /**
+ * Get the colour of the signal.
+ */
+ QColor get_colour() const;
+
+ /**
+ * Set the colour of the signal.
+ */
+ void set_colour(QColor colour);
+
/**
* Paints the signal with a QPainter
* @param p the QPainter to paint into.
QRectF get_label_rect(const QRect &rect);
protected:
- /**
- * Get the colour of the logic signal
- */
- virtual QColor get_colour() const = 0;
-
/**
* When painting into the rectangle, calculate the y
* offset of the zero point.
protected:
QString _name;
+ QColor _colour;
+
QSizeF _text_size;
};
#include <boost/foreach.hpp>
+#include <QColorDialog>
#include <QInputDialog>
#include <QMenu>
#include <QMouseEvent>
Header::Header(View &parent) :
QWidget(&parent),
_view(parent),
- _action_set_name(new QAction(tr("Set &Name..."), this))
+ _action_set_name(new QAction(tr("Set &Name..."), this)),
+ _action_set_colour(new QAction(tr("Set &Colour..."), this))
{
setMouseTracking(true);
connect(_action_set_name, SIGNAL(triggered()),
this, SLOT(on_action_set_name_triggered()));
+ connect(_action_set_colour, SIGNAL(triggered()),
+ this, SLOT(on_action_set_colour_triggered()));
}
void Header::paintEvent(QPaintEvent *event)
if(s->pt_in_label_rect(signal_heading_rect, _mouse_point)) {
QMenu menu(this);
menu.addAction(_action_set_name);
+ menu.addAction(_action_set_colour);
_context_signal = s;
menu.exec(event->globalPos());
context_signal->set_name(new_label);
}
+void Header::on_action_set_colour_triggered()
+{
+ boost::shared_ptr<Signal> context_signal = _context_signal;
+ if(!context_signal)
+ return;
+
+ const QColor new_colour = QColorDialog::getColor(
+ context_signal->get_colour(), this, tr("Set Colour"));
+
+ if(new_colour.isValid())
+ context_signal->set_colour(new_colour);
+}
+
} // namespace view
} // namespace pv
private slots:
void on_action_set_name_triggered();
+ void on_action_set_colour_triggered();
+
private:
View &_view;
boost::shared_ptr<pv::Signal> _context_signal;
QAction *_action_set_name;
+ QAction *_action_set_colour;
};
} // namespace view