-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImages.py
More file actions
78 lines (61 loc) · 2.44 KB
/
Images.py
File metadata and controls
78 lines (61 loc) · 2.44 KB
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
"""
Images - Static image rendering module for KiRender
Handles static 3D image generation (top/bottom/side views)
Uses cli_builder for all CLI command construction.
"""
import os
import sys
import subprocess
import threading
import wx
class StaticRenderThread(threading.Thread):
"""Thread for rendering static images (top/bottom/side views)."""
def __init__(self, parent, params):
super().__init__()
self.parent = parent
self.params = params
self.daemon = True
def run(self):
try:
self._do_render()
except Exception as e:
wx.CallAfter(self.parent.on_render_error, str(e))
def _do_render(self):
p = self.params
startupinfo = None
creationflags = 0
if sys.platform == "win32":
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
creationflags = subprocess.CREATE_NO_WINDOW
views = p['views']
total = len(views)
# Import the unified CLI builder
from .cli_builder import build_cli_command
for idx, view in enumerate(views):
wx.CallAfter(self.parent.log, f"Rendering {view} view...")
output_file = p['output_files'][idx]
# Build CLI params for this view
cli_params = {
'side': view,
'width': p['width'],
'height': p['height'],
'zoom': p['zoom'],
'background': p['background'],
'quality': p['quality'],
'perspective': p.get('perspective') != "orthographic",
}
# Use unified CLI builder
cmd = build_cli_command(cli_params, p['kicad_cli'], p['pcb_path'], output_file)
result = subprocess.run(
cmd,
startupinfo=startupinfo,
creationflags=creationflags,
capture_output=True,
text=True
)
if result.returncode != 0:
wx.CallAfter(self.parent.log, f"Error: {result.stderr}")
progress = int((idx + 1) / total * 100)
wx.CallAfter(self.parent.update_progress, progress, f"Rendered {view}")
wx.CallAfter(self.parent.on_render_complete, os.path.dirname(p['output_files'][0]))