|
@@ -39,7 +39,7 @@ class labkeySlicerPythonExtensionWidget(ScriptedLoadableModuleWidget):
|
|
ScriptedLoadableModuleWidget.setup(self)
|
|
ScriptedLoadableModuleWidget.setup(self)
|
|
# Instantiate and connect widgets ...
|
|
# Instantiate and connect widgets ...
|
|
self.logic=labkeySlicerPythonExtensionLogic(self)
|
|
self.logic=labkeySlicerPythonExtensionLogic(self)
|
|
- self.network=slicerNetwork.slicerNetwork(self)
|
|
|
|
|
|
+ self.network=slicerNetwork.labkeyURIHandler()
|
|
#
|
|
#
|
|
# Parameters Area
|
|
# Parameters Area
|
|
#
|
|
#
|
|
@@ -72,85 +72,64 @@ class labkeySlicerPythonExtensionWidget(ScriptedLoadableModuleWidget):
|
|
|
|
|
|
connectionFormLayout.addRow("CA certificate:",self.caCertButton)
|
|
connectionFormLayout.addRow("CA certificate:",self.caCertButton)
|
|
|
|
|
|
|
|
+ self.auth_pwd=''
|
|
self.connectButton=qt.QPushButton("Connect")
|
|
self.connectButton=qt.QPushButton("Connect")
|
|
self.connectButton.toolTip="Connect to the server"
|
|
self.connectButton.toolTip="Connect to the server"
|
|
self.connectButton.connect('clicked(bool)',self.onConnectButtonClicked)
|
|
self.connectButton.connect('clicked(bool)',self.onConnectButtonClicked)
|
|
|
|
|
|
connectionFormLayout.addRow("Connection:",self.connectButton)
|
|
connectionFormLayout.addRow("Connection:",self.connectButton)
|
|
|
|
|
|
- parametersCollapsibleButton = ctk.ctkCollapsibleButton()
|
|
|
|
- parametersCollapsibleButton.text = "Parameters"
|
|
|
|
- self.layout.addWidget(parametersCollapsibleButton)
|
|
|
|
|
|
+ fileDialogCollapsibleButton = ctk.ctkCollapsibleButton()
|
|
|
|
+ fileDialogCollapsibleButton.text = "Remote files"
|
|
|
|
+ self.layout.addWidget(fileDialogCollapsibleButton)
|
|
|
|
|
|
# Layout within the dummy collapsible button
|
|
# Layout within the dummy collapsible button
|
|
- parametersFormLayout = qt.QFormLayout(parametersCollapsibleButton)
|
|
|
|
|
|
+ fileDialogFormLayout = qt.QFormLayout(fileDialogCollapsibleButton)
|
|
|
|
|
|
- #
|
|
|
|
- # input volume selector
|
|
|
|
- #
|
|
|
|
- self.inputSelector = slicer.qMRMLNodeComboBox()
|
|
|
|
- self.inputSelector.nodeTypes = ( ("vtkMRMLScalarVolumeNode"), "" )
|
|
|
|
- self.inputSelector.addAttribute( "vtkMRMLScalarVolumeNode", "LabelMap", 0 )
|
|
|
|
- self.inputSelector.selectNodeUponCreation = True
|
|
|
|
- self.inputSelector.addEnabled = False
|
|
|
|
- self.inputSelector.removeEnabled = False
|
|
|
|
- self.inputSelector.noneEnabled = False
|
|
|
|
- self.inputSelector.showHidden = False
|
|
|
|
- self.inputSelector.showChildNodeTypes = False
|
|
|
|
- self.inputSelector.setMRMLScene( slicer.mrmlScene )
|
|
|
|
- self.inputSelector.setToolTip( "Pick the input to the algorithm." )
|
|
|
|
- parametersFormLayout.addRow("Input Volume: ", self.inputSelector)
|
|
|
|
|
|
+ #add item list for each found file/directory
|
|
|
|
+ self.fileList=qt.QListWidget(parent=self)
|
|
|
|
+ self.fileList.toolTip="Select remote file"
|
|
|
|
+ self.fileList.currentItemChanged.connect(self.onFileListItemChanged)
|
|
|
|
+ self.currentRemoteDir=''
|
|
|
|
|
|
- #
|
|
|
|
- # output volume selector
|
|
|
|
- #
|
|
|
|
- self.outputSelector = slicer.qMRMLNodeComboBox()
|
|
|
|
- self.outputSelector.nodeTypes = ( ("vtkMRMLScalarVolumeNode"), "" )
|
|
|
|
- self.outputSelector.addAttribute( "vtkMRMLScalarVolumeNode", "LabelMap", 0 )
|
|
|
|
- self.outputSelector.selectNodeUponCreation = False
|
|
|
|
- self.outputSelector.addEnabled = True
|
|
|
|
- self.outputSelector.removeEnabled = True
|
|
|
|
- self.outputSelector.noneEnabled = False
|
|
|
|
- self.outputSelector.showHidden = False
|
|
|
|
- self.outputSelector.showChildNodeTypes = False
|
|
|
|
- self.outputSelector.setMRMLScene( slicer.mrmlScene )
|
|
|
|
- self.outputSelector.setToolTip( "Pick the output to the algorithm." )
|
|
|
|
- parametersFormLayout.addRow("Output Volume: ", self.outputSelector)
|
|
|
|
|
|
+ #add dummy entry
|
|
|
|
+ items=('.','..')
|
|
|
|
+ self.populateFileList(items)
|
|
|
|
|
|
- #
|
|
|
|
- # check box to trigger taking screen shots for later use in tutorials
|
|
|
|
- #
|
|
|
|
- self.enableScreenshotsFlagCheckBox = qt.QCheckBox()
|
|
|
|
- self.enableScreenshotsFlagCheckBox.checked = 0
|
|
|
|
- self.enableScreenshotsFlagCheckBox.setToolTip("If checked, take screen shots for tutorials. Use Save Data to write them to disk.")
|
|
|
|
- parametersFormLayout.addRow("Enable Screenshots", self.enableScreenshotsFlagCheckBox)
|
|
|
|
|
|
+ fileDialogFormLayout.addWidget(self.fileList)
|
|
|
|
|
|
- #
|
|
|
|
- # scale factor for screen shots
|
|
|
|
- #
|
|
|
|
- self.screenshotScaleFactorSliderWidget = ctk.ctkSliderWidget()
|
|
|
|
- self.screenshotScaleFactorSliderWidget.singleStep = 1.0
|
|
|
|
- self.screenshotScaleFactorSliderWidget.minimum = 1.0
|
|
|
|
- self.screenshotScaleFactorSliderWidget.maximum = 50.0
|
|
|
|
- self.screenshotScaleFactorSliderWidget.value = 1.0
|
|
|
|
- self.screenshotScaleFactorSliderWidget.setToolTip("Set scale factor for the screen shots.")
|
|
|
|
- parametersFormLayout.addRow("Screenshot scale factor", self.screenshotScaleFactorSliderWidget)
|
|
|
|
|
|
+ #add selected file display
|
|
|
|
+ self.selectedFile=qt.QLineEdit(parent=self)
|
|
|
|
+ self.selectedFile.toolTip="Selected file"
|
|
|
|
|
|
- #
|
|
|
|
- # Apply Button
|
|
|
|
- #
|
|
|
|
- self.applyButton = qt.QPushButton("Apply")
|
|
|
|
- self.applyButton.toolTip = "Run the algorithm."
|
|
|
|
- self.applyButton.enabled = False
|
|
|
|
- parametersFormLayout.addRow(self.applyButton)
|
|
|
|
|
|
+ fileDialogFormLayout.addRow("Selected file :",self.selectedFile)
|
|
|
|
|
|
- # connections
|
|
|
|
- self.applyButton.connect('clicked(bool)', self.onApplyButton)
|
|
|
|
- self.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)
|
|
|
|
- self.outputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onSelect)
|
|
|
|
|
|
+ #add possible file Content
|
|
|
|
+ self.fileTypeSelector=qt.QComboBox()
|
|
|
|
+ self.fileTypeSelector.toolTip="Select file type"
|
|
|
|
|
|
- # Add vertical spacer
|
|
|
|
- self.layout.addStretch(1)
|
|
|
|
|
|
+ items=self.network.fileTypesAvailable()
|
|
|
|
+ self.populateFileTypeSelector(items)
|
|
|
|
+
|
|
|
|
+ fileDialogFormLayout.addRow("File type :",self.fileTypeSelector)
|
|
|
|
+
|
|
|
|
+ loadFileButton=qt.QPushButton("Load file")
|
|
|
|
+ loadFileButton.toolTip="Load file"
|
|
|
|
+ loadFileButton.clicked.connect(self.onLoadFileButtonClicked)
|
|
|
|
+
|
|
|
|
+ fileDialogFormLayout.addRow("Action :",loadFileButton)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ def populateFileList(self,items):
|
|
|
|
+ self.fileList.clear()
|
|
|
|
+ for it_text in items:
|
|
|
|
+ item=qt.QListWidgetItem(self.fileList)
|
|
|
|
+ item.setText(it_text)
|
|
|
|
+ item.setIcon(qt.QIcon(it_text))
|
|
|
|
+
|
|
|
|
+ def populateFileTypeSelector(self,items):
|
|
|
|
+ for item in items:
|
|
|
|
+ self.fileTypeSelector.addItem(item)
|
|
|
|
|
|
def cleanup(self):
|
|
def cleanup(self):
|
|
pass
|
|
pass
|
|
@@ -239,13 +218,49 @@ class labkeySlicerPythonExtensionWidget(ScriptedLoadableModuleWidget):
|
|
uname=qt.QInputDialog.getText(None,
|
|
uname=qt.QInputDialog.getText(None,
|
|
"Labkey credentials","Enter username",qt.QLineEdit.Normal,uname)
|
|
"Labkey credentials","Enter username",qt.QLineEdit.Normal,uname)
|
|
|
|
|
|
- pwd=qt.QInputDialog.getText(None,
|
|
|
|
- "Labkey credentials","Enter password",qt.QLineEdit.Password)
|
|
|
|
-
|
|
|
|
- self.network.connectRemote(str(self.serverURL.text),uname,pwd)
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ self.auth_pwd=qt.QInputDialog.getText(None,
|
|
|
|
+ "Labkey credentials","Enter password",qt.QLineEdit.Password,self.auth_pwd)
|
|
|
|
+
|
|
|
|
+ self.network.connectRemote(str(self.serverURL.text),uname,self.auth_pwd)
|
|
|
|
+
|
|
|
|
+ def onFileListItemChanged(self,curr,prev):
|
|
|
|
+ pText="None"
|
|
|
|
+ if prev != None:
|
|
|
|
+ pText=prev.text()
|
|
|
|
+ if curr == None:
|
|
|
|
+ print "Selected items: {0} -> None".format(pText)
|
|
|
|
+ return
|
|
|
|
+
|
|
|
|
+ print "Selected items: {0} -> None".format(pText)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ #this is hard -> compose path string from currentRemoteDir and selection
|
|
|
|
+ if curr.text().find('..')==0:
|
|
|
|
+ #one up
|
|
|
|
+ idx=self.currentRemoteDir.rfind('/')
|
|
|
|
+ if idx<0:
|
|
|
|
+ self.currentRemoteDir=''
|
|
|
|
+ else:
|
|
|
|
+ self.currentRemoteDir=self.currentRemoteDir[:idx]
|
|
|
|
+ elif curr.text().find('.')==0:
|
|
|
|
+ pass
|
|
|
|
+ else:
|
|
|
|
+ if len(self.currentRemoteDir)>0:
|
|
|
|
+ self.currentRemoteDir+='/'
|
|
|
|
+ self.currentRemoteDir+=curr.text()
|
|
|
|
+ print "Listing {0}".format(self.currentRemoteDir)
|
|
|
|
+ flist=self.network.toRelativePath(
|
|
|
|
+ self.network.listDir(self.currentRemoteDir))
|
|
|
|
+ print "Got"
|
|
|
|
+ print flist
|
|
|
|
+ flist.insert(0,'..')
|
|
|
|
+ flist.insert(0,'.')
|
|
|
|
+ self.populateFileList(flist)
|
|
|
|
+ self.selectedFile.setText(self.currentRemoteDir)
|
|
|
|
+
|
|
|
|
+ def onLoadFileButtonClicked(self):
|
|
|
|
+ self.network.loadNodeFromFile(self.selectedFile.text,
|
|
|
|
+ self.fileTypeSelector.currentText)
|
|
|
|
|
|
#
|
|
#
|
|
# labkeySlicerPythonExtensionLogic
|
|
# labkeySlicerPythonExtensionLogic
|