~ubuntu-branches/ubuntu/precise/grass/precise

« back to all changes in this revision

Viewing changes to imagery/i.ortho.photo/i.photo.2target/view.c

  • Committer: Bazaar Package Importer
  • Author(s): Francesco Paolo Lovergine
  • Date: 2011-04-13 17:08:41 UTC
  • mfrom: (8.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20110413170841-ss1t9bic0d0uq0gz
Tags: 6.4.1-1
* New upstream version.
* Now build-dep on libjpeg-dev and current libreadline6-dev.
* Removed patch swig: obsolete.
* Policy bumped to 3.9.2, without changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <string.h>
 
2
#include <grass/raster.h>
 
3
#include "globals.h"
 
4
#include "local_proto.h"
 
5
 
 
6
int Configure_view(View * view, char *name, char *mapset, double ns_res, double ew_res  /* original map resolution */
 
7
    )
 
8
{
 
9
    Erase_view(view);
 
10
    view->cell.configured = 0;
 
11
 
 
12
    /* copy the cell name into the view */
 
13
    strcpy(view->cell.name, name);
 
14
    strcpy(view->cell.mapset, mapset);
 
15
 
 
16
    /* determine the map edges */
 
17
    view->cell.left = view->left + (view->ncols - view->cell.head.cols) / 2;
 
18
    view->cell.right = view->cell.left + view->cell.head.cols - 1;
 
19
    view->cell.top = view->top + (view->nrows - view->cell.head.rows) / 2;
 
20
    view->cell.bottom = view->cell.top + view->cell.head.rows - 1;
 
21
 
 
22
    /* remember original resolutions */
 
23
    view->cell.ns_res = ns_res;
 
24
    view->cell.ew_res = ew_res;
 
25
 
 
26
    view->cell.configured = 1;
 
27
 
 
28
    return 0;
 
29
}
 
30
 
 
31
int In_view(View * view, int x, int y)
 
32
{
 
33
    return (x >= view->left && x <= view->right && y >= view->top &&
 
34
            y <= view->bottom);
 
35
}
 
36
 
 
37
int Erase_view(View * view)
 
38
{
 
39
    R_standard_color(BLACK);
 
40
    R_box_abs(view->left, view->top, view->right, view->bottom);
 
41
 
 
42
    return 0;
 
43
}
 
44
 
 
45
double magnification(View * view)
 
46
{
 
47
    if (!view->cell.configured)
 
48
        return ((double)0.0);
 
49
    return (view->cell.ew_res / view->cell.head.ew_res);
 
50
}