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

« back to all changes in this revision

Viewing changes to gui/wxpython/nviz/vector.cpp

  • 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
 
/**
2
 
   \file nviz/vector.cpp
3
 
 
4
 
   \brief wxNviz extension (3D view mode) - vector attributes
5
 
   
6
 
   This program is free software under the GNU General Public
7
 
   License (>=v2). Read the file COPYING that comes with GRASS
8
 
   for details.
9
 
   
10
 
   (C) 2008-2009 by Martin Landa, and the GRASS development team
11
 
   
12
 
   \author Martin Landa <landa.martin gmail.com> (Google SoC 2008)
13
 
*/
14
 
 
15
 
#include "nviz.h"
16
 
 
17
 
/**
18
 
   \brief Set mode of vector line overlay
19
 
 
20
 
   \param id vector id
21
 
   \param color_str color string
22
 
   \param width line width
23
 
   \param flat display flat or on surface
24
 
 
25
 
   \return -1 vector set not found
26
 
   \return -2 on failure
27
 
   \return 1 on success
28
 
*/
29
 
int Nviz::SetVectorLineMode(int id, const char *color_str,
30
 
                            int width, int flat)
31
 
{
32
 
    int color;
33
 
 
34
 
    if(!GV_vect_exists(id))
35
 
        return -1;
36
 
 
37
 
    G_debug(1, "Nviz::SetVectorMode(): id=%d, color=%s, width=%d, flat=%d",
38
 
            id, color_str, width, flat);
39
 
 
40
 
 
41
 
    color = Nviz_color_from_str(color_str);
42
 
 
43
 
    /* use memory by default */
44
 
    if (GV_set_vectmode(id, 1, color, width, flat) < 0)
45
 
        return -2;
46
 
    
47
 
    return 1;
48
 
}
49
 
 
50
 
/**
51
 
  \brief Set vector height above surface (lines)
52
 
 
53
 
  \param id vector set id
54
 
  \param height
55
 
 
56
 
  \return -1 vector set not found
57
 
  \return 1 on success
58
 
*/
59
 
int Nviz::SetVectorLineHeight(int id, float height)
60
 
{
61
 
    if(!GV_vect_exists(id))
62
 
        return -1;
63
 
 
64
 
    G_debug(1, "Nviz::SetVectorLineHeight(): id=%d, height=%f",
65
 
            id, height);
66
 
 
67
 
    GV_set_trans(id, 0.0, 0.0, height);
68
 
 
69
 
    return 1;
70
 
}
71
 
 
72
 
/**
73
 
   \brief Set reference surface of vector set (lines)
74
 
 
75
 
   \param id vector set id
76
 
   \param surf_id surface id
77
 
 
78
 
   \return 1 on success
79
 
   \return -1 vector set not found
80
 
   \return -2 surface not found
81
 
   \return -3 on failure
82
 
*/
83
 
int Nviz::SetVectorLineSurface(int id, int surf_id)
84
 
{
85
 
    if (!GV_vect_exists(id))
86
 
        return -1;
87
 
    
88
 
    if (!GS_surf_exists(surf_id))
89
 
        return -2;
90
 
 
91
 
    if (GV_select_surf(id, surf_id) < 0)
92
 
        return -3;
93
 
 
94
 
    return 1;
95
 
}
96
 
 
97
 
/**
98
 
   \brief Set mode of vector point overlay
99
 
 
100
 
   \param id vector id
101
 
   \param color_str color string
102
 
   \param width line width
103
 
   \param flat
104
 
 
105
 
   \return -1 vector set not found
106
 
*/
107
 
int Nviz::SetVectorPointMode(int id, const char *color_str,
108
 
                             int width, float size, int marker)
109
 
{
110
 
    int color;
111
 
 
112
 
    if(!GP_site_exists(id))
113
 
        return -1;
114
 
 
115
 
    G_debug(1, "Nviz::SetVectorPointMode(): id=%d, color=%s, "
116
 
            "width=%d, size=%f, marker=%d",
117
 
            id, color_str, width, size, marker);
118
 
 
119
 
 
120
 
    color = Nviz_color_from_str(color_str);
121
 
 
122
 
    if (GP_set_sitemode(id, ST_ATT_NONE,
123
 
                        color, width, size, marker) < 0)
124
 
        return -2;
125
 
    
126
 
    return 1;
127
 
}
128
 
 
129
 
/**
130
 
  \brief Set vector height above surface (points)
131
 
 
132
 
  \param id vector set id
133
 
  \param height
134
 
 
135
 
  \return -1 vector set not found
136
 
  \return 1 on success
137
 
*/
138
 
int Nviz::SetVectorPointHeight(int id, float height)
139
 
{
140
 
    if(!GP_site_exists(id))
141
 
        return -1;
142
 
 
143
 
    G_debug(1, "Nviz::SetVectorPointHeight(): id=%d, height=%f",
144
 
            id, height);
145
 
 
146
 
    GP_set_trans(id, 0.0, 0.0, height);
147
 
 
148
 
    return 1;
149
 
}
150
 
 
151
 
/**
152
 
   \brief Set reference surface of vector set (points)
153
 
 
154
 
   \param id vector set id
155
 
   \param surf_id surface id
156
 
 
157
 
   \return 1 on success
158
 
   \return -1 vector set not found
159
 
   \return -2 surface not found
160
 
   \return -3 on failure
161
 
*/
162
 
int Nviz::SetVectorPointSurface(int id, int surf_id)
163
 
{
164
 
    if (!GP_site_exists(id))
165
 
        return -1;
166
 
    
167
 
    if (!GS_surf_exists(surf_id))
168
 
        return -2;
169
 
 
170
 
    if (GP_select_surf(id, surf_id) < 0)
171
 
        return -3;
172
 
 
173
 
    return 1;
174
 
}