blob: 84e5dabc58f859606e4462af9ff1f809349cdd54 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#pragma once
#include "modelFactoryMesh.h"
#include "persistence.h"
#include "shape.h"
#include <optional>
#include <string>
#include <utility>
class Style {
public:
using StyleStack = std::vector<const Style *>;
using Colour = glm::vec3;
using ColourAlpha = glm::vec4;
void applyStyle(ModelFactoryMesh &, const StyleStack & parents, const Shape::CreatedFaces &) const;
void applyStyle(ModelFactoryMesh &, const StyleStack & parents, const ModelFactoryMesh::FaceHandle &) const;
template<typename T>
static std::optional<std::reference_wrapper<const T>>
getProperty(const StyleStack & parents, T Style::*member, auto && test)
{
if (const auto itr = std::find_if(parents.rbegin(), parents.rend(), std::forward<decltype(test)>(test));
itr != parents.rend()) {
return (*itr)->*member;
}
return {};
}
ColourAlpha colour {};
std::string texture;
std::string textureRotation; // Multiples of 90deg, no int/enum support
protected:
bool persist(Persistence::PersistenceStore & store);
};
|