SAGA API v9.10
Loading...
Searching...
No Matches
shapes_selection.cpp
Go to the documentation of this file.
1
3// //
4// SAGA //
5// //
6// System for Automated Geoscientific Analyses //
7// //
8// Application Programming Interface //
9// //
10// Library: SAGA_API //
11// //
12//-------------------------------------------------------//
13// //
14// shapes_selection.cpp //
15// //
16// Copyright (C) 2005 by Olaf Conrad //
17// //
18//-------------------------------------------------------//
19// //
20// This file is part of 'SAGA - System for Automated //
21// Geoscientific Analyses'. //
22// //
23// This library is free software; you can redistribute //
24// it and/or modify it under the terms of the GNU Lesser //
25// General Public License as published by the Free //
26// Software Foundation, either version 2.1 of the //
27// License, or (at your option) any later version. //
28// //
29// This library is distributed in the hope that it will //
30// be useful, but WITHOUT ANY WARRANTY; without even the //
31// implied warranty of MERCHANTABILITY or FITNESS FOR A //
32// PARTICULAR PURPOSE. See the GNU Lesser General Public //
33// License for more details. //
34// //
35// You should have received a copy of the GNU Lesser //
36// General Public License along with this program; if //
37// not, see <http://www.gnu.org/licenses/>. //
38// //
39//-------------------------------------------------------//
40// //
41// contact: Olaf Conrad //
42// Institute of Geography //
43// University of Goettingen //
44// Goldschmidtstr. 5 //
45// 37077 Goettingen //
46// Germany //
47// //
48// e-mail: oconrad@saga-gis.org //
49// //
51
52//---------------------------------------------------------
53#include "shapes.h"
54
55
57// //
58// //
59// //
61
62//---------------------------------------------------------
63bool CSG_Shapes::Select(sLong Index, bool bInvert)
64{
65 return( CSG_Table::Select(Index, bInvert) );
66}
67
68//---------------------------------------------------------
69bool CSG_Shapes::Select(CSG_Table_Record *pShape, bool bInvert)
70{
71 return( CSG_Table::Select(pShape, bInvert) );
72}
73
74//---------------------------------------------------------
75bool CSG_Shapes::Select(const TSG_Rect &Extent, bool bInvert)
76{
77 if( !bInvert )
78 {
80 }
81
82 for(sLong i=0; i<Get_Count(); i++)
83 {
84 if( Get_Shape(i)->Intersects(Extent) )
85 {
86 CSG_Table::Select(i, true);
87 }
88 }
89
90 return( Get_Selection_Count() > 0 );
91}
92
93//---------------------------------------------------------
94bool CSG_Shapes::Select(const TSG_Point &Point, bool bInvert)
95{
97 {
98 return( Select(CSG_Rect(Point, Point), bInvert) );
99 }
100
101 if( !bInvert )
102 {
104 }
105
106 for(sLong i=0; i<Get_Count(); i++)
107 {
108 if( ((CSG_Shape_Polygon *)Get_Shape(i))->Contains(Point) )
109 {
110 CSG_Table::Select(i, true);
111 }
112 }
113
114 return( Get_Selection_Count() > 0 );
115}
116
117//---------------------------------------------------------
119{
120 if( Get_Selection_Count() > 0 )
121 {
122 m_Extent_Selected = ((CSG_Shape *)Get_Selection(0))->Get_Extent();
123
124 for(sLong i=1; i<Get_Selection_Count(); i++)
125 {
127 }
128 }
129 else
130 {
131 m_Extent_Selected.Assign(0., 0., 0., 0.);
132 }
133
134 return( m_Extent_Selected );
135}
136
137
139// //
140// //
141// //
143
144//---------------------------------------------------------
signed long long sLong
Definition api_core.h:158
virtual const CSG_Rect & Get_Extent(void)
Definition shapes.h:810
virtual CSG_Shape * Get_Shape(const CSG_Point &Point, double Epsilon=0.)
Definition shapes.cpp:483
virtual TSG_Shape_Type Get_Type(void) const
Definition shapes.h:806
virtual const CSG_Rect & Get_Selection_Extent(void)
friend class CSG_Shape
Definition shapes.h:773
virtual bool Select(sLong Index, bool bInvert=false)
CSG_Rect m_Extent_Selected
Definition shapes.h:847
sLong Get_Count(void) const
Definition table.h:400
virtual bool Select(sLong Index, bool bInvert=false)
friend class CSG_Table_Record
Definition table.h:286
virtual CSG_Table_Record * Get_Selection(sLong Index=0) const
Definition table.h:430
sLong Get_Selection_Count(void) const
Definition table.h:428
struct SSG_Point TSG_Point
struct SSG_Rect TSG_Rect
@ SHAPE_TYPE_Polygon
Definition shapes.h:105