Loading...
Searching...
No Matches
LocationWindowInteractionExample.m
Go to the documentation of this file.
1#import <Foundation/Foundation.h>
2#import <NavigineSDK/NavigineSDK.h>
3
10@interface LocationWindowInteractionExample : NSObject
11
12@property (nonatomic, strong) NCLocationWindow *locationWindow;
13@property (nonatomic, strong) id<NCInputListener> inputListener;
14@property (nonatomic, strong) id<NCPickListener> pickListener;
15
16- (instancetype)init;
18- (void)cleanup;
19
20@end
21
22@implementation LocationWindowInteractionExample
23
24- (instancetype)init {
25 self = [super init];
26 if (self) {
28 }
29 return self;
30}
31
33 NSLog(@"=== LocationWindowInteraction Example ===");
34
35 [self demonstrateGestureProperties];
36 [self demonstratePickProperties];
37 [self demonstratePickMethods];
38 [self demonstrateInputListeners];
39 [self demonstratePickListeners];
40 [self cleanup];
41}
42
43- (void)demonstrateGestureProperties {
44 NSLog(@"--- Gesture Properties ---");
45
46 if (_locationWindow == nil) {
47 NSLog(@"LocationWindow not available yet");
48 return;
49 }
50
51 // [objc_LocationWindow_setStickToBorder]
52 // Set stick to border property
53 _locationWindow.stickToBorder = YES;
54 NSLog(@"Set stick to border to true");
55 // [objc_LocationWindow_setStickToBorder]
56
57 // [objc_LocationWindow_setRotateGestureEnabled]
58 // Set rotate gesture enabled
59 _locationWindow.rotateGestureEnabled = YES;
60 NSLog(@"Set rotate gesture enabled to true");
61 // [objc_LocationWindow_setRotateGestureEnabled]
62
63 // [objc_LocationWindow_setTiltGesturesEnabled]
64 // Set tilt gestures enabled
65 _locationWindow.tiltGesturesEnabled = YES;
66 NSLog(@"Set tilt gestures enabled to true");
67 // [objc_LocationWindow_setTiltGesturesEnabled]
68
69 // [objc_LocationWindow_setScrollGesturesEnabled]
70 // Set scroll gestures enabled
71 _locationWindow.scrollGesturesEnabled = YES;
72 NSLog(@"Set scroll gestures enabled to true");
73 // [objc_LocationWindow_setScrollGesturesEnabled]
74
75 // [objc_LocationWindow_setZoomGesturesEnabled]
76 // Set zoom gestures enabled
77 _locationWindow.zoomGesturesEnabled = YES;
78 NSLog(@"Set zoom gestures enabled to true");
79 // [objc_LocationWindow_setZoomGesturesEnabled]
80
81 // Test different gesture combinations
82 NSArray *gestureTests = @[
83 @[@YES, @YES, @YES, @YES, @YES],
84 @[@NO, @YES, @YES, @YES, @NO],
85 @[@YES, @NO, @YES, @NO, @YES],
86 @[@NO, @NO, @NO, @NO, @NO],
87 ];
88
89 for (int i = 0; i < gestureTests.count; i++) {
90 NSArray *test = gestureTests[i];
91 BOOL rotate = [test[0] boolValue];
92 BOOL tilt = [test[1] boolValue];
93 BOOL scroll = [test[2] boolValue];
94 BOOL zoom = [test[3] boolValue];
95 BOOL stick = [test[4] boolValue];
96
97 _locationWindow.rotateGestureEnabled = rotate;
98 _locationWindow.tiltGesturesEnabled = tilt;
99 _locationWindow.scrollGesturesEnabled = scroll;
100 _locationWindow.zoomGesturesEnabled = zoom;
101 _locationWindow.stickToBorder = stick;
102 NSLog(@"Gesture test %d: Rotate=%s, Tilt=%s, Scroll=%s, Zoom=%s, Stick=%s",
103 i, rotate ? "true" : "false", tilt ? "true" : "false",
104 scroll ? "true" : "false", zoom ? "true" : "false", stick ? "true" : "false");
105 }
106}
107
108- (void)demonstratePickProperties {
109 NSLog(@"--- Pick Properties ---");
110
111 if (_locationWindow == nil) {
112 NSLog(@"LocationWindow not available yet");
113 return;
114 }
115
116 // [objc_LocationWindow_setPickRadius]
117 // Set pick radius
118 _locationWindow.pickRadius = 10.0;
119 NSLog(@"Set pick radius to 10.0 pixels");
120 // [objc_LocationWindow_setPickRadius]
121
122 // Test different pick radius values
123 NSArray *pickRadiusTests = @[@5.0, @10.0, @20.0, @50.0, @100.0];
124
125 for (int i = 0; i < pickRadiusTests.count; i++) {
126 double radius = [pickRadiusTests[i] doubleValue];
127 _locationWindow.pickRadius = radius;
128 NSLog(@"Pick radius test %d: %.1f pixels", i, radius);
129 }
130}
131
132- (void)demonstratePickMethods {
133 NSLog(@"--- Pick Methods ---");
134
135 if (_locationWindow == nil) {
136 NSLog(@"LocationWindow not available yet");
137 return;
138 }
139
140 // [objc_LocationWindow_pickMapObjectAt]
141 // Pick map object at screen position
142 NCPoint *screenPoint = [[NCPoint alloc] initWithX:100.0 y:200.0];
143 [_locationWindow pickMapObjectAt:screenPoint];
144 NSLog(@"Picked map object at screen position (%.1f, %.1f)", screenPoint.x, screenPoint.y);
145 // [objc_LocationWindow_pickMapObjectAt]
146
147 // [objc_LocationWindow_pickMapFeatureAt]
148 // Pick map feature at screen position
149 NCPoint *featurePoint = [[NCPoint alloc] initWithX:150.0 y:250.0];
150 [_locationWindow pickMapFeatureAt:featurePoint];
151 NSLog(@"Picked map feature at screen position (%.1f, %.1f)", featurePoint.x, featurePoint.y);
152 // [objc_LocationWindow_pickMapFeatureAt]
153
154 // Test pick at different positions
155 NSArray *pickTests = @[
156 [[NCPoint alloc] initWithX:50.0 y:50.0],
157 [[NCPoint alloc] initWithX:200.0 y:300.0],
158 [[NCPoint alloc] initWithX:400.0 y:100.0],
159 [[NCPoint alloc] initWithX:300.0 y:400.0],
160 ];
161
162 for (int i = 0; i < pickTests.count; i++) {
163 NCPoint *point = pickTests[i];
164 [_locationWindow pickMapObjectAt:point];
165 [_locationWindow pickMapFeatureAt:point];
166 NSLog(@"Pick test %d: Object and feature at (%.1f, %.1f)", i, point.x, point.y);
167 }
168}
169
170- (void)demonstrateInputListeners {
171 NSLog(@"--- Input Listeners ---");
172
173 if (_locationWindow == nil) {
174 NSLog(@"LocationWindow not available yet");
175 return;
176 }
177
178 // [objc_LocationWindow_addInputListener]
179 // Add input listener
180 _inputListener = [[InputListenerImpl alloc] init];
181 [_locationWindow addInputListener:_inputListener];
182 NSLog(@"Added input listener");
183 // [objc_LocationWindow_addInputListener]
184
185 // [objc_LocationWindow_removeInputListener]
186 // Remove input listener
187 [_locationWindow removeInputListener:_inputListener];
188 _inputListener = nil;
189 NSLog(@"Removed input listener");
190 // [objc_LocationWindow_removeInputListener]
191
192 // Test multiple listeners
193 NSArray *listeners = @[
194 [[InputListenerImpl alloc] init],
195 [[InputListenerImpl alloc] init],
196 [[InputListenerImpl alloc] init],
197 ];
198
199 for (int i = 0; i < listeners.count; i++) {
200 [_locationWindow addInputListener:listeners[i]];
201 NSLog(@"Added input listener %d", i);
202 }
203
204 for (int i = 0; i < listeners.count; i++) {
205 [_locationWindow removeInputListener:listeners[i]];
206 NSLog(@"Removed input listener %d", i);
207 }
208}
209
210- (void)demonstratePickListeners {
211 NSLog(@"--- Pick Listeners ---");
212
213 if (_locationWindow == nil) {
214 NSLog(@"LocationWindow not available yet");
215 return;
216 }
217
218 // [objc_LocationWindow_addPickListener]
219 // Add pick listener
220 _pickListener = [[PickListenerImpl alloc] init];
221 [_locationWindow addPickListener:_pickListener];
222 NSLog(@"Added pick listener");
223 // [objc_LocationWindow_addPickListener]
224
225 // Test multiple pick listeners
226 NSArray *listeners = @[
227 [[PickListenerImpl alloc] init],
228 [[PickListenerImpl alloc] init],
229 [[PickListenerImpl alloc] init],
230 ];
231
232 for (int i = 0; i < listeners.count; i++) {
233 [_locationWindow addPickListener:listeners[i]];
234 NSLog(@"Added pick listener %d", i);
235 }
236
237 for (int i = 0; i < listeners.count; i++) {
238 // [objc_LocationWindow_removePickListener]
239 [_locationWindow removePickListener:listeners[i]];
240 NSLog(@"Removed pick listener %d", i);
241 // [objc_LocationWindow_removePickListener]
242 }
243}
244
245- (void)cleanup {
246 if (_inputListener != nil) {
247 [_locationWindow removeInputListener:_inputListener];
248 _inputListener = nil;
249 }
250 if (_pickListener != nil) {
251 [_locationWindow removePickListener:_pickListener];
252 _pickListener = nil;
253 }
254 NSLog(@"LocationWindowInteraction example cleanup completed");
255}
256
257@end
258
259// Input listener implementation
260@interface InputListenerImpl : NSObject <NCInputListener>
261@end
262
263@implementation InputListenerImpl
264
265// [objc_InputListener_onViewTap]
266- (void)onViewTapWithScreenPoint:(NCPoint *)screenPoint {
267 NSLog(@"View tapped at screen position (%.1f, %.1f)", screenPoint.x, screenPoint.y);
268}
269// [objc_InputListener_onViewTap]
270
271// [objc_InputListener_onViewDoubleTap]
272- (void)onViewDoubleTapWithScreenPoint:(NCPoint *)screenPoint {
273 NSLog(@"View double tapped at screen position (%.1f, %.1f)", screenPoint.x, screenPoint.y);
274}
275// [objc_InputListener_onViewDoubleTap]
276
277// [objc_InputListener_onViewLongTap]
278- (void)onViewLongTapWithScreenPoint:(NCPoint *)screenPoint {
279 NSLog(@"View long tapped at screen position (%.1f, %.1f)", screenPoint.x, screenPoint.y);
280}
281// [objc_InputListener_onViewLongTap]
282
283@end
284
285// Pick listener implementation
286@interface PickListenerImpl : NSObject <NCPickListener>
287@end
288
289@implementation PickListenerImpl
290
291// [objc_PickListener_onMapObjectPickComplete]
292- (void)onMapObjectPickCompleteWithMapObjectPickResult:(NCMapObjectPickResult *)mapObjectPickResult screenPosition:(NCPoint *)screenPosition {
293 if (mapObjectPickResult != nil) {
294 // [objc_MapObjectPickResult_getPoint]
295 NCLocationPoint *point = mapObjectPickResult.point;
296 NSLog(@"Map object picked at screen position (%.1f, %.1f)", screenPosition.x, screenPosition.y);
297 NSLog(@" Object location: (%.1f, %.1f)", point.x, point.y);
298 // [objc_MapObjectPickResult_getPoint]
299
300 // [objc_MapObjectPickResult_getMapObject]
301 NCMapObject *mapObject = mapObjectPickResult.mapObject;
302 NSLog(@" Object type: %@", NSStringFromClass([mapObject class]));
303 // [objc_MapObjectPickResult_getMapObject]
304 } else {
305 NSLog(@"No map object found at screen position (%.1f, %.1f)", screenPosition.x, screenPosition.y);
306 }
307}
308// [objc_PickListener_onMapObjectPickComplete]
309
310// [objc_PickListener_onMapFeaturePickComplete]
311- (void)onMapFeaturePickCompleteWithMapFeaturePickResult:(NSDictionary<NSString *, NSString *> *)mapFeaturePickResult screenPosition:(NCPoint *)screenPosition {
312 if (mapFeaturePickResult != nil) {
313 NSLog(@"Map feature picked at screen position (%.1f, %.1f)", screenPosition.x, screenPosition.y);
314 NSLog(@" Feature properties: %@", mapFeaturePickResult);
315 } else {
316 NSLog(@"No map feature found at screen position (%.1f, %.1f)", screenPosition.x, screenPosition.y);
317 }
318}
319// [objc_PickListener_onMapFeaturePickComplete]
320
321@end
322
323// Main function
324int main(int argc, const char * argv[]) {
325 @autoreleasepool {
327 }
328 return 0;
329}
330
331
332