Text archives Help
- From:
- To:
- Subject: [Manta] r2350 - in trunk: SwigInterface scenes/csafe/python
- Date: Thu, 4 Dec 2008 16:07:14 -0700 (MST)
Author: dav
Date: Thu Dec 4 16:07:10 2008
New Revision: 2350
Modified:
trunk/SwigInterface/CMakeLists.txt
trunk/scenes/csafe/python/Configuration.py
trunk/scenes/csafe/python/Histogram.py
trunk/scenes/csafe/python/SceneMenus.py
trunk/scenes/csafe/python/TransferF.py
trunk/scenes/csafe/python/csafe_demo.py
Log:
Beginings of cleanup up user interface...
General:
* Read images from an absolute path so that the script can be called from
anywhere.
* Add tooltips (can be turned off from the Help menu) to remind user what
each button does. (Good first start, but needs another pass.)
* White space improvements, including indentation and tab removal.
M scenes/csafe/python/TransferF.py
* See "General:" above.
M scenes/csafe/python/Histogram.py
* Keep track of measurementsWindow (dialog) so it can be shown/hidden
(instead of being created/destroyed).
Re-use the same window over and over instead of continually creating (and
not correctly managing)
multiple windows. (I think this works for multiple colormaps, but need to
verify)
* Bring up measurementsWindow near mouse.
* See "General:" above.
M scenes/csafe/python/SceneMenus.py
* Trying to get "ESC" key to work, but for some reason (wxpython sucks?) it
ignores the key down binding...
Leaving this here in case it is needed at some point.
M scenes/csafe/python/csafe_demo.py
* Added "#! /usr/bin/python" at top of scrpit so I can run it directly.
* Group "menu appending" so it is more clear what is going on.
* Add ability to toggle on/off tooltips
* Indent/use white space better/remove some tabs. (Tabs aren't very user
friendly in a language that
depends on 'proper' indentation...
* Turn on/off the 'generate' menu item (hopefully correctly) to handle
different run states.
* See "General:" above.
* Removed some unnecessary debug print statements.
M scenes/csafe/python/Configuration.py
* When the user goes to save a configuration file, add ".cfg" extension if
the user hasn't already done so.
* Removed some evil tabs.
M SwigInterface/CMakeLists.txt
* Update the pythonpath.csh script to add in WX paths as necessary...
Modified: trunk/SwigInterface/CMakeLists.txt
==============================================================================
--- trunk/SwigInterface/CMakeLists.txt (original)
+++ trunk/SwigInterface/CMakeLists.txt Thu Dec 4 16:07:10 2008
@@ -144,7 +144,21 @@
)
FILE(WRITE ${CMAKE_BINARY_DIR}/bin/pythonpath.csh
- "setenv PYTHONPATH
${CMAKE_SOURCE_DIR}/SwigInterface:${CMAKE_BINARY_DIR}/lib\n\n")
+ "setenv PYTHONPATH
${CMAKE_SOURCE_DIR}/SwigInterface:${CMAKE_BINARY_DIR}/lib\n"
+ "\n"
+ "if ( $?WXPATH ) then\n"
+ " setenv PYTHONPATH $WXPATH\\:$PYTHONPATH\n"
+ "endif\n"
+ "\n"
+ "if ( $?WXLIB ) then\n"
+ " if ( $?LD_LIBRARY_PATH ) then\n"
+ " setenv LD_LIBRARY_PATH $WXLIB\\:$LD_LIBRARY_PATH\n"
+ " else\n"
+ " setenv LD_LIBRARY_PATH $WXLIB\n"
+ " endif\n"
+ "endif\n"
+ "\n"
+ )
FILE(WRITE ${CMAKE_BINARY_DIR}/bin/pythonpath.sh
"export
PYTHONPATH=${CMAKE_SOURCE_DIR}/SwigInterface:${CMAKE_BINARY_DIR}/lib\n\n")
Modified: trunk/scenes/csafe/python/Configuration.py
==============================================================================
--- trunk/scenes/csafe/python/Configuration.py (original)
+++ trunk/scenes/csafe/python/Configuration.py Thu Dec 4 16:07:10 2008
@@ -1,5 +1,5 @@
-import sys, os, time, traceback, types, random
+import sys, os, time, traceback, types, random, re
import wx
import SceneInfo
import Histogram
@@ -9,51 +9,58 @@
from manta import *
def WriteConfiguration(scene, filename):
- f = open(filename, 'w')
- ts = scene.frame.transferFunctions
- for i in range(len(ts)):
- t = ts[i]
- f.write('[Transfer Function]\n')
- f.write(t.label+'\n')
- f.write(str(t.id)+'\n')
- f.write(str(len(t.colors))+'\n')
- for j in range(len(t.colors)):
- c = t.colors[j]
- f.write(str(c[0])+' '+str(c[1])+' '+str(c[2])+'
'+str(c[3])+' '+str(c[4])+'\n')
- f.write('\n\n')
- histoGroups = scene.frame.histoGroups
- for i in range(len(histoGroups)):
- h = histoGroups[i]
- f.write('[Histogram]\n')
- f.write(h.title+'\n')
- f.write(str(h.varIndex)+'\n')
- f.write(str(h.group)+'\n')
- f.write(str(h.histogram.zoomDMin)+'
'+str(h.histogram.zoomDMax)+'\n')
- f.write(str(h.dataMin)+' '+str(h.dataMax)+'\n')
- f.write(str(h.histogram.cropDMin)+'
'+str(h.histogram.cropDMax)+'\n')
- f.write(str(h.transferFID)+'\n')
- f.write('\n\n')
- f.write('[Scene Properties]\n')
- f.write(str(scene.duration)+'\n')
- f.write(str(scene.ridx)+'\n')
- f.write(str(scene.radius)+'\n')
- f.write(str(int(scene.cidx))+'\n')
- f.write(str(scene.numThreads)+'\n')
- for j in range(3):
- f.write(str(scene.volumeMinBound[j])+" ")
- f.write("\n")
- for j in range(3):
- f.write(str(scene.volumeMaxBound[j])+" ")
- f.write("\n")
- f.write(str(len(scene.nrrdFiles2))+'\n')
- for i in range(len(scene.nrrdFiles2)):
- f.write(scene.nrrdFiles2[i]+'\n')
- print scene.nrrdFiles
- print len(scene.nrrdFiles)
- f.write(str(len(scene.nrrdFiles))+'\n')
- for i in range(len(scene.nrrdFiles)):
- f.write(scene.nrrdFiles[i]+'\n')
- f.close()
+
+ # Make sure the 'filename' ends with ".cfg". If not, add it.
+ if ( not re.compile(".+\.cfg$").match( filename ) ) :
+ filename = filename + ".cfg"
+
+ print "Saving " + filename
+
+ f = open(filename, 'w')
+ ts = scene.frame.transferFunctions
+ for i in range(len(ts)):
+ t = ts[i]
+ f.write('[Transfer Function]\n')
+ f.write(t.label+'\n')
+ f.write(str(t.id)+'\n')
+ f.write(str(len(t.colors))+'\n')
+ for j in range(len(t.colors)):
+ c = t.colors[j]
+ f.write(str(c[0])+' '+str(c[1])+' '+str(c[2])+'
'+str(c[3])+' '+str(c[4])+'\n')
+ f.write('\n\n')
+ histoGroups = scene.frame.histoGroups
+ for i in range(len(histoGroups)):
+ h = histoGroups[i]
+ f.write('[Histogram]\n')
+ f.write(h.title+'\n')
+ f.write(str(h.varIndex)+'\n')
+ f.write(str(h.group)+'\n')
+ f.write(str(h.histogram.zoomDMin)+'
'+str(h.histogram.zoomDMax)+'\n')
+ f.write(str(h.dataMin)+' '+str(h.dataMax)+'\n')
+ f.write(str(h.histogram.cropDMin)+'
'+str(h.histogram.cropDMax)+'\n')
+ f.write(str(h.transferFID)+'\n')
+ f.write('\n\n')
+ f.write('[Scene Properties]\n')
+ f.write(str(scene.duration)+'\n')
+ f.write(str(scene.ridx)+'\n')
+ f.write(str(scene.radius)+'\n')
+ f.write(str(int(scene.cidx))+'\n')
+ f.write(str(scene.numThreads)+'\n')
+ for j in range(3):
+ f.write(str(scene.volumeMinBound[j])+" ")
+ f.write("\n")
+ for j in range(3):
+ f.write(str(scene.volumeMaxBound[j])+" ")
+ f.write("\n")
+ f.write(str(len(scene.nrrdFiles2))+'\n')
+ for i in range(len(scene.nrrdFiles2)):
+ f.write(scene.nrrdFiles2[i]+'\n')
+ print scene.nrrdFiles
+ print len(scene.nrrdFiles)
+ f.write(str(len(scene.nrrdFiles))+'\n')
+ for i in range(len(scene.nrrdFiles)):
+ f.write(scene.nrrdFiles[i]+'\n')
+ f.close()
def ReadConfiguration(scene, filename):
f = open(filename, 'r')
Modified: trunk/scenes/csafe/python/Histogram.py
==============================================================================
--- trunk/scenes/csafe/python/Histogram.py (original)
+++ trunk/scenes/csafe/python/Histogram.py Thu Dec 4 16:07:10 2008
@@ -9,8 +9,8 @@
import TransferF
import wx.lib.foldpanelbar
-from csafe import *
-
+from csafe import *
+from csafe_demo import setup, moveToMouse
data = []
numBuckets = 1
@@ -23,6 +23,7 @@
height = 20.0
barWidth = 0.0
colors = []
+measurementsWindow = []
def opj(path):
#copied from demo.py
@@ -35,31 +36,31 @@
class HistogramPanel(wx.Panel):
def __init__(self, parent,histValues, dataMin, dataMax, width, height,
transferF, scene, varIndex):
- self.scene = scene
- self.varIndex = varIndex
+ self.scene = scene
+ self.varIndex = varIndex
self.paddingW = 20.0
self.paddingH = 15.0
wx.Panel.__init__(self, parent, -1, (0, 0) , (width+self.paddingW,
height+self.paddingH) )
- self.dragging = False
+ self.dragging = False
self.selecting = False
self.draggingLeft = False
self.draggingRight = False
self.dragWidth = 1.0
self.cropMin = 0.0 #selected region from [0,1]
self.cropMax = 1.0
- #if (varIndex == 3): #TODO: take this out!
- # self.cropMin = -0.5
- # self.cropMax = 1.5;
+ #if (varIndex == 3): #TODO: take this out!
+ # self.cropMin = -0.5
+ # self.cropMax = 1.5;
self.colorMin = -99999.0
self.colorMax = 99999.0
self.dMin = dataMin
- self.dMax = dataMax #the min and max of displayed data
+ self.dMax = dataMax #the min and max of displayed data
self.zoomDMin = dataMin #min data value of data to display (may not
be an actual value contianed in data)
self.zoomDMax = dataMax #max data value of data to display (may not
be an actual value contianed in data)
self.absoluteDMin = self.dMin #absolute min of the data
self.absoluteDMax = self.dMax
- self.zooms = []
+ self.zooms = []
wx.EVT_PAINT(self, self.OnPaint)
self.transferF = transferF
self.SetValues(histValues, len(histValues), width, height)
@@ -74,11 +75,11 @@
self.Bind(wx.EVT_MOTION, self.OnMotion)
self.Bind( wx.EVT_MOUSEWHEEL, self.OnMouseWheel )
self.SetBackgroundColour(wx.Colour(90,90,90))
- #self.SetForegroundColour(wx.Colour(255,255,255))
- self.parent = parent
+ #self.SetForegroundColour(wx.Colour(255,255,255))
+ self.parent = parent
def SetHistValues(self, histValues, dataMin, dataMax):
- self.colorMin = -99999.0
+ self.colorMin = -99999.0
self.colorMax = 99999.0
self.dMin = dataMin
self.dMax = dataMax #the min and max of displayed data
@@ -86,19 +87,19 @@
self.zoomDMax = dataMax #max data value of data to display (may not
be an actual value contianed in data)
self.absoluteDMin = self.dMin #absolute min of the data (ignoring
zoom)
self.absoluteDMax = self.dMax
- self.colorDMin = self.dMin #scale colors by this minimum value
+ self.colorDMin = self.dMin #scale colors by this minimum value
self.colorDMax = self.dMax #scale colors by this maximum value
self.zoomDMin = self.dMin
self.zoomDMax = self.dMax
- self.data = histValues
- self.numBuckets = len(histValues)
- self.Update()
+ self.data = histValues
+ self.numBuckets = len(histValues)
+ self.Update()
def OnMouseWheel(self, evt):
pos = float(evt.GetPosition().x -
self.paddingW/2.0)/float(self.width)
delta = evt.GetWheelDelta()
rot = evt.GetWheelRotation()/delta
- #zoom in if rot > 0, out if ro < 0
+ # zoom in if rot > 0, out if ro < 0
if (rot > 0):
zoomAmount = 0.75 # the smaller the more zooming
self.zooms.append( (self.zoomDMin, self.zoomDMax))
@@ -141,7 +142,8 @@
def OnClick(self, evt):
pos = float(evt.GetPosition().x -
self.paddingW/2.0)/float(self.width)
sideLen = 0.05
- if (abs(pos - float(self.cropMin)) <= float(sideLen)) and (abs(pos -
float(self.cropMin)) < abs(pos - float(self.cropMax))):
+ if (abs(pos - float(self.cropMin)) <= float(sideLen)) and \
+ (abs(pos - float(self.cropMin)) < abs(pos - float(self.cropMax))):
self.draggingLeft = True
self.draggingRight = False
self.cropMin = pos
@@ -173,7 +175,7 @@
self.selecting = False
self.draggingLeft = False
self.draggingRight = False
- #self.scene.test.setClipMinMax(self.varIndex, self.cropDMin,
self.cropDMax)
+ #self.scene.test.setClipMinMax(self.varIndex, self.cropDMin,
self.cropDMax)
def OnRightClick(self, evt):
print "right"
@@ -210,7 +212,7 @@
self.UpdateDMinMax()
self.Refresh()
update_clip = True
- if (update_clip and self.parent.group != 1): #if not the volumedata
+ if (update_clip and self.parent.group != 1): #if not the volumedata
index = self.varIndex;
min = float(self.cropDMin - 0.00001)
max = float(self.cropDMax + 0.00001)
@@ -225,17 +227,17 @@
#update dMin/Max, cropMin/Max based on zoomDMin/Max
def UpdateDMinMax(self):
- absoluteDWidth = self.absoluteDMax - self.absoluteDMin
+ 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)
+ minBucket = int(float(self.zoomDMin/absoluteDWidth)*self.numBuckets )
+ maxBucket = int(float(self.zoomDMax/absoluteDWidth)*self.numBuckets)
if (self.numBuckets > 0):
- self.dMin = minBucket*(absoluteDWidth/self.numBuckets)
- self.dMax = maxBucket*(absoluteDWidth/self.numBuckets)
- else:
- self.dMin = self.dMax = 0.0
- dWidth = self.dMax - self.dMin
+ self.dMin = minBucket*(absoluteDWidth/self.numBuckets)
+ self.dMax = maxBucket*(absoluteDWidth/self.numBuckets)
+ else:
+ self.dMin = self.dMax = 0.0
+ dWidth = self.dMax - self.dMin
self.cropDMin = self.cropMin*dWidth + self.dMin #cropped data min
self.cropDMax = self.cropMax*dWidth + self.dMin #cropped data max
@@ -261,26 +263,26 @@
numBuckets = self.numBuckets
dMin = self.dMin
dMax = self.dMax
- absoluteDMin = self.absoluteDMin
- absoluteDMax = self.absoluteDMax
- absWidth = absoluteDMax - absoluteDMin
+ absoluteDMin = self.absoluteDMin
+ absoluteDMax = self.absoluteDMax
+ absWidth = absoluteDMax - absoluteDMin
if absWidth == 0:
absWidth = 1.0
- dWidth = dMax - dMin
+ dWidth = dMax - dMin
# lines.append( (0,0, 50, 50) )
#function(lines, range(0.0, 1.0))
start = float((dMin - absoluteDMin)/absWidth*float(numBuckets))
if (numBuckets > 0):
- step = float((dWidth/absWidth)/float(width))*float(numBuckets)
- else:
- step = 0.0
+ step = float((dWidth/absWidth)/float(width))*float(numBuckets)
+ else:
+ step = 0.0
end = start + step
print step
- if (numBuckets > 0):
+ if (numBuckets > 0):
barWidth = self.barWidth = float(width)/float(numBuckets)
- else:
- barWidth = self.barWidth = float(width)
+ else:
+ barWidth = self.barWidth = float(width)
#print barWidth
blx = 0.0 + barWidth/2.0 + self.paddingW/2.0 # bottom left x
@@ -292,69 +294,69 @@
#get the minimum and maximum frequencies in displayed range
#for i in range(int(numBuckets)):
- # frequency = 1.0
- # filter(lines, range(start, end) )
- # frequency = len( [x for x in data if (x >= start and x <= end)]
)
-# print '%f %f %f' % (frequency, start, end)
- # frequency = data[i]
- # if frequency < hMin:
- # hMin = frequency
- # if frequency > hMax:
- # hMax = frequency
- #start += step
- #end += step
+ # frequency = 1.0
+ # filter(lines, range(start, end) )
+ # frequency = len( [x for x in data if (x >= start and x <= end)]
)
+ # print '%f %f %f' % (frequency, start, end)
+ # frequency = data[i]
+ # if frequency < hMin:
+ # hMin = frequency
+ # if frequency > hMax:
+ # hMax = frequency
+ # start += step
+ # end += step
colorWidth = float(self.colorDMax - self.colorDMin)
- croppedHeightValues = int(width)*[0]
+ croppedHeightValues = int(width)*[0]
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)
if (start2 == end2):
end2 += 1
- for j in range(start2,end2):
+ for j in range(start2,end2):
if j >= 0 and j < numBuckets:
croppedHeightValues[i] += data[j]
- start += step
- end += step
-
- for i in range(0, int(width)):
- frequency = croppedHeightValues[i]
- if frequency < hMin:
- hMin = frequency
- if frequency > hMax:
- hMax = frequency
- if hMax > hMin:
- for i in range(0, width):
+ start += step
+ end += step
+
+ for i in range(0, int(width)):
+ frequency = croppedHeightValues[i]
+ if frequency < hMin:
+ hMin = frequency
+ if frequency > hMax:
+ hMax = frequency
+ if hMax > hMin:
+ for i in range(0, width):
frequency = croppedHeightValues[i]
- barHeightNorm = float(frequency)/float(hMax)
- #print str(frequency) + " " + str(barHeightNorm)
+ barHeightNorm = float(frequency)/float(hMax)
+ #print str(frequency) + " " + str(barHeightNorm)
if float(barHeightNorm) > 1.0:
print "error"
- # print '%f %f %f %f' % (frequency, start, end, barHeightNorm)
+ # print '%f %f %f %f' % (frequency, start, end, barHeightNorm)
# colorPos = (( (float(i)/width)*(absoluteDMax-absoluteDMin))
+ absoluteDMin- self.colorDMin)/colorWidth
colorPos = ((
(float(i)/width)*(self.zoomDMax-self.zoomDMin)) + self.zoomDMin-
self.colorDMin)/colorWidth
- #print colorPos
- color = self.transferF.GetColor(colorPos)
+ #print colorPos
+ color = self.transferF.GetColor(colorPos)
self.lines.append( (color, ( blx + i, bly, blx + i, (bly -
barHeightNorm*height) ) ) )
self.Refresh()
def OnPaint(self, evt=None):
pdc = wx.PaintDC(self)
#pdc.Clear()
- try:
+ try:
dc = wx.GCDC(pdc)
- except:
- dc = pdc
+ except:
+ dc = pdc
#gc = wx.GraphicsContext.Create(dc)
dc.SetPen(wx.Pen("BLACK", 1) )
#dc.DrawRectangle( 0, 0, width, height)
self.DrawLines(dc)
try:
- brushColor = wx.Colour(0,0,0,56)
- except:
- brushColor = wx.Colour(0,0,0)
+ brushColor = wx.Colour(0,0,0,56)
+ except:
+ brushColor = wx.Colour(0,0,0)
dc.SetBrush(wx.Brush( brushColor ) )
dc.SetPen(wx.Pen("BLACK", 0) )
cropMin = self.cropMin
@@ -367,13 +369,13 @@
dc.DrawRectangle(float(cropMin)*float(self.width) +
self.paddingW/2.0 , 0, cropWidth, self.height)
#draw cropping texta
- dc.SetTextForeground(wx.Colour(255,255,255))
- self.SetForegroundColour(wx.Colour(255,0,0))
- dc.SetPen(wx.Pen(wx.Colour(255,255,255), 1))
- dc.SetBrush(wx.Brush(wx.Colour(255,255,255)))
- fontSize = 10
- if self.scene.biggify == True:
- fontSize = 12
+ dc.SetTextForeground(wx.Colour(255,255,255))
+ self.SetForegroundColour(wx.Colour(255,0,0))
+ dc.SetPen(wx.Pen(wx.Colour(255,255,255), 1))
+ dc.SetBrush(wx.Brush(wx.Colour(255,255,255)))
+ fontSize = 10
+ if self.scene.biggify == True:
+ fontSize = 12
dc.SetFont(wx.Font(fontSize, wx.FONTFAMILY_DEFAULT, wx.NORMAL,
wx.FONTWEIGHT_BOLD))
string = str("%1.2g" % self.cropDMin)
extent = dc.GetTextExtent(string)
@@ -417,10 +419,10 @@
r = self.lines[i][0][0]*255.0
g = self.lines[i][0][1]*255.0
b = self.lines[i][0][2]*255.0
- try:
- penColor = wx.Colour(r,g,b,a)
- except:
- penColor = wx.Colour(r,g,b)
+ try:
+ penColor = wx.Colour(r,g,b,a)
+ except:
+ penColor = wx.Colour(r,g,b)
dc.SetPen(wx.Pen(penColor, self.barWidth))
dc.DrawLine( self.lines[i][1][0], self.lines[i][1][1],
self.lines[i][1][2], self.lines[i][1][3])
@@ -445,7 +447,7 @@
self.datavalues = []
for i in range(0, self.scene.histogramBuckets):
self.datavalues.append(5)
- self.dataMin = 0
+ self.dataMin = 0
self.dataMax = 100
self.numbuckets = self.scene.histogramBuckets
self.width = 300.0
@@ -457,22 +459,22 @@
# 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.scene = scene
+# self.varIndex = varIndex
# self.transferF = transferF
-# self.transferFID = transferF.id
+# 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.dataMin = dataMin
+# self.dataMax = dataMax
# self.numbuckets = self.scene.histogramBuckets
# self.width = width
# self.height = height
-# self.group = 0 #0 = spheres, 1 = volume
+# self.group = 0 #0 = spheres, 1 = volume
#
# self.CreateElements()
# self.SetBackgroundColour(self.scene.bgColor)
@@ -486,26 +488,32 @@
else:
self.scene.test.setVolCMap(transferF.cmap)
- def SetValues(self, histValues, dataMin, dataMax):
- self.dataMin = dataMin
- self.dataMax = dataMax
- self.datavalues = histValues
- self.histogram.SetHistValues(histValues, dataMin, dataMax)
-
+ def SetValues(self, histValues, dataMin, dataMax):
+ self.dataMin = dataMin
+ self.dataMax = dataMax
+ self.datavalues = histValues
+ self.histogram.SetHistValues(histValues, dataMin, dataMax)
+
def SetCMinMax(self, min, max):
- zoomMin = self.histogram.zoomDMin
- zoomMax = self.histogram.zoomDMax
- cropMin = self.histogram.cropDMin
- cropMax = self.histogram.cropDMax
- self.SendValues(zoomMin, zoomMax, cropMin, cropMax, float(min),
float(max))
+ zoomMin = self.histogram.zoomDMin
+ zoomMax = self.histogram.zoomDMax
+ cropMin = self.histogram.cropDMin
+ cropMax = self.histogram.cropDMax
+ self.SendValues(zoomMin, zoomMax, cropMin, cropMax, float(min),
float(max))
def OnClick(self, evt):
print "clicked histogro"
def CreateElements(self):
+ path = setup.csafe_scene_path
+
self.vs = vs = wx.BoxSizer( wx.VERTICAL )
box1_title = wx.StaticBox( self, -1, self.title )
- self.histogram = HistogramPanel(self, self.datavalues, self.dataMin,
self.dataMax, self.width, self.height, self.transferF, self.scene,
self.varIndex)
+
+ box1_title.SetForegroundColour( wx.WHITE ) # Make label readable!
+
+ self.histogram = HistogramPanel( self, self.datavalues,
self.dataMin, self.dataMax, self.width, self.height,
+ self.transferF, self.scene,
self.varIndex )
self.box1 = box1 = wx.StaticBoxSizer( box1_title, wx.VERTICAL )
#grid1 = wx.FlexGridSizer( 2, 2, 0, 0 )
gbs = wx.GridBagSizer(1,3)
@@ -517,28 +525,37 @@
gbs.Add(self.histogram,(0, 0), (2, 2) )
if self.scene.histogramBMPLoaded == False:
- self.scene.bmpVis = wx.Bitmap(opj('images/eye.png.8x8'),
wx.BITMAP_TYPE_PNG)
- self.scene.bmpColor = wx.Bitmap(opj('images/color.png.8x8'),
wx.BITMAP_TYPE_PNG)
- self.scene.bmpRuler = wx.Bitmap(opj('images/ruler.png.8x8'),
wx.BITMAP_TYPE_PNG)
- self.scene.bmpZoomIn =
wx.Bitmap(opj('images/zoomin.png.8x8'), wx.BITMAP_TYPE_PNG)
- self.scene.bmpZoomOut =
wx.Bitmap(opj('images/zoomout.png.8x8'), wx.BITMAP_TYPE_PNG)
- self.scene.histogramBMPLoaded = True
-
- self.bmpVis = self.scene.bmpVis
- self.bmpColor = self.scene.bmpColor
- self.bmpRuler = self.scene.bmpRuler
- self.bmpZoomIn = self.scene.bmpZoomIn
- self.bmpZoomOut = self.scene.bmpZoomOut
+ self.scene.bmpVis =
wx.Bitmap(opj(path+'images/eye.png.8x8'), wx.BITMAP_TYPE_PNG)
+ self.scene.bmpColor =
wx.Bitmap(opj(path+'images/color.png.8x8'), wx.BITMAP_TYPE_PNG)
+ self.scene.bmpRuler =
wx.Bitmap(opj(path+'images/ruler.png.8x8'), wx.BITMAP_TYPE_PNG)
+ self.scene.bmpZoomIn =
wx.Bitmap(opj(path+'images/zoomin.png.8x8'), wx.BITMAP_TYPE_PNG)
+ self.scene.bmpZoomOut =
wx.Bitmap(opj(path+'images/zoomout.png.8x8'), wx.BITMAP_TYPE_PNG)
+ self.scene.histogramBMPLoaded = True
+
+ self.bmpVis = self.scene.bmpVis
+ self.bmpColor = self.scene.bmpColor
+ self.bmpRuler = self.scene.bmpRuler
+ self.bmpZoomIn = self.scene.bmpZoomIn
+ self.bmpZoomOut = self.scene.bmpZoomOut
size = 10
visibilityB = wx.BitmapButton(self, -1, self.bmpVis, (8,8),
style=wx.NO_BORDER)
+ visibilityB.SetToolTip( wx.ToolTip( "Iconify this color map." ) )
+
self.visibilityB = visibilityB
colorB = wx.BitmapButton(self, -1, self.bmpColor, (0,0),
style=wx.NO_BORDER)
+ colorB.SetToolTip( wx.ToolTip( "Edit this color map (in color map
editor, below)" ) )
+
self.colorB = colorB
self.rulerB = wx.BitmapButton(self, -1, self.bmpRuler, (0,0),
style=wx.NO_BORDER)
+ self.rulerB.SetToolTip( wx.ToolTip( "Options" ) )
+
self.zoomInB = wx.BitmapButton(self, -1, self.bmpZoomIn, (0,0),
style=wx.NO_BORDER)
+ self.zoomInB.SetToolTip( wx.ToolTip( "Zoom In" ) )
+
self.zoomOutB = wx.BitmapButton(self, -1, self.bmpZoomOut, (0,0),
style=wx.NO_BORDER)
-
+ self.zoomOutB.SetToolTip( wx.ToolTip( "Zoom Out" ) )
+
self.Bind(wx.EVT_BUTTON, self.OnClickVisible, visibilityB)
self.Bind(wx.EVT_BUTTON, self.OnClickColor, colorB)
self.Bind(wx.EVT_BUTTON, self.OnClickMeasurements, self.rulerB)
@@ -557,16 +574,16 @@
vs2.AddSpacer(space)
vs2.Add( self.rulerB)
vs2.AddSpacer(space)
- vs3 = wx.BoxSizer(wx.VERTICAL)
+ vs3 = wx.BoxSizer(wx.VERTICAL)
vs3.Add( self.zoomInB)
vs3.AddSpacer(space)
vs3.Add( self.zoomOutB )
vs2.Layout()
- vs3.Layout()
+ vs3.Layout()
- vsH = wx.BoxSizer(wx.HORIZONTAL)
- vsH.Add(vs2, wx.ALIGN_CENTER|wx.ALL,0)
- vsH.Add(vs3, wx.ALIGN_CENTER|wx.ALL,0)
+ vsH = wx.BoxSizer(wx.HORIZONTAL)
+ vsH.Add(vs2, wx.ALIGN_CENTER|wx.ALL,0)
+ vsH.Add(vs3, wx.ALIGN_CENTER|wx.ALL,0)
#vs3.Layout()
gbs.Add(vsH, (0, 2), (2, 1))
#gbs.Add(vs3, (0, 3), (2, 1))
@@ -583,10 +600,17 @@
self.visible = True
def OnClickMeasurements(self, evt):
- win = MeasurementsFrame(self, -1, self.title + " Measurements",
self.histogram.zoomDMin, self.histogram.zoomDMax, self.histogram.cropDMin,
self.histogram.cropDMax, self.histogram.colorDMin, self.histogram.colorDMax,
self.group)
- win.Show(True)
+ global measurementsWindow
+ if not measurementsWindow:
+ measurementsWindow = MeasurementsFrame( self, -1, self.title + "
Measurements",
+ self.histogram.zoomDMin,
self.histogram.zoomDMax,
+ self.histogram.cropDMin,
self.histogram.cropDMax,
+
self.histogram.colorDMin, self.histogram.colorDMax, self.group)
+ moveToMouse( measurementsWindow )
+ measurementsWindow.Show(True)
+ measurementsWindow.Raise()
- def SendValues(self, zoomMin, zoomMax, cropMin, cropMax, colorMin,
colorMax): #sent from MeasurementsFrame
+ def SendValues(self, zoomMin, zoomMax, cropMin, cropMax, colorMin,
colorMax): # sent from MeasurementsFrame
#print "values arrived"
self.histogram.zooms.append( (self.histogram.zoomDMin,
self.histogram.zoomDMax))
self.histogram.zoomDMin = zoomMin
@@ -612,11 +636,11 @@
self.histogram.cropDMin = self.histogram.cropMin*dWidth +
self.histogram.dMin #cropped data min
self.histogram.cropDMax = self.histogram.cropMax*dWidth +
self.histogram.dMin #cropped data max
- if (self.histogram.parent.group == 0):
+ if (self.histogram.parent.group == 0):
if self.transferFPanel.transferFPanel.histogramGroup == self:
- self.scene.test.setSphereColorMinMax(self.histogram.varIndex,
colorMin, colorMax)
- else:
- self.scene.test.setVolColorMinMax(colorMin, colorMax)
+
self.scene.test.setSphereColorMinMax(self.histogram.varIndex, colorMin,
colorMax)
+ else:
+ self.scene.test.setVolColorMinMax(colorMin, colorMax)
def OnClickZoomIn(self, evt):
self.histogram.ZoomIn()
@@ -632,25 +656,32 @@
self.transferFPanel.transferFPanel.SetHistogramGroup(self)
self.transferFPanel.SetTransferF(self.transferF)
self.transferFPanel.SetUpdateFunction(self.Update())
- if self.varIndex != self.scene.volVar:
- self.scene.test.setCidx(self.varIndex)
- if (self.transferF != None):
- self.scene.test.setSphereCMap(self.transferF.cmap)
+ if self.varIndex != self.scene.volVar:
+ self.scene.test.setCidx(self.varIndex)
+ if (self.transferF != None):
+ self.scene.test.setSphereCMap(self.transferF.cmap)
self.scene.test.setSphereColorMinMax(self.varIndex,
self.histogram.colorDMin, self.histogram.colorDMax)
def OnClickVisible(self, evt):
if self.visible:
+ path = setup.csafe_scene_path
self.sizer.ShowItems(False)
#self.sizer.Show(self.visibilityB, True, True)
#self.sizer.Show(self.historgram, False, True)
#self.sizer.Show(self.colorB, False, True)
self.visible = False
+
box1_title = wx.StaticBox( self, -1, self.title )
+ box1_title.SetForegroundColour( wx.WHITE ) # Make label readable!
+
box = wx.StaticBoxSizer( box1_title, wx.HORIZONTAL )
sizer = wx.BoxSizer( wx.HORIZONTAL )
box.AddSpacer((100,0))
- bmpVis = wx.Bitmap(opj('images/eye.png.8x8'))
- visibilityB = wx.BitmapButton(self, -1, bmpVis, (0,0), (12, 12))
+ bmpVis = wx.Bitmap(opj(path+'images/eye.png.8x8'))
+
+ visibilityB = wx.BitmapButton(self, -1, bmpVis, (8,8), (12, 12))
+ visibilityB.SetToolTip( wx.ToolTip( "Un-iconfiy this color map."
) )
+
box.Add(visibilityB, wx.ALIGN_CENTRE|wx.ALL, 0, 0)
self.Bind(wx.EVT_BUTTON, self.OnClickVisible, visibilityB)
#p = wx.Panel(self.parent, -1)
@@ -706,7 +737,7 @@
self.zoomText = wx.StaticText(self, -1, "Zoom into data values: ",
(20, 10))
self.zoomMinTcl = wx.TextCtrl(self, -1, str(zoomMin), size=(125, -1))
self.zoomMaxTcl = wx.TextCtrl(self, -1, str(zoomMax), size=(125, -1))
- if (group == 0): #spheres
+ if (group == 0): # spheres
self.cropText = wx.StaticText(self, -1, "Crop displayed data
values: ", (20, 10))
self.cropMinTcl = wx.TextCtrl(self, -1, str(cropMin), size=(125,
-1))
self.cropMaxTcl = wx.TextCtrl(self, -1, str(cropMax), size=(125,
-1))
@@ -719,7 +750,7 @@
gbs.Add(self.zoomText, (1,0))
gbs.Add(self.zoomMinTcl, (1,1))
gbs.Add(self.zoomMaxTcl, (1,2))
- if (group == 0):
+ if (group == 0):
gbs.Add(self.cropText, (2,0))
gbs.Add(self.cropMinTcl, (2,1))
gbs.Add(self.cropMaxTcl, (2,2))
@@ -742,29 +773,28 @@
self.SetSizer(vs)
vs.Fit(self)
self.SetAutoLayout(True)
-
-
- self.Bind(wx.EVT_BUTTON, self.OnCloseMe, self.button)
+
+ self.Bind(wx.EVT_BUTTON, self.OnOK, self.button)
self.Bind(wx.EVT_BUTTON, self.OnCancel, self.cancelB)
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
def OnCancel(self, evt):
- self.Close(True)
+ self.Show( False )
- def OnCloseMe(self, event):
+ def OnOK(self, event):
zoomMin = self.zoomMinTcl.GetValue()
zoomMax = self.zoomMaxTcl.GetValue()
- cropMin = 0
- cropMax = 0
- if self.group == 0:
- cropMin = self.cropMinTcl.GetValue()
- cropMax = self.cropMaxTcl.GetValue()
+ cropMin = 0
+ cropMax = 0
+ if self.group == 0:
+ cropMin = self.cropMinTcl.GetValue()
+ cropMax = self.cropMaxTcl.GetValue()
colorMin = self.colorMinTcl.GetValue()
colorMax = self.colorMaxTcl.GetValue()
#print "zomMin: " + str(zoomMin)
self.parent.SendValues(float(zoomMin), float(zoomMax),
float(cropMin), float(cropMax), float(colorMin), float(colorMax))
- self.Close(True)
+ self.Show( False )
def OnCloseWindow(self, event):
self.Destroy()
Modified: trunk/scenes/csafe/python/SceneMenus.py
==============================================================================
--- trunk/scenes/csafe/python/SceneMenus.py (original)
+++ trunk/scenes/csafe/python/SceneMenus.py Thu Dec 4 16:07:10 2008
@@ -66,6 +66,13 @@
self.lb1.AppendItems(self.scene.nrrdFiles)
self.lb2.AppendItems(self.scene.nrrdFiles2)
+# def OnKeyDown(self, evt):
+# keycode = evt.GetKeyCode()
+# print "here"
+# print keycode
+# if keycode == wx.WXK_ESCAPE:
+# self.Close(True)
+
def OnClickOk(self, evt):
items = []
#items = self.scene.nrrdFiles
Modified: trunk/scenes/csafe/python/TransferF.py
==============================================================================
--- trunk/scenes/csafe/python/TransferF.py (original)
+++ trunk/scenes/csafe/python/TransferF.py Thu Dec 4 16:07:10 2008
@@ -4,9 +4,9 @@
import random
import wxManta
-from manta import *
-
-from csafe import *
+from manta import *
+from csafe import *
+from csafe_demo import setup
colors = [] # (pos, r, g, b, a)
@@ -21,6 +21,7 @@
class TransferF(wx.Object):
def __init__(self, parent, colorsn, id, title="untitled", cmap = None):
+
self.parent = parent
self.colors = colorsn
self.id = id
@@ -144,8 +145,11 @@
class TransferFPanel(wx.Panel):
def __init__(self, parent, width, height, transferF,
updateFunction=None):
- self.backgroundIMG = wx.Image(opj('images/bckgrnd.png'),
wx.BITMAP_TYPE_PNG).ConvertToBitmap()
- self.paddingW = 20.0
+
+ path = setup.csafe_scene_path
+
+ self.backgroundIMG = wx.Image(opj(path+'images/bckgrnd.png'),
wx.BITMAP_TYPE_PNG).ConvertToBitmap()
+ self.paddingW = 20.0
self.paddingH = 20.0
self.transferF = transferF
self.width = width
@@ -165,7 +169,7 @@
self.selected = None
self.dSelected = None
self.histogramGroup = None
- self.SetBackgroundColour(wx.Colour(90,90,90))
+ self.SetBackgroundColour(wx.Colour(90,90,90))
def SetUpdateFunction(self, function):
self.updateFunction = function
@@ -429,6 +433,9 @@
class TransferFGroup(wx.Panel):
def __init__(self, parent, width, height, transferF, title, scene):
+
+ path = setup.csafe_scene_path
+
self.parentC = parent
self.height = height
self.width = width
@@ -436,6 +443,9 @@
wx.Panel.__init__(self, parent, -1, (0, 0) , (width, height) )
self.vs = vs = wx.BoxSizer( wx.VERTICAL )
self.box1_title = wx.StaticBox( self, -1, title )
+
+ self.box1_title.SetForegroundColour( wx.WHITE ) # Make label
readable!
+
self.transferFPanel = TransferFPanel(self, width, height, transferF)
box1 = self.box1 = wx.StaticBoxSizer( self.box1_title, wx.VERTICAL )
self.gbs = gbs = wx.GridBagSizer(5,5)
@@ -444,13 +454,22 @@
gbs.Add(self.transferFPanel,(0, 0), (5, 2) )
- bmpNew = wx.Bitmap(opj('images/new_16x16.png'))
- bmpDel = wx.Bitmap(opj('images/delete_16x16.png'))
- bmpMod = wx.Bitmap(opj('images/color_16x16.png'))
+ bmpNew = wx.Bitmap(opj(path+'images/new_16x16.png'))
+ bmpDel = wx.Bitmap(opj(path+'images/delete_16x16.png'))
+ bmpMod = wx.Bitmap(opj(path+'images/color_16x16.png'))
+
self.newColorB = wx.BitmapButton(self, -1, bmpNew, (0,0),
style=wx.NO_BORDER)
+ self.newColorB.SetToolTip( wx.ToolTip( "Press to choose a new color
for chosen color map position." ) )
+
self.delColorB = wx.BitmapButton(self, -1, bmpDel, (0,0),
style=wx.NO_BORDER)
+ self.delColorB.SetToolTip( wx.ToolTip( "delcolorb: fix me" ) )
+
self.modifyColorB = wx.BitmapButton(self, -1, bmpMod, (0,0),
style=wx.NO_BORDER)
+ self.modifyColorB.SetToolTip( wx.ToolTip( "Modify Colormap" ) )
+
self.presetsB = wx.BitmapButton(self, -1, bmpMod, (0,0),
style=wx.NO_BORDER)
+ self.presetsB.SetToolTip( wx.ToolTip( "Choose Colormap Preset" ) )
+
gbs.Add( self.newColorB, (0, 2) )
gbs.Add( self.delColorB, (1, 2) )
gbs.Add( self.modifyColorB, (2, 2) )
Modified: trunk/scenes/csafe/python/csafe_demo.py
==============================================================================
--- trunk/scenes/csafe/python/csafe_demo.py (original)
+++ trunk/scenes/csafe/python/csafe_demo.py Thu Dec 4 16:07:10 2008
@@ -1,3 +1,5 @@
+#! /usr/bin/python
+
#
# For more information, please see:
http://software.sci.utah.edu
#
@@ -74,28 +76,34 @@
menuFile.Append(103, "Save As...", "")
menuFile.Append(104, "Load Configuration", "")
menuFile.Append(110, "Load UDA", "Uintah Dataset")
- menuFile.Append(107, "Import NrrdList")
- menuFile.Append(108, "Export NrrdList")
- menuFile.Append(106, "Import Transfer Function")
+ menuFile.Append(107, "Import NrrdList")
+ menuFile.Append(108, "Export NrrdList")
+ menuFile.Append(106, "Import Transfer Function")
menuFile.Append(105, "Export Transfer Function")
- menuFile.Append(109, "&Quit", "")
- menuBar.Append(menuFile, "File")
+ menuFile.Append(109, "&Quit", "")
menuScene = wx.Menu()
menuScene.Append(201, "&Add/Remove Data Files", "Add and remove Nrrd
files for the scene")
- menuScene.Append(204, "Add &Histogram", "Add a histogram to the
panel")
+ menuScene.Append(204, "Add &Histogram", "Add a histogram to the
panel")
menuScene.Append(202, "Scene Preferences")
menuScene.Append(205, "Cutting Bounding Box")
menuScene.Append(206, "Volume Position/Size")
+ # Keep track of the generateMenu so it can be enabled/disabled.
self.generateMenuItem = menuScene.Append(203, "&Generate")
- menuBar.Append(menuScene, "Scene")
self.generateMenuItem.Enable( False );
menuHelp = wx.Menu()
- menuBar.Append(menuHelp, "Help")
- self.SetMenuBar(menuBar)
+
+ # Keep track of toggleTooltipsMenuItem so it can be updated as
needed.
+ self.toggleTooltipsMenuItem = menuHelp.Append( 207, "Turn Off
Tooltips" )
+
+ menuBar.Append(menuFile, "File")
+ menuBar.Append(menuScene, "Scene")
+ menuBar.Append(menuHelp, "Help")
+
+ self.SetMenuBar(menuBar)
self.Bind(wx.EVT_MENU, self.Menu101, id=101)
self.Bind(wx.EVT_MENU, self.Menu102, id=102)
@@ -105,15 +113,25 @@
self.Bind(wx.EVT_MENU, self.Menu106, id=106)
self.Bind(wx.EVT_MENU, self.Menu201, id=201)
self.Bind(wx.EVT_MENU, self.Menu202, id=202)
- self.Bind(wx.EVT_MENU, self.Menu107, id=107)
- self.Bind(wx.EVT_MENU, self.Menu108, id=108)
- self.Bind(wx.EVT_MENU, self.Menu109, id=109)
- self.Bind(wx.EVT_MENU, self.Menu203, id=203)
- self.Bind(wx.EVT_MENU, self.Menu204, id=204)
+ self.Bind(wx.EVT_MENU, self.Menu107, id=107)
+ self.Bind(wx.EVT_MENU, self.Menu108, id=108)
+ self.Bind(wx.EVT_MENU, self.Menu109, id=109)
+ self.Bind(wx.EVT_MENU, self.Menu203, id=203)
+ self.Bind(wx.EVT_MENU, self.Menu204, id=204)
self.Bind(wx.EVT_MENU, self.Menu110, id=110)
self.Bind(wx.EVT_MENU, self.Menu205, id=205)
self.Bind(wx.EVT_MENU, self.MenuVolPositionSize, id = 206)
- self.SetBackgroundColour(self.scene.bgColor)
+ self.Bind(wx.EVT_MENU, self.ToggleTooltips, id=207)
+
+ self.SetBackgroundColour(self.scene.bgColor)
+
+ def ToggleTooltips( self, evt ):
+ if setup.tooltipsOn == True :
+ self.toggleTooltipsMenuItem.SetText( "Turn On Tooltips" )
+ else :
+ self.toggleTooltipsMenuItem.SetText( "Turn Off Tooltips" )
+ setup.tooltipsOn = not setup.tooltipsOn
+ wx.ToolTip.Enable( setup.tooltipsOn )
def Menu205(self, evt):
frame = SceneMenus.BBoxFrame(self, -1, "Bounding Box", self.scene)
@@ -125,8 +143,8 @@
def Menu110(self, evt):
self.SetFocus()
- dlg = wx.DirDialog(self, message="Open UDA folder",
style=wx.OPEN|wx.CHANGE_DIR)
- if dlg.ShowModal() == wx.ID_OK:
+ dlg = wx.DirDialog(self, message="Open UDA folder",
style=wx.OPEN|wx.CHANGE_DIR)
+ if dlg.ShowModal() == wx.ID_OK:
filename = str(dlg.GetPath())
choices = []
self.scene.test.readUDAHeader(filename)
@@ -168,162 +186,165 @@
wx.AboutBox(info)
def Menu102(self, evt):
- print "writing file: " + self.scene.sceneName
- if (self.scene.sceneName != "Untitled"):
- Configuration.WriteConfiguration(self.scene,
self.scene.sceneWD + '/' + self.scene.sceneName)
- else:
- self.Menu103(evt)
+ print "writing file: " + self.scene.sceneName
+ if (self.scene.sceneName != "Untitled"):
+ Configuration.WriteConfiguration(self.scene, self.scene.sceneWD
+ '/' + self.scene.sceneName)
+ else:
+ self.Menu103(evt)
def Menu103(self,evt):
- dlg = wx.FileDialog(self, message="Save file as...",
defaultDir=os.getcwd(),
- defaultFile="", wildcard="*", style=wx.SAVE)
- if dlg.ShowModal() == wx.ID_OK:
- path = dlg.GetPath()
- self.scene.sceneName = dlg.GetFilename()
- print "filename: " + dlg.GetFilename()
- self.scene.sceneWD = dlg.GetDirectory()
- Configuration.WriteConfiguration(self.scene, path)
+ dlg = wx.FileDialog( self, message="Save file as...",
defaultDir=os.getcwd(),
+ defaultFile="", wildcard="*", style=wx.SAVE )
+ if dlg.ShowModal() == wx.ID_OK:
+ path = dlg.GetPath()
+ self.scene.sceneName = dlg.GetFilename()
+
+ self.scene.sceneWD = dlg.GetDirectory()
+ Configuration.WriteConfiguration(self.scene, path)
def Menu104(self,evt):
self.SetFocus()
wildcard = "Config File (*.cfg)|*.cfg|" \
"All files (*.*)|*.*" \
- dlg = wx.FileDialog(self, message="Open Configuration File",
- defaultDir=os.getcwd(),
- defaultFile="",
- wildcard=wildcard,
- style=wx.OPEN|wx.CHANGE_DIR)
- if dlg.ShowModal() == wx.ID_OK:
- filename = dlg.GetPath()
- Configuration.ReadConfiguration(self.scene, filename)
- self.scene.sceneWD = dlg.GetDirectory()
- self.scene.sceneName = dlg.GetFilename()
- print "filename: " + self.scene.sceneName
+ dlg = wx.FileDialog( self, message="Open Configuration File",
+ defaultDir=os.getcwd(),
+ defaultFile="",
+ wildcard=wildcard,
+ style=wx.OPEN|wx.CHANGE_DIR )
+ if dlg.ShowModal() == wx.ID_OK:
+ filename = dlg.GetPath()
+ Configuration.ReadConfiguration(self.scene, filename)
+ self.scene.sceneWD = dlg.GetDirectory()
+ self.scene.sceneName = dlg.GetFilename()
+ print "filename: " + self.scene.sceneName
- ################ Export Transfer Function #################
+ ################ Export Transfer Function #################
def Menu105(self,evt):
self.log.write("export transfer function")
- ################ Import Transfer Function #################
+ ################ Import Transfer Function #################
def Menu106(self,evt):
self.log.write("import transfer function")
-
- ################ Import NRRDLIST #################
+
+ ################ Import NRRDLIST #################
def Menu107(self, e):
- dlg = wx.FileDialog(self, message="Open file",
- defaultDir=os.getcwd(),
- defaultFile="",
- wildcard="*",
- style=wx.OPEN|wx.CHANGE_DIR)
- if dlg.ShowModal() == wx.ID_OK:
- filename = dlg.GetPath()
- Configuration.ReadNRRDList(self.scene, filename)
-
- ################ Export NRRDLIST #################
+ dlg = wx.FileDialog(self, message="Open file",
+ defaultDir=os.getcwd(),
+ defaultFile="",
+ wildcard="*",
+ style=wx.OPEN|wx.CHANGE_DIR)
+ if dlg.ShowModal() == wx.ID_OK:
+ filename = dlg.GetPath()
+ Configuration.ReadNRRDList(self.scene, filename)
+
+ ################ Export NRRDLIST #################
def Menu108(self, e):
- dlg = wx.FileDialog(self, message="Save file as...",
defaultDir=os.getcwd(),
- defaultFile="", wildcard="*", style=wx.SAVE)
- if dlg.ShowModal() == wx.ID_OK:
- path = dlg.GetPath()
- Configuration.WriteNRRDList(self.scene, path)
-
- ################ Quit #################
+ dlg = wx.FileDialog(self, message="Save file as...",
defaultDir=os.getcwd(),
+ defaultFile="", wildcard="*", style=wx.SAVE)
+ if dlg.ShowModal() == wx.ID_OK:
+ path = dlg.GetPath()
+ Configuration.WriteNRRDList(self.scene, path)
+
+ ################ Quit #################
def Menu109(self, e):
- exit()
+ exit()
- ################ Add/Remove Files #################
+ ################ Add/Remove Files #################
def Menu201(self, evt):
frame = SceneMenus.AddRemoveFilesFrame(self, -1, "Add/Remove Data
Files", self.scene)
- frame.Show(True)
+ frame.Show(True)
- ################ Scene Properties #################
+ ################ Scene Properties #################
def Menu202(self, evt):
- frame = SceneMenus.ScenePropertiesFrame(self, -1, "Scene
Preferences", self.scene)
- frame.Show(True)
-
- ################ Generate Scene #################
+ frame = SceneMenus.ScenePropertiesFrame(self, -1, "Scene
Preferences", self.scene)
+ frame.Show(True)
+
+ ################ Generate Scene #################
def Menu203(self, evt):
- self.BuildScene()
+ # self.generateMenuItem.SetToolTip(
+ # wx.ToolTip( "You may only 'generate' once. You must restart if
you need to re-generate." ) )
+ self.generateMenuItem.Enable( False );
+ self.BuildScene()
################ Add Histogram #################
def Menu204(self, evt):
- group = 0
- name = "untitled"
+ group = 0
+ name = "untitled"
index = 0
frame = SceneMenus.AddHistogramFrame(self,-1, "Add Histogram",
self.scene, group, index, name)
- frame.Show(True)
- print "Added histogram: "
- print group
- print index
- print name
+ frame.Show(True)
+ print "Added histogram: "
+ print group
+ print index
+ print name
def BuildScene(self):
- self.test.setRidx(int(self.scene.ridx))
- self.test.setRadius(float(self.scene.radius))
- self.test.clearSphereNrrds();
- self.test.clearVolNrrds();
+ self.test.setRidx(int(self.scene.ridx))
+ self.test.setRadius(float(self.scene.radius))
+ self.test.clearSphereNrrds();
+ self.test.clearVolNrrds();
print "loading volume nrrds: "
- for i in range(len(self.scene.nrrdFiles2)):
- print str(self.scene.nrrdFiles2[i])
- print "end volume list."
- for i in range(len(self.scene.nrrdFiles2)):
- self.test.addVolNrrd(self.scene.nrrdFiles2[i])
+ for i in range(len(self.scene.nrrdFiles2)):
+ print str(self.scene.nrrdFiles2[i])
+ print "end volume list."
+ for i in range(len(self.scene.nrrdFiles2)):
+ self.test.addVolNrrd(self.scene.nrrdFiles2[i])
for i in range(0, len(self.scene.nrrdFiles)):
- self.test.addSphereNrrd(self.scene.nrrdFiles[i])
+ self.test.addSphereNrrd(self.scene.nrrdFiles[i])
#self.test.loadSphereNrrds()
#self.test.setVolColorMinMax(300, 1800)
self.test.reloadData()
-
- #self.test.loadVolNrrds()
-
- self.BuildHistograms()
+
+ #self.test.loadVolNrrds()
+
+ self.BuildHistograms()
self.slider.SetRange(1, int(max(len(self.scene.nrrdFiles),
len(self.scene.nrrdFiles2))))
self.scene.mantaApp.frame.StartEngine()
def BuildHistograms(self):
- for i in range(len(self.histoGroups)):
- print "building histogram: " + self.histoGroups[i].title
- vol = False
- if self.histoGroups[i].group == 1:
- vol = True
- histValues1Ptr =
SWIGIFYCreateIntArray(self.scene.histogramBuckets)
- histValues = []
- min = SWIGIFYCreateFloat(0)
- max = SWIGIFYCreateFloat(100)
- cmin = SWIGIFYCreateFloat(0)
- cmax = SWIGIFYCreateFloat(100)
- if (vol == False):
-
self.test.getHistogram(self.histoGroups[i].varIndex,self.scene.histogramBuckets
, histValues1Ptr, min, max)
- else:
-
self.test.getVolHistogram(self.scene.histogramBuckets, histValues1Ptr,min,
max)
- dataMin = SWIGIFYGetFloat(min)
- dataMax = SWIGIFYGetFloat(max)
- print "dataMin/max: " + str(dataMin) + " " + str(dataMax)
- for j in range(self.scene.histogramBuckets):
-
histValues.append(SWIGIFYGetIntArrayValue(histValues1Ptr, j))
- #print histValues[j]
- self.histoGroups[i].SetValues(histValues, dataMin, dataMax)
- if vol == False:
-
self.test.getSphereDataMinMax(self.histoGroups[i].varIndex, cmin, cmax)
- else:
- self.test.getVolDataMinMax(cmin, cmax)
- dataCMin = SWIGIFYGetFloat(cmin)
- dataCMax = SWIGIFYGetFloat(cmax)
- self.histoGroups[i].SetCMinMax(dataCMin, dataCMax)
- SWIGIFYDestroyIntArray(histValues1Ptr)
-
+ for i in range(len(self.histoGroups)):
+ print "building histogram: " + self.histoGroups[i].title
+ vol = False
+ if self.histoGroups[i].group == 1:
+ vol = True
+ histValues1Ptr =
SWIGIFYCreateIntArray(self.scene.histogramBuckets)
+ histValues = []
+ min = SWIGIFYCreateFloat(0)
+ max = SWIGIFYCreateFloat(100)
+ cmin = SWIGIFYCreateFloat(0)
+ cmax = SWIGIFYCreateFloat(100)
+ if (vol == False):
+
self.test.getHistogram(self.histoGroups[i].varIndex,self.scene.histogramBuckets
, histValues1Ptr, min, max)
+ else:
+ self.test.getVolHistogram(self.scene.histogramBuckets,
histValues1Ptr,min, max)
+ dataMin = SWIGIFYGetFloat(min)
+ dataMax = SWIGIFYGetFloat(max)
+ print "dataMin/max: " + str(dataMin) + " " + str(dataMax)
+ for j in range(self.scene.histogramBuckets):
+ histValues.append(SWIGIFYGetIntArrayValue(histValues1Ptr, j))
+ # print histValues[j]
+ self.histoGroups[i].SetValues(histValues, dataMin, dataMax)
+ if vol == False:
+ self.test.getSphereDataMinMax(self.histoGroups[i].varIndex,
cmin, cmax)
+ else:
+ self.test.getVolDataMinMax(cmin, cmax)
+ dataCMin = SWIGIFYGetFloat(cmin)
+ dataCMax = SWIGIFYGetFloat(cmax)
+ self.histoGroups[i].SetCMinMax(dataCMin, dataCMax)
+ SWIGIFYDestroyIntArray(histValues1Ptr)
def UpdateColorMap(self, transferF):
- cmap = transferF.cmap
- t = transferF
- slices = vector_ColorSlice()
- t.colors.sort()
- for i in range(0, len(t.colors)):
- slices.push_back(ColorSlice(t.colors[i][0],
RGBAColor(Color(RGBColor(t.colors[i][1],
- t.colors[i][2], t.colors[i][3])), t.colors[i][4])))
- if (cmap != None):
- cmap.SetColors(slices)
+ cmap = transferF.cmap
+ t = transferF
+ slices = vector_ColorSlice()
+ t.colors.sort()
+ for i in range(0, len(t.colors)):
+ slices.push_back(ColorSlice(t.colors[i][0],
+
RGBAColor(Color(RGBColor(t.colors[i][1],
+
t.colors[i][2], t.colors[i][3])), t.colors[i][4])))
+ if (cmap != None):
+ cmap.SetColors(slices)
self.volCMap.scaleAlphas(0.00125)
self.scene.test.updateSphereCMap()
@@ -349,180 +370,187 @@
self.visible = True
def InitializeScene(self,frame, engine):
- self.SetBackgroundColour(self.scene.bgColor)
+ self.SetBackgroundColour(self.scene.bgColor)
- # Create a scene object.
- scene = manta_new(Scene())
- eye = manta_new(Vector(0.340429, 0.161851, -0.441882))
- lookat = manta_new( Vector( 0.0411403, 0.0475211, 0.0508046))
- up = manta_new( Vector(-0.0893698, 0.980804, 0.173311))
- fov = 12.0039
- #TODO: be able to set these in GUI
- data = manta_new(BasicCameraData(eye,lookat,up,fov,fov))
- engine.getCamera(0).setBasicCameraData(data)
-#
scene.setBackground(manta_new(ConstantBackground(ColorDB.getNamedColor("SkyBlue3").scaled(0.5))))
+ # Create a scene object. (fix this: read from config file if
available)
+ scene = manta_new( Scene() )
+ eye = manta_new( Vector(0.340429, 0.161851, -0.441882) )
+ lookat = manta_new( Vector( 0.0411403, 0.0475211, 0.0508046) )
+ up = manta_new( Vector(-0.0893698, 0.980804, 0.173311) )
+ fov = 12.0039
+ # TODO: be able to set these in GUI
+ data = manta_new(BasicCameraData(eye,lookat,up,fov,fov))
+ engine.getCamera(0).setBasicCameraData(data)
+ #
scene.setBackground(manta_new(ConstantBackground(ColorDB.getNamedColor("SkyBlue3").scaled(0.5))))
scene.setBackground(manta_new(ConstantBackground(Color(RGBColor(0,0,0)))))
- engine.setShadowAlgorithm(manta_new(NoShadows()))
- #engine.selectShadowAlgorithm("noshadows")
-
+ engine.setShadowAlgorithm(manta_new(NoShadows()))
+ # engine.selectShadowAlgorithm("noshadows")
- # Create the checker textures.
- checker1 = manta_new(CheckerTexture_Color(Color(RGBColor(.6,.6,.6)),
- Color(RGBColor(0,0,0)),
- Vector(1,0,0),
- Vector(0,1,0)))
-
- constant_color1 = manta_new(Constant_Color(Color(RGBColor(.6,.6,.6))))
- checker2 = manta_new(CheckerTexture_ColorComponent(0.2, 0.5,
Vector(1,0,0),Vector(0,1,0)))
-
- # Create the floor shader.
- plane_matl = manta_new(Phong(checker1, constant_color1, 32, checker2))
-
- # Create a group for the scene.
- world = manta_new(Group())
-
- # Add the floor
- floor = manta_new(Parallelogram(plane_matl, Vector(-20,-20,0),
- Vector(40,0,0), Vector(0,40,0)))
- uniformmap = manta_new(UniformMapper())
- floor.setTexCoordMapper(uniformmap)
- world.add(floor)
- material = manta_new(Lambertian(Color(RGBColor(1,0,0))))
- world.add(manta_new(Sphere(material, Vector(0,0,1.2), 1.0)))
- scene.setObject(world)
-
- self.colorMap1 = colorMap1 = manta_new(RGBAColorMap())
-
- slices = manta_new(vector_ColorSlice());
- div = 1.0/255.0;
- a = 1.0;
- slices.push_back(ColorSlice(0.0, RGBAColor(Color(RGBColor(0.0, 0.0,
0.0)), 0*a)));
- slices.push_back(ColorSlice(0.109804,
RGBAColor(Color(RGBColor(52*div, 0*div, 0*div)), 0*a)));
- slices.push_back(ColorSlice(0.2, RGBAColor(Color(RGBColor(102*div,
2*div, 0)), 0.1*a)));
- slices.push_back(ColorSlice(0.328571,
RGBAColor(Color(RGBColor(153*div, 18*div, 0)), 0.216667*a)));
- slices.push_back(ColorSlice(0.4, RGBAColor(Color(RGBColor(200*div,
41*div, 0)), 0.23*a)));
- slices.push_back(ColorSlice(0.5, RGBAColor(Color(RGBColor(230*div,
71*div, 0)), 0.27*a)));
- slices.push_back(ColorSlice(0.618367,
RGBAColor(Color(RGBColor(255*div, 120*div, 0)) , 0.3375*a)));
- slices.push_back(ColorSlice(0.68, RGBAColor(Color(RGBColor(255*div,
163*div, 20*div)) , 0.35*a)));
- slices.push_back(ColorSlice(0.72, RGBAColor(Color(RGBColor(255*div,
204*div, 55*div)) , 0.37*a)));
- slices.push_back(ColorSlice(0.79, RGBAColor(Color(RGBColor(255*div,
228*div, 80*div)) , 0.39*a)));
- slices.push_back(ColorSlice(0.85, RGBAColor(Color(RGBColor(255*div,
247*div, 120*div)), 0.43*a)));
- slices.push_back(ColorSlice(0.92, RGBAColor(Color(RGBColor(255*div,
255*div, 180*div)), 0.47*a)));
- slices.push_back(ColorSlice(1.0, RGBAColor(Color(RGBColor(255*div,
255*div, 255*div)) , 0.5*a)));
- self.volCMap = manta_new(RGBAColorMap(slices, 64));
+ # Create the checker textures.
+ checker1 = manta_new( CheckerTexture_Color(Color(RGBColor(.6,.6,.6)),
+ Color(RGBColor(0,0,0)),
+ Vector(1,0,0),
+ Vector(0,1,0)) )
+
+ constant_color1 =
manta_new(Constant_Color(Color(RGBColor(.6,.6,.6))))
+ checker2 = manta_new(CheckerTexture_ColorComponent(0.2, 0.5,
Vector(1,0,0),Vector(0,1,0)))
+
+ # Create the floor shader.
+ plane_matl = manta_new(Phong(checker1, constant_color1, 32,
checker2))
+
+ # Create a group for the scene.
+ world = manta_new(Group())
+
+ # Add the floor
+ floor = manta_new(Parallelogram( plane_matl, Vector(-20,-20,0),
+ Vector(40,0,0), Vector(0,40,0)) )
+ uniformmap = manta_new(UniformMapper())
+ floor.setTexCoordMapper(uniformmap)
+ world.add(floor)
+ material = manta_new(Lambertian(Color(RGBColor(1,0,0))))
+ world.add(manta_new(Sphere(material, Vector(0,0,1.2), 1.0)))
+ scene.setObject(world)
+
+ self.colorMap1 = colorMap1 = manta_new(RGBAColorMap())
+
+ slices = manta_new(vector_ColorSlice());
+ div = 1.0/255.0;
+ a = 1.0;
+ slices.push_back(ColorSlice(0.0, RGBAColor(Color(RGBColor(0.0, 0.0,
0.0)), 0*a)));
+ slices.push_back(ColorSlice(0.109804,
RGBAColor(Color(RGBColor(52*div, 0*div, 0*div)), 0*a)));
+ slices.push_back(ColorSlice(0.2, RGBAColor(Color(RGBColor(102*div,
2*div, 0)), 0.1*a)));
+ slices.push_back(ColorSlice(0.328571,
RGBAColor(Color(RGBColor(153*div, 18*div, 0)), 0.216667*a)));
+ slices.push_back(ColorSlice(0.4, RGBAColor(Color(RGBColor(200*div,
41*div, 0)), 0.23*a)));
+ slices.push_back(ColorSlice(0.5, RGBAColor(Color(RGBColor(230*div,
71*div, 0)), 0.27*a)));
+ slices.push_back(ColorSlice(0.618367,
RGBAColor(Color(RGBColor(255*div, 120*div, 0)) , 0.3375*a)));
+ slices.push_back(ColorSlice(0.68, RGBAColor(Color(RGBColor(255*div,
163*div, 20*div)) , 0.35*a)));
+ slices.push_back(ColorSlice(0.72, RGBAColor(Color(RGBColor(255*div,
204*div, 55*div)) , 0.37*a)));
+ slices.push_back(ColorSlice(0.79, RGBAColor(Color(RGBColor(255*div,
228*div, 80*div)) , 0.39*a)));
+ slices.push_back(ColorSlice(0.85, RGBAColor(Color(RGBColor(255*div,
247*div, 120*div)), 0.43*a)));
+ slices.push_back(ColorSlice(0.92, RGBAColor(Color(RGBColor(255*div,
255*div, 180*div)), 0.47*a)));
+ slices.push_back(ColorSlice(1.0, RGBAColor(Color(RGBColor(255*div,
255*div, 255*div)) , 0.5*a)));
+ self.volCMap = manta_new(RGBAColorMap(slices, 64));
minBound = Vector(self.scene.volumeMinBound[0],
self.scene.volumeMinBound[1], self.scene.volumeMinBound[2])
maxBound = Vector(self.scene.volumeMaxBound[0],
self.scene.volumeMaxBound[1], self.scene.volumeMaxBound[2])
- self.test = manta_new(CDTest(scene, engine, minBound, maxBound));
+ self.test = manta_new(CDTest(scene, engine, minBound, maxBound));
self.test.initScene();
- self.test.setVolCMap(self.volCMap);
+ self.test.setVolCMap(self.volCMap);
self.scene.test = self.test
self.scene.isPlaying = True
- self.scene.engine = engine
+ self.scene.engine = engine
-
- histValues1Ptr = SWIGIFYCreateIntArray(self.scene.histogramBuckets)
- dataMin1 = -1.1
- dataMax1 = 2.2
- min = SWIGIFYCreateDouble(0)
- max = SWIGIFYCreateDouble(100)
- dataMin1 = SWIGIFYGetDouble(min)
+ histValues1Ptr = SWIGIFYCreateIntArray(self.scene.histogramBuckets)
+ dataMin1 = -1.1
+ dataMax1 = 2.2
+ min = SWIGIFYCreateDouble(0)
+ max = SWIGIFYCreateDouble(100)
+ dataMin1 = SWIGIFYGetDouble(min)
dataMax1 = SWIGIFYGetDouble(max)
print "datamin: " + str(dataMin1) + " datamax: " + str(dataMax1)
- scene.getRenderParameters().maxDepth = 5
+ scene.getRenderParameters().maxDepth = 5
- engine.setScene( scene )
+ engine.setScene( scene )
- #################init the GUI######################
+ #################init the GUI######################
- colors = []
- colors2 = []
- colors3 = []
- colors4 = []
- colors5 = []
- colors6 = []
- colors7 = []
- colors8 = []
- colors9 = []
- self.sphereVolCMaps = []
- for j in range(8):
- self.sphereVolCMaps.append(manta_new(RGBAColorMap(1)))
- self.t0 = t0 = TransferF.TransferF(self, colors9, 0, "volume",
self.volCMap)
- self.defaultTransferF = TransferF.TransferF(self, colors, 1, "empty",
self.sphereVolCMaps[0])
- t1 = TransferF.TransferF(self, [], 0, "InvRainbowIso",
manta_new(RGBAColorMap(RGBAColorMap.InvRainbowIso)))
- t2 = TransferF.TransferF(self, [], 0, "InvRainbow",
manta_new(RGBAColorMap(RGBAColorMap.InvRainbow)))
- t3 = TransferF.TransferF(self, [], 0, "Rainbow",
manta_new(RGBAColorMap(RGBAColorMap.Rainbow)))
- t4 = TransferF.TransferF(self, [], 0, "InvGreyScale",
manta_new(RGBAColorMap(RGBAColorMap.InvGreyScale)))
- t5 = TransferF.TransferF(self, [], 0, "InvBlackBody",
manta_new(RGBAColorMap(RGBAColorMap.InvBlackBody)))
- t6 = TransferF.TransferF(self, [], 0, "BlackBody",
manta_new(RGBAColorMap(RGBAColorMap.BlackBody)))
- t7 = TransferF.TransferF(self, [], 0, "GreyScale",
manta_new(RGBAColorMap(RGBAColorMap.GreyScale)))
- self.transferFunctions = []
- self.transferFunctions.append(self.t0)
- self.transferFunctions.append(t1)
- self.transferFunctions.append(t2)
- self.transferFunctions.append(t3)
- self.transferFunctions.append(t4)
- self.transferFunctions.append(t5)
- self.transferFunctions.append(t6)
- self.transferFunctions.append(t7)
-
- self.tPanel = tPanel = TransferF.TransferFGroup(self.panel, 300, 100,
self.defaultTransferF, "empty", self.scene)
- self.scene.tPanel = tPanel
- tPanel.SetBackgroundColour(self.scene.bgColor)
- self.Bind(wx.EVT_LEFT_DOWN, self.OnKeyDown)
-
- self.vs = vs = wx.BoxSizer( wx.VERTICAL )
- data = []
- for i in range(0, 1000):
+ colors = []
+ colors2 = []
+ colors3 = []
+ colors4 = []
+ colors5 = []
+ colors6 = []
+ colors7 = []
+ colors8 = []
+ colors9 = []
+ self.sphereVolCMaps = []
+ for j in range(8):
+ self.sphereVolCMaps.append(manta_new(RGBAColorMap(1)))
+ self.t0 = t0 = TransferF.TransferF(self, colors9, 0, "volume",
self.volCMap)
+ self.defaultTransferF = TransferF.TransferF(self, colors, 1,
"empty", self.sphereVolCMaps[0])
+ t1 = TransferF.TransferF(self, [], 0, "InvRainbowIso",
manta_new(RGBAColorMap(RGBAColorMap.InvRainbowIso)))
+ t2 = TransferF.TransferF(self, [], 0, "InvRainbow",
manta_new(RGBAColorMap(RGBAColorMap.InvRainbow)))
+ t3 = TransferF.TransferF(self, [], 0, "Rainbow",
manta_new(RGBAColorMap(RGBAColorMap.Rainbow)))
+ t4 = TransferF.TransferF(self, [], 0, "InvGreyScale",
manta_new(RGBAColorMap(RGBAColorMap.InvGreyScale)))
+ t5 = TransferF.TransferF(self, [], 0, "InvBlackBody",
manta_new(RGBAColorMap(RGBAColorMap.InvBlackBody)))
+ t6 = TransferF.TransferF(self, [], 0, "BlackBody",
manta_new(RGBAColorMap(RGBAColorMap.BlackBody)))
+ t7 = TransferF.TransferF(self, [], 0, "GreyScale",
manta_new(RGBAColorMap(RGBAColorMap.GreyScale)))
+ self.transferFunctions = []
+ self.transferFunctions.append(self.t0)
+ self.transferFunctions.append(t1)
+ self.transferFunctions.append(t2)
+ self.transferFunctions.append(t3)
+ self.transferFunctions.append(t4)
+ self.transferFunctions.append(t5)
+ self.transferFunctions.append(t6)
+ self.transferFunctions.append(t7)
+
+ self.tPanel = tPanel = TransferF.TransferFGroup(self.panel, 300,
100, self.defaultTransferF, "empty", self.scene)
+ self.scene.tPanel = tPanel
+ tPanel.SetBackgroundColour(self.scene.bgColor)
+ self.Bind(wx.EVT_LEFT_DOWN, self.OnKeyDown)
+
+ self.vs = vs = wx.BoxSizer( wx.VERTICAL )
+ data = []
+ for i in range(0, 1000):
data.append(( random.random() + random.random())/2.0 + 0.0)
- color = self.scene.bgColor
+ color = self.scene.bgColor
self.scene.histoVS = hvs = wx.BoxSizer(wx.VERTICAL)
self.scene.frame = self
- histoGroup0 = Histogram.HistogramGroup(self.panel, self.scene, 8,
"volume")
- histoGroup0.group = 1
- tPanel.transferFPanel.SetHistogramGroup(histoGroup0)
- self.histoGroups = []
- self.histoGroups.append(histoGroup0)
+ histoGroup0 = Histogram.HistogramGroup(self.panel, self.scene, 8,
"volume")
+ histoGroup0.group = 1
+ 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)
- 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)
- self.forwardBmp = wx.Bitmap("images/forward.png.32x32",
wx.BITMAP_TYPE_PNG)
- self.playB = wx.BitmapButton(self.panel, -1, self.pauseBmp, (40,40),
style=wx.NO_BORDER)
- self.playB.SetBackgroundColour(self.scene.bgColor)
- self.forwardB = wx.BitmapButton(self.panel, -1, self.forwardBmp,
(20,20), style=wx.NO_BORDER)
- self.backB = wx.BitmapButton(self.panel, -1, self.backBmp, (20,20),
style=wx.NO_BORDER)
+ path = setup.csafe_scene_path
+ self.backBmp = wx.Bitmap(path+"images/back.png.32x32",
wx.BITMAP_TYPE_PNG)
+ self.playBmp = wx.Bitmap(path+"images/play.png.32x32",
wx.BITMAP_TYPE_PNG)
+ self.pauseBmp = wx.Bitmap(path+"images/pause.png.32x32",
wx.BITMAP_TYPE_PNG)
+ self.forwardBmp = wx.Bitmap(path+"images/forward.png.32x32",
wx.BITMAP_TYPE_PNG)
+
+ self.playB = wx.BitmapButton(self.panel, -1, self.pauseBmp, (40,40),
style=wx.NO_BORDER)
+ self.playB.SetToolTip( wx.ToolTip( "Press to start playback." ) )
+ self.playB.SetBackgroundColour(self.scene.bgColor)
+
+ self.forwardB = wx.BitmapButton(self.panel, -1, self.forwardBmp,
(20,20), style=wx.NO_BORDER)
+ self.forwardB.SetToolTip( wx.ToolTip( "Forward (fix me)" ) )
+
+ self.backB = wx.BitmapButton(self.panel, -1, self.backBmp, (20,20),
style=wx.NO_BORDER)
+ self.backB.SetToolTip( wx.ToolTip( "Backward (fix me)" ) )
+ self.backB.Enable( False )
+
self.slider = wx.Slider(self.panel, 100, 0, 0, 0, (30, 60), (250,
-1), wx.SL_HORIZONTAL | wx.SL_AUTOTICKS | wx.SL_LABELS )
self.slider.SetTickFreq(1,1)
self.Bind(wx.EVT_SLIDER, self.OnSlider, self.slider)
- vs.Layout()
+ vs.Layout()
- self.panel.SetBackgroundColour(self.scene.bgColor)
- self.panel.SetSizer(vs)
- self.SetBackgroundColour(self.scene.bgColor)
- self.LayoutWindow()
-#TODO: values hardcoded for now
- #self.scene.ridx = 6
- self.scene.cidx = 4
- self.volCMap.scaleAlphas(0.00125)
+ self.panel.SetBackgroundColour(self.scene.bgColor)
+ self.panel.SetSizer(vs)
+ self.SetBackgroundColour(self.scene.bgColor)
+ self.LayoutWindow()
+ # TODO: values hardcoded for now
+ # self.scene.ridx = 6
+ self.scene.cidx = 4
+ self.volCMap.scaleAlphas(0.00125)
def LayoutWindow(self):
- self.vs = vs = wx.BoxSizer( wx.VERTICAL )
+ self.vs = vs = wx.BoxSizer( wx.VERTICAL )
self.scene.histoVS = hvs = wx.BoxSizer(wx.VERTICAL)
- for i in range(len(self.histoGroups)):
+ for i in range(len(self.histoGroups)):
hvs.Add(self.histoGroups[i], 0,wx.ALIGN_TOP|wx.ALIGN_CENTER,
5)
hvs.Add(self.tPanel, 0, wx.ALIGN_TOP,5 )
- vs.Add(hvs,0,wx.ALIGN_TOP|wx.ALIGN_CENTER,5)
+ vs.Add(hvs,0,wx.ALIGN_TOP|wx.ALIGN_CENTER,5)
- hvs2 = wx.BoxSizer(wx.HORIZONTAL)
- #animCtrlTitle = wx.StaticBox(self.panel, -1, "")
- # animCtrlSizer = wx.StaticBoxSizer(animCtrlTitle, wx.HORIZONTAL)
+ hvs2 = wx.BoxSizer(wx.HORIZONTAL)
+ # animCtrlTitle = wx.StaticBox(self.panel, -1, "")
+ # animCtrlSizer = wx.StaticBoxSizer(animCtrlTitle, wx.HORIZONTAL)
hvs2.Add(self.backB,0,wx.ALIGN_CENTER,2)
hvs2.Add(self.playB,0,wx.ALIGN_CENTER,2)
hvs2.Add(self.forwardB,0,wx.ALIGN_CENTER,2)
@@ -533,44 +561,44 @@
#if (self.scene.mantaFrame != None):
# vs.Add(self.scene.mantaFrame.panel, 0,wx.ALIGN_BOTTOM)
-
- self.Bind(wx.EVT_BUTTON, self.OnClickBack, self.backB)
- self.Bind(wx.EVT_BUTTON, self.OnClickPlay, self.playB)
- self.Bind(wx.EVT_BUTTON, self.OnClickForward, self.forwardB)
-
- vs.Layout()
- self.panel.SetSizer(vs)
- self.panel.SetupScrolling()
- self.panel.Refresh()
- self.Refresh()
-
+ self.Bind(wx.EVT_BUTTON, self.OnClickBack, self.backB)
+ self.Bind(wx.EVT_BUTTON, self.OnClickPlay, self.playB)
+ self.Bind(wx.EVT_BUTTON, self.OnClickForward, self.forwardB)
+
+ vs.Layout()
+ self.panel.SetSizer(vs)
+ self.panel.SetupScrolling()
+ self.panel.Refresh()
+ self.Refresh()
+
def OnSlider(self, e):
print str("on slider:") + str(self.slider.GetValue())
if (int(self.slider.GetValue()) > 0):
- self.test.gotoFrame(int(self.slider.GetValue()) - 1)
+ self.test.gotoFrame(int(self.slider.GetValue()) - 1)
def OnClickBack(self, evt):
- self.test.backAnimation()
+ self.test.backAnimation()
def OnClickPlay(self, evt):
- if self.scene.isPlaying:
- self.test.pauseAnimation()
- self.scene.isPlaying = False
- self.playB.SetBitmapFocus(self.playBmp)
- self.playB.SetBitmapLabel(self.playBmp)
- self.playB.SetBitmapDisabled(self.playBmp)
- else:
- self.test.resumeAnimation()
- self.scene.isPlaying = True
- self.playB.SetBitmapFocus(self.pauseBmp)
- self.playB.SetBitmapLabel(self.pauseBmp)
- self.playB.SetBitmapDisabled(self.pauseBmp)
+ if self.scene.isPlaying:
+ self.test.pauseAnimation()
+ self.scene.isPlaying = False
+ self.playB.SetBitmapFocus(self.playBmp)
+ self.playB.SetBitmapLabel(self.playBmp)
+ self.playB.SetBitmapDisabled(self.playBmp)
+ else:
+ self.test.resumeAnimation()
+ self.scene.isPlaying = True
+ self.playB.SetBitmapFocus(self.pauseBmp)
+ self.playB.SetBitmapLabel(self.pauseBmp)
+ self.playB.SetBitmapDisabled(self.pauseBmp)
def OnClickForward(self, evt):
- self.test.forwardAnimation()
-
+ self.test.forwardAnimation()
+
class Setup(wx.Object):
def __init__(self):
+ self.csafe_scene_path = sys.path[0] + "/"
self.num_workers = None
self.cfg = ""
self.nrrdlist = ""
@@ -584,6 +612,7 @@
self.pixelsampler = None
self.renderer = None
self.size = (512,512)
+ self.tooltipsOn = True
setup = Setup()
@@ -770,13 +799,13 @@
frame1 = MyFrame(None, -1, "C-SAFE Particle/Volume Visualizer")
frame1.scene.mantaFrame = app.frame
- frame1.Show(True)
+ frame1.Show(True)
frame1.InitializeScene(app.frame, app.frame.engine)
frame1.LayoutWindow()
frame1.scene.mantaApp = app
- print "cfg: " + str(setup.cfg)
if (setup.cfg != ""):
+ frame1.generateMenuItem.Enable( True );
Configuration.ReadConfiguration(frame1.scene, setup.cfg)
if (setup.nrrdlist != ""):
Configuration.ReadNRRDList(frame1.scene, setup.nrrdlist)
@@ -795,7 +824,7 @@
frame1.BuildHistograms()
frame1.slider.SetRange(1, 1)
frame1.scene.mantaApp.frame.StartEngine()
-
+
frame1.scene.numThreads = setup.num_workers
frame1.scene.engine.changeNumWorkers(frame1.scene.numThreads)
if (setup.generate == True):
@@ -805,11 +834,19 @@
###########################################################################
# Perform any additional setup
- # initialize_scene2(app.frame, app.frame.engine, app)
+ # initialize_scene2(app.frame, app.frame.engine, app)
# Start rendering.
app.MainLoop()
+###############################################################################
+# Helper Functions
+
+def moveToMouse( window ) :
+ window.Move( (wx.GetMouseState().GetX(),wx.GetMouseState().GetY()) )
+
+###############################################################################
+
if __name__ == "__main__":
- print "starting\n"
+
main()
- [Manta] r2350 - in trunk: SwigInterface scenes/csafe/python, dav, 12/04/2008
Archive powered by MHonArc 2.6.16.