[ios, osx] Added wireframe debugging mask

Added an option to MGLMapDebugMaskOptions for the new wireframe debugging mode and UI in the demo applications for toggling it.
This commit is contained in:
Minh Nguyễn
2016-05-22 11:17:44 -07:00
committed by Bruno de Oliveira Abinader
parent 7143408f69
commit 2865e7d35c
9 changed files with 56 additions and 11 deletions

View File

@@ -28,6 +28,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CON
- Added `MGLCoordinateInCoordinateBounds()`, a function that tests whether or not a coordinate is in a given bounds. ([#5053](https://github.com/mapbox/mapbox-gl-native/pull/5053))
- An MGLAnnotationView can be repositioned in relation to the associated MGLAnnotation.coordinate by changing its `centerOffset` property. ([#5059](https://github.com/mapbox/mapbox-gl-native/issues/5059))
- An MGLAnnotationView can be rotated to match the rotation pitch of the associated map view.
- Added a new option to `MGLMapDebugMaskOptions`, `MGLMapDebugWireframesMask`, that shows wireframes instead of the usual rendered output. ([#4359](https://github.com/mapbox/mapbox-gl-native/pull/4359))
## 3.2.2

View File

@@ -181,6 +181,9 @@ static NSString * const MBXViewControllerAnnotationViewReuseIdentifer = @"MBXVie
((debugMask & MGLMapDebugCollisionBoxesMask)
? @"Hide Collision Boxes"
: @"Show Collision Boxes"),
((debugMask & MGLMapDebugWireframesMask)
? @"Hide Wireframes"
: @"Show Wireframes"),
@"Add 100 Points",
@"Add 1,000 Points",
@"Add 10,000 Points",
@@ -222,17 +225,21 @@ static NSString * const MBXViewControllerAnnotationViewReuseIdentifer = @"MBXVie
}
else if (buttonIndex == actionSheet.firstOtherButtonIndex + 5)
{
[self parseFeaturesAddingCount:100];
self.mapView.debugMask ^= MGLMapDebugWireframesMask;
}
else if (buttonIndex == actionSheet.firstOtherButtonIndex + 6)
{
[self parseFeaturesAddingCount:1000];
[self parseFeaturesAddingCount:100];
}
else if (buttonIndex == actionSheet.firstOtherButtonIndex + 7)
{
[self parseFeaturesAddingCount:10000];
[self parseFeaturesAddingCount:1000];
}
else if (buttonIndex == actionSheet.firstOtherButtonIndex + 8)
{
[self parseFeaturesAddingCount:10000];
}
else if (buttonIndex == actionSheet.firstOtherButtonIndex + 9)
{
// PNW triangle
//
@@ -299,19 +306,19 @@ static NSString * const MBXViewControllerAnnotationViewReuseIdentifer = @"MBXVie
free(polygonCoordinates);
}
}
else if (buttonIndex == actionSheet.firstOtherButtonIndex + 9)
else if (buttonIndex == actionSheet.firstOtherButtonIndex + 10)
{
[self startWorldTour:actionSheet];
}
else if (buttonIndex == actionSheet.firstOtherButtonIndex + 10)
else if (buttonIndex == actionSheet.firstOtherButtonIndex + 11)
{
[self presentAnnotationWithCustomCallout];
}
else if (buttonIndex == actionSheet.firstOtherButtonIndex + 11)
else if (buttonIndex == actionSheet.firstOtherButtonIndex + 12)
{
[self.mapView removeAnnotations:self.mapView.annotations];
}
else if (buttonIndex == actionSheet.firstOtherButtonIndex + 12)
else if (buttonIndex == actionSheet.firstOtherButtonIndex + 13)
{
if (_isShowingCustomStyleLayer)
{
@@ -322,12 +329,12 @@ static NSString * const MBXViewControllerAnnotationViewReuseIdentifer = @"MBXVie
[self insertCustomStyleLayer];
}
}
else if (buttonIndex == actionSheet.firstOtherButtonIndex + 13)
else if (buttonIndex == actionSheet.firstOtherButtonIndex + 14)
{
NSString *fileContents = [NSString stringWithContentsOfFile:[self telemetryDebugLogfilePath] encoding:NSUTF8StringEncoding error:nil];
NSLog(@"%@", fileContents);
}
else if (buttonIndex == actionSheet.firstOtherButtonIndex + 14)
else if (buttonIndex == actionSheet.firstOtherButtonIndex + 15)
{
NSString *filePath = [self telemetryDebugLogfilePath];
if ([[NSFileManager defaultManager] isDeletableFileAtPath:filePath]) {

View File

@@ -42,6 +42,9 @@ typedef NS_OPTIONS(NSUInteger, MGLMapDebugMaskOptions) {
/** Edges of glyphs and symbols are shown as faint, green lines to help
diagnose collision and label placement issues. */
MGLMapDebugCollisionBoxesMask = 1 << 4,
/** Line widths, backgrounds, and fill colors are ignored to create a
wireframe effect. */
MGLMapDebugWireframesMask = 1 << 5,
};
/**

View File

@@ -1820,6 +1820,10 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
{
mask |= MGLMapDebugCollisionBoxesMask;
}
if (options & mbgl::MapDebugOptions::Wireframe)
{
mask |= MGLMapDebugWireframesMask;
}
return mask;
}
@@ -1842,6 +1846,10 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
{
options |= mbgl::MapDebugOptions::Collision;
}
if (debugMask & MGLMapDebugWireframesMask)
{
options |= mbgl::MapDebugOptions::Wireframe;
}
_mbglMap->setDebug(options);
}

View File

@@ -4,6 +4,7 @@
* Fixed an issue in which Mapbox.framework was nested inside another folder named Mapbox.framework. ([#4998](https://github.com/mapbox/mapbox-gl-native/pull/4998))
* Fixed a crash passing a mixture of point and shape annotations into `-[MGLMapView addAnnotations:]`. ([#5097](https://github.com/mapbox/mapbox-gl-native/pull/5097))
* Added a new option to `MGLMapDebugMaskOptions`, `MGLMapDebugWireframesMask`, that shows wireframes instead of the usual rendered output. ([#4359](https://github.com/mapbox/mapbox-gl-native/pull/4359))
## 0.1.0

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10117" systemVersion="15E65" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10116"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
@@ -461,6 +461,12 @@
<action selector="toggleCollisionBoxes:" target="-1" id="EYa-7n-iWZ"/>
</connections>
</menuItem>
<menuItem title="Show Wireframes" id="hSX-Be-8xC">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleWireframes:" target="-1" id="usj-ug-upt"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="dYw-bb-tr1"/>
<menuItem title="Show Tooltips on Dropped Pins" id="uir-Rx-zmw">
<modifierMask key="keyEquivalentModifierMask"/>

View File

@@ -244,6 +244,10 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = {
self.mapView.debugMask ^= MGLMapDebugCollisionBoxesMask;
}
- (IBAction)toggleWireframes:(id)sender {
self.mapView.debugMask ^= MGLMapDebugWireframesMask;
}
- (IBAction)toggleShowsToolTipsOnDroppedPins:(id)sender {
_showsToolTipsOnDroppedPins = !_showsToolTipsOnDroppedPins;
}
@@ -520,6 +524,11 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = {
menuItem.title = isShown ? @"Hide Collision Boxes" : @"Show Collision Boxes";
return YES;
}
if (menuItem.action == @selector(toggleWireframes:)) {
BOOL isShown = self.mapView.debugMask & MGLMapDebugWireframesMask;
menuItem.title = isShown ? @"Hide Wireframes" : @"Show Wireframes";
return YES;
}
if (menuItem.action == @selector(toggleShowsToolTipsOnDroppedPins:)) {
BOOL isShown = _showsToolTipsOnDroppedPins;
menuItem.title = isShown ? @"Hide Tooltips on Dropped Pins" : @"Show Tooltips on Dropped Pins";

View File

@@ -20,6 +20,10 @@ typedef NS_OPTIONS(NSUInteger, MGLMapDebugMaskOptions) {
/** Edges of glyphs and symbols are shown as faint, green lines to help
diagnose collision and label placement issues. */
MGLMapDebugCollisionBoxesMask = 1 << 4,
/** Line widths, backgrounds, and fill colors are ignored to create a
wireframe effect. */
MGLMapDebugWireframesMask = 1 << 5,
};
@class MGLAnnotationImage;

View File

@@ -2366,6 +2366,9 @@ public:
if (options & mbgl::MapDebugOptions::Collision) {
mask |= MGLMapDebugCollisionBoxesMask;
}
if (options & mbgl::MapDebugOptions::Wireframe) {
mask |= MGLMapDebugWireframesMask;
}
return mask;
}
@@ -2383,6 +2386,9 @@ public:
if (debugMask & MGLMapDebugCollisionBoxesMask) {
options |= mbgl::MapDebugOptions::Collision;
}
if (debugMask & MGLMapDebugWireframesMask) {
options |= mbgl::MapDebugOptions::Wireframe;
}
_mbglMap->setDebug(options);
}