def __init__(self, id, name): ivw.Processor.__init__(self, id, name) self.current = ivw.properties.OptionPropertyInt( "current", "Current", [ ivw.properties.IntOption("left_left", "left_left", 0), ivw.properties.IntOption("left_right", "left_right", 1), ivw.properties.IntOption("left_top", "left_top", 2), ivw.properties.IntOption("left_bottom", "left_bottom", 3), ivw.properties.IntOption("right_left", "right_left", 4), ivw.properties.IntOption("right_right", "right_right", 5), ivw.properties.IntOption("right_top", "right_top", 6), ivw.properties.IntOption("right_bottom", "right_bottom", 7), ], 0) self.addProperty(self.current) self.separation = ivw.properties.FloatProperty("offset", "Eye Separation", 0.01, 0.0, 0.1) self.addProperty(self.separation, owner=False) self.tilt = ivw.properties.FloatProperty("tilt", "View Tilt", 27, -90, 90) self.addProperty(self.tilt, owner=False) self.master = ivw.properties.CameraProperty("master", "master") self.addProperty(self.master, owner=False) self.camera = ivw.properties.CameraProperty("camera", "camera") self.addProperty(self.camera, owner=False) self.master.onChange(self.updateCamera) self.current.onChange(self.updateCamera) self.separation.onChange(self.updateCamera) self.tilt.onChange(self.updateCamera) self.camera.properties.cameraType.value = "SkewedPerspectiveCamera" self.camera.properties.lookFrom.minValue = glm.vec3(-10000.0) self.camera.properties.lookFrom.maxValue = glm.vec3(+10000.0) self.camera.properties.lookTo.minValue = glm.vec3(-10000.0) self.camera.properties.lookTo.maxValue = glm.vec3(+10000.0) self.camera.properties.offset.minValue = glm.vec2(-10000.0) self.camera.properties.offset.maxValue = glm.vec2(+10000.0) self.camera.properties.fov.value = 90 self.camera.properties.lookFrom.semantics = ivw.properties.PropertySemantics.SpinBox self.camera.properties.lookTo.semantics = ivw.properties.PropertySemantics.SpinBox self.camera.properties.lookUp.semantics = ivw.properties.PropertySemantics.SpinBox self.camera.properties.fov.semantics = ivw.properties.PropertySemantics.SpinBox self.camera.properties.offset.semantics = ivw.properties.PropertySemantics.SpinBox self.camera.readOnly = True
def updateCamera(self): def rotateVec(m, v): return glm.vec3(m * glm.vec4(v, 1.0)) self.camera.near.minValue = self.master.near.minValue self.camera.near.maxValue = self.master.near.maxValue self.camera.far.minValue = self.master.far.minValue self.camera.far.maxValue = self.master.far.maxValue self.camera.nearPlane = self.master.nearPlane self.camera.farPlane = self.master.farPlane self.camera.properties.fov.value = 90 rot = self.getRotation() offset = self.getOffset() viewDir = self.master.lookTo - self.master.lookFrom self.camera.lookFrom = self.master.lookFrom self.camera.lookTo = self.master.lookFrom + rotateVec(rot, viewDir) self.camera.lookUp = rotateVec(rot, self.master.lookUp) self.camera.properties.offset.value = glm.vec2(offset, 0)
prev = bg fontSize = 16 processorSpacing = 50 # vertical spacing of text vertTextSpacing = 1.0 / len(fontNames) # create one text overlay processor for each font face for i, (name, id) in enumerate(zip(fontNames, fontIdentifiers)): p = app.processorFactory.create("org.inviwo.TextOverlayGL", glm.ivec2(300, processorSpacing * i)) p.displayName = name p.font.color.value = glm.vec4(0, 0, 0, 1) p.font.fontFace.selectedIdentifier = id p.font.fontSize.value = fontSize p.font.anchor.value = glm.vec2(-1, 1) p.texts.text0.text.value = name p.texts.text0.position.value = glm.vec2(0.01, 1.0 - i * vertTextSpacing) network.addProcessor(p) if i > 0: # link font size network.addLink(prev.font.fontSize, p.font.fontSize) network.addLink(p.font.fontSize, prev.font.fontSize) network.addConnection(prev.outports[0], p.inports[0]) prev = p canvas.position = glm.ivec2(0, processorSpacing * len(fontNames) + 25)
# Inviwo Python script import matplotlib.cm as cm import matplotlib.pyplot as plt import inviwopy from inviwopy.glm import vec2, vec3 #http://matplotlib.org/examples/color/colormaps_reference.html #Perceptually Uniform Sequential : #['viridis', 'inferno', 'plasma', 'magma'] #Sequential : #['Blues', 'BuGn', 'BuPu','GnBu', 'Greens', 'Greys', 'Oranges', 'OrRd', 'PuBu', 'PuBuGn', 'PuRd', 'Purples', 'RdPu','Reds', 'YlGn', 'YlGnBu', 'YlOrBr', 'YlOrRd'] #Diverging : #['afmhot', 'autumn', 'bone', 'cool','copper', 'gist_heat', 'gray', 'hot','pink', 'spring', 'summer', 'winter'] #Qualitative : #['BrBG', 'bwr', 'coolwarm', 'PiYG', 'PRGn', 'PuOr', 'RdBu', 'RdGy', 'RdYlBu', 'RdYlGn', 'Spectral', 'seismic'] #Miscellaneous : #['Accent', 'Dark2', 'Paired', 'Pastel1', 'Pastel2', 'Set1', 'Set2', 'Set3'] #Sequential : #['gist_earth', 'terrain', 'ocean', 'gist_stern','brg', 'CMRmap', 'cubehelix','gnuplot', 'gnuplot2', 'gist_ncar', 'nipy_spectral', 'jet', 'rainbow', 'gist_rainbow', 'hsv', 'flag', 'prism'] tf = inviwopy.app.network.VolumeRaycaster.transferFunction tf.clear() cmapName = "hot" cmap = plt.get_cmap(cmapName) N = 128 for i in range(0, N, 1): x = i / (N - 1) a = 1.0 color = cmap(x) tf.addPoint(vec2(x, a), vec3(color[0], color[1], color[2]))
fontSize = 16 processorSpacing = 50 # vertical spacing of text vertTextSpacing = 1.0 / len(fontNames) ## create one text overlay processor for each font face for i, (name, id) in enumerate(zip(fontNames, fontIdentifiers)): p = app.processorFactory.create("org.inviwo.TextOverlayGL", glm.ivec2(300, processorSpacing * i)) p.displayName = name p.text.value = name p.color.value = glm.vec4(0, 0, 0, 1) p.font.fontFace.selectedIdentifier = id p.font.fontSize.value = fontSize p.font.anchor.value = glm.vec2(-1, 1) p.getPropertyByIdentifier("position").value = glm.vec2( 0.01, 1.0 - i * vertTextSpacing) network.addProcessor(p) if i > 0: # link font size network.addLink(prev.font.fontSize, p.font.fontSize) network.addLink(p.font.fontSize, prev.font.fontSize) network.addConnection(prev.outports[0], p.inports[0]) prev = p canvas.position = glm.ivec2(0, processorSpacing * len(fontNames) + 25)
import matplotlib.cm as cm import matplotlib.pyplot as plt import inviwopy from inviwopy.glm import vec2,vec3 #http://matplotlib.org/examples/color/colormaps_reference.html #Perceptually Uniform Sequential : #['viridis', 'inferno', 'plasma', 'magma'] #Sequential : #['Blues', 'BuGn', 'BuPu','GnBu', 'Greens', 'Greys', 'Oranges', 'OrRd', 'PuBu', 'PuBuGn', 'PuRd', 'Purples', 'RdPu','Reds', 'YlGn', 'YlGnBu', 'YlOrBr', 'YlOrRd'] #Diverging : #['afmhot', 'autumn', 'bone', 'cool','copper', 'gist_heat', 'gray', 'hot','pink', 'spring', 'summer', 'winter'] #Qualitative : #['BrBG', 'bwr', 'coolwarm', 'PiYG', 'PRGn', 'PuOr', 'RdBu', 'RdGy', 'RdYlBu', 'RdYlGn', 'Spectral', 'seismic'] #Miscellaneous : #['Accent', 'Dark2', 'Paired', 'Pastel1', 'Pastel2', 'Set1', 'Set2', 'Set3'] #Sequential : #['gist_earth', 'terrain', 'ocean', 'gist_stern','brg', 'CMRmap', 'cubehelix','gnuplot', 'gnuplot2', 'gist_ncar', 'nipy_spectral', 'jet', 'rainbow', 'gist_rainbow', 'hsv', 'flag', 'prism'] tf = inviwopy.app.network.VolumeRaycaster.transferFunction tf.clear() cmapName = "hot" cmap=plt.get_cmap(cmapName) N = 128 for i in range(0,N,1): x = i / (N-1) a = 1.0 color = cmap(x) tf.addPoint(vec2(x,a), vec3(color[0],color[1],color[2]))
# Inviwo Python script import inviwopy from inviwopy.glm import vec2,vec3 def color(x): r = x g = 1-x return vec3(r,g,0) tf = inviwopy.app.network.VolumeRaycaster.transferFunction tf.clear() tf.addPoint(vec2(0.0,0.0),vec3(0,0,0)) for i in range(1,256,9): x = i / 256.0 a = 0 if i%2==1: a = 0.1 tf.addPoint(vec2(x,a),color(x)) tf.addPoint(vec2(1.0,0.0),vec3(0,0,0))