Commit 8d6196a1d8ffdd67c545caf11f62d1ac518e49d8
Committed by
GitHub
1 parent
37109ae4
Exists in
master
and in
17 other branches
ENH: Code restructuring, "invesalius.py" now "app.py" (#55)
ENH: Code restructuring, invesalius.py is now app.py
Showing
50 changed files
with
710 additions
and
805 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,327 @@ |
| 1 | +#!/usr/bin/python | |
| 2 | +#-------------------------------------------------------------------------- | |
| 3 | +# Software: InVesalius - Software de Reconstrucao 3D de Imagens Medicas | |
| 4 | +# Copyright: (C) 2001 Centro de Pesquisas Renato Archer | |
| 5 | +# Homepage: http://www.softwarepublico.gov.br | |
| 6 | +# Contact: invesalius@cti.gov.br | |
| 7 | +# License: GNU - GPL 2 (LICENSE.txt/LICENCA.txt) | |
| 8 | +#-------------------------------------------------------------------------- | |
| 9 | +# Este programa e software livre; voce pode redistribui-lo e/ou | |
| 10 | +# modifica-lo sob os termos da Licenca Publica Geral GNU, conforme | |
| 11 | +# publicada pela Free Software Foundation; de acordo com a versao 2 | |
| 12 | +# da Licenca. | |
| 13 | +# | |
| 14 | +# Este programa eh distribuido na expectativa de ser util, mas SEM | |
| 15 | +# QUALQUER GARANTIA; sem mesmo a garantia implicita de | |
| 16 | +# COMERCIALIZACAO ou de ADEQUACAO A QUALQUER PROPOSITO EM | |
| 17 | +# PARTICULAR. Consulte a Licenca Publica Geral GNU para obter mais | |
| 18 | +# detalhes. | |
| 19 | +#------------------------------------------------------------------------- | |
| 20 | + | |
| 21 | + | |
| 22 | +import multiprocessing | |
| 23 | +import optparse as op | |
| 24 | +import os | |
| 25 | +import sys | |
| 26 | +import shutil | |
| 27 | + | |
| 28 | +if sys.platform == 'win32': | |
| 29 | + import _winreg | |
| 30 | +else: | |
| 31 | + if sys.platform != 'darwin': | |
| 32 | + import wxversion | |
| 33 | + #wxversion.ensureMinimal('2.8-unicode', optionsRequired=True) | |
| 34 | + #wxversion.select('2.8-unicode', optionsRequired=True) | |
| 35 | + wxversion.ensureMinimal('3.0') | |
| 36 | + | |
| 37 | +import wx | |
| 38 | +#from wx.lib.pubsub import setupv1 #new wx | |
| 39 | +from wx.lib.pubsub import setuparg1# as psv1 | |
| 40 | +#from wx.lib.pubsub import Publisher | |
| 41 | +#import wx.lib.pubsub as ps | |
| 42 | +from wx.lib.pubsub import pub as Publisher | |
| 43 | + | |
| 44 | +#import wx.lib.agw.advancedsplash as agw | |
| 45 | +#if sys.platform == 'linux2': | |
| 46 | +# _SplashScreen = agw.AdvancedSplash | |
| 47 | +#else: | |
| 48 | +# if sys.platform != 'darwin': | |
| 49 | +# _SplashScreen = wx.SplashScreen | |
| 50 | + | |
| 51 | + | |
| 52 | +import invesalius.gui.language_dialog as lang_dlg | |
| 53 | +import invesalius.i18n as i18n | |
| 54 | +import invesalius.session as ses | |
| 55 | +import invesalius.utils as utils | |
| 56 | + | |
| 57 | +# ------------------------------------------------------------------ | |
| 58 | + | |
| 59 | + | |
| 60 | +class InVesalius(wx.App): | |
| 61 | + """ | |
| 62 | + InVesalius wxPython application class. | |
| 63 | + """ | |
| 64 | + def OnInit(self): | |
| 65 | + """ | |
| 66 | + Initialize splash screen and main frame. | |
| 67 | + """ | |
| 68 | + self.SetAppName("InVesalius 3") | |
| 69 | + self.splash = SplashScreen() | |
| 70 | + self.splash.Show() | |
| 71 | + wx.CallLater(1000,self.Startup2) | |
| 72 | + | |
| 73 | + return True | |
| 74 | + | |
| 75 | + def MacOpenFile(self, filename): | |
| 76 | + """ | |
| 77 | + Open drag & drop files under darwin | |
| 78 | + """ | |
| 79 | + path = os.path.abspath(filename) | |
| 80 | + Publisher.sendMessage('Open project', path) | |
| 81 | + | |
| 82 | + def Startup2(self): | |
| 83 | + self.control = self.splash.control | |
| 84 | + self.frame = self.splash.main | |
| 85 | + self.SetTopWindow(self.frame) | |
| 86 | + self.frame.Show() | |
| 87 | + self.frame.Raise() | |
| 88 | + | |
| 89 | +# ------------------------------------------------------------------ | |
| 90 | + | |
| 91 | +class SplashScreen(wx.SplashScreen): | |
| 92 | + """ | |
| 93 | + Splash screen to be shown in InVesalius initialization. | |
| 94 | + """ | |
| 95 | + def __init__(self): | |
| 96 | + # Splash screen image will depend on currently language | |
| 97 | + lang = False | |
| 98 | + | |
| 99 | + # Language information is available in session configuration | |
| 100 | + # file. First we need to check if this file exist, if now, it | |
| 101 | + # should be created | |
| 102 | + create_session = False | |
| 103 | + session = ses.Session() | |
| 104 | + if not (session.ReadSession()): | |
| 105 | + create_session = True | |
| 106 | + | |
| 107 | + install_lang = 0 | |
| 108 | + # Check if there is a language set (if session file exists | |
| 109 | + if session.ReadLanguage(): | |
| 110 | + lang = session.GetLanguage() | |
| 111 | + if (lang != "False"): | |
| 112 | + _ = i18n.InstallLanguage(lang) | |
| 113 | + install_lang = 1 | |
| 114 | + else: | |
| 115 | + install_lang = 0 | |
| 116 | + else: | |
| 117 | + install_lang = 0 | |
| 118 | + | |
| 119 | + # If no language is set into session file, show dialog so | |
| 120 | + # user can select language | |
| 121 | + if install_lang == 0: | |
| 122 | + dialog = lang_dlg.LanguageDialog() | |
| 123 | + | |
| 124 | + # FIXME: This works ok in linux2, darwin and win32, | |
| 125 | + # except on win64, due to wxWidgets bug | |
| 126 | + try: | |
| 127 | + ok = (dialog.ShowModal() == wx.ID_OK) | |
| 128 | + except wx._core.PyAssertionError: | |
| 129 | + ok = True | |
| 130 | + finally: | |
| 131 | + if ok: | |
| 132 | + lang = dialog.GetSelectedLanguage() | |
| 133 | + session.SetLanguage(lang) | |
| 134 | + _ = i18n.InstallLanguage(lang) | |
| 135 | + else: | |
| 136 | + homedir = self.homedir = os.path.expanduser('~') | |
| 137 | + invdir = os.path.join(homedir, ".invesalius") | |
| 138 | + shutil.rmtree(invdir) | |
| 139 | + sys.exit() | |
| 140 | + | |
| 141 | + # Session file should be created... So we set the recent | |
| 142 | + # choosen language | |
| 143 | + if (create_session): | |
| 144 | + session.CreateItens() | |
| 145 | + session.SetLanguage(lang) | |
| 146 | + session.WriteSessionFile() | |
| 147 | + | |
| 148 | + session.SaveConfigFileBackup() | |
| 149 | + | |
| 150 | + | |
| 151 | + # Only after language was defined, splash screen will be | |
| 152 | + # shown | |
| 153 | + if lang: | |
| 154 | + # For pt_BR, splash_pt.png should be used | |
| 155 | + if (lang.startswith('pt')): | |
| 156 | + icon_file = "splash_pt.png" | |
| 157 | + else: | |
| 158 | + icon_file = "splash_" + lang + ".png" | |
| 159 | + | |
| 160 | + if hasattr(sys,"frozen") and (sys.frozen == "windows_exe"\ | |
| 161 | + or sys.frozen == "console_exe"): | |
| 162 | + abs_file_path = os.path.abspath(".." + os.sep) | |
| 163 | + path = abs_file_path | |
| 164 | + | |
| 165 | + path = os.path.join(path, "icons", icon_file) | |
| 166 | + else: | |
| 167 | + | |
| 168 | + path = os.path.join(".","icons", icon_file) | |
| 169 | + if not os.path.exists(path): | |
| 170 | + path = os.path.join(".", "icons", "splash_en.png") | |
| 171 | + | |
| 172 | + bmp = wx.Image(path).ConvertToBitmap() | |
| 173 | + | |
| 174 | + style = wx.SPLASH_TIMEOUT | wx.SPLASH_CENTRE_ON_SCREEN | |
| 175 | + wx.SplashScreen.__init__(self, | |
| 176 | + bitmap=bmp, | |
| 177 | + splashStyle=style, | |
| 178 | + milliseconds=1500, | |
| 179 | + id=-1, | |
| 180 | + parent=None) | |
| 181 | + self.Bind(wx.EVT_CLOSE, self.OnClose) | |
| 182 | + wx.Yield() | |
| 183 | + wx.CallLater(200,self.Startup) | |
| 184 | + | |
| 185 | + def Startup(self): | |
| 186 | + # Importing takes sometime, therefore it will be done | |
| 187 | + # while splash is being shown | |
| 188 | + from invesalius.gui.frame import Frame | |
| 189 | + from invesalius.control import Controller | |
| 190 | + from invesalius.project import Project | |
| 191 | + | |
| 192 | + self.main = Frame(None) | |
| 193 | + self.control = Controller(self.main) | |
| 194 | + | |
| 195 | + self.fc = wx.FutureCall(1, self.ShowMain) | |
| 196 | + wx.FutureCall(1, parse_comand_line) | |
| 197 | + | |
| 198 | + # Check for updates | |
| 199 | + from threading import Thread | |
| 200 | + p = Thread(target=utils.UpdateCheck, args=()) | |
| 201 | + p.start() | |
| 202 | + | |
| 203 | + def OnClose(self, evt): | |
| 204 | + # Make sure the default handler runs too so this window gets | |
| 205 | + # destroyed | |
| 206 | + evt.Skip() | |
| 207 | + self.Hide() | |
| 208 | + | |
| 209 | + # If the timer is still running then go ahead and show the | |
| 210 | + # main frame now | |
| 211 | + if self.fc.IsRunning(): | |
| 212 | + self.fc.Stop() | |
| 213 | + self.ShowMain() | |
| 214 | + | |
| 215 | + def ShowMain(self): | |
| 216 | + # Show main frame | |
| 217 | + self.main.Show() | |
| 218 | + | |
| 219 | + if self.fc.IsRunning(): | |
| 220 | + self.Raise() | |
| 221 | + | |
| 222 | +# ------------------------------------------------------------------ | |
| 223 | + | |
| 224 | + | |
| 225 | +def parse_comand_line(): | |
| 226 | + """ | |
| 227 | + Handle command line arguments. | |
| 228 | + """ | |
| 229 | + session = ses.Session() | |
| 230 | + | |
| 231 | + # Parse command line arguments | |
| 232 | + parser = op.OptionParser() | |
| 233 | + | |
| 234 | + # -d or --debug: print all pubsub messagessent | |
| 235 | + parser.add_option("-d", "--debug", | |
| 236 | + action="store_true", | |
| 237 | + dest="debug") | |
| 238 | + | |
| 239 | + # -i or --import: import DICOM directory | |
| 240 | + # chooses largest series | |
| 241 | + parser.add_option("-i", "--import", | |
| 242 | + action="store", | |
| 243 | + dest="dicom_dir") | |
| 244 | + options, args = parser.parse_args() | |
| 245 | + | |
| 246 | + # If debug argument... | |
| 247 | + if options.debug: | |
| 248 | + Publisher.subscribe(print_events, Publisher.ALL_TOPICS) | |
| 249 | + session.debug = 1 | |
| 250 | + | |
| 251 | + # If import DICOM argument... | |
| 252 | + if options.dicom_dir: | |
| 253 | + import_dir = options.dicom_dir | |
| 254 | + Publisher.sendMessage('Import directory', import_dir) | |
| 255 | + return True | |
| 256 | + | |
| 257 | + # Check if there is a file path somewhere in what the user wrote | |
| 258 | + # In case there is, try opening as it was a inv3 | |
| 259 | + else: | |
| 260 | + i = len(args) | |
| 261 | + while i: | |
| 262 | + i -= 1 | |
| 263 | + file = args[i] | |
| 264 | + if os.path.isfile(file): | |
| 265 | + path = os.path.abspath(file) | |
| 266 | + Publisher.sendMessage('Open project', path) | |
| 267 | + i = 0 | |
| 268 | + return True | |
| 269 | + return False | |
| 270 | + | |
| 271 | + | |
| 272 | +def print_events(data): | |
| 273 | + """ | |
| 274 | + Print pubsub messages | |
| 275 | + """ | |
| 276 | + utils.debug(data.topic) | |
| 277 | + | |
| 278 | +def main(): | |
| 279 | + """ | |
| 280 | + Initialize InVesalius GUI | |
| 281 | + """ | |
| 282 | + application = InVesalius(0) | |
| 283 | + application.MainLoop() | |
| 284 | + | |
| 285 | +if __name__ == '__main__': | |
| 286 | + # Needed in win 32 exe | |
| 287 | + if hasattr(sys,"frozen") and (sys.frozen == "windows_exe"\ | |
| 288 | + or sys.frozen == "console_exe"): | |
| 289 | + multiprocessing.freeze_support() | |
| 290 | + | |
| 291 | + #Click in the .inv3 file support | |
| 292 | + root = _winreg.HKEY_CLASSES_ROOT | |
| 293 | + key = "InVesalius 3.0\InstallationDir" | |
| 294 | + hKey = _winreg.OpenKey (root, key, 0, _winreg.KEY_READ) | |
| 295 | + value, type_ = _winreg.QueryValueEx (hKey, "") | |
| 296 | + path = os.path.join(value,'dist') | |
| 297 | + | |
| 298 | + os.chdir(path) | |
| 299 | + | |
| 300 | + # Create raycasting presets' folder, if it doens't exist | |
| 301 | + dirpath = os.path.join(os.path.expanduser('~'), | |
| 302 | + ".invesalius", | |
| 303 | + "presets") | |
| 304 | + if not os.path.isdir(dirpath): | |
| 305 | + os.makedirs(dirpath) | |
| 306 | + | |
| 307 | + # Create logs' folder, if it doesn't exist | |
| 308 | + dirpath = os.path.join(os.path.expanduser('~'), | |
| 309 | + ".invesalius", | |
| 310 | + "logs") | |
| 311 | + if not os.path.isdir(dirpath): | |
| 312 | + os.makedirs(dirpath) | |
| 313 | + | |
| 314 | + if hasattr(sys,"frozen") and sys.frozen == "windows_exe": | |
| 315 | + # Set system standard error output to file | |
| 316 | + path = os.path.join(dirpath, "stderr.log") | |
| 317 | + sys.stderr = open(path, "w") | |
| 318 | + | |
| 319 | + # Add current directory to PYTHONPATH, so other classes can | |
| 320 | + # import modules as they were on root invesalius folder | |
| 321 | + sys.path.insert(0, '.') | |
| 322 | + sys.path.append(".") | |
| 323 | + | |
| 324 | + | |
| 325 | + # Init application | |
| 326 | + main() | |
| 327 | + | ... | ... |
invesalius/constants.py
| ... | ... | @@ -23,8 +23,7 @@ import sys |
| 23 | 23 | import wx |
| 24 | 24 | import itertools |
| 25 | 25 | |
| 26 | -from project import Project | |
| 27 | - | |
| 26 | +#from invesalius.project import Project | |
| 28 | 27 | INVESALIUS_VERSION = "3.0" |
| 29 | 28 | |
| 30 | 29 | #--------------- |
| ... | ... | @@ -208,8 +207,10 @@ VOLUME_POSITION = {AXIAL: [AXIAL_VOLUME_CAM_VIEW_UP, AXIAL_VOLUME_CAM_POSITION], |
| 208 | 207 | |
| 209 | 208 | |
| 210 | 209 | # Mask threshold options |
| 211 | -proj = Project() | |
| 212 | -THRESHOLD_RANGE = proj.threshold_modes[_("Bone")] | |
| 210 | + | |
| 211 | +#proj = Project() | |
| 212 | +#THRESHOLD_RANGE = proj.threshold_modes[_("Bone")] | |
| 213 | +THRESHOLD_RANGE = [0,3033] | |
| 213 | 214 | THRESHOLD_PRESETS_INDEX = _("Bone") |
| 214 | 215 | THRESHOLD_HUE_RANGE = (0, 0.6667) |
| 215 | 216 | THRESHOLD_INVALUE = 5000 |
| ... | ... | @@ -319,9 +320,25 @@ WINDOW_LEVEL = {_("Abdomen"):(350,50), |
| 319 | 320 | |
| 320 | 321 | REDUCE_IMAGEDATA_QUALITY = 0 |
| 321 | 322 | |
| 322 | -ICON_DIR = os.path.abspath(os.path.join('..', 'icons')) | |
| 323 | -SAMPLE_DIR = os.path.abspath(os.path.join('..', 'samples')) | |
| 324 | -DOC_DIR = os.path.abspath(os.path.join('..', 'docs')) | |
| 323 | +FILE_PATH = os.path.split(__file__)[0] | |
| 324 | + | |
| 325 | +if hasattr(sys,"frozen") and (sys.frozen == "windows_exe"\ | |
| 326 | + or sys.frozen == "console_exe"): | |
| 327 | + abs_path_icon = os.path.abspath(FILE_PATH + os.sep + ".." + os.sep + ".." + os.sep + "..") | |
| 328 | + ICON_DIR = os.path.join(abs_path_icon, "icons") | |
| 329 | + SAMPLE_DIR = os.path.join(FILE_PATH, 'samples') | |
| 330 | + DOC_DIR = os.path.join(FILE_PATH, 'docs') | |
| 331 | +else: | |
| 332 | + ICON_DIR = os.path.abspath(os.path.join(FILE_PATH, '..', 'icons')) | |
| 333 | + SAMPLE_DIR = os.path.abspath(os.path.join(FILE_PATH,'..', 'samples')) | |
| 334 | + DOC_DIR = os.path.abspath(os.path.join(FILE_PATH,'..', 'docs')) | |
| 335 | + | |
| 336 | + | |
| 337 | +# MAC App | |
| 338 | +if not os.path.exists(ICON_DIR): | |
| 339 | + ICON_DIR = os.path.abspath(os.path.join(FILE_PATH, '..', '..', '..', '..', 'icons')) | |
| 340 | + SAMPLE_DIR = os.path.abspath(os.path.join(FILE_PATH,'..', '..', '..', '..', 'samples')) | |
| 341 | + DOC_DIR = os.path.abspath(os.path.join(FILE_PATH,'..', '..', '..', '..', 'docs')) | |
| 325 | 342 | |
| 326 | 343 | |
| 327 | 344 | ID_TO_BMP = {VOL_FRONT: [_("Front"), os.path.join(ICON_DIR, "view_front.png")], |
| ... | ... | @@ -336,7 +353,7 @@ ID_TO_BMP = {VOL_FRONT: [_("Front"), os.path.join(ICON_DIR, "view_front.png")], |
| 336 | 353 | # if 1, use vtkVolumeRaycastMapper, if 0, use vtkFixedPointVolumeRayCastMapper |
| 337 | 354 | TYPE_RAYCASTING_MAPPER = 0 |
| 338 | 355 | |
| 339 | -folder=RAYCASTING_PRESETS_DIRECTORY= os.path.abspath(os.path.join("..", | |
| 356 | +folder=RAYCASTING_PRESETS_DIRECTORY= os.path.abspath(os.path.join(".", | |
| 340 | 357 | "presets", |
| 341 | 358 | "raycasting")) |
| 342 | 359 | ... | ... |
invesalius/control.py
| ... | ... | @@ -23,24 +23,24 @@ import wx |
| 23 | 23 | import numpy |
| 24 | 24 | from wx.lib.pubsub import pub as Publisher |
| 25 | 25 | |
| 26 | -import constants as const | |
| 27 | -import data.imagedata_utils as image_utils | |
| 28 | -import data.mask as msk | |
| 29 | -import data.measures | |
| 30 | -import data.slice_ as sl | |
| 31 | -import data.surface as srf | |
| 32 | -import data.volume as volume | |
| 33 | -import gui.dialogs as dialog | |
| 34 | -import project as prj | |
| 35 | -import reader.analyze_reader as analyze | |
| 36 | -import reader.dicom_grouper as dg | |
| 37 | -import reader.dicom_reader as dcm | |
| 38 | -import reader.bitmap_reader as bmp | |
| 39 | -import session as ses | |
| 40 | - | |
| 41 | - | |
| 42 | -import utils | |
| 43 | -import gui.dialogs as dialogs | |
| 26 | +import invesalius.constants as const | |
| 27 | +import invesalius.data.imagedata_utils as image_utils | |
| 28 | +import invesalius.data.mask as msk | |
| 29 | +import invesalius.data.measures as measures | |
| 30 | +import invesalius.data.slice_ as sl | |
| 31 | +import invesalius.data.surface as srf | |
| 32 | +import invesalius.data.volume as volume | |
| 33 | +import invesalius.gui.dialogs as dialog | |
| 34 | +import invesalius.project as prj | |
| 35 | +import invesalius.reader.analyze_reader as analyze | |
| 36 | +import invesalius.reader.dicom_grouper as dg | |
| 37 | +import invesalius.reader.dicom_reader as dcm | |
| 38 | +import invesalius.reader.bitmap_reader as bmp | |
| 39 | +import invesalius.session as ses | |
| 40 | + | |
| 41 | + | |
| 42 | +import invesalius.utils as utils | |
| 43 | +import invesalius.gui.dialogs as dialogs | |
| 44 | 44 | import subprocess |
| 45 | 45 | import sys |
| 46 | 46 | |
| ... | ... | @@ -57,7 +57,7 @@ class Controller(): |
| 57 | 57 | self.cancel_import = False |
| 58 | 58 | #Init session |
| 59 | 59 | session = ses.Session() |
| 60 | - self.measure_manager = data.measures.MeasurementManager() | |
| 60 | + self.measure_manager = measures.MeasurementManager() | |
| 61 | 61 | |
| 62 | 62 | Publisher.sendMessage('Load Preferences') |
| 63 | 63 | |
| ... | ... | @@ -376,8 +376,8 @@ class Controller(): |
| 376 | 376 | data = evt.data |
| 377 | 377 | ok = self.LoadImportBitmapPanel(data) |
| 378 | 378 | if ok: |
| 379 | - Publisher.sendMessage('Show import bitmap panel in frame') | |
| 380 | - #Publisher.sendMessage("Show import panel in frame") | |
| 379 | + Publisher.sendMessage('Show import bitmap panel in frame') | |
| 380 | + #Publisher.sendMessage("Show import panel in invesalius.gui.frame") as frame | |
| 381 | 381 | |
| 382 | 382 | def LoadImportBitmapPanel(self, data): |
| 383 | 383 | #if patient_series and isinstance(patient_series, list): |
| ... | ... | @@ -435,6 +435,7 @@ class Controller(): |
| 435 | 435 | |
| 436 | 436 | const.THRESHOLD_OUTVALUE = proj.threshold_range[0] |
| 437 | 437 | const.THRESHOLD_INVALUE = proj.threshold_range[1] |
| 438 | + const.THRESHOLD_RANGE = proj.threshold_modes[_("Bone")] | |
| 438 | 439 | |
| 439 | 440 | const.WINDOW_LEVEL[_('Default')] = (proj.window, proj.level) |
| 440 | 441 | const.WINDOW_LEVEL[_('Manual')] = (proj.window, proj.level) | ... | ... |
invesalius/data/cursor_actors.py
| ... | ... | @@ -21,9 +21,9 @@ import math |
| 21 | 21 | |
| 22 | 22 | import numpy |
| 23 | 23 | import vtk |
| 24 | -import imagedata_utils | |
| 25 | -from project import Project | |
| 26 | -import constants as const | |
| 24 | +import invesalius.data.imagedata_utils as imagedata_utils | |
| 25 | +from invesalius.project import Project as project | |
| 26 | +import invesalius.constants as const | |
| 27 | 27 | |
| 28 | 28 | from vtk.util import numpy_support |
| 29 | 29 | |
| ... | ... | @@ -241,7 +241,6 @@ class CursorCircle(CursorBase): |
| 241 | 241 | """ |
| 242 | 242 | Function to plot the circle |
| 243 | 243 | """ |
| 244 | - print "Building circle cursor", self.orientation | |
| 245 | 244 | r = self.radius |
| 246 | 245 | sx, sy, sz = self.spacing |
| 247 | 246 | if self.orientation == 'AXIAL': |
| ... | ... | @@ -284,12 +283,6 @@ class CursorCircle(CursorBase): |
| 284 | 283 | |
| 285 | 284 | self.mapper.SetOrientation(ORIENTATION[self.orientation]) |
| 286 | 285 | |
| 287 | - print '====================================' | |
| 288 | - print self.orientation | |
| 289 | - print circle_ci.GetSpacing() | |
| 290 | - print xi, xf, yi, yf, zi, zf | |
| 291 | - print '====================================' | |
| 292 | - | |
| 293 | 286 | def _calculate_area_pixels(self): |
| 294 | 287 | """ |
| 295 | 288 | Return the cursor's pixels. | ... | ... |
invesalius/data/geometry.py
invesalius/data/imagedata_utils.py
| ... | ... | @@ -30,12 +30,11 @@ from wx.lib.pubsub import pub as Publisher |
| 30 | 30 | from scipy.ndimage import shift |
| 31 | 31 | from vtk.util import numpy_support |
| 32 | 32 | |
| 33 | -import constants as const | |
| 34 | -from data import vtk_utils | |
| 35 | -from reader import bitmap_reader | |
| 36 | -import utils | |
| 37 | -import converters | |
| 38 | - | |
| 33 | +import invesalius.constants as const | |
| 34 | +from invesalius.data import vtk_utils as vtk_utils | |
| 35 | +import invesalius.reader.bitmap_reader as bitmap_reader | |
| 36 | +import invesalius.utils as utils | |
| 37 | +import invesalius.data.converters as converters | |
| 39 | 38 | # TODO: Test cases which are originally in sagittal/coronal orientation |
| 40 | 39 | # and have gantry |
| 41 | 40 | ... | ... |
invesalius/data/mask.py
| ... | ... | @@ -26,9 +26,9 @@ import tempfile |
| 26 | 26 | import numpy |
| 27 | 27 | import vtk |
| 28 | 28 | |
| 29 | -import constants as const | |
| 30 | -import imagedata_utils as iu | |
| 31 | -import session as ses | |
| 29 | +import invesalius.constants as const | |
| 30 | +import invesalius.data.imagedata_utils as iu | |
| 31 | +import invesalius.session as ses | |
| 32 | 32 | |
| 33 | 33 | from wx.lib.pubsub import pub as Publisher |
| 34 | 34 | |
| ... | ... | @@ -110,9 +110,6 @@ class EditionHistory(object): |
| 110 | 110 | #self._reload_slice(self.index - 1) |
| 111 | 111 | if h[self.index - 1].orientation == 'VOLUME': |
| 112 | 112 | self.index -= 1 |
| 113 | - print "================================" | |
| 114 | - print mvolume.shape | |
| 115 | - print "================================" | |
| 116 | 113 | h[self.index].commit_history(mvolume) |
| 117 | 114 | self._reload_slice(self.index) |
| 118 | 115 | Publisher.sendMessage("Enable redo", True) | ... | ... |
invesalius/data/measures.py
| ... | ... | @@ -10,11 +10,10 @@ from wx.lib.pubsub import pub as Publisher |
| 10 | 10 | import numpy as np |
| 11 | 11 | import vtk |
| 12 | 12 | |
| 13 | -import constants as const | |
| 14 | -import project as prj | |
| 15 | -import session as ses | |
| 16 | -import utils | |
| 17 | - | |
| 13 | +import invesalius.constants as const | |
| 14 | +import invesalius.project as prj | |
| 15 | +import invesalius.session as ses | |
| 16 | +import invesalius.utils as utils | |
| 18 | 17 | TYPE = {const.LINEAR: _(u"Linear"), |
| 19 | 18 | const.ANGULAR: _(u"Angular"), |
| 20 | 19 | } | ... | ... |
invesalius/data/polydata_utils.py
invesalius/data/slice_.py
| ... | ... | @@ -23,20 +23,18 @@ import numpy as np |
| 23 | 23 | import vtk |
| 24 | 24 | from wx.lib.pubsub import pub as Publisher |
| 25 | 25 | |
| 26 | -import constants as const | |
| 27 | -import converters | |
| 28 | -import imagedata_utils as iu | |
| 29 | -import style as st | |
| 30 | -import session as ses | |
| 31 | -import utils | |
| 32 | - | |
| 33 | -from mask import Mask | |
| 34 | -from project import Project | |
| 35 | -from data import mips | |
| 36 | - | |
| 37 | -from data import transforms | |
| 38 | -import transformations | |
| 39 | - | |
| 26 | +import invesalius.constants as const | |
| 27 | +import invesalius.data.converters as converters | |
| 28 | +import invesalius.data.imagedata_utils as iu | |
| 29 | +import invesalius.style as st | |
| 30 | +import invesalius.session as ses | |
| 31 | +import invesalius.utils as utils | |
| 32 | +from invesalius.data.mask import Mask | |
| 33 | +from invesalius.project import Project | |
| 34 | +from invesalius.data import mips | |
| 35 | + | |
| 36 | +from invesalius.data import transforms | |
| 37 | +import invesalius.data.transformations as transformations | |
| 40 | 38 | OTHER=0 |
| 41 | 39 | PLIST=1 |
| 42 | 40 | WIDGET=2 |
| ... | ... | @@ -386,7 +384,6 @@ class Slice(object): |
| 386 | 384 | def __show_mask(self, pubsub_evt): |
| 387 | 385 | # "if" is necessary because wx events are calling this before any mask |
| 388 | 386 | # has been created |
| 389 | - print "__show_mask" | |
| 390 | 387 | if self.current_mask: |
| 391 | 388 | index, value = pubsub_evt.data |
| 392 | 389 | self.ShowMask(index, value) |
| ... | ... | @@ -889,7 +886,6 @@ class Slice(object): |
| 889 | 886 | |
| 890 | 887 | def ShowMask(self, index, value): |
| 891 | 888 | "Show a mask given its index and 'show' value (0: hide, other: show)" |
| 892 | - print "Showing Mask" | |
| 893 | 889 | proj = Project() |
| 894 | 890 | proj.mask_dict[index].is_shown = value |
| 895 | 891 | proj.mask_dict[index].on_show() | ... | ... |
invesalius/data/slice_data.py
| ... | ... | @@ -18,8 +18,8 @@ |
| 18 | 18 | #-------------------------------------------------------------------------- |
| 19 | 19 | import vtk |
| 20 | 20 | |
| 21 | -import constants as const | |
| 22 | -import vtk_utils as vu | |
| 21 | +import invesalius.constants as const | |
| 22 | +import invesalius.data.vtk_utils as vu | |
| 23 | 23 | |
| 24 | 24 | BORDER_UP = 1 |
| 25 | 25 | BORDER_DOWN = 2 | ... | ... |
invesalius/data/styles.py
| ... | ... | @@ -30,10 +30,10 @@ import wx |
| 30 | 30 | |
| 31 | 31 | from wx.lib.pubsub import pub as Publisher |
| 32 | 32 | |
| 33 | -import constants as const | |
| 34 | -import converters | |
| 35 | -import cursor_actors as ca | |
| 36 | -import session as ses | |
| 33 | +import invesalius.constants as const | |
| 34 | +import invesalius.data.converters as converters | |
| 35 | +import invesalius.data.cursor_actors as ca | |
| 36 | +import invesalius.session as ses | |
| 37 | 37 | |
| 38 | 38 | import numpy as np |
| 39 | 39 | |
| ... | ... | @@ -43,16 +43,15 @@ from scipy.ndimage import watershed_ift, generate_binary_structure |
| 43 | 43 | from skimage.morphology import watershed |
| 44 | 44 | from skimage import filter |
| 45 | 45 | |
| 46 | -from gui import dialogs | |
| 47 | -from .measures import MeasureData | |
| 46 | +import invesalius.gui.dialogs as dialogs | |
| 47 | +from invesalius.data.measures import MeasureData | |
| 48 | 48 | |
| 49 | 49 | from . import floodfill |
| 50 | 50 | |
| 51 | -import watershed_process | |
| 52 | - | |
| 53 | -import utils | |
| 54 | -import transformations | |
| 55 | -import geometry as geom | |
| 51 | +import invesalius.data.watershed_process as watershed_process | |
| 52 | +import invesalius.utils as utils | |
| 53 | +import invesalius.data.transformations as transformations | |
| 54 | +import invesalius.data.geometry as geom | |
| 56 | 55 | |
| 57 | 56 | ORIENTATIONS = { |
| 58 | 57 | "AXIAL": const.AXIAL, |
| ... | ... | @@ -1895,7 +1894,7 @@ class SelectMaskPartsInteractorStyle(DefaultInteractorStyle): |
| 1895 | 1894 | |
| 1896 | 1895 | def SetUp(self): |
| 1897 | 1896 | if not self.config.dlg_visible: |
| 1898 | - import data.mask as mask | |
| 1897 | + import invesalius.data.mask as mask | |
| 1899 | 1898 | default_name = const.MASK_NAME_PATTERN %(mask.Mask.general_index+2) |
| 1900 | 1899 | |
| 1901 | 1900 | self.config.mask_name = default_name | ... | ... |
invesalius/data/surface.py
| ... | ... | @@ -28,14 +28,14 @@ import vtk |
| 28 | 28 | import wx |
| 29 | 29 | from wx.lib.pubsub import pub as Publisher |
| 30 | 30 | |
| 31 | -import constants as const | |
| 32 | -import imagedata_utils as iu | |
| 33 | -import polydata_utils as pu | |
| 34 | -import project as prj | |
| 35 | -import session as ses | |
| 36 | -import surface_process | |
| 37 | -import utils as utl | |
| 38 | -import vtk_utils as vu | |
| 31 | +import invesalius.constants as const | |
| 32 | +import invesalius.data.imagedata_utils as iu | |
| 33 | +import invesalius.data.polydata_utils as pu | |
| 34 | +import invesalius.project as prj | |
| 35 | +import invesalius.session as ses | |
| 36 | +import invesalius.data.surface_process as surface_process | |
| 37 | +import invesalius.utils as utl | |
| 38 | +import invesalius.data.vtk_utils as vu | |
| 39 | 39 | |
| 40 | 40 | try: |
| 41 | 41 | import ca_smoothing | ... | ... |
invesalius/data/surface_process.py
| ... | ... | @@ -5,9 +5,9 @@ import time |
| 5 | 5 | import numpy |
| 6 | 6 | import vtk |
| 7 | 7 | |
| 8 | -import i18n | |
| 9 | -import converters | |
| 10 | -# import imagedata_utils as iu | |
| 8 | +import invesalius.i18n as i18n | |
| 9 | +import invesalius.data.converters as converters | |
| 10 | +# import invesalius.data.imagedata_utils as iu | |
| 11 | 11 | |
| 12 | 12 | from scipy import ndimage |
| 13 | 13 | ... | ... |
invesalius/data/viewer_slice.py
| ... | ... | @@ -28,8 +28,7 @@ import numpy as np |
| 28 | 28 | import vtk |
| 29 | 29 | from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor |
| 30 | 30 | |
| 31 | -import styles | |
| 32 | - | |
| 31 | +import invesalius.data.styles as styles | |
| 33 | 32 | import wx |
| 34 | 33 | import sys |
| 35 | 34 | from wx.lib.pubsub import pub as Publisher |
| ... | ... | @@ -39,17 +38,16 @@ try: |
| 39 | 38 | except ImportError: # if it's not there locally, try the wxPython lib. |
| 40 | 39 | import wx.lib.agw.floatspin as FS |
| 41 | 40 | |
| 42 | -import constants as const | |
| 43 | -import cursor_actors as ca | |
| 44 | -import data.slice_ as sl | |
| 45 | -import data.vtk_utils as vtku | |
| 46 | -import project | |
| 47 | -import slice_data as sd | |
| 48 | -import utils | |
| 49 | -import session as ses | |
| 50 | -from data import converters | |
| 51 | - | |
| 52 | -from data import measures | |
| 41 | +import invesalius.constants as const | |
| 42 | +import invesalius.data.cursor_actors as ca | |
| 43 | +import invesalius.data.slice_ as sl | |
| 44 | +import invesalius.data.vtk_utils as vtku | |
| 45 | +import invesalius.project as project | |
| 46 | +import invesalius.data.slice_data as sd | |
| 47 | +import invesalius.utils as utils | |
| 48 | +import invesalius.session as ses | |
| 49 | +import invesalius.data.converters as converters | |
| 50 | +import invesalius.data.measures as measures | |
| 53 | 51 | |
| 54 | 52 | ID_TO_TOOL_ITEM = {} |
| 55 | 53 | STR_WL = "WL: %d WW: %d" |
| ... | ... | @@ -1236,10 +1234,10 @@ class Viewer(wx.Panel): |
| 1236 | 1234 | self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZEWE)) |
| 1237 | 1235 | |
| 1238 | 1236 | def SetSizeNWSECursor(self, pubsub_evt): |
| 1239 | - if sys.platform == 'win32': | |
| 1240 | - self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZING)) | |
| 1241 | - else: | |
| 1237 | + if sys.platform == 'linux2': | |
| 1242 | 1238 | self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZENWSE)) |
| 1239 | + else: | |
| 1240 | + self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZING)) | |
| 1243 | 1241 | |
| 1244 | 1242 | def OnExportPicture(self, pubsub_evt): |
| 1245 | 1243 | Publisher.sendMessage('Begin busy cursor') | ... | ... |
invesalius/data/viewer_volume.py
| ... | ... | @@ -28,14 +28,13 @@ import vtk |
| 28 | 28 | from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor |
| 29 | 29 | from wx.lib.pubsub import pub as Publisher |
| 30 | 30 | |
| 31 | -import constants as const | |
| 32 | -import data.bases as bases | |
| 33 | -import data.vtk_utils as vtku | |
| 34 | -import project as prj | |
| 35 | -import style as st | |
| 36 | -import utils | |
| 37 | - | |
| 38 | -from data import measures | |
| 31 | +import invesalius.constants as const | |
| 32 | +import invesalius.data.bases as bases | |
| 33 | +import invesalius.data.vtk_utils as vtku | |
| 34 | +import invesalius.project as prj | |
| 35 | +import invesalius.style as st | |
| 36 | +import invesalius.utils as utils | |
| 37 | +import invesalius.data.measures as measures | |
| 39 | 38 | |
| 40 | 39 | PROP_MEASURE = 0.8 |
| 41 | 40 | ... | ... |
invesalius/data/volume.py
| ... | ... | @@ -25,13 +25,13 @@ import vtk |
| 25 | 25 | import wx |
| 26 | 26 | from wx.lib.pubsub import pub as Publisher |
| 27 | 27 | |
| 28 | -import constants as const | |
| 29 | -import project as prj | |
| 30 | -import slice_ | |
| 31 | -import converters | |
| 32 | -from data import vtk_utils | |
| 28 | +import invesalius.constants as const | |
| 29 | +import invesalius.project as prj | |
| 30 | +import invesalius.data.slice_ as slice_ | |
| 31 | +import invesalius.data.converters as converters | |
| 32 | +import invesalius.data.vtk_utils as vtk_utils | |
| 33 | 33 | from vtk.util import numpy_support |
| 34 | -import session as ses | |
| 34 | +import invesalius.session as ses | |
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | Kernels = { | ... | ... |
invesalius/data/vtk_utils.py
| ... | ... | @@ -20,9 +20,8 @@ import sys |
| 20 | 20 | |
| 21 | 21 | import vtk |
| 22 | 22 | from wx.lib.pubsub import pub as Publisher |
| 23 | - | |
| 24 | -import constants as const | |
| 25 | -from gui.dialogs import ProgressDialog | |
| 23 | +import invesalius.constants as const | |
| 24 | +from invesalius.gui.dialogs import ProgressDialog | |
| 26 | 25 | |
| 27 | 26 | # If you are frightened by the code bellow, or think it must have been result of |
| 28 | 27 | # an identation error, lookup at: | ... | ... |
invesalius/gui/bitmap_preview_panel.py
| ... | ... | @@ -8,11 +8,11 @@ from vtk.util import numpy_support |
| 8 | 8 | from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor |
| 9 | 9 | from wx.lib.pubsub import pub as Publisher |
| 10 | 10 | |
| 11 | -import constants as const | |
| 12 | -import data.vtk_utils as vtku | |
| 13 | -from data import converters | |
| 14 | -from reader import bitmap_reader | |
| 15 | -import utils | |
| 11 | +import invesalius.constants as const | |
| 12 | +import invesalius.data.vtk_utils as vtku | |
| 13 | +import invesalius.data.converters as converters | |
| 14 | +import invesalius.reader.bitmap_reader as bitmap_reader | |
| 15 | +import invesalius.utils as utils | |
| 16 | 16 | |
| 17 | 17 | NROWS = 3 |
| 18 | 18 | NCOLS = 6 | ... | ... |
invesalius/gui/data_notebook.py
| ... | ... | @@ -20,6 +20,7 @@ |
| 20 | 20 | #-------------------------------------------------------------------------- |
| 21 | 21 | import sys |
| 22 | 22 | import platform |
| 23 | +import os | |
| 23 | 24 | |
| 24 | 25 | try: |
| 25 | 26 | import Image |
| ... | ... | @@ -32,11 +33,11 @@ import wx.lib.flatnotebook as fnb |
| 32 | 33 | import wx.lib.platebtn as pbtn |
| 33 | 34 | from wx.lib.pubsub import pub as Publisher |
| 34 | 35 | |
| 35 | -import constants as const | |
| 36 | -import data.slice_ as slice_ | |
| 37 | -import gui.dialogs as dlg | |
| 38 | -import gui.widgets.listctrl as listmix | |
| 39 | -import utils as ul | |
| 36 | +import invesalius.constants as const | |
| 37 | +import invesalius.data.slice_ as slice_ | |
| 38 | +import invesalius.gui.dialogs as dlg | |
| 39 | +import invesalius.gui.widgets.listctrl as listmix | |
| 40 | +import invesalius.utils as ul | |
| 40 | 41 | |
| 41 | 42 | |
| 42 | 43 | BTN_NEW, BTN_REMOVE, BTN_DUPLICATE = [wx.NewId() for i in xrange(3)] |
| ... | ... | @@ -148,11 +149,11 @@ class MeasureButtonControlPanel(wx.Panel): |
| 148 | 149 | def __init_gui(self): |
| 149 | 150 | |
| 150 | 151 | # Bitmaps to be used in plate buttons |
| 151 | - BMP_NEW = wx.Bitmap("../icons/data_new.png", | |
| 152 | + BMP_NEW = wx.Bitmap(os.path.join(const.ICON_DIR, "data_new.png"), | |
| 152 | 153 | wx.BITMAP_TYPE_PNG) |
| 153 | - BMP_REMOVE = wx.Bitmap("../icons/data_remove.png", | |
| 154 | + BMP_REMOVE = wx.Bitmap(os.path.join(const.ICON_DIR, "data_remove.png"), | |
| 154 | 155 | wx.BITMAP_TYPE_PNG) |
| 155 | - BMP_DUPLICATE = wx.Bitmap("../icons/data_duplicate.png", | |
| 156 | + BMP_DUPLICATE = wx.Bitmap(os.path.join(const.ICON_DIR, "data_duplicate.png"), | |
| 156 | 157 | wx.BITMAP_TYPE_PNG) |
| 157 | 158 | |
| 158 | 159 | # Plate buttons based on previous bitmaps |
| ... | ... | @@ -261,11 +262,11 @@ class ButtonControlPanel(wx.Panel): |
| 261 | 262 | def __init_gui(self): |
| 262 | 263 | |
| 263 | 264 | # Bitmaps to be used in plate buttons |
| 264 | - BMP_NEW = wx.Bitmap("../icons/data_new.png", | |
| 265 | + BMP_NEW = wx.Bitmap(os.path.join(const.ICON_DIR, "data_new.png"), | |
| 265 | 266 | wx.BITMAP_TYPE_PNG) |
| 266 | - BMP_REMOVE = wx.Bitmap("../icons/data_remove.png", | |
| 267 | + BMP_REMOVE = wx.Bitmap(os.path.join(const.ICON_DIR, "data_remove.png"), | |
| 267 | 268 | wx.BITMAP_TYPE_PNG) |
| 268 | - BMP_DUPLICATE = wx.Bitmap("../icons/data_duplicate.png", | |
| 269 | + BMP_DUPLICATE = wx.Bitmap(os.path.join(const.ICON_DIR, "data_duplicate.png"), | |
| 269 | 270 | wx.BITMAP_TYPE_PNG) |
| 270 | 271 | |
| 271 | 272 | # Plate buttons based on previous bitmaps |
| ... | ... | @@ -452,13 +453,13 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
| 452 | 453 | def __init_image_list(self): |
| 453 | 454 | self.imagelist = wx.ImageList(16, 16) |
| 454 | 455 | |
| 455 | - image = wx.Image("../icons/object_invisible.jpg") | |
| 456 | + image = wx.Image(os.path.join(const.ICON_DIR, "object_invisible.jpg")) | |
| 456 | 457 | bitmap = wx.BitmapFromImage(image.Scale(16, 16)) |
| 457 | 458 | bitmap.SetWidth(16) |
| 458 | 459 | bitmap.SetHeight(16) |
| 459 | 460 | img_null = self.imagelist.Add(bitmap) |
| 460 | 461 | |
| 461 | - image = wx.Image("../icons/object_visible.jpg") | |
| 462 | + image = wx.Image(os.path.join(const.ICON_DIR, "object_visible.jpg")) | |
| 462 | 463 | bitmap = wx.BitmapFromImage(image.Scale(16, 16)) |
| 463 | 464 | bitmap.SetWidth(16) |
| 464 | 465 | bitmap.SetHeight(16) |
| ... | ... | @@ -466,7 +467,7 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
| 466 | 467 | |
| 467 | 468 | self.SetImageList(self.imagelist,wx.IMAGE_LIST_SMALL) |
| 468 | 469 | |
| 469 | - self.image_gray = Image.open("../icons/object_colour.jpg") | |
| 470 | + self.image_gray = Image.open(os.path.join(const.ICON_DIR, "object_colour.jpg")) | |
| 470 | 471 | |
| 471 | 472 | def OnEditLabel(self, evt): |
| 472 | 473 | Publisher.sendMessage('Change mask name', |
| ... | ... | @@ -586,11 +587,11 @@ class SurfaceButtonControlPanel(wx.Panel): |
| 586 | 587 | def __init_gui(self): |
| 587 | 588 | |
| 588 | 589 | # Bitmaps to be used in plate buttons |
| 589 | - BMP_NEW = wx.Bitmap("../icons/data_new.png", | |
| 590 | + BMP_NEW = wx.Bitmap(os.path.join(const.ICON_DIR, "data_new.png"), | |
| 590 | 591 | wx.BITMAP_TYPE_PNG) |
| 591 | - BMP_REMOVE = wx.Bitmap("../icons/data_remove.png", | |
| 592 | + BMP_REMOVE = wx.Bitmap(os.path.join(const.ICON_DIR, "data_remove.png"), | |
| 592 | 593 | wx.BITMAP_TYPE_PNG) |
| 593 | - BMP_DUPLICATE = wx.Bitmap("../icons/data_duplicate.png", | |
| 594 | + BMP_DUPLICATE = wx.Bitmap(os.path.join(const.ICON_DIR, "data_duplicate.png"), | |
| 594 | 595 | wx.BITMAP_TYPE_PNG) |
| 595 | 596 | |
| 596 | 597 | # Plate buttons based on previous bitmaps |
| ... | ... | @@ -781,13 +782,13 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
| 781 | 782 | def __init_image_list(self): |
| 782 | 783 | self.imagelist = wx.ImageList(16, 16) |
| 783 | 784 | |
| 784 | - image = wx.Image("../icons/object_invisible.jpg") | |
| 785 | + image = wx.Image(os.path.join(const.ICON_DIR, "object_invisible.jpg")) | |
| 785 | 786 | bitmap = wx.BitmapFromImage(image.Scale(16, 16)) |
| 786 | 787 | bitmap.SetWidth(16) |
| 787 | 788 | bitmap.SetHeight(16) |
| 788 | 789 | img_null = self.imagelist.Add(bitmap) |
| 789 | 790 | |
| 790 | - image = wx.Image("../icons//object_visible.jpg") | |
| 791 | + image = wx.Image(os.path.join(const.ICON_DIR, "object_visible.jpg")) | |
| 791 | 792 | bitmap = wx.BitmapFromImage(image.Scale(16, 16)) |
| 792 | 793 | bitmap.SetWidth(16) |
| 793 | 794 | bitmap.SetHeight(16) |
| ... | ... | @@ -795,7 +796,7 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
| 795 | 796 | |
| 796 | 797 | self.SetImageList(self.imagelist,wx.IMAGE_LIST_SMALL) |
| 797 | 798 | |
| 798 | - self.image_gray = Image.open("../icons/object_colour.jpg") | |
| 799 | + self.image_gray = Image.open(os.path.join(const.ICON_DIR, "object_colour.jpg")) | |
| 799 | 800 | |
| 800 | 801 | def OnEditLabel(self, evt): |
| 801 | 802 | Publisher.sendMessage('Change surface name', (evt.GetIndex(), evt.GetLabel())) |
| ... | ... | @@ -1045,13 +1046,13 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
| 1045 | 1046 | def __init_image_list(self): |
| 1046 | 1047 | self.imagelist = wx.ImageList(16, 16) |
| 1047 | 1048 | |
| 1048 | - image = wx.Image("../icons/object_invisible.jpg") | |
| 1049 | + image = wx.Image(os.path.join(const.ICON_DIR, "object_invisible.jpg")) | |
| 1049 | 1050 | bitmap = wx.BitmapFromImage(image.Scale(16, 16)) |
| 1050 | 1051 | bitmap.SetWidth(16) |
| 1051 | 1052 | bitmap.SetHeight(16) |
| 1052 | 1053 | img_null = self.imagelist.Add(bitmap) |
| 1053 | 1054 | |
| 1054 | - image = wx.Image("../icons/object_visible.jpg") | |
| 1055 | + image = wx.Image(os.path.join(const.ICON_DIR, "object_visible.jpg")) | |
| 1055 | 1056 | bitmap = wx.BitmapFromImage(image.Scale(16, 16)) |
| 1056 | 1057 | bitmap.SetWidth(16) |
| 1057 | 1058 | bitmap.SetHeight(16) |
| ... | ... | @@ -1059,7 +1060,7 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
| 1059 | 1060 | |
| 1060 | 1061 | self.SetImageList(self.imagelist,wx.IMAGE_LIST_SMALL) |
| 1061 | 1062 | |
| 1062 | - self.image_gray = Image.open("../icons/object_colour.jpg") | |
| 1063 | + self.image_gray = Image.open(os.path.join(const.ICON_DIR, "object_colour.jpg")) | |
| 1063 | 1064 | |
| 1064 | 1065 | |
| 1065 | 1066 | def OnEditLabel(self, evt): |
| ... | ... | @@ -1240,19 +1241,19 @@ class AnnotationsListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): |
| 1240 | 1241 | def __init_image_list(self): |
| 1241 | 1242 | self.imagelist = wx.ImageList(16, 16) |
| 1242 | 1243 | |
| 1243 | - image = wx.Image("../icons/object_visible.jpg") | |
| 1244 | + image = wx.Image(os.path.join(const.ICON_DIR, "object_visible.jpg")) | |
| 1244 | 1245 | bitmap = wx.BitmapFromImage(image.Scale(16, 16)) |
| 1245 | 1246 | bitmap.SetWidth(16) |
| 1246 | 1247 | bitmap.SetHeight(16) |
| 1247 | 1248 | img_check = self.imagelist.Add(bitmap) |
| 1248 | 1249 | |
| 1249 | - image = wx.Image("../icons/object_invisible.jpg") | |
| 1250 | + image = wx.Image(os.path.join(const.ICON_DIR, "object_invisible.jpg")) | |
| 1250 | 1251 | bitmap = wx.BitmapFromImage(image.Scale(16, 16)) |
| 1251 | 1252 | bitmap.SetWidth(16) |
| 1252 | 1253 | bitmap.SetHeight(16) |
| 1253 | 1254 | img_null = self.imagelist.Add(bitmap) |
| 1254 | 1255 | |
| 1255 | - image = wx.Image("../icons/object_colour.jpg") | |
| 1256 | + image = wx.Image(os.path.join(const.ICON_DIR, "object_colour.jpg")) | |
| 1256 | 1257 | bitmap = wx.BitmapFromImage(image.Scale(16, 16)) |
| 1257 | 1258 | bitmap.SetWidth(16) |
| 1258 | 1259 | bitmap.SetHeight(16) | ... | ... |
invesalius/gui/default_tasks.py
| ... | ... | @@ -21,15 +21,15 @@ import wx |
| 21 | 21 | import wx.lib.foldpanelbar as fpb |
| 22 | 22 | from wx.lib.pubsub import pub as Publisher |
| 23 | 23 | |
| 24 | -import constants as const | |
| 25 | -import data_notebook as nb | |
| 26 | -import session as ses | |
| 27 | -import task_exporter as exporter | |
| 28 | -import task_slice as slice_ | |
| 29 | -import task_importer as importer | |
| 30 | -import task_surface as surface | |
| 31 | -import task_tools as tools | |
| 32 | -import task_navigator as navigator | |
| 24 | +import invesalius.constants as const | |
| 25 | +import invesalius.gui.data_notebook as nb | |
| 26 | +import invesalius.session as ses | |
| 27 | +import invesalius.gui.task_exporter as exporter | |
| 28 | +import invesalius.gui.task_slice as slice_ | |
| 29 | +import invesalius.gui.task_importer as importer | |
| 30 | +import invesalius.gui.task_surface as surface | |
| 31 | +import invesalius.gui.task_tools as tools | |
| 32 | +import invesalius.gui.task_navigator as navigator | |
| 33 | 33 | |
| 34 | 34 | FPB_DEFAULT_STYLE = 2621440 |
| 35 | 35 | ... | ... |
invesalius/gui/default_viewers.py
| ... | ... | @@ -17,21 +17,24 @@ |
| 17 | 17 | # detalhes. |
| 18 | 18 | #-------------------------------------------------------------------------- |
| 19 | 19 | import sys |
| 20 | +import os | |
| 20 | 21 | |
| 21 | 22 | import wx |
| 22 | 23 | import wx.lib.agw.fourwaysplitter as fws |
| 23 | 24 | from wx.lib.pubsub import pub as Publisher |
| 24 | 25 | |
| 25 | -import data.viewer_slice as slice_viewer | |
| 26 | -import data.viewer_volume as volume_viewer | |
| 27 | -import project | |
| 28 | -import widgets.slice_menu as slice_menu_ | |
| 26 | +import invesalius.data.viewer_slice as slice_viewer | |
| 27 | +import invesalius.data.viewer_volume as volume_viewer | |
| 28 | +import invesalius.project as project | |
| 29 | +import invesalius.gui.widgets.slice_menu as slice_menu_ | |
| 29 | 30 | |
| 30 | -from gui.widgets.clut_raycasting import CLUTRaycastingWidget, \ | |
| 31 | + | |
| 32 | +from invesalius.gui.widgets.clut_raycasting import CLUTRaycastingWidget, \ | |
| 31 | 33 | EVT_CLUT_POINT_RELEASE, EVT_CLUT_CURVE_SELECT, \ |
| 32 | 34 | EVT_CLUT_CURVE_WL_CHANGE |
| 33 | 35 | |
| 34 | -from constants import ID_TO_BMP | |
| 36 | +from invesalius.constants import ID_TO_BMP | |
| 37 | +import invesalius.constants as const | |
| 35 | 38 | |
| 36 | 39 | class Panel(wx.Panel): |
| 37 | 40 | def __init__(self, parent): |
| ... | ... | @@ -300,8 +303,8 @@ import wx.lib.platebtn as pbtn |
| 300 | 303 | import wx.lib.buttons as btn |
| 301 | 304 | import wx.lib.pubsub as ps |
| 302 | 305 | |
| 303 | -import constants as const | |
| 304 | -import widgets.colourselect as csel | |
| 306 | +import invesalius.constants as const | |
| 307 | +import invesalius.gui.widgets.colourselect as csel | |
| 305 | 308 | |
| 306 | 309 | [BUTTON_RAYCASTING, BUTTON_VIEW, BUTTON_SLICE_PLANE, BUTTON_3D_STEREO] = [wx.NewId() for num in xrange(4)] |
| 307 | 310 | RAYCASTING_TOOLS = wx.NewId() |
| ... | ... | @@ -333,14 +336,14 @@ class VolumeToolPanel(wx.Panel): |
| 333 | 336 | wx.Panel.__init__(self, parent) |
| 334 | 337 | |
| 335 | 338 | # VOLUME RAYCASTING BUTTON |
| 336 | - BMP_RAYCASTING = wx.Bitmap("../icons/volume_raycasting.png", | |
| 339 | + BMP_RAYCASTING = wx.Bitmap(os.path.join(const.ICON_DIR, "volume_raycasting.png"), | |
| 337 | 340 | wx.BITMAP_TYPE_PNG) |
| 338 | 341 | |
| 339 | - BMP_SLICE_PLANE = wx.Bitmap("../icons/slice_plane.png", | |
| 342 | + BMP_SLICE_PLANE = wx.Bitmap(os.path.join(const.ICON_DIR, "slice_plane.png"), | |
| 340 | 343 | wx.BITMAP_TYPE_PNG) |
| 341 | 344 | |
| 342 | 345 | |
| 343 | - BMP_3D_STEREO = wx.Bitmap("../icons/3D_glasses.png", | |
| 346 | + BMP_3D_STEREO = wx.Bitmap(os.path.join(const.ICON_DIR, "3D_glasses.png"), | |
| 344 | 347 | wx.BITMAP_TYPE_PNG) |
| 345 | 348 | |
| 346 | 349 | ... | ... |
invesalius/gui/dialogs.py
| ... | ... | @@ -29,13 +29,12 @@ from wx.lib.agw import floatspin |
| 29 | 29 | from wx.lib.wordwrap import wordwrap |
| 30 | 30 | from wx.lib.pubsub import pub as Publisher |
| 31 | 31 | |
| 32 | -import constants as const | |
| 33 | -import gui.widgets.gradient as grad | |
| 34 | -import project as proj | |
| 35 | -import session as ses | |
| 36 | -import utils | |
| 37 | - | |
| 38 | -from gui.widgets.clut_imagedata import CLUTImageDataWidget, EVT_CLUT_NODE_CHANGED | |
| 32 | +import invesalius.constants as const | |
| 33 | +import invesalius.gui.widgets.gradient as grad | |
| 34 | +import invesalius.session as ses | |
| 35 | +import invesalius.utils as utils | |
| 36 | +from invesalius.gui.widgets import clut_imagedata | |
| 37 | +from invesalius.gui.widgets.clut_imagedata import CLUTImageDataWidget, EVT_CLUT_NODE_CHANGED | |
| 39 | 38 | |
| 40 | 39 | import numpy as np |
| 41 | 40 | |
| ... | ... | @@ -603,9 +602,9 @@ class NewMask(wx.Dialog): |
| 603 | 602 | pos=wx.DefaultPosition, |
| 604 | 603 | style=wx.DEFAULT_DIALOG_STYLE, |
| 605 | 604 | useMetal=False): |
| 606 | - import constants as const | |
| 607 | - import data.mask as mask | |
| 608 | - import project as prj | |
| 605 | + import invesalius.constants as const | |
| 606 | + import invesalius.data.mask as mask | |
| 607 | + import invesalius.project as prj | |
| 609 | 608 | |
| 610 | 609 | # Instead of calling wx.Dialog.__init__ we precreate the dialog |
| 611 | 610 | # so we can set an extra style that must be set before |
| ... | ... | @@ -711,14 +710,14 @@ class NewMask(wx.Dialog): |
| 711 | 710 | |
| 712 | 711 | |
| 713 | 712 | def OnComboThresh(self, evt): |
| 714 | - import project as prj | |
| 713 | + import invesalius.project as prj | |
| 715 | 714 | proj = prj.Project() |
| 716 | 715 | (thresh_min, thresh_max) = proj.threshold_modes[evt.GetString()] |
| 717 | 716 | self.gradient.SetMinimun(thresh_min) |
| 718 | 717 | self.gradient.SetMaximun(thresh_max) |
| 719 | 718 | |
| 720 | 719 | def OnSlideChanged(self, evt): |
| 721 | - import project as prj | |
| 720 | + import invesalius.project as prj | |
| 722 | 721 | thresh_min = self.gradient.GetMinValue() |
| 723 | 722 | thresh_max = self.gradient.GetMaxValue() |
| 724 | 723 | thresh = (thresh_min, thresh_max) |
| ... | ... | @@ -878,9 +877,9 @@ class NewSurfaceDialog(wx.Dialog): |
| 878 | 877 | def __init__(self, parent=None, ID=-1, title="InVesalius 3", size=wx.DefaultSize, |
| 879 | 878 | pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE, |
| 880 | 879 | useMetal=False): |
| 881 | - import constants as const | |
| 882 | - import data.surface as surface | |
| 883 | - import project as prj | |
| 880 | + import invesalius.constants as const | |
| 881 | + import invesalius.data.surface as surface | |
| 882 | + import invesalius.project as prj | |
| 884 | 883 | |
| 885 | 884 | # Instead of calling wx.Dialog.__init__ we precreate the dialog |
| 886 | 885 | # so we can set an extra style that must be set before |
| ... | ... | @@ -1002,7 +1001,9 @@ class NewSurfaceDialog(wx.Dialog): |
| 1002 | 1001 | |
| 1003 | 1002 | |
| 1004 | 1003 | def ExportPicture(type_=""): |
| 1005 | - import constants as const | |
| 1004 | + import invesalius.constants as const | |
| 1005 | + import invesalius.project as proj | |
| 1006 | + | |
| 1006 | 1007 | INDEX_TO_EXTENSION = {0: "bmp", 1: "jpg", 2: "png", 3: "ps", 4:"povray", 5:"tiff"} |
| 1007 | 1008 | WILDCARD_SAVE_PICTURE = _("BMP image")+" (*.bmp)|*.bmp|"+\ |
| 1008 | 1009 | _("JPG image")+" (*.jpg)|*.jpg|"+\ |
| ... | ... | @@ -1143,6 +1144,7 @@ class SurfaceCreationDialog(wx.Dialog): |
| 1143 | 1144 | sizer.Fit(self) |
| 1144 | 1145 | |
| 1145 | 1146 | def OnSetMask(self, evt): |
| 1147 | + import invesalius.project as proj | |
| 1146 | 1148 | mask = proj.Project().mask_dict[evt.mask_index] |
| 1147 | 1149 | self.ca.mask_edited = mask.was_edited |
| 1148 | 1150 | self.ca.ReloadMethodsOptions() |
| ... | ... | @@ -1153,9 +1155,9 @@ class SurfaceCreationDialog(wx.Dialog): |
| 1153 | 1155 | |
| 1154 | 1156 | class SurfaceCreationOptionsPanel(wx.Panel): |
| 1155 | 1157 | def __init__(self, parent, ID=-1): |
| 1156 | - import constants as const | |
| 1157 | - import data.surface as surface | |
| 1158 | - import project as prj | |
| 1158 | + import invesalius.constants as const | |
| 1159 | + import invesalius.data.surface as surface | |
| 1160 | + import invesalius.project as prj | |
| 1159 | 1161 | |
| 1160 | 1162 | wx.Panel.__init__(self, parent, ID) |
| 1161 | 1163 | |
| ... | ... | @@ -1565,7 +1567,7 @@ class MaskBooleanDialog(wx.Dialog): |
| 1565 | 1567 | else: |
| 1566 | 1568 | self.mask2.SetSelection(0) |
| 1567 | 1569 | |
| 1568 | - icon_folder = '../icons/' | |
| 1570 | + icon_folder = const.ICON_DIR | |
| 1569 | 1571 | op_choices = ((_(u"Union"), const.BOOLEAN_UNION, 'bool_union.png'), |
| 1570 | 1572 | (_(u"Difference"), const.BOOLEAN_DIFF, 'bool_difference.png'), |
| 1571 | 1573 | (_(u"Intersection"), const.BOOLEAN_AND, 'bool_intersection.png'), |
| ... | ... | @@ -1711,7 +1713,7 @@ class ImportBitmapParameters(wx.Dialog): |
| 1711 | 1713 | |
| 1712 | 1714 | def _init_gui(self): |
| 1713 | 1715 | |
| 1714 | - import project as prj | |
| 1716 | + import invesalius.project as prj | |
| 1715 | 1717 | |
| 1716 | 1718 | p = wx.Panel(self, -1, style = wx.TAB_TRAVERSAL |
| 1717 | 1719 | | wx.CLIP_CHILDREN |
| ... | ... | @@ -1915,7 +1917,7 @@ class PanelFFillThreshold(wx.Panel): |
| 1915 | 1917 | self._init_gui() |
| 1916 | 1918 | |
| 1917 | 1919 | def _init_gui(self): |
| 1918 | - import project as prj | |
| 1920 | + import invesalius.project as prj | |
| 1919 | 1921 | |
| 1920 | 1922 | project = prj.Project() |
| 1921 | 1923 | bound_min, bound_max = project.threshold_range |
| ... | ... | @@ -2204,7 +2206,7 @@ class FFillSegmentationOptionsDialog(wx.Dialog): |
| 2204 | 2206 | """ |
| 2205 | 2207 | Create the widgets. |
| 2206 | 2208 | """ |
| 2207 | - import project as prj | |
| 2209 | + import invesalius.project as prj | |
| 2208 | 2210 | |
| 2209 | 2211 | # Target |
| 2210 | 2212 | if sys.platform == "win32": | ... | ... |
invesalius/gui/dicom_preview_panel.py
| ... | ... | @@ -31,10 +31,10 @@ from vtk.util import numpy_support |
| 31 | 31 | from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor |
| 32 | 32 | from wx.lib.pubsub import pub as Publisher |
| 33 | 33 | |
| 34 | -import constants as const | |
| 35 | -from reader import dicom_reader | |
| 36 | -import data.vtk_utils as vtku | |
| 37 | -import utils | |
| 34 | +import invesalius.constants as const | |
| 35 | +import invesalius.reader.dicom_reader as dicom_reader | |
| 36 | +import invesalius.data.vtk_utils as vtku | |
| 37 | +import invesalius.utils as utils | |
| 38 | 38 | import vtkgdcm |
| 39 | 39 | |
| 40 | 40 | ... | ... |
invesalius/gui/frame.py
| ... | ... | @@ -31,18 +31,17 @@ import wx.lib.popupctl as pc |
| 31 | 31 | |
| 32 | 32 | from wx.lib.agw.aui.auibar import AuiToolBar, AUI_TB_PLAIN_BACKGROUND |
| 33 | 33 | |
| 34 | -import constants as const | |
| 35 | -import default_tasks as tasks | |
| 36 | -import default_viewers as viewers | |
| 37 | -import gui.dialogs as dlg | |
| 38 | -import import_panel as imp | |
| 39 | -import import_bitmap_panel as imp_bmp | |
| 40 | -import import_network_panel as imp_net | |
| 41 | -import project as prj | |
| 42 | -import session as ses | |
| 43 | -import utils | |
| 44 | -import preferences | |
| 45 | - | |
| 34 | +import invesalius.constants as const | |
| 35 | +import invesalius.gui.default_tasks as tasks | |
| 36 | +import invesalius.gui.default_viewers as viewers | |
| 37 | +import invesalius.gui.dialogs as dlg | |
| 38 | +import invesalius.gui.import_panel as imp | |
| 39 | +import invesalius.gui.import_bitmap_panel as imp_bmp | |
| 40 | +import invesalius.gui.import_network_panel as imp_net | |
| 41 | +import invesalius.project as prj | |
| 42 | +import invesalius.session as ses | |
| 43 | +import invesalius.utils as utils | |
| 44 | +import invesalius.gui.preferences as preferences | |
| 46 | 45 | # Layout tools' IDs - this is used only locally, therefore doesn't |
| 47 | 46 | # need to be defined in constants.py |
| 48 | 47 | VIEW_TOOLS = [ID_LAYOUT, ID_TEXT] =\ |
| ... | ... | @@ -174,8 +173,7 @@ class Frame(wx.Frame): |
| 174 | 173 | Hide().Layer(1).MaximizeButton(True). |
| 175 | 174 | Name("Data").Position(1)) |
| 176 | 175 | |
| 177 | - # This is the DICOM import panel. When the two panels above | |
| 178 | - # are shown, this should be hiden | |
| 176 | + # This is the DICOM import panel. When the two panels above as dicom # are shown, this should be hiden | |
| 179 | 177 | caption = _("Preview medical data to be reconstructed") |
| 180 | 178 | aui_manager.AddPane(imp.Panel(self), wx.aui.AuiPaneInfo(). |
| 181 | 179 | Name("Import").CloseButton(False).Centre().Hide(). |
| ... | ... | @@ -353,8 +351,7 @@ class Frame(wx.Frame): |
| 353 | 351 | |
| 354 | 352 | def _ShowImportPanel(self, evt_pubsub): |
| 355 | 353 | """ |
| 356 | - Show only DICOM import panel. | |
| 357 | - """ | |
| 354 | + Show only DICOM import panel. as dicom """ | |
| 358 | 355 | Publisher.sendMessage("Set layout button data only") |
| 359 | 356 | aui_manager = self.aui_manager |
| 360 | 357 | aui_manager.GetPane("Import").Show(1) |
| ... | ... | @@ -535,8 +532,7 @@ class Frame(wx.Frame): |
| 535 | 532 | |
| 536 | 533 | def ShowImportDicomPanel(self): |
| 537 | 534 | """ |
| 538 | - Show import DICOM panel. | |
| 539 | - """ | |
| 535 | + Show import DICOM panel. as dicom """ | |
| 540 | 536 | Publisher.sendMessage('Show import directory dialog') |
| 541 | 537 | |
| 542 | 538 | def ShowRetrieveDicomPanel(self): |
| ... | ... | @@ -1041,8 +1037,7 @@ class TaskBarIcon(wx.TaskBarIcon): |
| 1041 | 1037 | |
| 1042 | 1038 | class ProjectToolBar(AuiToolBar): |
| 1043 | 1039 | """ |
| 1044 | - Toolbar related to general project operations, including: import, | |
| 1045 | - open, save and saveas, among others. | |
| 1040 | + Toolbar related to general invesalius.project operations, including: import, as project open, save and saveas, among others. | |
| 1046 | 1041 | """ |
| 1047 | 1042 | def __init__(self, parent): |
| 1048 | 1043 | style = AUI_TB_PLAIN_BACKGROUND | ... | ... |
invesalius/gui/import_bitmap_panel.py
| ... | ... | @@ -21,12 +21,11 @@ import wx.gizmos as gizmos |
| 21 | 21 | from wx.lib.pubsub import pub as Publisher |
| 22 | 22 | import wx.lib.splitter as spl |
| 23 | 23 | |
| 24 | -import constants as const | |
| 25 | -import gui.dialogs as dlg | |
| 26 | -import bitmap_preview_panel as bpp | |
| 27 | -import reader.bitmap_reader as bpr | |
| 28 | -from dialogs import ImportBitmapParameters | |
| 29 | - | |
| 24 | +import invesalius.constants as const | |
| 25 | +import invesalius.gui.dialogs as dlg | |
| 26 | +import invesalius.gui.bitmap_preview_panel as bpp | |
| 27 | +import invesalius.reader.bitmap_reader as bpr | |
| 28 | +from invesalius.gui.dialogs import ImportBitmapParameters as dialogs | |
| 30 | 29 | myEVT_SELECT_SERIE = wx.NewEventType() |
| 31 | 30 | EVT_SELECT_SERIE = wx.PyEventBinder(myEVT_SELECT_SERIE, 1) |
| 32 | 31 | ... | ... |
invesalius/gui/import_network_panel.py
| ... | ... | @@ -22,11 +22,11 @@ import wx.gizmos as gizmos |
| 22 | 22 | from wx.lib.pubsub import pub as Publisher |
| 23 | 23 | import wx.lib.splitter as spl |
| 24 | 24 | |
| 25 | -import constants as const | |
| 26 | -import gui.dialogs as dlg | |
| 27 | -#import dicom_preview_panel as dpp | |
| 28 | -import reader.dicom_grouper as dcm | |
| 29 | -import net.dicom as dcm_net | |
| 25 | +import invesalius.constants as const | |
| 26 | +import invesalius.gui.dialogs as dlg | |
| 27 | +#import invesalius.gui.dicom_preview_panel as dpp | |
| 28 | +import invesalius.reader.dicom_grouper as dcm | |
| 29 | +import invesalius.net.dicom as dcm_net | |
| 30 | 30 | |
| 31 | 31 | from wx.lib.mixins.listctrl import CheckListCtrlMixin |
| 32 | 32 | #from dicionario import musicdata | ... | ... |
invesalius/gui/import_panel.py
| ... | ... | @@ -21,10 +21,10 @@ import wx.gizmos as gizmos |
| 21 | 21 | from wx.lib.pubsub import pub as Publisher |
| 22 | 22 | import wx.lib.splitter as spl |
| 23 | 23 | |
| 24 | -import constants as const | |
| 25 | -import gui.dialogs as dlg | |
| 26 | -import dicom_preview_panel as dpp | |
| 27 | -import reader.dicom_grouper as dcm | |
| 24 | +import invesalius.constants as const | |
| 25 | +import invesalius.gui.dialogs as dlg | |
| 26 | +import invesalius.gui.dicom_preview_panel as dpp | |
| 27 | +import invesalius.reader.dicom_grouper as dcm | |
| 28 | 28 | |
| 29 | 29 | myEVT_SELECT_SERIE = wx.NewEventType() |
| 30 | 30 | EVT_SELECT_SERIE = wx.PyEventBinder(myEVT_SELECT_SERIE, 1) | ... | ... |
invesalius/gui/language_dialog.py
| ... | ... | @@ -18,12 +18,25 @@ |
| 18 | 18 | #-------------------------------------------------------------------------- |
| 19 | 19 | |
| 20 | 20 | import os |
| 21 | +import sys | |
| 21 | 22 | import wx |
| 22 | 23 | import wx.combo |
| 23 | 24 | |
| 24 | -import i18n | |
| 25 | +import invesalius.i18n as i18n | |
| 25 | 26 | |
| 26 | -ICON_DIR = os.path.abspath(os.path.join('..', 'icons')) | |
| 27 | +file_path = os.path.split(__file__)[0] | |
| 28 | + | |
| 29 | +if hasattr(sys,"frozen") and (sys.frozen == "windows_exe"\ | |
| 30 | + or sys.frozen == "console_exe"): | |
| 31 | + abs_file_path = os.path.abspath(file_path + os.sep + ".." +\ | |
| 32 | + os.sep + ".." + os.sep + ".." + os.sep + "..") | |
| 33 | + ICON_DIR = os.path.abspath(os.path.join(abs_file_path, 'icons')) | |
| 34 | +else: | |
| 35 | + ICON_DIR = os.path.abspath(os.path.join(file_path, '..', '..','icons')) | |
| 36 | + | |
| 37 | +# MAC App | |
| 38 | +if not os.path.exists(ICON_DIR): | |
| 39 | + ICON_DIR = os.path.abspath(os.path.join(file_path, '..', '..', '..', '..', '..', 'icons')) | |
| 27 | 40 | |
| 28 | 41 | class ComboBoxLanguage: |
| 29 | 42 | ... | ... |
invesalius/gui/preferences.py
| 1 | 1 | import wx |
| 2 | -import constants as const | |
| 2 | +import invesalius.constants as const | |
| 3 | 3 | from wx.lib.pubsub import pub as Publisher |
| 4 | -import session as ses | |
| 5 | -from language_dialog import ComboBoxLanguage | |
| 6 | - | |
| 4 | +import invesalius.session as ses | |
| 5 | +from invesalius.gui.language_dialog import ComboBoxLanguage | |
| 7 | 6 | ID = wx.NewId() |
| 8 | 7 | |
| 9 | 8 | try: | ... | ... |
invesalius/gui/task_exporter.py
| ... | ... | @@ -25,9 +25,9 @@ import wx.lib.hyperlink as hl |
| 25 | 25 | import wx.lib.platebtn as pbtn |
| 26 | 26 | from wx.lib.pubsub import pub as Publisher |
| 27 | 27 | |
| 28 | -import constants as const | |
| 29 | -import gui.dialogs as dlg | |
| 30 | -import project as proj | |
| 28 | +import invesalius.constants as const | |
| 29 | +import invesalius.gui.dialogs as dlg | |
| 30 | +import invesalius.project as proj | |
| 31 | 31 | |
| 32 | 32 | BTN_MASK = wx.NewId() |
| 33 | 33 | BTN_PICTURE = wx.NewId() |
| ... | ... | @@ -164,22 +164,22 @@ class InnerTaskPanel(wx.Panel): |
| 164 | 164 | # Image(s) for buttons |
| 165 | 165 | if sys.platform == 'darwin': |
| 166 | 166 | BMP_EXPORT_SURFACE = wx.Bitmap(\ |
| 167 | - "../icons/surface_export_original.png", | |
| 167 | + os.path.join(const.ICON_DIR, "surface_export_original.png"), | |
| 168 | 168 | wx.BITMAP_TYPE_PNG).ConvertToImage()\ |
| 169 | 169 | .Rescale(25, 25).ConvertToBitmap() |
| 170 | 170 | BMP_TAKE_PICTURE = wx.Bitmap(\ |
| 171 | - "../icons/tool_photo_original.png", | |
| 171 | + os.path.join(const.ICON_DIR, "tool_photo_original.png"), | |
| 172 | 172 | wx.BITMAP_TYPE_PNG).ConvertToImage()\ |
| 173 | 173 | .Rescale(25, 25).ConvertToBitmap() |
| 174 | 174 | |
| 175 | 175 | #BMP_EXPORT_MASK = wx.Bitmap("../icons/mask.png", |
| 176 | 176 | # wx.BITMAP_TYPE_PNG) |
| 177 | 177 | else: |
| 178 | - BMP_EXPORT_SURFACE = wx.Bitmap("../icons/surface_export.png", | |
| 178 | + BMP_EXPORT_SURFACE = wx.Bitmap(os.path.join(const.ICON_DIR, "surface_export.png"), | |
| 179 | 179 | wx.BITMAP_TYPE_PNG).ConvertToImage()\ |
| 180 | 180 | .Rescale(25, 25).ConvertToBitmap() |
| 181 | 181 | |
| 182 | - BMP_TAKE_PICTURE = wx.Bitmap("../icons/tool_photo.png", | |
| 182 | + BMP_TAKE_PICTURE = wx.Bitmap(os.path.join(const.ICON_DIR, "tool_photo.png"), | |
| 183 | 183 | wx.BITMAP_TYPE_PNG).ConvertToImage()\ |
| 184 | 184 | .Rescale(25, 25).ConvertToBitmap() |
| 185 | 185 | ... | ... |
invesalius/gui/task_importer.py
| ... | ... | @@ -24,8 +24,8 @@ import wx.lib.hyperlink as hl |
| 24 | 24 | import wx.lib.platebtn as pbtn |
| 25 | 25 | from wx.lib.pubsub import pub as Publisher |
| 26 | 26 | |
| 27 | -import constants as const | |
| 28 | -import gui.dialogs as dlg | |
| 27 | +import invesalius.constants as const | |
| 28 | +import invesalius.gui.dialogs as dlg | |
| 29 | 29 | |
| 30 | 30 | BTN_IMPORT_LOCAL = wx.NewId() |
| 31 | 31 | BTN_IMPORT_PACS = wx.NewId() |
| ... | ... | @@ -96,9 +96,9 @@ class InnerTaskPanel(wx.Panel): |
| 96 | 96 | link_open_proj.Bind(hl.EVT_HYPERLINK_LEFT, self.OnLinkOpenProject) |
| 97 | 97 | |
| 98 | 98 | # Image(s) for buttons |
| 99 | - BMP_IMPORT = wx.Bitmap("../icons/file_import.png", wx.BITMAP_TYPE_PNG) | |
| 100 | - BMP_NET = wx.Bitmap("../icons/file_from_internet.png", wx.BITMAP_TYPE_PNG) | |
| 101 | - BMP_OPEN_PROJECT = wx.Bitmap("../icons/file_open.png", wx.BITMAP_TYPE_PNG) | |
| 99 | + BMP_IMPORT = wx.Bitmap(os.path.join(const.ICON_DIR, "file_import.png"), wx.BITMAP_TYPE_PNG) | |
| 100 | + BMP_NET = wx.Bitmap(os.path.join(const.ICON_DIR, "file_from_internet.png"), wx.BITMAP_TYPE_PNG) | |
| 101 | + BMP_OPEN_PROJECT = wx.Bitmap(os.path.join(const.ICON_DIR, "file_open.png"), wx.BITMAP_TYPE_PNG) | |
| 102 | 102 | |
| 103 | 103 | bmp_list = [BMP_IMPORT, BMP_NET, BMP_OPEN_PROJECT] |
| 104 | 104 | #for bmp in bmp_list: |
| ... | ... | @@ -159,7 +159,7 @@ class InnerTaskPanel(wx.Panel): |
| 159 | 159 | # self.LoadProject(filename, path) |
| 160 | 160 | |
| 161 | 161 | def TestLoadProjects2(self): |
| 162 | - import session as ses | |
| 162 | + import invesalius.session as ses | |
| 163 | 163 | session = ses.Session() |
| 164 | 164 | projects = session.recent_projects |
| 165 | 165 | for tuple in projects: |
| ... | ... | @@ -175,7 +175,7 @@ class InnerTaskPanel(wx.Panel): |
| 175 | 175 | |
| 176 | 176 | def LoadProject(self, proj_name="Unnamed", proj_dir=""): |
| 177 | 177 | """ |
| 178 | - Load into user interface name of project into import task panel. | |
| 178 | + Load into user interface name of invesalius.project into import task panel. | |
| 179 | 179 | Can be called 3 times in sequence. |
| 180 | 180 | Call UnloadProjects to empty it. |
| 181 | 181 | """ | ... | ... |
invesalius/gui/task_navigator.py
| ... | ... | @@ -27,10 +27,9 @@ import wx.lib.masked.numctrl |
| 27 | 27 | import wx.lib.platebtn as pbtn |
| 28 | 28 | from wx.lib.pubsub import pub as Publisher |
| 29 | 29 | |
| 30 | -import data.bases as db | |
| 31 | -import data.co_registration as dcr | |
| 32 | -import project | |
| 33 | - | |
| 30 | +import invesalius.data.bases as db | |
| 31 | +import invesalius.data.co_registration as dcr | |
| 32 | +import invesalius.project as project | |
| 34 | 33 | IR1 = wx.NewId() |
| 35 | 34 | IR2 = wx.NewId() |
| 36 | 35 | IR3 = wx.NewId() | ... | ... |
invesalius/gui/task_slice.py
| ... | ... | @@ -18,22 +18,23 @@ |
| 18 | 18 | # detalhes. |
| 19 | 19 | #-------------------------------------------------------------------------- |
| 20 | 20 | import sys |
| 21 | +import os | |
| 21 | 22 | |
| 22 | 23 | import wx |
| 23 | 24 | import wx.lib.hyperlink as hl |
| 24 | 25 | import wx.lib.platebtn as pbtn |
| 25 | 26 | from wx.lib.pubsub import pub as Publisher |
| 26 | 27 | |
| 27 | -import data.mask as mask | |
| 28 | -import data.slice_ as slice_ | |
| 29 | -import constants as const | |
| 30 | -import gui.dialogs as dlg | |
| 31 | -import gui.widgets.gradient as grad | |
| 32 | -import gui.widgets.foldpanelbar as fpb | |
| 33 | -import widgets.colourselect as csel | |
| 28 | +import invesalius.data.mask as mask | |
| 29 | +import invesalius.data.slice_ as slice_ | |
| 30 | +import invesalius.constants as const | |
| 31 | +import invesalius.gui.dialogs as dlg | |
| 32 | +import invesalius.gui.widgets.gradient as grad | |
| 33 | +import invesalius.gui.widgets.foldpanelbar as fpb | |
| 34 | +import invesalius.gui.widgets.colourselect as csel | |
| 34 | 35 | |
| 35 | -from project import Project | |
| 36 | -import session as ses | |
| 36 | +from invesalius.project import Project | |
| 37 | +import invesalius.session as ses | |
| 37 | 38 | |
| 38 | 39 | BTN_NEW = wx.NewId() |
| 39 | 40 | |
| ... | ... | @@ -70,7 +71,7 @@ class InnerTaskPanel(wx.Panel): |
| 70 | 71 | self.SetAutoLayout(1) |
| 71 | 72 | |
| 72 | 73 | # Image(s) for buttons |
| 73 | - BMP_ADD = wx.Bitmap("../icons/object_add.png", wx.BITMAP_TYPE_PNG) | |
| 74 | + BMP_ADD = wx.Bitmap(os.path.join(const.ICON_DIR, "object_add.png"), wx.BITMAP_TYPE_PNG) | |
| 74 | 75 | #BMP_ADD.SetWidth(25) |
| 75 | 76 | #BMP_ADD.SetHeight(25) |
| 76 | 77 | |
| ... | ... | @@ -524,7 +525,7 @@ class MaskProperties(wx.Panel): |
| 524 | 525 | self.bind_evt_gradient = False |
| 525 | 526 | self.gradient.SetMinValue(thresh_min) |
| 526 | 527 | self.gradient.SetMaxValue(thresh_max) |
| 527 | - print ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", thresh_min, thresh_max | |
| 528 | + | |
| 528 | 529 | self.bind_evt_gradient = True |
| 529 | 530 | thresh = (thresh_min, thresh_max) |
| 530 | 531 | if thresh in Project().threshold_modes.values(): |
| ... | ... | @@ -651,11 +652,11 @@ class EditionTools(wx.Panel): |
| 651 | 652 | ## LINE 2 |
| 652 | 653 | menu = wx.Menu() |
| 653 | 654 | |
| 654 | - CIRCLE_BMP = wx.Bitmap("../icons/brush_circle.jpg", wx.BITMAP_TYPE_JPEG) | |
| 655 | + CIRCLE_BMP = wx.Bitmap(os.path.join(const.ICON_DIR, "brush_circle.jpg"), wx.BITMAP_TYPE_JPEG) | |
| 655 | 656 | item = wx.MenuItem(menu, MENU_BRUSH_CIRCLE, _("Circle")) |
| 656 | 657 | item.SetBitmap(CIRCLE_BMP) |
| 657 | 658 | |
| 658 | - SQUARE_BMP = wx.Bitmap("../icons/brush_square.jpg", wx.BITMAP_TYPE_JPEG) | |
| 659 | + SQUARE_BMP = wx.Bitmap(os.path.join(const.ICON_DIR, "brush_square.jpg"), wx.BITMAP_TYPE_JPEG) | |
| 659 | 660 | item2 = wx.MenuItem(menu, MENU_BRUSH_SQUARE, _("Square")) |
| 660 | 661 | item2.SetBitmap(SQUARE_BMP) |
| 661 | 662 | |
| ... | ... | @@ -771,8 +772,8 @@ class EditionTools(wx.Panel): |
| 771 | 772 | (thresh_min, thresh_max)) |
| 772 | 773 | |
| 773 | 774 | def OnMenu(self, evt): |
| 774 | - SQUARE_BMP = wx.Bitmap("../icons/brush_square.jpg", wx.BITMAP_TYPE_JPEG) | |
| 775 | - CIRCLE_BMP = wx.Bitmap("../icons/brush_circle.jpg", wx.BITMAP_TYPE_JPEG) | |
| 775 | + SQUARE_BMP = wx.Bitmap(os.path.join(const.ICON_DIR, "brush_square.jpg"), wx.BITMAP_TYPE_JPEG) | |
| 776 | + CIRCLE_BMP = wx.Bitmap(os.path.join(const.ICON_DIR, "brush_circle.jpg"), wx.BITMAP_TYPE_JPEG) | |
| 776 | 777 | |
| 777 | 778 | brush = {MENU_BRUSH_CIRCLE: const.BRUSH_CIRCLE, |
| 778 | 779 | MENU_BRUSH_SQUARE: const.BRUSH_SQUARE} |
| ... | ... | @@ -815,11 +816,11 @@ class WatershedTool(EditionTools): |
| 815 | 816 | ## LINE 2 |
| 816 | 817 | menu = wx.Menu() |
| 817 | 818 | |
| 818 | - CIRCLE_BMP = wx.Bitmap("../icons/brush_circle.jpg", wx.BITMAP_TYPE_JPEG) | |
| 819 | + CIRCLE_BMP = wx.Bitmap(os.path.join(const.ICON_DIR, "brush_circle.jpg"), wx.BITMAP_TYPE_JPEG) | |
| 819 | 820 | item = wx.MenuItem(menu, MENU_BRUSH_CIRCLE, _("Circle")) |
| 820 | 821 | item.SetBitmap(CIRCLE_BMP) |
| 821 | 822 | |
| 822 | - SQUARE_BMP = wx.Bitmap("../icons/brush_square.jpg", wx.BITMAP_TYPE_JPEG) | |
| 823 | + SQUARE_BMP = wx.Bitmap(os.path.join(const.ICON_DIR, "brush_square.jpg"), wx.BITMAP_TYPE_JPEG) | |
| 823 | 824 | item2 = wx.MenuItem(menu, MENU_BRUSH_SQUARE, _("Square")) |
| 824 | 825 | item2.SetBitmap(SQUARE_BMP) |
| 825 | 826 | |
| ... | ... | @@ -874,7 +875,7 @@ class WatershedTool(EditionTools): |
| 874 | 875 | self.ww_wl_cbox = ww_wl_cbox |
| 875 | 876 | |
| 876 | 877 | # Line 6 |
| 877 | - bmp = wx.Bitmap("../icons/configuration.png", wx.BITMAP_TYPE_PNG) | |
| 878 | + bmp = wx.Bitmap(os.path.join(const.ICON_DIR, "configuration.png"), wx.BITMAP_TYPE_PNG) | |
| 878 | 879 | self.btn_wconfig = wx.BitmapButton(self, -1, bitmap=bmp, |
| 879 | 880 | size=(bmp.GetWidth()+10, bmp.GetHeight()+10)) |
| 880 | 881 | self.btn_exp_watershed = wx.Button(self, -1, _('Expand watershed to 3D')) |
| ... | ... | @@ -942,8 +943,8 @@ class WatershedTool(EditionTools): |
| 942 | 943 | self.gradient_thresh.SetMaxValue(thresh_max) |
| 943 | 944 | |
| 944 | 945 | def OnMenu(self, evt): |
| 945 | - SQUARE_BMP = wx.Bitmap("../icons/brush_square.jpg", wx.BITMAP_TYPE_JPEG) | |
| 946 | - CIRCLE_BMP = wx.Bitmap("../icons/brush_circle.jpg", wx.BITMAP_TYPE_JPEG) | |
| 946 | + SQUARE_BMP = wx.Bitmap(os.path.join(const.ICON_DIR, "brush_square.jpg"), wx.BITMAP_TYPE_JPEG) | |
| 947 | + CIRCLE_BMP = wx.Bitmap(os.path.join(const.ICON_DIR, "brush_circle.jpg"), wx.BITMAP_TYPE_JPEG) | |
| 947 | 948 | |
| 948 | 949 | brush = {MENU_BRUSH_CIRCLE: const.BRUSH_CIRCLE, |
| 949 | 950 | MENU_BRUSH_SQUARE: const.BRUSH_SQUARE} |
| ... | ... | @@ -978,7 +979,7 @@ class WatershedTool(EditionTools): |
| 978 | 979 | Publisher.sendMessage('Set use ww wl', value) |
| 979 | 980 | |
| 980 | 981 | def OnConfig(self, evt): |
| 981 | - from data.styles import WatershedConfig | |
| 982 | + from invesalius.data.styles import WatershedConfig as styles | |
| 982 | 983 | config = WatershedConfig() |
| 983 | 984 | dlg.WatershedOptionsDialog(config).Show() |
| 984 | 985 | ... | ... |
invesalius/gui/task_surface.py
| ... | ... | @@ -17,19 +17,20 @@ |
| 17 | 17 | # detalhes. |
| 18 | 18 | #-------------------------------------------------------------------------- |
| 19 | 19 | import sys |
| 20 | +import os | |
| 20 | 21 | |
| 21 | 22 | import wx |
| 22 | 23 | import wx.lib.hyperlink as hl |
| 23 | 24 | from wx.lib.pubsub import pub as Publisher |
| 24 | 25 | |
| 25 | -import constants as const | |
| 26 | -import data.slice_ as slice_ | |
| 27 | -import gui.dialogs as dlg | |
| 28 | -import gui.widgets.foldpanelbar as fpb | |
| 29 | -import gui.widgets.colourselect as csel | |
| 30 | -import gui.widgets.platebtn as pbtn | |
| 31 | -import project as prj | |
| 32 | -import utils as utl | |
| 26 | +import invesalius.constants as const | |
| 27 | +import invesalius.data.slice_ as slice_ | |
| 28 | +import invesalius.gui.dialogs as dlg | |
| 29 | +import invesalius.gui.widgets.foldpanelbar as fpb | |
| 30 | +import invesalius.gui.widgets.colourselect as csel | |
| 31 | +import invesalius.gui.widgets.platebtn as pbtn | |
| 32 | +import invesalius.project as prj | |
| 33 | +import invesalius.utils as utl | |
| 33 | 34 | |
| 34 | 35 | #INTERPOLATION_MODE_LIST = ["Cubic", "Linear", "NearestNeighbor"] |
| 35 | 36 | MIN_TRANSPARENCY = 0 |
| ... | ... | @@ -73,7 +74,7 @@ class InnerTaskPanel(wx.Panel): |
| 73 | 74 | self.SetAutoLayout(1) |
| 74 | 75 | |
| 75 | 76 | |
| 76 | - BMP_ADD = wx.Bitmap("../icons/object_add.png", wx.BITMAP_TYPE_PNG) | |
| 77 | + BMP_ADD = wx.Bitmap(os.path.join(const.ICON_DIR, "object_add.png"), wx.BITMAP_TYPE_PNG) | |
| 77 | 78 | #BMP_ADD.SetWidth(25) |
| 78 | 79 | #BMP_ADD.SetHeight(25) |
| 79 | 80 | |
| ... | ... | @@ -134,7 +135,7 @@ class InnerTaskPanel(wx.Panel): |
| 134 | 135 | evt.Skip() |
| 135 | 136 | |
| 136 | 137 | def OnLinkNewSurface(self, evt=None): |
| 137 | - #import gui.dialogs as dlg | |
| 138 | + #import invesalius.gui.dialogs as dlg | |
| 138 | 139 | sl = slice_.Slice() |
| 139 | 140 | dialog = dlg.SurfaceCreationDialog(None, -1, |
| 140 | 141 | _('New surface'), |
| ... | ... | @@ -299,17 +300,17 @@ class SurfaceTools(wx.Panel): |
| 299 | 300 | link_seeds.Bind(hl.EVT_HYPERLINK_LEFT, self.OnLinkSeed) |
| 300 | 301 | |
| 301 | 302 | # Image(s) for buttons |
| 302 | - img_largest = wx.Image("../icons/connectivity_largest.png", | |
| 303 | + img_largest = wx.Image(os.path.join(const.ICON_DIR, "connectivity_largest.png"), | |
| 303 | 304 | wx.BITMAP_TYPE_PNG) |
| 304 | 305 | img_largest.Rescale(25, 25) |
| 305 | 306 | bmp_largest = img_largest.ConvertToBitmap() |
| 306 | 307 | |
| 307 | - img_split_all = wx.Image("../icons/connectivity_split_all.png", | |
| 308 | + img_split_all = wx.Image(os.path.join(const.ICON_DIR, "connectivity_split_all.png"), | |
| 308 | 309 | wx.BITMAP_TYPE_PNG) |
| 309 | 310 | img_split_all.Rescale(25, 25) |
| 310 | 311 | bmp_split_all = img_split_all.ConvertToBitmap() |
| 311 | 312 | |
| 312 | - img_seeds = wx.Image("../icons/connectivity_manual.png", | |
| 313 | + img_seeds = wx.Image(os.path.join(const.ICON_DIR, "connectivity_manual.png"), | |
| 313 | 314 | wx.BITMAP_TYPE_PNG) |
| 314 | 315 | img_seeds.Rescale(25, 25) |
| 315 | 316 | bmp_seeds = img_seeds.ConvertToBitmap() |
| ... | ... | @@ -556,7 +557,7 @@ class SurfaceProperties(wx.Panel): |
| 556 | 557 | |
| 557 | 558 | class QualityAdjustment(wx.Panel): |
| 558 | 559 | def __init__(self, parent): |
| 559 | - import constants as const | |
| 560 | + import invesalius.constants as const | |
| 560 | 561 | wx.Panel.__init__(self, parent) |
| 561 | 562 | default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR) |
| 562 | 563 | self.SetBackgroundColour(default_colour) | ... | ... |
invesalius/gui/task_tools.py
| ... | ... | @@ -18,12 +18,14 @@ |
| 18 | 18 | #-------------------------------------------------------------------------- |
| 19 | 19 | |
| 20 | 20 | import wx |
| 21 | +import os | |
| 21 | 22 | import wx.lib.embeddedimage as emb |
| 22 | 23 | import wx.lib.hyperlink as hl |
| 23 | 24 | import wx.lib.platebtn as pbtn |
| 24 | 25 | from wx.lib.pubsub import pub as Publisher |
| 25 | 26 | |
| 26 | -import constants | |
| 27 | +import invesalius.constants as constants | |
| 28 | +import invesalius.constants as const | |
| 27 | 29 | |
| 28 | 30 | ID_BTN_MEASURE_LINEAR = wx.NewId() |
| 29 | 31 | ID_BTN_MEASURE_ANGULAR = wx.NewId() |
| ... | ... | @@ -71,9 +73,9 @@ class InnerTaskPanel(wx.Panel): |
| 71 | 73 | txt_annotation.Bind(hl.EVT_HYPERLINK_LEFT, self.OnTextAnnotation) |
| 72 | 74 | |
| 73 | 75 | # Image(s) for buttons |
| 74 | - BMP_ANNOTATE = wx.Bitmap("../icons/annotation.png", wx.BITMAP_TYPE_PNG) | |
| 75 | - BMP_ANGLE = wx.Bitmap("../icons/measure_angle.jpg", wx.BITMAP_TYPE_JPEG) | |
| 76 | - BMP_DISTANCE = wx.Bitmap("../icons/measure_line.png", wx.BITMAP_TYPE_PNG) | |
| 76 | + BMP_ANNOTATE = wx.Bitmap(os.path.join(const.ICON_DIR, "annotation.png"), wx.BITMAP_TYPE_PNG) | |
| 77 | + BMP_ANGLE = wx.Bitmap(os.path.join(const.ICON_DIR, "measure_angle.jpg"), wx.BITMAP_TYPE_JPEG) | |
| 78 | + BMP_DISTANCE = wx.Bitmap(os.path.join(const.ICON_DIR, "measure_line.png"), wx.BITMAP_TYPE_PNG) | |
| 77 | 79 | BMP_ANNOTATE.SetWidth(25) |
| 78 | 80 | BMP_ANNOTATE.SetHeight(25) |
| 79 | 81 | BMP_ANGLE.SetWidth(25) | ... | ... |
invesalius/gui/widgets/clut_raycasting.py
| ... | ... | @@ -26,8 +26,8 @@ import numpy |
| 26 | 26 | import wx |
| 27 | 27 | from wx.lib.pubsub import pub as Publisher |
| 28 | 28 | |
| 29 | -import gui.dialogs as dialog | |
| 30 | -import constants as const | |
| 29 | +import invesalius.gui.dialogs as dialog | |
| 30 | +import invesalius.constants as const | |
| 31 | 31 | |
| 32 | 32 | FONT_COLOUR = (1, 1, 1) |
| 33 | 33 | LINE_COLOUR = (128, 128, 128) | ... | ... |
invesalius/gui/widgets/slice_menu.py
| ... | ... | @@ -29,12 +29,10 @@ except(ImportError): |
| 29 | 29 | import wx |
| 30 | 30 | from wx.lib.pubsub import pub as Publisher |
| 31 | 31 | |
| 32 | -import constants as const | |
| 33 | -import data.slice_ as sl | |
| 34 | -import presets | |
| 35 | - | |
| 36 | -from gui.dialogs import ClutImagedataDialog | |
| 37 | - | |
| 32 | +import invesalius.constants as const | |
| 33 | +import invesalius.data.slice_ as sl | |
| 34 | +import invesalius.presets as presets | |
| 35 | +from invesalius.gui.dialogs import ClutImagedataDialog as dialogs | |
| 38 | 36 | PROJECTIONS_ID = OrderedDict(((_('Normal'), const.PROJECTION_NORMAL), |
| 39 | 37 | (_('MaxIP'), const.PROJECTION_MaxIP), |
| 40 | 38 | (_('MinIP'), const.PROJECTION_MinIP), | ... | ... |
invesalius/i18n.py
| ... | ... | @@ -26,7 +26,7 @@ import gettext |
| 26 | 26 | import os |
| 27 | 27 | import sys |
| 28 | 28 | |
| 29 | -import utils as utl | |
| 29 | +import invesalius.utils as utl | |
| 30 | 30 | |
| 31 | 31 | def GetLocales(): |
| 32 | 32 | """Return a dictionary which defines supported languages""" |
| ... | ... | @@ -58,8 +58,23 @@ def GetLocaleOS(): |
| 58 | 58 | |
| 59 | 59 | return locale.getdefaultlocale()[0] |
| 60 | 60 | |
| 61 | -def InstallLanguage(language): | |
| 62 | - language_dir = os.path.abspath(os.path.join('..','locale')) | |
| 61 | +def InstallLanguage(language): | |
| 62 | + file_path = os.path.split(__file__)[0] | |
| 63 | + | |
| 64 | + if hasattr(sys,"frozen") and (sys.frozen == "windows_exe"\ | |
| 65 | + or sys.frozen == "console_exe"): | |
| 66 | + | |
| 67 | + abs_file_path = os.path.abspath(file_path + os.sep + ".." + os.sep + ".." + os.sep + "..") | |
| 68 | + language_dir = os.path.join(abs_file_path, 'locale') | |
| 69 | + else: | |
| 70 | + abs_file_path = os.path.abspath(file_path + os.sep + "..") | |
| 71 | + language_dir = os.path.join(abs_file_path, 'locale') | |
| 72 | + | |
| 73 | + # MAC App | |
| 74 | + if not os.path.exists(language_dir): | |
| 75 | + abs_file_path = os.path.abspath(os.path.join(file_path, '..', '..', '..', '..')) | |
| 76 | + language_dir = os.path.join(abs_file_path, 'locale') | |
| 77 | + | |
| 63 | 78 | lang = gettext.translation('invesalius', language_dir,\ |
| 64 | 79 | languages=[language], codeset='utf8') |
| 65 | 80 | # Using unicode | ... | ... |
invesalius/invesalius.py
| ... | ... | @@ -1,320 +0,0 @@ |
| 1 | -#!/usr/bin/python | |
| 2 | -#-------------------------------------------------------------------------- | |
| 3 | -# Software: InVesalius - Software de Reconstrucao 3D de Imagens Medicas | |
| 4 | -# Copyright: (C) 2001 Centro de Pesquisas Renato Archer | |
| 5 | -# Homepage: http://www.softwarepublico.gov.br | |
| 6 | -# Contact: invesalius@cti.gov.br | |
| 7 | -# License: GNU - GPL 2 (LICENSE.txt/LICENCA.txt) | |
| 8 | -#-------------------------------------------------------------------------- | |
| 9 | -# Este programa e software livre; voce pode redistribui-lo e/ou | |
| 10 | -# modifica-lo sob os termos da Licenca Publica Geral GNU, conforme | |
| 11 | -# publicada pela Free Software Foundation; de acordo com a versao 2 | |
| 12 | -# da Licenca. | |
| 13 | -# | |
| 14 | -# Este programa eh distribuido na expectativa de ser util, mas SEM | |
| 15 | -# QUALQUER GARANTIA; sem mesmo a garantia implicita de | |
| 16 | -# COMERCIALIZACAO ou de ADEQUACAO A QUALQUER PROPOSITO EM | |
| 17 | -# PARTICULAR. Consulte a Licenca Publica Geral GNU para obter mais | |
| 18 | -# detalhes. | |
| 19 | -#------------------------------------------------------------------------- | |
| 20 | - | |
| 21 | - | |
| 22 | -import multiprocessing | |
| 23 | -import optparse as op | |
| 24 | -import os | |
| 25 | -import sys | |
| 26 | -import shutil | |
| 27 | - | |
| 28 | -if sys.platform == 'win32': | |
| 29 | - import _winreg | |
| 30 | -else: | |
| 31 | - if sys.platform != 'darwin': | |
| 32 | - import wxversion | |
| 33 | - #wxversion.ensureMinimal('2.8-unicode', optionsRequired=True) | |
| 34 | - #wxversion.select('2.8-unicode', optionsRequired=True) | |
| 35 | - wxversion.ensureMinimal('3.0') | |
| 36 | - | |
| 37 | -import wx | |
| 38 | -#from wx.lib.pubsub import setupv1 #new wx | |
| 39 | -from wx.lib.pubsub import setuparg1# as psv1 | |
| 40 | -#from wx.lib.pubsub import Publisher | |
| 41 | -#import wx.lib.pubsub as ps | |
| 42 | -from wx.lib.pubsub import pub as Publisher | |
| 43 | - | |
| 44 | -#import wx.lib.agw.advancedsplash as agw | |
| 45 | -#if sys.platform == 'linux2': | |
| 46 | -# _SplashScreen = agw.AdvancedSplash | |
| 47 | -#else: | |
| 48 | -# if sys.platform != 'darwin': | |
| 49 | -# _SplashScreen = wx.SplashScreen | |
| 50 | - | |
| 51 | - | |
| 52 | -import gui.language_dialog as lang_dlg | |
| 53 | -import i18n | |
| 54 | -import session as ses | |
| 55 | -import utils | |
| 56 | - | |
| 57 | -# ------------------------------------------------------------------ | |
| 58 | - | |
| 59 | - | |
| 60 | -class InVesalius(wx.App): | |
| 61 | - """ | |
| 62 | - InVesalius wxPython application class. | |
| 63 | - """ | |
| 64 | - def OnInit(self): | |
| 65 | - """ | |
| 66 | - Initialize splash screen and main frame. | |
| 67 | - """ | |
| 68 | - self.SetAppName("InVesalius 3") | |
| 69 | - self.splash = SplashScreen() | |
| 70 | - self.splash.Show() | |
| 71 | - wx.CallLater(1000,self.Startup2) | |
| 72 | - | |
| 73 | - return True | |
| 74 | - | |
| 75 | - def MacOpenFile(self, filename): | |
| 76 | - """ | |
| 77 | - Open drag & drop files under darwin | |
| 78 | - """ | |
| 79 | - path = os.path.abspath(filename) | |
| 80 | - Publisher.sendMessage('Open project', path) | |
| 81 | - | |
| 82 | - def Startup2(self): | |
| 83 | - self.control = self.splash.control | |
| 84 | - self.frame = self.splash.main | |
| 85 | - self.SetTopWindow(self.frame) | |
| 86 | - self.frame.Show() | |
| 87 | - self.frame.Raise() | |
| 88 | - | |
| 89 | -# ------------------------------------------------------------------ | |
| 90 | - | |
| 91 | -class SplashScreen(wx.SplashScreen): | |
| 92 | - """ | |
| 93 | - Splash screen to be shown in InVesalius initialization. | |
| 94 | - """ | |
| 95 | - def __init__(self): | |
| 96 | - # Splash screen image will depend on currently language | |
| 97 | - lang = False | |
| 98 | - | |
| 99 | - # Language information is available in session configuration | |
| 100 | - # file. First we need to check if this file exist, if now, it | |
| 101 | - # should be created | |
| 102 | - create_session = False | |
| 103 | - session = ses.Session() | |
| 104 | - if not (session.ReadSession()): | |
| 105 | - create_session = True | |
| 106 | - | |
| 107 | - install_lang = 0 | |
| 108 | - # Check if there is a language set (if session file exists | |
| 109 | - if session.ReadLanguage(): | |
| 110 | - lang = session.GetLanguage() | |
| 111 | - if (lang != "False"): | |
| 112 | - _ = i18n.InstallLanguage(lang) | |
| 113 | - install_lang = 1 | |
| 114 | - else: | |
| 115 | - install_lang = 0 | |
| 116 | - else: | |
| 117 | - install_lang = 0 | |
| 118 | - | |
| 119 | - # If no language is set into session file, show dialog so | |
| 120 | - # user can select language | |
| 121 | - if install_lang == 0: | |
| 122 | - dialog = lang_dlg.LanguageDialog() | |
| 123 | - | |
| 124 | - # FIXME: This works ok in linux2, darwin and win32, | |
| 125 | - # except on win64, due to wxWidgets bug | |
| 126 | - try: | |
| 127 | - ok = (dialog.ShowModal() == wx.ID_OK) | |
| 128 | - except wx._core.PyAssertionError: | |
| 129 | - ok = True | |
| 130 | - finally: | |
| 131 | - if ok: | |
| 132 | - lang = dialog.GetSelectedLanguage() | |
| 133 | - session.SetLanguage(lang) | |
| 134 | - _ = i18n.InstallLanguage(lang) | |
| 135 | - else: | |
| 136 | - homedir = self.homedir = os.path.expanduser('~') | |
| 137 | - invdir = os.path.join(homedir, ".invesalius") | |
| 138 | - shutil.rmtree(invdir) | |
| 139 | - sys.exit() | |
| 140 | - | |
| 141 | - # Session file should be created... So we set the recent | |
| 142 | - # choosen language | |
| 143 | - if (create_session): | |
| 144 | - session.CreateItens() | |
| 145 | - session.SetLanguage(lang) | |
| 146 | - session.WriteSessionFile() | |
| 147 | - | |
| 148 | - session.SaveConfigFileBackup() | |
| 149 | - | |
| 150 | - | |
| 151 | - # Only after language was defined, splash screen will be | |
| 152 | - # shown | |
| 153 | - if lang: | |
| 154 | - # For pt_BR, splash_pt.png should be used | |
| 155 | - if (lang.startswith('pt')): | |
| 156 | - icon_file = "splash_pt.png" | |
| 157 | - else: | |
| 158 | - icon_file = "splash_" + lang + ".png" | |
| 159 | - | |
| 160 | - path = os.path.join("..","icons", icon_file) | |
| 161 | - | |
| 162 | - if not os.path.exists(path): | |
| 163 | - path = os.path.join("..", "icons", "splash_en.png") | |
| 164 | - | |
| 165 | - bmp = wx.Image(path).ConvertToBitmap() | |
| 166 | - | |
| 167 | - style = wx.SPLASH_TIMEOUT | wx.SPLASH_CENTRE_ON_SCREEN | |
| 168 | - wx.SplashScreen.__init__(self, | |
| 169 | - bitmap=bmp, | |
| 170 | - splashStyle=style, | |
| 171 | - milliseconds=1500, | |
| 172 | - id=-1, | |
| 173 | - parent=None) | |
| 174 | - self.Bind(wx.EVT_CLOSE, self.OnClose) | |
| 175 | - wx.Yield() | |
| 176 | - wx.CallLater(200,self.Startup) | |
| 177 | - | |
| 178 | - def Startup(self): | |
| 179 | - # Importing takes sometime, therefore it will be done | |
| 180 | - # while splash is being shown | |
| 181 | - from gui.frame import Frame | |
| 182 | - from control import Controller | |
| 183 | - from project import Project | |
| 184 | - | |
| 185 | - self.main = Frame(None) | |
| 186 | - self.control = Controller(self.main) | |
| 187 | - | |
| 188 | - self.fc = wx.FutureCall(1, self.ShowMain) | |
| 189 | - wx.FutureCall(1, parse_comand_line) | |
| 190 | - | |
| 191 | - # Check for updates | |
| 192 | - from threading import Thread | |
| 193 | - p = Thread(target=utils.UpdateCheck, args=()) | |
| 194 | - p.start() | |
| 195 | - | |
| 196 | - def OnClose(self, evt): | |
| 197 | - # Make sure the default handler runs too so this window gets | |
| 198 | - # destroyed | |
| 199 | - evt.Skip() | |
| 200 | - self.Hide() | |
| 201 | - | |
| 202 | - # If the timer is still running then go ahead and show the | |
| 203 | - # main frame now | |
| 204 | - if self.fc.IsRunning(): | |
| 205 | - self.fc.Stop() | |
| 206 | - self.ShowMain() | |
| 207 | - | |
| 208 | - def ShowMain(self): | |
| 209 | - # Show main frame | |
| 210 | - self.main.Show() | |
| 211 | - | |
| 212 | - if self.fc.IsRunning(): | |
| 213 | - self.Raise() | |
| 214 | - | |
| 215 | -# ------------------------------------------------------------------ | |
| 216 | - | |
| 217 | - | |
| 218 | -def parse_comand_line(): | |
| 219 | - """ | |
| 220 | - Handle command line arguments. | |
| 221 | - """ | |
| 222 | - session = ses.Session() | |
| 223 | - | |
| 224 | - # Parse command line arguments | |
| 225 | - parser = op.OptionParser() | |
| 226 | - | |
| 227 | - # -d or --debug: print all pubsub messagessent | |
| 228 | - parser.add_option("-d", "--debug", | |
| 229 | - action="store_true", | |
| 230 | - dest="debug") | |
| 231 | - | |
| 232 | - # -i or --import: import DICOM directory | |
| 233 | - # chooses largest series | |
| 234 | - parser.add_option("-i", "--import", | |
| 235 | - action="store", | |
| 236 | - dest="dicom_dir") | |
| 237 | - options, args = parser.parse_args() | |
| 238 | - | |
| 239 | - # If debug argument... | |
| 240 | - if options.debug: | |
| 241 | - Publisher.subscribe(print_events, Publisher.ALL_TOPICS) | |
| 242 | - session.debug = 1 | |
| 243 | - | |
| 244 | - # If import DICOM argument... | |
| 245 | - if options.dicom_dir: | |
| 246 | - import_dir = options.dicom_dir | |
| 247 | - Publisher.sendMessage('Import directory', import_dir) | |
| 248 | - return True | |
| 249 | - | |
| 250 | - # Check if there is a file path somewhere in what the user wrote | |
| 251 | - # In case there is, try opening as it was a inv3 | |
| 252 | - else: | |
| 253 | - i = len(args) | |
| 254 | - while i: | |
| 255 | - i -= 1 | |
| 256 | - file = args[i] | |
| 257 | - if os.path.isfile(file): | |
| 258 | - path = os.path.abspath(file) | |
| 259 | - Publisher.sendMessage('Open project', path) | |
| 260 | - i = 0 | |
| 261 | - return True | |
| 262 | - return False | |
| 263 | - | |
| 264 | - | |
| 265 | -def print_events(data): | |
| 266 | - """ | |
| 267 | - Print pubsub messages | |
| 268 | - """ | |
| 269 | - utils.debug(data.topic) | |
| 270 | - | |
| 271 | -def main(): | |
| 272 | - """ | |
| 273 | - Initialize InVesalius GUI | |
| 274 | - """ | |
| 275 | - application = InVesalius(0) | |
| 276 | - application.MainLoop() | |
| 277 | - | |
| 278 | -if __name__ == '__main__': | |
| 279 | - # Needed in win 32 exe | |
| 280 | - if hasattr(sys,"frozen") and (sys.frozen == "windows_exe"\ | |
| 281 | - or sys.frozen == "console_exe"): | |
| 282 | - multiprocessing.freeze_support() | |
| 283 | - | |
| 284 | - #Click in the .inv3 file support | |
| 285 | - root = _winreg.HKEY_CLASSES_ROOT | |
| 286 | - key = "InVesalius 3.0\InstallationDir" | |
| 287 | - hKey = _winreg.OpenKey (root, key, 0, _winreg.KEY_READ) | |
| 288 | - value, type_ = _winreg.QueryValueEx (hKey, "") | |
| 289 | - path = os.path.join(value,'dist') | |
| 290 | - | |
| 291 | - os.chdir(path) | |
| 292 | - | |
| 293 | - # Create raycasting presets' folder, if it doens't exist | |
| 294 | - dirpath = os.path.join(os.path.expanduser('~'), | |
| 295 | - ".invesalius", | |
| 296 | - "presets") | |
| 297 | - if not os.path.isdir(dirpath): | |
| 298 | - os.makedirs(dirpath) | |
| 299 | - | |
| 300 | - # Create logs' folder, if it doesn't exist | |
| 301 | - dirpath = os.path.join(os.path.expanduser('~'), | |
| 302 | - ".invesalius", | |
| 303 | - "logs") | |
| 304 | - if not os.path.isdir(dirpath): | |
| 305 | - os.makedirs(dirpath) | |
| 306 | - | |
| 307 | - if hasattr(sys,"frozen") and sys.frozen == "windows_exe": | |
| 308 | - # Set system standard error output to file | |
| 309 | - path = os.path.join(dirpath, "stderr.log") | |
| 310 | - sys.stderr = open(path, "w") | |
| 311 | - | |
| 312 | - # Add current directory to PYTHONPATH, so other classes can | |
| 313 | - # import modules as they were on root invesalius folder | |
| 314 | - sys.path.insert(0, '..') | |
| 315 | - sys.path.append(".") | |
| 316 | - | |
| 317 | - | |
| 318 | - # Init application | |
| 319 | - main() | |
| 320 | - |
invesalius/net/dicom.py
| 1 | 1 | import gdcm |
| 2 | -import utils | |
| 3 | - | |
| 2 | +import invesalius.utils as utils | |
| 4 | 3 | |
| 5 | 4 | class DicomNet: |
| 6 | 5 | |
| ... | ... | @@ -110,7 +109,6 @@ class DicomNet: |
| 110 | 109 | acquisition_date = utils.format_date(self.GetValueFromDICOM(rt, (0x0008,0x0022))) |
| 111 | 110 | |
| 112 | 111 | teste = self.GetValueFromDICOM(rt, (0x0020,0x000d)) |
| 113 | - print ">>>>>>>>>>>>>>>>>>>>", teste | |
| 114 | 112 | |
| 115 | 113 | patients[patient_id][serie_id] = {'name':name, 'age':age, 'gender':gender,\ |
| 116 | 114 | 'study_description':study_description,\ |
| ... | ... | @@ -146,11 +144,6 @@ class DicomNet: |
| 146 | 144 | patient_id = str(values[0]) |
| 147 | 145 | serie_id = str(values[1]) |
| 148 | 146 | |
| 149 | - print "(0x0010, 0x0020)",patient_id | |
| 150 | - | |
| 151 | - print "(0x0020, 0x000e)",serie_id | |
| 152 | - print "\n\n" | |
| 153 | - | |
| 154 | 147 | de_patient.SetByteValue(patient_id, gdcm.VL(len(patient_id))) |
| 155 | 148 | de_serie.SetByteValue(serie_id, gdcm.VL(len(serie_id))) |
| 156 | 149 | ... | ... |
invesalius/presets.py
| ... | ... | @@ -20,12 +20,11 @@ import glob |
| 20 | 20 | import os |
| 21 | 21 | import plistlib |
| 22 | 22 | |
| 23 | -import constants as const | |
| 23 | +import invesalius.constants as const | |
| 24 | 24 | |
| 25 | 25 | from wx.lib.pubsub import pub as Publisher |
| 26 | 26 | |
| 27 | -from utils import TwoWaysDictionary | |
| 28 | - | |
| 27 | +from invesalius.utils import TwoWaysDictionary | |
| 29 | 28 | class Presets(): |
| 30 | 29 | |
| 31 | 30 | def __init__(self): | ... | ... |
invesalius/project.py
| ... | ... | @@ -29,13 +29,11 @@ import wx |
| 29 | 29 | from wx.lib.pubsub import pub as Publisher |
| 30 | 30 | import vtk |
| 31 | 31 | |
| 32 | -import constants as const | |
| 33 | -import data.mask as msk | |
| 34 | -import data.polydata_utils as pu | |
| 35 | -import data.surface as srf | |
| 36 | -from presets import Presets | |
| 37 | -from utils import Singleton, debug | |
| 38 | -import version | |
| 32 | +import invesalius.constants as const | |
| 33 | +import invesalius.data.polydata_utils as pu | |
| 34 | +from invesalius.presets import Presets | |
| 35 | +from invesalius.utils import Singleton, debug | |
| 36 | +import invesalius.version as version | |
| 39 | 37 | |
| 40 | 38 | class Project(object): |
| 41 | 39 | # Only one project will be initialized per time. Therefore, we use |
| ... | ... | @@ -264,12 +262,13 @@ class Project(object): |
| 264 | 262 | |
| 265 | 263 | for f in filelist: |
| 266 | 264 | if filelist[f].endswith('.plist'): |
| 267 | - print f | |
| 268 | 265 | os.remove(f) |
| 269 | 266 | |
| 270 | 267 | def OpenPlistProject(self, filename): |
| 271 | - import data.measures as ms | |
| 272 | - | |
| 268 | + import invesalius.data.measures as ms | |
| 269 | + import invesalius.data.mask as msk | |
| 270 | + import invesalius.data.surface as srf | |
| 271 | + | |
| 273 | 272 | if not const.VTK_WARNING: |
| 274 | 273 | log_path = os.path.join(const.LOG_FOLDER, 'vtkoutput.txt') |
| 275 | 274 | fow = vtk.vtkFileOutputWindow() |
| ... | ... | @@ -358,7 +357,6 @@ def Extract(filename, folder): |
| 358 | 357 | del fsrc |
| 359 | 358 | del fdst |
| 360 | 359 | tar.close() |
| 361 | - print filelist | |
| 362 | 360 | return filelist |
| 363 | 361 | |
| 364 | 362 | ... | ... |
invesalius/reader/bitmap_reader.py
| ... | ... | @@ -23,7 +23,7 @@ import tempfile |
| 23 | 23 | import sys |
| 24 | 24 | import vtk |
| 25 | 25 | import re |
| 26 | -import constants as const | |
| 26 | +import invesalius.constants as const | |
| 27 | 27 | import wx |
| 28 | 28 | |
| 29 | 29 | from wx.lib.pubsub import pub as Publisher |
| ... | ... | @@ -34,9 +34,8 @@ from scipy import misc |
| 34 | 34 | import numpy |
| 35 | 35 | import imghdr |
| 36 | 36 | |
| 37 | -import utils | |
| 38 | -from data import converters | |
| 39 | - | |
| 37 | +import invesalius.utils as utils | |
| 38 | +import invesalius.data.converters as converters | |
| 40 | 39 | #flag to control vtk error in read files |
| 41 | 40 | no_error = True |
| 42 | 41 | vtk_error = False | ... | ... |
invesalius/reader/dicom.py
| ... | ... | @@ -21,8 +21,8 @@ import time |
| 21 | 21 | #import gdcm |
| 22 | 22 | #import vtkgdcm |
| 23 | 23 | import sys |
| 24 | -import utils | |
| 25 | -import constants as const | |
| 24 | +import invesalius.utils as utils | |
| 25 | +import invesalius.constants as const | |
| 26 | 26 | # In DICOM file format, if multiple values are present for the |
| 27 | 27 | # "Window Center" (Level) and "Window Width", both attributes |
| 28 | 28 | # shall have the same number of values and shall be considered as | ... | ... |
invesalius/reader/dicom_grouper.py
invesalius/reader/dicom_reader.py
| ... | ... | @@ -29,14 +29,12 @@ import vtkgdcm |
| 29 | 29 | import gdcm |
| 30 | 30 | from wx.lib.pubsub import pub as Publisher |
| 31 | 31 | |
| 32 | -import constants as const | |
| 33 | -import dicom | |
| 34 | -import dicom_grouper | |
| 35 | -import session | |
| 36 | - | |
| 32 | +import invesalius.constants as const | |
| 33 | +import invesalius.reader.dicom as dicom | |
| 34 | +import invesalius.reader.dicom_grouper as dicom_grouper | |
| 35 | +import invesalius.session as session | |
| 37 | 36 | import glob |
| 38 | -import utils | |
| 39 | - | |
| 37 | +import invesalius.utils as utils | |
| 40 | 38 | |
| 41 | 39 | import plistlib |
| 42 | 40 | |
| ... | ... | @@ -71,7 +69,7 @@ def SortFiles(filelist, dicom): |
| 71 | 69 | # Sort slices |
| 72 | 70 | # FIXME: Coronal Crash. necessary verify |
| 73 | 71 | if (dicom.image.orientation_label <> "CORONAL"): |
| 74 | - #Organize reversed image | |
| 72 | + ##Organize reversed image | |
| 75 | 73 | sorter = gdcm.IPPSorter() |
| 76 | 74 | sorter.SetComputeZSpacing(True) |
| 77 | 75 | sorter.SetZSpacingTolerance(1e-10) | ... | ... |
invesalius/session.py
| ... | ... | @@ -27,7 +27,7 @@ import time |
| 27 | 27 | #import wx.lib.pubsub as ps |
| 28 | 28 | from wx.lib.pubsub import pub as Publisher |
| 29 | 29 | |
| 30 | -from utils import Singleton, debug | |
| 30 | +from invesalius.utils import Singleton, debug | |
| 31 | 31 | from random import randint |
| 32 | 32 | |
| 33 | 33 | class Session(object): |
| ... | ... | @@ -42,7 +42,7 @@ class Session(object): |
| 42 | 42 | self.project_status = 3 |
| 43 | 43 | |
| 44 | 44 | def CreateItens(self): |
| 45 | - import constants as const | |
| 45 | + import invesalius.constants as const | |
| 46 | 46 | self.project_path = () |
| 47 | 47 | self.debug = False |
| 48 | 48 | self.project_status = const.PROJ_CLOSE |
| ... | ... | @@ -75,7 +75,7 @@ class Session(object): |
| 75 | 75 | self.WriteSessionFile() |
| 76 | 76 | |
| 77 | 77 | def IsOpen(self): |
| 78 | - import constants as const | |
| 78 | + import invesalius.constants as const | |
| 79 | 79 | return self.project_status != const.PROJ_CLOSE |
| 80 | 80 | |
| 81 | 81 | def SaveConfigFileBackup(self): |
| ... | ... | @@ -98,7 +98,7 @@ class Session(object): |
| 98 | 98 | return False |
| 99 | 99 | |
| 100 | 100 | def CloseProject(self): |
| 101 | - import constants as const | |
| 101 | + import invesalius.constants as const | |
| 102 | 102 | debug("Session.CloseProject") |
| 103 | 103 | self.project_path = () |
| 104 | 104 | self.project_status = const.PROJ_CLOSE |
| ... | ... | @@ -107,7 +107,7 @@ class Session(object): |
| 107 | 107 | self.WriteSessionFile() |
| 108 | 108 | |
| 109 | 109 | def SaveProject(self, path=()): |
| 110 | - import constants as const | |
| 110 | + import invesalius.constants as const | |
| 111 | 111 | debug("Session.SaveProject") |
| 112 | 112 | self.project_status = const.PROJ_OPEN |
| 113 | 113 | if path: |
| ... | ... | @@ -118,12 +118,12 @@ class Session(object): |
| 118 | 118 | self.WriteSessionFile() |
| 119 | 119 | |
| 120 | 120 | def ChangeProject(self): |
| 121 | - import constants as const | |
| 121 | + import invesalius.constants as const | |
| 122 | 122 | debug("Session.ChangeProject") |
| 123 | 123 | self.project_status = const.PROJ_CHANGE |
| 124 | 124 | |
| 125 | 125 | def CreateProject(self, filename): |
| 126 | - import constants as const | |
| 126 | + import invesalius.constants as const | |
| 127 | 127 | debug("Session.CreateProject") |
| 128 | 128 | Publisher.sendMessage('Begin busy cursor') |
| 129 | 129 | # Set session info |
| ... | ... | @@ -134,7 +134,7 @@ class Session(object): |
| 134 | 134 | return self.tempdir |
| 135 | 135 | |
| 136 | 136 | def OpenProject(self, filepath): |
| 137 | - import constants as const | |
| 137 | + import invesalius.constants as const | |
| 138 | 138 | debug("Session.OpenProject") |
| 139 | 139 | # Add item to recent projects list |
| 140 | 140 | item = (path, file) = os.path.split(filepath) |
| ... | ... | @@ -183,7 +183,7 @@ class Session(object): |
| 183 | 183 | configfile.close() |
| 184 | 184 | |
| 185 | 185 | def __add_to_list(self, item): |
| 186 | - import constants as const | |
| 186 | + import invesalius.constants as const | |
| 187 | 187 | # Last projects list |
| 188 | 188 | l = self.recent_projects |
| 189 | 189 | ... | ... |
invesalius/style.py
| ... | ... | @@ -1,112 +0,0 @@ |
| 1 | -#-------------------------------------------------------------------------- | |
| 2 | -# Software: InVesalius - Software de Reconstrucao 3D de Imagens Medicas | |
| 3 | -# Copyright: (C) 2001 Centro de Pesquisas Renato Archer | |
| 4 | -# Homepage: http://www.softwarepublico.gov.br | |
| 5 | -# Contact: invesalius@cti.gov.br | |
| 6 | -# License: GNU - GPL 2 (LICENSE.txt/LICENCA.txt) | |
| 7 | -#-------------------------------------------------------------------------- | |
| 8 | -# Este programa e software livre; voce pode redistribui-lo e/ou | |
| 9 | -# modifica-lo sob os termos da Licenca Publica Geral GNU, conforme | |
| 10 | -# publicada pela Free Software Foundation; de acordo com a versao 2 | |
| 11 | -# da Licenca. | |
| 12 | -# | |
| 13 | -# Este programa eh distribuido na expectativa de ser util, mas SEM | |
| 14 | -# QUALQUER GARANTIA; sem mesmo a garantia implicita de | |
| 15 | -# COMERCIALIZACAO ou de ADEQUACAO A QUALQUER PROPOSITO EM | |
| 16 | -# PARTICULAR. Consulte a Licenca Publica Geral GNU para obter mais | |
| 17 | -# detalhes. | |
| 18 | -#-------------------------------------------------------------------------- | |
| 19 | - | |
| 20 | -from wx.lib.pubsub import pub as Publisher | |
| 21 | - | |
| 22 | - | |
| 23 | -# mode.py | |
| 24 | -# to be instanced inside Controller (control.py) | |
| 25 | - | |
| 26 | - | |
| 27 | - | |
| 28 | -# IMPORTANT: When adding a new state, remember o insert it into LEVEL | |
| 29 | -# dictionary | |
| 30 | - | |
| 31 | - | |
| 32 | -# RULE: | |
| 33 | -# default is the only level 0 | |
| 34 | -# states controlled somehow by taskmenu are level 1 | |
| 35 | -# states controlled by toolbar are level 2 | |
| 36 | -#LEVEL = {SLICE_STATE_DEFAULT: 0, | |
| 37 | -# SLICE_STATE_EDITOR: 1, | |
| 38 | -# SLICE_STATE_WL: 2, | |
| 39 | -# SLICE_STATE_SPIN: 2, | |
| 40 | -# SLICE_STATE_ZOOM: 2, | |
| 41 | -# SLICE_STATE_ZOOM_SL: 2} | |
| 42 | -#---------------------- | |
| 43 | -# TODO: Add to viewer_slice.py: | |
| 44 | - | |
| 45 | -#ps.Publisher().subscribe(self.OnSetMode, 'Set slice mode') | |
| 46 | - | |
| 47 | -#def OnSetMode(self, pubsub_evt): | |
| 48 | -# mode = pubsub_evt.data | |
| 49 | - # according to mode, set cursor, interaction, etc | |
| 50 | -#---------------------- | |
| 51 | -# TODO: Add GUI classes (frame, tasks related to slice, toolbar): | |
| 52 | - | |
| 53 | -# always bind to this class (regarding slice mode) and not to | |
| 54 | -# viewer_slice directly | |
| 55 | - | |
| 56 | -# example - pseudo code | |
| 57 | -#def OnToggleButtonSpin(self, evt) | |
| 58 | -# if evt.toggle: # doesn't exist, just to illustrate | |
| 59 | -# ps.Publisher().sendMessage('Enable mode', const.SLICE_STATE_ZOOM) | |
| 60 | -# else: | |
| 61 | -# ps.Publisher().subscribe('Disable mode', const.SLICE_STATE_ZOOM) | |
| 62 | - | |
| 63 | - | |
| 64 | -#---------------------- | |
| 65 | - | |
| 66 | - | |
| 67 | -import constants as const | |
| 68 | - | |
| 69 | -class StyleStateManager(object): | |
| 70 | -# don't need to be singleton, only needs to be instantiated inside | |
| 71 | -# (Controller) self.slice_mode = SliceMode() | |
| 72 | - | |
| 73 | - def __init__(self): | |
| 74 | - self.stack = {} | |
| 75 | - | |
| 76 | - # push default value to stack | |
| 77 | - self.stack[const.STYLE_LEVEL[const.STATE_DEFAULT]] = \ | |
| 78 | - const.STATE_DEFAULT | |
| 79 | - | |
| 80 | - def AddState(self, state): | |
| 81 | - | |
| 82 | - level = const.STYLE_LEVEL[state] | |
| 83 | - max_level = max(self.stack.keys()) | |
| 84 | - | |
| 85 | - # Insert new state into stack | |
| 86 | - self.stack[level] = state | |
| 87 | - | |
| 88 | - | |
| 89 | - new_max_level = max(self.stack.keys()) | |
| 90 | - return self.stack[new_max_level] | |
| 91 | - | |
| 92 | - def RemoveState(self, state): | |
| 93 | - level = const.STYLE_LEVEL[state] | |
| 94 | - if level in self.stack.keys(): | |
| 95 | - max_level = max(self.stack.keys()) | |
| 96 | - | |
| 97 | - # Remove item from stack | |
| 98 | - self.stack.pop(level) | |
| 99 | - | |
| 100 | - # New max level | |
| 101 | - new_max_level = max(self.stack.keys()) | |
| 102 | - | |
| 103 | - # Only will affect InVesalius behaviour if the highest | |
| 104 | - # level in stack has been removed | |
| 105 | - if level == max_level: | |
| 106 | - new_state = self.stack[new_max_level] | |
| 107 | - | |
| 108 | - return self.stack[new_max_level] | |
| 109 | - | |
| 110 | - max_level = max(self.stack.keys()) | |
| 111 | - return self.stack[max_level] | |
| 112 | - |
invesalius/utils.py
| ... | ... | @@ -71,10 +71,9 @@ def debug(error_str): |
| 71 | 71 | Redirects output to file, or to the terminal |
| 72 | 72 | This should be used in the place of "print" |
| 73 | 73 | """ |
| 74 | - from session import Session | |
| 74 | + from invesalius.session import Session | |
| 75 | 75 | session = Session() |
| 76 | 76 | #if session.debug: |
| 77 | - print >> sys.stderr, error_str | |
| 78 | 77 | |
| 79 | 78 | def next_copy_name(original_name, names_list): |
| 80 | 79 | """ |
| ... | ... | @@ -372,8 +371,9 @@ def UpdateCheck(): |
| 372 | 371 | import urllib |
| 373 | 372 | import urllib2 |
| 374 | 373 | import wx |
| 374 | + import invesalius.session as ses | |
| 375 | 375 | def _show_update_info(): |
| 376 | - from gui import dialogs | |
| 376 | + from invesalius.gui import dialogs | |
| 377 | 377 | msg=_("A new version of InVesalius is available. Do you want to open the download website now?") |
| 378 | 378 | title=_("Invesalius Update") |
| 379 | 379 | msgdlg = dialogs.UpdateMessageDialog(url) |
| ... | ... | @@ -385,8 +385,7 @@ def UpdateCheck(): |
| 385 | 385 | print "Checking updates..." |
| 386 | 386 | |
| 387 | 387 | # Check if there is a language set |
| 388 | - #import i18n | |
| 389 | - import session as ses | |
| 388 | + #import invesalius.i18n as i18n import invesalius.session as ses | |
| 390 | 389 | session = ses.Session() |
| 391 | 390 | install_lang = 0 |
| 392 | 391 | if session.ReadLanguage(): |
| ... | ... | @@ -400,7 +399,7 @@ def UpdateCheck(): |
| 400 | 399 | random_id = session.GetRandomId() |
| 401 | 400 | |
| 402 | 401 | # Fetch update data from server |
| 403 | - import constants as const | |
| 402 | + import invesalius.constants as const | |
| 404 | 403 | url = "http://www.cti.gov.br/dt3d/invesalius/update/checkupdate.php" |
| 405 | 404 | headers = { 'User-Agent' : 'Mozilla/5.0 (compatible; MSIE 5.5; Windows NT)' } |
| 406 | 405 | data = {'update_protocol_version' : '1', | ... | ... |