blob: 2a437aa1fe56368f0a2b08c1dce81d509c16a4d5 (
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
37
38
39
|
#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 EffectiveColour = std::optional<std::reference_wrapper<const RGBA>>;
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 {};
}
static EffectiveColour getColour(const StyleStack & parents);
RGBA colour {};
std::optional<bool> smooth;
std::string texture;
std::string textureRotation; // Multiples of 90deg, no int/enum support
protected:
bool persist(Persistence::PersistenceStore & store);
void applyStyle(ModelFactoryMesh &, const ModelFactoryMesh::FaceHandle &, EffectiveColour) const;
};
|