Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1300 - trunk/SwigInterface


Chronological Thread 
  • From: bigler@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1300 - trunk/SwigInterface
  • Date: Wed, 14 Mar 2007 14:22:49 -0700 (MST)

Author: bigler
Date: Wed Mar 14 14:22:48 2007
New Revision: 1300

Modified:
   trunk/SwigInterface/FloatSpin.py
   trunk/SwigInterface/runwxmanta.py
   trunk/SwigInterface/wxManta.py
Log:

FloatSpin.py

  Code comment changes.

runwxmanta.py

  Create a copy of command arguments that help with the perhaps 'late'
  binding of the lambda parameter.

wxManta.py

  Restructered some of the light dialog stuff to make it (hopefully)
  work on the mac.  It didn't like it when I gave the same ID to
  multiple widgets.


Modified: trunk/SwigInterface/FloatSpin.py
==============================================================================
--- trunk/SwigInterface/FloatSpin.py    (original)
+++ trunk/SwigInterface/FloatSpin.py    Wed Mar 14 14:22:48 2007
@@ -72,15 +72,16 @@
 FloatSpin Construction Can Be Summarized As Follows:
 
 FloatSpin.__init__(self, parent, id, pos=wx.DefaultPosition,
-                   size=wx.DefaultSize, style=0, value=0.0, min=0.0, 
max=100.0,
+                   size=wx.DefaultSize, style=0, value=0.0,
+                   min_val=None, max_val=None,
                    increment=1.0, digits=-1, extrastyle=FS_LEFT,
                    name="FloatSpin")
 
 Where:
 
 - value: Is The Current Value For FloatSpin;
-- min: The Minimum Value;
-- max: The Maximum Value;
+- min_val: The Minimum Value, not used if None
+- max_val: The Maximum Value, not used if None
 - increment: The Increment For Every EVT_FLOATSPIN Events;
 - digits: Number Of Representative Digits For Your Floating Point Numbers;
 - extrastyle: One Of The Following:
@@ -97,6 +98,28 @@
 
 Latest Revision: Andrea Gavana @ 16 Nov 2005, 21.50 CET
 
