Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[Manta] r2401 - in trunk: Model/Readers SwigInterface scenes/csafe/python


Chronological Thread 
  • From:
  • To:
  • Subject: [Manta] r2401 - in trunk: Model/Readers SwigInterface scenes/csafe/python
  • Date: Mon, 13 Apr 2009 09:31:07 -0600 (MDT)

Author: brownlee
Date: Mon Apr 13 09:30:55 2009
New Revision: 2401

Modified:
   trunk/Model/Readers/UDAReader-stub.cc
   trunk/SwigInterface/CSpin.py
   trunk/SwigInterface/FloatSpin.py
   trunk/SwigInterface/MantaCapture.py
   trunk/scenes/csafe/python/Histogram.py
   trunk/scenes/csafe/python/SceneMenus.py
Log:
Histogram.py:
        zoom buttons now zoominto the center instead of the crop regions
        right clicking now pans the visible region from left to right
        fixed reset button position
        changes in measurements frame now take effect to manta even if not
        currently displayed histogram.
        got rid of cancel button in measurement frame
FloatSpin.py:
        still getting bogus text events, now it looks for two before coloring
        red.  hopefully this gets rid of them though it means it might not
        catch the first true text event.
MantaCapture.py:
        adding try, except blocks just in case of permissions problems.
        added error dialog if there is a problem
SceneMenus.py
        fixing indentation
        index in nrrd no longer appears for volume when adding a histogram
CSpin.py:
        changing error color from dark grey to dark red



Modified: trunk/Model/Readers/UDAReader-stub.cc
==============================================================================
--- trunk/Model/Readers/UDAReader-stub.cc       (original)
+++ trunk/Model/Readers/UDAReader-stub.cc       Mon Apr 13 09:30:55 2009
@@ -8,3 +8,7 @@
     cerr << "UDAReader compiled without libxml, please link libxml2 and 
recompile Manta\n";
 }
 
+void UDAReader::readUDAHeader(string directory)
+{
+    cerr << "UDAReader compiled without libxml, please link libxml2 and 
recompile Manta\n";
+}

Modified: trunk/SwigInterface/CSpin.py
==============================================================================
--- trunk/SwigInterface/CSpin.py        (original)
+++ trunk/SwigInterface/CSpin.py        Mon Apr 13 09:30:55 2009
@@ -11,7 +11,7 @@
 
     def OnText(self, evt):
         if self.color_set:  
-          self.SetBackgroundColour(wx.Colour(220,220,220))
+          self.SetBackgroundColour(wx.Colour(150,30,30))
         self.color_set = True
         evt.Skip()
 

Modified: trunk/SwigInterface/FloatSpin.py
==============================================================================
--- trunk/SwigInterface/FloatSpin.py    (original)
+++ trunk/SwigInterface/FloatSpin.py    Mon Apr 13 09:30:55 2009
@@ -440,9 +440,10 @@
 
 
     def OnText(self, event):
-        if self.color_set > 1:  
-          self.SetBackgroundColour(wx.Colour(128,0,0))
-        self.color_set += 1
+       if (event != None):
+          if self.color_set > 2:  
+            self.SetBackgroundColour(wx.Colour(128,0,0))
+          self.color_set += 1
         
     def OnChar(self, event):
         """ Handles The wx.EVT_CHAR For The Underline wx.TextCtrl. """

Modified: trunk/SwigInterface/MantaCapture.py
==============================================================================
--- trunk/SwigInterface/MantaCapture.py (original)
+++ trunk/SwigInterface/MantaCapture.py Mon Apr 13 09:30:55 2009
@@ -192,21 +192,32 @@
         evt.Skip()
 
     def OnStartButton( self, event ):
-
+      try:
         self.capture_panel.OnStartButton( event )
         
         self.start_button.Disable()
         self.stop_button.Enable()
         self.capture_button.Disable()
