示例#1
0
        public void AddGate(Gate gate)
        {
            //StepModel currentStep = _steps.Count > 0 ? _steps[_steps.Count - 1] : null;
            //if (currentStep != null && currentStep.HasPlace(gate.Begin, gate.End))
            //{
            //    currentStep.SetGate(gate);
            //}
            //else
            //{

            if (_stepForNewGates == -1)
            {
                StepModel step = new StepModel(Registers);
                step.SetGate(gate);
                _steps.Add(step);
            }
            else
            {
                InsertStepRight(_stepForNewGates);
                _stepForNewGates++;
                _steps[_stepForNewGates].SetGate(gate);
            }

            //}
        }
示例#2
0
        public bool MeasurementExist(int column)
        {
            StepModel step = _steps[column];

            foreach (Gate g in step.Gates)
            {
                if (g.Name == GateName.Measure)
                {
                    return(true);
                }
            }
            return(false);
        }
示例#3
0
        public bool CanStepBack(int column)
        {
            StepModel step = _steps[column];

            foreach (Gate g in step.Gates)
            {
                if (g.Name == GateName.Measure)
                {
                    return(false);
                }
                if (g.Name == GateName.Parametric)
                {
                    ParametricGate cg = g as ParametricGate;
                    if (cg.InverseMethod == null)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
 private string GenerateStepCode(ComputerModel model, StepModel step, int column, string indent)
 {
     StringBuilder builder = new StringBuilder();
     string gateString;
     Gate lastGate = null;
     foreach (Gate gate in step.Gates)
     {
         if (gate != lastGate)
         {
             gateString = GenerateGateCode(model, gate, column, indent);
             if (gateString.Length > 0)
             {
                 builder.Append(indent).AppendLine(gateString);
             }
         }
         lastGate = gate;
     }
     return builder.ToString();
 }
        public void AddGate(Gate gate)
        {
            //StepModel currentStep = _steps.Count > 0 ? _steps[_steps.Count - 1] : null;
            //if (currentStep != null && currentStep.HasPlace(gate.Begin, gate.End))
            //{
            //    currentStep.SetGate(gate);
            //}
            //else
            //{

            if (_stepForNewGates == -1)
            {
                StepModel step = new StepModel(Registers);
                step.SetGate(gate);
                _steps.Add(step);
            }
            else
            {
                InsertStepRight(_stepForNewGates);
                _stepForNewGates++;
                _steps[_stepForNewGates].SetGate(gate);
            }

            //}
        }