Skip to content

Commit f484859

Browse files
author
unknown
committed
pkg resources & transformation tools
1 parent e811fe9 commit f484859

12 files changed

+568
-95
lines changed

MANIFEST.in

+2
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ include d3dslic3r/meta/dippy.png
44
include d3dslic3r/meta/Logo.png
55
include d3dslic3r/meta/noslice.png
66
include d3dslic3r/meta/sys_icon.png
7+
include d3dslic3r/meta/translate_icon.png
8+
include d3dslic3r/meta/rotate_icon.png
79
include README.MD

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<span>![<span>Logo</span>](assets/Logo.png)</span>
44

5-
DED SLICER (ded ˈslaɪ.sər) or dee three dee slick three arrr is a utility for discombobulating geometry into paths for direct energy deposition that might work. Garantees are as firm as the current documentation. Start it up, click the buttons, read the tool tips and see what it does.
5+
DED SLICER (ded ˈslaɪ.sər) or dee three dee slick three arrr is a utility for discombobulating geometry into paths for direct energy deposition. Guarantees of it working are as firm as the extent of the current documentation. Start it up, click the buttons, read the tool tips and see what it does.
66

77
# Installation
88
Install it from source using the tarball in the dist folder:

d3dslic3r.egg-info/PKG-INFO

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 2.1
22
Name: d3dslic3r
3-
Version: 0.1
3+
Version: 0.2
44
Summary: DED SLICER
55
Home-page: https://github.com/majroy/d3dslic3r
66
Author: M J Roy
@@ -16,5 +16,15 @@ Classifier: Programming Language :: Python :: 3.11
1616
Classifier: Intended Audience :: End Users/Desktop
1717
Classifier: Natural Language :: English
1818
License-File: LICENSE
19+
Requires-Dist: vtk>=6.0
20+
Requires-Dist: numpy
21+
Requires-Dist: scipy
22+
Requires-Dist: pyyaml>=5.0
23+
Requires-Dist: matplotlib
24+
Requires-Dist: PyQt5>=5
25+
Requires-Dist: h5py
26+
Requires-Dist: scikit-learn
27+
Requires-Dist: shapely
28+
Requires-Dist: pyclipper
1929

2030
https://github.com/majroy/d3dslic3r

d3dslic3r.egg-info/SOURCES.txt

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ README.md
55
setup.py
66
d3dslic3r/__init__.py
77
d3dslic3r/d3dslic3r_common.py
8+
d3dslic3r/d3dslic3r_gui_common.py
89
d3dslic3r/export_widget.py
910
d3dslic3r/main.py
1011
d3dslic3r/slic3_widget.py
12+
d3dslic3r/transform_widget.py
1113
d3dslic3r.egg-info/PKG-INFO
1214
d3dslic3r.egg-info/SOURCES.txt
1315
d3dslic3r.egg-info/dependency_links.txt
@@ -20,4 +22,6 @@ d3dslic3r/meta/clippy.png
2022
d3dslic3r/meta/dippy.png
2123
d3dslic3r/meta/nogeometry.png
2224
d3dslic3r/meta/noslice.png
23-
d3dslic3r/meta/sys_icon.png
25+
d3dslic3r/meta/rotate_icon.png
26+
d3dslic3r/meta/sys_icon.png
27+
d3dslic3r/meta/translate_icon.png

d3dslic3r/d3dslic3r_common.py

+1-83
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,16 @@
1-
import os
2-
import vtk
31
import numpy as np
2+
import vtk
43
from scipy.spatial.distance import cdist
54
from scipy.spatial import Delaunay
65
from vtk.util.numpy_support import vtk_to_numpy as v2n
76
from vtk.util.numpy_support import numpy_to_vtk as n2v
8-
from PyQt5 import QtCore, QtGui, QtWidgets
97
from sklearn.cluster import AgglomerativeClustering
108
from shapely.ops import unary_union, polygonize
119
import shapely.geometry as geometry
1210
from pyclipper import PyclipperOffset, scale_to_clipper, scale_from_clipper, JT_SQUARE, ET_CLOSEDPOLYGON
1311
from scipy.interpolate import interp1d
14-
from pkg_resources import Requirement, resource_filename
1512

