rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
inputs = [i for i in self._inputs if i['Connected'] == 'vtkImageDataPrimary'] if inputs: inputData = inputs[0]['inputData'] else: inputData = None
inputData = self._getPrimaryInput()
def _pointWidgetInteractionCallback(self, pw, evt_name): # we have to find pw in our list pwidgets = map(lambda i: i['point_widget'], self._selectedPoints) if pw in pwidgets: idx = pwidgets.index(pw) # toggle the selection for this point in our list self._viewFrame.spointsGrid.SelectRow(idx)
print "Rerouting %d" % (len(allLines))
def _canvasLeftClick(self, canvas, eventName, event, userData): if event.LeftDown(): # we are in "create/edit" mode, so let's create some glyph # first get the currently selected tree node sel_item = self._graphFrame.treeCtrl.GetSelection() # then the root node root_item = self._graphFrame.treeCtrl.GetRootItem() if roo...
print "Rerouting %d" % (len(allLines))
def _glyphDrag(self, glyph, eventName, event, module):
currentSd = 65535
currentSd = sys.maxint
def _routeLine(self, line): # we have to get a list of all coGlyphs allGlyphs = self._graphFrame.canvas.getObjectsOfClass(wxpc.coGlyph)
print "Extra node added to avoid new clips."
def _routeLine(self, line): # we have to get a list of all coGlyphs allGlyphs = self._graphFrame.canvas.getObjectsOfClass(wxpc.coGlyph)
def _routeLineBACKUP2(self, line): allGlyphs = self._graphFrame.canvas.getObjectsOfClass(wxpc.coGlyph) line.updateEndPoints() overshoot = 7 successfulInsert = True while successfulInsert: (x0, y0), (x1, y1) = line.getThirdLastSecondLast() clips = {} for glyph in allGlyphs: (xmin, ymin), (xmax, ymax) = glyph.ge...
def _routeLineBACKUP2(self, line): # we have to get a list of all coGlyphs allGlyphs = self._graphFrame.canvas.getObjectsOfClass(wxpc.coGlyph)
self._shape_canvas.PopupMenu(pmenu, wxPoint(x, y))
view_start = self._shape_canvas.GetViewStart() sppu = self._shape_canvas.GetScrollPixelsPerUnit() x1 = x * self._shape_canvas.GetScaleX() y1 = y * self._shape_canvas.GetScaleY() mnx = x1 - view_start[0] * sppu[0] mny = y1 - view_start[1] * sppu[1] self._shape_canvas.PopupMenu(pmenu, wxPoint(mnx, mny))
def mshape_rightclick_cb(self, x, y, keys, attachment, glyph): pmenu = wxMenu(glyph.get_name())
self._rws = []
self._rwis = []
def __init__(self, module_manager): # call base constructor module_base.__init__(self, module_manager) self._num_inputs = 5 self._num_orthos = 3 # use list comprehension to create list keeping track of inputs
del self._rws
del self._rwis
def close(self): for idx in range(self._num_inputs): pass #self.set_input(idx, None)
self._rws.append(wxVTKRenderWindowSlice(panel, -1))
self._rwis.append(wxVTKRenderWindowInteractor(panel, -1))
def _create_ortho_panel(self, parent): panel = wxPanel(parent, id=-1) self._rws.append(wxVTKRenderWindowSlice(panel, -1)) self._pws.append(vtk.vtkPlaneWidget()) self._renderers.append(vtk.vtkRenderer()) self._rws[-1].GetRenderWindow().AddRenderer(self._renderers[-1]) panel_sizer = wxBoxSizer(wxVERTICAL) panel_sizer.Add...
self._rws[-1].GetRenderWindow().AddRenderer(self._renderers[-1])
self._rwis[-1].GetRenderWindow().AddRenderer(self._renderers[-1]) istyle = vtk.vtkInteractorStyleImage() self._rwis[-1].SetInteractorStyle(istyle)
def _create_ortho_panel(self, parent): panel = wxPanel(parent, id=-1) self._rws.append(wxVTKRenderWindowSlice(panel, -1)) self._pws.append(vtk.vtkPlaneWidget()) self._renderers.append(vtk.vtkRenderer()) self._rws[-1].GetRenderWindow().AddRenderer(self._renderers[-1]) panel_sizer = wxBoxSizer(wxVERTICAL) panel_sizer.Add...
panel_sizer.Add(self._rws[-1], option=1, flag=wxEXPAND)
panel_sizer.Add(self._rwis[-1], option=1, flag=wxEXPAND)
def _create_ortho_panel(self, parent): panel = wxPanel(parent, id=-1) self._rws.append(wxVTKRenderWindowSlice(panel, -1)) self._pws.append(vtk.vtkPlaneWidget()) self._renderers.append(vtk.vtkRenderer()) self._rws[-1].GetRenderWindow().AddRenderer(self._renderers[-1]) panel_sizer = wxBoxSizer(wxVERTICAL) panel_sizer.Add...
self._rws.append(wxVTKRenderWindowInteractor(td_panel, -1))
self._rwis.append(wxVTKRenderWindowInteractor(td_panel, -1))
def _create_window(self): # create main frame, make sure that when it's closed, it merely hides parent_window = self._module_manager.get_module_view_parent_window() self._view_frame = wxFrame(parent=parent_window, id=-1, title='slice viewer') EVT_CLOSE(self._view_frame, lambda e, s=self: s._view_frame.Show(false))
self._rws[-1].GetRenderWindow().AddRenderer(self._renderers[-1])
self._rwis[-1].GetRenderWindow().AddRenderer(self._renderers[-1])
def _create_window(self): # create main frame, make sure that when it's closed, it merely hides parent_window = self._module_manager.get_module_view_parent_window() self._view_frame = wxFrame(parent=parent_window, id=-1, title='slice viewer') EVT_CLOSE(self._view_frame, lambda e, s=self: s._view_frame.Show(false))
td_panel_sizer.Add(self._rws[-1], option=1, flag=wxEXPAND)
td_panel_sizer.Add(self._rwis[-1], option=1, flag=wxEXPAND)
def _create_window(self): # create main frame, make sure that when it's closed, it merely hides parent_window = self._module_manager.get_module_view_parent_window() self._view_frame = wxFrame(parent=parent_window, id=-1, title='slice viewer') EVT_CLOSE(self._view_frame, lambda e, s=self: s._view_frame.Show(false))
def setup_ortho_plane(self, cur_pipe):
def _setup_ortho_plane(self, cur_pipe):
def setup_ortho_plane(self, cur_pipe):
def update_3d_plane(self, cur_pipe, output_z=0):
def _update_3d_plane(self, cur_pipe, output_z=0):
def update_3d_plane(self, cur_pipe, output_z=0): """Move texture-mapper 3d plane source so that it corresponds to the passed output z coord.
def setup_camera(self, cur_pipe, renderer):
def _setup_camera(self, cur_pipe, renderer):
def setup_camera(self, cur_pipe, renderer):
layer_pl_indices.append(self._ortho_pipes[ortidx].index(layer_pl)) if len(layer_pl_indices) > 0: layer_pl_indices.sort() layer_pl_indices.reverse() for i in layer_pl_indices: del self._ortho_pipes[ortidx][i]
if len(self._ortho_pipes[ortidx]) == 1: pw = self._pws[ortidx] pw.Off() pw.SetInteractor(None) pl_idx = self._ortho_pipes[ortidx].index(layer_pl) layer_pl_indices.append(pl_idx) if len(layer_pl_indices) > 0: layer_pl_indices.sort() layer_pl_indices.reverse() for i in layer_pl_indices: del self._ortho_pipes...
def set_input(self, idx, input_stream): if input_stream == None:
if len(self._ortho_pipes[i]) == 1: cur_pipe['vtkImageReslice'].SetResliceAxesDirectionCosines( self._InitialResliceAxes[i]['axes']) cur_pipe['vtkImageReslice'].SetResliceAxesOrigin( self._InitialResliceAxes[i]['origin']) some_trans = vtk.vtkTransform() some_trans.RotateWXYZ(-50,1,1,1) new_matrix = vtk.vtkMatrix4x4() vt...
def set_input(self, idx, input_stream): if input_stream == None:
self.setup_ortho_plane(cur_pipe) self.update_3d_plane(cur_pipe, 0) if len(self._ortho_pipes[i]) == 1: self._pws[i].SetProp3D(cur_pipe['vtkActor3']) if i == 0: self._pws[i].NormalToZAxisOn() elif i == 1: self._pws[i].NormalToXAxisOn() else: self._pws[i].NormalToYAxisOn() self._pws[i].SetResolution(20) self._pws[i].Set...
self._reset_ortho_overlay(i, cur_pipe) self._renderers[0].ResetCamera() self._rwis[0].Render()
def set_input(self, idx, input_stream): if input_stream == None:
self.rw_window.deiconify()
self._view_frame.Show(true)
def view(self):
about.htmlWindow.SetSize((ir.GetWidth(), ir.GetHeight())) about.GetSizer().Fit(about) about.GetSizer().SetSizeHints(about) about.Layout()
about.SetSize((1.2 * ir.GetWidth(), 1.1 * ir.GetHeight()))
def aboutCallback(self, event): from resources.python.aboutDialog import aboutDialog
self._selectccs.Modified()
self._seedConnect.Modified()
def _inputPointsObserver(self, obj): # extract a list from the input points tempList = [] if self._inputPoints: for i in self._inputPoints: tempList.append(i['discrete']) if tempList != self._seedPoints: self._seedPoints = tempList self._seedConnect.RemoveAllSeeds() # we need to call Modified() explicitly as RemoveAll...
beginFreeMemory = wxGetFreeMemory()
def deleteModule(self, instance): beginFreeMemory = wxGetFreeMemory()
endFreeMemory = wxGetFreeMemory() print "%d %d" % (beginFreeMemory, endFreeMemory) print "Deleted %s, %.2fM freed." % \ (instance.__class__.__name__, (endFreeMemory - beginFreeMemory) / 1024.0 / 1024.0)
def deleteModule(self, instance): beginFreeMemory = wxGetFreeMemory()
self._view_frame.statusbar.SetLabel(
self._view_frame.statusbar.SetStatusText(
def _handler_file_open(self, evt): fd = wx.FileDialog( self._view_frame, 'Select file to open into current edit', wildcard='*.py', style=wx.OPEN)
self.miscObjectConfigure(self.threedFrame, self, 'slice3dVWR %s' % \ (self._moduleManager.getInstanceName(self),))
self.miscObjectConfigure( self.threedFrame, self, 'slice3dVWR %s' % \ (self._moduleManager.get_instance_name(self),))
def _handlerIntrospectButton(self, event): """Open Python introspection window with this module as main object. """
glyphDeletionSchedule = []
def clearAllGlyphsFromCanvas(self): allGlyphs = self._graphFrame.canvas.getObjectsOfClass(wxpc.coGlyph)
if glyph in mm.consumerTypeTable: moduleClassName = glyph.moduleInstance.__class__.__name__
moduleClassName = glyph.moduleInstance.__class__.__name__ if moduleClassName in mm.consumerTypeTable:
def clearAllGlyphsFromCanvas(self): allGlyphs = self._graphFrame.canvas.getObjectsOfClass(wxpc.coGlyph)
self._deleteModule(glyph)
glyphDeletionSchedule.append(glyph) for glyph in glyphDeletionSchedule: self._deleteModule(glyph)
def clearAllGlyphsFromCanvas(self): allGlyphs = self._graphFrame.canvas.getObjectsOfClass(wxpc.coGlyph)
vtk_objs.append (["%s%d"%(icon[0], i), obj, icon[2]])
if icon: vtk_objs.append (["%s%d"%(icon[0], i), obj, icon[2]])
def get_vtk_objs (vtk_obj): "Obtain vtk objects from the passed objects." debug ("vtkPipeline.py: get_vtk_objs (%s)"% (vtk_obj.GetClassName ())) methods = get_methods(vtk_obj) vtk_objs = [] for method in methods: try: t = eval ("vtk_obj.Get%s ().GetClassName ()"%method[0]) except: pass else: if string.find (t, "Coll...
vtk_objs.append (get_icon (obj))
icon = get_icon(obj) if icon: vtk_objs.append (icon)
def get_vtk_objs (vtk_obj): "Obtain vtk objects from the passed objects." debug ("vtkPipeline.py: get_vtk_objs (%s)"% (vtk_obj.GetClassName ())) methods = get_methods(vtk_obj) vtk_objs = [] for method in methods: try: t = eval ("vtk_obj.Get%s ().GetClassName ()"%method[0]) except: pass else: if string.find (t, "Coll...
vtk_objs.append (icon)
if icon: vtk_objs.append (icon)
def get_vtk_objs (vtk_obj): "Obtain vtk objects from the passed objects." debug ("vtkPipeline.py: get_vtk_objs (%s)"% (vtk_obj.GetClassName ())) methods = get_methods(vtk_obj) vtk_objs = [] for method in methods: try: t = eval ("vtk_obj.Get%s ().GetClassName ()"%method[0]) except: pass else: if string.find (t, "Coll...
print str(val)
def configToView(self): for configTuple in self._configList: widget = self._widgets[configTuple[0]] val = getattr(self._config, configTuple[1]) # only supporting 'text' widgets for now if configTuple[3] == 'text': widget.SetValue(str(val)) elif configTuple[3] == 'checkbox': # checkbox widget.SetValue(bool(val)) else: #...
if len(self._internalPoints) == 0: return
def _createSpheres(self): """Create all spheres according to self._internalPoints. """ if len(self._internalPoints) == 0: return
print lut.GetTableRange()
def _setOverlayLookupTable(self, ipw): """Configures overlay lookup table according to mode.
r2 = vtk.vtkPNGReader() r2.SetFileName(image2_filename) r2.Update()
def compare_png_images(self, image1_filename, image2_filename, threshold=16):
for connection in connectionList:
for connection in newConnections:
def _realiseNetwork(self, pmsDict, connectionList, glyphPosDict, origin=(0,0), reposition=False): """Given a pmsDict, connectionList and glyphPosDict, recreate the network described by those structures. The origin of the glyphs will be set. If reposition is True, the uppermost and leftmost coordinates of all glyphs i...
self.get_set_texts[i].SetLabel(str(self.get_set_var[i]))
self.get_set_texts[i].SetValue(str(self.get_set_var[i]))
def update_gui (self, event=None):
self._renderer.RemoveAllProps()
self._renderer.RemoveAllViewProps()
def close(self): for i in range(len(self.getInputDescriptions())): self.setInput(i, None)
self._config.lt = 1250 self._config.ut = 2500 self._config.rtu = 1 self._config.ri = 1 self._config.iv = 1 self._config.ro = 1 self._config.ov = 0 self._config.os = self._imageThreshold.GetOutputScalarType()
self._config.lowerThreshold = 1250 self._config.upperThreshold = 2500 self._config.replaceIn = 1 self._config.inValue = 1 self._config.replaceOut = 1 self._config.outValue = 0 self._config.outputScalarType = self._imageThreshold.GetOutputScalarType()
def __init__(self, moduleManager):
self._config.lt = self._imageThreshold.GetLowerThreshold() self._config.ut = self._imageThreshold.GetUpperThreshold() self._config.ri = self._imageThreshold.GetReplaceIn() self._config.iv = self._imageThreshold.GetInValue() self._config.ro = self._imageThreshold.GetReplaceOut() self._config.ov = self._imageThreshold.Ge...
self._config.lowerThreshold = self._imageThreshold.GetLowerThreshold() self._config.upperThreshold = self._imageThreshold.GetUpperThreshold() self._config.replaceIn = self._imageThreshold.GetReplaceIn() self._config.inValue = self._imageThreshold.GetInValue() self._config.replaceOut = self._imageThreshold.GetReplaceOut...
def logicToConfig(self): self._config.lt = self._imageThreshold.GetLowerThreshold() self._config.ut = self._imageThreshold.GetUpperThreshold() self._config.ri = self._imageThreshold.GetReplaceIn() self._config.iv = self._imageThreshold.GetInValue() self._config.ro = self._imageThreshold.GetReplaceOut() self._config.ov ...
self._imageThreshold.ThresholdBetween(self._config.lt, self._config.ut)
self._imageThreshold.ThresholdBetween(self._config.lowerThreshold, self._config.upperThreshold)
def configToLogic(self): self._imageThreshold.ThresholdBetween(self._config.lt, self._config.ut) # SetInValue HAS to be called before SetReplaceIn(), as SetInValue() # always toggles SetReplaceIn() to ON self._imageThreshold.SetInValue(self._config.iv) self._imageThreshold.SetReplaceIn(self._config.ri) # SetOutValue HA...
self._imageThreshold.SetInValue(self._config.iv) self._imageThreshold.SetReplaceIn(self._config.ri)
self._imageThreshold.SetInValue(self._config.inValue) self._imageThreshold.SetReplaceIn(self._config.replaceIn)
def configToLogic(self): self._imageThreshold.ThresholdBetween(self._config.lt, self._config.ut) # SetInValue HAS to be called before SetReplaceIn(), as SetInValue() # always toggles SetReplaceIn() to ON self._imageThreshold.SetInValue(self._config.iv) self._imageThreshold.SetReplaceIn(self._config.ri) # SetOutValue HA...
self._imageThreshold.SetOutValue(self._config.ov) self._imageThreshold.SetReplaceOut(self._config.ro) self._imageThreshold.SetOutputScalarType(self._config.os)
self._imageThreshold.SetOutValue(self._config.outValue) self._imageThreshold.SetReplaceOut(self._config.replaceOut) self._imageThreshold.SetOutputScalarType(self._config.outputScalarType)
def configToLogic(self): self._imageThreshold.ThresholdBetween(self._config.lt, self._config.ut) # SetInValue HAS to be called before SetReplaceIn(), as SetInValue() # always toggles SetReplaceIn() to ON self._imageThreshold.SetInValue(self._config.iv) self._imageThreshold.SetReplaceIn(self._config.ri) # SetOutValue HA...
self._config.lt = self._sanitiseThresholdTexts(0) self._config.ut = self._sanitiseThresholdTexts(1) self._config.ri = self._viewFrame.replaceInCheckBox.GetValue() self._config.iv = float(self._viewFrame.replaceInText.GetValue()) self._config.ro = self._viewFrame.replaceOutCheckBox.GetValue() self._config.ov = float(sel...
self._config.lowerThreshold = self._sanitiseThresholdTexts(0) self._config.upperThreshold = self._sanitiseThresholdTexts(1) self._config.replaceIn = self._viewFrame.replaceInCheckBox.GetValue() self._config.inValue = float(self._viewFrame.replaceInText.GetValue()) self._config.replaceOut = self._viewFrame.replaceOutChe...
def viewToConfig(self): self._config.lt = self._sanitiseThresholdTexts(0) self._config.ut = self._sanitiseThresholdTexts(1) self._config.ri = self._viewFrame.replaceInCheckBox.GetValue() self._config.iv = float(self._viewFrame.replaceInText.GetValue()) self._config.ro = self._viewFrame.replaceOutCheckBox.GetValue() sel...
self._config.os = -1
self._config.outputScalarType = -1
def viewToConfig(self): self._config.lt = self._sanitiseThresholdTexts(0) self._config.ut = self._sanitiseThresholdTexts(1) self._config.ri = self._viewFrame.replaceInCheckBox.GetValue() self._config.iv = float(self._viewFrame.replaceInText.GetValue()) self._config.ro = self._viewFrame.replaceOutCheckBox.GetValue() sel...
self._config.os = getattr(vtk, symbolicOutputType)
self._config.outputScalarType = getattr(vtk, symbolicOutputType)
def viewToConfig(self): self._config.lt = self._sanitiseThresholdTexts(0) self._config.ut = self._sanitiseThresholdTexts(1) self._config.ri = self._viewFrame.replaceInCheckBox.GetValue() self._config.iv = float(self._viewFrame.replaceInText.GetValue()) self._config.ro = self._viewFrame.replaceOutCheckBox.GetValue() sel...
self._viewFrame.lowerThresholdText.SetValue("%.2f" % (self._config.lt)) self._viewFrame.upperThresholdText.SetValue("%.2f" % (self._config.ut)) self._viewFrame.replaceInCheckBox.SetValue(self._config.ri) self._viewFrame.replaceInText.SetValue(str(self._config.iv)) self._viewFrame.replaceOutCheckBox.SetValue(self._confi...
self._viewFrame.lowerThresholdText.SetValue("%.2f" % (self._config.lowerThreshold)) self._viewFrame.upperThresholdText.SetValue("%.2f" % (self._config.upperThreshold)) self._viewFrame.replaceInCheckBox.SetValue(self._config.replaceIn) self._viewFrame.replaceInText.SetValue(str(self._config.inValue)) self._viewFrame.rep...
def configToView(self): self._viewFrame.lowerThresholdText.SetValue("%.2f" % (self._config.lt)) self._viewFrame.upperThresholdText.SetValue("%.2f" % (self._config.ut)) self._viewFrame.replaceInCheckBox.SetValue(self._config.ri) self._viewFrame.replaceInText.SetValue(str(self._config.iv)) self._viewFrame.replaceOutCheck...
if self._config.os == numericOutputType:
if self._config.outputScalarType == numericOutputType:
def configToView(self): self._viewFrame.lowerThresholdText.SetValue("%.2f" % (self._config.lt)) self._viewFrame.upperThresholdText.SetValue("%.2f" % (self._config.ut)) self._viewFrame.replaceInCheckBox.SetValue(self._config.ri) self._viewFrame.replaceInText.SetValue(str(self._config.iv)) self._viewFrame.replaceOutCheck...
self._config.lt)) return self._config.lt
self._config.lowerThreshold)) return self._config.lowerThreshold
def _sanitiseThresholdTexts(self, whichText): if whichText == 0: try: lower = float(self._viewFrame.lowerThresholdText.GetValue()) except ValueError: # this means that the user did something stupid, so we # restore the value to what's in our config self._viewFrame.lowerThresholdText.SetValue(str( self._config.lt)) ret...
self._config.ut)) return self._config.ut
self._config.upperThreshold)) return self._config.upperThreshold
def _sanitiseThresholdTexts(self, whichText): if whichText == 0: try: lower = float(self._viewFrame.lowerThresholdText.GetValue()) except ValueError: # this means that the user did something stupid, so we # restore the value to what's in our config self._viewFrame.lowerThresholdText.SetValue(str( self._config.lt)) ret...
m = float(y1 - y0 + 0.00000001) / float(x1 - x0 + 0.00000001) mi = 1.0 / m
dx = float(x1 - x0) dy = float(y1 - y0) if dx != 0.0: m = dy / dx else: m = 0.0 if dy != 0.0: mi = dx / dy else: mi = 0.0
def outCode(x, y, xmin, ymin, xmax, ymax):
self.threedRWI = wxVTKRenderWindowInteractor(self.panel_1, -1)
self.panel_3 = wxPanel(self.panel_1, -1) self.threedRWI = wxVTKRenderWindowInteractor(self.panel_3, -1)
def __init__(self, *args, **kwds): # begin wxGlade: MainFrame.__init__ kwds["style"] = wxDEFAULT_FRAME_STYLE wxFrame.__init__(self, *args, **kwds) self.panel_1 = wxPanel(self, -1) self.notebook_1_copy = wxNotebook(self.panel_1, -1, style=0) self.notebook_1_copy_pane_7 = wxPanel(self.notebook_1_copy, -1) self.notebook_1...
self.SetSize((674, 681))
self.panel_3.SetSize((663, 412))
def __set_properties(self): # begin wxGlade: MainFrame.__set_properties self.SetTitle("Slice3D Viewer") self.SetSize((674, 681)) self.sliceCursorNameCombo.SetSelection(0) self.spointsGrid.CreateGrid(0, 3) self.spointsGrid.SetRowLabelSize(30) self.spointsGrid.EnableEditing(0) self.spointsGrid.SetSelectionMode(wxGrid.wxG...
self.spointsGrid.SetSize((643, 111))
self.spointsGrid.SetSize((646, 118))
def __set_properties(self): # begin wxGlade: MainFrame.__set_properties self.SetTitle("Slice3D Viewer") self.SetSize((674, 681)) self.sliceCursorNameCombo.SetSelection(0) self.spointsGrid.CreateGrid(0, 3) self.spointsGrid.SetRowLabelSize(30) self.spointsGrid.EnableEditing(0) self.spointsGrid.SetSelectionMode(wxGrid.wxG...
sizer_8.Add(self.threedRWI, 1, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, 7)
sizer_2 = wxBoxSizer(wxVERTICAL) sizer_2.Add(self.threedRWI, 1, wxEXPAND, 0) self.panel_3.SetAutoLayout(1) self.panel_3.SetSizer(sizer_2) sizer_8.Add(self.panel_3, 1, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, 7)
def __do_layout(self): # begin wxGlade: MainFrame.__do_layout sizer_1 = wxBoxSizer(wxVERTICAL) sizer_8 = wxBoxSizer(wxVERTICAL) sizer_9 = wxBoxSizer(wxHORIZONTAL) sizer_10 = wxBoxSizer(wxVERTICAL) sizer_6 = wxBoxSizer(wxVERTICAL) sizer_20_copy_1_copy = wxBoxSizer(wxHORIZONTAL) sizer_7 = wxBoxSizer(wxHORIZONTAL) sizer_1...
print "IN " + message
def setProgress(self, progress, message): # 1. we shouldn't call setProgress whilst busy with setProgress # 2. only do something if the message or the progress has changed # 3. we only perform an update if a second or more has passed # since the previous update, unless this is the final # (i.e. 100% update) if no...
wxSafeYield()
wxSafeYield(None, 1)
def setProgress(self, progress, message): # 1. we shouldn't call setProgress whilst busy with setProgress # 2. only do something if the message or the progress has changed # 3. we only perform an update if a second or more has passed # since the previous update, unless this is the final # (i.e. 100% update) if no...
print "OUT " + message
def setProgress(self, progress, message): # 1. we shouldn't call setProgress whilst busy with setProgress # 2. only do something if the message or the progress has changed # 3. we only perform an update if a second or more has passed # since the previous update, unless this is the final # (i.e. 100% update) if no...
spacing = tuple([int(i) for i in spacing])
spacing = tuple([float(i) for i in spacing])
def viewToConfig(self): self._config.filename = self._viewFrame.filenameText.GetValue()
self._viewFrame.spacingText.SetValue(str(self._config.spacing))
spacingText = "(%.3f, %.3f, %.3f)" % tuple(self._config.spacing) self._viewFrame.spacingText.SetValue(spacingText)
def configToView(self):
self._config.seriesInstanceIdx = -1
self._config.seriesInstanceIdx = 0
def __init__(self, moduleManager): # call the constructor in the "base" moduleBase.__init__(self, moduleManager)
self._availableModuleList = None
self._availableModules = None
def __init__(self, devideApp): # initialise vars self._devideApp = devideApp
if moduleName in self._availableModuleList:
if moduleName in self._availableModules:
def createModuleAndGlyph(self, x, y, moduleName): """Create a DeVIDE and a corresponding glyph at window event position x,y. x, y will be converted to real (canvas-absolute) coordinates internally. """ # check that it's a valid module name if moduleName in self._availableModuleList: # we have a valid module, we shoul...
inputData = self._ipws[0].GetInput()
if self._ipws[0]: inputData = self._ipws[0][0].GetInput() else: inputData = None
def _storeSurfacePoint(self, pointId, actor): polyData = actor.GetMapper().GetInput() if polyData: xyz = polyData.GetPoint(pointId) else: # something really weird went wrong return
map(operator.sub, pos, iorigin), ispacing)) val = inputData.GetScalarComponentAsFloat(x,y,z, 0)
map(operator.sub, xyz, iorigin), ispacing)) val = inputData.GetScalarComponentAsFloat(discrete[0],discrete[1], discrete[2], 0)
def _storeSurfacePoint(self, pointId, actor): polyData = actor.GetMapper().GetInput() if polyData: xyz = polyData.GetPoint(pointId) else: # something really weird went wrong return
self._selectedPoints.append({'discrete' : discrete, 'world' : world,
self._selectedPoints.append({'discrete' : tuple(discrete), 'world' : tuple(world),
def pw_ei_cb(pw, evt_name): # make sure our output is good self._syncOutputSelectedPoints()
tm2p.SetPoint1(roBounds[1], 0, 0) tm2p.SetPoint2(0, roBounds[3], 0)
tm2p.SetPoint1(roBounds[1] - roBounds[0], 0, 0) tm2p.SetPoint2(0, roBounds[3] - roBounds[2], 0)
def _syncOrthoViewWithIPW(self, orthoIdx): orthoView = self._orthoViews[orthoIdx] # find IPW that we're syncing with direction = orthoView['direction'] ipwDir = self._ipws[direction]
inputData = self._ipws[0].GetInput()
if self._ipws[0]: inputData = self._ipws[0][0].GetInput() else: inputData = None
def _pointWidgetInteractionCallback(self, pw, evt_name): # we have to find pw in our list pwidgets = map(lambda i: i['point_widget'], self._selectedPoints) if pw in pwidgets: idx = pwidgets.index(pw) # toggle the selection for this point in our list self._viewFrame.spointsGrid.SelectRow(idx)
self._selectedPoints[idx]['discrete'] = discrete
self._selectedPoints[idx]['discrete'] = tuple(discrete)
def _pointWidgetInteractionCallback(self, pw, evt_name): # we have to find pw in our list pwidgets = map(lambda i: i['point_widget'], self._selectedPoints) if pw in pwidgets: idx = pwidgets.index(pw) # toggle the selection for this point in our list self._viewFrame.spointsGrid.SelectRow(idx)
self._selectedPoints[idx]['world'] = pos
self._selectedPoints[idx]['world'] = tuple(pos)
def _pointWidgetInteractionCallback(self, pw, evt_name): # we have to find pw in our list pwidgets = map(lambda i: i['point_widget'], self._selectedPoints) if pw in pwidgets: idx = pwidgets.index(pw) # toggle the selection for this point in our list self._viewFrame.spointsGrid.SelectRow(idx)
self.statusBar = self.CreateStatusBar(1)
def __init__(self, *args, **kwds): # begin wxGlade: pythonShellFrame.__init__ kwds["style"] = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) self.panel_1 = wx.Panel(self, -1) self.pyShell = py.shell.Shell(self.panel_1, -1) self.closeButton = wx.Button(self.panel_1, -1, "Close") self.statusBar = self.Crea...
self.pyShell.SetFocus() self.panel_1.SetSize((654, 533))
self.SetSize((670, 623))
def __set_properties(self): # begin wxGlade: pythonShellFrame.__set_properties self.SetTitle("Python Introspection") self.pyShell.SetFocus() self.panel_1.SetSize((654, 533)) self.statusBar.SetStatusWidths([-1]) # statusbar fields statusBar_fields = ["Welcome to the Python Shell!"] for i in range(len(statusBar_fields)):...
topSizer.Fit(self) topSizer.SetSizeHints(self)
def __do_layout(self): # begin wxGlade: pythonShellFrame.__do_layout topSizer = wx.BoxSizer(wx.VERTICAL) sizer_2 = wx.BoxSizer(wx.VERTICAL) sizer_3 = wx.BoxSizer(wx.VERTICAL) sizer_6 = wx.BoxSizer(wx.HORIZONTAL) sizer_3.Add(self.pyShell, 1, wx.EXPAND, 0) sizer_6.Add(self.closeButton, 0, 0, 0) sizer_3.Add(sizer_6, 0, wx...
return self._pSource.GetStructuredPointsOutput()
return self._vtkImporter.GetOutput()
def getOutput(self, idx): return self._pSource.GetStructuredPointsOutput()
self._pSource = vtk.vtkProgrammableSource() self._pSource.SetExecuteMethod(self._psExecute)
def _createConnectPipeline(self): """When creating a new VTK->ITK-VTK pipeline, copy this method, as well as _psExecute. """ # this is the main module input self._inputImageCast = vtk.vtkImageCast() self._inputImageCast.SetOutputScalarTypeToFloat()
angleIncr = 2.0 * vtk.vtkMath.Pi() / 8.056
angleIncr = 2.0 * vtk.vtkMath.Pi() / 8.0
def executeModule(self): if self._giaDistal and self._giaProximal and self._inputPolyData: # construct eight planes with the insertion axis as mid-line # the planes should go somewhat further proximally than the # proximal insertion axis point
cut.SetValue(0,1)
cut.SetValue(0,0)
def executeModule(self): if self._giaDistal and self._giaProximal and self._inputPolyData: # construct eight planes with the insertion axis as mid-line # the planes should go somewhat further proximally than the # proximal insertion axis point
for i in range(20):
onGlenoid = True while onGlenoid:
def executeModule(self): if self._giaDistal and self._giaProximal and self._inputPolyData: # construct eight planes with the insertion axis as mid-line # the planes should go somewhat further proximally than the # proximal insertion axis point
lines[lineIdx].append((curStartPtId,
if abs(vtk.vtkMath.Dot(giaN, n)) > 0.8: lines[lineIdx].append((curStartPtId,
def executeModule(self): if self._giaDistal and self._giaProximal and self._inputPolyData: # construct eight planes with the insertion axis as mid-line # the planes should go somewhat further proximally than the # proximal insertion axis point
curStartPtId = nextPointId curLineId = nextLineId
curStartPtId = nextPointId curLineId = nextLineId else: onGlenoid = False
def executeModule(self): if self._giaDistal and self._giaProximal and self._inputPolyData: # construct eight planes with the insertion axis as mid-line # the planes should go somewhat further proximally than the # proximal insertion axis point
houseNormal = [0, 0, 0] cutPlane.ProjectPoint(startPointNormal, cutPlane.GetOrigin(), cutPlane.GetNormal(), houseNormal)
t = vtk.vtkMath.Dot(startPointNormal, cutPlane.GetNormal()) houseNormal = map(operator.sub, startPointNormal, [t * i for i in cutPlane.GetNormal()])
def _buildHouse(self, startPoint, startPointNormal, cutPlane): """Calculate the vertices of a single house.
houseNormal = startPointNormal
def _buildHouse(self, startPoint, startPointNormal, cutPlane): """Calculate the vertices of a single house.
self._view_frame.statusbar.SetLabel(
self._view_frame.statusbar.SetStatusText(
def run_current_edit(self): cew = self._get_current_editwindow() text = cew.GetText()
nameOfObject, obj.GetProgress(), progressText)
nameOfObject, getattr(dvModule, objAttrString).GetProgress(), progressText)
def commandCallable(): mm.genericProgressCallback( nameOfObject, obj.GetProgress(), progressText)
self._contourFilter = vtk.vtkKitwareContourFilter()
self._contourFilter = vtk.vtkContourFilter()
def __init__(self, moduleManager, contourFilterText):
'%s type %s and dimensions %s.' % (vType, g[0], g[1])
'type %s.' % (shortstring,)
def executeModule(self): if len(self._config.filename) and self._input:
self._writer.SetInput(None) self._writer = None
def executeModule(self): if len(self._config.filename) and self._input:
if bounds[1] - bounds[0] <= 0 or \ bounds[3] - bounds[2] <= 0 or \ bounds[5] - bounds[4] <= 0: bounds = (-1,1,-1,1,-1,1)
def _storePoint(self, discrete, world, value, pointName, lockToSurface=False, boundsForPoints=None):
self._matrixToLT = vtk.vtkMatrixToLinearTransform() self._matrixToLT.Inverse()
def __init__(self, moduleManager): # initialise our base class moduleBase.__init__(self, moduleManager) # initialise any mixins we might have noConfigModuleMixin.__init__(self)
try: self._matrixToLT.SetInput(inputStream.GetMatrix()) except AttributeError: if inputStream == None: self._matrixToLT.SetInput(None) self._imageReslice.SetResliceTransform(None)
if inputStream == None: self._imageReslice.SetResliceTransform(None)
def setInput(self, idx, inputStream): if idx == 0: self._imageReslice.SetInput(inputStream) else: try: self._matrixToLT.SetInput(inputStream.GetMatrix()) except AttributeError: # this means the inputStream has no GetMatrix() # i.e. it could be None or just the wrong type # if it's none, we just have to disconnect if i...
else: raise TypeError, \ "transformVolume input 2 requires a transform."
def setInput(self, idx, inputStream): if idx == 0: self._imageReslice.SetInput(inputStream) else: try: self._matrixToLT.SetInput(inputStream.GetMatrix()) except AttributeError: # this means the inputStream has no GetMatrix() # i.e. it could be None or just the wrong type # if it's none, we just have to disconnect if i...
self._imageReslice.SetResliceTransform(self._matrixToLT)
self._imageReslice.SetResliceTransform( inputStream.GetInverse())
def setInput(self, idx, inputStream): if idx == 0: self._imageReslice.SetInput(inputStream) else: try: self._matrixToLT.SetInput(inputStream.GetMatrix()) except AttributeError: # this means the inputStream has no GetMatrix() # i.e. it could be None or just the wrong type # if it's none, we just have to disconnect if i...
self._inputPoints.removeObserver( self._observerInputPoints)
if self._inputPoints: self._inputPoints.removeObserver( self._observerInputPoints)
def setInput(self, idx, inputStream): if inputStream is not self._inputPoints:
def toObjectID(self): return ObjectID([self.value])
def decodeTwosInteger3(self, stream): """ A third algorithm for decoding twos complement Integers Coded from scratch by jpw """ val = 0 bytes = map(ord, stream)
self.value = value
self.value = copy.copy(value)
def __init__(self, value=''): Asn1Object.__init__(self) self.value = value return
def toObjectID(self): return ObjectID([ ord(x) for x in self.value])
def __oct__(self): return ''.join( [ '%3o' % ord(x) for x in self.value ] )
self.value = value
self.value = copy.copy(value)
def __init__(self, value=None): """Create an ObjectID - value is a list of subids as a string or list""" Asn1Object.__init__(self) if type(value) == types.StringType: value = value.strip('.') subidlist = value.split('.') self.value = [] for subid in subidlist: number = int(subid) if number < 0 or number > 0x7FFFFF...