Browse Source

Adding slicerNetwork

Andrej Studen 7 years ago
parent
commit
26192442b9

+ 44 - 18
labkeySlicerPythonExtension/labkeySlicerPythonExtension.py

@@ -2,35 +2,36 @@ import os
 import unittest
 import unittest
 from __main__ import vtk, qt, ctk, slicer
 from __main__ import vtk, qt, ctk, slicer
 from slicer.ScriptedLoadableModule import *
 from slicer.ScriptedLoadableModule import *
+import OpenSSL
+
 
 
 #
 #
-# LineIntensityProfile
+# labkeySlicerPythonExtension
 #
 #
 
 
-class LineIntensityProfile(ScriptedLoadableModule):
+class labkeySlicerPythonExtension(ScriptedLoadableModule):
   """Uses ScriptedLoadableModule base class, available at:
   """Uses ScriptedLoadableModule base class, available at:
   https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/ScriptedLoadableModule.py
   https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/ScriptedLoadableModule.py
   """
   """
 
 
   def __init__(self, parent):
   def __init__(self, parent):
     ScriptedLoadableModule.__init__(self, parent)
     ScriptedLoadableModule.__init__(self, parent)
-    self.parent.title = "LineIntensityProfile" # TODO make this more human readable by adding spaces
+    self.parent.title = "labkeySlicerPythonExtension" # TODO make this more human readable by adding spaces
     self.parent.categories = ["Examples"]
     self.parent.categories = ["Examples"]
     self.parent.dependencies = []
     self.parent.dependencies = []
-    self.parent.contributors = ["John Doe (AnyWare Corp.)"] # replace with "Firstname Lastname (Organization)"
+    self.parent.contributors = ["Andrej Studen (UL/FMF)"] # replace with "Firstname Lastname (Organization)"
     self.parent.helpText = """
     self.parent.helpText = """
-    This is an example of scripted loadable module bundled in an extension.
+    Labkey interface to slicer
     """
     """
     self.parent.acknowledgementText = """
     self.parent.acknowledgementText = """
-    This file was originally developed by Jean-Christophe Fillion-Robin, Kitware Inc.
-    and Steve Pieper, Isomics, Inc. and was partially funded by NIH grant 3P41RR013218-12S1.
-""" # replace with organization, grant and thanks.
+    Developed within the medical physics research programme of the Slovenian research agency.
+    """ # replace with organization, grant and thanks.
 
 
 #
 #
-# LineIntensityProfileWidget
+# labkeySlicerPythonExtensionWidget
 #
 #
 
 
-class LineIntensityProfileWidget(ScriptedLoadableModuleWidget):
+class labkeySlicerPythonExtensionWidget(ScriptedLoadableModuleWidget):
   """Uses ScriptedLoadableModuleWidget base class, available at:
   """Uses ScriptedLoadableModuleWidget base class, available at:
   https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/ScriptedLoadableModule.py
   https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/ScriptedLoadableModule.py
   """
   """
@@ -42,6 +43,22 @@ class LineIntensityProfileWidget(ScriptedLoadableModuleWidget):
     #
     #
     # Parameters Area
     # Parameters Area
     #
     #
+    connectionCollapsibleButton = ctk.ctkCollapsibleButton()
+    connectionCollapsibleButton.text = "Connection"
+    self.layout.addWidget(connectionCollapsibleButton)
+
+    connectionFormLayout = qt.QFormLayout(connectionCollapsibleButton)
+
+    self.serverURL=qt.QLineEdit()
+    self.userCertButton=qt.QPushButton("Load")
+    self.userCertButton.toolTip="Load user certificate (p12)"
+    self.userCertButton.connect('clicked(bool)',self.onUserCertButtonClicked)
+
+    connectionFormLayout.addRow("Server: ", self.serverURL)
+    connectionFormLayout.addRow("User certificate:",self.userCertButton)
+
+
+
     parametersCollapsibleButton = ctk.ctkCollapsibleButton()
     parametersCollapsibleButton = ctk.ctkCollapsibleButton()
     parametersCollapsibleButton.text = "Parameters"
     parametersCollapsibleButton.text = "Parameters"
     self.layout.addWidget(parametersCollapsibleButton)
     self.layout.addWidget(parametersCollapsibleButton)
@@ -123,18 +140,27 @@ class LineIntensityProfileWidget(ScriptedLoadableModuleWidget):
     self.applyButton.enabled = self.inputSelector.currentNode() and self.outputSelector.currentNode()
     self.applyButton.enabled = self.inputSelector.currentNode() and self.outputSelector.currentNode()
 
 
   def onApplyButton(self):
   def onApplyButton(self):
