]> git.tdb.fi Git - libs/gl.git/blob - blender/io_mspgl/util.py
Use the same mesh for multiple instances of an object in scene exporter
[libs/gl.git] / blender / io_mspgl / util.py
1 class Progress:
2         def __init__(self, context):
3                 self.task = ""
4                 self.start = 0.0
5                 self.delta = 1.0
6                 self.last = 0.0
7                 self.stack = []
8                 self.window_manager = context.window_manager
9                 self.window_manager.progress_begin(0.0, 1.0)
10
11         def push_task(self, task, low, high):
12                 self.stack.append((task, low, high-low))
13                 self.set_task("init", 0.0, 0.0)
14
15         def pop_task(self):
16                 self.set_task("finish", 1.0, 1.0)
17                 self.stack.pop()
18
19         def set_task(self, task, low, high):
20                 if self.stack:
21                         task = self.stack[-1][0]+": "+task
22                         low = self.stack[-1][1]+self.stack[-1][2]*low
23                         high = self.stack[-1][1]+self.stack[-1][2]*high
24
25                 self.task = task
26                 self.start = low
27                 self.delta = high-low
28
29                 self.set_progress(0)
30
31         def set_progress(self, value):
32                 value = self.start+self.delta*value
33                 if value>self.last+0.01:
34                         self.window_manager.progress_update(value)
35                         self.last = value