Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1452 - in trunk: Model/Groups SwigInterface


Chronological Thread 
  • From: bigler@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1452 - in trunk: Model/Groups SwigInterface
  • Date: Fri, 6 Jul 2007 15:18:05 -0600 (MDT)

Author: bigler
Date: Fri Jul  6 15:18:04 2007
New Revision: 1452

Modified:
   trunk/Model/Groups/ObjGroup.cc
   trunk/SwigInterface/wxManta.py
Log:

Model/Groups/ObjGroup.cc

  Use a single variable for the texture name rather than doing
  path_name+file_name everywhere.

SwigInterface/wxManta.py

  Don't set the DOUBLEBUFFER flag for versions of wx < 2.6.

  Added HeadLight controls.

  Refactored some of the light dialog code.


Modified: trunk/Model/Groups/ObjGroup.cc
==============================================================================
--- trunk/Model/Groups/ObjGroup.cc      (original)
+++ trunk/Model/Groups/ObjGroup.cc      Fri Jul  6 15:18:04 2007
@@ -26,8 +26,8 @@
                                    const float* map_scaling ) {
   static std::map<string, Texture<Color>*> texture_cache;
 
-  map<string, Texture<Color>*>::iterator iter = 
-    texture_cache.find(path_name + file_name);
+  string tex_name = path_name + file_name;
+  map<string, Texture<Color>*>::iterator iter = texture_cache.find(tex_name);
   if (iter != texture_cache.end())
     return iter->second;
 
@@ -36,7 +36,7 @@
     if (file_name.size()) {
         // Load the image texture.
         try {
-          ImageTexture<Color>* it = LoadColorImageTexture( path_name + 
file_name , &cerr);
+          ImageTexture<Color>* it = LoadColorImageTexture( tex_name , &cerr);
           // The values are assigned to zero in in unintialized state
           if (map_scaling[0] != 0) {
             it->setScale(map_scaling[0], map_scaling[1]);
@@ -45,7 +45,7 @@
             it->setInterpolationMethod(ImageTexture<Color>::Bilinear);
           }
           texture = it;
-          texture_cache[path_name+file_name] = texture;
+          texture_cache[tex_name] = texture;
         }
         catch (SCIRun::Exception &e) {
             std::cerr << "Could not load diffuse map: "

Modified: trunk/SwigInterface/wxManta.py
==============================================================================
--- trunk/SwigInterface/wxManta.py      (original)
+++ trunk/SwigInterface/wxManta.py      Fri Jul  6 15:18:04 2007
@@ -112,7 +112,8 @@
     def __init__(self, parent, sync_display, opengl_display, updateFramerate,
                  size=wx.Size(xres,yres)):
 
-        if (sys.platform == "darwin"):
+        if (sys.platform == "darwin" or
+            (wx.VERSION[0]*10 + wx.VERSION[1]) < 26):
             # This line for OSX
             wxGLCanvas.__init__(self, parent, -1, style=wx.NO_BORDER, 
size=size)
         else:
@@ -213,9 +214,29 @@
         if (head_light != None):
             return self.addHeadLight(where, head_light)
 
+    def addHeadLight(self, where, light):
+        offset = light.getOffset()
+
+        panel = wx.Panel(where, -1)
+
+        gbs = wx.GridBagSizer(5,1)
+        gbs.Add( wx.StaticText(panel, -1, "Offset"), (0,0))
+        spinnerOffset = self.addSpinner(panel, offset)
+        spinnerOffset.light = light
+        # Override the callback function
+        spinnerOffset.Bind(FS.EVT_FLOATSPIN, self.OnOffsetSpin)
+        gbs.Add( spinnerOffset, (0,1))
+        
+        colorWidgets = self.AddColorButton(light, panel)
+        gbs.Add( colorWidgets["colorButton"], (0,2))
+        gbs.Add( wx.StaticText(where, -1, "Color Scale"), (0,3))
+        gbs.Add( colorWidgets["colorScaleSpinner"], (0,4) )
+
+        panel.SetSizerAndFit(gbs)
+        return panel
+
     def addPointLight(self, where, light):
         location = light.getPosition()
-        color = light.getColor().convertRGB()
 
         panel = wx.Panel(where, -1)
         
@@ -240,6 +261,46 @@
         gbs.Add( spinnerY, (0,2))
         gbs.Add( spinnerZ, (0,3))
 
+        colorWidgets = self.AddColorButton(light, panel)
+        gbs.Add( colorWidgets["colorButton"], (0,4))
+        gbs.Add( wx.StaticText(where, -1, "Color Scale"), (0,5))
+        gbs.Add( colorWidgets["colorScaleSpinner"], (0,6) )
+        
+
+        panel.SetSizerAndFit(gbs)
+        return panel
+
+    def addSpinner(self, where, value, id=wx.ID_ANY):
+        floatspin = FS.FloatSpin(where, id,
+                                 increment=0.01, value=value,
+                                 extrastyle=FS.FS_LEFT)
+        floatspin.SetFormat("%g")
+        floatspin.SetDigits(5)
+        floatspin.Bind(FS.EVT_FLOATSPIN, self.OnFloatSpin)
+        return floatspin
+
+    def OnFloatSpin(self, event):
+        # Pull out the new value
+        spinner = event.GetEventObject()
+        x = float(spinner.X.GetValue())
+        y = float(spinner.Y.GetValue())
+        z = float(spinner.Z.GetValue())
+        newPosition = Vector(x,y,z)
+        cbArgs = ( newPosition, )
+        self.engine.addTransaction("Light Position",
+                                   
manta_new(createMantaTransaction(spinner.light.setPosition, cbArgs)))
+
+    def OnOffsetSpin(self, event):
+        # Pull out the new value
+        spinner = event.GetEventObject()
+        offset = float(spinner.GetValue())
+        cbArgs = ( offset, )
+        self.engine.addTransaction("Light Offset",
+                                   
manta_new(createMantaTransaction(spinner.light.setOffset, cbArgs)))
+        
+    def AddColorButton(self, light, where):
+        color = light.getColor().convertRGB()
+
         # Because our colors can be more than one we need to do a
         # little bit of work.  The color selector can't deal with
         # floating point colors, and it must work with ranges [0,255].
@@ -257,7 +318,7 @@
         colorTup = map(lambda c:clampZeroTo255(int(c*255/colorScale)),
                        colorTupRaw)
         
-        colorButton =  csel.ColourSelect(panel, wx.ID_ANY, "Color",
+        colorButton =  csel.ColourSelect(where, 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
@@ -266,15 +327,13 @@
         self.colorButtonRefs[colorButton.GetId()] = colorButton
         colorButton.light = light
 
-        gbs.Add( colorButton, (0,4))
 
         # Add the scale
         print "colorScale = %g, maxComponent = %g" % 
(colorScale,maxComponent)
-        gbs.Add( wx.StaticText(panel, -1, "Color Scale"), (0,5))
         # 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,
+        colorScaleSpinner = FS.FloatSpin(where, wx.ID_ANY,
                                          min_val=1, increment=0.01,
                                          value=colorScale,
                                          extrastyle=FS.FS_LEFT)
@@ -283,32 +342,10 @@
         colorScaleSpinner.Bind(FS.EVT_FLOATSPIN, self.OnColorScaleSpin)
         colorScaleSpinner.button = colorButton
         colorButton.spinner = colorScaleSpinner
-        gbs.Add( colorScaleSpinner, (0,6) )
-        
-
-        panel.SetSizerAndFit(gbs)
-        return panel
-
-    def addSpinner(self, where, value, id=wx.ID_ANY):
-        floatspin = FS.FloatSpin(where, id,
-                                 increment=0.01, value=value,
-                                 extrastyle=FS.FS_LEFT)
-        floatspin.SetFormat("%g")
-        floatspin.SetDigits(5)
-        floatspin.Bind(FS.EVT_FLOATSPIN, self.OnFloatSpin)
-        return floatspin
-
-    def OnFloatSpin(self, event):
-        # Pull out the new value
-        spinner = event.GetEventObject()
-        x = float(spinner.X.GetValue())
-        y = float(spinner.Y.GetValue())
-        z = float(spinner.Z.GetValue())
-        newPosition = Vector(x,y,z)
-        cbArgs = ( newPosition, )
-        self.engine.addTransaction("Light Position",
-                                   
manta_new(createMantaTransaction(spinner.light.setPosition, cbArgs)))
 
+        # Shoving multiple results in a dictionary will make things a little 
easier to read.
+        results = {"colorButton":colorButton, 
"colorScaleSpinner":colorScaleSpinner}
+        return results
 
     def UpdateColor(self, colorButton):
         color = colorButton.GetColour()




  • [MANTA] r1452 - in trunk: Model/Groups SwigInterface, bigler, 07/06/2007

Archive powered by MHonArc 2.6.16.

Top of page