molde 0.1.11__tar.gz → 0.1.13__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. {molde-0.1.11 → molde-0.1.13}/PKG-INFO +1 -1
  2. {molde-0.1.11 → molde-0.1.13}/molde/actors/common_symbols_actor.py +19 -35
  3. {molde-0.1.11 → molde-0.1.13}/molde/colors/color.py +101 -38
  4. {molde-0.1.11 → molde-0.1.13}/pyproject.toml +1 -1
  5. {molde-0.1.11 → molde-0.1.13}/README.md +0 -0
  6. {molde-0.1.11 → molde-0.1.13}/molde/__init__.py +0 -0
  7. {molde-0.1.11 → molde-0.1.13}/molde/__main__.py +0 -0
  8. {molde-0.1.11 → molde-0.1.13}/molde/actors/__init__.py +0 -0
  9. {molde-0.1.11 → molde-0.1.13}/molde/actors/ghost_actor.py +0 -0
  10. {molde-0.1.11 → molde-0.1.13}/molde/actors/lines_actor.py +0 -0
  11. {molde-0.1.11 → molde-0.1.13}/molde/actors/round_points_actor.py +0 -0
  12. {molde-0.1.11 → molde-0.1.13}/molde/actors/square_points_actor.py +0 -0
  13. {molde-0.1.11 → molde-0.1.13}/molde/colors/__init__.py +0 -0
  14. {molde-0.1.11 → molde-0.1.13}/molde/colors/color_names.py +0 -0
  15. {molde-0.1.11 → molde-0.1.13}/molde/fonts/IBMPlexMono-Bold.ttf +0 -0
  16. {molde-0.1.11 → molde-0.1.13}/molde/fonts/IBMPlexMono-Regular.ttf +0 -0
  17. {molde-0.1.11 → molde-0.1.13}/molde/icons/arrow_down_dark_theme.svg +0 -0
  18. {molde-0.1.11 → molde-0.1.13}/molde/icons/arrow_down_disabled_dark_theme.svg +0 -0
  19. {molde-0.1.11 → molde-0.1.13}/molde/icons/arrow_down_disabled_light_theme.svg +0 -0
  20. {molde-0.1.11 → molde-0.1.13}/molde/icons/arrow_down_light_theme.svg +0 -0
  21. {molde-0.1.11 → molde-0.1.13}/molde/icons/arrow_left_dark_theme.svg +0 -0
  22. {molde-0.1.11 → molde-0.1.13}/molde/icons/arrow_left_light_theme.svg +0 -0
  23. {molde-0.1.11 → molde-0.1.13}/molde/icons/arrow_right_dark_theme.svg +0 -0
  24. {molde-0.1.11 → molde-0.1.13}/molde/icons/arrow_right_light_theme.svg +0 -0
  25. {molde-0.1.11 → molde-0.1.13}/molde/icons/arrow_up_dark_theme.svg +0 -0
  26. {molde-0.1.11 → molde-0.1.13}/molde/icons/arrow_up_disabled_dark_theme.svg +0 -0
  27. {molde-0.1.11 → molde-0.1.13}/molde/icons/arrow_up_disabled_light_theme.svg +0 -0
  28. {molde-0.1.11 → molde-0.1.13}/molde/icons/arrow_up_light_theme.svg +0 -0
  29. {molde-0.1.11 → molde-0.1.13}/molde/icons/check_box_image.svg +0 -0
  30. {molde-0.1.11 → molde-0.1.13}/molde/interactor_styles/__init__.py +0 -0
  31. {molde-0.1.11 → molde-0.1.13}/molde/interactor_styles/arcball_camera_style.py +0 -0
  32. {molde-0.1.11 → molde-0.1.13}/molde/interactor_styles/box_selection_style.py +0 -0
  33. {molde-0.1.11 → molde-0.1.13}/molde/main_window.ui +0 -0
  34. {molde-0.1.11 → molde-0.1.13}/molde/pickers/__init__.py +0 -0
  35. {molde-0.1.11 → molde-0.1.13}/molde/pickers/cell_area_picker.py +0 -0
  36. {molde-0.1.11 → molde-0.1.13}/molde/pickers/cell_property_area_picker.py +0 -0
  37. {molde-0.1.11 → molde-0.1.13}/molde/poly_data/__init__.py +0 -0
  38. {molde-0.1.11 → molde-0.1.13}/molde/poly_data/arrows.py +0 -0
  39. {molde-0.1.11 → molde-0.1.13}/molde/poly_data/lines_data.py +0 -0
  40. {molde-0.1.11 → molde-0.1.13}/molde/poly_data/simple_shapes.py +0 -0
  41. {molde-0.1.11 → molde-0.1.13}/molde/poly_data/vertices_data.py +0 -0
  42. {molde-0.1.11 → molde-0.1.13}/molde/render_widgets/__init__.py +0 -0
  43. {molde-0.1.11 → molde-0.1.13}/molde/render_widgets/animated_render_widget.py +0 -0
  44. {molde-0.1.11 → molde-0.1.13}/molde/render_widgets/common_render_widget.py +0 -0
  45. {molde-0.1.11 → molde-0.1.13}/molde/stylesheets/__init__.py +0 -0
  46. {molde-0.1.11 → molde-0.1.13}/molde/stylesheets/common.qss +0 -0
  47. {molde-0.1.11 → molde-0.1.13}/molde/stylesheets/create_color_page.py +0 -0
  48. {molde-0.1.11 → molde-0.1.13}/molde/stylesheets/mainwindow.ui +0 -0
  49. {molde-0.1.11 → molde-0.1.13}/molde/stylesheets/qcheckbox.qss +0 -0
  50. {molde-0.1.11 → molde-0.1.13}/molde/stylesheets/qinputs.qss +0 -0
  51. {molde-0.1.11 → molde-0.1.13}/molde/stylesheets/qlayouts.qss +0 -0
  52. {molde-0.1.11 → molde-0.1.13}/molde/stylesheets/qmenubar.qss +0 -0
  53. {molde-0.1.11 → molde-0.1.13}/molde/stylesheets/qprogressbar.qss +0 -0
  54. {molde-0.1.11 → molde-0.1.13}/molde/stylesheets/qpushbutton.qss +0 -0
  55. {molde-0.1.11 → molde-0.1.13}/molde/stylesheets/qradiobutton.qss +0 -0
  56. {molde-0.1.11 → molde-0.1.13}/molde/stylesheets/qscrollbar.qss +0 -0
  57. {molde-0.1.11 → molde-0.1.13}/molde/stylesheets/qslider.qss +0 -0
  58. {molde-0.1.11 → molde-0.1.13}/molde/stylesheets/qtablewidget.qss +0 -0
  59. {molde-0.1.11 → molde-0.1.13}/molde/stylesheets/qtabwidget.qss +0 -0
  60. {molde-0.1.11 → molde-0.1.13}/molde/stylesheets/qtoolbar.qss +0 -0
  61. {molde-0.1.11 → molde-0.1.13}/molde/stylesheets/qtoolbuttons.qss +0 -0
  62. {molde-0.1.11 → molde-0.1.13}/molde/stylesheets/qtreewidget.qss +0 -0
  63. {molde-0.1.11 → molde-0.1.13}/molde/ui_files/messages/new_loading_window.ui +0 -0
  64. {molde-0.1.11 → molde-0.1.13}/molde/utils/__init__.py +0 -0
  65. {molde-0.1.11 → molde-0.1.13}/molde/utils/format_sequences.py +0 -0
  66. {molde-0.1.11 → molde-0.1.13}/molde/utils/poly_data_utils.py +0 -0
  67. {molde-0.1.11 → molde-0.1.13}/molde/utils/tree_info.py +0 -0
  68. {molde-0.1.11 → molde-0.1.13}/molde/windows/loading_window.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: molde
