11 #ifndef hifi_render_utils_HighlightStage_h
12 #define hifi_render_utils_HighlightStage_h
16 #include "IndexedContainer.h"
17 #include "HighlightStyle.h"
22 class HighlightStage :
public Stage {
28 Highlight(
const std::string& selectionName,
const HighlightStyle& style) : _selectionName{ selectionName }, _style{ style } { }
30 std::string _selectionName;
31 HighlightStyle _style;
35 static const std::string& getName() {
return _name; }
37 using Index = render::indexed_container::Index;
38 static const Index INVALID_INDEX;
39 using HighlightIdList = render::indexed_container::Indices;
41 static bool isIndexInvalid(Index index) {
return index == INVALID_INDEX; }
43 bool checkHighlightId(Index index)
const {
return _highlights.checkIndex(index); }
45 const Highlight& getHighlight(Index index)
const {
return _highlights.get(index); }
46 Highlight& editHighlight(Index index) {
return _highlights.edit(index); }
48 Index addHighlight(
const std::string& selectionName,
const HighlightStyle& style = HighlightStyle());
49 Index getHighlightIdBySelection(
const std::string& selectionName)
const;
50 void removeHighlight(Index index);
52 HighlightIdList::iterator begin() {
return _activeHighlightIds.begin(); }
53 HighlightIdList::iterator end() {
return _activeHighlightIds.end(); }
54 const HighlightIdList& getActiveHighlightIds()
const {
return _activeHighlightIds; }
58 using Highlights = render::indexed_container::IndexedVector<Highlight>;
60 static std::string _name;
62 Highlights _highlights;
63 HighlightIdList _activeHighlightIds;
65 using HighlightStagePointer = std::shared_ptr<HighlightStage>;
67 class HighlightStageConfig :
public render::Job::Config {
69 Q_PROPERTY(QString selectionName READ getSelectionName WRITE setSelectionName NOTIFY dirty)
70 Q_PROPERTY(
bool isOutlineSmooth READ isOutlineSmooth WRITE setOutlineSmooth NOTIFY dirty)
71 Q_PROPERTY(
float colorR READ getColorRed WRITE setColorRed NOTIFY dirty)
72 Q_PROPERTY(
float colorG READ getColorGreen WRITE setColorGreen NOTIFY dirty)
73 Q_PROPERTY(
float colorB READ getColorBlue WRITE setColorBlue NOTIFY dirty)
74 Q_PROPERTY(
float outlineWidth READ getOutlineWidth WRITE setOutlineWidth NOTIFY dirty)
75 Q_PROPERTY(
float outlineIntensity READ getOutlineIntensity WRITE setOutlineIntensity NOTIFY dirty)
76 Q_PROPERTY(
float unoccludedFillOpacity READ getUnoccludedFillOpacity WRITE setUnoccludedFillOpacity NOTIFY dirty)
77 Q_PROPERTY(
float occludedFillOpacity READ getOccludedFillOpacity WRITE setOccludedFillOpacity NOTIFY dirty)
81 using SelectionStyles = std::map<std::string, HighlightStyle>;
83 QString getSelectionName()
const {
return QString(_selectionName.c_str()); }
84 void setSelectionName(
const QString& name);
86 bool isOutlineSmooth()
const {
return getStyle()._isOutlineSmooth; }
87 void setOutlineSmooth(
bool isSmooth);
89 float getColorRed()
const {
return getStyle()._outlineUnoccluded.color.r; }
90 void setColorRed(
float value);
92 float getColorGreen()
const {
return getStyle()._outlineUnoccluded.color.g; }
93 void setColorGreen(
float value);
95 float getColorBlue()
const {
return getStyle()._outlineUnoccluded.color.b; }
96 void setColorBlue(
float value);
98 float getOutlineWidth()
const {
return getStyle()._outlineWidth; }
99 void setOutlineWidth(
float value);
101 float getOutlineIntensity()
const {
return getStyle()._outlineUnoccluded.alpha; }
102 void setOutlineIntensity(
float value);
104 float getUnoccludedFillOpacity()
const {
return getStyle()._fillUnoccluded.alpha; }
105 void setUnoccludedFillOpacity(
float value);
107 float getOccludedFillOpacity()
const {
return getStyle()._fillOccluded.alpha; }
108 void setOccludedFillOpacity(
float value);
110 std::string _selectionName {
"contextOverlayHighlightList" };
111 mutable SelectionStyles _styles;
113 const HighlightStyle& getStyle()
const;
114 HighlightStyle& editStyle();
120 class HighlightStageSetup {
122 using Config = HighlightStageConfig;
123 using JobModel = render::Job::Model<HighlightStageSetup, Config>;
125 HighlightStageSetup();
127 void configure(
const Config& config);
128 void run(
const RenderContextPointer& renderContext);
132 HighlightStageConfig::SelectionStyles _styles;