-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerateManagerFactory.py
83 lines (66 loc) · 3.39 KB
/
generateManagerFactory.py
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from stringUtils import *
import addFunctionWrappers
onlyExperimental = ["vr_camera"]
def generate(animationTypes, animationManagerFilePath):
fileContents = """#include "KAnimationManagerFactory.h"
#include "animation/KAnimationManager.h"
"""
for animationType in animationTypes:
capitalizedName = capitalize(animationType)
fileContents += '#include "animation/types/' + animationType + '/K' + capitalizedName + 'ViewFactory.h"\n'
fileContents += '#include "animation/types/' + animationType + '/K' + capitalizedName + 'NodeFactory.h"\n'
fileContents += '#include "kscene/animation/types/' + animationType + '/K' + capitalizedName + 'AnimationType.h"\n'
fileContents += """
struct KAnimationManagerFactory::Private
{
Private(QPointer<KUndoStack> undoStack) : """
index = 0
for animationType in animationTypes:
capitalizedName = capitalize(animationType)
camelCaseName = capitalizedName[0].lower() + capitalizedName[1:]
fileContents += camelCaseName + 'ViewFactory(undoStack)'
if index < len(animationTypes) - 1:
fileContents += ', '
index += 1
fileContents += """{}
"""
for animationType in animationTypes:
capitalizedName = capitalize(animationType)
camelCaseName = capitalizedName[0].lower() + capitalizedName[1:]
fileContents += ' K' + capitalizedName + 'ViewFactory ' + camelCaseName + 'ViewFactory;\n'
fileContents += """
KAnimationManager animationManager;
};
// *************************************************************************************************
KAnimationManagerFactory::KAnimationManagerFactory(luxScene_manager &sceneManager,
QPointer<KUndoStack> undoStack,
bool hasExperimentalFeatures)
// *************************************************************************************************
{
d = std::make_unique<Private>(undoStack);
"""
for animationType in animationTypes:
capitalizedName = capitalize(animationType)
camelCaseName = capitalizedName[0].lower() + capitalizedName[1:]
if animationType in onlyExperimental:
fileContents += ' if (hasExperimentalFeatures) {\n '
fileContents += ' d->animationManager.registerType(AnimationTypes::' + camelCaseName + ', &d->' + camelCaseName + 'ViewFactory,\nnew K' + capitalizedName + 'NodeFactory(sceneManager));\n'
if animationType in onlyExperimental:
fileContents += ' }'
fileContents += """}
// *************************************************************************************************
KAnimationManagerFactory::~KAnimationManagerFactory()
// *************************************************************************************************
{
}
// *************************************************************************************************
QPointer<KAnimationManager> KAnimationManagerFactory::getAnimationManager() const
// *************************************************************************************************
{
return &d->animationManager;
}
"""
file = open(animationManagerFilePath, 'w')
file.write(fileContents)
file.close()
addFunctionWrappers.add(animationManagerFilePath)