@@ -347,9 +347,14 @@ const SWAPGate = ({
347347const QuantumCircuit = ( ) => {
348348 // Number of Qubits
349349 const [ numQubits , setNumQubits ] = useState ( ( ) => {
350- const input = prompt ( "Enter number of Qubits:" ) ;
351- const parsedValue = parseInt ( input , 10 ) ;
352- return ! isNaN ( parsedValue ) && parsedValue > 0 ? parsedValue : 0 ;
350+ while ( true ) {
351+ const input = prompt ( "Enter number of Qubits:" ) ;
352+ const parsedValue = parseInt ( input , 10 ) ;
353+ if ( ! isNaN ( parsedValue ) && parsedValue > 0 && isFinite ( parsedValue ) )
354+ return parsedValue ;
355+ else
356+ alert ( "There must be atleast 1 qubit in a quantum system" ) ;
357+ }
353358 } ) ;
354359 // Result or Log Data from the Backend
355360 const [ resultData , setResultData ] = useState ( null ) ;
@@ -370,10 +375,6 @@ const QuantumCircuit = () => {
370375 // SWAP gates
371376 const [ swapGates , setSwapGates ] = useState ( [ ] ) ; // { x, qubit1, qubit2 }
372377
373- // For Bloch sphere popup
374- const [ selectedQubit , setSelectedQubit ] = useState ( null ) ;
375- const [ modalOpen , setModalOpen ] = useState ( false ) ;
376-
377378 // For rotation/phase gates
378379 const [ rotationModalOpen , setRotationModalOpen ] = useState ( false ) ;
379380 const [ rotationValue , setRotationValue ] = useState ( 45 ) ;
@@ -467,16 +468,16 @@ const QuantumCircuit = () => {
467468 // =======================
468469 // QUBIT LINE COMPONENT
469470 // =======================
470- const QubitLine = ( { y, label, onClickQubit } ) => (
471+ const QubitLine = ( { y, label } ) => (
471472 < Group >
472473 < Text
473474 text = { label }
475+ fontStyle = "1000"
474476 fontSize = { 20 }
475477 x = { 10 }
476478 y = { y - 20 }
477- fill = "blue "
479+ fill = "#4169E1 "
478480 listening = { true }
479- onClick = { onClickQubit }
480481 />
481482 < Line
482483 points = { [ 50 , y , window . innerWidth - 300 , y ] }
@@ -612,19 +613,6 @@ const QuantumCircuit = () => {
612613 setSwapGates ( ( prev ) => prev . filter ( ( _ , i ) => i !== index ) ) ;
613614 } ;
614615
615- // =======================
616- // MODALS & POPUPS
617- // =======================
618- // Bloch sphere popup
619- const openModalForQubit = ( qid ) => {
620- setSelectedQubit ( qid ) ;
621- setModalOpen ( true ) ;
622- } ;
623- const closeModal = ( ) => {
624- setSelectedQubit ( null ) ;
625- setModalOpen ( false ) ;
626- } ;
627-
628616 // =======================
629617 // TOOLTIP HANDLERS
630618 // =======================
@@ -774,7 +762,7 @@ const QuantumCircuit = () => {
774762 < div className = "p-4" >
775763 { /* Tab Buttons */ }
776764 < div className = "sticky top-0 left-[220px] right-0 bg-white z-50 flex space-x-4 border-b mb-4 py-2 px-4" >
777- { [ "Circuit" , "Result" , "Probability" , "Log" ] . map ( ( tab ) => (
765+ { [ "Circuit" , "Result" , "Probability" , "Bloch Sphere" , " Log"] . map ( ( tab ) => (
778766 < button
779767 key = { tab }
780768 className = { `p-2 transition-all ${ activeTab === tab
@@ -938,7 +926,6 @@ const QuantumCircuit = () => {
938926 key = { i }
939927 y = { ( i + 1 ) * qubitSpacing }
940928 label = { `Q${ i } ` }
941- onClickQubit = { ( ) => openModalForQubit ( i ) }
942929 />
943930 ) ) }
944931 { /* Render single-qubit gates */ }
@@ -1022,49 +1009,13 @@ const QuantumCircuit = () => {
10221009 placeholder = "Log Data from Backend"
10231010 value = { resultData }
10241011 > </ textarea >
1025- ) : ( null ) }
1012+ ) : activeTab === "Bloch Sphere" ? (
1013+ < dd > </ dd >
1014+ )
1015+ : ( null ) }
10261016 </ div >
10271017 </ div >
10281018
1029- { /* BLOCH SPHERE MODAL */ }
1030- { modalOpen && (
1031- < div
1032- onClick = { closeModal }
1033- style = { {
1034- position : "fixed" ,
1035- top : 0 ,
1036- left : 0 ,
1037- width : "100vw" ,
1038- height : "100vh" ,
1039- background : "rgba(0, 0, 0, 0.5)" ,
1040- display : "flex" ,
1041- alignItems : "center" ,
1042- justifyContent : "center" ,
1043- } }
1044- >
1045- < div
1046- onClick = { ( e ) => e . stopPropagation ( ) }
1047- style = { {
1048- background : "white" ,
1049- padding : "20px" ,
1050- borderRadius : "10px" ,
1051- textAlign : "center" ,
1052- } }
1053- >
1054- < h3 > Bloch Sphere for Q{ selectedQubit } </ h3 >
1055- < img
1056- src = "https://upload.wikimedia.org/wikipedia/commons/thumb/f/f2/Bloch_sphere.svg/512px-Bloch_sphere.svg.png"
1057- alt = "Bloch Sphere"
1058- style = { { width : "300px" , height : "300px" } }
1059- />
1060- < br />
1061- < button onClick = { closeModal } style = { { marginTop : "10px" } } >
1062- Close
1063- </ button >
1064- </ div >
1065- </ div >
1066- ) }
1067-
10681019 { /* ROTATION/PHASE GATE MODAL */ }
10691020 { rotationModalOpen && (
10701021 < div
0 commit comments