Skip to content

Commit

Permalink
chain selection
Browse files Browse the repository at this point in the history
  • Loading branch information
joonarafael committed Jan 20, 2024
1 parent d064713 commit 615933b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 20 deletions.
22 changes: 12 additions & 10 deletions app/calc/calculator.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"use client";

import { useEffect, useState } from "react";
import { useEffect, useState } from 'react';

import Container from "../components/container";
import LatencyChange from "./latencychange";
import Matrix from "./matrix";
import Menu from "./menu";
import eraseAdjacentConnections from "./supports/connections/eraseadjacentconnections";
import initConnection from "./supports/initconnection";
import replaceOldEntry from "./supports/replaceoldentry";
import ToolBar from "./toolbar";
import Container from '../components/container';
import LatencyChange from './latencychange';
import Matrix from './matrix';
import Menu from './menu';
import eraseAdjacentConnections from './supports/connections/eraseadjacentconnections';
import initConnection from './supports/initconnection';
import replaceOldEntry from './supports/replaceoldentry';
import ToolBar from './toolbar';

interface CalculatorProps {
width: number;
Expand Down Expand Up @@ -137,7 +137,8 @@ const Calculator: React.FC<CalculatorProps> = ({ width, height }) => {
updateFieldValue,
tool
);
setSelectedBoreHole(null);

setSelectedBoreHole(position[2]);
}
}

Expand Down Expand Up @@ -189,6 +190,7 @@ const Calculator: React.FC<CalculatorProps> = ({ width, height }) => {
resetField={resetField}
setLatencyChangeView={setLatencyChangeView}
debugStates={debugStates}
setSelectedBoreHole={setSelectedBoreHole}
/>
<div className="flex flex-row gap-4">
<div className="border rounded-lg w-5/6 h-[80svh] overflow-scroll">
Expand Down
7 changes: 3 additions & 4 deletions app/calc/latencychange.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use client";

import { toast } from "sonner";
import { toast } from 'sonner';

import { Button } from "../components/ui/button";
import { Input } from "../components/ui/input";
import { Button } from '../components/ui/button';
import { Input } from '../components/ui/input';

interface LatencyChangeProps {
latencySelection: number[];
Expand All @@ -30,7 +30,6 @@ const LatencyChange: React.FC<LatencyChangeProps> = ({
tmp[index] = asNumber;

setLatencySelection(tmp);
console.log(latencySelection);
} catch (e) {
console.log(e);
}
Expand Down
14 changes: 14 additions & 0 deletions app/calc/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface MenuProps {
resetField: () => void;
setLatencyChangeView: (value: boolean) => void;
debugStates: () => void;
setSelectedBoreHole: (value: number | null) => void;
}

const Menu: React.FC<MenuProps> = ({
Expand All @@ -29,6 +30,7 @@ const Menu: React.FC<MenuProps> = ({
resetField,
setLatencyChangeView,
debugStates,
setSelectedBoreHole,
}) => {
const zoomIn = () => {
if (zoom < 6) {
Expand Down Expand Up @@ -112,6 +114,18 @@ const Menu: React.FC<MenuProps> = ({
</MenubarItem>
</MenubarContent>
</MenubarMenu>
<MenubarMenu>
<MenubarTrigger>Select</MenubarTrigger>
<MenubarContent>
<MenubarItem
onClick={() => {
setSelectedBoreHole(null);
}}
>
Clear selection
</MenubarItem>
</MenubarContent>
</MenubarMenu>
<MenubarMenu>
<MenubarTrigger>View</MenubarTrigger>
<MenubarContent>
Expand Down
8 changes: 2 additions & 6 deletions app/calc/supports/connections/connectnortheast.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import getColIndex from '../getcolindex';
import getRowIndex from '../getrowindex';
import getColIndex from "../getcolindex";
import getRowIndex from "../getrowindex";

export default function connectNorthEast(
start: number,
Expand All @@ -12,13 +12,9 @@ export default function connectNorthEast(
) {
const targetIndex = start - width + 1;

console.log(targetIndex);

const targetIndexRow = getRowIndex(targetIndex, width);
const targetIndexCol = getColIndex(targetIndex, width);

console.log(targetIndexRow, targetIndexCol);

updateFieldValue([targetIndexRow, targetIndexCol], 1);
updateFieldStatus([targetIndexRow, targetIndexCol], parseInt(tool, 10));
}

0 comments on commit 615933b

Please sign in to comment.