[GRASS-SVN] r32090 - in grass/trunk/gui/wxpython: gui_modules nviz

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jul 14 03:41:52 EDT 2008


Author: martinl
Date: 2008-07-14 03:41:51 -0400 (Mon, 14 Jul 2008)
New Revision: 32090

Modified:
   grass/trunk/gui/wxpython/gui_modules/nviz.py
   grass/trunk/gui/wxpython/nviz/load.cpp
   grass/trunk/gui/wxpython/nviz/surface.cpp
   grass/trunk/gui/wxpython/nviz/vector.cpp
Log:
nviz2/wxGUI: more debug messages, default surface attribute fixes

Modified: grass/trunk/gui/wxpython/gui_modules/nviz.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz.py	2008-07-13 21:06:30 UTC (rev 32089)
+++ grass/trunk/gui/wxpython/gui_modules/nviz.py	2008-07-14 07:41:51 UTC (rev 32090)
@@ -91,11 +91,6 @@
         self.nvizClass.SetDisplay(self)
 
         #
-        # set default lighting model
-        #
-        self.nvizClass.SetLightsDefault()
-
-        #
         # initialize mouse position
         #
         self.lastX = self.x = 30
@@ -418,7 +413,17 @@
         # draw
         #
         for control, value in UserSettings.Get(group='nviz', key='surface', subkey='draw').iteritems():
-            self.update.append('surface:draw:%s' % control)
+            if control[:3] == 'res':
+                if 'surface:draw:%s' % 'resolution' not in self.update:
+                    self.update.append('surface:draw:%s' % 'resolution')
+                    data['draw']['resolution'] = { 'all' : False,
+                                                   control[4:] : value }
+                else:
+                    data['draw']['resolution'][control[4:]] = value
+                continue
+            else:
+                self.update.append('surface:draw:%s' % control)
+
             if control == 'wire-color':
                 value = str(value[0]) + ':' + str(value[1]) + ':' + str(value[2])
             elif control in ('mode', 'style', 'shading'):
@@ -619,9 +624,9 @@
         if 'surface:draw:wire-color' in self.update:
             color = data['draw']['wire-color']['value']
             if data['draw']['wire-color']['all']:
+                self.nvizClass.SetWireColor(-1, str(color))
+            else:
                 self.nvizClass.SetWireColor(id, str(color))
-            else:
-                self.nvizClass.SetWireColor(-1, str(color))
                 self.update.remove('surface:draw:wire-color')
         
         # position
@@ -696,8 +701,8 @@
         # settings page
         self.__createSettingsPage()
         self.page['settings'] = 3
-        self.pageUpdated = True
         self.UpdatePage('settings')
+        self.pageChanging = False
 
         mainSizer.Add(item=self.notebook, proportion=1,
                       flag=wx.EXPAND | wx.ALL, border=5)
@@ -1782,8 +1787,8 @@
             else:
                 value = self.FindWindowById(self.win['surface'][attrb]['const']).GetValue()
             map = False
