def ProcessIPWAction( self, caller, event, **args ): action = caller.State iAxis = caller.PlaneIndex if event == ImagePlaneWidget.InteractionUpdateEvent: if action == ImagePlaneWidget.Cursoring: if not self.isSlicing: HyperwallManager.getInstance().setInteractionState( 'VolumeSlicer.Slicing' ) self.isSlicing = True ispec = self.inputSpecs[ 0 ] cursor_data = caller.GetCursorData() image_value = cursor_data[3] cpos = cursor_data[0:3] dataValue = self.getDataValue( image_value ) wpos = ispec.getWorldCoords( cpos ) if self.generateContours: contour_image_value = cursor_data[4] if contour_image_value: contour_value = self.getDataValue( contour_image_value, 1 ) contour_units = self.getUnits(1) textDisplay = " Position: (%s, %s, %s), Value: %.3G %s, Contour Value: %.3G %s" % ( wpos[0], wpos[1], wpos[2], dataValue, ispec.units, contour_value, contour_units ) else: textDisplay = " Position: (%s, %s, %s), Value: %.3G %s" % ( wpos[0], wpos[1], wpos[2], dataValue, ispec.units ) # print " >>>>> Current Image Value: %d %d, data value: %.3G, contour value: %.3G, pos = %s, (%s) " % ( image_value, contour_image_value, dataValue, contour_value, str(cpos), str(wpos) ) else: textDisplay = " Position: (%s, %s, %s), Value: %.3G %s." % ( wpos[0], wpos[1], wpos[2], dataValue, ispec.units ) # print " >>>>> Current Image Value: %d, data value: %.3G, pos = %s, (%s) " % ( image_value, dataValue, str(cpos), str(wpos) ) sliceIndex = caller.GetSliceIndex() self.slicePosition[iAxis] = sliceIndex self.updateTextDisplay( textDisplay ) coord = ispec.getWorldCoordsAsFloat(cpos) PM_VolumeSlicer.global_coords = coord screenPos = caller.GetCurrentScreenPosition() self.updateLensDisplay(screenPos, coord) if action == ImagePlaneWidget.Pushing: ispec = self.inputSpecs[ 0 ] if not self.isSlicing: HyperwallManager.getInstance().setInteractionState( 'VolumeSlicer.Slicing' ) self.isSlicing = True sliceIndex = caller.GetSliceIndex() axisName, spos = ispec.getWorldCoord( sliceIndex, iAxis ) textDisplay = " %s = %s ." % ( axisName, spos ) if iAxis == 0: p1 = caller.GetPoint1() # print " >++++++++++++++++++> Slicing: Set Slice[%d], index=%d, pos=%.2f, " % ( iAxis, sliceIndex, p1[0] ), textDisplay self.slicePosition[ iAxis ] = sliceIndex self.updateTextDisplay( textDisplay ) if self.generateContours: slice_data = caller.GetReslice2Output() slice_data.Update() self.contours.SetInput( slice_data ) self.contours.Modified() origin = caller.GetOrigin() contourLineActor = self.getContourActor( iAxis ) contourLineActor.SetPosition( origin[0], origin[1], origin[2] ) # contourLineActor.SetOrigin( origin[0], origin[1], origin[2] ) self.setVisibleContour( iAxis ) # print " Generate Contours, data dims = %s, origin = %s, pos = %s, extent = %s" % ( str( slice_data.GetDimensions() ), str(slice_data.GetOrigin()), str(origin), str(slice_data.GetExtent()) ) self.render()
def ProcessIPWAction(self, caller, event, **args): action = args.get('action', caller.State) iAxis = caller.PlaneIndex if event == ImagePlaneWidget.InteractionUpdateEvent: if action == ImagePlaneWidget.Cursoring: if not self.isSlicing: HyperwallManager.getInstance().setInteractionState( 'VolumeSlicer.Slicing') self.isSlicing = True ispec = self.inputSpecs[0] cursor_data = caller.GetCursorData() image_value = cursor_data[3] cpos = cursor_data[0:3] dataValue = self.getDataValue(image_value) wpos = ispec.getWorldCoords(cpos) if self.generateContours: contour_image_value = cursor_data[4] if contour_image_value: contour_value = self.getDataValue( contour_image_value, 1) contour_units = self.getUnits(1) textDisplay = " Position: (%s, %s, %s), Value: %.3G %s, Contour Value: %.3G %s" % ( wpos[0], wpos[1], wpos[2], dataValue, ispec.units, contour_value, contour_units) else: textDisplay = " Position: (%s, %s, %s), Value: %.3G %s" % ( wpos[0], wpos[1], wpos[2], dataValue, ispec.units) # print " >>>>> Current Image Value: %d %d, data value: %.3G, contour value: %.3G, pos = %s, (%s) " % ( image_value, contour_image_value, dataValue, contour_value, str(cpos), str(wpos) ) else: textDisplay = " Position: (%s, %s, %s), Value: %.3G %s." % ( wpos[0], wpos[1], wpos[2], dataValue, ispec.units) # print " >>>>> Current Image Value: %d, data value: %.3G, pos = %s, (%s) " % ( image_value, dataValue, str(cpos), str(wpos) ) sliceIndex = caller.GetSliceIndex() self.slicePosition[iAxis] = sliceIndex self.updateTextDisplay(textDisplay) coord = ispec.getWorldCoordsAsFloat(cpos) PM_VolumeSlicer.global_coords = coord screenPos = caller.GetCurrentScreenPosition() self.updateLensDisplay(screenPos, coord) if action == ImagePlaneWidget.Pushing: ispec = self.inputSpecs[0] md = ispec.getMetadata() if (md == None): return latLonGrid = md.get('latLonGrid', True) if not self.isSlicing: HyperwallManager.getInstance().setInteractionState( 'VolumeSlicer.Slicing') self.isSlicing = True sliceIndex = caller.GetSliceIndex() axisName, spos = ispec.getWorldCoord(sliceIndex, iAxis, latLonGrid) textDisplay = " %s = %s ." % (axisName, spos) if iAxis == 0: p1 = caller.GetPoint1() # print " >++++++++++++++++++> Slicing: Set Slice[%d], index=%d, pos=%.2f, " % ( iAxis, sliceIndex, p1[0] ), textDisplay self.slicePosition[iAxis] = sliceIndex self.updateTextDisplay(textDisplay) if (iAxis == 2): origin = caller.GetOrigin() for type in ('coastline', 'countries', 'states', 'lakes'): line_specs = self.basemapLineSpecs.get(type, None) polys_list = self.shapefilePolylineActors.get( type, None) density = int(round( line_specs[1])) if line_specs else 1 polys = polys_list[density] if polys_list else None if polys: pos = polys.GetPosition() pos1 = [pos[0], pos[1], origin[2]] polys.SetPosition(pos1) if self.generateContours: slice_data = caller.GetReslice2Output() if slice_data: caller.Update() iextent = slice_data.GetExtent() ispacing = slice_data.GetSpacing() if vtk.VTK_MAJOR_VERSION <= 5: self.contours.SetInput(slice_data) else: self.contours.SetInputData(slice_data) self.contours.Modified() origin = caller.GetOrigin() contourLineActor = self.getContourActor(iAxis) contourLineActor.SetPosition(origin[0], origin[1], origin[2]) # contourLineActor.SetOrigin( origin[0], origin[1], origin[2] ) self.setVisibleContour(iAxis) # print " Generate Contours, data dims = %s, origin = %s, pos = %s, extent = %s" % ( str( slice_data.GetDimensions() ), str(slice_data.GetOrigin()), str(origin), str(slice_data.GetExtent()) ) self.render()
def init_hyperwall(optionsDict): from packages.vtDV3D import HyperwallManager hw_role = optionsDict.get( "hw_role", 'global') spawn = optionsDict.get( "spawn", True ) HyperwallManager.getInstance().initialize( hw_role, spawn )
def shutdown(): from packages.vtDV3D import HyperwallManager print " !! --shutdown-- !! " HyperwallManager.getInstance().shutdown()
def ProcessIPWAction( self, caller, event, **args ): action = args.get( 'action', caller.State ) iAxis = caller.PlaneIndex if event == ImagePlaneWidget.InteractionUpdateEvent: if action == ImagePlaneWidget.Cursoring: if not self.isSlicing: HyperwallManager.getInstance().setInteractionState( 'VolumeSlicer.Slicing' ) self.isSlicing = True ispec = self.inputSpecs[ 0 ] cursor_data = caller.GetCursorData() image_value = cursor_data[3] cpos = cursor_data[0:3] dataValue = self.getDataValue( image_value ) wpos = ispec.getWorldCoords( cpos ) if self.generateContours: contour_image_value = cursor_data[4] if contour_image_value: contour_value = self.getDataValue( contour_image_value, 1 ) contour_units = self.getUnits(1) textDisplay = " Position: (%s, %s, %s), Value: %.3G %s, Contour Value: %.3G %s" % ( wpos[0], wpos[1], wpos[2], dataValue, ispec.units, contour_value, contour_units ) else: textDisplay = " Position: (%s, %s, %s), Value: %.3G %s" % ( wpos[0], wpos[1], wpos[2], dataValue, ispec.units ) # print " >>>>> Current Image Value: %d %d, data value: %.3G, contour value: %.3G, pos = %s, (%s) " % ( image_value, contour_image_value, dataValue, contour_value, str(cpos), str(wpos) ) else: textDisplay = " Position: (%s, %s, %s), Value: %.3G %s." % ( wpos[0], wpos[1], wpos[2], dataValue, ispec.units ) # print " >>>>> Current Image Value: %d, data value: %.3G, pos = %s, (%s) " % ( image_value, dataValue, str(cpos), str(wpos) ) sliceIndex = caller.GetSliceIndex() self.slicePosition[iAxis] = sliceIndex self.updateTextDisplay( textDisplay ) coord = ispec.getWorldCoordsAsFloat(cpos) PM_VolumeSlicer.global_coords = coord screenPos = caller.GetCurrentScreenPosition() self.updateLensDisplay(screenPos, coord) if action == ImagePlaneWidget.Pushing: ispec = self.inputSpecs[ 0 ] md = ispec.getMetadata() latLonGrid = md.get( 'latLonGrid', True ) if not self.isSlicing: HyperwallManager.getInstance().setInteractionState( 'VolumeSlicer.Slicing' ) self.isSlicing = True sliceIndex = caller.GetSliceIndex() axisName, spos = ispec.getWorldCoord( sliceIndex, iAxis, latLonGrid ) textDisplay = " %s = %s ." % ( axisName, spos ) if iAxis == 0: p1 = caller.GetPoint1() # print " >++++++++++++++++++> Slicing: Set Slice[%d], index=%d, pos=%.2f, " % ( iAxis, sliceIndex, p1[0] ), textDisplay self.slicePosition[ iAxis ] = sliceIndex self.updateTextDisplay( textDisplay ) if (iAxis == 2): origin = caller.GetOrigin() for type in ( 'coastline', 'countries', 'states', 'lakes' ): line_specs = self.basemapLineSpecs.get( type, None ) polys_list = self.shapefilePolylineActors.get( type, None ) density = int( round( line_specs[1] ) ) if line_specs else 1 polys = polys_list[ density ] if polys_list else None if polys: pos = polys.GetPosition() pos1 = [ pos[0], pos[1], origin[2] ] polys.SetPosition( pos1 ) if self.generateContours: slice_data = caller.GetReslice2Output() if slice_data: slice_data.Update() iextent = slice_data.GetExtent() ispacing = slice_data.GetSpacing() self.contours.SetInput( slice_data ) self.contours.Modified() origin = caller.GetOrigin() contourLineActor = self.getContourActor( iAxis ) contourLineActor.SetPosition( origin[0], origin[1], origin[2] ) # contourLineActor.SetOrigin( origin[0], origin[1], origin[2] ) self.setVisibleContour( iAxis ) # print " Generate Contours, data dims = %s, origin = %s, pos = %s, extent = %s" % ( str( slice_data.GetDimensions() ), str(slice_data.GetOrigin()), str(origin), str(slice_data.GetExtent()) ) self.render()