11import { useMutation , useQuery , useQueryClient } from "@tanstack/react-query" ;
22import { getMatProjStructure , postCrystal } from "../../queryfunctions" ;
3- import { Button , Stack , Typography } from "@mui/material" ;
4- import React from "react" ;
3+ import { Button , Checkbox , Stack , Typography } from "@mui/material" ;
4+ import React , { useState } from "react" ;
55import { useNavigate } from "react-router-dom" ;
66import XYZCrystalViewer from "./XYZCrystalViewer" ;
77import { MolStarCrystalWrapper } from "../MolstarCrystalViewer" ;
@@ -15,6 +15,12 @@ function MatProjCrystalViewer(props: { mpid: string }) {
1515 retry : false ,
1616 } ) ;
1717
18+ const [ checked , setChecked ] = useState ( false ) ;
19+
20+ const handleChange = ( event : React . ChangeEvent < HTMLInputElement > ) => {
21+ setChecked ( event . target . checked ) ;
22+ } ;
23+
1824 const navigate = useNavigate ( ) ;
1925 const queryClient = useQueryClient ( ) ;
2026
@@ -55,10 +61,31 @@ function MatProjCrystalViewer(props: { mpid: string }) {
5561 labelledAtomIndex = { undefined }
5662 > </ MolStarCrystalWrapper >
5763 </ Stack >
64+ < Stack direction = "row" alignItems = "center" >
65+ < Checkbox checked = { checked } onChange = { handleChange } > </ Checkbox >
66+ < Typography > Round Lattice Parameters to 4 Decimal Places</ Typography >
67+ </ Stack >
5868 < Button
5969 variant = "contained"
6070 onClick = { ( ) => {
61- mutation . mutate ( query . data ) ;
71+ const structure = query . data ;
72+
73+ if ( checked ) {
74+ structure . lattice . a =
75+ Math . round ( structure . lattice . a * 10000.0 ) / 10000.0 ;
76+ structure . lattice . b =
77+ Math . round ( structure . lattice . b * 10000.0 ) / 10000.0 ;
78+ structure . lattice . c =
79+ Math . round ( structure . lattice . c * 10000.0 ) / 10000.0 ;
80+ structure . lattice . alpha =
81+ Math . round ( structure . lattice . alpha * 10000.0 ) / 10000.0 ;
82+ structure . lattice . beta =
83+ Math . round ( structure . lattice . beta * 10000.0 ) / 10000.0 ;
84+ structure . lattice . gamma =
85+ Math . round ( structure . lattice . gamma * 10000.0 ) / 10000.0 ;
86+ }
87+
88+ mutation . mutate ( structure ) ;
6289 } }
6390 >
6491 Create Crystal
0 commit comments