Skip to content

Commit

Permalink
Rename scrollIndex into scrollDimIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmartel committed Dec 19, 2024
1 parent 79c823b commit 715dce0
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 49 deletions.
4 changes: 2 additions & 2 deletions src/app/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -1363,15 +1363,15 @@ export class App {
}
} else if (event.key === 'ArrowUp') { // crtl-shift-arrow-up
if (layerGroup.canScroll()) {
positionHelper.incrementScrollPosition();
positionHelper.incrementPositionAlongScroll();
}
} else if (event.key === 'ArrowRight') { // crtl-shift-arrow-right
if (layerGroup.moreThanOne(3)) {
positionHelper.incrementPosition(3);
}
} else if (event.key === 'ArrowDown') { // crtl-shift-arrow-down
if (layerGroup.canScroll()) {
positionHelper.decrementScrollPosition();
positionHelper.decrementPositionAlongScroll();
}
}
} else if (event.key === 'y') { // crtl-y
Expand Down
22 changes: 11 additions & 11 deletions src/app/viewController.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,21 +252,21 @@ export class ViewController {
}

/**
* Get the scroll index.
* Get the scroll dimension index.
*
* @returns {number} The index.
*/
getScrollIndex() {
return this.#view.getScrollIndex();
getScrollDimIndex() {
return this.#view.getScrollDimIndex();
}

/**
* Get the current scroll index value.
* Get the current index scroll value.
*
* @returns {number} The value.
*/
getCurrentScrollIndexValue() {
return this.getCurrentIndex().get(this.#view.getScrollIndex());
getCurrentIndexScrollValue() {
return this.getCurrentIndex().get(this.#view.getScrollDimIndex());
}

/**
Expand Down Expand Up @@ -305,8 +305,8 @@ export class ViewController {
* @returns {number} The value.
*/
getCurrentScrollPosition() {
const scrollIndex = this.#view.getScrollIndex();
return this.#view.getCurrentPosition().get(scrollIndex);
const scrollDimIndex = this.#view.getScrollDimIndex();
return this.#view.getCurrentPosition().get(scrollDimIndex);
}

/**
Expand Down Expand Up @@ -611,7 +611,7 @@ export class ViewController {
getPositionFromPlanePoint(point2D, k) {
// keep third direction
if (typeof k === 'undefined') {
k = this.getCurrentScrollIndexValue();
k = this.getCurrentIndexScrollValue();
}
const planePoint = new Point3D(point2D.getX(), point2D.getY(), k);
// de-orient
Expand Down Expand Up @@ -675,7 +675,7 @@ export class ViewController {
*/
getPlanePositionFromPlanePoint(point2D) {
// keep third direction
const k = this.getCurrentScrollIndexValue();
const k = this.getCurrentIndexScrollValue();
const planePoint = new Point3D(point2D.getX(), point2D.getY(), k);
// de-orient
const point = this.#planeHelper.getTargetDeOrientedPoint3D(planePoint);
Expand Down Expand Up @@ -718,7 +718,7 @@ export class ViewController {
this.#playerID = window.setInterval(() => {
let canDoMore = false;
if (canScroll3D) {
canDoMore = this.#positionHelper.incrementScrollPosition();
canDoMore = this.#positionHelper.incrementPositionAlongScroll();
} else {
canDoMore = this.#positionHelper.incrementPosition(3);
}
Expand Down
8 changes: 4 additions & 4 deletions src/gui/drawLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,11 +478,11 @@ export class DrawLayer {
* @returns {boolean} True if the offset was updated.
*/
setBaseOffset(scrollOffset, planeOffset) {
const scrollIndex = this.#planeHelper.getNativeScrollIndex();
const scrollDimIndex = this.#planeHelper.getNativeScrollDimIndex();
const newOffset = this.#planeHelper.getPlaneOffsetFromOffset3D({
x: scrollIndex === 0 ? scrollOffset.getX() : planeOffset.getX(),
y: scrollIndex === 1 ? scrollOffset.getY() : planeOffset.getY(),
z: scrollIndex === 2 ? scrollOffset.getZ() : planeOffset.getZ(),
x: scrollDimIndex === 0 ? scrollOffset.getX() : planeOffset.getX(),
y: scrollDimIndex === 1 ? scrollOffset.getY() : planeOffset.getY(),
z: scrollDimIndex === 2 ? scrollOffset.getZ() : planeOffset.getZ(),
});
const needsUpdate = this.#baseOffset.x !== newOffset.x ||
this.#baseOffset.y !== newOffset.y;
Expand Down
14 changes: 7 additions & 7 deletions src/gui/viewLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,11 +575,11 @@ export class ViewLayer {
scrollOffset, planeOffset,
layerGroupOrigin, layerGroupOrigin0) {
const helper = this.#viewController.getPlaneHelper();
const scrollIndex = helper.getNativeScrollIndex();
const scrollDimIndex = helper.getNativeScrollDimIndex();
const newOffset = helper.getPlaneOffsetFromOffset3D({
x: scrollIndex === 0 ? scrollOffset.getX() : planeOffset.getX(),
y: scrollIndex === 1 ? scrollOffset.getY() : planeOffset.getY(),
z: scrollIndex === 2 ? scrollOffset.getZ() : planeOffset.getZ(),
x: scrollDimIndex === 0 ? scrollOffset.getX() : planeOffset.getX(),
y: scrollDimIndex === 1 ? scrollOffset.getY() : planeOffset.getY(),
z: scrollDimIndex === 2 ? scrollOffset.getZ() : planeOffset.getZ(),
});
const needsUpdate = this.#baseOffset.x !== newOffset.x ||
this.#baseOffset.y !== newOffset.y;
Expand Down Expand Up @@ -1070,9 +1070,9 @@ export class ViewLayer {
// 3D dimensions
const dims3D = [0, 1, 2];
// remove scroll index
const indexScrollIndex =
dims3D.indexOf(this.#viewController.getScrollIndex());
dims3D.splice(indexScrollIndex, 1);
const indexScrollDimIndex =
dims3D.indexOf(this.#viewController.getScrollDimIndex());
dims3D.splice(indexScrollDimIndex, 1);
// remove non scroll index from diff dims
const diffDims = event.diffDims.filter(function (item) {
return dims3D.indexOf(item) === -1;
Expand Down
4 changes: 2 additions & 2 deletions src/image/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ export class Annotation {
new Point([origin.getX(), origin.getY(), origin.getZ()]);
const originIndex =
this.#viewController.getIndexFromPosition(originPoint);
const scrollIndex = this.#viewController.getScrollIndex();
const k = originIndex.getValues()[scrollIndex];
const scrollDimIndex = this.#viewController.getScrollDimIndex();
const k = originIndex.getValues()[scrollDimIndex];

// shape center converted to 3D
const planePoint = this.mathShape.getCentroid();
Expand Down
4 changes: 2 additions & 2 deletions src/image/planeHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ export class PlaneHelper {
*
* @returns {number} The index.
*/
getScrollIndex() {
getScrollDimIndex() {
let index = null;
if (typeof this.#viewOrientation !== 'undefined') {
index = this.#viewOrientation.getThirdColMajorDirection();
Expand All @@ -395,7 +395,7 @@ export class PlaneHelper {
*
* @returns {number} The index.
*/
getNativeScrollIndex() {
getNativeScrollDimIndex() {
let index = null;
if (typeof this.#imageOrientation !== 'undefined') {
index = this.#imageOrientation.getThirdColMajorDirection();
Expand Down
20 changes: 10 additions & 10 deletions src/image/positionHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ export class PositionHelper {
/**
* @type {number}
*/
#scrollIndex;
#scrollDimIndex;

/**
* @param {View} view The associated view.
*/
constructor(view) {
this.#positionAccessor = new ViewPositionAccessor(view);
this.#geometry = view.getImage().getGeometry();
this.#scrollIndex = view.getScrollIndex();
this.#scrollDimIndex = view.getScrollDimIndex();
}

/**
Expand All @@ -86,8 +86,8 @@ export class PositionHelper {
*
* @returns {number} The scroll index.
*/
getScrollIndex() {
return this.#scrollIndex;
getScrollDimIndex() {
return this.#scrollDimIndex;
}

/**
Expand Down Expand Up @@ -136,7 +136,7 @@ export class PositionHelper {
*/
merge(rhs) {
// check compatibility
if (this.#scrollIndex !== rhs.getScrollIndex()) {
if (this.#scrollDimIndex !== rhs.getScrollDimIndex()) {
throw new Error(
'Cannot merge helper of a view with different orientation'
);
Expand All @@ -154,7 +154,7 @@ export class PositionHelper {
*/
isPositionInBounds(position) {
const index = this.#geometry.worldToIndex(position);
const dirs = [this.#scrollIndex];
const dirs = [this.#scrollDimIndex];
if (index.length() === 4) {
dirs.push(3);
}
Expand Down Expand Up @@ -217,17 +217,17 @@ export class PositionHelper {
*
* @returns {boolean} True if possible and in bounds.
*/
incrementScrollPosition() {
return this.incrementPosition(this.#scrollIndex);
incrementPositionAlongScroll() {
return this.incrementPosition(this.#scrollDimIndex);
}

/**
* Decrement the current position along the scroll dimension.
*
* @returns {boolean} True if possible and in bounds.
*/
decrementScrollPosition() {
return this.decrementPosition(this.#scrollIndex);
decrementPositionAlongScroll() {
return this.decrementPosition(this.#scrollDimIndex);
}

}
8 changes: 4 additions & 4 deletions src/image/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ export class View {
}
const geometry = this.#image.getGeometry();
const index = geometry.worldToIndex(position);
const dirs = [this.getScrollIndex()];
const dirs = [this.getScrollDimIndex()];
if (index.length() === 4) {
dirs.push(3);
}
Expand Down Expand Up @@ -605,7 +605,7 @@ export class View {
// send invalid event if not in bounds
const geometry = this.#image.getGeometry();
const index = geometry.worldToIndex(position);
const dirs = [this.getScrollIndex()];
const dirs = [this.getScrollDimIndex()];
if (index.length() === 4) {
dirs.push(3);
}
Expand Down Expand Up @@ -645,7 +645,7 @@ export class View {
const position = geometry.indexToWorld(index);

// check if possible
const dirs = [this.getScrollIndex()];
const dirs = [this.getScrollDimIndex()];
if (index.length() === 4) {
dirs.push(3);
}
Expand Down Expand Up @@ -985,7 +985,7 @@ export class View {
*
* @returns {number} The index.
*/
getScrollIndex() {
getScrollDimIndex() {
let index = null;
const orientation = this.getOrientation();
if (typeof orientation !== 'undefined') {
Expand Down
4 changes: 2 additions & 2 deletions src/tools/scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ export class Scroll {
if (yMove && layerGroup.canScroll()) {
// update view controller
if (diffY > 0) {
positionHelper.decrementScrollPosition();
positionHelper.decrementPositionAlongScroll();
} else {
positionHelper.incrementScrollPosition();
positionHelper.incrementPositionAlongScroll();
}
} else if (xMove && layerGroup.moreThanOne(3)) {
// update view controller
Expand Down
4 changes: 2 additions & 2 deletions src/tools/scrollWheel.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ export class ScrollWheel {

if (layerGroup.canScroll()) {
if (up) {
positionHelper.incrementScrollPosition();
positionHelper.incrementPositionAlongScroll();
} else {
positionHelper.decrementScrollPosition();
positionHelper.decrementPositionAlongScroll();
}
} else if (layerGroup.moreThanOne(3)) {
if (up) {
Expand Down
4 changes: 2 additions & 2 deletions src/tools/zoomPan.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ export class ZoomAndPan {
// update view controller
if (layerGroup.canScroll()) {
if (diffY > 0) {
positionHelper.incrementScrollPosition();
positionHelper.incrementPositionAlongScroll();
} else {
positionHelper.decrementScrollPosition();
positionHelper.decrementPositionAlongScroll();
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion tests/pacs/viewer.rendertest.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function getRunRenderTest(app) {
}
const vc = vl.getViewController();
const runner = function () {
vc.incrementScrollIndex();
vc.getPositionHelper().incrementPositionAlongScroll();
};

let startTime;
Expand Down

0 comments on commit 715dce0

Please sign in to comment.