-
-        if self.pageUpdated: # do not update when selection is changed
+        
+        if not self.pageChanging:
             self.mapWindow.update.append('surface:attribute:%s' % attrb)
             data = self.mapWindow.GetSelectedLayer(nviz=True)
             data['surface']['attribute'][attrb] = { 'map' : map,
@@ -1836,19 +1841,18 @@
 
         value, desc = self.mapWindow.GetSurfaceMode(mode, style, shade)
 
-        if self.pageUpdated:
-            self.mapWindow.update.append('surface:draw:mode')
-            data = self.mapWindow.GetSelectedLayer(nviz=True)
-            data['surface']['draw']['mode'] = { 'value' : value,
-                                                'all' : all,
-                                                'desc' : desc }
-
-            self.mapWindow.UpdateLayerProperties()
-
     def OnSurfaceMode(self, event):
         """Set draw mode"""
         self.SetSurfaceMode()
 
+        self.mapWindow.update.append('surface:draw:mode')
+        data = self.mapWindow.GetSelectedLayer(nviz=True)
+        data['surface']['draw']['mode'] = { 'value' : value,
+                                            'all' : all,
+                                            'desc' : desc }
+
+        self.mapWindow.UpdateLayerProperties()
+
         if apply and self.parent.autoRender.IsChecked():
             self.mapWindow.Refresh(False)
 
@@ -1866,17 +1870,16 @@
         """Set wire color"""
         value = str(color[0]) + ':' + str(color[1]) + ':' + str(color[2])
 
-        if self.pageUpdated:
-            self.mapWindow.update.append('surface:draw:wire-color')
-            data = self.mapWindow.GetSelectedLayer(nviz=True)
-            data['surface']['draw']['wire-color'] = { 'value' : value,
-                                                      'all' : all }
-            self.mapWindow.UpdateLayerProperties()
-
     def OnSurfaceWireColor(self, event):
         """Set wire color"""
         self.SetSurfaceWireColor(event.GetValue())
 
+        self.mapWindow.update.append('surface:draw:wire-color')
+        data = self.mapWindow.GetSelectedLayer(nviz=True)
+        data['surface']['draw']['wire-color'] = { 'value' : value,
+                                                  'all' : all }
+        self.mapWindow.UpdateLayerProperties()
+
         if self.parent.autoRender.IsChecked():
             self.mapWindow.Refresh(False)
 
@@ -1990,7 +1993,7 @@
     
     def UpdatePage(self, pageId):
         """Update dialog (selected page)"""
-        self.pageUpdated = False
+        self.pageChanging = True
         layer = self.mapWindow.GetSelectedLayer()
         data = self.mapWindow.GetSelectedLayer(nviz=True)
 
@@ -2017,7 +2020,7 @@
             self.notebook.GetPage(self.page['surface']).Enable(False)
             self.notebook.GetPage(self.page['vector']).Enable(True)
 
-        self.pageUpdated = True
+        self.pageChanging = False
         
     def UpdateSurfacePage(self, layer, data):
         #
@@ -2047,6 +2050,31 @@
         # draw
         #
         for control, dict in data['draw'].iteritems():
+            if control == 'resolution':
+                self.FindWindowById(self.win['surface']['draw']['res-coarse']).SetValue(dict['coarse'])
+                self.FindWindowById(self.win['surface']['draw']['res-fine']).SetValue(dict['fine'])
+                continue
+
+            if control == 'mode':
+                if dict['desc']['mode'] == 'coarse':
+                    self.FindWindowById(self.win['surface']['draw']['mode']).SetSelection(0)
+                elif dict['desc']['mode'] == 'fine':
+                    self.FindWindowById(self.win['surface']['draw']['mode']).SetSelection(1)
+                else: # both
+                    self.FindWindowById(self.win['surface']['draw']['mode']).SetSelection(2)
+                    
+                if dict['desc']['style'] == 'wire':
+                    self.FindWindowById(self.win['surface']['draw']['style']).SetSelection(0)
+                else: # surface
+                    self.FindWindowById(self.win['surface']['draw']['style']).SetSelection(1)
+
+                if dict['desc']['shading'] == 'flat':
+                    self.FindWindowById(self.win['surface']['draw']['shading']).SetSelection(0)
+                else: # gouraud
+                    self.FindWindowById(self.win['surface']['draw']['shading']).SetSelection(1)
+                
+                continue
+
             value = dict['value']
             win = self.FindWindowById(self.win['surface']['draw'][control])
             
@@ -2151,9 +2179,10 @@
             self.mapWindow.update.append('view')
 
             self.mapWindow.render = False
-        
-        if event.LeftUp():
+            self.mapWindow.Refresh(eraseBackground=False)
+
+        elif event.LeftUp():
             self.mapWindow.render = True
+            self.mapWindow.Refresh(eraseBackground=False)
         
-        self.mapWindow.Refresh(eraseBackground=False)
-        
+        event.Skip()

Modified: grass/trunk/gui/wxpython/nviz/load.cpp
===================================================================
--- grass/trunk/gui/wxpython/nviz/load.cpp	2008-07-13 21:06:30 UTC (rev 32089)
+++ grass/trunk/gui/wxpython/nviz/load.cpp	2008-07-14 07:41:51 UTC (rev 32090)
@@ -81,7 +81,7 @@
     /* focus on loaded data */
     Nviz_set_focus_map(MAP_OBJ_UNDEFINED, -1);
 
-    G_debug(1, "Nviz::LoadRaster(): name=%s", name);
+    G_debug(1, "Nviz::LoadRaster(): name=%s -> id=%d", name, id);
 
     return id;
 }
@@ -100,6 +100,8 @@
 	return 0;
     }
 
+    G_debug(1, "Nviz::UnloadSurface(): id=%d", id);
+
     if (GS_delete_surface(id) < 0)
       return 0;
 
@@ -138,6 +140,8 @@
 		     G_fully_qualified_name(name, mapset), 0.0,
 		     data);
 
+    G_debug(1, "Nviz::LoadVector(): name=%s -> id=%d", name, id);
+
     return id;
 }
   
@@ -155,6 +159,8 @@
 	return 0;
     }
 
+    G_debug(1, "Nviz::UnloadVector(): id=%d", id);
+
     if (GV_delete_vector(id) < 0)
       return 0;
 

Modified: grass/trunk/gui/wxpython/nviz/surface.cpp
===================================================================
--- grass/trunk/gui/wxpython/nviz/surface.cpp	2008-07-13 21:06:30 UTC (rev 32089)
+++ grass/trunk/gui/wxpython/nviz/surface.cpp	2008-07-14 07:41:51 UTC (rev 32090)
@@ -212,6 +212,9 @@
 	return 0;
     }
 
+    G_debug(1, "Nviz::UnsetSurfaceAttr(): id=%d, attr=%d",
+	    id, attr);
+    
     return Nviz_unset_attr(id, MAP_OBJ_SURF, attr);
 }
 
@@ -227,6 +230,10 @@
 */
 int Nviz::SetSurfaceRes(int id, int fine, int coarse)
 {
+    G_debug(1, "Nviz::SetSurfaceRes(): id=%d, fine=%d, coarse=%d",
+	    id, fine, coarse);
+
+
     if (id > 0) {
 	if (!GS_surf_exists(id)) {
 	    return 0;
@@ -265,6 +272,9 @@
 */
 int Nviz::SetSurfaceStyle(int id, int style)
 {
+    G_debug(1, "Nviz::SetSurfaceStyle(): id=%d, style=%d",
+	    id, style);
+
     if (id > 0) {
 	if (!GS_surf_exists(id)) {
 	    return 0;
@@ -298,6 +308,9 @@
 {
     int color;
 
+    G_debug(1, "Nviz::SetWireColor(): id=%d, color=%s",
+	    id, color_str);
+
     color = Nviz_color_from_str(color_str);
 
     if (id > 0) {
@@ -339,6 +352,10 @@
     
     GS_get_trans(id, &x, &y, &z);
     
+    G_debug(1, "Nviz::GetSurfacePosition(): id=%d, x=%f, y=%f, z=%f",
+	    id, x, y, z);
+
+
     vals.push_back(double (x));
     vals.push_back(double (y));
     vals.push_back(double (z));
@@ -361,6 +378,9 @@
 	return 0;
     }
     
+    G_debug(1, "Nviz::SetSurfacePosition(): id=%d, x=%f, y=%f, z=%f",
+	    id, x, y, z);
+
     GS_set_trans(id, x, y, z);
 
     return 1;

Modified: grass/trunk/gui/wxpython/nviz/vector.cpp
===================================================================
--- grass/trunk/gui/wxpython/nviz/vector.cpp	2008-07-13 21:06:30 UTC (rev 32089)
+++ grass/trunk/gui/wxpython/nviz/vector.cpp	2008-07-14 07:41:51 UTC (rev 32090)
@@ -34,6 +34,10 @@
     if(!GV_vect_exists(id))
 	return 0;
 
+    G_debug(1, "Nviz::SetVectorMode(): id=%d, color=%s, width=%d, flat=%d",
+	    id, color_str, width, flat);
+
+
     color = Nviz_color_from_str(color_str);
 
     /* use memory by default */
@@ -56,7 +60,10 @@
 {
     if(!GV_vect_exists(id))
 	return 0;
-    
+
+    G_debug(1, "Nviz::SetVectorHeight(): id=%d, height=%f",
+	    id, height);
+
     GV_set_trans(id, 0.0, 0.0, height);
 
     return 1;



More information about the grass-commit mailing list