|
@@ -35,8 +35,7 @@ Nviz::Nviz(PyObject *log)
|
|
logStream = log;
|
|
logStream = log;
|
|
|
|
|
|
G_set_error_routine(&print_error);
|
|
G_set_error_routine(&print_error);
|
|
- // TODO
|
|
|
|
- // G_set_percent_routine(&print_percent);
|
|
|
|
|
|
+ G_set_percent_routine(&print_percent);
|
|
|
|
|
|
GS_libinit();
|
|
GS_libinit();
|
|
GVL_libinit();
|
|
GVL_libinit();
|
|
@@ -44,10 +43,7 @@ Nviz::Nviz(PyObject *log)
|
|
GS_set_swap_func(swap_gl);
|
|
GS_set_swap_func(swap_gl);
|
|
|
|
|
|
data = (nv_data*) G_malloc(sizeof (nv_data));
|
|
data = (nv_data*) G_malloc(sizeof (nv_data));
|
|
-
|
|
|
|
- /* GLCanvas */
|
|
|
|
- glCanvas = NULL;
|
|
|
|
-
|
|
|
|
|
|
+
|
|
G_debug(1, "Nviz::Nviz()");
|
|
G_debug(1, "Nviz::Nviz()");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -57,33 +53,15 @@ Nviz::Nviz(PyObject *log)
|
|
Nviz::~Nviz()
|
|
Nviz::~Nviz()
|
|
{
|
|
{
|
|
G_unset_error_routine();
|
|
G_unset_error_routine();
|
|
- // TODO
|
|
|
|
- // G_unset_percent_routine();
|
|
|
|
|
|
+ G_unset_percent_routine();
|
|
|
|
|
|
G_free((void *) data);
|
|
G_free((void *) data);
|
|
|
|
|
|
data = NULL;
|
|
data = NULL;
|
|
- glCanvas = NULL;
|
|
|
|
-
|
|
|
|
|
|
+
|
|
logStream = NULL;
|
|
logStream = NULL;
|
|
}
|
|
}
|
|
|
|
|
|
-/*!
|
|
|
|
- \brief Associate display with render window
|
|
|
|
-
|
|
|
|
- \return 1 on success
|
|
|
|
- \return 0 on failure
|
|
|
|
-*/
|
|
|
|
-int Nviz::SetDisplay(void *display)
|
|
|
|
-{
|
|
|
|
- glCanvas = (wxGLCanvas *) display;
|
|
|
|
- // glCanvas->SetCurrent();
|
|
|
|
-
|
|
|
|
- G_debug(1, "Nviz::SetDisplay()");
|
|
|
|
-
|
|
|
|
- return 1;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
void Nviz::InitView()
|
|
void Nviz::InitView()
|
|
{
|
|
{
|
|
/* initialize nviz data */
|
|
/* initialize nviz data */
|
|
@@ -125,18 +103,6 @@ void Nviz::SetBgColor(const char *color_str)
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
-int print_error(const char *msg, const int type)
|
|
|
|
-{
|
|
|
|
- if (logStream) {
|
|
|
|
- print_sentence(logStream, type, msg);
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- fprintf(stderr, "Nviz: %s\n", msg);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return 0;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
/*
|
|
/*
|
|
\brief Print one message, prefix inserted before each new line
|
|
\brief Print one message, prefix inserted before each new line
|
|
|
|
|
|
@@ -148,60 +114,92 @@ void print_sentence (PyObject *pyFd, const int type, const char *msg)
|
|
const char *start;
|
|
const char *start;
|
|
char* sentence;
|
|
char* sentence;
|
|
|
|
|
|
- switch ( type ) {
|
|
|
|
- case MSG:
|
|
|
|
- sprintf (prefix, "GRASS_INFO_MESSAGE(%d,%d): Nviz: ", getpid(), message_id);
|
|
|
|
- break;
|
|
|
|
- case WARN:
|
|
|
|
- sprintf (prefix, "GRASS_INFO_WARNING(%d,%d): Nviz: ", getpid(), message_id);
|
|
|
|
- break;
|
|
|
|
- case ERR:
|
|
|
|
- sprintf (prefix, "GRASS_INFO_ERROR(%d,%d): Nviz: ", getpid(), message_id);
|
|
|
|
- break;
|
|
|
|
|
|
+ switch (type) {
|
|
|
|
+ case MSG:
|
|
|
|
+ sprintf (prefix, "GRASS_INFO_MESSAGE(%d,%d): Nviz: ", getpid(), message_id);
|
|
|
|
+ break;
|
|
|
|
+ case WARN:
|
|
|
|
+ sprintf (prefix, "GRASS_INFO_WARNING(%d,%d): Nviz: ", getpid(), message_id);
|
|
|
|
+ break;
|
|
|
|
+ case ERR:
|
|
|
|
+ sprintf (prefix, "GRASS_INFO_ERROR(%d,%d): Nviz: ", getpid(), message_id);
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
|
|
|
|
start = msg;
|
|
start = msg;
|
|
-
|
|
|
|
|
|
+
|
|
PyFile_WriteString("\n", pyFd);
|
|
PyFile_WriteString("\n", pyFd);
|
|
|
|
|
|
- while ( *start != '\0' ) {
|
|
|
|
|
|
+ while (*start != '\0') {
|
|
const char *next = start;
|
|
const char *next = start;
|
|
-
|
|
|
|
|
|
+
|
|
PyFile_WriteString(prefix, pyFd);
|
|
PyFile_WriteString(prefix, pyFd);
|
|
-
|
|
|
|
|
|
+
|
|
while ( *next != '\0' ) {
|
|
while ( *next != '\0' ) {
|
|
next++;
|
|
next++;
|
|
-
|
|
|
|
|
|
+
|
|
if ( *next == '\n' ) {
|
|
if ( *next == '\n' ) {
|
|
next++;
|
|
next++;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- sentence = (char *) G_malloc ((next - start + 1) * sizeof (char));
|
|
|
|
|
|
+
|
|
|
|
+ sentence = (char *) G_malloc((next - start + 1) * sizeof (char));
|
|
strncpy(sentence, start, next - start + 1);
|
|
strncpy(sentence, start, next - start + 1);
|
|
sentence[next-start] = '\0';
|
|
sentence[next-start] = '\0';
|
|
-
|
|
|
|
|
|
+
|
|
PyFile_WriteString(sentence, pyFd);
|
|
PyFile_WriteString(sentence, pyFd);
|
|
G_free((void *)sentence);
|
|
G_free((void *)sentence);
|
|
-
|
|
|
|
|
|
+
|
|
PyFile_WriteString("\n", pyFd);
|
|
PyFile_WriteString("\n", pyFd);
|
|
start = next;
|
|
start = next;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
PyFile_WriteString("\n", pyFd);
|
|
PyFile_WriteString("\n", pyFd);
|
|
sprintf(prefix, "GRASS_INFO_END(%d,%d)\n", getpid(), message_id);
|
|
sprintf(prefix, "GRASS_INFO_END(%d,%d)\n", getpid(), message_id);
|
|
PyFile_WriteString(prefix, pyFd);
|
|
PyFile_WriteString(prefix, pyFd);
|
|
-
|
|
|
|
|
|
+
|
|
message_id++;
|
|
message_id++;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/*!
|
|
|
|
+ \brief Print error/warning/message
|
|
|
|
+
|
|
|
|
+ \param msg message buffer
|
|
|
|
+ \param type message type
|
|
|
|
+
|
|
|
|
+ \return 0
|
|
|
|
+*/
|
|
|
|
+int print_error(const char *msg, const int type)
|
|
|
|
+{
|
|
|
|
+ if (logStream) {
|
|
|
|
+ print_sentence(logStream, type, msg);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ fprintf(stderr, "Nviz: %s\n", msg);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*!
|
|
|
|
+ \brief Print percentage information
|
|
|
|
+
|
|
|
|
+ \param x value
|
|
|
|
+
|
|
|
|
+ \return 0
|
|
|
|
+*/
|
|
int print_percent(int x)
|
|
int print_percent(int x)
|
|
{
|
|
{
|
|
char msg[256];
|
|
char msg[256];
|
|
|
|
|
|
- sprintf(msg, "GRASS_INFO_PERCENT: %d\n", x);
|
|
|
|
- PyFile_WriteString(msg, logStream);
|
|
|
|
-
|
|
|
|
|
|
+ if (logStream) {
|
|
|
|
+ sprintf(msg, "GRASS_INFO_PERCENT: %d\n", x);
|
|
|
|
+ PyFile_WriteString(msg, logStream);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ fprintf(stderr, "GRASS_INFO_PERCENT: %d\n", x);
|
|
|
|
+ }
|
|
|
|
+
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|