[GRASS-SVN] r32237 - in grass/trunk/gui/wxpython: gui_modules nviz
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Jul 23 18:27:19 EDT 2008
Author: martinl
Date: 2008-07-23 18:27:19 -0400 (Wed, 23 Jul 2008)
New Revision: 32237
Modified:
grass/trunk/gui/wxpython/gui_modules/goutput.py
grass/trunk/gui/wxpython/gui_modules/nviz.py
grass/trunk/gui/wxpython/nviz/init.cpp
grass/trunk/gui/wxpython/nviz/nviz.h
grass/trunk/gui/wxpython/nviz/nviz.i
Log:
nviz2/wxGUI: nviz module log improved
Modified: grass/trunk/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/goutput.py 2008-07-23 21:28:04 UTC (rev 32236)
+++ grass/trunk/gui/wxpython/gui_modules/goutput.py 2008-07-23 22:27:19 UTC (rev 32237)
@@ -372,7 +372,7 @@
self.gmstc.StartStyling(p1, 0xff)
self.gmstc.SetStyling(p2 - p1 + 1, self.gmstc.StyleOutput)
-class GMStderr:
+class GMStderr(object):
"""GMConsole standard error output
Based on FrameOutErr.py
Modified: grass/trunk/gui/wxpython/gui_modules/nviz.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz.py 2008-07-23 21:28:04 UTC (rev 32236)
+++ grass/trunk/gui/wxpython/gui_modules/nviz.py 2008-07-23 22:27:19 UTC (rev 32237)
@@ -94,7 +94,7 @@
#
# create nviz instance
#
- self.nvizClass = wxnviz.Nviz()
+ self.nvizClass = wxnviz.Nviz(sys.stderr)
#
# set current display
@@ -349,14 +349,12 @@
if type == 'raster':
self.LoadRaster(item)
except gcmd.NvizError, e:
- print >> sys.stderr, "Nviz: %s" % (self.nvizClass.GetErrorMsg())
print >> sys.stderr, "Nviz: " + e.message
try:
if type == 'vector':
self.LoadVector(item)
except gcmd.NvizError, e:
- print >> sys.stderr, "Nviz: %s" % (self.nvizClass.GetErrorMsg())
print >> sys.stderr, "Nviz: " + e.message
stop = time.time()
Modified: grass/trunk/gui/wxpython/nviz/init.cpp
===================================================================
--- grass/trunk/gui/wxpython/nviz/init.cpp 2008-07-23 21:28:04 UTC (rev 32236)
+++ grass/trunk/gui/wxpython/nviz/init.cpp 2008-07-23 22:27:19 UTC (rev 32237)
@@ -20,16 +20,16 @@
static void swap_gl();
static int print_error(const char *, const int);
-static std::string *error;
+static PyObject *logStream;
/*!
\brief Initialize Nviz class instance
*/
-Nviz::Nviz()
+Nviz::Nviz(PyObject *log)
{
G_gisinit(""); /* GRASS functions */
- error = new std::string();
+ logStream = log;
G_set_error_routine(&print_error);
G_set_verbose(0); // TODO: read progress info
@@ -57,7 +57,7 @@
data = NULL;
glCanvas = NULL;
- delete error;
+ logStream = NULL;
}
/*!
@@ -135,23 +135,20 @@
return;
}
-std::string Nviz::GetErrorMsg()
-{
- if (error) {
- std::string retStr(*error);
- error->clear();
- return retStr;
- }
-
- return std::string();
-}
-
int print_error(const char *msg, const int type)
{
- if (error) {
- error->append(msg);
- error->append("\n");
+ char *fmsg;
+
+ if (logStream) {
+ fmsg = (char *) G_malloc (strlen(msg) + 6);
+ sprintf (fmsg, "Nviz: %s", msg);
+
+ PyFile_WriteString(fmsg, logStream);
+ G_free((void *) fmsg);
}
+ else {
+ fprintf(stderr, "Nviz: %s\n", msg);
+ }
return 0;
}
Modified: grass/trunk/gui/wxpython/nviz/nviz.h
===================================================================
--- grass/trunk/gui/wxpython/nviz/nviz.h 2008-07-23 21:28:04 UTC (rev 32236)
+++ grass/trunk/gui/wxpython/nviz/nviz.h 2008-07-23 22:27:19 UTC (rev 32237)
@@ -1,7 +1,6 @@
#ifndef WXNVIZ_H
#define WXNVIZ_H
-#include <string>
#include <vector>
extern "C" {
@@ -25,6 +24,8 @@
#include <wx/glcanvas.h>
+#include <Python.h>
+
class Nviz
{
private:
@@ -37,13 +38,11 @@
public:
/* constructor */
- Nviz();
+ Nviz(PyObject *);
/* destructor */
~Nviz();
- std::string GetErrorMsg();
-
/* change_view.cpp */
int ResizeWindow(int, int);
std::vector<double> SetViewDefault();
Modified: grass/trunk/gui/wxpython/nviz/nviz.i
===================================================================
--- grass/trunk/gui/wxpython/nviz/nviz.i 2008-07-23 21:28:04 UTC (rev 32236)
+++ grass/trunk/gui/wxpython/nviz/nviz.i 2008-07-23 22:27:19 UTC (rev 32237)
@@ -17,6 +17,4 @@
%template(IntVecIntMap) map<int, vector<int> >;
}
-%include "std_string.i"
-
%include "nviz.h"
More information about the grass-commit
mailing list