Skip to content

Commit

Permalink
Hit-test: ignore components on top/bottom if relevant layer not shown
Browse files Browse the repository at this point in the history
  • Loading branch information
jenswilly committed Jan 26, 2015
1 parent d371eb9 commit 712df5a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
2 changes: 0 additions & 2 deletions EAGLEView/Models/EAGLEBoard.m
Expand Up @@ -103,8 +103,6 @@ - (id)initFromXMLElement:(DDXMLElement *)element
}
_signals = [NSArray arrayWithArray:tmpElements];

/// ...


// Plain
elements = [element nodesForXPath:@"plain/*" error:&error];
Expand Down
2 changes: 2 additions & 0 deletions EAGLEView/Models/EAGLEElement.h
Expand Up @@ -23,5 +23,7 @@
@property (readonly) NSString *valueText; // Same as value

- (void)drawInContext:(CGContextRef)context layerNumber:(NSNumber*)layerNumber;
- (BOOL)isOnBottomLayer;
- (BOOL)isOnTopLayer;

@end
11 changes: 11 additions & 0 deletions EAGLEView/Models/EAGLEElement.m
Expand Up @@ -102,6 +102,17 @@ - (NSString *)description
return [NSString stringWithFormat:@"Element %@ - value: %@", _name, _value];
}

- (BOOL)isOnBottomLayer
{
// A mirrored object is considered a bottom element.
return [EAGLEDrawableObject rotationIsMirrored:_rotation];
}

- (BOOL)isOnTopLayer
{
return ![self isOnBottomLayer];
}

- (void)drawInContext:(CGContextRef)context layerNumber:(NSNumber*)layerNumber
{
// Rotate if necessary. First offset coordinate system to origin point then rotate. State is pushed/popped.
Expand Down
10 changes: 7 additions & 3 deletions EAGLEView/Views/EAGLEFileView.m
Expand Up @@ -346,10 +346,14 @@ - (NSArray*)objectsAtPoint:(CGPoint)point
EAGLEBoard *board = (EAGLEBoard*)self.file;

// Instances
for( id<EAGLEDrawable> drawable in board.elements )
for( EAGLEElement *element in board.elements )
{
if( CGRectContainsPoint( [drawable boundingRect], coordinate ))
objectsAtCoordinate[ distance( drawable, coordinate ) ] = drawable;
// Ignore this element if it is on the top layer and layer 1 (top) is hidden or it is on bottom and the bottom layer (16) is hidden
if( ([element isOnTopLayer] && !((EAGLELayer*)self.file.layers[ @1 ]).visible) || ([element isOnBottomLayer] && !((EAGLELayer*)self.file.layers[ @16 ]).visible) )
continue;

if( CGRectContainsPoint( [element boundingRect], coordinate ))
objectsAtCoordinate[ distance( element, coordinate ) ] = element;
}

/*
Expand Down
3 changes: 2 additions & 1 deletion To-do.txt
Expand Up @@ -18,7 +18,6 @@ To-do:
- Improve single vs. double tap on iPhone
- Alternative to polygon fills: polygons on/off setting
- Speed up drawing by checking for relevant rect?
- Hit-test: ignore components on top/bottom if relevant layer not shown
- Search: deselect all marked components
- Fix text drawing of R270 rotated instances
- Fix bounding rect of R270 rotated instances
Expand All @@ -40,6 +39,8 @@ In progress/partly done:
-----
Done:

√ Hit-test: ignore components on top/bottom if relevant layer not shown
√ Fixed initial state of toolbar buttons
√ Fixed initial file loading
--- b142
√ Disable sheets picker if there is only one sheet/module or if it's a board file
Expand Down

0 comments on commit 712df5a

Please sign in to comment.