+      except:
+        print "Error encountered, make sure you have sufficient write 
priviledges"
+        dlg = wx.MessageDialog(self, "Error: you probably don't have correct 
priviledges", "Error saving frames", wx.OK)
+       dlg.ShowModal()
+       dlg.Destroy()
 
 
     def OnStopButton( self, event ):
-
+      try:
         self.capture_panel.OnStopButton( event )
 
         self.start_button.Enable()
         self.stop_button.Disable()
         self.capture_button.Enable()
+      except:
+        print "Error encountered, make sure you have sufficient write 
priviledges"
+        dlg = wx.MessageDialog(self, "Error: you probably don't have correct 
priviledges", "Error saving frames", wx.OK)
+        dlg.ShowModal()
+        dlg.Destroy()
+
         
 
     def OnCaptureButton( self, event ):

Modified: trunk/scenes/csafe/python/Histogram.py
==============================================================================
--- trunk/scenes/csafe/python/Histogram.py      (original)
+++ trunk/scenes/csafe/python/Histogram.py      Mon Apr 13 09:30:55 2009
@@ -66,10 +66,13 @@
         self.Update()
         self.Bind(wx.EVT_LEFT_DOWN, self.OnClick)
         self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
-        self.Bind(wx.EVT_RIGHT_UP, self.OnRightClick)
+        self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightClick)
+        self.Bind(wx.EVT_RIGHT_UP, self.OnRightUp)
         self.Bind(wx.EVT_MOTION, self.OnMotion)
         self.Bind( wx.EVT_MOUSEWHEEL, self.OnMouseWheel )
         self.SetBackgroundColour(wx.Colour(90,90,90))
+        self.panning = False
+        self.panning_pos = 0
         #self.SetForegroundColour(wx.Colour(255,255,255))
        
     def SetHistValues(self, histValues, dataMin, dataMax):
@@ -99,51 +102,51 @@
         # zoom in if rot > 0, out if ro < 0
         dWidth = self.zoomDMax - self.zoomDMin
         zoomAmount = 0.75 # the smaller the more zooming
-        if (rot > 0):
-            self.zooms.append( (self.zoomDMin, self.zoomDMax))
-            
-            self.zoomDMax = (pos + zoomAmount*(1.0 - pos))*dWidth + 
self.zoomDMin
-            self.zoomDMin = (pos - zoomAmount*pos)*dWidth + self.zoomDMin
+        if (rot > 0): 
+          self.ZoomIn(pos,zoomAmount)
         
         if (rot < 0):
-            self.zoomDMax += (pos + zoomAmount*(1.0 - pos))*dWidth
-            self.zoomDMin -= (pos - zoomAmount*pos)*dWidth
+          self.ZoomOut(pos, zoomAmount)
+    
+    def ZoomIn(self, pos, zoom_amount):
+      dWidth = self.zoomDMax - self.zoomDMin
+      self.zoomDMax = (pos + zoom_amount*(1.0 - pos))*dWidth + self.zoomDMin
+      self.zoomDMin = (pos - zoom_amount*pos)*dWidth + self.zoomDMin
 
-        if (self.zoomDMin < self.absoluteDMin):
+      if (self.zoomDMin < self.absoluteDMin):
            self.zoomDMin = self.absoluteDMin
-        if (self.zoomDMax > self.absoluteDMax):
+      if (self.zoomDMax > self.absoluteDMax):
            self.zoomDMax = self.absoluteDMax
             
-        tempMin = self.cropDMin
-        tempMax = self.cropDMax
-        self.Update()
-        self.cropDMin = tempMin
-        self.cropDMax = tempMax
-        self.UpdateCropToD()
-        self.UpdateMeasurementsFrame()
-    
-    def ZoomIn(self):
-        self.zooms.append( (self.zoomDMin, self.zoomDMax))
-        self.zoomDMin = self.cropDMin
-        self.zoomDMax = self.cropDMax
-        tempMin = self.cropDMin
-        tempMax = self.cropDMax
-        self.Update()
-        self.cropDMin = tempMin
-        self.cropDMax = tempMax
-        self.UpdateCropToD()
-        
-    def ZoomOut(self):
-        if (len(self.zooms)) > 0:
-            zoom = self.zooms.pop()
-            self.zoomDMin = zoom[0]
-            self.zoomDMax = zoom[1]
-            tempMin = self.cropDMin
-            tempMax = self.cropDMax
-            self.Update()
-            self.cropDMin = tempMin
-            self.cropDMax = tempMax
-            self.UpdateCropToD()
+      tempMin = self.cropDMin
+      tempMax = self.cropDMax
+      self.Update()
+      self.cropDMin = tempMin
+      self.cropDMax = tempMax
+      self.UpdateCropToD()
+      self.UpdateMeasurementsFrame()
+       
+        
+    def ZoomOut(self, pos, zoom_amount):
+      zoom_amount = 1.0/zoom_amount
+      dWidth = self.zoomDMax - self.zoomDMin
+      self.zoomDMax = (pos + zoom_amount*(1.0 - pos))*dWidth + self.zoomDMin
+      self.zoomDMin = (pos - zoom_amount*pos)*dWidth + self.zoomDMin
+      #self.zoomDMax += (pos + zoom_amount*(1.0 - pos))*dWidth
+      #self.zoomDMin -= (pos - zoom_amount*pos)*dWidth
+
+      if (self.zoomDMin < self.absoluteDMin):
+       self.zoomDMin = self.absoluteDMin
+      if (self.zoomDMax > self.absoluteDMax):
+        self.zoomDMax = self.absoluteDMax
+         
+      tempMin = self.cropDMin
+      tempMax = self.cropDMax
+      self.Update()
+      self.cropDMin = tempMin
+      self.cropDMax = tempMax
+      self.UpdateCropToD()
+      self.UpdateMeasurementsFrame()
        
     def OnClick(self, evt):
         pos = float(evt.GetPosition().x - 
self.paddingW/2.0)/float(self.width)
@@ -188,7 +191,41 @@
         #self.scene.test.setClipMinMax(self.varIndex, self.cropDMin, 
self.cropDMax)
     
     def OnRightClick(self, evt):
-        None        
+      pos = float(evt.GetPosition().x - self.paddingW/2.0)/float(self.width)
+      self.panning = True
+      self.panning_pos = pos
+
+    def OnRightUp(self, evt):
+      self.panning = False
+
+    def Pan(self, amount):
+      dWidth = self.zoomDMax - self.zoomDMin
+      pan = amount*dWidth
+      if (amount > 0):
+        if( self.zoomDMax + pan ) > self.absoluteDMax:
+          pan = self.absoluteDMax - self.zoomDMax
+      if (amount < 0):
+        if( self.zoomDMin + pan ) < self.absoluteDMin:
+          pan =  self.zoomDMin - self.absoluteDMin
+      self.zoomDMax += pan
+      self.zoomDMin += pan
+      #self.zoomDMax += (pos + zoom_amount*(1.0 - pos))*dWidth
+      #self.zoomDMin -= (pos - zoom_amount*pos)*dWidth
+
+      if (self.zoomDMin < self.absoluteDMin):
+        self.zoomDMin = self.absoluteDMin
+      if (self.zoomDMax > self.absoluteDMax):
+        self.zoomDMax = self.absoluteDMax
+    
+      tempMin = self.cropDMin
+      tempMax = self.cropDMax
+      self.Update()
+      self.cropDMin = tempMin
+      self.cropDMax = tempMax
+      self.UpdateCropToD()
+      self.UpdateMeasurementsFrame()
+      
+      
         
     def OnMotion(self, evt):
         #pdc = wx.PaintDC(self)
@@ -198,6 +235,9 @@
           return
         pos = float(evt.GetPosition().x - 
self.paddingW/2.0)/float(self.width)
         update_clip = False
+        if (self.panning):  
+          self.Pan(pos - self.panning_pos)
+          self.panning_pos = pos
         if self.selecting == True:
             self.cropMax = pos
             self.UpdateDisplayedValues()
@@ -784,16 +824,16 @@
         if (self.histogram.parent.group == 0):
             if self.transferFPanel.transferFPanel.histogramGroup == self:
                 
self.scene.test.setSphereColorMinMax(self.histogram.varIndex, colorMin, 
colorMax)
-                self.scene.test.setClipMinMax(self.histogram.varIndex, 
cropMin,cropMax)
+            self.scene.test.setClipMinMax(self.histogram.varIndex, 
cropMin,cropMax)
         else:
                 self.scene.test.setVolColorMinMax(float(colorMin), 
float(colorMax))
                 
self.scene.test.setVolClipMinMax(self.histogram.absoluteDMin, 
self.histogram.absoluteDMax, cropMin, cropMax)
         
     def OnClickZoomIn(self, evt):
-        self.histogram.ZoomIn()
+        self.histogram.ZoomIn(.5, .75)
         
     def OnClickZoomOut(self, evt):
-        self.histogram.ZoomOut()
+        self.histogram.ZoomOut(.5, .75)
         
     def Update(self):
         self.histogram.Update()
@@ -881,11 +921,13 @@
             
 class MeasurementsFrame(wx.Frame):
     def __init__(self, parent, ID, title,  zoomMin, zoomMax, cropMin, 
cropMax, colorMin, colorMax, group, pos=wx.DefaultPosition, 
size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE):
+      
+        self.cancelling = False
         wx.Frame.__init__(self, parent, ID, title, pos, size, style)
         self.parent = parent
-        panel = wx.Panel(self, -1)
-        vs = wx.BoxSizer( wx.VERTICAL )
-        gbs = wx.GridBagSizer(5,5)
+        self.panel = panel = wx.Panel(self, -1)
+        self.vs = vs = wx.BoxSizer( wx.VERTICAL )
+        gbs = wx.GridBagSizer(6,6)
         self.group = group
         self.zoomText = wx.StaticText(panel, -1, "Zoom into data values: ", 
(20, 10))
         spin = self.zoomMinFS = self.addSpinner(panel,zoomMin);
@@ -905,7 +947,7 @@
         spin = self.colorMaxFS = self.addSpinner(panel,colorMax);
         self.Bind(FS.EVT_FLOATSPIN, self.OnColorMaxFS, self.colorMaxFS )
         self.button = wx.Button(panel, -1, "OK")
-        self.cancelB = wx.Button(panel, -1, "Cancel")
+        #self.cancelB = wx.Button(panel, -1, "Cancel")
         self.resetB = wx.Button(panel, -1, "Reset")
         self.Bind(wx.EVT_BUTTON, self.OnReset, self.resetB)
 
@@ -924,33 +966,49 @@
         gbs.Add(self.colorText, (3,0))
         gbs.Add(self.colorMinFS, (3,1))
         gbs.Add(self.colorMaxFS, (3,2))
-        gbs.Add(self.resetB, (4,2))
         
         vs2 = wx.BoxSizer( wx.HORIZONTAL )
         
         vs2.Add(self.button)
+        #vs2.AddSpacer(15)
+        #vs2.Add(self.cancelB)
         vs2.AddSpacer(15)
-        vs2.Add(self.cancelB)
+        vs2.Add(self.resetB)
         vs2.Layout()
         
-        vs.Add(gbs, 0, wx.ALIGN_CENTRE, 1 )
+        vs.Add(gbs, 0, wx.ALIGN_CENTRE, border=15 )
+        vs.AddSpacer(15)
         vs.Add(vs2, 0, wx.ALIGN_CENTRE|wx.ALIGN_BOTTOM, 1 )
+        vs.AddSpacer(15)
         
         vs.Layout()
         
         panel.SetSizerAndFit(vs)
 
-        vs3 = wx.BoxSizer(wx.VERTICAL)
-        vs3.Add(panel,0, wx.EXPAND)
+        self.vs3 = vs3 = wx.BoxSizer(wx.VERTICAL)
+        vs3.Add(panel,0, wx.EXPAND, border=15)
         self.SetSizerAndFit(vs3)
         self.SetAutoLayout(True)
         
 
         self.Bind(wx.EVT_BUTTON, self.OnOK, self.button)
-        self.Bind(wx.EVT_BUTTON, self.OnCancel, self.cancelB)
+        #self.Bind(wx.EVT_BUTTON, self.OnCancel, self.cancelB)
         self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
+        self.Bind(wx.EVT_SHOW, self.OnShowWindow)
         panel.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
         panel.SetFocus()
+        
+        self.zoomMin = self.zoomMinFS.GetValue()
+        self.zoomMax = self.zoomMaxFS.GetValue()
+        self.cropMin = self.cropMinFS.GetValue()
+        self.cropMax = self.cropMaxFS.GetValue()
+        self.colorMin = self.colorMinFS.GetValue()
+        self.colorMax = self.colorMaxFS.GetValue()
+        
+        
+    def OnShowWindow(self, evt):
+      None
+      #  self.cancelling = False
 
     def OnKeyDown(self, evt):
         keycode = evt.GetKeyCode()
@@ -1025,6 +1083,14 @@
         self.UpdateIncrement(self.colorMaxFS)
         
     def OnCancel(self, evt):
+        print "cancel"
+        self.zoomMinFS.SetValue(self.zoomMin)
+        self.zoomMaxFS.SetValue(self.zoomMax)
+        self.cropMinFS.SetValue(self.cropMin)
+        self.cropMaxFS.SetValue(self.cropMax)
+        self.colorMinFS.SetValue(self.colorMin)
+        self.colorMaxFS.SetValue(self.colorMax)
+        self.cancelling = True
         self.Show( False )
 
     def ApplyValues(self):
@@ -1038,7 +1104,15 @@
         else:
             colorMin = cropMin
             colorMax = cropMax
+      #  if self.cancelling == False:
         self.parent.SendValues(float(zoomMin), float(zoomMax), 
float(cropMin), float(cropMax), float(colorMin), float(colorMax))
+        
+        self.zoomMin = self.zoomMinFS.GetValue()
+        self.zoomMax = self.zoomMaxFS.GetValue()
+        self.cropMin = self.cropMinFS.GetValue()
+        self.cropMax = self.cropMaxFS.GetValue()
+        self.colorMin = self.colorMinFS.GetValue()
+        self.colorMax = self.colorMaxFS.GetValue()
 
     #who to send values to.  Should have SendValues function
     def SetParent(self,parent):
@@ -1046,11 +1120,19 @@
         self.group = parent.group
         self.SetTitle(parent.title)
         if (self.group == 0):
-            self.colorMinFS.Show(True)
-            self.colorMaxFS.Show(True)
+          self.colorText.Show(True)
+          self.colorMinFS.Show(True)
+          self.colorMaxFS.Show(True)
         else:
-            self.colorMinFS.Show(False)
-            self.colorMaxFS.Show(False)
+          self.colorText.Show(False)
+          self.colorMinFS.Show(False)
+          self.colorMaxFS.Show(False)
+        self.vs.Layout()
+        
+        self.panel.SetSizerAndFit(self.vs)
+
+        self.SetSizerAndFit(self.vs3)
+        self.SetAutoLayout(True)
         
 
     def SendValues(self, zoomMin, zoomMax, cropMin, cropMax, colorMin, 
colorMax):

Modified: trunk/scenes/csafe/python/SceneMenus.py
==============================================================================
--- trunk/scenes/csafe/python/SceneMenus.py     (original)
+++ trunk/scenes/csafe/python/SceneMenus.py     Mon Apr 13 09:30:55 2009
@@ -710,7 +710,7 @@
        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
 
        hSizer2 = wx.BoxSizer(wx.HORIZONTAL)
-       text2 = wx.StaticText(panel,-1,"Index in NRRD: ")
+       self.text2 = text2 = wx.StaticText(panel,-1,"Index in NRRD: ")
        self.indexSP = wx.SpinCtrl(panel, -1, "", (30,50))
        self.indexSP.SetRange(0, 100)
        self.indexSP.SetValue(0)
@@ -747,11 +747,11 @@
 
        
         
-       panel.SetSizer(sizer)
+       panel.SetSizerAndFit(sizer)
 
-       selfSizer = wx.BoxSizer()
+       self.selfSizer = selfSizer = wx.BoxSizer()
        selfSizer.Add(panel, 1, wx.EXPAND)
-       self.SetSizer(selfSizer)
+       self.SetSizerAndFit(self.selfSizer)
        self.SetAutoLayout(True)
 
        self.Bind(wx.EVT_BUTTON, self.OnClickOK, self.okButton)
@@ -813,6 +813,14 @@
 
     def EvtChoice(self, e):
         self.group = e.GetSelection()
+        if self.group == 0:
+           self.text2.Show(True)
+           self.indexSP.Show(True)
+        else:
+           self.text2.Show(False)
+           self.indexSP.Show(False)
+         
+        self.SetSizerAndFit(self.selfSizer)
           
     def OnCloseMe(self, evt):
         self.Close(True)


  • [Manta] r2401 - in trunk: Model/Readers SwigInterface scenes/csafe/python, brownlee, 04/13/2009

Archive powered by MHonArc 2.6.16.

Top of page