-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathshow_pointcloud.py
49 lines (36 loc) · 1.46 KB
/
show_pointcloud.py
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
import FreeCAD, FreeCADGui
import Points
import lithophane_utils
from utils.geometry_utils import linesToPointCloud
from utils.resource_utils import iconPath
import utils.qtutils as qtutils
def showPointCloud(pts, name):
pointCloud = Points.Points()
pointCloud.addPoints(linesToPointCloud(pts))
Points.show(pointCloud, name)
class ShowPointCloudCommand:
toolbarName = 'Debugging_Tools'
commandName = 'Show_PointCloud'
def GetResources(self):
return {'MenuText': "Show PointCloud",
'ToolTip' : "Show the point cloud generated for the selected image",
'Pixmap': iconPath('ShowPointcloud.svg')}
def Activated(self):
lithophaneImage, imageLabel = lithophane_utils.findSelectedImage()
if lithophaneImage is None:
qtutils.showInfo("No LithophaneImage selected", "Select exactly one LithophaneImage to continue")
return
showPointCloud(lithophaneImage.lines, imageLabel + '_PointCloud')
lithophane_utils.recomputeView()
def IsActive(self):
"""There should be at least an active document."""
return not FreeCAD.ActiveDocument is None
if __name__ == "__main__":
command = ShowPointCloudCommand();
if command.IsActive():
command.Activated()
else:
qtutils.showInfo("No open Document", "There is no open document")
else:
import toolbars
toolbars.toolbarManager.registerCommand(ShowPointCloudCommand())