Explorar el Código

Re-instate G_set_window()

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@38024 15284696-431f-4ddb-bdfa-cd5b030d7da7
Glynn Clements hace 16 años
padre
commit
25761d39b2
Se han modificado 2 ficheros con 32 adiciones y 0 borrados
  1. 1 0
      include/gisdefs.h
  2. 31 0
      lib/gis/set_window.c

+ 1 - 0
include/gisdefs.h

@@ -536,6 +536,7 @@ void G_fseek(FILE *, off_t, int);
 
 /* set_window.c */
 void G_get_set_window(struct Cell_head *);
+int G_set_window(struct Cell_head *);
 
 /* short_way.c */
 void G_shortest_way(double *, double *);

+ 31 - 0
lib/gis/set_window.c

@@ -29,3 +29,34 @@ void G_get_set_window(struct Cell_head *window)
     G__init_window();
     G_copy(window, &G__.window, sizeof(*window));
 }
+
+/*!
+ * \brief Establishes 'window' as the current working window.
+ * 
+ * \param window window to become operative window
+ * 
+ * \return -1 on error
+ * \return  1 on success
+ */
+int G_set_window(struct Cell_head *window)
+{
+    const char *err;
+
+    /* adjust window, check for valid window */
+    /* adjust the real one, not a copy
+       G_copy (&twindow, window, sizeof(struct Cell_head));
+       window = &twindow;
+     */
+
+    if ((err = G_adjust_Cell_head(window, 0, 0))) {
+	G_warning("G_set_window(): %s", err);
+	return -1;
+    }
+
+    /* copy the window to the current window */
+    G_copy((char *)&G__.window, (char *)window, sizeof(*window));
+
+    G__.window_set = 1;
+
+    return 1;
+}