Skip to content

Commit

Permalink
Merge pull request #180 from t29mato/feature/rename-is-log-to-is-log-…
Browse files Browse the repository at this point in the history
…scale

feat: rename variable name: isLog -> isLogScale
  • Loading branch information
yu-smc authored Sep 5, 2024
2 parents 080beee + c981666 commit 82213de
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 40 deletions.
12 changes: 6 additions & 6 deletions src/domain/repositories/axisRepository/axisRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export class AxisRepository implements AxisRepositoryInterface {
y1: AxisInterface
y2: AxisInterface
x2y2: AxisInterface //x2, y2を同時調整するために使う仮想軸
xIsLog = false
yIsLog = false
xIsLogScale = false
yIsLogScale = false
activeAxisName = ''
pointMode = 0 // INFO: {0: '2Points', 1: '4Points'}
considerGraphTilt = false
Expand Down Expand Up @@ -203,11 +203,11 @@ export class AxisRepository implements AxisRepositoryInterface {
this.y2.value = value
}

setXIsLog(value: boolean): void {
this.xIsLog = value
setXIsLogScale(value: boolean): void {
this.xIsLogScale = value
}

setYIsLog(value: boolean): void {
this.yIsLog = value
setYIsLogScale(value: boolean): void {
this.yIsLogScale = value
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export interface AxisRepositoryInterface {
y1: AxisInterface
y2: AxisInterface
x2y2: AxisInterface
xIsLog: boolean
yIsLog: boolean
xIsLogScale: boolean
yIsLogScale: boolean
activeAxisName: string
pointMode: number // INFO: {0: '2Points', 1: '4Points'}
considerGraphTilt: boolean
Expand All @@ -36,6 +36,6 @@ export interface AxisRepositoryInterface {
setX2Value(value: number): void
setY1Value(value: number): void
setY2Value(value: number): void
setXIsLog(value: boolean): void
setYIsLog(value: boolean): void
setXIsLogScale(value: boolean): void
setYIsLogScale(value: boolean): void
}
8 changes: 4 additions & 4 deletions src/domain/services/XYAxesCalculator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ describe('XYAxesCalculator', () => {
coord: { xPx: 243.5724043715847, yPx: 45.02049180327869 },
initialCoord: { xPx: -999, yPx: -999 },
},
xIsLog: false,
yIsLog: false,
xIsLogScale: false,
yIsLogScale: false,
activeAxisName: '',
x1IsSameAsY1: false,
considerGraphTilt: false,
Expand Down Expand Up @@ -155,8 +155,8 @@ describe('XYAxesCalculator', () => {
coord: { xPx: 243.5724043715847, yPx: 45.02049180327869 },
initialCoord: { xPx: -999, yPx: -999 },
},
xIsLog: false,
yIsLog: false,
xIsLogScale: false,
yIsLogScale: false,
activeAxisName: '',
x1IsSameAsY1: false,
considerGraphTilt: true, // This is the difference of this test case
Expand Down
10 changes: 5 additions & 5 deletions src/domain/services/XYAxesCalculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export default class XYAxesCalculator {
effectiveDigits: number = 4

#axes: AxisRepositoryInterface
#isLog: { x: boolean; y: boolean }
#isLogScale: { x: boolean; y: boolean }
constructor(
axes: AxisRepositoryInterface,
isLog: { x: boolean; y: boolean },
isLogScale: { x: boolean; y: boolean },
) {
this.#axes = axes
this.#isLog = isLog
this.#isLogScale = isLogScale
}
calculateXYValues(xt: number, yt: number): { xV: string; yV: string } {
if (
Expand Down Expand Up @@ -58,14 +58,14 @@ export default class XYAxesCalculator {
xp = xa + r * xab
yq = yc + s * ycd
}
const xV = this.#isLog.x
const xV = this.#isLogScale.x
? Math.pow(
10,
((xp - xa) / (xb - xa)) * (Math.log10(b) - Math.log10(a)) +
Math.log10(a),
)
: ((xp - xa) / (xb - xa)) * (b - a) + a
const yV = this.#isLog.y
const yV = this.#isLogScale.y
? Math.pow(
10,
((yq - yc) / (yd - yc)) * (Math.log10(d) - Math.log10(c)) +
Expand Down
4 changes: 2 additions & 2 deletions src/presentation/components/Export/DataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ export default defineComponent({
calculateXY(x: number, y: number): { xV: string; yV: string } {
// INFO: 軸の値が未決定の場合は、ピクセルをそのまま表示
const calculator = new XYAxesCalculator(this.axisRepository, {
x: this.axisRepository.xIsLog,
y: this.axisRepository.yIsLog,
x: this.axisRepository.xIsLogScale,
y: this.axisRepository.yIsLogScale,
})
return calculator.calculateXYValues(x, y)
},
Expand Down
6 changes: 3 additions & 3 deletions src/presentation/components/Magnifier/MagnifierMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default defineComponent({
return {
magnifierSettingError: '',
shouldShowSettingsDialog: false,
magnifier,
magnifier,
canvasHandler,
axisRepository,
datasetRepository,
Expand All @@ -125,8 +125,8 @@ magnifier,
} {
// INFO: 軸の値が未決定の場合は、ピクセルをそのまま表示
const calculator = new XYAxesCalculator(this.axisRepository, {
x: this.axisRepository.xIsLog,
y: this.axisRepository.yIsLog,
x: this.axisRepository.xIsLogScale,
y: this.axisRepository.yIsLogScale,
})
return calculator.calculateXYValues(
this.canvasHandler.cursor.xPx,
Expand Down
32 changes: 16 additions & 16 deletions src/presentation/components/Settings/AxesSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
>
<div
class="c__axisRepository-settings__log-adjuster"
v-if="xIsLog"
v-if="xIsLogScale"
>
<button
size="x-small"
Expand Down Expand Up @@ -48,7 +48,7 @@
>
<div
class="c__axisRepository-settings__log-adjuster"
v-if="xIsLog"
v-if="xIsLogScale"
>
<button
id="multiply-by-ten-x2"
Expand All @@ -72,7 +72,7 @@
<td>
<v-checkbox
color="primary"
v-model="xIsLog"
v-model="xIsLogScale"
id="x-is-log"
hide-details
density="compact"
Expand All @@ -93,7 +93,7 @@
>
<div
class="c__axisRepository-settings__log-adjuster"
v-if="yIsLog"
v-if="yIsLogScale"
>
<button
id="multiply-by-ten-y1"
Expand Down Expand Up @@ -125,7 +125,7 @@
>
<div
class="c__axisRepository-settings__log-adjuster"
v-if="yIsLog"
v-if="yIsLogScale"
>
<button
id="multiply-by-ten-y2"
Expand All @@ -149,7 +149,7 @@
<td>
<v-checkbox
color="primary"
v-model="yIsLog"
v-model="yIsLogScale"
id="y-is-log"
density="compact"
hide-details
Expand Down Expand Up @@ -200,7 +200,7 @@ import { axisRepository } from '@/instanceStore/repositoryInatances'
export default defineComponent({
computed: {
errorMessage(): string {
if (this.axisRepository.xIsLog) {
if (this.axisRepository.xIsLogScale) {
if (this.x1 === '0' || this.x2 === '0') {
return 'x1 or x2 should not be 0'
}
Expand All @@ -209,7 +209,7 @@ export default defineComponent({
return 'x1 and x2 should not be same value'
}
}
if (this.axisRepository.yIsLog) {
if (this.axisRepository.yIsLogScale) {
if (this.y1 === '0' || this.y2 === '0') {
return 'y1 or y2 should not be 0'
}
Expand All @@ -228,8 +228,8 @@ export default defineComponent({
x2: '1',
y1: '0',
y2: '1',
xIsLog: false,
yIsLog: false,
xIsLogScale: false,
yIsLogScale: false,
}
},
Expand Down Expand Up @@ -276,15 +276,15 @@ export default defineComponent({
this.x2 = String(this.axisRepository.x2.value)
this.y1 = String(this.axisRepository.y1.value)
this.y2 = String(this.axisRepository.y2.value)
this.xIsLog = this.axisRepository.xIsLog
this.yIsLog = this.axisRepository.yIsLog
this.xIsLogScale = this.axisRepository.xIsLogScale
this.yIsLogScale = this.axisRepository.yIsLogScale
},
watch: {
xIsLog(value: boolean) {
this.axisRepository.setXIsLog(value)
xIsLogScale(value: boolean) {
this.axisRepository.setXIsLogScale(value)
},
yIsLog(value: boolean) {
this.axisRepository.setYIsLog(value)
yIsLogScale(value: boolean) {
this.axisRepository.setYIsLogScale(value)
},
x1(value: string) {
this.axisRepository.setX1Value(parseFloat(value))
Expand Down

0 comments on commit 82213de

Please sign in to comment.