Skip to content

Commit

Permalink
Merge pull request maria-korosteleva#11 from maria-korosteleva/nicegui
Browse files Browse the repository at this point in the history
Nicegui -- substitute of PySimpleGUI + web version
  • Loading branch information
maria-korosteleva authored Jul 21, 2024
2 parents 859d11e + 10db0c0 commit 27ea3b3
Show file tree
Hide file tree
Showing 33 changed files with 947 additions and 1,509 deletions.
11 changes: 2 additions & 9 deletions assets/design_params/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ design:
default_prob: 0.6
sleeve:
sleeveless:
v: false
v: true
range:
- true
- false
Expand Down Expand Up @@ -444,7 +444,7 @@ design:
default_prob: 0.8
sleeve:
sleeveless:
v: false
v: true
range:
- true
- false
Expand Down Expand Up @@ -765,15 +765,8 @@ design:
range:
- Sun
- SIGGRAPH_logo
- SVGFile
type: select_null
default_prob: 1.
style_side_file:
v: assets\img\test_shape.svg
range: # NOTE: Range is only needed for sampling
- assets\img\Logo_adjusted.svg
- assets\img\test_shape.svg
type: file_svg
levels-skirt:
base:
v: PencilSkirt
Expand Down
2 changes: 1 addition & 1 deletion assets/garment_programs/skirt_paneled.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def __init__(self, body, design, tag='', length=None, rise=None, slit=True, **kw
style_shape_l, style_shape_r = shape_class(
width=depth * 1.5,
depth=depth, n_rays=6, d_rays=depth*0.2,
filename=design['style_side_file']['v']
filename=design['style_side_file']['v'] if 'style_side_file' in design else None
)
else:
style_shape_l, style_shape_r = None, None
Expand Down
Binary file added assets/img/err_dress_20s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/err_dress_30s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/err_dress_50s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/err_js.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/err_red_modern.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/err_regency.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions assets/img/ggg_outline_mean_all.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions assets/img/pattern_test.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions external/pattern/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
'edges': []
}

# FIXME too many abs_to_rel and rel_to_abs functions

class EmptyPatternError(BaseException):
def __init__(self, *args: object) -> None:
super().__init__(*args)

# ------------ Patterns --------
class BasicPattern(object):
Expand Down
41 changes: 28 additions & 13 deletions external/pattern/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import cairosvg
import svgpathtools as svgpath
import svgwrite as sw

import matplotlib.pyplot as plt

Expand Down Expand Up @@ -220,18 +221,14 @@ def _add_panel_annotations(
font_size='7',
text_anchor='middle'))

def _save_as_image(
self, svg_filename, png_filename,
def get_svg(self, svg_filename,
with_text=True, view_ids=True,
margin=2):
"""
Saves current pattern in svg and png format for visualization
* with_text: include panel names
* view_ids: include ids of vertices and edges in the output image
* margin: small amount of free space around the svg drawing (to correctly display the line width)
margin=2) -> sw.Drawing:
"""Convert pattern to writable svg representation"""

"""
if len(self.panel_order()) == 0: # If we are still here, but pattern is empty, don't generate an image
raise core.EmptyPatternError()

# Get svg representation per panel
# Order by depth (=> most front panels render in front)
# TODOLOW Even smarter way is needed for prettier allignment
Expand Down Expand Up @@ -274,9 +271,9 @@ def _save_as_image(
dims[1] + 2 * margin
)

# "floor" level for a pattern
self.body_bottom_shift = -viewbox[0] * self.px_per_unit, -viewbox[1] * self.px_per_unit
self.png_size = viewbox[2:]
# Pattern info for correct placement
self.svg_bbox = [np.min(arrdims[:, 0]), np.max(arrdims[:, 1]), np.min(arrdims[:, 2]), np.max(arrdims[:, 3])]
self.svg_bbox_size = [viewbox[2], viewbox[3]]

# Save
attributes = attributes_f + attributes_b
Expand All @@ -298,6 +295,24 @@ def _save_as_image(
self._add_panel_annotations(
dwg, panel, paths[i], with_text, view_ids)

return dwg


def _save_as_image(
self, svg_filename, png_filename,
with_text=True, view_ids=True,
margin=2):
"""
Saves current pattern in svg and png format for visualization
* with_text: include panel names
* view_ids: include ids of vertices and edges in the output image
* margin: small amount of free space around the svg drawing (to correctly display the line width)
"""

dwg = self.get_svg(svg_filename, with_text, view_ids, margin)

dwg.save(pretty=True)

# to png
Expand Down
Loading

0 comments on commit 27ea3b3

Please sign in to comment.