Skip to content
Snippets Groups Projects
Commit aae2db64 authored by Omar Animashaun's avatar Omar Animashaun
Browse files

Updates to AmpScanGUI.py including better documentation for updated parts

parent 2d2d5648
Branches
No related tags found
1 merge request!24Omar changes
Pipeline #808 canceled
...@@ -89,14 +89,12 @@ class AmpScanGUI(QMainWindow): ...@@ -89,14 +89,12 @@ class AmpScanGUI(QMainWindow):
moving = str(self.alCont.moving.currentText()) moving = str(self.alCont.moving.currentText())
self.files[moving].save(fname[0]) self.files[moving].save(fname[0])
try: try:
self.pnt
f = open(fname[0]+'.txt','w+') f = open(fname[0]+'.txt','w+')
f.write('Picked Coordinates = {}'.format(self.pnt)) f.write('{}'.format(self.pnt))
except AttributeError: except AttributeError:
print('A point has not been selected') print('A point has not been selected')
def display(self): def display(self):
render = [] render = []
for r in range(self.fileManager.n): for r in range(self.fileManager.n):
...@@ -128,23 +126,32 @@ class AmpScanGUI(QMainWindow): ...@@ -128,23 +126,32 @@ class AmpScanGUI(QMainWindow):
def Point_Pick(self): def Point_Pick(self):
""" """
Pick a point on the mesh. Waits for a point click to occur before calling further functions
TODO: Create 'Picker controls'? Similar to Alignment controls, but where
user can enter the name of the point they select - this can allow
multiple landmark locations to be stored and marked?
""" """
self.vtkWidget.iren.AddObserver('RightButtonPressEvent', self.pick_loc) self.vtkWidget.iren.AddObserver('RightButtonPressEvent', self.pick_loc)
self.renWin.Render() self.renWin.Render()
def pick_loc(self, event, x): def pick_loc(self, event, x):
""" """
calcs the location of click calcs the location of click in GUI (x,y)
calls function in ampVis.py which converts from GUI coordinates to
mesh coordinates and marks the point
""" """
#print(event, x) #print(event, x)
self.vtkWidget.iren.RemoveObservers('RightButtonPressEvent') self.vtkWidget.iren.RemoveObservers('RightButtonPressEvent')
loc = event.GetEventPosition() loc = event.GetEventPosition()
self.pnt = vtkRenWin.Pick_point(self.renWin, loc) self.pnt = vtkRenWin.Pick_point(self.renWin, loc)
#[name, _, color, opacity, display] = self.fileManager.getRow(0) #vtkRenWin.mark(self.renWin,self.pnt[0],self.pnt[1],self.pnt[2])
#self.files[name].MeasurementsOut(pnt) print(self.pnt)
def removePick(self): def removePick(self):
"""
delete all marked points and labels
TODO: be able to delete individual points?
"""
self.pnt = None self.pnt = None
vtkRenWin.delMarker(self.renWin) vtkRenWin.delMarker(self.renWin)
...@@ -322,6 +329,14 @@ class AmpScanGUI(QMainWindow): ...@@ -322,6 +329,14 @@ class AmpScanGUI(QMainWindow):
self.renWin.renderActors(self.AmpObj.actors, ['socket', 'antS']) self.renWin.renderActors(self.AmpObj.actors, ['socket', 'antS'])
self.renWin.setScalarBar(self.AmpObj.actors['antS']) self.renWin.setScalarBar(self.AmpObj.actors['antS'])
def measure(self):
#if no point selected condition move to analyse.py
if self.pnt is None:
print("Please select a reference point first.")
else:
[name, _, color, opacity, display] = self.fileManager.getRow(0)
self.files[name].MeasurementsOut(self.pnt)
def createActions(self): def createActions(self):
""" """
Numpy style docstring. Numpy style docstring.
...@@ -349,6 +364,8 @@ class AmpScanGUI(QMainWindow): ...@@ -349,6 +364,8 @@ class AmpScanGUI(QMainWindow):
triggered=self.Point_Pick) triggered=self.Point_Pick)
self.removePick = QAction(QIcon('open.png'), 'Clear all picked points', self, self.removePick = QAction(QIcon('open.png'), 'Clear all picked points', self,
triggered = self.removePick) triggered = self.removePick)
self.Measure = QAction(QIcon('open.png'), 'Generate Measurements', self,
triggered = self.measure)
def createMenus(self): def createMenus(self):
""" """
...@@ -373,6 +390,8 @@ class AmpScanGUI(QMainWindow): ...@@ -373,6 +390,8 @@ class AmpScanGUI(QMainWindow):
self.PointMenu = self.menuBar().addMenu("&Pick Point") self.PointMenu = self.menuBar().addMenu("&Pick Point")
self.PointMenu.addAction(self.pick) self.PointMenu.addAction(self.pick)
self.PointMenu.addAction(self.removePick) self.PointMenu.addAction(self.removePick)
self.measureMenu = self.menuBar().addMenu("Measure")
self.measureMenu.addAction(self.Measure)
class fileManager(QMainWindow): class fileManager(QMainWindow):
""" """
...@@ -383,7 +402,7 @@ class fileManager(QMainWindow): ...@@ -383,7 +402,7 @@ class fileManager(QMainWindow):
Perhaps an example implementation: Perhaps an example implementation:
>>> from AmpScan.AmpScanGUI import AmpScanGUI >>> from AmpScan.AmpScanGUI import AmpScanGUI
*
""" """
def __init__(self, parent = None): def __init__(self, parent = None):
...@@ -491,27 +510,6 @@ class AlignControls(QMainWindow): ...@@ -491,27 +510,6 @@ class AlignControls(QMainWindow):
self.moving.addItems(self.names) self.moving.addItems(self.names)
class PickerControls(QMainWindow):
"""
Pop up after point is picked
"""
def __init__(self, names, parent = None):
super(PickerControls, self).__init__(parent)
self.main = QWidget()
self.names = names
self.baseline = QComboBox()
self.target = QComboBox()
self.reg = QPushButton("Run Registration")
self.setCentralWidget(self.main)
self.layout = QGridLayout()
self.layout.addWidget(QLabel('Baseline'), 0, 0)
self.layout.addWidget(QLabel('Target'), 1, 0)
self.layout.addWidget(self.baseline, 0, 1)
self.layout.addWidget(self.target, 1, 1)
self.layout.addWidget(self.reg, 2, 0, 1, -1)
self.main.setLayout(self.layout)
self.setWindowTitle("Registration Manager")
self.getNames()
def getNames(self): def getNames(self):
""" """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment