Text archives Help
- From:
- To:
- Subject: [Manta] r2317 - trunk/scenes/csafe/python
- Date: Wed, 20 Aug 2008 15:51:45 -0600 (MDT)
Author: brownlee
Date: Wed Aug 20 15:51:45 2008
New Revision: 2317
Modified:
trunk/scenes/csafe/python/Configuration.py
trunk/scenes/csafe/python/Histogram.py
trunk/scenes/csafe/python/csafe_demo.py
Log:
fixing volume renderer, some minor csafe scene additions/fixes. it seems
that wxpython is showing 50% cpu utilization, need to figure out what was
changed there over the summer
Modified: trunk/scenes/csafe/python/Configuration.py
==============================================================================
--- trunk/scenes/csafe/python/Configuration.py (original)
+++ trunk/scenes/csafe/python/Configuration.py Wed Aug 20 15:51:45 2008
@@ -114,7 +114,7 @@
histValues1 = []
for i in range(scene.histogramBuckets):
histValues1.append(5.0)
- histoGroup =
Histogram.HistogramGroup(scene.frame.panel, histValues1, cropColorMin,
cropColorMax, 300.0, 40.0, scene.frame.transferFunctions[transferFID],
scene.frame.tPanel, scene, index, name)
+ histoGroup =
Histogram.HistogramGroup(scene.frame.panel, scene, index, name, transferFID)
histoGroup.SetBackgroundColour(wx.Colour(90,90,90))
histoGroup.group = group
scene.frame.histoGroups.append(histoGroup)
@@ -179,8 +179,16 @@
lines = f.readlines()
for i in range(len(lines)-1):
vol = lines[i].strip()
+ while (vol == "" and i < len(lines)-1):
+ i +=1
+ vol = lines[i].strip()
i+=1
sphere = lines[i].strip()
+ while(sphere == "" and i < len(lines) -1):
+ i += 1
+ sphere = lines[i].strip()
+ if (sphere == "" or vol == ""):
+ return
scene.nrrdFiles.append(sphere)
scene.nrrdFiles2.append(vol)
@@ -191,4 +199,4 @@
else:
for i in range(len(scene.nrrdFiles)):
f.write(str(scene.nrrdFiles2[i])+"\n")
- a.write(str(scene.nrrdFiles[i])+"\n")
+ f.write(str(scene.nrrdFiles[i])+"\n")
Modified: trunk/scenes/csafe/python/Histogram.py
==============================================================================
--- trunk/scenes/csafe/python/Histogram.py (original)
+++ trunk/scenes/csafe/python/Histogram.py Wed Aug 20 15:51:45 2008
@@ -9,6 +9,8 @@
import TransferF
import wx.lib.foldpanelbar
+from csafe import *
+
data = []
numBuckets = 1
@@ -225,6 +227,8 @@
min = 0
max = 0
dWidth = self.dMax - self.dMin
+ if dWidth == 0:
+ dWidth = 1.0
self.cropMin = (cropMin - self.dMin)/dWidth
self.cropMax = (cropMax - self.dMin)/dWidth
if self.cropDMin < 0.0:
@@ -247,6 +251,8 @@
#update dMin/Max, cropMin/Max based on zoomDMin/Max
def UpdateDMinMax(self):
absoluteDWidth = self.absoluteDMax - self.absoluteDMin
+ if absoluteDWidth == 0:
+ absoluteDWidth = 1.0
minBucket = int(float(self.zoomDMin/absoluteDWidth)*self.numBuckets )
maxBucket = int(float(self.zoomDMax/absoluteDWidth)*self.numBuckets)
if (self.numBuckets > 0):
@@ -283,6 +289,8 @@
absoluteDMin = self.absoluteDMin
absoluteDMax = self.absoluteDMax
absWidth = absoluteDMax - absoluteDMin
+ if absWidth == 0:
+ absWidth = 1.0
dWidth = dMax - dMin
# lines.append( (0,0, 50, 50) )
@@ -323,7 +331,7 @@
colorWidth = float(self.colorDMax - self.colorDMin)
croppedHeightValues = int(width)*[0]
- for i in range(0,width):
+ for i in range(0,int(width)):
#frequency = len( [x for x in data if (x >= start and x <= end)]
)
start2 = int(start)
end2 = int(end)
@@ -335,7 +343,7 @@
start += step
end += step
- for i in range(0, width):
+ for i in range(0, int(width)):
frequency = croppedHeightValues[i]
if frequency < hMin:
hMin = frequency
@@ -449,24 +457,51 @@
####################### Histogram Group ###########################
###################################################################
class HistogramGroup(wx.Panel):
- def __init__(self, parent, histValues, dataMin, dataMax, width, height,
transferF, transferFPanel, scene, varIndex, title = "No Name"):
- wx.Panel.__init__(self, parent, -1, (0, 0) , (width, height) )
- self.scene = scene
- self.varIndex = varIndex
- self.transferF = transferF
- self.transferFID = transferF.id
- self.transferFPanel = transferFPanel
+ def __init__(self, parent, scene, varIndex, title = "No Name",
transferFID = 0):
+ wx.Panel.__init__(self, parent, -1, (0, 0) , (300.0, 40.0) )
+ self.scene = scene
+ self.varIndex = varIndex
+ self.transferF = self.scene.frame.transferFunctions[transferFID]
+ self.transferFID = transferFID
+ self.transferFPanel = self.scene.tPanel
self.title = title
self.parent = parent
- self.datavalues = histValues
- self.dataMin = dataMin
- self.dataMax = dataMax
- self.numbuckets = len(histValues)
- self.width = width
- self.height = height
- self.group = 0 #0 = spheres, 1 = volume
+ self.datavalues = []
+ for i in range(0, self.scene.histogramBuckets):
+ self.datavalues.append(5)
+ min = SWIGIFYCreateDouble(0)
+ max = SWIGIFYCreateDouble(100)
+ self.dataMin = SWIGIFYGetDouble(min)
+ self.dataMax = SWIGIFYGetDouble(max)
+ self.numbuckets = self.scene.histogramBuckets
+ self.width = 300.0
+ self.height = 40.0
+ self.group = 0 #0 = spheres, 1 = volume
self.CreateElements()
+ self.SetBackgroundColour(scene.bgColor)
+
+# def __init__(self, parent, dataMin, dataMax, width, height, transferF,
transferFPanel, scene, varIndex, title = "No Name"):
+# wx.Panel.__init__(self, parent, -1, (0, 0) , (width, height) )
+# self.scene = scene
+# self.varIndex = varIndex
+# self.transferF = transferF
+# self.transferFID = transferF.id
+# self.transferFPanel = transferFPanel
+# self.title = title
+# self.parent = parent
+# self.datavalues = []
+# for i in range(0, self.scene.histogramBuckets):
+# self.datavalues.append(5)
+# self.dataMin = dataMin
+# self.dataMax = dataMax
+# self.numbuckets = self.scene.histogramBuckets
+# self.width = width
+# self.height = height
+# self.group = 0 #0 = spheres, 1 = volume
+#
+# self.CreateElements()
+# self.SetBackgroundColour(self.scene.bgColor)
def SetTransferF(self, transferF):
if (transferF != self.transferF):
Modified: trunk/scenes/csafe/python/csafe_demo.py
==============================================================================
--- trunk/scenes/csafe/python/csafe_demo.py (original)
+++ trunk/scenes/csafe/python/csafe_demo.py Wed Aug 20 15:51:45 2008
@@ -116,17 +116,16 @@
def Menu110(self, evt):
self.SetFocus()
- dlg = wx.DirDialog(self, message="Open UDA folder",
- style=wx.OPEN|wx.CHANGE_DIR)
+ dlg = wx.DirDialog(self, message="Open UDA folder",
style=wx.OPEN|wx.CHANGE_DIR)
if dlg.ShowModal() == wx.ID_OK:
- filename = dlg.GetPath()
+ filename = str(dlg.GetPath())
choices = []
self.scene.test.readUDAHeader(filename)
for i in range(self.scene.test.getUDANumVars()):
choices.append(str(self.scene.test.getUDAVarName(i)))
dlg2 = wx.SingleChoiceDialog(self, 'Name of Volume Value (must
be CCVariable, float):', 'Vol', choices, wx.CHOICEDLG_STYLE)
if dlg2.ShowModal() == wx.ID_OK:
- volName = dlg2.GetStringSelection()
+ volName = str(dlg2.GetStringSelection())
print "volume selected: " + str(volName)
self.scene.test.loadUDA(filename, volName)
t0 = TransferF.TransferF(self, [], 1, "x")
@@ -136,25 +135,12 @@
max = SWIGIFYCreateDouble(100)
dataMin = SWIGIFYGetDouble(min)
dataMax = SWIGIFYGetDouble(max)
- histValues1 = []
- histValues2 = []
- histValues3 = []
- for i in range(0,self.scene.histogramBuckets):
- histValues1.append(5)
- histValues2.append(5)
- histValues3.append(5)
- histoGroup0 =
Histogram.HistogramGroup(self.scene.frame.panel, histValues1, dataMin,
dataMax, 300, 40.0, self.scene.frame.transferFunctions[1], self.scene.tPanel,
self.scene, 0, "x")
+ histoGroup0 =
Histogram.HistogramGroup(self.scene.frame.panel, self.scene, 0, "x")
self.scene.frame.histoGroups.append(histoGroup0)
- histoGroup1 =
Histogram.HistogramGroup(self.scene.frame.panel, histValues2, dataMin,
dataMax, 300, 40.0, self.scene.frame.transferFunctions[2], self.scene.tPanel,
self.scene, 1, "y")
+ histoGroup1 =
Histogram.HistogramGroup(self.scene.frame.panel, self.scene, 1, "y")
self.scene.frame.histoGroups.append(histoGroup1)
- histoGroup2 =
Histogram.HistogramGroup(self.scene.frame.panel, histValues3, dataMin,
dataMax, 300, 40.0, self.scene.frame.transferFunctions[3], self.scene.tPanel,
self.scene, 2, "z")
+ histoGroup2 =
Histogram.HistogramGroup(self.scene.frame.panel, self.scene, 2, "z")
self.scene.frame.histoGroups.append(histoGroup2)
- histoGroup0.group = 0
- histoGroup1.group = 1
- histoGroup2.group = 2
- histoGroup0.SetBackgroundColour(self.scene.bgColor)
- histoGroup1.SetBackgroundColour(self.scene.bgColor)
- histoGroup2.SetBackgroundColour(self.scene.bgColor)
self.scene.frame.LayoutWindow()
self.BuildHistograms()
@@ -423,7 +409,6 @@
histValues1Ptr = SWIGIFYCreateIntArray(self.scene.histogramBuckets)
- histValues1 = []
dataMin1 = -1.1
dataMax1 = 2.2
min = SWIGIFYCreateDouble(0)
@@ -431,8 +416,6 @@
dataMin1 = SWIGIFYGetDouble(min)
dataMax1 = SWIGIFYGetDouble(max)
print "datamin: " + str(dataMin1) + " datamax: " + str(dataMax1)
- for i in range(0,self.scene.histogramBuckets):
- histValues1.append(5);
scene.getRenderParameters().maxDepth = 5
@@ -483,17 +466,14 @@
color = self.scene.bgColor
self.scene.histoVS = hvs = wx.BoxSizer(wx.VERTICAL)
self.scene.frame = self
- histoGroup0 = Histogram.HistogramGroup(self.panel, histValues1,
dataMin1, dataMax1, 300, 40.0, t0, tPanel, self.scene, 8, "volume")
+ histoGroup0 = Histogram.HistogramGroup(self.panel, self.scene, 8,
"volume")
histoGroup0.group = 1
- histoGroup0.SetBackgroundColour(color)
tPanel.transferFPanel.SetHistogramGroup(histoGroup0)
self.histoGroups = []
self.histoGroups.append(histoGroup0)
vs.Add(hvs,0,wx.ALIGN_TOP|wx.ALL,1)
vs.Add(tPanel,0,wx.ALIGN_TOP|wx.ALL,1)
-# animCtrlTitle = wx.StaticBox(self.panel, -1)
-# animCtrlSizer = wx.StaticBoxSizer(animCtrlTitle, wx.HORIZONTAL)
self.backBmp = wx.Bitmap("images/back.png.32x32", wx.BITMAP_TYPE_PNG)
self.playBmp = wx.Bitmap("images/play.png.32x32", wx.BITMAP_TYPE_PNG)
self.pauseBmp = wx.Bitmap("images/pause.png.32x32",
wx.BITMAP_TYPE_PNG)
@@ -581,6 +561,8 @@
self.cfg = ""
self.nrrdlist = ""
self.generate = False
+ self.uda = ""
+ self.udaVol = ""
setup = Setup()
@@ -595,9 +577,27 @@
Configuration.ReadConfiguration(frame1.scene, setup.cfg)
if (setup.nrrdlist != ""):
Configuration.ReadNRRDList(frame1.scene, setup.nrrdlist)
+ if (setup.uda != ""):
+ frame1.scene.test.readUDAHeader(str(setup.uda))
+ frame1.scene.test.loadUDA(str(setup.uda), str(setup.udaVol))
+ t0 = TransferF.TransferF(frame1, [], 1, "x")
+ histoGroup0 = Histogram.HistogramGroup(frame1.scene.frame.panel,
frame1.scene, 0, "x")
+ frame1.scene.frame.histoGroups.append(histoGroup0)
+ histoGroup1 = Histogram.HistogramGroup(frame1.scene.frame.panel,
frame1.scene, 1, "y")
+ frame1.scene.frame.histoGroups.append(histoGroup1)
+ histoGroup2 = Histogram.HistogramGroup(frame1.scene.frame.panel,
frame1.scene, 2, "z")
+ frame1.scene.frame.histoGroups.append(histoGroup2)
+
+ frame1.scene.frame.LayoutWindow()
+ frame1.BuildHistograms()
+ frame1.slider.SetRange(1, 1)
+ frame1.scene.mantaFrame.StartEngine()
+
if (setup.generate == True):
frame1.BuildScene()
- frame.StartEngine()
+ frame1.scene.mantaFrame.StartEngine()
+ frame1.scene.numThreads = setup.num_workers
+ frame1.scene.engine.changeNumWorkers(frame1.scene.numThreads)
def usage():
@@ -629,6 +629,11 @@
elif (args[i][0] == "nrrdlist"):
setup.nrrdlist = args[i][1][0]
print "loading nrrdlist: " + str(setup.nrrdlist)
+ elif (args[i][0] == "uda"):
+ setup.uda = args[i][1][0]
+ print "loading uda: " + str(setup.uda)
+ i += 1
+ setup.udaVol = args[i][1][0]
elif (args[i][0] == "g"):
setup.generate = True
print "generating scene on startup"
- [Manta] r2317 - trunk/scenes/csafe/python, brownlee, 08/20/2008
Archive powered by MHonArc 2.6.16.