pv/views/trace/viewwidget.cpp
pv/views/viewbase.cpp
pv/views/trace/standardbar.cpp
- pv/widgets/colourbutton.cpp
- pv/widgets/colourpopup.cpp
+ pv/widgets/colorbutton.cpp
+ pv/widgets/colorpopup.cpp
pv/widgets/devicetoolbutton.cpp
pv/widgets/exportmenu.cpp
pv/widgets/importmenu.cpp
pv/views/trace/viewwidget.hpp
pv/views/viewbase.hpp
pv/views/trace/standardbar.hpp
- pv/widgets/colourbutton.hpp
- pv/widgets/colourpopup.hpp
+ pv/widgets/colorbutton.hpp
+ pv/widgets/colorpopup.hpp
pv/widgets/devicetoolbutton.hpp
pv/widgets/exportmenu.hpp
pv/widgets/importmenu.hpp
namespace pv {
namespace data {
-const int SignalBase::ColourBGAlpha = 8 * 256 / 100;
+const int SignalBase::ColorBGAlpha = 8 * 256 / 100;
const uint64_t SignalBase::ConversionBlockSize = 4096;
const uint32_t SignalBase::ConversionDelay = 1000; // 1 second
return 0;
}
-QColor SignalBase::colour() const
+QColor SignalBase::color() const
{
- return colour_;
+ return color_;
}
-void SignalBase::set_colour(QColor colour)
+void SignalBase::set_color(QColor color)
{
- colour_ = colour;
+ color_ = color;
- bgcolour_ = colour;
- bgcolour_.setAlpha(ColourBGAlpha);
+ bgcolor_ = color;
+ bgcolor_.setAlpha(ColorBGAlpha);
- colour_changed(colour);
+ color_changed(color);
}
-QColor SignalBase::bgcolour() const
+QColor SignalBase::bgcolor() const
{
- return bgcolour_;
+ return bgcolor_;
}
void SignalBase::set_data(shared_ptr<pv::data::SignalData> data)
{
settings.setValue("name", name());
settings.setValue("enabled", enabled());
- settings.setValue("colour", colour());
+ settings.setValue("color", color());
settings.setValue("conversion_type", (int)conversion_type_);
settings.setValue("conv_options", (int)(conversion_options_.size()));
{
set_name(settings.value("name").toString());
set_enabled(settings.value("enabled").toBool());
- set_colour(settings.value("colour").value<QColor>());
+ set_color(settings.value("color").value<QColor>());
set_conversion_type((ConversionType)settings.value("conversion_type").toInt());
int conv_options = settings.value("conv_options").toInt();
};
private:
- static const int ColourBGAlpha;
+ static const int ColorBGAlpha;
static const uint64_t ConversionBlockSize;
static const uint32_t ConversionDelay;
virtual void set_name(QString name);
/**
- * Get the colour of the signal.
+ * Get the color of the signal.
*/
- QColor colour() const;
+ QColor color() const;
/**
- * Set the colour of the signal.
+ * Set the color of the signal.
*/
- void set_colour(QColor colour);
+ void set_color(QColor color);
/**
- * Get the background colour of the signal.
+ * Get the background color of the signal.
*/
- QColor bgcolour() const;
+ QColor bgcolor() const;
/**
* Sets the internal data object.
void name_changed(const QString &name);
- void colour_changed(const QColor &colour);
+ void color_changed(const QColor &color);
void conversion_type_changed(const ConversionType t);
QTimer delayed_conversion_starter_;
QString internal_name_, name_;
- QColor colour_, bgcolour_;
+ QColor color_, bgcolor_;
};
} // namespace data
QFormLayout *trace_view_layout = new QFormLayout();
trace_view_group->setLayout(trace_view_layout);
- cb = create_checkbox(GlobalSettings::Key_View_ColouredBG,
- SLOT(on_view_colouredBG_changed(int)));
- trace_view_layout->addRow(tr("Use coloured trace &background"), cb);
+ cb = create_checkbox(GlobalSettings::Key_View_ColoredBG,
+ SLOT(on_view_coloredBG_changed(int)));
+ trace_view_layout->addRow(tr("Use colored trace &background"), cb);
cb = create_checkbox(GlobalSettings::Key_View_ZoomToFitDuringAcq,
SLOT(on_view_zoomToFitDuringAcq_changed(int)));
settings.setValue(GlobalSettings::Key_View_TriggerIsZeroTime, state ? true : false);
}
-void Settings::on_view_colouredBG_changed(int state)
+void Settings::on_view_coloredBG_changed(int state)
{
GlobalSettings settings;
- settings.setValue(GlobalSettings::Key_View_ColouredBG, state ? true : false);
+ settings.setValue(GlobalSettings::Key_View_ColoredBG, state ? true : false);
}
void Settings::on_view_stickyScrolling_changed(int state)
void on_view_zoomToFitDuringAcq_changed(int state);
void on_view_zoomToFitAfterAcq_changed(int state);
void on_view_triggerIsZero_changed(int state);
- void on_view_colouredBG_changed(int state);
+ void on_view_coloredBG_changed(int state);
void on_view_stickyScrolling_changed(int state);
void on_view_showSamplingPoints_changed(int state);
void on_view_showAnalogMinorGrid_changed(int state);
const QString GlobalSettings::Key_View_ZoomToFitDuringAcq = "View_ZoomToFitDuringAcq";
const QString GlobalSettings::Key_View_ZoomToFitAfterAcq = "View_ZoomToFitAfterAcq";
const QString GlobalSettings::Key_View_TriggerIsZeroTime = "View_TriggerIsZeroTime";
-const QString GlobalSettings::Key_View_ColouredBG = "View_ColouredBG";
+const QString GlobalSettings::Key_View_ColoredBG = "View_ColoredBG";
const QString GlobalSettings::Key_View_StickyScrolling = "View_StickyScrolling";
const QString GlobalSettings::Key_View_ShowSamplingPoints = "View_ShowSamplingPoints";
const QString GlobalSettings::Key_View_ShowAnalogMinorGrid = "View_ShowAnalogMinorGrid";
if (!contains(Key_View_ZoomToFitAfterAcq))
setValue(Key_View_ZoomToFitAfterAcq, true);
- // Enable coloured trace backgrounds by default
- if (!contains(Key_View_ColouredBG))
- setValue(Key_View_ColouredBG, true);
+ // Enable colored trace backgrounds by default
+ if (!contains(Key_View_ColoredBG))
+ setValue(Key_View_ColoredBG, true);
// Enable showing sampling points by default
if (!contains(Key_View_ShowSamplingPoints))
static const QString Key_View_ZoomToFitDuringAcq;
static const QString Key_View_ZoomToFitAfterAcq;
static const QString Key_View_TriggerIsZeroTime;
- static const QString Key_View_ColouredBG;
+ static const QString Key_View_ColoredBG;
static const QString Key_View_StickyScrolling;
static const QString Key_View_ShowSamplingPoints;
static const QString Key_View_ShowAnalogMinorGrid;
views::trace::View *tv =
qobject_cast<views::trace::View*>(v.get());
- tv->enable_coloured_bg(settings.value(GlobalSettings::Key_View_ColouredBG).toBool());
+ tv->enable_colored_bg(settings.value(GlobalSettings::Key_View_ColoredBG).toBool());
tv->enable_show_sampling_points(settings.value(GlobalSettings::Key_View_ShowSamplingPoints).toBool());
tv->enable_show_analog_minor_grid(settings.value(GlobalSettings::Key_View_ShowAnalogMinorGrid).toBool());
void MainWindow::on_setting_changed(const QString &key, const QVariant &value)
{
- if (key == GlobalSettings::Key_View_ColouredBG)
- on_settingViewColouredBg_changed(value);
+ if (key == GlobalSettings::Key_View_ColoredBG)
+ on_settingViewColoredBg_changed(value);
if (key == GlobalSettings::Key_View_ShowSamplingPoints)
on_settingViewShowSamplingPoints_changed(value);
view_show_analog_minor_grid_shortcut_ = new QShortcut(QKeySequence(Qt::Key_G), this, SLOT(on_view_show_analog_minor_grid_shortcut()));
view_show_analog_minor_grid_shortcut_->setAutoRepeat(false);
- view_coloured_bg_shortcut_ = new QShortcut(QKeySequence(Qt::Key_B), this, SLOT(on_view_coloured_bg_shortcut()));
- view_coloured_bg_shortcut_->setAutoRepeat(false);
+ view_colored_bg_shortcut_ = new QShortcut(QKeySequence(Qt::Key_B), this, SLOT(on_view_colored_bg_shortcut()));
+ view_colored_bg_shortcut_->setAutoRepeat(false);
// Set up the tab area
new_session_button_ = new QToolButton();
remove_session(session);
}
-void MainWindow::on_view_coloured_bg_shortcut()
+void MainWindow::on_view_colored_bg_shortcut()
{
GlobalSettings settings;
- bool state = settings.value(GlobalSettings::Key_View_ColouredBG).toBool();
- settings.setValue(GlobalSettings::Key_View_ColouredBG, !state);
+ bool state = settings.value(GlobalSettings::Key_View_ColoredBG).toBool();
+ settings.setValue(GlobalSettings::Key_View_ColoredBG, !state);
}
void MainWindow::on_view_sticky_scrolling_shortcut()
settings.setValue(GlobalSettings::Key_View_ShowAnalogMinorGrid, !state);
}
-void MainWindow::on_settingViewColouredBg_changed(const QVariant new_value)
+void MainWindow::on_settingViewColoredBg_changed(const QVariant new_value)
{
bool state = new_value.toBool();
views::trace::View* view =
qobject_cast<views::trace::View*>(viewbase.get());
if (view)
- view->enable_coloured_bg(state);
+ view->enable_colored_bg(state);
}
}
void on_tab_changed(int index);
void on_tab_close_requested(int index);
- void on_view_coloured_bg_shortcut();
+ void on_view_colored_bg_shortcut();
void on_view_sticky_scrolling_shortcut();
void on_view_show_sampling_points_shortcut();
void on_view_show_analog_minor_grid_shortcut();
- void on_settingViewColouredBg_changed(const QVariant new_value);
+ void on_settingViewColoredBg_changed(const QVariant new_value);
void on_settingViewShowSamplingPoints_changed(const QVariant new_value);
void on_settingViewShowAnalogMinorGrid_changed(const QVariant new_value);
QShortcut *view_sticky_scrolling_shortcut_;
QShortcut *view_show_sampling_points_shortcut_;
QShortcut *view_show_analog_minor_grid_shortcut_;
- QShortcut *view_coloured_bg_shortcut_;
+ QShortcut *view_colored_bg_shortcut_;
QShortcut *run_stop_shortcut_;
QShortcut *close_application_shortcut_;
QShortcut *close_current_tab_shortcut_;
namespace views {
namespace trace {
-const QColor AnalogSignal::SignalColours[4] = {
+const QColor AnalogSignal::SignalColors[4] = {
QColor(0xC4, 0xA0, 0x00), // Yellow
QColor(0x87, 0x20, 0x7A), // Magenta
QColor(0x20, 0x4A, 0x87), // Blue
const QColor AnalogSignal::GridMajorColor = QColor(0, 0, 0, 40 * 256 / 100);
const QColor AnalogSignal::GridMinorColor = QColor(0, 0, 0, 20 * 256 / 100);
-const QColor AnalogSignal::SamplingPointColour(0x77, 0x77, 0x77);
-const QColor AnalogSignal::SamplingPointColourLo = QColor(200, 0, 0, 80 * 256 / 100);
-const QColor AnalogSignal::SamplingPointColourNe = QColor(0, 0, 0, 80 * 256 / 100);
-const QColor AnalogSignal::SamplingPointColourHi = QColor(0, 200, 0, 80 * 256 / 100);
+const QColor AnalogSignal::SamplingPointColor(0x77, 0x77, 0x77);
+const QColor AnalogSignal::SamplingPointColorLo = QColor(200, 0, 0, 80 * 256 / 100);
+const QColor AnalogSignal::SamplingPointColorNe = QColor(0, 0, 0, 80 * 256 / 100);
+const QColor AnalogSignal::SamplingPointColorHi = QColor(0, 200, 0, 80 * 256 / 100);
const QColor AnalogSignal::ThresholdColor = QColor(0, 0, 0, 30 * 256 / 100);
const QColor AnalogSignal::ThresholdColorLo = QColor(255, 0, 0, 8 * 256 / 100);
div_height_ = gs.value(GlobalSettings::Key_View_DefaultDivHeight).toInt();
- base_->set_colour(SignalColours[base_->index() % countof(SignalColours)]);
+ base_->set_color(SignalColors[base_->index() % countof(SignalColors)]);
update_scale();
}
// Show the info section on the right side of the trace
const QString infotext = QString("%1 V/div").arg(resolution_);
- p.setPen(base_->colour());
+ p.setPen(base_->color());
p.setFont(QApplication::font());
const QRectF bounding_rect = QRectF(pp.left(),
(settings.value(GlobalSettings::Key_View_ShowSamplingPoints).toBool() ||
paint_thr_dots) && (samples_per_pixel < 0.25);
- p.setPen(base_->colour());
+ p.setPen(base_->color());
const int64_t points_count = end - start;
if (show_sampling_points) {
if (paint_thr_dots) {
- p.setPen(SamplingPointColourNe);
+ p.setPen(SamplingPointColorNe);
p.drawRects(sampling_points[0].data(), sampling_points[0].size());
- p.setPen(SamplingPointColourLo);
+ p.setPen(SamplingPointColorLo);
p.drawRects(sampling_points[1].data(), sampling_points[1].size());
- p.setPen(SamplingPointColourHi);
+ p.setPen(SamplingPointColorHi);
p.drawRects(sampling_points[2].data(), sampling_points[2].size());
} else {
- p.setPen(SamplingPointColour);
+ p.setPen(SamplingPointColor);
p.drawRects(sampling_points[0].data(), sampling_points[0].size());
}
}
return;
p.setPen(QPen(Qt::NoPen));
- p.setBrush(base_->colour());
+ p.setBrush(base_->color());
QRectF *const rects = new QRectF[e.length];
QRectF *rect = rects;
sampling_point_x += pixels_per_sample;
};
- p.setPen(LogicSignal::EdgeColour);
+ p.setPen(LogicSignal::EdgeColor);
p.drawLines(edge_lines, edge_count);
delete[] edge_lines;
const unsigned int max_cap_line_count = edges.size();
QLineF *const cap_lines = new QLineF[max_cap_line_count];
- p.setPen(LogicSignal::HighColour);
+ p.setPen(LogicSignal::HighColor);
paint_logic_caps(p, cap_lines, edges, true, samples_per_pixel,
pixels_offset, pp.left(), high_offset);
- p.setPen(LogicSignal::LowColour);
+ p.setPen(LogicSignal::LowColor);
paint_logic_caps(p, cap_lines, edges, false, samples_per_pixel,
pixels_offset, pp.left(), low_offset);
// Paint the sampling points
if (show_sampling_points) {
- p.setPen(SamplingPointColour);
+ p.setPen(SamplingPointColor);
p.drawRects(sampling_points.data(), sampling_points.size());
}
}
private:
static const QPen AxisPen;
- static const QColor SignalColours[4];
+ static const QColor SignalColors[4];
static const QColor GridMajorColor, GridMinorColor;
- static const QColor SamplingPointColour;
- static const QColor SamplingPointColourLo;
- static const QColor SamplingPointColourNe;
- static const QColor SamplingPointColourHi;
+ static const QColor SamplingPointColor;
+ static const QColor SamplingPointColorLo;
+ static const QColor SamplingPointColorNe;
+ static const QColor SamplingPointColorHi;
static const QColor ThresholdColor;
static const QColor ThresholdColorLo;
static const QColor ThresholdColorNe;
namespace views {
namespace trace {
-const QColor Cursor::FillColour(52, 101, 164);
+const QColor Cursor::FillColor(52, 101, 164);
Cursor::Cursor(View &view, double time) :
- TimeMarker(view, FillColour, time)
+ TimeMarker(view, FillColor, time)
{
}
Q_OBJECT
public:
- static const QColor FillColour;
+ static const QColor FillColor;
public:
/**
namespace trace {
const int CursorPair::DeltaPadding = 8;
-const QColor CursorPair::ViewportFillColour(220, 231, 243);
+const QColor CursorPair::ViewportFillColor(220, 231, 243);
CursorPair::CursorPair(View &view) :
TimeItem(view),
if (!enabled())
return;
- const QColor text_colour =
- ViewItem::select_text_colour(Cursor::FillColour);
+ const QColor text_color =
+ ViewItem::select_text_color(Cursor::FillColor);
- p.setPen(text_colour);
+ p.setPen(text_color);
compute_text_size(p);
QRectF delta_rect(label_rect(rect));
p.drawRoundedRect(delta_rect, radius, radius);
}
- p.setBrush(hover ? Cursor::FillColour.lighter() :
- Cursor::FillColour);
- p.setPen(Cursor::FillColour.darker());
+ p.setBrush(hover ? Cursor::FillColor.lighter() :
+ Cursor::FillColor);
+ p.setPen(Cursor::FillColor.darker());
p.drawRoundedRect(delta_rect, radius, radius);
delta_rect.adjust(1, 1, -1, -1);
- p.setPen(Cursor::FillColour.lighter());
+ p.setPen(Cursor::FillColor.lighter());
p.drawRoundedRect(delta_rect, highlight_radius, highlight_radius);
- p.setPen(text_colour);
+ p.setPen(text_color);
p.drawText(text_rect, Qt::AlignCenter | Qt::AlignVCenter,
format_string());
}
return;
p.setPen(Qt::NoPen);
- p.setBrush(QBrush(ViewportFillColour));
+ p.setBrush(QBrush(ViewportFillColor));
const pair<float, float> offsets(get_cursor_offsets());
const int l = (int)max(min(
{
private:
static const int DeltaPadding;
- static const QColor ViewportFillColour;
+ static const QColor ViewportFillColor;
public:
/**
namespace views {
namespace trace {
-const QColor DecodeTrace::DecodeColours[4] = {
+const QColor DecodeTrace::DecodeColors[4] = {
QColor(0xEF, 0x29, 0x29), // Red
QColor(0xFC, 0xE9, 0x4F), // Yellow
QColor(0x8A, 0xE2, 0x34), // Green
QColor(0x72, 0x9F, 0xCF) // Blue
};
-const QColor DecodeTrace::ErrorBgColour = QColor(0xEF, 0x29, 0x29);
-const QColor DecodeTrace::NoDecodeColour = QColor(0x88, 0x8A, 0x85);
+const QColor DecodeTrace::ErrorBgColor = QColor(0xEF, 0x29, 0x29);
+const QColor DecodeTrace::NoDecodeColor = QColor(0x88, 0x8A, 0x85);
const int DecodeTrace::ArrowSize = 4;
const double DecodeTrace::EndCapWidth = 5;
const int DecodeTrace::MaxTraceUpdateRate = 1; // No more than 1 Hz
-const QColor DecodeTrace::Colours[16] = {
+const QColor DecodeTrace::Colors[16] = {
QColor(0xEF, 0x29, 0x29),
QColor(0xF6, 0x6A, 0x32),
QColor(0xFC, 0xAE, 0x3E),
QColor(0xD7, 0x47, 0x6F)
};
-const QColor DecodeTrace::OutlineColours[16] = {
+const QColor DecodeTrace::OutlineColors[16] = {
QColor(0x77, 0x14, 0x14),
QColor(0x7B, 0x35, 0x19),
QColor(0x7E, 0x57, 0x1F),
QFontMetrics m(QApplication::font());
min_useful_label_width_ = m.width("XX"); // e.g. two hex characters
- base_->set_colour(DecodeColours[index % countof(DecodeColours)]);
+ base_->set_color(DecodeColors[index % countof(DecodeColors)]);
connect(decode_signal_.get(), SIGNAL(new_annotations()),
this, SLOT(on_new_annotations()));
}
// Determine the row's color
- size_t base_colour = 0x13579BDF;
- boost::hash_combine(base_colour, this);
- boost::hash_combine(base_colour, row.decoder());
- boost::hash_combine(base_colour, row.row());
- base_colour >>= 16;
+ size_t base_color = 0x13579BDF;
+ boost::hash_combine(base_color, this);
+ boost::hash_combine(base_color, row.decoder());
+ boost::hash_combine(base_color, row.row());
+ base_color >>= 16;
vector<Annotation> annotations;
decode_signal_->get_annotation_subset(annotations, row,
current_segment_, sample_range.first, sample_range.second);
if (!annotations.empty()) {
draw_annotations(annotations, p, annotation_height, pp, y,
- base_colour, row_title_width);
+ base_color, row_title_width);
y += row_height_;
void DecodeTrace::draw_annotations(vector<pv::data::decode::Annotation> annotations,
QPainter &p, int h, const ViewItemPaintParams &pp, int y,
- size_t base_colour, int row_title_width)
+ size_t base_color, int row_title_width)
{
using namespace pv::data::decode;
if ((abs(delta) > 1) || a_is_separate) {
// Block was broken, draw annotations that form the current block
if (a_block.size() == 1) {
- draw_annotation(a_block.front(), p, h, pp, y, base_colour,
+ draw_annotation(a_block.front(), p, h, pp, y, base_color,
row_title_width);
}
else
- draw_annotation_block(a_block, p, h, y, base_colour);
+ draw_annotation_block(a_block, p, h, y, base_color);
a_block.clear();
}
if (a_is_separate) {
- draw_annotation(a, p, h, pp, y, base_colour, row_title_width);
+ draw_annotation(a, p, h, pp, y, base_color, row_title_width);
// Next annotation must start a new block. delta will be > 1
// because we set p_end to INT_MIN but that's okay since
// a_block will be empty, so nothing will be drawn
}
if (a_block.size() == 1)
- draw_annotation(a_block.front(), p, h, pp, y, base_colour,
+ draw_annotation(a_block.front(), p, h, pp, y, base_color,
row_title_width);
else
- draw_annotation_block(a_block, p, h, y, base_colour);
+ draw_annotation_block(a_block, p, h, y, base_color);
}
void DecodeTrace::draw_annotation(const pv::data::decode::Annotation &a,
QPainter &p, int h, const ViewItemPaintParams &pp, int y,
- size_t base_colour, int row_title_width) const
+ size_t base_color, int row_title_width) const
{
double samples_per_pixel, pixels_offset;
tie(pixels_offset, samples_per_pixel) =
pixels_offset;
const double end = a.end_sample() / samples_per_pixel - pixels_offset;
- const size_t colour = (base_colour + a.format()) % countof(Colours);
- p.setPen(OutlineColours[colour]);
- p.setBrush(Colours[colour]);
+ const size_t color = (base_color + a.format()) % countof(Colors);
+ p.setPen(OutlineColors[color]);
+ p.setBrush(Colors[color]);
if (start > pp.right() + DrawPadding || end < pp.left() - DrawPadding)
return;
void DecodeTrace::draw_annotation_block(
vector<pv::data::decode::Annotation> annotations, QPainter &p, int h,
- int y, size_t base_colour) const
+ int y, size_t base_color) const
{
using namespace pv::data::decode;
const double top = y + .5 - h / 2;
const double bottom = y + .5 + h / 2;
- const size_t colour = (base_colour + annotations.front().format()) %
- countof(Colours);
+ const size_t color = (base_color + annotations.front().format()) %
+ countof(Colors);
// Check if all annotations are of the same type (i.e. we can use one color)
// or if we should use a neutral color (i.e. gray)
p.setBrush(Qt::white);
p.drawRoundedRect(rect, r, r);
- p.setPen((single_format ? OutlineColours[colour] : Qt::gray));
- p.setBrush(QBrush((single_format ? Colours[colour] : Qt::gray),
+ p.setPen((single_format ? OutlineColors[color] : Qt::gray));
+ p.setBrush(QBrush((single_format ? Colors[color] : Qt::gray),
Qt::Dense4Pattern));
p.drawRoundedRect(rect, r, r);
}
{
const int y = get_visual_y();
- p.setPen(ErrorBgColour.darker());
- p.setBrush(ErrorBgColour);
+ p.setPen(ErrorBgColor.darker());
+ p.setBrush(ErrorBgColor);
const QRectF bounding_rect =
QRectF(pp.left(), INT_MIN / 2 + y, pp.right(), INT_MAX);
p.setBrush(Qt::white);
p.drawRect(no_decode_rect);
- p.setPen(NoDecodeColour);
- p.setBrush(QBrush(NoDecodeColour, Qt::Dense6Pattern));
+ p.setPen(NoDecodeColor);
+ p.setBrush(QBrush(NoDecodeColor, Qt::Dense6Pattern));
p.drawRect(no_decode_rect);
}
Q_OBJECT
private:
- static const QColor DecodeColours[4];
- static const QColor ErrorBgColour;
- static const QColor NoDecodeColour;
+ static const QColor DecodeColors[4];
+ static const QColor ErrorBgColor;
+ static const QColor NoDecodeColor;
static const int ArrowSize;
static const double EndCapWidth;
static const int MaxTraceUpdateRate;
- static const QColor Colours[16];
- static const QColor OutlineColours[16];
+ static const QColor Colors[16];
+ static const QColor OutlineColors[16];
public:
DecodeTrace(pv::Session &session, shared_ptr<data::SignalBase> signalbase,
private:
void draw_annotations(vector<pv::data::decode::Annotation> annotations,
QPainter &p, int h, const ViewItemPaintParams &pp, int y,
- size_t base_colour, int row_title_width);
+ size_t base_color, int row_title_width);
void draw_annotation(const pv::data::decode::Annotation &a, QPainter &p,
int h, const ViewItemPaintParams &pp, int y,
- size_t base_colour, int row_title_width) const;
+ size_t base_color, int row_title_width) const;
void draw_annotation_block(vector<pv::data::decode::Annotation> annotations,
- QPainter &p, int h, int y, size_t base_colour) const;
+ QPainter &p, int h, int y, size_t base_color) const;
void draw_instant(const pv::data::decode::Annotation &a, QPainter &p,
int h, double x, int y) const;
namespace views {
namespace trace {
-const QColor Flag::FillColour(0x73, 0xD2, 0x16);
+const QColor Flag::FillColor(0x73, 0xD2, 0x16);
Flag::Flag(View &view, const pv::util::Timestamp& time, const QString &text) :
- TimeMarker(view, FillColour, time),
+ TimeMarker(view, FillColor, time),
text_(text)
{
}
Flag::Flag(const Flag &flag) :
- TimeMarker(flag.view_, FillColour, flag.time_),
+ TimeMarker(flag.view_, FillColor, flag.time_),
enable_shared_from_this<Flag>(flag)
{
}
Q_OBJECT
public:
- static const QColor FillColour;
+ static const QColor FillColor;
public:
/**
const float LogicSignal::Oversampling = 2.0f;
-const QColor LogicSignal::EdgeColour(0x80, 0x80, 0x80);
-const QColor LogicSignal::HighColour(0x00, 0xC0, 0x00);
-const QColor LogicSignal::LowColour(0xC0, 0x00, 0x00);
-const QColor LogicSignal::SamplingPointColour(0x77, 0x77, 0x77);
+const QColor LogicSignal::EdgeColor(0x80, 0x80, 0x80);
+const QColor LogicSignal::HighColor(0x00, 0xC0, 0x00);
+const QColor LogicSignal::LowColor(0xC0, 0x00, 0x00);
+const QColor LogicSignal::SamplingPointColor(0x77, 0x77, 0x77);
-const QColor LogicSignal::SignalColours[10] = {
+const QColor LogicSignal::SignalColors[10] = {
QColor(0x16, 0x19, 0x1A), // Black
QColor(0x8F, 0x52, 0x02), // Brown
QColor(0xCC, 0x00, 0x00), // Red
QColor(0xEE, 0xEE, 0xEC), // White
};
-QColor LogicSignal::TriggerMarkerBackgroundColour = QColor(0xED, 0xD4, 0x00);
+QColor LogicSignal::TriggerMarkerBackgroundColor = QColor(0xED, 0xD4, 0x00);
const int LogicSignal::TriggerMarkerPadding = 2;
const char* LogicSignal::TriggerMarkerIcons[8] = {
nullptr,
{
shared_ptr<Trigger> trigger;
- base_->set_colour(SignalColours[base->index() % countof(SignalColours)]);
+ base_->set_color(SignalColors[base->index() % countof(SignalColors)]);
GlobalSettings gs;
signal_height_ = gs.value(GlobalSettings::Key_View_DefaultLogicHeight).toInt();
sampling_point_x += pixels_per_sample;
};
- p.setPen(EdgeColour);
+ p.setPen(EdgeColor);
p.drawLines(edge_lines, edge_count);
delete[] edge_lines;
const unsigned int max_cap_line_count = edges.size();
QLineF *const cap_lines = new QLineF[max_cap_line_count];
- p.setPen(HighColour);
+ p.setPen(HighColor);
paint_caps(p, cap_lines, edges, true, samples_per_pixel,
pixels_offset, pp.left(), high_offset);
- p.setPen(LowColour);
+ p.setPen(LowColor);
paint_caps(p, cap_lines, edges, false, samples_per_pixel,
pixels_offset, pp.left(), low_offset);
// Paint the sampling points
if (show_sampling_points) {
- p.setPen(SamplingPointColour);
+ p.setPen(SamplingPointColor);
p.drawRects(sampling_points.data(), sampling_points.size());
}
}
pp.right() - size.width() - pad * 2,
y - (signal_height_ + size.height()) / 2);
- p.setPen(QPen(TriggerMarkerBackgroundColour.darker()));
- p.setBrush(TriggerMarkerBackgroundColour);
+ p.setPen(QPen(TriggerMarkerBackgroundColor.darker()));
+ p.setBrush(TriggerMarkerBackgroundColor);
p.drawRoundedRect(QRectF(point, size).adjusted(
-pad, -pad, pad, pad), pad, pad);
p.drawPixmap(point, *pixmap);
public:
static const float Oversampling;
- static const QColor EdgeColour;
- static const QColor HighColour;
- static const QColor LowColour;
- static const QColor SamplingPointColour;
+ static const QColor EdgeColor;
+ static const QColor HighColor;
+ static const QColor LowColor;
+ static const QColor SamplingPointColor;
- static const QColor SignalColours[10];
+ static const QColor SignalColors[10];
- static QColor TriggerMarkerBackgroundColour;
+ static QColor TriggerMarkerBackgroundColor;
static const int TriggerMarkerPadding;
static const char* TriggerMarkerIcons[8];
form->addRow(tr("Name"), name_widget_);
- add_colour_option(parent, form);
+ add_color_option(parent, form);
}
QMenu* Signal::create_context_menu(QWidget *parent)
const int TimeMarker::ArrowSize = 4;
TimeMarker::TimeMarker(
- View &view, const QColor &colour, const pv::util::Timestamp& time) :
+ View &view, const QColor &color, const pv::util::Timestamp& time) :
TimeItem(view),
- colour_(colour),
+ color_(color),
time_(time),
value_action_(nullptr),
value_widget_(nullptr),
}
p.setPen(Qt::transparent);
- p.setBrush(hover ? colour_.lighter() : colour_);
+ p.setBrush(hover ? color_.lighter() : color_);
p.drawPolygon(points, countof(points));
- p.setPen(colour_.lighter());
+ p.setPen(color_.lighter());
p.setBrush(Qt::transparent);
p.drawPolygon(highlight_points, countof(highlight_points));
- p.setPen(colour_.darker());
+ p.setPen(color_.darker());
p.setBrush(Qt::transparent);
p.drawPolygon(points, countof(points));
- p.setPen(select_text_colour(colour_));
+ p.setPen(select_text_color(color_));
p.drawText(r, Qt::AlignCenter | Qt::AlignVCenter, get_text());
}
return;
const float x = get_x();
- p.setPen(colour_.darker());
+ p.setPen(color_.darker());
p.drawLine(QPointF(x, pp.top()), QPointF(x, pp.bottom()));
}
/**
* Constructor.
* @param view A reference to the view that owns this marker.
- * @param colour A reference to the colour of this cursor.
+ * @param color A reference to the color of this cursor.
* @param time The time to set the flag to.
*/
- TimeMarker(View &view, const QColor &colour, const pv::util::Timestamp& time);
+ TimeMarker(View &view, const QColor &color, const pv::util::Timestamp& time);
public:
/**
void on_value_changed(const pv::util::Timestamp& value);
protected:
- const QColor &colour_;
+ const QColor &color_;
pv::util::Timestamp time_;
#include "view.hpp"
#include "pv/globalsettings.hpp"
-#include "pv/widgets/colourbutton.hpp"
+#include "pv/widgets/colorbutton.hpp"
#include "pv/widgets/popup.hpp"
using std::pair;
const QPen Trace::AxisPen(QColor(0, 0, 0, 30 * 256 / 100));
const int Trace::LabelHitPadding = 2;
-const QColor Trace::BrightGrayBGColour = QColor(0, 0, 0, 10 * 255 / 100);
-const QColor Trace::DarkGrayBGColour = QColor(0, 0, 0, 15 * 255 / 100);
+const QColor Trace::BrightGrayBGColor = QColor(0, 0, 0, 10 * 255 / 100);
+const QColor Trace::DarkGrayBGColor = QColor(0, 0, 0, 15 * 255 / 100);
Trace::Trace(shared_ptr<data::SignalBase> channel) :
base_(channel),
{
connect(channel.get(), SIGNAL(name_changed(const QString&)),
this, SLOT(on_name_changed(const QString&)));
- connect(channel.get(), SIGNAL(colour_changed(const QColor&)),
- this, SLOT(on_colour_changed(const QColor&)));
+ connect(channel.get(), SIGNAL(color_changed(const QColor&)),
+ this, SLOT(on_color_changed(const QColor&)));
}
shared_ptr<data::SignalBase> Trace::base() const
{
const int y = get_visual_y();
- p.setBrush(base_->colour());
+ p.setBrush(base_->color());
if (!enabled())
return;
}
p.setPen(Qt::transparent);
- p.setBrush(hover ? base_->colour().lighter() : base_->colour());
+ p.setBrush(hover ? base_->color().lighter() : base_->color());
p.drawPolygon(points, countof(points));
- p.setPen(base_->colour().lighter());
+ p.setPen(base_->color().lighter());
p.setBrush(Qt::transparent);
p.drawPolygon(highlight_points, countof(highlight_points));
- p.setPen(base_->colour().darker());
+ p.setPen(base_->color().darker());
p.setBrush(Qt::transparent);
p.drawPolygon(points, countof(points));
// Paint the text
- p.setPen(select_text_colour(base_->colour()));
+ p.setPen(select_text_color(base_->color()));
p.setFont(QApplication::font());
p.drawText(QRectF(r.x(), r.y(),
r.width() - label_arrow_length, r.height()),
const View *view = owner_->view();
assert(view);
- if (view->coloured_bg())
- p.setBrush(base_->bgcolour());
+ if (view->colored_bg())
+ p.setBrush(base_->bgcolor());
else
- p.setBrush(pp.next_bg_colour_state() ? BrightGrayBGColour : DarkGrayBGColour);
+ p.setBrush(pp.next_bg_color_state() ? BrightGrayBGColor : DarkGrayBGColor);
p.setPen(QPen(Qt::NoPen));
p.setRenderHint(QPainter::Antialiasing, true);
}
-void Trace::add_colour_option(QWidget *parent, QFormLayout *form)
+void Trace::add_color_option(QWidget *parent, QFormLayout *form)
{
- using pv::widgets::ColourButton;
+ using pv::widgets::ColorButton;
- ColourButton *const colour_button = new ColourButton(
+ ColorButton *const color_button = new ColorButton(
TracePalette::Rows, TracePalette::Cols, parent);
- colour_button->set_palette(TracePalette::Colours);
- colour_button->set_colour(base_->colour());
- connect(colour_button, SIGNAL(selected(const QColor&)),
- this, SLOT(on_colouredit_changed(const QColor&)));
+ color_button->set_palette(TracePalette::Colors);
+ color_button->set_color(base_->color());
+ connect(color_button, SIGNAL(selected(const QColor&)),
+ this, SLOT(on_coloredit_changed(const QColor&)));
- form->addRow(tr("Colour"), colour_button);
+ form->addRow(tr("Color"), color_button);
}
void Trace::create_popup_form()
this, SLOT(on_nameedit_changed(const QString&)));
form->addRow(tr("Name"), name_edit);
- add_colour_option(parent, form);
+ add_color_option(parent, form);
}
void Trace::set_name(QString name)
base_->set_name(name);
}
-void Trace::set_colour(QColor colour)
+void Trace::set_color(QColor color)
{
- base_->set_colour(colour);
+ base_->set_color(color);
}
void Trace::set_segment_display_mode(SegmentDisplayMode mode)
}
}
-void Trace::on_colour_changed(const QColor &colour)
+void Trace::on_color_changed(const QColor &color)
{
- /* This event handler is called by SignalBase when the colour was changed there */
- (void)colour;
+ /* This event handler is called by SignalBase when the color was changed there */
+ (void)color;
if (owner_)
owner_->row_item_appearance_changed(true, true);
set_name(name);
}
-void Trace::on_colouredit_changed(const QColor &colour)
+void Trace::on_coloredit_changed(const QColor &color)
{
- /* This event handler notifies SignalBase that the colour changed */
- set_colour(colour);
+ /* This event handler notifies SignalBase that the color changed */
+ set_color(color);
}
} // namespace trace
static const QPen AxisPen;
static const int LabelHitPadding;
- static const QColor BrightGrayBGColour;
- static const QColor DarkGrayBGColour;
+ static const QColor BrightGrayBGColor;
+ static const QColor DarkGrayBGColor;
protected:
Trace(shared_ptr<data::SignalBase> channel);
virtual void set_name(QString name);
/**
- * Set the colour of the signal.
+ * Set the color of the signal.
*/
- virtual void set_colour(QColor colour);
+ virtual void set_color(QColor color);
/**
* Configures the segment display mode to use.
*/
void paint_axis(QPainter &p, ViewItemPaintParams &pp, int y);
- void add_colour_option(QWidget *parent, QFormLayout *form);
+ void add_color_option(QWidget *parent, QFormLayout *form);
void create_popup_form();
protected Q_SLOTS:
virtual void on_name_changed(const QString &text);
- virtual void on_colour_changed(const QColor &colour);
+ virtual void on_color_changed(const QColor &color);
void on_popup_closed();
private Q_SLOTS:
void on_nameedit_changed(const QString &name);
- void on_colouredit_changed(const QColor &colour);
+ void on_coloredit_changed(const QColor &color);
protected:
shared_ptr<data::SignalBase> base_;
const int TraceGroup::Padding = 8;
const int TraceGroup::Width = 12;
const int TraceGroup::LineThickness = 5;
-const QColor TraceGroup::LineColour(QColor(0x55, 0x57, 0x53));
+const QColor TraceGroup::LineColor(QColor(0x55, 0x57, 0x53));
TraceGroup::~TraceGroup()
{
p.drawPolyline(points, countof(points));
}
- p.setPen(QPen(QBrush(LineColour.darker()), LineThickness,
+ p.setPen(QPen(QBrush(LineColor.darker()), LineThickness,
Qt::SolidLine, Qt::SquareCap, Qt::RoundJoin));
p.drawPolyline(points, countof(points));
- p.setPen(QPen(QBrush(hover ? LineColour.lighter() : LineColour),
+ p.setPen(QPen(QBrush(hover ? LineColor.lighter() : LineColor),
LineThickness - 2, Qt::SolidLine, Qt::SquareCap,
Qt::RoundJoin));
p.drawPolyline(points, countof(points));
static const int Padding;
static const int Width;
static const int LineThickness;
- static const QColor LineColour;
+ static const QColor LineColor;
public:
/**
namespace views {
namespace trace {
-const QColor TracePalette::Colours[Cols * Rows] = {
+const QColor TracePalette::Colors[Cols * Rows] = {
- // Light Colours
+ // Light Colors
QColor(0xFC, 0xE9, 0x4F), // Butter
QColor(0xFC, 0xAF, 0x3E), // Orange
QColor(0xE9, 0xB9, 0x6E), // Chocolate
QColor(0xCF, 0x72, 0xC3), // Magenta
QColor(0xEF, 0x29, 0x29), // Scarlet Red
- // Mid Colours
+ // Mid Colors
QColor(0xED, 0xD4, 0x00), // Butter
QColor(0xF5, 0x79, 0x00), // Orange
QColor(0xC1, 0x7D, 0x11), // Chocolate
QColor(0xA3, 0x34, 0x96), // Magenta
QColor(0xCC, 0x00, 0x00), // Scarlet Red
- // Dark Colours
+ // Dark Colors
QColor(0xC4, 0xA0, 0x00), // Butter
QColor(0xCE, 0x5C, 0x00), // Orange
QColor(0x8F, 0x59, 0x02), // Chocolate
public:
static const unsigned int Cols = 8;
static const unsigned int Rows = 4;
- static const QColor Colours[Cols * Rows];
+ static const QColor Colors[Cols * Rows];
};
} // namespace trace
namespace views {
namespace trace {
-const QColor TriggerMarker::Colour(0x00, 0x00, 0xB0);
+const QColor TriggerMarker::Color(0x00, 0x00, 0xB0);
TriggerMarker::TriggerMarker(View &view, const pv::util::Timestamp& time) :
TimeItem(view),
if (!enabled())
return;
- QPen pen(Colour);
+ QPen pen(Color);
pen.setStyle(Qt::DashLine);
const float x = get_x();
Q_OBJECT
public:
- static const QColor Colour;
+ static const QColor Color;
public:
/**
// Set up settings and event handlers
GlobalSettings settings;
- coloured_bg_ = settings.value(GlobalSettings::Key_View_ColouredBG).toBool();
+ colored_bg_ = settings.value(GlobalSettings::Key_View_ColoredBG).toBool();
GlobalSettings::add_change_handler(this);
viewport_->update();
}
-void View::enable_coloured_bg(bool state)
+void View::enable_colored_bg(bool state)
{
- coloured_bg_ = state;
+ colored_bg_ = state;
viewport_->update();
}
-bool View::coloured_bg() const
+bool View::colored_bg() const
{
- return coloured_bg_;
+ return colored_bg_;
}
bool View::cursors_shown() const
pair<pv::util::Timestamp, pv::util::Timestamp> get_time_extents() const;
/**
- * Enables or disables coloured trace backgrounds. If they're not
- * coloured then they will use alternating colors.
+ * Enables or disables colored trace backgrounds. If they're not
+ * colored then they will use alternating colors.
*/
- void enable_coloured_bg(bool state);
+ void enable_colored_bg(bool state);
/**
- * Returns true if the trace background should be drawn with a coloured background.
+ * Returns true if the trace background should be drawn with a colored background.
*/
- bool coloured_bg() const;
+ bool colored_bg() const;
/**
* Enable or disable showing sampling points.
bool header_was_shrunk_;
bool sticky_scrolling_;
- bool coloured_bg_;
+ bool colored_bg_;
bool always_zoom_to_fit_;
pv::util::Timestamp tick_period_;
(void)pp;
}
-QColor ViewItem::select_text_colour(QColor background)
+QColor ViewItem::select_text_color(QColor background)
{
return (background.lightness() > 110) ? Qt::black : Qt::white;
}
public:
/**
- * Gets the text colour.
- * @remarks This colour is computed by comparing the lightness
- * of the trace colour against a threshold to determine whether
+ * Gets the text color.
+ * @remarks This color is computed by comparing the lightness
+ * of the trace color against a threshold to determine whether
* white or black would be more visible.
*/
- static QColor select_text_colour(QColor background);
+ static QColor select_text_color(QColor background);
public:
virtual QMenu* create_context_menu(QWidget *parent);
rect_(rect),
scale_(scale),
offset_(offset),
- bg_colour_state_(false)
+ bg_color_state_(false)
{
assert(scale > 0.0);
}
return (offset_ / scale_).convert_to<double>();
}
- bool next_bg_colour_state() {
- const bool state = bg_colour_state_;
- bg_colour_state_ = !bg_colour_state_;
+ bool next_bg_color_state() {
+ const bool state = bg_color_state_;
+ bg_color_state_ = !bg_color_state_;
return state;
}
QRect rect_;
double scale_;
pv::util::Timestamp offset_;
- bool bg_colour_state_;
+ bool bg_color_state_;
};
} // namespace trace
--- /dev/null
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "colorbutton.hpp"
+
+#include <cassert>
+
+#include <QApplication>
+#include <QPainter>
+
+namespace pv {
+namespace widgets {
+
+const int ColorButton::SwatchMargin = 7;
+
+ColorButton::ColorButton(int rows, int cols, QWidget *parent) :
+ QPushButton("", parent),
+ popup_(rows, cols, this)
+{
+ connect(this, SIGNAL(clicked(bool)), this, SLOT(on_clicked(bool)));
+ connect(&popup_, SIGNAL(selected(int, int)),
+ this, SLOT(on_selected(int, int)));
+}
+
+ColorPopup& ColorButton::popup()
+{
+ return popup_;
+}
+
+const QColor& ColorButton::color() const
+{
+ return cur_color_;
+}
+
+void ColorButton::set_color(QColor color)
+{
+ cur_color_ = color;
+
+ const unsigned int rows = popup_.well_array().numRows();
+ const unsigned int cols = popup_.well_array().numCols();
+
+ for (unsigned int r = 0; r < rows; r++)
+ for (unsigned int c = 0; c < cols; c++)
+ if (popup_.well_array().cellBrush(r, c).color() == color) {
+ popup_.well_array().setSelected(r, c);
+ popup_.well_array().setCurrent(r, c);
+ return;
+ }
+}
+
+void ColorButton::set_palette(const QColor *const palette)
+{
+ assert(palette);
+
+ const unsigned int rows = popup_.well_array().numRows();
+ const unsigned int cols = popup_.well_array().numCols();
+
+ for (unsigned int r = 0; r < rows; r++)
+ for (unsigned int c = 0; c < cols; c++)
+ popup_.well_array().setCellBrush(r, c,
+ QBrush(palette[r * cols + c]));
+}
+
+void ColorButton::on_clicked(bool)
+{
+ popup_.set_position(mapToGlobal(rect().center()), Popup::Bottom);
+ popup_.show();
+}
+
+void ColorButton::on_selected(int row, int col)
+{
+ cur_color_ = popup_.well_array().cellBrush(row, col).color();
+ selected(cur_color_);
+}
+
+void ColorButton::paintEvent(QPaintEvent *event)
+{
+ QPushButton::paintEvent(event);
+
+ QPainter p(this);
+
+ const QRect r = rect().adjusted(SwatchMargin, SwatchMargin,
+ -SwatchMargin, -SwatchMargin);
+ p.setPen(QApplication::palette().color(QPalette::Dark));
+ p.setBrush(QBrush(cur_color_));
+ p.drawRect(r);
+}
+
+} // namespace widgets
+} // namespace pv
--- /dev/null
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef PULSEVIEW_PV_WIDGETS_COLORBUTTON_HPP
+#define PULSEVIEW_PV_WIDGETS_COLORBUTTON_HPP
+
+#include <QPushButton>
+
+#include "colorpopup.hpp"
+
+namespace pv {
+namespace widgets {
+
+class ColorButton : public QPushButton
+{
+ Q_OBJECT;
+
+private:
+ static const int SwatchMargin;
+
+public:
+ ColorButton(int rows, int cols, QWidget *parent);
+
+ ColorPopup& popup();
+
+ const QColor& color() const;
+
+ void set_color(QColor color);
+
+ void set_palette(const QColor *const palette);
+
+private:
+ void paintEvent(QPaintEvent *event);
+
+private Q_SLOTS:
+ void on_clicked(bool);
+
+ void on_selected(int row, int col);
+
+Q_SIGNALS:
+ void selected(const QColor &color);
+
+private:
+ ColorPopup popup_;
+ QColor cur_color_;
+};
+
+} // namespace widgets
+} // namespace pv
+
+#endif // PULSEVIEW_PV_WIDGETS_COLORBUTTON_HPP
--- /dev/null
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "colorpopup.hpp"
+
+namespace pv {
+namespace widgets {
+
+ColorPopup::ColorPopup(int rows, int cols, QWidget *parent) :
+ Popup(parent),
+ well_array_(rows, cols, this),
+ layout_(this)
+{
+ layout_.addWidget(&well_array_);
+ setLayout(&layout_);
+
+ connect(&well_array_, SIGNAL(selected(int, int)),
+ this, SIGNAL(selected(int, int)));
+ connect(&well_array_, SIGNAL(selected(int, int)),
+ this, SLOT(color_selected(int, int)));
+}
+
+WellArray& ColorPopup::well_array()
+{
+ return well_array_;
+}
+
+void ColorPopup::color_selected(int, int)
+{
+ close();
+}
+
+} // namespace widgets
+} // namespace pv
--- /dev/null
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef PULSEVIEW_PV_WIDGETS_COLORPOPUP_HPP
+#define PULSEVIEW_PV_WIDGETS_COLORPOPUP_HPP
+
+#include "popup.hpp"
+#include "wellarray.hpp"
+
+#include <QVBoxLayout>
+
+namespace pv {
+namespace widgets {
+
+class ColorPopup : public Popup
+{
+ Q_OBJECT
+
+public:
+ ColorPopup(int rows, int cols, QWidget *parent);
+
+ WellArray& well_array();
+
+Q_SIGNALS:
+ void selected(int row, int col);
+
+private Q_SLOTS:
+ void color_selected(int, int);
+
+private:
+ WellArray well_array_;
+ QVBoxLayout layout_;
+};
+
+} // namespace widgets
+} // namespace pv
+
+#endif // PULSEVIEW_PV_WIDGETS_COLORPOPUP_HPP
+++ /dev/null
-/*
- * This file is part of the PulseView project.
- *
- * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "colourbutton.hpp"
-
-#include <cassert>
-
-#include <QApplication>
-#include <QPainter>
-
-namespace pv {
-namespace widgets {
-
-const int ColourButton::SwatchMargin = 7;
-
-ColourButton::ColourButton(int rows, int cols, QWidget *parent) :
- QPushButton("", parent),
- popup_(rows, cols, this)
-{
- connect(this, SIGNAL(clicked(bool)), this, SLOT(on_clicked(bool)));
- connect(&popup_, SIGNAL(selected(int, int)),
- this, SLOT(on_selected(int, int)));
-}
-
-ColourPopup& ColourButton::popup()
-{
- return popup_;
-}
-
-const QColor& ColourButton::colour() const
-{
- return cur_colour_;
-}
-
-void ColourButton::set_colour(QColor colour)
-{
- cur_colour_ = colour;
-
- const unsigned int rows = popup_.well_array().numRows();
- const unsigned int cols = popup_.well_array().numCols();
-
- for (unsigned int r = 0; r < rows; r++)
- for (unsigned int c = 0; c < cols; c++)
- if (popup_.well_array().cellBrush(r, c).color() == colour) {
- popup_.well_array().setSelected(r, c);
- popup_.well_array().setCurrent(r, c);
- return;
- }
-}
-
-void ColourButton::set_palette(const QColor *const palette)
-{
- assert(palette);
-
- const unsigned int rows = popup_.well_array().numRows();
- const unsigned int cols = popup_.well_array().numCols();
-
- for (unsigned int r = 0; r < rows; r++)
- for (unsigned int c = 0; c < cols; c++)
- popup_.well_array().setCellBrush(r, c,
- QBrush(palette[r * cols + c]));
-}
-
-void ColourButton::on_clicked(bool)
-{
- popup_.set_position(mapToGlobal(rect().center()), Popup::Bottom);
- popup_.show();
-}
-
-void ColourButton::on_selected(int row, int col)
-{
- cur_colour_ = popup_.well_array().cellBrush(row, col).color();
- selected(cur_colour_);
-}
-
-void ColourButton::paintEvent(QPaintEvent *event)
-{
- QPushButton::paintEvent(event);
-
- QPainter p(this);
-
- const QRect r = rect().adjusted(SwatchMargin, SwatchMargin,
- -SwatchMargin, -SwatchMargin);
- p.setPen(QApplication::palette().color(QPalette::Dark));
- p.setBrush(QBrush(cur_colour_));
- p.drawRect(r);
-}
-
-} // namespace widgets
-} // namespace pv
+++ /dev/null
-/*
- * This file is part of the PulseView project.
- *
- * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef PULSEVIEW_PV_WIDGETS_COLOURBUTTON_HPP
-#define PULSEVIEW_PV_WIDGETS_COLOURBUTTON_HPP
-
-#include <QPushButton>
-
-#include "colourpopup.hpp"
-
-namespace pv {
-namespace widgets {
-
-class ColourButton : public QPushButton
-{
- Q_OBJECT;
-
-private:
- static const int SwatchMargin;
-
-public:
- ColourButton(int rows, int cols, QWidget *parent);
-
- ColourPopup& popup();
-
- const QColor& colour() const;
-
- void set_colour(QColor colour);
-
- void set_palette(const QColor *const palette);
-
-private:
- void paintEvent(QPaintEvent *event);
-
-private Q_SLOTS:
- void on_clicked(bool);
-
- void on_selected(int row, int col);
-
-Q_SIGNALS:
- void selected(const QColor &colour);
-
-private:
- ColourPopup popup_;
- QColor cur_colour_;
-};
-
-} // namespace widgets
-} // namespace pv
-
-#endif // PULSEVIEW_PV_WIDGETS_COLOURBUTTON_HPP
+++ /dev/null
-/*
- * This file is part of the PulseView project.
- *
- * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "colourpopup.hpp"
-
-namespace pv {
-namespace widgets {
-
-ColourPopup::ColourPopup(int rows, int cols, QWidget *parent) :
- Popup(parent),
- well_array_(rows, cols, this),
- layout_(this)
-{
- layout_.addWidget(&well_array_);
- setLayout(&layout_);
-
- connect(&well_array_, SIGNAL(selected(int, int)),
- this, SIGNAL(selected(int, int)));
- connect(&well_array_, SIGNAL(selected(int, int)),
- this, SLOT(colour_selected(int, int)));
-}
-
-WellArray& ColourPopup::well_array()
-{
- return well_array_;
-}
-
-void ColourPopup::colour_selected(int, int)
-{
- close();
-}
-
-} // namespace widgets
-} // namespace pv
+++ /dev/null
-/*
- * This file is part of the PulseView project.
- *
- * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef PULSEVIEW_PV_WIDGETS_COLOURPOPUP_HPP
-#define PULSEVIEW_PV_WIDGETS_COLOURPOPUP_HPP
-
-#include "popup.hpp"
-#include "wellarray.hpp"
-
-#include <QVBoxLayout>
-
-namespace pv {
-namespace widgets {
-
-class ColourPopup : public Popup
-{
- Q_OBJECT
-
-public:
- ColourPopup(int rows, int cols, QWidget *parent);
-
- WellArray& well_array();
-
-Q_SIGNALS:
- void selected(int row, int col);
-
-private Q_SLOTS:
- void colour_selected(int, int);
-
-private:
- WellArray well_array_;
- QVBoxLayout layout_;
-};
-
-} // namespace widgets
-} // namespace pv
-
-#endif // PULSEVIEW_PV_WIDGETS_COLOURPOPUP_HPP
${PROJECT_SOURCE_DIR}/pv/views/trace/viewwidget.cpp
${PROJECT_SOURCE_DIR}/pv/views/viewbase.cpp
${PROJECT_SOURCE_DIR}/pv/views/trace/standardbar.cpp
- ${PROJECT_SOURCE_DIR}/pv/widgets/colourbutton.cpp
- ${PROJECT_SOURCE_DIR}/pv/widgets/colourpopup.cpp
+ ${PROJECT_SOURCE_DIR}/pv/widgets/colorbutton.cpp
+ ${PROJECT_SOURCE_DIR}/pv/widgets/colorpopup.cpp
${PROJECT_SOURCE_DIR}/pv/widgets/devicetoolbutton.cpp
${PROJECT_SOURCE_DIR}/pv/widgets/exportmenu.cpp
${PROJECT_SOURCE_DIR}/pv/widgets/importmenu.cpp
${PROJECT_SOURCE_DIR}/pv/views/trace/viewwidget.hpp
${PROJECT_SOURCE_DIR}/pv/views/viewbase.hpp
${PROJECT_SOURCE_DIR}/pv/views/trace/standardbar.hpp
- ${PROJECT_SOURCE_DIR}/pv/widgets/colourbutton.hpp
- ${PROJECT_SOURCE_DIR}/pv/widgets/colourpopup.hpp
+ ${PROJECT_SOURCE_DIR}/pv/widgets/colorbutton.hpp
+ ${PROJECT_SOURCE_DIR}/pv/widgets/colorpopup.hpp
${PROJECT_SOURCE_DIR}/pv/widgets/devicetoolbutton.hpp
${PROJECT_SOURCE_DIR}/pv/widgets/exportmenu.hpp
${PROJECT_SOURCE_DIR}/pv/widgets/importmenu.hpp