~ubuntu-branches/ubuntu/wily/grass/wily

« back to all changes in this revision

Viewing changes to gui/wxpython/vdigit/select.cpp

Tags: 7.0.0~rc1+ds1-1~exp1
* New upstream release candidate.
* Repack upstream tarball, remove precompiled Python objects.
* Add upstream metadata.
* Update gbp.conf and Vcs-Git URL to use the experimental branch.
* Update watch file for GRASS 7.0.
* Drop build dependencies for Tcl/Tk, add build dependencies:
  python-numpy, libnetcdf-dev, netcdf-bin, libblas-dev, liblapack-dev
* Update Vcs-Browser URL to use cgit instead of gitweb.
* Update paths to use grass70.
* Add configure options: --with-netcdf, --with-blas, --with-lapack,
  remove --with-tcltk-includes.
* Update patches for GRASS 7.
* Update copyright file, changes:
  - Update copyright years
  - Group files by license
  - Remove unused license sections
* Add patches for various typos.
* Fix desktop file with patch instead of d/rules.
* Use minimal dh rules.
* Bump Standards-Version to 3.9.6, no changes.
* Use dpkg-maintscript-helper to replace directories with symlinks.
  (closes: #776349)
* Update my email to use @debian.org address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
   \file vdigit/select.cpp
3
 
 
4
 
   \brief wxvdigit - Select lines (by query)
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>
13
 
*/
14
 
 
15
 
extern "C" {
16
 
#include <grass/vedit.h>
17
 
}
18
 
#include "driver.h"
19
 
#include "digit.h"
20
 
 
21
 
/**
22
 
   \brief Select features by query (based on geometry)
23
 
 
24
 
   Currently supported:
25
 
    - QUERY_LENGTH, select all lines longer then threshold (or shorter if threshold is negative)
26
 
    - QUERY_DANGLE, select all dangles then threshold (or shorter if threshold is negative)
27
 
 
28
 
   \todo Rewrite dangle part to use Vector library functionality
29
 
   \todo 3D
30
 
 
31
 
   \param x1,y1,z1,x2,y2,z2 bounding box 
32
 
   \param query query (length, dangle, ...)
33
 
   \param thresh threshold value (< 0 for 'shorter', > 0 for 'longer')
34
 
   \param type feature type
35
 
   \param box query features in bounding box
36
 
 
37
 
   \return list of selected features
38
 
*/
39
 
 
40
 
std::vector<int> Digit::SelectLinesByQuery(double x1, double y1, double z1,
41
 
                                           double x2, double y2, double z2, bool box,
42
 
                                           int query, int type, double thresh)
43
 
{
44
 
    int layer;
45
 
    std::vector<int> ids;
46
 
    struct ilist *List;
47
 
    struct line_pnts *bbox;
48
 
 
49
 
    if (!display->mapInfo) {
50
 
        display->DisplayMsg();
51
 
        return ids;
52
 
    }
53
 
 
54
 
    layer = 1; // TODO
55
 
    bbox  = NULL;
56
 
 
57
 
    List = Vect_new_list();
58
 
 
59
 
    if (box) {
60
 
        bbox = Vect_new_line_struct();
61
 
        
62
 
        Vect_append_point(bbox, x1, y1, z1);
63
 
        Vect_append_point(bbox, x2, y1, z2);
64
 
        Vect_append_point(bbox, x2, y2, z1);
65
 
        Vect_append_point(bbox, x1, y2, z2);
66
 
        Vect_append_point(bbox, x1, y1, z1);
67
 
        
68
 
        Vect_select_lines_by_polygon (display->mapInfo, bbox, 0, NULL, type, List);
69
 
        if (List->n_values == 0) {
70
 
            return ids;
71
 
        }
72
 
    }
73
 
    
74
 
    G_debug(3, "wxDigit.SelectLinesByQuery(): lines=%d", List->n_values);
75
 
 
76
 
    Vedit_select_by_query(display->mapInfo,
77
 
                          type, layer, thresh, query,
78
 
                          List);
79
 
    
80
 
    ids = display->ListToVector(List); // TODO
81
 
 
82
 
    G_debug(3, "wxDigit.SelectLinesByQuery(): lines=%d", List->n_values);
83
 
 
84
 
    Vect_destroy_list(List);
85
 
    if (bbox) {
86
 
        Vect_destroy_line_struct(bbox);
87
 
    }
88
 
 
89
 
    return ids;
90
 
}