Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

BUG: make sure precache tags are set for database instances

Since the precache tags are specific to the ctkDICOMDatabase,
be sure to set the correct values to both slicer.app.dicomDatabase
and the database that is internal to the ctkDICOMAppWidget.

Need to use a timer here, because we want to ensure that all plugins
(which are modules) have been discovered before we set the precache
tags.

git-svn-id: http://svn.slicer.org/Slicer4/trunk@21526 3bd1e089-480b-0410-8dfb-8563597acbee
  • Loading branch information...
commit e7c817c0410c66defd751af3fa9ccca1e6f77a9e 1 parent 6e34166
pieper authored
Showing with 22 additions and 16 deletions.
  1. +22 −16 Modules/Scripted/Scripts/DICOM.py
38 Modules/Scripted/Scripts/DICOM.py
View
@@ -16,6 +16,23 @@
#
class DICOM:
+
+ @staticmethod
+ def setDatabasePrecacheTags(dicomApp=None):
+ """query each plugin for tags that should be cached on import
+ and set them for the dicom app widget and slicer"""
+ if not slicer.dicomDatabase:
+ return
+ tagsToPrecache = list(slicer.dicomDatabase.tagsToPrecache)
+ for pluginClass in slicer.modules.dicomPlugins:
+ plugin = slicer.modules.dicomPlugins[pluginClass]()
+ tagsToPrecache += plugin.tags.values()
+ tagsToPrecache = list(set(tagsToPrecache)) # remove duplicates
+ tagsToPrecache.sort()
+ slicer.dicomDatabase.tagsToPrecache = tagsToPrecache
+ if dicomApp:
+ dicomApp.tagsToPrecache = tagsToPrecache
+
def __init__(self, parent):
import string
parent.title = "DICOM"
@@ -62,7 +79,9 @@ def __init__(self, parent):
# Trigger the menu to be added when application has started up
if not slicer.app.commandOptions().noMainWindow :
- qt.QTimer.singleShot(0, self.addMenu);
+ qt.QTimer.singleShot(0, self.addMenu)
+ # set the dicom pre-cache tags once all plugin classes have been initialized
+ qt.QTimer.singleShot(0, DICOM.setDatabasePrecacheTags)
def addMenu(self):
#actionIcon = self.parent.icon
@@ -200,6 +219,7 @@ def setup(self):
# in the CTK code to avoid the findChildren calls
#
self.dicomApp = ctk.ctkDICOMAppWidget()
+ DICOM.setDatabasePrecacheTags(self.dicomApp)
if self.hideSearch:
# hide the search options - doesn't work yet and doesn't fit
# well into the frame
@@ -299,7 +319,7 @@ def onResumeModelRequestTimeout(self):
def onDatabaseDirectoryChanged(self,databaseDirectory):
if not hasattr(slicer, 'dicomDatabase') or not slicer.dicomDatabase:
slicer.dicomDatabase = ctk.ctkDICOMDatabase()
- self.setDatabasePrecacheTags()
+ DICOM.setDatabasePrecacheTags(self.dicomApp)
databaseFilepath = databaseDirectory + "/ctkDICOM.sql"
messages = ""
if not os.path.exists(databaseDirectory):
@@ -330,20 +350,6 @@ def onDatabaseDirectoryChanged(self,databaseDirectory):
if slicer.dicomDatabase:
slicer.app.setDICOMDatabase(slicer.dicomDatabase)
- def setDatabasePrecacheTags(self):
- """query each plugin for tags that should be cached on import
- and set them for the dicom app widget and slicer"""
- tagsToPrecache = list(slicer.dicomDatabase.tagsToPrecache)
- for pluginClass in slicer.modules.dicomPlugins:
- plugin = slicer.modules.dicomPlugins[pluginClass]()
- tagsToPrecache += plugin.tags.values()
- tagsToPrecache = list(set(tagsToPrecache)) # remove duplicates
- tagsToPrecache.sort()
- if hasattr(slicer, 'dicomDatabase'):
- slicer.dicomDatabase.tagsToPrecache = tagsToPrecache
- if self.dicomApp:
- self.dicomApp.tagsToPrecache = tagsToPrecache
-
def promptForDatabaseDirectory(self):
"""Ask the user to pick a database directory.
But, if the application is in testing mode, just pick
Please sign in to comment.
Something went wrong with that request. Please try again.