3
- Version: 0.1.11
3
+ Version: 0.1.13
4
4
  Summary:
5
5
  Author: André Fernandes
6
6
  Author-email: fpf.andre@gmail.com
@@ -1,7 +1,6 @@
1
1
  from dataclasses import dataclass
2
+ from typing import Callable
2
3
 
3
- from molde import Color
4
- from molde.utils import transform_polydata
5
4
  from vtkmodules.vtkCommonCore import (
6
5
  vtkDoubleArray,
7
6
  vtkIntArray,
@@ -9,14 +8,21 @@ from vtkmodules.vtkCommonCore import (
9
8
  vtkUnsignedCharArray,
10
9
  )
11
10
  from vtkmodules.vtkCommonDataModel import vtkPolyData
12
- from vtkmodules.vtkRenderingCore import vtkActor, vtkDistanceToCamera, vtkGlyph3DMapper, vtkRenderer
11
+ from vtkmodules.vtkRenderingCore import (
12
+ vtkActor,
13
+ vtkDistanceToCamera,
14
+ vtkGlyph3DMapper,
15
+ vtkRenderer,
16
+ )
17
+
18
+ from molde import Color
13
19
 
14
20
  Triple = tuple[float, float, float]
15
21
 
16
22
 
17
23
  @dataclass
18
24
  class Symbol:
19
- shape_name: str
25
+ shape_function: Callable
20
26
  position: Triple
21
27
  orientation: Triple
22
28
  color: Color
@@ -25,34 +31,18 @@ class Symbol:
25
31
 
26
32
  class CommonSymbolsActor(vtkActor):
27
33
  def __init__(self, *args, **kwargs):
28
- self._shapes: dict[str, vtkPolyData] = dict()
29
34
  self._symbols: list[Symbol] = list()
30
35
 
31
- def register_shape(
32
- self,
33
- name: str,
34
- shape: vtkPolyData,
35
- position: Triple = (0, 0, 0),
36
- rotation: Triple = (0, 0, 0),
37
- scale: Triple = (1, 1, 1),
38
- ):
39
- self._shapes[name] = transform_polydata(
40
- shape,
41
- position,
42
- rotation,
43
- scale,
44
- )
45
-
46
36
  def add_symbol(
47
37
  self,
48
- shape_name: str,
38
+ shape_function: Callable,
49
39
  position: Triple,
50
40
  orientation: Triple,
51
41
  color: Triple,
52
42
  scale: float = 1,
53
43
  ):
54
44
  symbol = Symbol(
55
- shape_name,
45
+ shape_function,
56
46
  position,
57
47
  orientation,
58
48
  color,
@@ -60,16 +50,9 @@ class CommonSymbolsActor(vtkActor):
60
50
  )
61
51
  self._symbols.append(symbol)
62
52
 
63
- def clear_shapes(self):
64
- self._shapes.clear()
65
-
66
53
  def clear_symbols(self):
67
54
  self._symbols.clear()
68
55
 
69
- def clear_all(self):
70
- self.clear_shapes()
71
- self.clear_symbols()
72
-
73
56
  def common_build(self):
74
57
  self.data = vtkPolyData()
75
58
  points = vtkPoints()
@@ -91,17 +74,18 @@ class CommonSymbolsActor(vtkActor):
91
74
  colors.SetNumberOfComponents(4)
92
75
  colors.SetName("colors")
93
76
 
94
- shape_name_to_index = dict()
95
- for index, (name, shape) in enumerate(self._shapes.items()):
96
- shape_name_to_index[name] = index
97
- self.mapper.SetSourceData(index, shape)
98
-
77
+ shape_function_to_index = dict()
99
78
  for symbol in self._symbols:
79
+ if symbol.shape_function not in shape_function_to_index:
80
+ index = len(shape_function_to_index)
81
+ shape_function_to_index[symbol.shape_function] = index
82
+ self.mapper.SetSourceData(index, symbol.shape_function())
83
+
100
84
  points.InsertNextPoint(symbol.position)
101
85
  rotations.InsertNextTuple(symbol.orientation)
102
86
  colors.InsertNextTuple(symbol.color.to_rgba())
103
87
  scales.InsertNextValue(symbol.scale)
104
- sources.InsertNextValue(shape_name_to_index[symbol.shape_name])
88
+ sources.InsertNextValue(shape_function_to_index[symbol.shape_function])
105
89
 
106
90
  self.data.SetPoints(points)
107
91
  self.data.GetPointData().AddArray(sources)
@@ -11,44 +11,43 @@ class Color:
11
11
 
12
12
  @typing.overload
13
13
  def __init__(self, r: int, g: int, b: int, a: int = 255):
14
- '''
14
+ """
15
15
  Initialize Colors with RGB or RGBA integer values ranging from 0 to 255.
16
- '''
17
-
16
+ """
17
+
18
18
  @typing.overload
19
19
  def __init__(self, r: float, g: float, b: float, a: float = 1.0):
20
- '''
20
+ """
21
21
  Initialize Colors with RGB or RGBA floating values ranging from 0.0 to 1.0.
22
- '''
23
-
22
+ """
23
+
24
24
  @typing.overload
25
25
  def __init__(self, hexa: str):
26
- '''
26
+ """
27
27
  Initialize colors from hex values.
28
28
  The valid formats incluce RGB (#FF0000 for example)
29
29
  and RGBA (#FF0000FF for example)
30
- '''
30
+ """
31
31
 
32
32
  @typing.overload
33
33
  def __init__(self, qcolor: QColor):
34
- '''
34
+ """
35
35
  Initialize the color class with an instance of QColor
36
- '''
37
-
36
+ """
37
+
38
38
  @typing.overload
39
39
  def __init__(self, color: "Color"):
40
- '''
40
+ """
41
41
  Initialize the color class with an instance it's own class
42
- '''
43
-
42
+ """
43
+
44
44
  @typing.overload
45
45
  def __init__(self):
46
- '''
46
+ """
47
47
  Initialize an empty black color
48
- '''
48
+ """
49
49
 
50
50
  def __init__(self, *args):
51
-
52
51
  all_int = all([isinstance(i, int) for i in args])
53
52
  all_float = all([isinstance(i, float) for i in args])
54
53
 
@@ -57,10 +56,10 @@ class Color:
57
56
 
58
57
  elif len(args) == 1 and isinstance(args[0], str):
59
58
  self.from_hex(*args)
60
-
59
+
61
60
  elif len(args) == 1 and isinstance(args[0], QColor):
62
61
  self.from_qcolor(*args)
63
-
62
+
64
63
  elif len(args) == 1 and isinstance(args[0], Color):
65
64
  self.from_color(*args)
66
65
 
@@ -76,11 +75,11 @@ class Color:
76
75
  def from_rgb(self, r: int, g: int, b: int) -> "Color":
77
76
  return self.from_rgba(r, g, b)
78
77
 
79
- def from_rgba(self, r: int, g: int, b: int, a: int=255) -> "Color":
80
- self.r = int(np.clip(r, 0, 255))
81
- self.g = int(np.clip(g, 0, 255))
82
- self.b = int(np.clip(b, 0, 255))
83
- self.a = int(np.clip(a, 0, 255))
78
+ def from_rgba(self, r: int, g: int, b: int, a: int = 255) -> "Color":
79
+ self.r = round(np.clip(r, 0, 255))
80
+ self.g = round(np.clip(g, 0, 255))
81
+ self.b = round(np.clip(b, 0, 255))
82
+ self.a = round(np.clip(a, 0, 255))
84
83
  return self
85
84
 
86
85
  def from_rgb_f(self, r: float, g: float, b: float) -> "Color":
@@ -88,14 +87,14 @@ class Color:
88
87
 
89
88
  def from_rgba_f(self, r: float, g: float, b: float, a: float = 1) -> "Color":
90
89
  return self.from_rgba(
91
- int(r * 255),
92
- int(g * 255),
93
- int(b * 255),
94
- int(a * 255),
90
+ round(r * 255),
91
+ round(g * 255),
92
+ round(b * 255),
93
+ round(a * 255),
95
94
  )
96
95
 
97
96
  def from_hex(self, color: str) -> "Color":
98
- color = color.lstrip('#')
97
+ color = color.lstrip("#")
99
98
  if len(color) == 6:
100
99
  r, g, b = int(color[0:2], 16), int(color[2:4], 16), int(color[4:6], 16)
101
100
  return self.from_rgb(r, g, b)
@@ -104,6 +103,35 @@ class Color:
104
103
  return self.from_rgba(r, g, b, a)
105
104
  raise ValueError("Invalid hex color format")
106
105
 
106
+ def from_hsv(self, hue: float, saturation: float, value: float):
107
+ v = value / 100
108
+ s = saturation / 100
109
+
110
+ c = v * s
111
+ h = hue / 60
112
+ x = c * (1 - abs(h % 2 - 1))
113
+
114
+ if 0 < h < 1:
115
+ r, g, b = c, x, 0
116
+ elif 1 < h < 2:
117
+ r, g, b = x, c, 0
118
+ elif 2 < h < 3:
119
+ r, g, b = 0, c, x
120
+ elif 3 < h < 4:
121
+ r, g, b = 0, x, c
122
+ elif 4 < h < 5:
123
+ r, g, b = x, 0, c
124
+ elif 5 < h < 6:
125
+ r, g, b = c, 0, x
126
+ else:
127
+ r, g, b = 0, 0, 0
128
+
129
+ return self.from_rgb_f(
130
+ (r + v - c),
131
+ (g + v - c),
132
+ (b + v - c),
133
+ )
134
+
107
135
  def from_qcolor(self, color: QColor) -> "Color":
108
136
  return self.from_rgba(color.red(), color.green(), color.blue(), color.alpha())
109
137
 
@@ -127,24 +155,59 @@ class Color:
127
155
  return ((self.r / 255), (self.g / 255), (self.b / 255), (self.a / 255))
128
156
 
129
157
  def to_hex(self) -> str:
130
- return (f'#{self.r:02X}{self.g:02X}{self.b:02X}')
158
+ return f"#{self.r:02X}{self.g:02X}{self.b:02X}"
131
159
 
132
160
  def to_hexa(self) -> str:
133
- return (f'#{self.r:02X}{self.g:02X}{self.b:02X}{self.a:02X}')
161
+ return f"#{self.r:02X}{self.g:02X}{self.b:02X}{self.a:02X}"
162
+
163
+ def to_hsv(self) -> tuple[int, int, int]:
164
+ r, g, b = self.to_rgb_f()
165
+ min_, mid_, max_ = sorted((r, g, b))
166
+ delta = max_ - min_
167
+
168
+ if max_ == r:
169
+ hue = (g - b) / delta
170
+ elif max_ == g:
171
+ hue = (b - r) / delta + 2
172
+ elif max_ == b:
173
+ hue = (r - g) / delta + 4
174
+ else:
175
+ hue = 0
176
+
177
+ hue = round(60 * hue)
178
+ value = round(100 * max_)
179
+ saturation = round(100 * delta / max_) if (max_ != 0) else 0
180
+
181
+ return (
182
+ np.clip(0, 360, hue),
183
+ np.clip(0, 100, saturation),
184
+ np.clip(0, 100, value),
185
+ )
134
186
 
135
187
  def to_qt(self) -> QColor:
136
188
  return QColor(self.r, self.g, self.b, self.a)
137
189
 
138
- def copy(self):
190
+ def copy(self) -> "Color":
139
191
  return Color(self.r, self.g, self.b, self.a)
140
-
141
- def apply_factor(self, factor: float|int):
192
+
193
+ def apply_factor(self, factor: float | int) -> "Color":
142
194
  new_color = self.copy()
143
- new_color.r = int(np.clip(self.r*factor, 0, 255))
144
- new_color.g = int(np.clip(self.g*factor, 0, 255))
145
- new_color.b = int(np.clip(self.b*factor, 0, 255))
195
+ new_color.r = round(np.clip(self.r * factor, 0, 255))
196
+ new_color.g = round(np.clip(self.g * factor, 0, 255))
197
+ new_color.b = round(np.clip(self.b * factor, 0, 255))
146
198
 
147
199
  return new_color
148
200
 
201
+ def set_brightness(self, brightness: int) -> "Color":
202
+ h, s, _ = self.to_hsv()
203
+ return self.to_hsv(h, s, brightness)
204
+
205
+ def set_saturation(self, saturation: int) -> "Color":
206
+ h, _, v = self.to_hsv()
207
+ return self.to_hsv(h, saturation, v)
208
+
209
+ def __repr__(self):
210
+ return f"Color(r={self.r}, g={self.g}, b={self.b}, a={self.a})"
149
211
 
150
-
212
+ def __eq__(self, other: "Color"):
213
+ return self.r == other.r and self.g == other.g and self.b == other.b and self.a == other.a
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "molde"
3
- version = "0.1.11"
3
+ version = "0.1.13"
4
4
  description = ""
5
5
  authors = ["André Fernandes <fpf.andre@gmail.com>"]
6
6
  readme = "README.md"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes