Skip to content

Commit b900956

Browse files
authored
Merge pull request #138 from LinkunGao/release/v1.12.14
Release/v1.12.14
2 parents 70eb776 + 29c1abf commit b900956

File tree

6 files changed

+70
-33
lines changed

6 files changed

+70
-33
lines changed

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
author = 'LinkunGao'
2323

2424
# The full version, including alpha/beta/rc tags
25-
release = 'v1.12.13'
25+
release = 'v1.12.14'
2626

2727

2828
# -- General configuration ---------------------------------------------------

docs/source/release/release.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,3 +1112,9 @@ const resetMainAreaSize = (factor: number) => {
11121112
## Release v1.12.13
11131113

11141114
- remove useless code.
1115+
1116+
## Release v1.12.14
1117+
1118+
- remove arrow key function in nrrd tools.
1119+
- add using cursor function to selete the point position on NRRD slice via corsshair.
1120+
- press `s` on keyboard to use this function.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "copper3d_visualisation",
33
"description": "A 3d visualisation package base on threejs provides multiple scenes and Nrrd image load funtion.",
4-
"version": "1.12.13",
4+
"version": "1.12.14",
55
"main": "dist/bundle.umd.js",
66
"moudle": "dist/bundle.esm.js",
77
"types": "dist/types/index.d.ts",

src/Utils/nrrd_tool.ts

Lines changed: 58 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ export class nrrd_tools {
7373
Max_sensitive: 100,
7474
readyToUpdate: true,
7575
showContrast: false,
76+
enableCursorChoose: false,
77+
isCursorSelect: false,
78+
cursorPageX: 0,
79+
cursorPageY: 0,
7680
Mouse_Over_x: 0,
7781
Mouse_Over_y: 0,
7882
Mouse_Over: false,
@@ -160,12 +164,12 @@ export class nrrd_tools {
160164
this.container.addEventListener("keydown", (ev: KeyboardEvent) => {
161165
if (ev.key === "Shift") {
162166
this.Is_Shift_Pressed = true;
167+
this.nrrd_states.enableCursorChoose = false;
163168
}
164-
if (ev.key === "ArrowUp") {
165-
this.setSliceMoving(-1);
166-
}
167-
if (ev.key === "ArrowDown") {
168-
this.setSliceMoving(1);
169+
if (ev.key === "s") {
170+
this.Is_Draw = false;
171+
this.nrrd_states.enableCursorChoose =
172+
!this.nrrd_states.enableCursorChoose;
169173
}
170174
});
171175
this.container.addEventListener("keyup", (ev: KeyboardEvent) => {
@@ -860,30 +864,33 @@ export class nrrd_tools {
860864
this.drawingCanvas.removeEventListener("wheel", this.handleWheelMove);
861865

862866
if (e.button === 0) {
863-
if (!this.Is_Shift_Pressed) {
864-
return;
865-
}
866-
867-
leftclicked = true;
868-
lines = [];
869-
Is_Painting = true;
870-
this.Is_Draw = true;
867+
if (this.Is_Shift_Pressed) {
868+
leftclicked = true;
869+
lines = [];
870+
Is_Painting = true;
871+
this.Is_Draw = true;
872+
873+
if (this.gui_states.Eraser) {
874+
this.drawingCanvas.style.cursor =
875+
"url(https://raw.githubusercontent.com/LinkunGao/copper3d_icons/main/icons/circular-cursor.png) 52 52, crosshair";
876+
} else {
877+
this.drawingCanvas.style.cursor =
878+
this.nrrd_states.defaultPaintCursor;
879+
}
871880

872-
if (this.gui_states.Eraser) {
873-
this.drawingCanvas.style.cursor =
874-
"url(https://raw.githubusercontent.com/LinkunGao/copper3d_icons/main/icons/circular-cursor.png) 52 52, crosshair";
875-
} else {
876-
this.drawingCanvas.style.cursor =
877-
this.nrrd_states.defaultPaintCursor;
881+
this.nrrd_states.drawStartPos.set(e.offsetX, e.offsetY);
882+
this.drawingLayerOneCtx.beginPath();
883+
this.drawingCanvas.addEventListener("pointerup", handlePointerUp);
884+
this.drawingCanvas.addEventListener(
885+
"pointermove",
886+
handleOnPainterMove
887+
);
888+
} else if (this.nrrd_states.enableCursorChoose) {
889+
this.nrrd_states.cursorPageX =
890+
e.offsetX / this.nrrd_states.sizeFoctor;
891+
this.nrrd_states.cursorPageY =
892+
e.offsetY / this.nrrd_states.sizeFoctor;
878893
}
879-
880-
this.nrrd_states.drawStartPos.set(e.offsetX, e.offsetY);
881-
this.drawingLayerOneCtx.beginPath();
882-
this.drawingCanvas.addEventListener("pointerup", handlePointerUp);
883-
this.drawingCanvas.addEventListener(
884-
"pointermove",
885-
handleOnPainterMove
886-
);
887894
} else if (e.button === 2) {
888895
rightclicked = true;
889896
let offsetX = parseInt(this.drawingCanvas.style.left);
@@ -1075,6 +1082,22 @@ export class nrrd_tools {
10751082
this.drawingCtx.stroke();
10761083
}
10771084
}
1085+
if (this.nrrd_states.enableCursorChoose) {
1086+
this.drawingCtx.clearRect(
1087+
0,
1088+
0,
1089+
this.nrrd_states.changedWidth,
1090+
this.nrrd_states.changedHeight
1091+
);
1092+
1093+
const ex =
1094+
this.nrrd_states.cursorPageX * this.nrrd_states.sizeFoctor;
1095+
const ey =
1096+
this.nrrd_states.cursorPageY * this.nrrd_states.sizeFoctor;
1097+
1098+
this.drawLine(ex, 0, ex, this.drawingCanvas.height);
1099+
this.drawLine(0, ey, this.drawingCanvas.width, ey);
1100+
}
10781101
}
10791102
this.drawingCtx.drawImage(this.drawingCanvasLayerOne, 0, 0);
10801103
} else {
@@ -1089,6 +1112,14 @@ export class nrrd_tools {
10891112
});
10901113
}
10911114

1115+
private drawLine = (x1: number, y1: number, x2: number, y2: number) => {
1116+
this.drawingCtx.beginPath();
1117+
this.drawingCtx.moveTo(x1, y1);
1118+
this.drawingCtx.lineTo(x2, y2);
1119+
this.drawingCtx.strokeStyle = this.gui_states.color;
1120+
this.drawingCtx.stroke();
1121+
};
1122+
10921123
private undoLastPainting() {
10931124
this.Is_Draw = true;
10941125
this.drawingCanvasLayerOne.width = this.drawingCanvasLayerOne.width;

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ import {
3333

3434
import "./css/style.css";
3535

36-
export const REVISION = "v1.12.13";
36+
export const REVISION = "v1.12.14";
3737

3838
console.log(
39-
"%cCopper3D Visualisation %cBeta:v1.12.13",
39+
"%cCopper3D Visualisation %cBeta:v1.12.14",
4040
"padding: 3px;color:white; background:#023047",
4141
"padding: 3px;color:white; background:#f50a25"
4242
);

0 commit comments

Comments
 (0)