Overte C++ Documentation
HighlightStage.h
1 //
2 // HighlightStage.h
3 
4 // Created by Olivier Prat on 07/07/2017.
5 // Copyright 2017 High Fidelity, Inc.
6 // Copyright 2024 Overte e.V.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 #ifndef hifi_render_utils_HighlightStage_h
13 #define hifi_render_utils_HighlightStage_h
14 
15 #include "Engine.h"
16 #include "HighlightStyle.h"
17 #include "Stage.h"
18 
19 namespace render {
20 
21  class Highlight {
22  public:
23  Highlight(const std::string& selectionName, const HighlightStyle& style) : _selectionName{ selectionName }, _style{ style } { }
24 
25  std::string _selectionName;
26  HighlightStyle _style;
27  };
28 
29  // Highlight stage to set up HighlightStyle-related effects
30  class HighlightStage : public TypedStage<Highlight> {
31  public:
32  Index addHighlight(const std::string& selectionName, const HighlightStyle& style = HighlightStyle());
33  Index getHighlightIdBySelection(const std::string& selectionName) const;
34 
35  const IDList& getActiveHighlightIds() const { return _activeElementIDs; }
36  };
37  using HighlightStagePointer = std::shared_ptr<HighlightStage>;
38 
39  class HighlightStageConfig : public render::Job::Config {
40  Q_OBJECT
41  Q_PROPERTY(QString selectionName READ getSelectionName WRITE setSelectionName NOTIFY dirty)
42  Q_PROPERTY(bool isOutlineSmooth READ isOutlineSmooth WRITE setOutlineSmooth NOTIFY dirty)
43  Q_PROPERTY(float colorR READ getColorRed WRITE setColorRed NOTIFY dirty)
44  Q_PROPERTY(float colorG READ getColorGreen WRITE setColorGreen NOTIFY dirty)
45  Q_PROPERTY(float colorB READ getColorBlue WRITE setColorBlue NOTIFY dirty)
46  Q_PROPERTY(float outlineWidth READ getOutlineWidth WRITE setOutlineWidth NOTIFY dirty)
47  Q_PROPERTY(float outlineIntensity READ getOutlineIntensity WRITE setOutlineIntensity NOTIFY dirty)
48  Q_PROPERTY(float unoccludedFillOpacity READ getUnoccludedFillOpacity WRITE setUnoccludedFillOpacity NOTIFY dirty)
49  Q_PROPERTY(float occludedFillOpacity READ getOccludedFillOpacity WRITE setOccludedFillOpacity NOTIFY dirty)
50 
51  public:
52 
53  using SelectionStyles = std::map<std::string, HighlightStyle>;
54 
55  QString getSelectionName() const { return QString(_selectionName.c_str()); }
56  void setSelectionName(const QString& name);
57 
58  bool isOutlineSmooth() const { return getStyle()._isOutlineSmooth; }
59  void setOutlineSmooth(bool isSmooth);
60 
61  float getColorRed() const { return getStyle()._outlineUnoccluded.color.r; }
62  void setColorRed(float value);
63 
64  float getColorGreen() const { return getStyle()._outlineUnoccluded.color.g; }
65  void setColorGreen(float value);
66 
67  float getColorBlue() const { return getStyle()._outlineUnoccluded.color.b; }
68  void setColorBlue(float value);
69 
70  float getOutlineWidth() const { return getStyle()._outlineWidth; }
71  void setOutlineWidth(float value);
72 
73  float getOutlineIntensity() const { return getStyle()._outlineUnoccluded.alpha; }
74  void setOutlineIntensity(float value);
75 
76  float getUnoccludedFillOpacity() const { return getStyle()._fillUnoccluded.alpha; }
77  void setUnoccludedFillOpacity(float value);
78 
79  float getOccludedFillOpacity() const { return getStyle()._fillOccluded.alpha; }
80  void setOccludedFillOpacity(float value);
81 
82  std::string _selectionName { "contextOverlayHighlightList" };
83  mutable SelectionStyles _styles;
84 
85  const HighlightStyle& getStyle() const;
86  HighlightStyle& editStyle();
87 
88  signals:
89  void dirty();
90  };
91 
92  class HighlightStageSetup {
93  public:
94  using Config = HighlightStageConfig;
95  using JobModel = render::Job::Model<HighlightStageSetup, Config>;
96 
97  HighlightStageSetup() {}
98 
99  void configure(const Config& config);
100  void run(const RenderContextPointer& renderContext);
101 
102  protected:
103 
104  HighlightStageConfig::SelectionStyles _styles;
105  };
106 
107 }
108 #endif // hifi_render_utils_HighlightStage_h