Skip to content

Commit

Permalink
Merge pull request #348 from vshekar/remove-prefill
Browse files Browse the repository at this point in the history
Prevent prefilling of parameters when request clicked
  • Loading branch information
vshekar authored Dec 5, 2023
2 parents 6d644da + 0d74496 commit 875e94a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
12 changes: 7 additions & 5 deletions gui/control_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ def createSampleTab(self):
colStartLabel.setFixedWidth(140)
colStartLabel.setAlignment(QtCore.Qt.AlignCenter)
self.osc_start_ledit = QtWidgets.QLineEdit()
self.setGuiValues({"osc_start": "0.0"})
self.osc_start_ledit.setFixedWidth(60)
self.osc_start_ledit.setValidator(QtGui.QDoubleValidator())
self.colEndLabel = QtWidgets.QLabel("Oscillation Range:")
Expand Down Expand Up @@ -599,6 +600,7 @@ def createSampleTab(self):
self.detDistRBVLabel = QtEpicsPVLabel(
daq_utils.motor_dict["detectorDist"] + ".RBV", self, 70
)
self.detDistTextChanged(self.detDistRBVLabel.getEntry().text())
detDistSPLabel = QtWidgets.QLabel("SetPoint:")
self.detDistMotorEntry = QtEpicsPVEntry(
daq_utils.motor_dict["detectorDist"] + ".VAL", self, 70, 2
Expand Down Expand Up @@ -4454,8 +4456,8 @@ def unmountSampleCB(self):
self.send_to_server("unmountSample")


def refreshCollectionParams(self, selectedSampleRequest, validate_hdf5=True):
reqObj = selectedSampleRequest["request_obj"]
def fillRequestParameters(self, reqObj):
"""Fills UI elements based on reqObj dictionary passed to it"""
self.protoComboBox.setCurrentIndex(
self.protoComboBox.findText(str(reqObj["protocol"]))
)
Expand Down Expand Up @@ -4498,9 +4500,9 @@ def refreshCollectionParams(self, selectedSampleRequest, validate_hdf5=True):
energy_s = str(daq_utils.wave2energy(reqObj["wavelength"], digits=6))
dist_s = str(reqObj["detDist"])
self.detDistMotorEntry.getEntry().setText(str(dist_s))
self.dataPathGB.setFilePrefix_ledit(str(reqObj["file_prefix"]))
self.dataPathGB.setBasePath_ledit(str(reqObj["basePath"]))
self.dataPathGB.setDataPath_ledit(str(reqObj["directory"]))

def refreshCollectionParams(self, selectedSampleRequest, validate_hdf5=True):
reqObj = selectedSampleRequest["request_obj"]
if (
str(reqObj["protocol"]) == "characterize"
or str(reqObj["protocol"]) == "ednaCol"
Expand Down
1 change: 1 addition & 0 deletions gui/data_loc_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def __init__(self, parent: "ControlMain"):
self.hBoxDPathParams2.addWidget(self.prefix_ledit)
self.dataNumstartLabel = QtWidgets.QLabel("File Number Start:")
self.file_numstart_ledit = QtWidgets.QLineEdit()
self.file_numstart_ledit.setText("1")
self.file_numstart_ledit.setValidator(QtGui.QIntValidator(1, 99999, self))
self.file_numstart_ledit.setFixedWidth(50)
self.hBoxDPathParams3 = QtWidgets.QHBoxLayout()
Expand Down
37 changes: 37 additions & 0 deletions gui/dewar_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def __init__(self, parent: "ControlMain"):
# self.isExpanded = 1
self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.customContextMenuRequested.connect(self.openMenu)
self.setStyleSheet("QTreeView::item::hover{background-color: #999966;}")
# Keeps track of whether the user is part of a proposal
self.proposal_membership = {}

Expand All @@ -59,6 +60,8 @@ def openMenu(self, position):
level = list(selectedLevels)[0]
menu = QtWidgets.QMenu()
if level == 2: # This is usually a request
useParamsAction = QtWidgets.QAction('Use Request Parameters', self)
useParamsAction.triggered.connect(self.useParamsCB)
deleteReqAction = QtWidgets.QAction(
"Delete selected request(s)", self
)
Expand All @@ -73,13 +76,46 @@ def openMenu(self, position):
"Dequeue selected request(s)", self
)
dequeueSelAction.triggered.connect(self.deQueueAllSelectedCB)
menu.addAction(useParamsAction)
menu.addAction(cloneReqAction)
menu.addAction(queueSelAction)
menu.addAction(dequeueSelAction)
menu.addSeparator()
menu.addAction(deleteReqAction)
menu.exec_(self.viewport().mapToGlobal(position))

def useParamsCB(self):
index = self.selectedIndexes()[0]
item = self.model.itemFromIndex(index)
requestData = db_lib.getRequestByID(item.data(32))
reqObj = requestData['request_obj']
self.parent.fillRequestParameters(reqObj)

def fillToolTip(self, data):
text = ""
table_data = {}
if 'request_obj' in data:
req_data = data['request_obj']
table_data['Exposure Time'] = req_data['exposure_time']
table_data['Transmission'] = req_data['attenuation']
table_data['Oscillation Width'] = req_data['img_width']
table_data['Oscillation Range'] = req_data['sweep_end'] - req_data['sweep_start']
table_data['Oscillation Start'] = req_data['sweep_start']
table_data['Detector Distance'] = req_data['detDist']
table_data['Resolution'] = req_data['resolution']
table_data['Energy (eV)'] = req_data['energy']
table_data['Wavelength'] = req_data['wavelength']
text = """<table border='1' style='border-collapse: collapse;'>
<tr>
<th style='border: 1px solid black;'>Parameter</th>
<th style='border: 1px solid black;'>Value</th>
</tr>"""
for key, value in table_data.items():
text += f"""<tr><td style='border: 1px solid black;'>{key}</td>
<td style='border: 1px solid black;'>{value}</td></tr>"""
text = text + "</table>"
return text

def cloneRequestCB(self):
# Only the first selected request is cloned (If multiple are chosen)
index = self.selectedIndexes()[0]
Expand Down Expand Up @@ -278,6 +314,7 @@ def create_request_item(self, request) -> QtGui.QStandardItem:
else:
col_item.setCheckState(Qt.CheckState.Unchecked)
col_item.setBackground(QtGui.QColor("white"))
col_item.setToolTip(self.fillToolTip(request))
return col_item

def refreshTreePriorityView(
Expand Down

0 comments on commit 875e94a

Please sign in to comment.