[Populate] Added support for `render_3d`
- So now we have a better image and no need for 2D representations of the 3D models
This commit is contained in:
parent
0ee280b6d9
commit
e874b3af8e
|
|
@ -2890,7 +2890,7 @@ Notes:
|
||||||
Note that the YAML section of the file will be skipped, all the needed information
|
Note that the YAML section of the file will be skipped, all the needed information
|
||||||
comes from this output and the `renderer` output.
|
comes from this output and the `renderer` output.
|
||||||
- **`renderer`**: [string=''] Name of the output used to render the PCB steps.
|
- **`renderer`**: [string=''] Name of the output used to render the PCB steps.
|
||||||
Currently this must be a `pcbdraw` output.
|
Currently this must be a `pcbdraw` or `render_3d` output.
|
||||||
- `dnf_filter`: [string|list(string)='_none'] Name of the filter to mark components as not fitted.
|
- `dnf_filter`: [string|list(string)='_none'] Name of the filter to mark components as not fitted.
|
||||||
A short-cut to use for simple cases where a variant is an overkill.
|
A short-cut to use for simple cases where a variant is an overkill.
|
||||||
- `imgname`: [string='img/populating_%d.%x'] Pattern used for the image names. The `%d` is replaced by the image number.
|
- `imgname`: [string='img/populating_%d.%x'] Pattern used for the image names. The `%d` is replaced by the image number.
|
||||||
|
|
|
||||||
|
|
@ -1663,7 +1663,7 @@ outputs:
|
||||||
# A short-cut to use for simple cases where a variant is an overkill
|
# A short-cut to use for simple cases where a variant is an overkill
|
||||||
pre_transform: '_none'
|
pre_transform: '_none'
|
||||||
# [string=''] Name of the output used to render the PCB steps.
|
# [string=''] Name of the output used to render the PCB steps.
|
||||||
# Currently this must be a `pcbdraw` output
|
# Currently this must be a `pcbdraw` or `render_3d` output
|
||||||
renderer: ''
|
renderer: ''
|
||||||
# [string] The name of the handlebars template used for the HTML output.
|
# [string] The name of the handlebars template used for the HTML output.
|
||||||
# The extension must be `.handlebars`, it will be added when missing.
|
# The extension must be `.handlebars`, it will be added when missing.
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ class PopulateOptions(VariantOptions):
|
||||||
with document:
|
with document:
|
||||||
self.renderer = ''
|
self.renderer = ''
|
||||||
""" *Name of the output used to render the PCB steps.
|
""" *Name of the output used to render the PCB steps.
|
||||||
Currently this must be a `pcbdraw` output """
|
Currently this must be a `pcbdraw` or `render_3d` output """
|
||||||
self.template = 'simple'
|
self.template = 'simple'
|
||||||
""" [string] The name of the handlebars template used for the HTML output.
|
""" [string] The name of the handlebars template used for the HTML output.
|
||||||
The extension must be `.handlebars`, it will be added when missing.
|
The extension must be `.handlebars`, it will be added when missing.
|
||||||
|
|
@ -88,17 +88,21 @@ class PopulateOptions(VariantOptions):
|
||||||
format(side, components, active_components, name))
|
format(side, components, active_components, name))
|
||||||
# Configure it according to our needs
|
# Configure it according to our needs
|
||||||
options._filters_to_expand = False
|
options._filters_to_expand = False
|
||||||
options.bottom = side.startswith("back")
|
|
||||||
options.show_components = [c for c in components if c]
|
options.show_components = [c for c in components if c]
|
||||||
if not options.show_components:
|
if not options.show_components:
|
||||||
options.show_components = None
|
options.show_components = None if self._renderer_is_pcbdraw else []
|
||||||
else:
|
else:
|
||||||
options.show_components = options.solve_filters(options.show_components)
|
options.show_components = options.solve_kf_filters(options.show_components)
|
||||||
options.add_to_variant = False
|
options.highlight = options.solve_kf_filters([c for c in active_components if c])
|
||||||
options.highlight = options.solve_filters([c for c in active_components if c])
|
|
||||||
options.output = name
|
options.output = name
|
||||||
self._renderer.dir = self._parent.dir
|
self._renderer.dir = self._parent.dir
|
||||||
self._renderer._done = False
|
self._renderer._done = False
|
||||||
|
if self._renderer_is_pcbdraw:
|
||||||
|
options.add_to_variant = False
|
||||||
|
options.bottom = side.startswith("back")
|
||||||
|
else: # render_3D
|
||||||
|
options.view = 'Z' if side.startswith("back") else 'z'
|
||||||
|
options._show_all_components = False
|
||||||
run_output(self._renderer)
|
run_output(self._renderer)
|
||||||
return options.expand_filename_both(name, is_sch=False)
|
return options.expand_filename_both(name, is_sch=False)
|
||||||
|
|
||||||
|
|
@ -106,25 +110,33 @@ class PopulateOptions(VariantOptions):
|
||||||
""" Save the current renderer settings """
|
""" Save the current renderer settings """
|
||||||
options = self._renderer.options
|
options = self._renderer.options
|
||||||
self.old_filters_to_expand = options._filters_to_expand
|
self.old_filters_to_expand = options._filters_to_expand
|
||||||
self.old_bottom = options.bottom
|
|
||||||
self.old_show_components = options.show_components
|
self.old_show_components = options.show_components
|
||||||
self.old_add_to_variant = options.add_to_variant
|
|
||||||
self.old_highlight = options.highlight
|
self.old_highlight = options.highlight
|
||||||
self.old_output = options.output
|
self.old_output = options.output
|
||||||
self.old_dir = self._renderer.dir
|
self.old_dir = self._renderer.dir
|
||||||
self.old_done = self._renderer._done
|
self.old_done = self._renderer._done
|
||||||
|
if self._renderer_is_pcbdraw:
|
||||||
|
self.old_bottom = options.bottom
|
||||||
|
self.old_add_to_variant = options.add_to_variant
|
||||||
|
else: # render_3D
|
||||||
|
self.old_view = options.view
|
||||||
|
self.old_show_all_components = options._show_all_components
|
||||||
|
|
||||||
def restore_options(self):
|
def restore_options(self):
|
||||||
""" Restore the renderer settings """
|
""" Restore the renderer settings """
|
||||||
options = self._renderer.options
|
options = self._renderer.options
|
||||||
options._filters_to_expand = self.old_filters_to_expand
|
options._filters_to_expand = self.old_filters_to_expand
|
||||||
options.bottom = self.old_bottom
|
|
||||||
options.show_components = self.old_show_components
|
options.show_components = self.old_show_components
|
||||||
options.add_to_variant = self.old_add_to_variant
|
|
||||||
options.highlight = self.old_highlight
|
options.highlight = self.old_highlight
|
||||||
options.output = self.old_output
|
options.output = self.old_output
|
||||||
self._renderer.dir = self.old_dir
|
self._renderer.dir = self.old_dir
|
||||||
self._renderer._done = self.old_done
|
self._renderer._done = self.old_done
|
||||||
|
if self._renderer_is_pcbdraw:
|
||||||
|
options.bottom = self.old_bottom
|
||||||
|
options.add_to_variant = self.old_add_to_variant
|
||||||
|
else: # render_3D
|
||||||
|
options.view = self.old_view
|
||||||
|
options._show_all_components = self.old_show_all_components
|
||||||
|
|
||||||
def generate_images(self, dir_name, content):
|
def generate_images(self, dir_name, content):
|
||||||
# Memorize the current options
|
# Memorize the current options
|
||||||
|
|
@ -157,7 +169,10 @@ class PopulateOptions(VariantOptions):
|
||||||
if out is None:
|
if out is None:
|
||||||
raise KiPlotConfigurationError('Unknown output `{}` selected in {}'.format(self.renderer, self._parent))
|
raise KiPlotConfigurationError('Unknown output `{}` selected in {}'.format(self.renderer, self._parent))
|
||||||
config_output(out)
|
config_output(out)
|
||||||
|
if out.type not in ['pcbdraw', 'render_3d']:
|
||||||
|
raise KiPlotConfigurationError('The `renderer` must be `pcbdraw` or `render_3d` type, not {}'.format(out.type))
|
||||||
self._renderer = out
|
self._renderer = out
|
||||||
|
self._renderer_is_pcbdraw = out.type == 'pcbdraw'
|
||||||
# Load the input content
|
# Load the input content
|
||||||
try:
|
try:
|
||||||
_, content = load_content(self.input)
|
_, content = load_content(self.input)
|
||||||
|
|
|
||||||
|
|
@ -45,10 +45,28 @@ outputs:
|
||||||
options:
|
options:
|
||||||
format: png
|
format: png
|
||||||
|
|
||||||
|
- name: KiCad_3D
|
||||||
|
comment: "How to draw a step"
|
||||||
|
type: render_3d
|
||||||
|
run_by_default: false
|
||||||
|
options:
|
||||||
|
width: 1280
|
||||||
|
height: 960
|
||||||
|
orthographic: true
|
||||||
|
zoom: 4
|
||||||
|
ray_tracing: true
|
||||||
|
# DAF1FF
|
||||||
|
background1: "#DAF1FF"
|
||||||
|
background2: "#DAF1FF"
|
||||||
|
# auto_crop: true
|
||||||
|
# auto_crop_color: "#00FF00"
|
||||||
|
# auto_crop_fuzz: 15
|
||||||
|
|
||||||
|
|
||||||
- name: Populate
|
- name: Populate
|
||||||
comment: "Populate example"
|
comment: "Populate example"
|
||||||
type: populate
|
type: populate
|
||||||
dir: PopulateWithFilter
|
dir: PopulateWithFilter
|
||||||
options:
|
options:
|
||||||
renderer: PcbDraw
|
renderer: KiCad_3D
|
||||||
input: tests/data/with_filter_html.md
|
input: tests/data/with_filter_html.md
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue