Text archives Help
- From:
- To:
- Subject: [Manta] r2356 - trunk/scenes/csafe/python
- Date: Wed, 17 Dec 2008 14:22:58 -0700 (MST)
Author: dav
Date: Wed Dec 17 14:22:56 2008
New Revision: 2356
Modified:
trunk/scenes/csafe/python/Configuration.py
trunk/scenes/csafe/python/SceneMenus.py
trunk/scenes/csafe/python/csafe_scene.py
Log:
M scenes/csafe/python/csafe_scene.py
- Use a single dialog (instead of creating a new one each time (without
destroying the old one)) for the 'volume position' and 'add/remove
file' dialogs. Place the dialogs near mouse when they are invoked.
- Update menu status (enabled/disabled) in (correct) common location
M scenes/csafe/python/SceneMenus.py
Don't destory the window when it is closed, just withdraw it.
M scenes/csafe/python/Configuration.py
- Fix problem with forceDataMin/Max writing.
- Tried to clean up the placement of "i+=1" to make the code more readable.
- Added comments on what the "[Scene Properties] list contains.
Modified: trunk/scenes/csafe/python/Configuration.py
==============================================================================
--- trunk/scenes/csafe/python/Configuration.py (original)
+++ trunk/scenes/csafe/python/Configuration.py Wed Dec 17 14:22:56 2008
@@ -62,8 +62,8 @@
f.write( '\n' )
f.write('[Scene Properties]\n')
- f.write(str(scene.forceDataMin+'\n'))
- f.write(str(scene.forceDataMax+'\n'))
+ f.write(str(scene.forceDataMin)+'\n')
+ f.write(str(scene.forceDataMax)+'\n')
f.write(str(scene.duration)+'\n')
f.write(str(scene.ridx)+'\n')
f.write(str(scene.radius)+'\n')
@@ -105,7 +105,7 @@
scene.nrrdFiles = []
scene.nrrdFiles2 = []
- ###read in new values
+ ### Read in new values
lines = f.readlines()
currentHistogramIndex = 0
currentParticleHistogramIndex = 0
@@ -113,17 +113,13 @@
##### Transfer Function####
if lines[i].find("[Transfer Function]") != -1:
i+=1
- name = lines[i].strip()
- print name
- i+=1
- id = int(lines[i].strip())
- i+=1
- num = int(lines[i].strip())
+ name = lines[i].strip(); i += 1
+ id = int(lines[i].strip()); i += 1
+ num = int(lines[i].strip()); i += 1
colors = []
slices = manta_new(vector_ColorSlice())
for j in range(num):
- i+=1
- line = lines[i].split()
+ line = lines[i].split(); i += 1
pos = float(line[0])
r = float(line[1])
g = float(line[2])
@@ -148,24 +144,18 @@
#### Histogram ####
elif lines[i].find("[Histogram]") != -1:
i +=1
- name = lines[i].strip()
- i += 1
- index = int(float(lines[i].strip()))
- i += 1
- group = int(float(lines[i].strip()))
- i += 1
- zoomInto = lines[i].split()
+ name = lines[i].strip(); i += 1
+ index = int(float(lines[i].strip())); i += 1
+ group = int(float(lines[i].strip())); i += 1
+ zoomInto = lines[i].split(); i += 1
zoomIntoMin = float(zoomInto[0])
zoomIntoMax = float(zoomInto[1])
- i+=1
- cropDisplay = lines[i].split()
+ cropDisplay = lines[i].split(); i += 1
cropDisplayMin = float(cropDisplay[0])
cropDisplayMax = float(cropDisplay[1])
- i+=1
- cropColor = lines[i].split()
+ cropColor = lines[i].split(); i += 1
cropColorMin = float(cropColor[0])
cropColorMax = float(cropColor[1])
- i+=1
transferFID = int(lines[i].strip())
histValues1 = []
for i in range(scene.histogramBuckets):
@@ -194,28 +184,25 @@
##### Eye (Camera) ####
elif lines[i].find("[Eye]") != -1:
- i+=1
- line = lines[i].split()
+ i += 1
+ line = lines[i].split(); i += 1
x = float(line[0])
y = float(line[1])
z = float(line[2])
eye = manta_new( Vector(x, y, z) )
- i+=1
- line = lines[i].split()
+ line = lines[i].split(); i += 1
x = float(line[0])
y = float(line[1])
z = float(line[2])
lookat = manta_new( Vector(x, y, z) )
- i+=1
- line = lines[i].split()
+ line = lines[i].split(); i += 1
x = float(line[0])
y = float(line[1])
z = float(line[2])
up = manta_new( Vector(x, y, z) )
- i+=1
line = lines[i].split()
h = float(line[0]) # h-fov
v = float(line[1]) # v-fov
@@ -226,57 +213,58 @@
cbArgs)))
##### Scene Properties ####
+ # DataMin
+ # DataMax
+ # duration
+ # ridx
+ # radius
+ # cidx
+ # numThreads
+ # minBound
+ # maxBound
+ # numVol files
+ # nrrd name(s)
+ # numParticle files
+ # nrrd name(s)
elif lines[i].find("[Scene Properties]") != -1:
i+=1
- scene.forceDataMin = float(lines[i].strip())
- i+=1
- scene.forceDataMax = float(lines[i].strip())
+ scene.forceDataMin = float(lines[i].strip()); i += 1
+ scene.forceDataMax = float(lines[i].strip()); i += 1
if (scene.forceDataMin != scene.forceDataMax):
scene.test.setVolColorMinMax(scene.forceDataMin,
scene.forceDataMax)
- i+=1
- scene.duration = float(lines[i].strip())
+ scene.duration = float(lines[i].strip()); i += 1
scene.test.setDuration(scene.duration)
- i+=1
- scene.ridx = int(float(lines[i].strip()))
+ scene.ridx = int(float(lines[i].strip())); i += 1
scene.test.setRidx(scene.ridx)
- i+=1
- scene.radius = float(lines[i].strip())
+ scene.radius = float(lines[i].strip()); i += 1
scene.test.setRadius(scene.radius)
- i+=1
- scene.cidx = int(float(lines[i].strip()))
+ scene.cidx = int(float(lines[i].strip())); i += 1
scene.test.setCidx(scene.cidx)
- i+=1
- scene.numThreads = int(float(lines[i].strip()))
+ scene.numThreads = int(float(lines[i].strip())); i += 1
scene.engine.changeNumWorkers(scene.numThreads)
- i+=1
- minBound = lines[i].split()
- i+=1
- maxBound = lines[i].split()
+ minBound = lines[i].split(); i += 1
+ maxBound = lines[i].split(); i += 1
for j in range(3):
scene.volumeMinBound[j] = float(minBound[j])
scene.volumeMaxBound[j] = float(maxBound[j])
- minVector = Vector(scene.volumeMinBound[0],
scene.volumeMinBound[1],
- scene.volumeMinBound[2])
- maxVector = Vector(scene.volumeMaxBound[0],
scene.volumeMaxBound[1],
- scene.volumeMaxBound[2])
+ minVector = Vector(scene.volumeMinBound[0],
scene.volumeMinBound[1], scene.volumeMinBound[2])
+ maxVector = Vector(scene.volumeMaxBound[0],
scene.volumeMaxBound[1], scene.volumeMaxBound[2])
scene.test.setVolumeMinMaxBounds(minVector, maxVector)
print "setting numWorkers to: " + str(scene.numThreads)
- i+=1
- numVol = int(float(lines[i].strip()))
+ numVol = int(float(lines[i].strip())); i += 1
+
for j in range(numVol):
- i += 1
- nrrd = lines[i].strip()
+ nrrd = lines[i].strip(); i += 1
if not os.path.exists( nrrd ) :
print ""
print "ERROR file '" + nrrd + "' does not exist. Config
file appears to be invalid. Goodbye."
print ""
os._exit( -1 ) # We're done... force exit.
scene.nrrdFiles2.append( nrrd )
- i+=1
- numSphere = int(float(lines[i].strip()))
+
+ numSphere = int(float(lines[i].strip())); i += 1
for j in range(numSphere):
- i+=1
- nrrd = lines[i].strip()
+ nrrd = lines[i].strip(); i += 1
if not os.path.exists( nrrd ) :
print ""
print "ERROR file '" + nrrd + "' does not exist. Config
file appears to be invalid. Goodbye."
@@ -308,21 +296,17 @@
lines = f.readlines()
i = 0
while i in range(len(lines)-1):
- vol = lines[i].strip()
+ vol = lines[i].strip(); i += 1
while (vol == "" and i < len(lines)-1):
- i +=1
- vol = lines[i].strip()
- 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()
+ sphere = lines[i].strip(); i += 1
if (sphere == "" or vol == ""):
return
print "volume file: " + str(vol) + " sphere file: " + str(sphere)
scene.nrrdFiles.append(sphere)
scene.nrrdFiles2.append(vol)
- i += 1
def WriteNRRDList(scene, filename):
f = open(filename, 'w')
Modified: trunk/scenes/csafe/python/SceneMenus.py
==============================================================================
--- trunk/scenes/csafe/python/SceneMenus.py (original)
+++ trunk/scenes/csafe/python/SceneMenus.py Wed Dec 17 14:22:56 2008
@@ -223,7 +223,6 @@
panel.SetSizer(sizer)
-
def addSpinner(self, where, value, id=wx.ID_ANY):
floatspin = FS.FloatSpin(where, id,
increment=0.001, value=value,
@@ -314,7 +313,12 @@
panel.SetSizer(sizer)
panel.Refresh()
self.Refresh()
-
+
+ self.Bind( wx.EVT_CLOSE, self.OnCloseWindow )
+
+
+ def OnCloseWindow( self, evt ):
+ self.Show( False )
def addSpinner(self, where, value, id=wx.ID_ANY):
Modified: trunk/scenes/csafe/python/csafe_scene.py
==============================================================================
--- trunk/scenes/csafe/python/csafe_scene.py (original)
+++ trunk/scenes/csafe/python/csafe_scene.py Wed Dec 17 14:22:56 2008
@@ -37,7 +37,6 @@
# Import wxManta gui and some system modules.
#import wxversion
#wxversion.ensureMinimal("2.8")
-import wxManta
import getopt, sys, re
from manta import *
@@ -45,8 +44,10 @@
import wx
import wx.lib.scrolledpanel as scrolled
#from wx.lib.wordwrap import wordwrap
-from csafe import *
+from csafe import *
+import wxManta
+from wxManta import moveToMouse
import wx.lib.buttons
import sys, os, time, traceback, types
@@ -77,6 +78,8 @@
wx.Point(20,20), wx.Size(400, 450))
self.panel = scrolled.ScrolledPanel(self,-1, style= wx.TAB_TRAVERSAL)
self.scene = SceneInfo.Scene()
+ self.volPosSizeFrame = None
+ self.addRemoveFilesFrame = None
# CurrentHistogram is the histogram being edited.
currentParticleHistogram may also
# be the currentHistogram, but always denotes the histogram
currently chosen
@@ -99,7 +102,7 @@
menuFile.Append(109, "&Quit", "")
menuScene = wx.Menu()
- menuScene.Append(201, "&Add/Remove Data Files", "Add and remove Nrrd
files for the scene")
+ self.addRemoveDataFilesMenu = 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(202, "Scene Preferences")
menuScene.Append(205, "Cutting Bounding Box")
@@ -163,12 +166,20 @@
wx.ToolTip.Enable( setup.tooltipsOn )
def Menu205(self, evt):
- frame = SceneMenus.BBoxFrame(self, -1, "Bounding Box", self.scene)
- frame.Show(True)
+ if( self.addRemoveDataFilesMenu == None ) :
+ self.addRemoveDataFilesMenu = SceneMenus.BBoxFrame(self, -1,
"Bounding Box", self.scene)
+
+ moveToMouse( self.addRemoveDataFilesMenu )
+ self.addRemoveDataFilesMenu.Raise()
+ self.addRemoveDataFilesMenu.Show(True)
def MenuVolPositionSize(self, evt):
- frame = SceneMenus.VolPositionSizeFrame(self, -1, "Volume Position
and Size", self.scene)
- frame.Show(True)
+ if( self.volPosSizeFrame == None ) :
+ self.volPosSizeFrame = SceneMenus.VolPositionSizeFrame( self, -1,
+ "Volume
Position and Size", self.scene )
+ moveToMouse( self.volPosSizeFrame )
+ self.volPosSizeFrame.Raise()
+ self.volPosSizeFrame.Show(True)
def Menu110(self, evt):
self.SetFocus()
@@ -291,9 +302,6 @@
################ Generate Scene #################
def Menu203(self, evt):
- # 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 #################
@@ -309,6 +317,9 @@
print name
def BuildScene(self):
+ self.generateMenuItem.Enable( False )
+ self.addRemoveDataFilesMenu.Enable( False )
+
self.test.setRidx(int(self.scene.ridx))
self.test.setRadius(float(self.scene.radius))
self.test.clearSphereNrrds();
- [Manta] r2356 - trunk/scenes/csafe/python, dav, 12/17/2008
Archive powered by MHonArc 2.6.16.