public override void OnGridClick(Tuple <int, int, Editor.ClickPosition> infos) { QCS.Circuit.GateStruct gateStruct = _selectedGate.gateStruct; int sourceRow = gateStruct.row; int sourceCol = gateStruct.col; int nbEntries = gateStruct.gate.NbEntries; int targetRow = infos.Item1; int targetCol = infos.Item2; Editor.ClickPosition position = infos.Item3; if (nbEntries % 2 == 0 && (position == Editor.ClickPosition.TopLeft || position == Editor.ClickPosition.BotLeft)) { targetCol -= nbEntries / 2; } else { targetCol -= (nbEntries - 1) / 2; } if (targetCol < 0) { targetCol = 0; } Debug.Log("MoveGate to (" + targetRow + ", " + targetCol + ")"); context.currentCircuit.MoveGate(sourceRow, sourceCol, targetRow, targetCol); context.CurrentState = _previousState; }
public override void OnProcessCircuitClick() { QCS.Circuit.GateStruct gateStruct = _selectedGate.gateStruct; int row = gateStruct.row; context.CurrentState = new ShowResult(context, row, _previousState); }
public override void OnEnter() { QCS.Circuit.GateStruct gateStruct = _selectedGate.gateStruct; //TODO : pas terminé ? int row = gateStruct.row; int col = gateStruct.col; Debug.Log("MoveGate from (" + row + ", " + col + ")"); }
public override void OnInsertGateClick() { QCS.Circuit.GateStruct gateStruct = _selectedGate.gateStruct; int row = gateStruct.row; int col = gateStruct.col; context.CurrentState = new SelectGateToInsert(context, row, col, _previousState); }
/// <summary> /// Transforme un circuit du module SerialisableClass en un circuit de la librairie QCS afin de pouvoir l'utiliser correctement. /// Celui-ci a besoin, pour être transformer, de la liste des portes par défauts, et des portes customs représenté sous la forme d'un dictionnaire. /// </summary> public static QCS.Circuit ToUsableCircuit(Circuit circuitSerialised, Dictionary <string, QCS.Gate> defaultGates, Dictionary <string, QCS.Gate> customGates) { QCS.Circuit circuitUsuable = new QCS.Circuit(); int nbCols = circuitSerialised.entries.Count; int nbRows = circuitSerialised.rows.Count; for (int indexEntry = 0; indexEntry < nbCols; indexEntry++) { QCS.Qubit usuableQubit = ToUsableQubit(circuitSerialised.entries [indexEntry]); QCS.Circuit.EntryStruct entryStruct = new QCS.Circuit.EntryStruct(indexEntry, usuableQubit); circuitUsuable.entries.Add(entryStruct); } for (int indexRow = 0; indexRow < nbRows; indexRow++) { circuitUsuable.rows.Add(new List <QCS.Circuit.GateStruct> ()); QCS.Gate gateUsuable; for (int indexCol = 0; indexCol < nbCols; indexCol += gateUsuable.NbEntries) { string nameGate = circuitSerialised.rows [indexRow].cols [indexCol]; if (defaultGates.ContainsKey(nameGate)) { gateUsuable = defaultGates [nameGate]; } else if (customGates.ContainsKey(nameGate)) { gateUsuable = customGates [nameGate]; } else { gateUsuable = QCS.Gate.IDENTITY; } QCS.Circuit.GateStruct gateStruct = new QCS.Circuit.GateStruct(indexRow, indexCol, gateUsuable); for (int indexEntry = 0; indexEntry < gateUsuable.NbEntries; indexEntry++) { circuitUsuable.rows [indexRow].Add(gateStruct); } } } return(circuitUsuable); }
public override void OnDeleteGateClick() { QCS.Circuit.GateStruct gateStruct = _selectedGate.gateStruct; int row = gateStruct.row; int col = gateStruct.col; context.currentCircuit.RemoveGate(row, col); context.CurrentState = _previousState; }
/// <summary> /// Fonction qui permet de selectionner les tuyaux lors du résultat afin de savoir ceux qui sont liés au tuyau demandé /// </summary> public override void OnProcessCircuitClick() { QCS.Circuit.GateStruct gateStruct = _selectedGate.gateStruct; int col = gateStruct.col; // ne pas toucher int numTuyau = col + 1; int code = context.TuyauxLiee(); int cas = context.isRelated(code); int choix = context.Choice(numTuyau, cas); Debug.Log("numTuyau :" + numTuyau + " code:" + code + " cas: " + cas + "choix: " + choix); int i = 0; int row = context.currentCircuit.NbRow; Debug.Log("ligne" + row); Debug.Log("col" + context.currentCircuit.NbCol); if (choix == 12) { for (i = 0; i < row; i++) { context.gridBoard.GetGateObject(i, 0).Select(); context.gridBoard.GetGateObject(i, 1).Select(); } } if (choix == 2) { for (i = 0; i < row; i++) { context.gridBoard.GetGateObject(i, 1).Select(); } } if (choix == 1) { for (i = 0; i < row; i++) { context.gridBoard.GetGateObject(i, 0).Select(); } } if (choix == 3) { for (i = 0; i < row; i++) { context.gridBoard.GetGateObject(i, 2).Select(); } } if (choix == 123) { for (i = 0; i < row; i++) { context.gridBoard.GetGateObject(i, 0).Select(); context.gridBoard.GetGateObject(i, 1).Select(); context.gridBoard.GetGateObject(i, 2).Select(); } } if (choix == 23) { for (i = 0; i < row; i++) { context.gridBoard.GetGateObject(i, 1).Select(); context.gridBoard.GetGateObject(i, 2).Select(); } } context.CurrentState = new ShowResult(context, row, col, _previousState, _selectedGate); }