Commit 96ef77a9 authored by pieper's avatar pieper
Browse files

ENH: fix undo/redo display name (was PreviousCheckPoint/NextCheckPoint) and...

ENH: fix undo/redo display name (was PreviousCheckPoint/NextCheckPoint) and fix enable/disable of undo/redo buttons

git-svn-id: 3bd1e089-480b-0410-8dfb-8563597acbee
parent 2e377864
......@@ -36,6 +36,7 @@ class EditBox(object):
def __init__(self, parent=0, optionsFrame=None, embedded=False, suppliedEffects=[]):
self.effects = []
self.effectButtons = {}
self.effectMapper = qt.QSignalMapper()
self.effectMapper.connect('mapped(const QString&)', self.selectEffect)
self.editUtil = EditUtil.EditUtil()
......@@ -114,6 +115,11 @@ class EditBox(object):
"ToggleLabelOutline", "Watershed", "Wand", "GrowCutSegment",
# allow overriding the developers name of the tool for a more user-friendly label name
displayNames = {}
displayNames["PreviousCheckPoint"] = "Undo"
displayNames["NextCheckPoint"] = "Redo"
# calculates the intersection of two flat lists
def listIntersection(cls, inList1, inList2):
......@@ -193,9 +199,11 @@ class EditBox(object):
if (effect in self.effects):
i = self.icons[effect] = qt.QIcon(self.effectIconFiles[effect,self.effectModes[effect]])
a = self.actions[effect] = qt.QAction(i, '', f)
b = self.buttons[effect] = qt.QToolButton()
self.effectButtons[effect] = b = self.buttons[effect] = qt.QToolButton()
if EditBox.displayNames.has_key(effect):
if self.disabled.__contains__(effect):
......@@ -252,8 +260,12 @@ class EditBox(object):
# if using embedded format: create all of the buttons in the effects list in a single row
def setActiveToolLabel(self,name):
if EditBox.displayNames.has_key(name):
name = EditBox.displayNames[name]
# needs to be a valid effect name and state of "", Disabled, or Selected
......@@ -383,4 +395,12 @@ itcl::body EditBox::setButtonState {effect state} {
$w previewOptions
def updateCheckPointButtons(self):
previousImagesExist = nextImagesExist = False
if bool(int(tcl('info exists ::Editor(previousCheckPointImages)'))):
previousImagesExist = bool(int(tcl('llength $::Editor(previousCheckPointImages)')))
if bool(int(tcl('info exists ::Editor(nextCheckPointImages)'))):
nextImagesExist = bool(int(tcl('llength $::Editor(nextCheckPointImages)')))
self.effectButtons["PreviousCheckPoint"].setDisabled( not previousImagesExist )
self.effectButtons["NextCheckPoint"].setDisabled( not nextImagesExist )
import os
from __main__ import tcl
from __main__ import slicer
import qt, ctk
import EditorLib
......@@ -48,6 +49,7 @@ class EditorWidget:
self.embedded = embedded
self.suppliedEffects = suppliedEffects
self.showVolumesFrame = showVolumesFrame
self.editUtil = EditorLib.EditUtil()
#->> check to make sure it works with a supplied parent
if not parent:
......@@ -66,10 +68,10 @@ class EditorWidget:
def enter(self):
# get the master and merge nodes from the composite node associated
# with the red slice, but only if showing volumes
if (self.showVolumesFrame == True):
if self.showVolumesFrame:
# get the slice composite node for the Red slice view (we'll assume it exists
# since we are in the editor) to get the current background and label
compositeNode = EditorLib.EditUtil.getCompositeNode()
compositeNode = self.editUtil.getCompositeNode()
masterNode = slicer.mrmlScene.GetNodeByID( compositeNode.GetBackgroundVolumeID() )
mergeNode = slicer.mrmlScene.GetNodeByID( compositeNode.GetLabelVolumeID() )
......@@ -77,12 +79,23 @@ class EditorWidget:
# if not showing volumes, the caller is responsible for setting the master and
# merge nodes, most likely according to a widget within the caller
# Observe the parameter node in order to make changes to
# button states as needed
nodeID = tcl('[EditorGetParameterNode] GetID')
self.parameterNode = slicer.mrmlScene.GetNodeByID(nodeID)
self.parameterNodeTag = self.parameterNode.AddObserver("ModifiedEvent", self.updateGUIFromMRML)
# resume the current effect, if we left the editor and re-entered
def exit(self):
def updateGUIFromMRML(self, caller, event):
if self.toolsBox:
def pauseEffect(self):
if self.toolsBox:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment