%load_ext autoreload
%autoreload 2

import qiskit_metal as metal
from qiskit_metal import designs, draw
from qiskit_metal import MetalGUI, Dict, open_docs

%metal_heading Welcome to Qiskit Metal!

design = designs.DesignPlanar()
gui = MetalGUI(design)

# Select a QComponent to create (The QComponent is a python class named `TransmonPocket`)
from qiskit_metal.qlibrary.qubits.transmon_pocket import TransmonPocket

# Create a new qcomponent object  
q1 = TransmonPocket(design)
gui.rebuild()  # rebuild the design and plot 

# Delete all QComponents in our design, which in this case is just the transmon pocket "Pocket_1"
design.delete_all_components()
gui.rebuild()  # rebuild the design and plot 

# Create a new qcomponent object with name 'Q1' 
q1 = TransmonPocket(design, 'Q1')
gui.rebuild()  # rebuild the design and plot 

q1

TransmonPocket.get_template_options(design)

# Change options
q1.options.pos_x = '2.0 mm'
q1.options.pos_y = '2.0 mm'
q1.options.pad_height = '250 um'
q1.options.pad_width  = '300 um'

# Update the geoemtry and render to the gui, since we changed the options
gui.rebuild()

# Copy q1 and place the new Qcomponent ("q1_copy") at (-2,2):
q1_copy = design.copy_qcomponent(q1, 'Q1_copy')
q1_copy.options['pos_x']='-2.0mm'
gui.rebuild()
gui.autoscale()

# Let's copy the two QComponents and change the y-coordinates of the copies to both be -2:
newcopies = design.copy_multiple_qcomponents([q1, q1_copy], ['Q3', 'Q4'], [dict(pos_y='-2.0mm'), dict(pos_y='-2.0mm')])
gui.rebuild()
gui.autoscale()

design.delete_component('Q1')
gui.rebuild()
gui.autoscale()

design._delete_component(3)
gui.rebuild()
gui.autoscale()

design.rename_component(4,'Q_three') # rename "Q3" to "Q_three"
design.rename_component(5,'Q_four') # rename "Q4" to "Q_four"

design.overwrite_enabled = True

gui.main_window.close()

