
from qgis.core import (
    QgsLayoutSize,
    QgsUnitTypes,
    QgsLayoutPoint,
)


def fletch_canvas(self):
    if self.radioButton_6.isChecked():
        values_page = 'A4'
    else:
        values_page = 'A3'
    if self.radioButton_7.isChecked():
        page_rotate = 'Portrait'
    else:
        page_rotate = 'Landscape'

    if page_rotate == 'Portrait':
        if values_page == 'A4':
            self.template_parameters['Carte_2_size'] = QgsLayoutSize(50, 50, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(2.5, 20, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Carte_size'] = QgsLayoutSize(210, 297, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Carte_locals'] = QgsLayoutPoint(0, 0, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Titre_size'] = QgsLayoutSize(200, 8, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Titre_locals'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Sous_titre_size'] = QgsLayoutSize(200, 8, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(5, 10, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Logo_size'] = QgsLayoutSize(48, 17, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Logo_locals'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Logo_2_size'] = QgsLayoutSize(50, 20, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(5, 275, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Legande_size'] = QgsLayoutSize(405, 203, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Legande_locals'] = QgsLayoutPoint(133, 215, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Echelle_size'] = QgsLayoutSize(64, 7, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Echelle_locals'] = QgsLayoutPoint(3, 288, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Echelle_2_size'] = QgsLayoutSize(65, 15, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(3, 273, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Arrow_size'] = QgsLayoutSize(12, 12, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Arrow_locals'] = QgsLayoutPoint(196, 283, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Credit_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Credit_locals'] = QgsLayoutPoint(205, 125, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Source_size'] = QgsLayoutSize(100, 4, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Source_locals'] = QgsLayoutPoint(55, 292, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Carte_rotate'] = 0
            self.template_parameters['Carte_2_rotate'] = 0
            self.template_parameters['Legande_rotate'] = 0
            self.template_parameters['Arrow_rotate'] = 0
            self.template_parameters['Echelle_rotate'] = 0
            self.template_parameters['Logo_rotate'] = 0
            self.template_parameters['Titre_rotate'] = 0
            self.template_parameters['Credit_rotate'] = 270
            self.template_parameters['Source_rotate'] = 0
            self.template_parameters['Sous_titre_rotate'] = 0
            self.template_parameters['Echelle_2_rotate'] = 0
            self.template_parameters['Logo_2_rotate'] = 0
            self.template_parameters['Carte_frame'] = True
            self.template_parameters['Carte_2_frame'] = False
            self.template_parameters['Legande_frame'] = False
            self.template_parameters['Arrow_background'] = True
            self.template_parameters['Arrow_path'] = "NorthArrow_02.svg"
            self.template_parameters['Credit_alignment'] = 0x0002
            self.template_parameters['Source_alignment'] = 0x0002
        if values_page == 'A3':
            self.template_parameters['Carte_2_size'] = QgsLayoutSize(50, 50, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(2.5, 20, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Carte_size'] = QgsLayoutSize(297, 420, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Carte_locals'] = QgsLayoutPoint(0, 0, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Titre_size'] = QgsLayoutSize(286, 8, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Titre_locals'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Sous_titre_size'] = QgsLayoutSize(286, 8, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(5, 10, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Logo_size'] = QgsLayoutSize(48, 17, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Logo_locals'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Logo_2_size'] = QgsLayoutSize(50, 20, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(5, 370, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Legande_size'] = QgsLayoutSize(405, 203, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Legande_locals'] = QgsLayoutPoint(219, 324, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Echelle_size'] = QgsLayoutSize(64, 7, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Echelle_locals'] = QgsLayoutPoint(3, 410, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Echelle_2_size'] = QgsLayoutSize(65, 15, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(3, 395, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Arrow_size'] = QgsLayoutSize(24, 24, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Arrow_locals'] = QgsLayoutPoint(271, 394, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Credit_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Credit_locals'] = QgsLayoutPoint(291, 125, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Source_size'] = QgsLayoutSize(100, 4, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Source_locals'] = QgsLayoutPoint(98, 414, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Carte_rotate'] = 0
            self.template_parameters['Carte_2_rotate'] = 0
            self.template_parameters['Legande_rotate'] = 0
            self.template_parameters['Arrow_rotate'] = 0
            self.template_parameters['Echelle_rotate'] = 0
            self.template_parameters['Logo_rotate'] = 0
            self.template_parameters['Titre_rotate'] = 0
            self.template_parameters['Credit_rotate'] = 270
            self.template_parameters['Source_rotate'] = 0
            self.template_parameters['Sous_titre_rotate'] = 0
            self.template_parameters['Echelle_2_rotate'] = 0
            self.template_parameters['Logo_2_rotate'] = 0
            self.template_parameters['Logo_2_rotate'] = 0
            self.template_parameters['Carte_frame'] = True
            self.template_parameters['Carte_2_frame'] = False
            self.template_parameters['Legande_frame'] = False
            self.template_parameters['Arrow_background'] = True
            self.template_parameters['Arrow_path'] = "NorthArrow_02.svg"
            self.template_parameters['Credit_alignment'] = 0x0002
            self.template_parameters['Source_alignment'] = 0x0002

    if page_rotate == 'Landscape':
        if values_page == 'A3':
            self.template_parameters['Carte_2_size'] = QgsLayoutSize(100, 100, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(6, 23, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Carte_size'] = QgsLayoutSize(420, 297, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Carte_locals'] = QgsLayoutPoint(0, 0, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Titre_size'] = QgsLayoutSize(411, 8, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Titre_locals'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Sous_titre_size'] = QgsLayoutSize(411, 8, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(5, 10, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Logo_size'] = QgsLayoutSize(48, 17, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Logo_locals'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Logo_2_size'] = QgsLayoutSize(50, 20, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(5, 247, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Legande_size'] = QgsLayoutSize(405, 203, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Legande_locals'] = QgsLayoutPoint(341, 196, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Echelle_size'] = QgsLayoutSize(64, 7, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Echelle_locals'] = QgsLayoutPoint(3, 287, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Echelle_2_size'] = QgsLayoutSize(65, 15, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(3, 272, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Arrow_size'] = QgsLayoutSize(24, 24, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Arrow_locals'] = QgsLayoutPoint(394, 271, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Credit_size'] = QgsLayoutSize(100, 4, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Credit_locals'] = QgsLayoutPoint(414, 123, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Source_size'] = QgsLayoutSize(100, 4, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Source_locals'] = QgsLayoutPoint(185, 292, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Carte_rotate'] = 0
            self.template_parameters['Carte_2_rotate'] = 0
            self.template_parameters['Legande_rotate'] = 0
            self.template_parameters['Arrow_rotate'] = 0
            self.template_parameters['Echelle_rotate'] = 0
            self.template_parameters['Logo_rotate'] = 0
            self.template_parameters['Titre_rotate'] = 0
            self.template_parameters['Credit_rotate'] = 270
            self.template_parameters['Source_rotate'] = 0
            self.template_parameters['Sous_titre_rotate'] = 0
            self.template_parameters['Echelle_2_rotate'] = 0
            self.template_parameters['Logo_2_rotate'] = 0
            self.template_parameters['Logo_2_rotate'] = 0
            self.template_parameters['Carte_frame'] = True
            self.template_parameters['Carte_2_frame'] = False
            self.template_parameters['Legande_frame'] = False
            self.template_parameters['Arrow_background'] = True
            self.template_parameters['Arrow_path'] = "NorthArrow_02.svg"
            self.template_parameters['Credit_alignment'] = 0x0002
            self.template_parameters['Source_alignment'] = 0x0002
        if values_page == 'A4':
            self.template_parameters['Carte_2_size'] = QgsLayoutSize(100, 100, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(6, 23, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Carte_size'] = QgsLayoutSize(297, 210, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Carte_locals'] = QgsLayoutPoint(0, 0, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Titre_size'] = QgsLayoutSize(286, 8, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Titre_locals'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Sous_titre_size'] = QgsLayoutSize(286, 8, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(5, 10, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Logo_size'] = QgsLayoutSize(48, 17, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Logo_locals'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Logo_2_size'] = QgsLayoutSize(50, 20, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(5, 185, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Legande_size'] = QgsLayoutSize(405, 203, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Legande_locals'] = QgsLayoutPoint(231, 135, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Echelle_size'] = QgsLayoutSize(64, 7, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Echelle_locals'] = QgsLayoutPoint(3, 201, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Echelle_2_size'] = QgsLayoutSize(65, 15, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(3, 186, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Arrow_size'] = QgsLayoutSize(12, 12, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Arrow_locals'] = QgsLayoutPoint(283, 196, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Credit_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Credit_locals'] = QgsLayoutPoint(291.5, 123, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Source_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Source_locals'] = QgsLayoutPoint(98, 205, QgsUnitTypes.LayoutMillimeters)
            self.template_parameters['Carte_rotate'] = 0
            self.template_parameters['Carte_2_rotate'] = 0
            self.template_parameters['Legande_rotate'] = 0
            self.template_parameters['Arrow_rotate'] = 0
            self.template_parameters['Echelle_rotate'] = 0
            self.template_parameters['Logo_rotate'] = 0
            self.template_parameters['Titre_rotate'] = 0
            self.template_parameters['Credit_rotate'] = 270
            self.template_parameters['Source_rotate'] = 0
            self.template_parameters['Sous_titre_rotate'] = 0
            self.template_parameters['Echelle_2_rotate'] = 0
            self.template_parameters['Logo_2_rotate'] = 0
            self.template_parameters['Logo_2_rotate'] = 0
            self.template_parameters['Carte_frame'] = True
            self.template_parameters['Carte_2_frame'] = False
            self.template_parameters['Legande_frame'] = False
            self.template_parameters['Arrow_background'] = True
            self.template_parameters['Arrow_path'] = "NorthArrow_02.svg"
            self.template_parameters['Credit_alignment'] = 0x0002
            self.template_parameters['Source_alignment'] = 0x0002

    # Retour des info #
    return self.template_parameters
