whooooooooooooooooooooooooooo
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useState } from "react";
|
||||
import { useState, useEffect } from "react";
|
||||
import {
|
||||
Pane,
|
||||
TextInputField,
|
||||
@@ -6,8 +6,8 @@ import {
|
||||
Button,
|
||||
toaster,
|
||||
Alert,
|
||||
TrashIcon,
|
||||
Icon
|
||||
TrashIcon,
|
||||
Icon,
|
||||
} from "evergreen-ui";
|
||||
import axios from "axios";
|
||||
import Footer from "./footer";
|
||||
@@ -17,31 +17,34 @@ export default function Manual() {
|
||||
const [points, setPoints] = useState([{ id: 0, len: 0, height: 0 }]);
|
||||
const [args, setArgs] = useState({ scale: 200 });
|
||||
|
||||
//useEffect(() => {
|
||||
//do something here
|
||||
// }, [points]);
|
||||
|
||||
const reIndex=()=>{
|
||||
let newId = 0;
|
||||
let newPoints = []
|
||||
for(let point of points){
|
||||
point.id = newId
|
||||
newPoints.push(point)
|
||||
newId += 1;
|
||||
}
|
||||
setPoints([...newPoints])
|
||||
}
|
||||
const reIndex = () => {
|
||||
let newId = 0;
|
||||
let newPoints = [];
|
||||
for (let point of points) {
|
||||
point.id = newId;
|
||||
newPoints.push(point);
|
||||
newId += 1;
|
||||
}
|
||||
setPoints([...newPoints]);
|
||||
};
|
||||
|
||||
const generation=(e)=>{
|
||||
let pointString ="Próbkowanie: 1\nSegment 0: w dół\nX: Y, Z"
|
||||
const generation = (e) => {
|
||||
let pointString = "Próbkowanie: 1\nSegment 0: w dół\nX: Y, Z";
|
||||
|
||||
for(let point of points){
|
||||
pointString += '\n'
|
||||
pointString += Number(point.len)
|
||||
pointString += '.0, 1.0, '
|
||||
pointString += point.height
|
||||
for (let point of points) {
|
||||
pointString += "\n";
|
||||
pointString += Number(point.len) * 1.0;
|
||||
pointString += ", 1.0, ";
|
||||
pointString += point.height;
|
||||
}
|
||||
|
||||
console.log(pointString)
|
||||
py(e,pointString,args)
|
||||
}
|
||||
console.log(pointString);
|
||||
py(e, pointString, args);
|
||||
};
|
||||
|
||||
const py = (e, profil, args) => {
|
||||
e.preventDefault();
|
||||
@@ -78,43 +81,74 @@ export default function Manual() {
|
||||
placeholder="0 m"
|
||||
onChange={(e) => {
|
||||
console.log(e.target.value);
|
||||
let newPoints = points;
|
||||
newPoints[index].len = e.target.value;
|
||||
setPoints([...newPoints])
|
||||
let newPoints = points;
|
||||
newPoints[index].len = e.target.value;
|
||||
setPoints([...newPoints]);
|
||||
}}
|
||||
value={point.len}
|
||||
value={point.len}
|
||||
></TextInputField>
|
||||
<TextInputField
|
||||
<TextInputField
|
||||
id={`h-${index}`}
|
||||
placeholder="0 m n.p.m."
|
||||
onChange={(e) => {
|
||||
console.log(e.target.value);
|
||||
let newPoints = points;
|
||||
newPoints[index].height = e.target.value;
|
||||
setPoints([...newPoints])
|
||||
let newPoints = points;
|
||||
newPoints[index].height = e.target.value;
|
||||
setPoints([...newPoints]);
|
||||
}}
|
||||
value={point.height}
|
||||
></TextInputField>
|
||||
<Button appearance="minimal" onClick={() => {
|
||||
let newPoints = points;
|
||||
newPoints.splice(index, 1);
|
||||
setPoints([...newPoints]);
|
||||
reIndex();
|
||||
}}><Icon icon={TrashIcon} color='danger'></Icon></Button>
|
||||
value={point.height}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key == "Enter") {
|
||||
setPoints([
|
||||
...points,
|
||||
{
|
||||
id: points.length,
|
||||
len: Number(points[points.length - 1].len) + 1,
|
||||
height: 0,
|
||||
},
|
||||
]);
|
||||
|
||||
let nextDiv = e.target.parentNode.parentNode.nextSibling;
|
||||
nextDiv.childNodes[1].childNodes[1].focus()
|
||||
}
|
||||
}}
|
||||
></TextInputField>
|
||||
<Button
|
||||
appearance="minimal"
|
||||
onClick={() => {
|
||||
let newPoints = points;
|
||||
newPoints.splice(index, 1);
|
||||
setPoints([...newPoints]);
|
||||
reIndex();
|
||||
}}
|
||||
>
|
||||
<Icon icon={TrashIcon} color="danger"></Icon>
|
||||
</Button>
|
||||
</Pane>
|
||||
))}
|
||||
</Pane>
|
||||
<Button
|
||||
onClick={() => {
|
||||
setPoints([...points, { id: points.length, len: Number(points[points.length-1].len)+1, height: 0 }]);
|
||||
setPoints([
|
||||
...points,
|
||||
{
|
||||
id: points.length,
|
||||
len: Number(points[points.length - 1].len) + 1,
|
||||
height: 0,
|
||||
},
|
||||
]);
|
||||
}}
|
||||
>
|
||||
Dodaj
|
||||
</Button>
|
||||
<Button appearance="primary" onClick={(e)=>{
|
||||
generation(e);
|
||||
}}>Generuj</Button>
|
||||
<Button
|
||||
appearance="primary"
|
||||
onClick={(e) => {
|
||||
generation(e);
|
||||
}}
|
||||
>
|
||||
Generuj
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user