-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wafer Map Experimental Event Coordinator (#1916)
# Pull Request ## 🤨 Rationale I tried to expand on the strategy switching mechanism from the renderer, and reused it in the coordinator This approach has the benefits of isolating the experimental code while in development, and an easy way to switch to the new version by changing just the imports and switching mechanism and removing the old versions after they become obsolete ## 👩💻 Implementation because arquero causes typescript errors I implemented an alternative search and posted a PR with fixes in arquero repo uwdata/arquero#346 changed the zoom handler to catch events on the component, not just the canvas removed zooming border of around 100px when zooming in the wafer after PO decision, resulting in less complex code and touch controls enabling. ## 🧪 Testing existing tests are passing created new hover unit tests with wafer and data manager mocks ## ✅ Checklist <!--- Review the list and put an x in the boxes that apply or ~~strike through~~ around items that don't (along with an explanation). --> - [x] I have updated the project documentation to reflect my changes or determined no changes are needed. --------- Co-authored-by: rajsite <[email protected]>
- Loading branch information
1 parent
626b6c7
commit f56b73b
Showing
22 changed files
with
698 additions
and
471 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@ni-nimble-components-163379f4-09c6-4606-95f4-05917dd50ee0.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Created new hover event for the new diesTable api and changed the zoom event", | ||
"packageName": "@ni/nimble-components", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 0 additions & 47 deletions
47
packages/nimble-components/src/wafer-map/modules/event-coordinator.ts
This file was deleted.
Oops, something went wrong.
98 changes: 98 additions & 0 deletions
98
packages/nimble-components/src/wafer-map/modules/experimental/hover-handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import type { WaferMap } from '../..'; | ||
import { PointCoordinates, WaferMapOriginLocation } from '../../types'; | ||
|
||
/** | ||
* HoverHandler deals with user interactions and events like hovering | ||
*/ | ||
export class HoverHandler { | ||
public constructor(private readonly wafermap: WaferMap) {} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
public connect(): void { | ||
this.wafermap.addEventListener('mousemove', this.onMouseMove); | ||
this.wafermap.addEventListener('mouseout', this.onMouseOut); | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
public disconnect(): void { | ||
this.wafermap.removeEventListener('mousemove', this.onMouseMove); | ||
this.wafermap.removeEventListener('mouseout', this.onMouseOut); | ||
} | ||
|
||
/** | ||
* @internal | ||
* keep public for testing until data manager refactor | ||
*/ | ||
public readonly onMouseMove = (event: MouseEvent): void => { | ||
if (!this.wafermap.isExperimentalRenderer()) { | ||
return; | ||
} | ||
// get original mouse position in case we are in zoom. | ||
const invertedPoint = this.wafermap.transform.invert([ | ||
event.offsetX, | ||
event.offsetY | ||
]); | ||
|
||
// does not work yet until data manager will parse diesTable | ||
const dieCoordinates = this.calculateDieCoordinates({ | ||
x: invertedPoint[0], | ||
y: invertedPoint[1] | ||
}); | ||
const colIndex = this.wafermap | ||
.diesTable!.getChild('colIndex')! | ||
.toArray(); | ||
const rowIndex = this.wafermap | ||
.diesTable!.getChild('rowIndex')! | ||
.toArray(); | ||
|
||
// will replace iterating with arquero filtering after fixing errors | ||
for (let i = 0; i < colIndex.length; i++) { | ||
if ( | ||
colIndex[i] === dieCoordinates.x | ||
&& rowIndex[i] === dieCoordinates.y | ||
) { | ||
this.wafermap.hoverDie = { | ||
index: i, | ||
x: dieCoordinates.x, | ||
y: dieCoordinates.y | ||
}; | ||
return; | ||
} | ||
} | ||
this.wafermap.hoverDie = undefined; | ||
}; | ||
|
||
private readonly onMouseOut = (_event: MouseEvent): void => { | ||
this.wafermap.hoverDie = undefined; | ||
}; | ||
|
||
private calculateDieCoordinates( | ||
mousePosition: PointCoordinates | ||
): PointCoordinates { | ||
const originLocation = this.wafermap.originLocation; | ||
const xRoundFunction = originLocation === WaferMapOriginLocation.bottomLeft | ||
|| originLocation === WaferMapOriginLocation.topLeft | ||
? Math.floor | ||
: Math.ceil; | ||
const yRoundFunction = originLocation === WaferMapOriginLocation.bottomLeft | ||
|| originLocation === WaferMapOriginLocation.bottomRight | ||
? Math.floor | ||
: Math.ceil; | ||
// go to x and y scale to get the x,y values of the die. | ||
const x = xRoundFunction( | ||
this.wafermap.dataManager.invertedHorizontalScale( | ||
mousePosition.x - this.wafermap.dataManager.margin.left | ||
) | ||
); | ||
const y = yRoundFunction( | ||
this.wafermap.dataManager.invertedVerticalScale( | ||
mousePosition.y - this.wafermap.dataManager.margin.top | ||
) | ||
); | ||
return { x, y }; | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
.../src/wafer-map/modules/worker-renderer.ts → ...p/modules/experimental/worker-renderer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.