+Modifications to allow min_val or max_val to be None done by:
+
+  James Bigler
+  SCI Institute, University of Utah
+  March 14, 2007
+
+Note that the changes I made will break backward compatibility,
+because I changed the contructor's parameters from min/max to
+min_val/max_val to be consistent with the other functions and to
+eliminate any potential confusion with the built in min and max
+functions.
+
+You specify open ranges like this (you can equally do this in the
+constructor).
+
+[1,] => SetRange(min_val=1, max_val=None)
+[,0] => SetRange(min_val=None, max_val=0)
+
+Or no range
+
+[,]  => SetRange(min_val=None, max_val=None)
+
 """
 
 
@@ -210,8 +233,8 @@
         Default Class Constructor. Non-Default Parameters Are:
         
         - value: Is The Current Value For FloatSpin;
-        - min: The Minimum Value, ignored if None
-        - max: The Maximum Value, ignored if None
+        - min_val: The Minimum Value, ignored if None
+        - max_val: The Maximum Value, ignored if None
         - increment: The Increment For Every EVT_FLOATSPIN Events;
         - digits: Number Of Representative Digits For Your Floating Point 
Numbers;
         - extrastyle: One Of The Following:

Modified: trunk/SwigInterface/runwxmanta.py
==============================================================================
--- trunk/SwigInterface/runwxmanta.py   (original)
+++ trunk/SwigInterface/runwxmanta.py   Wed Mar 14 14:22:48 2007
@@ -31,7 +31,8 @@
                 usage()
                 sys.exit(2)
         if o in ("-s", "--scene"):
-            sceneCreator = lambda frame,engine: 
wxManta.createPluginScene(frame, engine, a)
+            sceneArg = str(a)
+            sceneCreator = lambda frame,engine: 
wxManta.createPluginScene(frame, engine, sceneArg)
             
 
         # Add additional command line args here.
@@ -39,6 +40,8 @@
 
     
###########################################################################
     # Create the application.
+    print "num_workers = "
+    print num_workers
     app = wxManta.MantaApp( sceneCreator, num_workers )
 
 

Modified: trunk/SwigInterface/wxManta.py
==============================================================================
--- trunk/SwigInterface/wxManta.py      (original)
+++ trunk/SwigInterface/wxManta.py      Wed Mar 14 14:22:48 2007
@@ -75,6 +75,7 @@
     engine.setScene( scene )
 
 def createPluginScene( frame, engine, scene_parameters ):
+    print "scene_parameters = %s" % (scene_parameters,)
     scene = frame.factory.readScene(scene_parameters)
     
 class DisplayThread(threading.Thread):
@@ -246,9 +247,12 @@
         colorTup = map(lambda c:clampZeroTo255(int(c*255/colorScale)),
                        colorTupRaw)
         
-        colorButton =  csel.ColourSelect(panel, -1, "Color",
+        colorButton =  csel.ColourSelect(panel, wx.ID_ANY, "Color",
                                                         tuple(colorTup))
         colorButton.Bind(csel.EVT_COLOURSELECT, self.OnSelectColor)
+        # You have to use these refs, because the event you get in
+        # your callback doesn't contain the actual colorButton object.
+        # All you can be sure of is the ID.
         self.colorButtonRefs[colorButton.GetId()] = colorButton
         colorButton.light = light
 
@@ -257,13 +261,17 @@
         # Add the scale
         print "colorScale = %g, maxComponent = %g" % 
(colorScale,maxComponent)
         gbs.Add( wx.StaticText(panel, -1, "Color Scale"), (0,5))
-        colorScaleSpinner = FS.FloatSpin(panel, colorButton.GetId(),
+        # I tried to make the ID the same as the colorButton and bind
+        # it to the same callback, but wxMac didn't like it.  Thus,
+        # the spinner now gets its own callback.
+        colorScaleSpinner = FS.FloatSpin(panel, wx.ID_ANY,
                                          min_val=1, increment=0.01,
                                          value=colorScale,
                                          extrastyle=FS.FS_LEFT)
         colorScaleSpinner.SetFormat("%g")
         colorScaleSpinner.SetDigits(5)
-        colorScaleSpinner.Bind(FS.EVT_FLOATSPIN, self.OnSelectColor)
+        colorScaleSpinner.Bind(FS.EVT_FLOATSPIN, self.OnColorScaleSpin)
+        colorScaleSpinner.button = colorButton
         colorButton.spinner = colorScaleSpinner
         gbs.Add( colorScaleSpinner, (0,6) )
         
@@ -292,17 +300,7 @@
                                    
manta_new(createMantaTransaction(spinner.light.setPosition, cbArgs)))
 
 
-    def OnSelectColor(self, event):
-        try:
-            colorButton = self.colorButtonRefs[event.GetId()]
-        except:
-            dlg = wx.MessageDialog(self, 'Getting Wrong IDs from Color 
event!',
-                                   'ERROR',
-                                   wx.OK | wx.ICON_ERROR
-                                   )
-            dlg.ShowModal()
-            dlg.Destroy()
-            return
+    def UpdateColor(self, colorButton):
         color = colorButton.GetColour()
         colorScale = float(colorButton.spinner.GetValue()) / 255.0
         rgbColor = RGBColor(color.Red()   * colorScale,
@@ -311,6 +309,20 @@
         cbArgs = ( Color(rgbColor), )
         self.engine.addTransaction("Light Color",
                                    
manta_new(createMantaTransaction(colorButton.light.setColor, cbArgs)))
+        
+    def OnColorScaleSpin(self, event):
+        try:
+            colorButton = event.GetEventObject().button
+            self.UpdateColor(colorButton)
+        except:
+            wx.LogError("Button not found")
+        
+    def OnSelectColor(self, event):
+        try:
+            colorButton = self.colorButtonRefs[event.GetId()]
+            self.UpdateColor(colorButton)
+        except:
+            wx.LogError("Button not found")
 
 
###############################################################################
 
###############################################################################




  • [MANTA] r1300 - trunk/SwigInterface, bigler, 03/14/2007

Archive powered by MHonArc 2.6.16.

Top of page