Skip to content

Commit 712df5a

Browse files
committed
Hit-test: ignore components on top/bottom if relevant layer not shown
1 parent d371eb9 commit 712df5a

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

EAGLEView/Models/EAGLEBoard.m

-2
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@ - (id)initFromXMLElement:(DDXMLElement *)element
103103
}
104104
_signals = [NSArray arrayWithArray:tmpElements];
105105

106-
/// ...
107-
108106

109107
// Plain
110108
elements = [element nodesForXPath:@"plain/*" error:&error];

EAGLEView/Models/EAGLEElement.h

+2
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@
2323
@property (readonly) NSString *valueText; // Same as value
2424

2525
- (void)drawInContext:(CGContextRef)context layerNumber:(NSNumber*)layerNumber;
26+
- (BOOL)isOnBottomLayer;
27+
- (BOOL)isOnTopLayer;
2628

2729
@end

EAGLEView/Models/EAGLEElement.m

+11
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,17 @@ - (NSString *)description
102102
return [NSString stringWithFormat:@"Element %@ - value: %@", _name, _value];
103103
}
104104

105+
- (BOOL)isOnBottomLayer
106+
{
107+
// A mirrored object is considered a bottom element.
108+
return [EAGLEDrawableObject rotationIsMirrored:_rotation];
109+
}
110+
111+
- (BOOL)isOnTopLayer
112+
{
113+
return ![self isOnBottomLayer];
114+
}
115+
105116
- (void)drawInContext:(CGContextRef)context layerNumber:(NSNumber*)layerNumber
106117
{
107118
// Rotate if necessary. First offset coordinate system to origin point then rotate. State is pushed/popped.

EAGLEView/Views/EAGLEFileView.m

+7-3
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,14 @@ - (NSArray*)objectsAtPoint:(CGPoint)point
346346
EAGLEBoard *board = (EAGLEBoard*)self.file;
347347

348348
// Instances
349-
for( id<EAGLEDrawable> drawable in board.elements )
349+
for( EAGLEElement *element in board.elements )
350350
{
351-
if( CGRectContainsPoint( [drawable boundingRect], coordinate ))
352-
objectsAtCoordinate[ distance( drawable, coordinate ) ] = drawable;
351+
// 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
352+
if( ([element isOnTopLayer] && !((EAGLELayer*)self.file.layers[ @1 ]).visible) || ([element isOnBottomLayer] && !((EAGLELayer*)self.file.layers[ @16 ]).visible) )
353+
continue;
354+
355+
if( CGRectContainsPoint( [element boundingRect], coordinate ))
356+
objectsAtCoordinate[ distance( element, coordinate ) ] = element;
353357
}
354358

355359
/*

To-do.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ To-do:
1818
- Improve single vs. double tap on iPhone
1919
- Alternative to polygon fills: polygons on/off setting
2020
- Speed up drawing by checking for relevant rect?
21-
- Hit-test: ignore components on top/bottom if relevant layer not shown
2221
- Search: deselect all marked components
2322
- Fix text drawing of R270 rotated instances
2423
- Fix bounding rect of R270 rotated instances
@@ -40,6 +39,8 @@ In progress/partly done:
4039
-----
4140
Done:
4241

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

0 commit comments

Comments
 (0)