Skip to content

Commit

Permalink
gui: expand highlights sets from 8 to 16
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
  • Loading branch information
maliberty committed Feb 27, 2025
1 parent a5cf66c commit d0e7d85
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 20 deletions.
40 changes: 29 additions & 11 deletions src/gui/include/gui/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ class Selected;
class Options;

// A collection of selected objects

// Only a finite set of highlight color is supported for now
constexpr int num_highlight_set = 16;
using SelectionSet = std::set<Selected>;
using HighlightSet = std::array<SelectionSet, 8>; // Only 8 Discrete Highlight
// Color is supported for now
using HighlightSet = std::array<SelectionSet, num_highlight_set>;

using DBUToString = std::function<std::string(int, bool)>;
using StringToDBU = std::function<int(const std::string&, bool*)>;
Expand Down Expand Up @@ -119,17 +121,33 @@ class Painter
static inline const Color dark_cyan{0x00, 0x80, 0x80, 0xff};
static inline const Color dark_magenta{0x80, 0x00, 0x80, 0xff};
static inline const Color dark_yellow{0x80, 0x80, 0x00, 0xff};
static inline const Color orange{0xff, 0xa5, 0x00, 0xff};
static inline const Color purple{0x80, 0x00, 0x80, 0xff};
static inline const Color lime{0xbf, 0xff, 0x00, 0xff};
static inline const Color teal{0x00, 0x80, 0x80, 0xff};
static inline const Color pink{0xff, 0xc0, 0xcb, 0xff};
static inline const Color brown{0x8b, 0x45, 0x13, 0xff};
static inline const Color indigo{0x4b, 0x00, 0x82, 0xff};
static inline const Color turquoise{0x40, 0xe0, 0xd0, 0xff};
static inline const Color transparent{0x00, 0x00, 0x00, 0x00};

static inline const std::array<Painter::Color, 8> highlightColors{
Color(Painter::green, 100),
Color(Painter::yellow, 100),
Color(Painter::cyan, 100),
Color(Painter::magenta, 100),
Color(Painter::red, 100),
Color(Painter::dark_green, 100),
Color(Painter::dark_magenta, 100),
Color(Painter::blue, 100)};
static inline const std::array<Painter::Color, num_highlight_set>
highlightColors{Color(Painter::green, 100),
Color(Painter::yellow, 100),
Color(Painter::cyan, 100),
Color(Painter::magenta, 100),
Color(Painter::red, 100),
Color(Painter::dark_green, 100),
Color(Painter::dark_magenta, 100),
Color(Painter::blue, 100),
Color(Painter::orange, 100),
Color(Painter::purple, 100),
Color(Painter::lime, 100),
Color(Painter::teal, 100),
Color(Painter::pink, 100),
Color(Painter::brown, 100),
Color(Painter::indigo, 100),
Color(Painter::turquoise, 100)};

// The color to highlight in
static inline const Color highlight = yellow;
Expand Down
20 changes: 18 additions & 2 deletions src/gui/src/highlightGroupDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ HighlightGroupDialog::HighlightGroupDialog(QWidget* parent) : QDialog(parent)
setButtonBackground(grp6RadioButton, Painter::highlightColors[5]);
setButtonBackground(grp7RadioButton, Painter::highlightColors[6]);
setButtonBackground(grp8RadioButton, Painter::highlightColors[7]);
setButtonBackground(grp9RadioButton, Painter::highlightColors[8]);
setButtonBackground(grp10RadioButton, Painter::highlightColors[9]);
setButtonBackground(grp11RadioButton, Painter::highlightColors[10]);
setButtonBackground(grp12RadioButton, Painter::highlightColors[11]);
setButtonBackground(grp13RadioButton, Painter::highlightColors[12]);
setButtonBackground(grp14RadioButton, Painter::highlightColors[13]);
setButtonBackground(grp15RadioButton, Painter::highlightColors[14]);
setButtonBackground(grp16RadioButton, Painter::highlightColors[15]);
}

void HighlightGroupDialog::setButtonBackground(QRadioButton* button,
Expand All @@ -73,8 +81,16 @@ int HighlightGroupDialog::getSelectedHighlightGroup() const
grp5RadioButton,
grp6RadioButton,
grp7RadioButton,
grp8RadioButton};
for (int i = 0; i < 8; ++i) {
grp8RadioButton,
grp9RadioButton,
grp10RadioButton,
grp11RadioButton,
grp12RadioButton,
grp13RadioButton,
grp14RadioButton,
grp15RadioButton,
grp16RadioButton};
for (int i = 0; i < num_highlight_set; ++i) {
if (highlight_group_buttons[i]->isChecked()) {
return i;
}
Expand Down
70 changes: 63 additions & 7 deletions src/gui/ui/highlightGroupDlg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>230</width>
<height>230</height>
<width>293</width>
<height>315</height>
</rect>
</property>
<property name="minimumSize">
Expand All @@ -31,11 +31,11 @@
<item row="2" column="0">
<widget class="QRadioButton" name="grp3RadioButton">
<property name="text">
<string>Group3</string>
<string>Group 3</string>
</property>
</widget>
</item>
<item row="0" column="1">
<item row="4" column="0">
<widget class="QRadioButton" name="grp5RadioButton">
<property name="text">
<string>Group 5</string>
Expand All @@ -49,7 +49,7 @@
</property>
</widget>
</item>
<item row="1" column="1">
<item row="5" column="0">
<widget class="QRadioButton" name="grp6RadioButton">
<property name="text">
<string>Group 6</string>
Expand All @@ -63,7 +63,7 @@
</property>
</widget>
</item>
<item row="3" column="1">
<item row="7" column="0">
<widget class="QRadioButton" name="grp8RadioButton">
<property name="text">
<string>Group 8</string>
Expand All @@ -77,13 +77,69 @@
</property>
</widget>
</item>
<item row="2" column="1">
<item row="6" column="0">
<widget class="QRadioButton" name="grp7RadioButton">
<property name="text">
<string>Group 7</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="grp9RadioButton">
<property name="text">
<string>Group9</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QRadioButton" name="grp10RadioButton">
<property name="text">
<string>Group 10</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QRadioButton" name="grp11RadioButton">
<property name="text">
<string>Group 11</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QRadioButton" name="grp12RadioButton">
<property name="text">
<string>Group 12</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QRadioButton" name="grp13RadioButton">
<property name="text">
<string>Group 13</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QRadioButton" name="grp14RadioButton">
<property name="text">
<string>Group 14</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QRadioButton" name="grp15RadioButton">
<property name="text">
<string>Group 15</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QRadioButton" name="grp16RadioButton">
<property name="text">
<string>Group 16</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down

0 comments on commit d0e7d85

Please sign in to comment.