-    logic = LineIntensityProfileLogic()
+    logic = labkeySlicerPythonExtensionLogic()
     enableScreenshotsFlag = self.enableScreenshotsFlagCheckBox.checked
     enableScreenshotsFlag = self.enableScreenshotsFlagCheckBox.checked
     screenshotScaleFactor = int(self.screenshotScaleFactorSliderWidget.value)
     screenshotScaleFactor = int(self.screenshotScaleFactorSliderWidget.value)
     print("Run the algorithm")
     print("Run the algorithm")
     logic.run(self.inputSelector.currentNode(), self.outputSelector.currentNode(), enableScreenshotsFlag,screenshotScaleFactor)
     logic.run(self.inputSelector.currentNode(), self.outputSelector.currentNode(), enableScreenshotsFlag,screenshotScaleFactor)
 
 
+  def onUserCertButtonClicked(self):
+     startDir=os.environ['HOME']
+     filename=qt.QFileDialog.getOpenFileName(None,'Open user certificate',
+           startDir, '*.p12')
+     pwd=qt.QInputDialog.getText(None,'Certificate password',
+       'Enter certificate password',qt.QLineEdit.Password)
+
+     p12=OpenSSL.crypto.load_pkcs12(open(filename,'rb').read(),pwd)
+
 
 
 #
 #
-# LineIntensityProfileLogic
+# labkeySlicerPythonExtensionLogic
 #
 #
 
 
-class LineIntensityProfileLogic(ScriptedLoadableModuleLogic):
+class labkeySlicerPythonExtensionLogic(ScriptedLoadableModuleLogic):
   """This class should implement all the actual
   """This class should implement all the actual
   computation done by your module.  The interface
   computation done by your module.  The interface
   should be such that other python code can import
   should be such that other python code can import
@@ -207,12 +233,12 @@ class LineIntensityProfileLogic(ScriptedLoadableModuleLogic):
     self.enableScreenshots = enableScreenshots
     self.enableScreenshots = enableScreenshots
     self.screenshotScaleFactor = screenshotScaleFactor
     self.screenshotScaleFactor = screenshotScaleFactor
 
 
-    self.takeScreenshot('LineIntensityProfile-Start','Start',-1)
+    self.takeScreenshot('labkeySlicerPythonExtension-Start','Start',-1)
 
 
     return True
     return True
 
 
 
 
-class LineIntensityProfileTest(ScriptedLoadableModuleTest):
+class labkeySlicerPythonExtensionTest(ScriptedLoadableModuleTest):
   """
   """
   This is the test case for your scripted module.
   This is the test case for your scripted module.
   Uses ScriptedLoadableModuleTest base class, available at:
   Uses ScriptedLoadableModuleTest base class, available at:
@@ -228,9 +254,9 @@ class LineIntensityProfileTest(ScriptedLoadableModuleTest):
     """Run as few or as many tests as needed here.
     """Run as few or as many tests as needed here.
     """
     """
     self.setUp()
     self.setUp()
-    self.test_LineIntensityProfile1()
+    self.test_labkeySlicerPythonExtension1()
 
 
-  def test_LineIntensityProfile1(self):
+  def test_labkeySlicerPythonExtension1(self):
     """ Ideally you should have several levels of tests.  At the lowest level
     """ Ideally you should have several levels of tests.  At the lowest level
     tests sould exercise the functionality of the logic with different inputs
     tests sould exercise the functionality of the logic with different inputs
     (both valid and invalid).  At higher levels your tests should emulate the
     (both valid and invalid).  At higher levels your tests should emulate the
@@ -262,6 +288,6 @@ class LineIntensityProfileTest(ScriptedLoadableModuleTest):
     self.delayDisplay('Finished with download and loading\n')
     self.delayDisplay('Finished with download and loading\n')
 
 
     volumeNode = slicer.util.getNode(pattern="FA")
     volumeNode = slicer.util.getNode(pattern="FA")
-    logic = LineIntensityProfileLogic()
+    logic = labkeySlicerPythonExtensionLogic()
     self.assertTrue( logic.hasImageData(volumeNode) )
     self.assertTrue( logic.hasImageData(volumeNode) )
     self.delayDisplay('Test passed!')
     self.delayDisplay('Test passed!')

+ 7 - 0
labkeySlicerPythonExtension/slicerNetwork.py

@@ -0,0 +1,7 @@
+import qt
+import OpenSSL
+
+
+class slicerNetwork:
+    def __init__():
+        pass