~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to visualization/nviz/src/exag.c

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
/* update_sliders:
3
 
 ** updates the text fields when the sliders have changed
4
 
 ** and also updates the sliders if the text fields have changed
5
 
 */
6
 
 
7
 
 
8
 
#include <stdlib.h>
9
 
#include "interface.h"
10
 
 
11
 
#ifdef OLD
12
 
 
13
 
/* use own system of getting vals from sliders to make it easier to
14
 
   change the slider's range dynamically */
15
 
int
16
 
init_default_slider_vals1(Nv_data * dc, float *min, float *max, float *val)
17
 
{
18
 
    float longdim;
19
 
 
20
 
    GS_get_longdim(&longdim);
21
 
 
22
 
    min[MAIN_PSP] = 3;
23
 
    max[MAIN_PSP] = 120;
24
 
    val[MAIN_PSP] = UNIT_OF(120, 3, 40);
25
 
 
26
 
    min[CPL_TILT] = 0.0;
27
 
    max[CPL_TILT] = 360.;
28
 
    val[CPL_TILT] = 0.5;
29
 
 
30
 
    min[CPL_ROT] = 0.0;
31
 
    max[CPL_ROT] = 360.;
32
 
    val[CPL_ROT] = 0.5;
33
 
 
34
 
    val[VECT_ZEX] = 0.1;
35
 
    val[LITE_BGT] = 0.8;
36
 
    val[LITE_RED] = 1.0;
37
 
    val[LITE_GRN] = 1.0;
38
 
    val[LITE_BLU] = 1.0;
39
 
    val[LITE_AMB] = 0.3;
40
 
    val[LITE_HGT] = 0.8;
41
 
    val[LITE_SHN] = 0.8;
42
 
 
43
 
    max[COL_RED] = max[COL_GRN] = max[COL_BLU] = 255;
44
 
    val[COL_RED] = 0.3;
45
 
    val[COL_GRN] = 0.3;
46
 
    val[COL_BLU] = 0.3;
47
 
 
48
 
    max[ATTR_CON] = 255;
49
 
    val[ATTR_CON] = 0.0;
50
 
 
51
 
    max[SITE_SIZ] = longdim / 20.;
52
 
    val[SITE_SIZ] = 0.2;
53
 
}
54
 
#endif
55
 
 
56
 
int Nget_first_exag_cmd(Nv_data * data, Tcl_Interp * interp,    /* Current interpreter. */
57
 
                        int argc, char **argv)
58
 
{
59
 
    float exag, texag;
60
 
    int nsurfs, i, *surf_list;
61
 
    char buf[128];
62
 
 
63
 
    surf_list = GS_get_surf_list(&nsurfs);
64
 
 
65
 
    exag = 0.0;
66
 
    for (i = 0; i < nsurfs; i++) {
67
 
        if (GS_get_exag_guess(surf_list[i], &texag) > -1) {
68
 
            if (texag)
69
 
                exag = (texag > exag) ? texag : exag;
70
 
        }
71
 
    }
72
 
 
73
 
    if (exag == 0.0)
74
 
        exag = 1.0;
75
 
    sprintf(buf, "%f", exag);
76
 
 
77
 
    if (nsurfs)
78
 
        free(surf_list);
79
 
 
80
 
    Tcl_SetResult(interp, buf, TCL_VOLATILE);
81
 
    return TCL_OK;
82
 
 
83
 
}
84
 
 
85
 
/* after initial data has been loaded, & maybe again later */
86
 
int Nget_height_cmd(Nv_data * data, Tcl_Interp * interp,        /* Current interpreter. */
87
 
                    int argc, char **argv)
88
 
{
89
 
    float longdim, exag, texag, hmin, hmax;
90
 
    int nsurfs, i, *surf_list;
91
 
    char min[128];
92
 
    char max[128];
93
 
    char val[128];
94
 
    float fmin, fmax;
95
 
    char *list[4];
96
 
 
97
 
    surf_list = GS_get_surf_list(&nsurfs);
98
 
    if (nsurfs) {
99
 
        GS_get_longdim(&longdim);
100
 
        GS_get_zrange_nz(&hmin, &hmax);
101
 
 
102
 
        exag = 0.0;
103
 
        for (i = 0; i < nsurfs; i++) {
104
 
            if (GS_get_exag_guess(surf_list[i], &texag) > -1)
105
 
                if (texag)
106
 
                    exag = texag > exag ? texag : exag;
107
 
        }
108
 
        if (exag == 0.0)
109
 
            exag = 1.0;
110
 
 
111
 
        fmin = hmin - (2. * longdim / exag);
112
 
        fmax = hmin + (3 * longdim / exag);
113
 
    }
114
 
    else {
115
 
        fmax = 10000.0;
116
 
        fmin = 0.0;
117
 
    }
118
 
 
119
 
    /* The one decimal place of accuracy is necessary to force Tcl to */
120
 
    /* parse these values as floating point rather than integers.  This */
121
 
    /* avoids problems with integers which are too large to represent. */
122
 
    sprintf(min, "%.1f", fmin);
123
 
    sprintf(max, "%.1f", fmax);
124
 
    sprintf(val, "%.1f", fmin + (fmax - fmin) / 2.0);
125
 
 
126
 
    list[0] = val;
127
 
    list[1] = min;
128
 
    list[2] = max;
129
 
    list[3] = NULL;
130
 
    Tcl_SetResult(interp, Tcl_Merge(3, list), TCL_DYNAMIC);
131
 
 
132
 
    return TCL_OK;
133
 
 
134
 
}