Created
May 8, 2017 14:43
-
-
Save tfmoraes/37107e7dba7200c54298642f2558f834 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app.py b/app.py | |
index a2b76f9..cd4c055 100755 | |
--- a/app.py | |
+++ b/app.py | |
@@ -198,7 +198,8 @@ class SplashScreen(wx.SplashScreen): | |
self.control = Controller(self.main) | |
self.fc = wx.FutureCall(1, self.ShowMain) | |
- wx.FutureCall(1, parse_comand_line) | |
+ options, args = parse_comand_line() | |
+ wx.FutureCall(1, use_cmd_optargs, options, args) | |
# Check for updates | |
from threading import Thread | |
@@ -224,6 +225,24 @@ class SplashScreen(wx.SplashScreen): | |
if self.fc.IsRunning(): | |
self.Raise() | |
+ | |
+def non_gui_startup(options, args): | |
+ lang = 'en' | |
+ _ = i18n.InstallLanguage(lang) | |
+ | |
+ from invesalius.control import Controller | |
+ from invesalius.project import Project | |
+ | |
+ session = ses.Session() | |
+ if not session.ReadSession(): | |
+ session.CreateItens() | |
+ session.SetLanguage(lang) | |
+ session.WriteSessionFile() | |
+ | |
+ control = Controller(None) | |
+ | |
+ use_cmd_optargs(options, args) | |
+ | |
# ------------------------------------------------------------------ | |
@@ -241,6 +260,10 @@ def parse_comand_line(): | |
action="store_true", | |
dest="debug") | |
+ parser.add_option('--no-gui', | |
+ action='store_true', | |
+ dest='no_gui') | |
+ | |
# -i or --import: import DICOM directory | |
# chooses largest series | |
parser.add_option("-i", "--import", | |
@@ -254,7 +277,10 @@ def parse_comand_line(): | |
help="To open a project and export it to STL for all mask presets.") | |
options, args = parser.parse_args() | |
+ return options, args | |
+ | |
+def use_cmd_optargs(options, args): | |
# If debug argument... | |
if options.debug: | |
Publisher.subscribe(print_events, Publisher.ALL_TOPICS) | |
@@ -333,8 +359,13 @@ def main(): | |
""" | |
Initialize InVesalius GUI | |
""" | |
- application = InVesalius(0) | |
- application.MainLoop() | |
+ options, args = parse_comand_line() | |
+ | |
+ if options.no_gui: | |
+ non_gui_startup(options, args) | |
+ else: | |
+ application = InVesalius(0) | |
+ application.MainLoop() | |
if __name__ == '__main__': | |
#Is needed because of pyinstaller | |
diff --git a/invesalius/constants.py b/invesalius/constants.py | |
index 8664b7d..450468f 100644 | |
--- a/invesalius/constants.py | |
+++ b/invesalius/constants.py | |
@@ -686,19 +686,19 @@ BTNS_IMG_MKS = {IR1: {0: 'LEI'}, | |
IR2: {1: 'REI'}, | |
IR3: {2: 'NAI'}} | |
-TIPS_IMG = [wx.ToolTip(_("Select left ear in image")), | |
- wx.ToolTip(_("Select right ear in image")), | |
- wx.ToolTip(_("Select nasion in image"))] | |
+TIPS_IMG = [_("Select left ear in image"), | |
+ _("Select right ear in image"), | |
+ _("Select nasion in image")] | |
BTNS_TRK = {TR1: {3: _('LET')}, | |
TR2: {4: _('RET')}, | |
TR3: {5: _('NAT')}, | |
SET: {6: _('SET')}} | |
-TIPS_TRK = [wx.ToolTip(_("Select left ear with spatial tracker")), | |
- wx.ToolTip(_("Select right ear with spatial tracker")), | |
- wx.ToolTip(_("Select nasion with spatial tracker")), | |
- wx.ToolTip(_("Show set coordinates in image"))] | |
+TIPS_TRK = [_("Select left ear with spatial tracker"), | |
+ _("Select right ear with spatial tracker"), | |
+ _("Select nasion with spatial tracker"), | |
+ _("Show set coordinates in image")] | |
CAL_DIR = os.path.abspath(os.path.join(FILE_PATH, '..', 'navigation', 'mtc_files', 'CalibrationFiles')) | |
MAR_DIR = os.path.abspath(os.path.join(FILE_PATH, '..', 'navigation', 'mtc_files', 'Markers')) | |
diff --git a/invesalius/data/slice_.py b/invesalius/data/slice_.py | |
index 48f6f46..d23eb81 100644 | |
--- a/invesalius/data/slice_.py | |
+++ b/invesalius/data/slice_.py | |
@@ -353,19 +353,22 @@ class Slice(object): | |
# TODO: merge this code with apply_slice_buffer_to_mask | |
b_mask = self.buffer_slices["AXIAL"].mask | |
- n = self.buffer_slices["AXIAL"].index + 1 | |
- self.current_mask.matrix[n, 1:, 1:] = b_mask | |
- self.current_mask.matrix[n, 0, 0] = 1 | |
+ if b_mask: | |
+ n = self.buffer_slices["AXIAL"].index + 1 | |
+ self.current_mask.matrix[n, 1:, 1:] = b_mask | |
+ self.current_mask.matrix[n, 0, 0] = 1 | |
b_mask = self.buffer_slices["CORONAL"].mask | |
- n = self.buffer_slices["CORONAL"].index + 1 | |
- self.current_mask.matrix[1:, n, 1:] = b_mask | |
- self.current_mask.matrix[0, n, 0] = 1 | |
+ if b_mask: | |
+ n = self.buffer_slices["CORONAL"].index + 1 | |
+ self.current_mask.matrix[1:, n, 1:] = b_mask | |
+ self.current_mask.matrix[0, n, 0] = 1 | |
b_mask = self.buffer_slices["SAGITAL"].mask | |
- n = self.buffer_slices["SAGITAL"].index + 1 | |
- self.current_mask.matrix[1:, 1:, n] = b_mask | |
- self.current_mask.matrix[0, 0, n] = 1 | |
+ if b_mask: | |
+ n = self.buffer_slices["SAGITAL"].index + 1 | |
+ self.current_mask.matrix[1:, 1:, n] = b_mask | |
+ self.current_mask.matrix[0, 0, n] = 1 | |
if to_reload: | |
Publisher.sendMessage('Reload actual slice') | |
@@ -882,8 +885,8 @@ class Slice(object): | |
self.current_mask.matrix[n+1, 1:, 1:] = m | |
else: | |
slice_ = self.buffer_slices[orientation].image | |
- print ">>>", slice_, index | |
- self.buffer_slices[orientation].mask = (255 * ((slice_ >= thresh_min) & (slice_ <= thresh_max))).astype('uint8') | |
+ if slice_: | |
+ self.buffer_slices[orientation].mask = (255 * ((slice_ >= thresh_min) & (slice_ <= thresh_max))).astype('uint8') | |
# Update viewer | |
#Publisher.sendMessage('Update slice viewer') | |
diff --git a/invesalius/data/vtk_utils.py b/invesalius/data/vtk_utils.py | |
index c24e224..84b1bd9 100644 | |
--- a/invesalius/data/vtk_utils.py | |
+++ b/invesalius/data/vtk_utils.py | |
@@ -44,7 +44,10 @@ def ShowProgress(number_of_filters = 1, | |
progress = [0] | |
last_obj_progress = [0] | |
if (dialog_type == "ProgressDialog"): | |
- dlg = ProgressDialog(100) | |
+ try: | |
+ dlg = ProgressDialog(100) | |
+ except wx._core.PyNoAppError: | |
+ return lambda obj, label: 0 | |
# when the pipeline is larger than 1, we have to consider this object | |
diff --git a/invesalius/gui/task_navigator.py b/invesalius/gui/task_navigator.py | |
index c939189..66a8a4b 100644 | |
--- a/invesalius/gui/task_navigator.py | |
+++ b/invesalius/gui/task_navigator.py | |
@@ -247,7 +247,7 @@ class NeuronavigationPanel(wx.Panel): | |
n = btns_img[k].keys()[0] | |
lab = btns_img[k].values()[0] | |
self.btns_coord[n] = wx.ToggleButton(self, k, label=lab, size=wx.Size(45, 23)) | |
- self.btns_coord[n].SetToolTip(tips_img[n]) | |
+ self.btns_coord[n].SetToolTip(wx.ToolTip(tips_img[n])) | |
self.btns_coord[n].Bind(wx.EVT_TOGGLEBUTTON, self.OnImageFiducials) | |
# Push buttons for tracker fiducials | |
@@ -258,7 +258,7 @@ class NeuronavigationPanel(wx.Panel): | |
n = btns_trk[k].keys()[0] | |
lab = btns_trk[k].values()[0] | |
self.btns_coord[n] = wx.Button(self, k, label=lab, size=wx.Size(45, 23)) | |
- self.btns_coord[n].SetToolTip(tips_trk[n-3]) | |
+ self.btns_coord[n].SetToolTip(wx.ToolTip(tips_trk[n-3])) | |
# Excepetion for event of button that set image coordinates | |
if n == 6: | |
self.btns_coord[n].Bind(wx.EVT_BUTTON, self.OnSetImageCoordinates) | |
@@ -798,4 +798,4 @@ class MarkersPanel(wx.Panel): | |
while len(selection) != self.lc.GetSelectedItemCount(): | |
index = self.lc.GetNextSelected(index) | |
selection.append(index) | |
- return selection | |
\ No newline at end of file | |
+ return selection |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment