Loading...
Searching...
No Matches
LocationWindowCommonExample.m
Go to the documentation of this file.
2#import <NCLocationWindow.h>
3#import <NCPoint.h>
4
11@implementation LocationWindowCommonExample {
12 NCLocationWindow *_locationWindow;
13}
14
15- (instancetype)init {
16 self = [super init];
17 if (self) {
19 }
20 return self;
21}
22
27 NSLog(@"=== LocationWindowCommon Methods ===");
28
29 [self demonstrateSetSublocationId];
30 [self demonstrateCoordinateConversion];
31 [self demonstrateMapFeatureSelection];
32 [self demonstrateZoomProperties];
33}
34
38- (void)demonstrateSetSublocationId {
39 NSLog(@"--- setSublocationId Method ---");
40
41 if (_locationWindow == nil) {
42 NSLog(@"LocationWindow not available yet");
43 return;
44 }
45
46 // [objc_LocationWindow_setSublocationId]
47 // Set sublocation ID to switch between floors
48 [_locationWindow setSublocationId:1];
49 NSLog(@"Set sublocation ID to 1 (first floor)");
50 // [objc_LocationWindow_setSublocationId]
51
52 // [objc_LocationWindow_setSublocationId_2]
53 // Set sublocation ID to another floor
54 [_locationWindow setSublocationId:2];
55 NSLog(@"Set sublocation ID to 2 (second floor)");
56 // [objc_LocationWindow_setSublocationId_2]
57
58 // [objc_LocationWindow_setSublocationId_3]
59 // Set sublocation ID to ground floor
60 [_locationWindow setSublocationId:0];
61 NSLog(@"Set sublocation ID to 0 (ground floor)");
62 // [objc_LocationWindow_setSublocationId_3]
63
64 // Test with different sublocation IDs
65 NSArray<NSNumber *> *sublocationIds = @[@1, @2, @3, @0, @5];
66 for (NSNumber *idNumber in sublocationIds) {
67 [_locationWindow setSublocationId:idNumber.intValue];
68 NSLog(@"Switched to sublocation ID: %d", idNumber.intValue);
69 }
70}
71
75- (void)demonstrateCoordinateConversion {
76 NSLog(@"--- Coordinate Conversion Methods ---");
77
78 if (_locationWindow == nil) {
79 NSLog(@"LocationWindow not available yet");
80 return;
81 }
82
83 // [objc_LocationWindow_screenPositionToMeters]
84 // Convert screen position to meters
85 NCPoint *screenPoint = [[NCPoint alloc] initWithX:100.0 y:200.0];
86 NCPoint *metersPoint = [_locationWindow screenPositionToMeters:screenPoint];
87 NSLog(@"Screen position (%.1f, %.1f) converted to meters: (%.1f, %.1f)",
88 screenPoint.x, screenPoint.y, metersPoint.x, metersPoint.y);
89 // [objc_LocationWindow_screenPositionToMeters]
90
91 // [objc_LocationWindow_screenPositionToMeters_2]
92 // Convert another screen position to meters
93 NCPoint *screenPoint2 = [[NCPoint alloc] initWithX:500.0 y:300.0];
94 NCPoint *metersPoint2 = [_locationWindow screenPositionToMeters:screenPoint2];
95 NSLog(@"Screen position (%.1f, %.1f) converted to meters: (%.1f, %.1f)",
96 screenPoint2.x, screenPoint2.y, metersPoint2.x, metersPoint2.y);
97 // [objc_LocationWindow_screenPositionToMeters_2]
98
99 // [objc_LocationWindow_metersToScreenPosition]
100 // Convert meters to screen position with clipping
101 NCPoint *metersPoint3 = [[NCPoint alloc] initWithX:50.0 y:75.0];
102 NCPoint *screenPoint3 = [_locationWindow metersToScreenPosition:metersPoint3 clipToViewport:YES];
103 NSLog(@"Meters position (%.1f, %.1f) converted to screen with clipping: (%.1f, %.1f)",
104 metersPoint3.x, metersPoint3.y, screenPoint3.x, screenPoint3.y);
105 // [objc_LocationWindow_metersToScreenPosition]
106
107 // [objc_LocationWindow_metersToScreenPosition_2]
108 // Convert meters to screen position without clipping
109 NCPoint *metersPoint4 = [[NCPoint alloc] initWithX:150.0 y:200.0];
110 NCPoint *screenPoint4 = [_locationWindow metersToScreenPosition:metersPoint4 clipToViewport:NO];
111 NSLog(@"Meters position (%.1f, %.1f) converted to screen without clipping: (%.1f, %.1f)",
112 metersPoint4.x, metersPoint4.y, screenPoint4.x, screenPoint4.y);
113 // [objc_LocationWindow_metersToScreenPosition_2]
114
115 // Test coordinate conversion with different values
116 NSArray<NCPoint *> *testScreenPoints = @[
117 [[NCPoint alloc] initWithX:0.0 y:0.0],
118 [[NCPoint alloc] initWithX:250.0 y:250.0],
119 [[NCPoint alloc] initWithX:1000.0 y:600.0]
120 ];
121
122 for (int i = 0; i < testScreenPoints.count; i++) {
123 NCPoint *screenPoint = testScreenPoints[i];
124 NCPoint *metersPoint = [_locationWindow screenPositionToMeters:screenPoint];
125 NCPoint *backToScreen = [_locationWindow metersToScreenPosition:metersPoint clipToViewport:NO];
126 NSLog(@"Test %d: Screen (%.1f, %.1f) -> Meters (%.1f, %.1f) -> Screen (%.1f, %.1f)",
127 i, screenPoint.x, screenPoint.y,
128 metersPoint.x, metersPoint.y,
129 backToScreen.x, backToScreen.y);
130 }
131}
132
136- (void)demonstrateMapFeatureSelection {
137 NSLog(@"--- Map Feature Selection Methods ---");
138
139 if (_locationWindow == nil) {
140 NSLog(@"LocationWindow not available yet");
141 return;
142 }
143
144 // [objc_LocationWindow_selectMapFeature]
145 // Select map feature by ID
146 NSString *featureId = "room_101";
147 BOOL selected = [_locationWindow selectMapFeature:featureId];
148 NSLog(@"Selected map feature %@: %@", featureId, selected ? @"YES" : @"NO");
149 // [objc_LocationWindow_selectMapFeature]
150
151 // [objc_LocationWindow_selectMapFeature_2]
152 // Select another map feature
153 NSString *featureId2 = "office_205";
154 BOOL selected2 = [_locationWindow selectMapFeature:featureId2];
155 NSLog(@"Selected map feature %@: %@", featureId2, selected2 ? @"YES" : @"NO");
156 // [objc_LocationWindow_selectMapFeature_2]
157
158 // [objc_LocationWindow_getSelectedMapFeatures]
159 // Get list of selected map features
160 NSArray<NSString *> *selectedFeatures = [_locationWindow selectedMapFeatures];
161 NSLog(@"Currently selected map features: %lu features", (unsigned long)selectedFeatures.count);
162 for (NSString *feature in selectedFeatures) {
163 NSLog(@" - %@", feature);
164 }
165 // [objc_LocationWindow_getSelectedMapFeatures]
166
167 // [objc_LocationWindow_deselectMapFeature]
168 // Deselect specific map feature
169 BOOL deselected = [_locationWindow deselectMapFeature:featureId];
170 NSLog(@"Deselected map feature %@: %@", featureId, deselected ? @"YES" : @"NO");
171 // [objc_LocationWindow_deselectMapFeature]
172
173 // [objc_LocationWindow_deselectMapFeature_2]
174 // Deselect another map feature
175 BOOL deselected2 = [_locationWindow deselectMapFeature:featureId2];
176 NSLog(@"Deselected map feature %@: %@", featureId2, deselected2 ? @"YES" : @"NO");
177 // [objc_LocationWindow_deselectMapFeature_2]
178
179 // [objc_LocationWindow_deselectAllMapFeatures]
180 // Deselect all map features
181 [_locationWindow deselectAllMapFeatures];
182 NSLog(@"Deselected all map features");
183 // [objc_LocationWindow_deselectAllMapFeatures]
184
185 // [objc_LocationWindow_getSelectedMapFeatures_2]
186 // Verify all features are deselected
187 NSArray<NSString *> *remainingFeatures = [_locationWindow selectedMapFeatures];
188 NSLog(@"Remaining selected features after deselect all: %lu features", (unsigned long)remainingFeatures.count);
189 // [objc_LocationWindow_getSelectedMapFeatures_2]
190
191 // Test multiple feature selection and deselection
192 NSArray<NSString *> *testFeatureIds = @[@"room_101", @"office_205", @"meeting_room_301", @"cafe_401"];
193
194 // Select multiple features
195 for (NSString *featureId in testFeatureIds) {
196 BOOL success = [_locationWindow selectMapFeature:featureId];
197 NSLog(@"Selected feature %@: %@", featureId, success ? @"YES" : @"NO");
198 }
199
200 // Check selected features
201 NSArray<NSString *> *allSelected = [_locationWindow selectedMapFeatures];
202 NSLog(@"All selected features: %lu features", (unsigned long)allSelected.count);
203
204 // Deselect all at once
205 [_locationWindow deselectAllMapFeatures];
206 NSLog(@"Deselected all features at once");
207}
208
212- (void)demonstrateZoomProperties {
213 NSLog(@"--- Zoom Properties ---");
214
215 if (_locationWindow == nil) {
216 NSLog(@"LocationWindow not available yet");
217 return;
218 }
219
220 // [objc_LocationWindow_getZoomFactor]
221 // Get current zoom factor
222 double currentZoom = [_locationWindow zoomFactor];
223 NSLog(@"Current zoom factor: %.1f", currentZoom);
224 // [objc_LocationWindow_getZoomFactor]
225
226 // [objc_LocationWindow_setZoomFactor]
227 // Set zoom factor
228 [_locationWindow setZoomFactor:150.0];
229 NSLog(@"Set zoom factor to 150.0");
230 // [objc_LocationWindow_setZoomFactor]
231
232 // [objc_LocationWindow_getMinZoomFactor]
233 // Get minimum zoom factor
234 double minZoomFactor = [_locationWindow minZoomFactor];
235 NSLog(@"Minimum zoom factor: %.1f", minZoomFactor);
236 // [objc_LocationWindow_getMinZoomFactor]
237
238 // [objc_LocationWindow_setMinZoomFactor]
239 // Set minimum zoom factor
240 [_locationWindow setMinZoomFactor:50.0];
241 NSLog(@"Set minimum zoom factor to 50.0");
242 // [objc_LocationWindow_setMinZoomFactor]
243
244 // [objc_LocationWindow_getMaxZoomFactor]
245 // Get maximum zoom factor
246 double maxZoomFactor = [_locationWindow maxZoomFactor];
247 NSLog(@"Maximum zoom factor: %.1f", maxZoomFactor);
248 // [objc_LocationWindow_getMaxZoomFactor]
249
250 // [objc_LocationWindow_setMaxZoomFactor]
251 // Set maximum zoom factor
252 [_locationWindow setMaxZoomFactor:300.0];
253 NSLog(@"Set maximum zoom factor to 300.0");
254 // [objc_LocationWindow_setMaxZoomFactor]
255
256 // Test zoom factor changes
257 NSArray<NSNumber *> *testZoomFactors = @[@100.0, @125.0, @150.0, @200.0, @250.0];
258 for (NSNumber *zoom in testZoomFactors) {
259 [_locationWindow setZoomFactor:zoom.doubleValue];
260 NSLog(@"Changed zoom factor to: %.1f", [_locationWindow zoomFactor]);
261 }
262
263 // Test zoom limits
264 NSLog(@"Testing zoom limits...");
265 [_locationWindow setZoomFactor:[_locationWindow minZoomFactor]];
266 NSLog(@"Set to minimum zoom: %.1f", [_locationWindow zoomFactor]);
267
268 [_locationWindow setZoomFactor:[_locationWindow maxZoomFactor]];
269 NSLog(@"Set to maximum zoom: %.1f", [_locationWindow zoomFactor]);
270
271 // Reset to default
272 [_locationWindow setZoomFactor:100.0];
273 NSLog(@"Reset zoom factor to default: %.1f", [_locationWindow zoomFactor]);
274}
275
279- (void)runExample {
280 NSLog(@"=== LocationWindowCommon Example ===");
281
282 // Simulate LocationWindow initialization
283 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
284 // TODO: User will implement LocationWindow initialization here
285 // self->_locationWindow = [self getLocationWindow];
286
287 // Run demonstrations
288 [self demonstrateLocationWindowCommonMethods];
289
290 NSLog(@"=== Example completed ===");
291 });
292}
293
294@end
295
299int main(int argc, const char * argv[]) {
300 @autoreleasepool {
302 [example runExample];
303
304 // Keep the program running for a bit to see the output
305 [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:2.0]];
306 }
307 return 0;
308}