-
Notifications
You must be signed in to change notification settings - Fork 24
/
diskCache.py
92 lines (63 loc) · 2.59 KB
/
diskCache.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
84
85
86
87
88
89
90
91
92
#This Source Code Form is subject to the terms of the Mozilla Public
#License, v. 2.0. If a copy of the MPL was not distributed with this
#file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#Created by Fabrice Fernandez on 23/06/2019.
from NatronGui import *
from PySide.QtGui import *
import NatronEngine
# CREATES AND PROCESS A 'DISKCACHE' NODE FOR THE SELECTED NODE #
def diskCache():
# creates dialog window #
app = natron.getGuiInstance(0)
dialog = app.createModalDialog()
# set dialog title #
dialog.setWindowTitle("Disk cache")
# set dialog margins #
dialog.setContentsMargins(0, 0, 10, 10)
# creates UI #
line01 = dialog.createStringParam("sep01","")
line01.setType(NatronEngine.StringParam.TypeEnum.eStringTypeLabel)
line02 = dialog.createStringParam("sep02","")
line02.setType(NatronEngine.StringParam.TypeEnum.eStringTypeLabel)
firstFrame = dialog.createIntParam("firstFrame","In :")
defaultFirstFrame = app.getProjectParam('frameRange').get()[0]
firstFrame.set(defaultFirstFrame)
lastFrame = dialog.createIntParam("lastFrame","Out :")
defaultLastFrame = app.getProjectParam('frameRange').get()[1]
lastFrame.set(defaultLastFrame)
lastFrame.setAddNewLine(False)
line03 = dialog.createStringParam("sep03","")
line03.setType(NatronEngine.StringParam.TypeEnum.eStringTypeLabel)
sep01 = dialog.createSeparatorParam("line01","")
# Refresh UI #
dialog.refreshUserParamsGUI()
# code executed when OK button is pressed #
if dialog.exec_():
# retrieves values entered by user #
newFirstFrame = dialog.getParam("firstFrame").getValue()
newLastFrame = dialog.getParam("lastFrame").getValue()
counter = 0
selectedNodes = app.getSelectedNodes()
for n in selectedNodes:
# if more than 1 node have been selected, stop the process #
if len(selectedNodes) != 1 :
break
else :
# creates a DiskCache node #
parentPosition = n.getPosition()
diskCache = app.createNode("fr.inria.built-in.DiskCache")
# connects the Disk Cache node to the selected node, and set graph position. #
diskCache.connectInput(0, n)
diskCache.setPosition(parentPosition[0]+150,parentPosition[1]+75)
# set node color #
diskCache.setColor(0.521,0.51492,0.0003)
# set node name #
parentLabel = n.getLabel()
diskCache.setLabel('DiskCache_' + str(parentLabel))
myFrameRange = diskCache.getParam("frameRange")
myFrameRange.set(2)
myFirstFrame = diskCache.getParam("firstFrame")
myFirstFrame.set(newFirstFrame)
myLastFrame = diskCache.getParam("LastFrame")
myLastFrame.set(newLastFrame)
app.render(diskCache, newFirstFrame, newLastFrame)