Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
cd6afc8
created dialogs.py added browsing remote filesystem
paskino Nov 11, 2021
2f963db
reset the remote settings checkbox
paskino Nov 11, 2021
4e9d200
allows copy from the remote to local
paskino Nov 30, 2021
cf3fb23
update progress dialog
paskino Nov 30, 2021
61b3c08
revert tempfile.tempdir change
paskino Nov 30, 2021
cd35b9c
added remote workdir selection
paskino Nov 30, 2021
e6c47e7
work in progress to push dvc config to remote
paskino Nov 30, 2021
effa417
about ok
paskino Dec 1, 2021
a2f563e
up to zip dvc config and transfer to remote
paskino Dec 1, 2021
7fc1624
up to unzip on remote
paskino Dec 3, 2021
6dc4823
first working run on the remote
paskino Dec 3, 2021
654e111
fix indent
paskino Dec 3, 2021
a5dde6c
some updates
paskino Dec 3, 2021
8272d53
retrieves the results from remote
paskino Dec 10, 2021
d14e18e
graph window partially populated
paskino Dec 11, 2021
566fef6
Merge remote-tracking branch 'origin' into remote_devel
paskino Dec 13, 2021
ac2124c
added comments on remote transfer of files
paskino Dec 15, 2021
5bdd97d
Merge remote-tracking branch 'origin' into remote_devel
paskino Dec 15, 2021
e1fd2b6
fix check for local run
paskino Dec 15, 2021
43d680e
Fixes error in displaying DVC results (#78)
lauramurgatroyd Dec 15, 2021
a77789f
Merge branch 'remote_devel' of github.com:TomographicImaging/iDVC int…
paskino Dec 15, 2021
0807b92
make local dvc analysis work again
paskino Dec 15, 2021
d5b62ba
Merge remote-tracking branch 'origin' into remote_devel
paskino Jan 26, 2022
42a1fa2
Merge branch 'master' into remote_devel
paskino May 19, 2022
3fa4ec3
Merge remote-tracking branch 'origin' into remote_devel
paskino May 20, 2022
ce11634
Merge branch 'master' into remote_devel
paskino Sep 27, 2022
3544e94
Merge branch 'master' into remote_devel
paskino Nov 25, 2022
645fafe
Merge branch 'master' into remote_devel
paskino Mar 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 171 additions & 0 deletions src/idvc/dialogs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
from PySide2 import QtCore, QtGui, QtWidgets
from PySide2.QtWidgets import QCheckBox, QLabel, QDoubleSpinBox, QFrame, QVBoxLayout, QDialogButtonBox, QPushButton, QDialog
from PySide2.QtCore import Qt
import vtk
from brem.ui import RemoteServerSettingDialog
from eqt.ui import UIFormFactory

class SettingsWindow(QDialog):

def __init__(self, parent):
super(SettingsWindow, self).__init__(parent)

self.parent = parent

self.setWindowTitle("Settings")

self.dark_checkbox = QCheckBox("Dark Mode")

self.copy_files_checkbox = QCheckBox("Allow a copy of the image files to be stored. ")
self.vis_size_label = QLabel("Maximum downsampled image size (GB): ")
self.vis_size_entry = QDoubleSpinBox()

self.vis_size_entry.setMaximum(64.0)
self.vis_size_entry.setMinimum(0.01)
self.vis_size_entry.setSingleStep(0.01)

if self.parent.settings.value("vis_size") is not None:
self.vis_size_entry.setValue(float(self.parent.settings.value("vis_size")))

else:
self.vis_size_entry.setValue(1.0)


if self.parent.settings.value("dark_mode") is not None:
if self.parent.settings.value("dark_mode") == "true":
self.dark_checkbox.setChecked(True)
else:
self.dark_checkbox.setChecked(False)
else:
self.dark_checkbox.setChecked(True)

separator = QFrame()
separator.setFrameShape(QFrame.HLine)
separator.setFrameShadow(QFrame.Raised)
self.adv_settings_label = QLabel("Advanced")


self.gpu_label = QLabel("Please set the size of your GPU memory.")
self.gpu_size_label = QLabel("GPU Memory (GB): ")
self.gpu_size_entry = QDoubleSpinBox()


if self.parent.settings.value("gpu_size") is not None:
self.gpu_size_entry.setValue(float(self.parent.settings.value("gpu_size")))

else:
self.gpu_size_entry.setValue(1.0)

self.gpu_size_entry.setMaximum(64.0)
self.gpu_size_entry.setMinimum(0.00)
self.gpu_size_entry.setSingleStep(0.01)
self.gpu_checkbox = QCheckBox("Use GPU for volume render. (Recommended) ")
self.gpu_checkbox.setChecked(True) #gpu is default
if self.parent.settings.value("volume_mapper") == "cpu":
self.gpu_checkbox.setChecked(False)

if hasattr(self.parent, 'copy_files'):
self.copy_files_checkbox.setChecked(self.parent.copy_files)

self.layout = QVBoxLayout(self)
self.layout.addWidget(self.dark_checkbox)
self.layout.addWidget(self.copy_files_checkbox)
self.layout.addWidget(self.vis_size_label)
self.layout.addWidget(self.vis_size_entry)
self.layout.addWidget(separator)
self.layout.addWidget(self.adv_settings_label)
self.layout.addWidget(self.gpu_checkbox)
self.layout.addWidget(self.gpu_label)
self.layout.addWidget(self.gpu_size_label)
self.layout.addWidget(self.gpu_size_entry)

# configure remote server settings
remote_separator = QFrame()
remote_separator.setFrameShape(QFrame.HLine)
remote_separator.setFrameShadow(QFrame.Raised)
fw = UIFormFactory.getQWidget(parent=self)

self.remote_button_entry = QPushButton(self)
self.remote_button_entry.setText("Open Preferences")
self.remote_button_entry.clicked.connect(self.openConfigRemote)
fw.addWidget(self.remote_button_entry, 'Configure remote settings', 'remote_preferences')
cb = QCheckBox(self)
cb.setChecked(self.parent.connection_details is not None)
fw.addWidget(cb, 'Connect to remote server', 'connect_to_remote')
self.fw = fw
for k,v in fw.widgets.items():
print ("fw", k)
# add to layout
self.layout.addWidget(remote_separator)
self.layout.addWidget(fw)

self.buttons = QDialogButtonBox(
QDialogButtonBox.Save | QDialogButtonBox.Cancel,
Qt.Horizontal, self)
self.layout.addWidget(self.buttons)
self.buttons.accepted.connect(self.accept)
self.buttons.rejected.connect(self.quit)

def accept(self):
#self.parent.settings.setValue("settings_chosen", 1)
if self.dark_checkbox.isChecked():
self.parent.settings.setValue("dark_mode", True)
else:
self.parent.settings.setValue("dark_mode", False)
self.parent.SetAppStyle()

if self.copy_files_checkbox.isChecked():
self.parent.copy_files = 1 # save for this session
self.parent.settings.setValue("copy_files", 1) #save for next time we open app
else:
self.parent.copy_files = 0
self.parent.settings.setValue("copy_files", 0)

if self.gpu_checkbox.isChecked():
self.parent.settings.setValue("volume_mapper", "gpu")
self.parent.vis_widget_3D.volume_mapper = vtk.vtkSmartVolumeMapper()
else:
self.parent.settings.setValue("volume_mapper", "cpu")

self.parent.settings.setValue("gpu_size", float(self.gpu_size_entry.value()))
self.parent.settings.setValue("vis_size", float(self.vis_size_entry.value()))

if self.parent.settings.value("first_app_load") != "False":
self.parent.CreateSessionSelector("new window")
self.parent.settings.setValue("first_app_load", "False")

# if remote is checked
statusBar = self.parent.statusBar()
if self.fw.widgets['connect_to_remote_field'].isChecked():
self.parent.connection_details = self.connection_details
statusBar.showMessage("Connected to {}@{}:{}".format(
self.connection_details['username'],
self.connection_details['server_name'],
self.connection_details['server_port'])
)
else:
statusBar.clearMessage()
self.parent.connection_details = None
self.close()


#print(self.parent.settings.value("copy_files"))
def quit(self):
if self.parent.settings.value("first_app_load") != "False":
self.parent.CreateSessionSelector("new window")
self.parent.settings.setValue("first_app_load", "False")
self.close()

def openConfigRemote(self):

dialog = RemoteServerSettingDialog(self,port=None,
host=None,
username=None,
private_key=None)
dialog.Ok.clicked.connect(lambda: self.getConnectionDetails(dialog))
dialog.exec()

def getConnectionDetails(self, dialog):
for k,v in dialog.connection_details.items():
print (k,v)
self.connection_details = dialog.connection_details
168 changes: 52 additions & 116 deletions src/idvc/dvc_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@
from qdarkstyle.light.palette import LightPalette

from idvc import version as gui_version
from idvc.dialogs import SettingsWindow

from brem.ui import RemoteFileDialog
from brem import AsyncCopyFromSSH

__version__ = gui_version.version

Expand Down Expand Up @@ -223,6 +227,7 @@ def InitialiseSessionVars(self):
self.dvc_input_image_in_session_folder = False
if hasattr(self, 'ref_image_data'):
del self.ref_image_data
self.connection_details = None


#Loading the DockWidgets:
Expand Down Expand Up @@ -499,7 +504,54 @@ def view_and_load_images(self):
self.view_image()
self.resetRegistration()


def SelectImage(self, image_var, image, label=None, next_button=None):
if self.connection_details is None:
return self.SelectImageLocal(image_var, image, label, next_button)
else:
return self.SelectImageRemote(image_var, image, label, next_button)

def SelectImageRemote(self, image_var, image, label=None, next_button=None):
# start the RemoteFileBrowser
logfile = os.path.join(os.getcwd(), '..','..',"RemoteFileDialog.log")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clearly this is a hack. Possibly we don't want to save a log file? Or we should have another temporary directory/file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

temporary would be best

dialog = RemoteFileDialog(self, logfile=logfile, port=self.connection_details['server_port'],
host=self.connection_details['server_name'],
username=self.connection_details['username'],
private_key=self.connection_details['private_key'],
remote_os=self.connection_details['remote_os'])
dialog.Ok.clicked.connect(lambda: self.getSelected(dialog))
if hasattr(self, 'files_to_get'):
try:
dialog.widgets['lineEdit'].setText(self.files_to_get[0][0])
except:
pass
dialog.exec()
def getSelected(self, dialog):
if hasattr(dialog, 'selected'):
print (type(dialog.selected))
for el in dialog.selected:
print ("Return from dialogue", el)
self.files_to_get = list (dialog.selected)
def ResampleAndGetFileFromRemote(self):
# 1 download self.files_to_get
if len(self.files_to_get) == 1:
self.asyncCopy = AsyncCopyFromSSH()
if not hasattr(self, 'connection_details'):
self.statusBar().showMessage("define the connection")
return
username = self.connection_details['username']
port = self.connection_details['server_port']
host = self.connection_details['server_name']
private_key = self.connection_details['private_key']

self.asyncCopy.setRemoteConnectionSettings(username=username,
port=port, host=host, private_key=private_key)
self.asyncCopy.SetRemoteFileName(dirname=self.files_to_get[0][0], filename=self.files_to_get[0][1])
self.asyncCopy.SetDestinationDir(os.path.abspath(self.tempdir.name))
self.asyncCopy.signals.finished.connect(lambda: self.visualise())
self.asyncCopy.GetFile()

def SelectImageLocal(self, image_var, image, label=None, next_button=None):
#print("In select image")
dialogue = QFileDialog()
files = dialogue.getOpenFileNames(self,"Load Images")[0]
Expand Down Expand Up @@ -5021,123 +5073,7 @@ def progress(self, value):



class SettingsWindow(QDialog):

def __init__(self, parent):
super(SettingsWindow, self).__init__(parent)

self.parent = parent

self.setWindowTitle("Settings")

self.dark_checkbox = QCheckBox("Dark Mode")

self.copy_files_checkbox = QCheckBox("Allow a copy of the image files to be stored. ")
self.vis_size_label = QLabel("Maximum downsampled image size (GB): ")
self.vis_size_entry = QDoubleSpinBox()

self.vis_size_entry.setMaximum(64.0)
self.vis_size_entry.setMinimum(0.01)
self.vis_size_entry.setSingleStep(0.01)

if self.parent.settings.value("vis_size") is not None:
self.vis_size_entry.setValue(float(self.parent.settings.value("vis_size")))

else:
self.vis_size_entry.setValue(1.0)


if self.parent.settings.value("dark_mode") is not None:
if self.parent.settings.value("dark_mode") == "true":
self.dark_checkbox.setChecked(True)
else:
self.dark_checkbox.setChecked(False)
else:
self.dark_checkbox.setChecked(True)

separator = QFrame()
separator.setFrameShape(QFrame.HLine)
separator.setFrameShadow(QFrame.Raised)
self.adv_settings_label = QLabel("Advanced")


self.gpu_label = QLabel("Please set the size of your GPU memory.")
self.gpu_size_label = QLabel("GPU Memory (GB): ")
self.gpu_size_entry = QDoubleSpinBox()


if self.parent.settings.value("gpu_size") is not None:
self.gpu_size_entry.setValue(float(self.parent.settings.value("gpu_size")))

else:
self.gpu_size_entry.setValue(1.0)

self.gpu_size_entry.setMaximum(64.0)
self.gpu_size_entry.setMinimum(0.00)
self.gpu_size_entry.setSingleStep(0.01)
self.gpu_checkbox = QCheckBox("Use GPU for volume render. (Recommended) ")
self.gpu_checkbox.setChecked(True) #gpu is default
if self.parent.settings.value("volume_mapper") == "cpu":
self.gpu_checkbox.setChecked(False)

if hasattr(self.parent, 'copy_files'):
self.copy_files_checkbox.setChecked(self.parent.copy_files)

self.layout = QVBoxLayout(self)
self.layout.addWidget(self.dark_checkbox)
self.layout.addWidget(self.copy_files_checkbox)
self.layout.addWidget(self.vis_size_label)
self.layout.addWidget(self.vis_size_entry)
self.layout.addWidget(separator)
self.layout.addWidget(self.adv_settings_label)
self.layout.addWidget(self.gpu_checkbox)
self.layout.addWidget(self.gpu_label)
self.layout.addWidget(self.gpu_size_label)
self.layout.addWidget(self.gpu_size_entry)
self.buttons = QDialogButtonBox(
QDialogButtonBox.Save | QDialogButtonBox.Cancel,
Qt.Horizontal, self)
self.layout.addWidget(self.buttons)
self.buttons.accepted.connect(self.accept)
self.buttons.rejected.connect(self.quit)

def accept(self):
#self.parent.settings.setValue("settings_chosen", 1)
if self.dark_checkbox.isChecked():
self.parent.settings.setValue("dark_mode", True)
else:
self.parent.settings.setValue("dark_mode", False)
self.parent.SetAppStyle()

if self.copy_files_checkbox.isChecked():
self.parent.copy_files = 1 # save for this session
self.parent.settings.setValue("copy_files", 1) #save for next time we open app
else:
self.parent.copy_files = 0
self.parent.settings.setValue("copy_files", 0)

if self.gpu_checkbox.isChecked():
self.parent.settings.setValue("volume_mapper", "gpu")
self.parent.vis_widget_3D.volume_mapper = vtk.vtkSmartVolumeMapper()
else:
self.parent.settings.setValue("volume_mapper", "cpu")

self.parent.settings.setValue("gpu_size", float(self.gpu_size_entry.value()))
self.parent.settings.setValue("vis_size", float(self.vis_size_entry.value()))

if self.parent.settings.value("first_app_load") != "False":
self.parent.CreateSessionSelector("new window")
self.parent.settings.setValue("first_app_load", "False")

self.close()


#print(self.parent.settings.value("copy_files"))
def quit(self):
if self.parent.settings.value("first_app_load") != "False":
self.parent.CreateSessionSelector("new window")
self.parent.settings.setValue("first_app_load", "False")
self.close()



Expand Down