1+ #This Source Code Form is subject to the terms of the Mozilla Public
2+ #License, v. 2.0. If a copy of the MPL was not distributed with this
3+ #file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+ #Created by Fabrice Fernandez on 17/01/2018.
5+
6+ from NatronEngine import *
7+ from NatronGui import *
8+ from PySide .QtGui import *
9+ import NatronEngine
10+
11+
12+ # DISK CACHE THE SELECTED NODE #
13+
14+ def diskCache ():
15+
16+ # creates dialog window #
17+ app = natron .getGuiInstance (0 )
18+ dialog = app .createModalDialog ()
19+
20+ # creates UI #
21+
22+ line01 = dialog .createStringParam ("sep01" ,"" )
23+ line01 .setType (NatronEngine .StringParam .TypeEnum .eStringTypeLabel )
24+ line02 = dialog .createStringParam ("sep02" ,"" )
25+ line02 .setType (NatronEngine .StringParam .TypeEnum .eStringTypeLabel )
26+
27+ sep01 = dialog .createSeparatorParam ("line03" ,"Disk Cache" )
28+
29+ line03 = dialog .createStringParam ("sep03" ,"" )
30+ line03 .setType (NatronEngine .StringParam .TypeEnum .eStringTypeLabel )
31+ line04 = dialog .createStringParam ("sep04" ,"" )
32+ line04 .setType (NatronEngine .StringParam .TypeEnum .eStringTypeLabel )
33+
34+
35+ firstFrame = dialog .createIntParam ("firstFrame" ,"In :" )
36+ lastFrame = dialog .createIntParam ("lastFrame" ,"Out :" )
37+ lastFrame .setAddNewLine (False )
38+
39+ line05 = dialog .createStringParam ("sep05" ,"" )
40+ line05 .setType (NatronEngine .StringParam .TypeEnum .eStringTypeLabel )
41+
42+ sep02 = dialog .createSeparatorParam ("line02" ,"" )
43+
44+ # Refresh UI #
45+ dialog .refreshUserParamsGUI ()
46+
47+ # code executed when OK button is pressed #
48+ if dialog .exec_ ():
49+
50+ # retrieves values entered by user #
51+ newFirstFrame = dialog .getParam ("firstFrame" ).getValue ()
52+ newLastFrame = dialog .getParam ("lastFrame" ).getValue ()
53+
54+ counter = 0
55+ selectedNodes = app .getSelectedNodes ()
56+
57+
58+
59+ for n in selectedNodes :
60+
61+ # if more than 1 node have been selected, stop the process #
62+ if len (selectedNodes ) != 1 :
63+ break
64+
65+ else :
66+ # creates a DiskCache node #
67+ parentPosition = n .getPosition ()
68+ diskCache = app .createNode ("fr.inria.built-in.DiskCache" )
69+
70+ # connects the Disk Cache node to the selected node, and set graph position. #
71+ diskCache .connectInput (0 , n )
72+ diskCache .setPosition (parentPosition [0 ]+ 150 ,parentPosition [1 ]+ 75 )
73+
74+ # set node color #
75+ diskCache .setColor (0.521 ,0.51492 ,0.0003 )
76+
77+ # set node name #
78+ parentLabel = n .getLabel ()
79+ diskCache .setLabel ('DiskCache_' + str (parentLabel ))
80+
81+ myFrameRange = diskCache .getParam ("frameRange" )
82+ myFrameRange .set (2 )
83+
84+ myFirstFrame = diskCache .getParam ("firstFrame" )
85+ myFirstFrame .set (newFirstFrame )
86+
87+ myLastFrame = diskCache .getParam ("LastFrame" )
88+ myLastFrame .set (newLastFrame )
89+
90+ app .render (diskCache , newFirstFrame , newLastFrame )
0 commit comments