1613

17-
def make_splash():
18-
'''
19-
Makes and returns a Qt splash window object
20-
'''
21-
spl_fname=resource_filename("d3dslic3r","meta/Logo.png")
22-
splash_pix = QtGui.QPixmap(spl_fname,'PNG')
23-
splash = QtWidgets.QSplashScreen(splash_pix, QtCore.Qt.SplashScreen)
24-
splash.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.FramelessWindowHint)
25-
26-
font = splash.font()
27-
font.setPixelSize(20)
28-
font.setWeight(QtGui.QFont.Bold)
29-
splash.setFont(font)
30-
31-
# splash.showMessage('v%s'%(version('d3dslic3r')),QtCore.Qt.AlignRight | QtCore.Qt.AlignBottom, QtCore.Qt.lightGray)
32-
splash.showMessage('v%s'%("0.0.1"),QtCore.Qt.AlignRight | QtCore.Qt.AlignTop, QtCore.Qt.darkGray)
33-
return splash
34-
35-
def make_logo(ren):
36-
spl_fname=resource_filename("d3dslic3r","meta/background.png")
37-
img_reader = vtk.vtkPNGReader()
38-
img_reader.SetFileName(spl_fname)
39-
img_reader.Update()
40-
logo = vtk.vtkLogoRepresentation()
41-
logo.SetImage(img_reader.GetOutput())
42-
logo.ProportionalResizeOn()
43-
logo.SetPosition( 0.1, 0.1 ) #lower left
44-
logo.SetPosition2( 0.8, 0.8 ) #upper right
45-
logo.GetImageProperty().SetDisplayLocationToBackground()
46-
ren.AddViewProp(logo)
47-
logo.SetRenderer(ren)
48-
return logo
49-
5014
def get_slice_data(polydata,param,num_slices = True):
5115
"""
5216
Obtains x,y pairs corresponding to a vtkCutter operation on input polydata
@@ -144,29 +108,6 @@ def actor_from_polydata(polydata):
144108

145109
return stl_actor
146110

147-
def get_file(*args):
148-
'''
149-
Returns absolute path to filename and the directory it is located in from a PyQt5 filedialog. First value is file extension, second is a string which overwrites the window message.
150-
'''
151-
ext = args
152-
launchdir = os.getcwd()
153-
ftypeName={}
154-
ftypeName['*.stl']=["STereoLithography file", "*.stl","STL file"]
155-
156-
filter_str = ""
157-
for entry in args:
158-
filter_str += ftypeName[entry][2] + ' ('+ftypeName[entry][1]+');;'
159-
filter_str += ('All Files (*.*)')
160-
161-
filer = QtWidgets.QFileDialog.getOpenFileName(None, ftypeName[ext[0]][0],
162-
os.getcwd(),(filter_str))
163-
164-
if filer[0] == '':
165-
return None
166-
167-
else: #return the filename/path
168-
return filer[0]
169-
170111
def gen_outline_actor(pts, color = (1,1,1), size = 2):
171112
'''
172113
Returns an outline actor with specified numpy array of points, color and size. pts should be ordered
@@ -459,26 +400,3 @@ def offset_poly(poly, offset):
459400
two_d = respace_equally(two_d,len(poly))[0]
460401

461402
return np.column_stack((two_d,np.ones(len(two_d))*zval))
462-
463-
464-
def xyview(ren):
465-
camera = ren.GetActiveCamera()
466-
camera.SetPosition(0,0,1)
467-
camera.SetFocalPoint(0,0,0)
468-
camera.SetViewUp(0,1,0)
469-
ren.ResetCamera()
470-
471-
def yzview(ren):
472-
camera = ren.GetActiveCamera()
473-
camera.SetPosition(1,0,0)
474-
camera.SetFocalPoint(0,0,0)
475-
camera.SetViewUp(0,0,1)
476-
ren.ResetCamera()
477-
478-
def xzview(ren):
479-
vtk.vtkObject.GlobalWarningDisplayOff() #mapping from '3' triggers an underlying stereoview that most displays do not support for trackball interactors
480-
camera = ren.GetActiveCamera()
481-
camera.SetPosition(0,1,0)
482-
camera.SetFocalPoint(0,0,0)
483-
camera.SetViewUp(0,0,1)
484-
ren.ResetCamera()

d3dslic3r/d3dslic3r_gui_common.py

+175
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
import os
2+
import vtk
3+
4+
from PyQt5 import QtCore, QtGui, QtWidgets
5+
import importlib.resources
6+
7+
class collapsible_box(QtWidgets.QWidget):
8+
def __init__(self, title="", parent=None):
9+
super(collapsible_box, self).__init__(parent)
10+
11+
self.toggle_button = QtWidgets.QToolButton(
12+
text=title, checkable=True, checked=False
13+
)
14+
self.toggle_button.setStyleSheet("QToolButton { border: none; }")
15+
self.toggle_button.setToolButtonStyle(
16+
QtCore.Qt.ToolButtonTextBesideIcon
17+
)
18+
self.toggle_button.setArrowType(QtCore.Qt.RightArrow)
19+
self.toggle_button.pressed.connect(self.on_pressed)
20+
21+
self.toggle_animation = QtCore.QParallelAnimationGroup(self)
22+
23+
self.content_area = QtWidgets.QScrollArea(
24+
maximumHeight=0, minimumHeight=0
25+
)
26+
self.content_area.setSizePolicy(
27+
QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed
28+
)
29+
self.content_area.setFrameShape(QtWidgets.QFrame.NoFrame)
30+
31+
lay = QtWidgets.QVBoxLayout(self)
32+
lay.setSpacing(0)
33+
lay.setContentsMargins(0, 0, 0, 0)
34+
lay.addWidget(self.toggle_button)
35+
lay.addWidget(self.content_area)
36+
37+
self.toggle_animation.addAnimation(
38+
QtCore.QPropertyAnimation(self, b"minimumHeight")
39+
)
40+
self.toggle_animation.addAnimation(
41+
QtCore.QPropertyAnimation(self, b"maximumHeight")
42+
)
43+
self.toggle_animation.addAnimation(
44+
QtCore.QPropertyAnimation(self.content_area, b"maximumHeight")
45+
)
46+
47+
@QtCore.pyqtSlot()
48+
def on_pressed(self):
49+
checked = self.toggle_button.isChecked()
50+
self.toggle_button.setArrowType(
51+
QtCore.Qt.DownArrow if not checked else QtCore.Qt.RightArrow
52+
)
53+
self.toggle_animation.setDirection(
54+
QtCore.QAbstractAnimation.Forward
55+
if not checked
56+
else QtCore.QAbstractAnimation.Backward
57+
)
58+
self.toggle_animation.start()
59+
60+
def set_content_layout(self, layout):
61+
lay = self.content_area.layout()
62+
del lay
63+
self.content_area.setLayout(layout)
64+
collapsed_height = (
65+
self.sizeHint().height() - self.content_area.maximumHeight()
66+
)
67+
content_height = layout.sizeHint().height()
68+
for i in range(self.toggle_animation.animationCount()):
69+
animation = self.toggle_animation.animationAt(i)
70+
animation.setDuration(500)
71+
animation.setStartValue(collapsed_height)
72+
animation.setEndValue(collapsed_height + content_height)
73+
74+
content_animation = self.toggle_animation.animationAt(
75+
self.toggle_animation.animationCount() - 1
76+
)
77+
content_animation.setDuration(500)
78+
content_animation.setStartValue(0)
79+
content_animation.setEndValue(content_height)
80+
81+
def make_splash():
82+
'''
83+
Makes and returns a Qt splash window object
84+
'''
85+
spl_fname = importlib.resources.files('d3dslic3r') / 'meta/Logo.png'
86+
splash_pix = QtGui.QPixmap(spl_fname,'PNG')
87+
splash = QtWidgets.QSplashScreen(splash_pix, QtCore.Qt.SplashScreen)
88+
splash.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.FramelessWindowHint)
89+
90+
font = splash.font()
91+
font.setPixelSize(20)
92+
font.setWeight(QtGui.QFont.Bold)
93+
splash.setFont(font)
94+
95+
# splash.showMessage('v%s'%(version('d3dslic3r')),QtCore.Qt.AlignRight | QtCore.Qt.AlignBottom, QtCore.Qt.lightGray)
96+
splash.showMessage('v%s'%("0.0.1"),QtCore.Qt.AlignRight | QtCore.Qt.AlignTop, QtCore.Qt.darkGray)
97+
return splash
98+
99+
def make_logo(ren):
100+
spl_fname = importlib.resources.files('d3dslic3r') / 'meta/background.png'
101+
# spl_fname=resource_filename("d3dslic3r","meta/background.png")
102+
img_reader = vtk.vtkPNGReader()
103+
img_reader.SetFileName(spl_fname)
104+
img_reader.Update()
105+
logo = vtk.vtkLogoRepresentation()
106+
logo.SetImage(img_reader.GetOutput())
107+
logo.ProportionalResizeOn()
108+
logo.SetPosition( 0.1, 0.1 ) #lower left
109+
logo.SetPosition2( 0.8, 0.8 ) #upper right
110+
logo.GetImageProperty().SetDisplayLocationToBackground()
111+
ren.AddViewProp(logo)
112+
logo.SetRenderer(ren)
113+
return logo
114+
115+
def get_file(*args):
116+
'''
117+
Returns absolute path to filename and the directory it is located in from a PyQt5 filedialog. First value is file extension, second is a string which overwrites the window message.
118+
'''
119+
ext = args
120+
launchdir = os.getcwd()
121+
ftypeName={}
122+
ftypeName['*.stl']=["STereoLithography file", "*.stl","STL file"]
123+
124+
filter_str = ""
125+
for entry in args:
126+
filter_str += ftypeName[entry][2] + ' ('+ftypeName[entry][1]+');;'
127+
filter_str += ('All Files (*.*)')
128+
129+
filer = QtWidgets.QFileDialog.getOpenFileName(None, ftypeName[ext[0]][0],
130+
os.getcwd(),(filter_str))
131+
132+
if filer[0] == '':
133+
return None
134+
135+
else: #return the filename/path
136+
return filer[0]
137+
138+
def generate_sphere(center, radius, color):
139+
source = vtk.vtkSphereSource()
140+
source.SetCenter(*center)
141+
source.SetRadius(radius)
142+
source.SetThetaResolution(20)
143+
source.SetPhiResolution(20)
144+
source.Update()
145+
146+
mapper = vtk.vtkPolyDataMapper()
147+
mapper.SetInputData(source.GetOutput())
148+
149+
actor = vtk.vtkActor()
150+
actor.SetMapper(mapper)
151+
actor.GetProperty().SetColor(*color)
152+
153+
return actor
154+
155+
def xyview(ren):
156+
camera = ren.GetActiveCamera()
157+
camera.SetPosition(0,0,1)
158+
camera.SetFocalPoint(0,0,0)
159+
camera.SetViewUp(0,1,0)
160+
ren.ResetCamera()
161+
162+
def yzview(ren):
163+
camera = ren.GetActiveCamera()
164+
camera.SetPosition(1,0,0)
165+
camera.SetFocalPoint(0,0,0)
166+
camera.SetViewUp(0,0,1)
167+
ren.ResetCamera()
168+
169+
def xzview(ren):
170+
vtk.vtkObject.GlobalWarningDisplayOff() #mapping from '3' triggers an underlying stereoview that most displays do not support for trackball interactors
171+
camera = ren.GetActiveCamera()
172+
camera.SetPosition(0,1,0)
173+
camera.SetFocalPoint(0,0,0)
174+
camera.SetViewUp(0,0,1)
175+
ren.ResetCamera()

d3dslic3r/meta/rotate_icon.png

2.34 KB
Loading

d3dslic3r/meta/translate_icon.png

1.7 KB
Loading

0 commit comments

Comments
 (0)