import QtQuick 2.0
import QtQuick.Controls 2.0
import TcpSocket 2.0
import BCIManager 2.0
Item {
    property int hitIndex: -1
    property bool bStimulate: false
    property int responseTime: 10
    property bool bTest: true
    property bool bConnect: false;
    property var brainTrainForm: null


    property int currentIndexTenHz: 0
    property var imageFilesTenHz:
         [
             "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R01.png",
             "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R02.png",
             "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R03.png",
             "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R04.png",
             "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R05.png",
             "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R06.png",
             "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R07.png",
             "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R08.png",
             "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R09.png",
             "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R10.png",
             "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R11.png",
             "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R12.png",
             "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R13.png",
             "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R14.png",
             "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R15.png",
             "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R14.png",
             "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R13.png",
             "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R12.png",
             "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R11.png",
             "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R10.png",
             "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R09.png",
             "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R08.png",
             "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R07.png",
             "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R06.png",
             "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R05.png",
             "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R04.png",
             "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R03.png",
             "qrc:/DependFile/Source/brainTrain/upTest/upper_stretch_R02.png"
         ]

    property int currentIndexTwelevHz: 0
    property var imageFilesTwelevHz:
         [
             "qrc:/DependFile/Source/brainTrain/upTest2D/upper_stretch_R01.png",
             "qrc:/DependFile/Source/brainTrain/upTest2D/upper_stretch_R02.png",
             "qrc:/DependFile/Source/brainTrain/upTest2D/upper_stretch_R03.png",
             "qrc:/DependFile/Source/brainTrain/upTest2D/upper_stretch_R04.png",
             "qrc:/DependFile/Source/brainTrain/upTest2D/upper_stretch_R05.png",
             "qrc:/DependFile/Source/brainTrain/upTest2D/upper_stretch_R06.png",
             "qrc:/DependFile/Source/brainTrain/upTest2D/upper_stretch_R07.png"
         ]

    property int currentIndexFifteenHz: 0
    property var imageFilesFifteenHz:
         [
        "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R01.png",
        "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R02.png",
        "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R03.png",
        "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R04.png",
        "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R05.png",
        "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R06.png",
        "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R07.png",
        "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R08.png",
        "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R09.png",
        "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R10.png",
        "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R11.png",
        "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R12.png",
        "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R13.png",
        "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R14.png",
        "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R15.png",
        "qrc:/DependFile/Source/brainTrain/upTest3/upper_stretch_R16.png",
         ]


    function startStimulate()
    {
        animationTenHz.start();
        animationTwelveHz.start();
        animationFifteenHz.start();
        if(!bConnect)
        {
            clientSocket.connectToHost();
            bConnect = true;
        }else
        {
            clientSocket.writeBytes(getIntArr("1"));
        }
    }


    function stopStimulate()
    {
        if(animationTenHz.running)
        {
            animationTenHz.stop();
            flashingImageTenHz.opacity = 1;
        }
        if(animationTwelveHz.running)
        {
            animationTwelveHz.stop();
            flashingImageTwelveHz.opacity = 1;
        }
        if(animationFifteenHz.running)
        {
            animationFifteenHz.stop();
            flashingImageFifteenHz.opacity = 1;
        }
    }


    function clearHit()
    {
        if(hitIndex === 0)
        {
             ssvepTenHzTimer.stop();
             imageTenHz.source = imageFilesTenHz[0];
        }else if(hitIndex === 1)
        {
             ssvepTwelveHzTimer.stop();
             imageTwelveHz.source = imageFilesTwelevHz[0];
        }else if(hitIndex === 2)
        {
             ssvepFifteenHzTimer.stop();
             imageFifteenHz.source = imageFilesFifteenHz[0];
        }
        if(hitTimer.running)
        {
            hitTimer.stop();
        }
        hitIndex = -1;
    }

    Timer {
        id: hitTimer
        interval: responseTime*1000;
        repeat: false
        onTriggered: {
            clearHit();
            startStimulate();
        }
    }

    function ssvepHit(index)
    {
        if(!bStimulate)
        {
            return;
        }
        if(hitIndex !== -1)
        {
            return;
        }
        if(index === "0")
        {
            ssvepTenHzTimer.start();
            hitTimer.start();
            bci.startTrain(0,responseTime-1);
        }else if(index === "1")
        {
            ssvepTwelveHzTimer.start();
            hitTimer.start();
            bci.startTrain(1,responseTime-1);
        }else if(index === "2")
        {
            ssvepFifteenHzTimer.start();
            hitTimer.start();
            bci.startTrain(2,responseTime-1);
        }else
        {
            return;
        }
        hitIndex = index;
    }

    function getStr(intArr){
        var str = "";
        for(var i=0;i<intArr.length;i++)
            str += String.fromCharCode(intArr[i]);
        return str;
    }

    function getIntArr(str){
        var ret = [];
        for(var i=0;i<str.length;i++)
            ret.push(str.charCodeAt(i));
        return ret;
    }

    function onExit(){
        if(bConnect)
        {
            clientSocket.writeBytes(getIntArr("2"));
            return true;
        }
        return false;
    }
    function onConnectAndExit(){
        clientSocket.connectToHost();
        clientSocket.writeBytes(getIntArr("2"));
    }

    Component.onCompleted:
    {
        bci.initTrain();
    }

    TcpSocket{
        id: clientSocket
        peer: "127.0.0.1"
        port: 8099
        onBytesReceived:
        {
            var cmd = getStr(bytes);
            console.info("Client received: " + cmd);
            if(cmd !== "0" && cmd !== "1" && cmd !== "2")
            {
                return;
            }
            ssvepHit(cmd);
            stopStimulate();

        }
        onConnected:
        {
            console.info("Client socket connected");
            writeBytes(getIntArr("1"));
        }
        onDisconnected:
        {
            console.info("Client socket disconnected");
            bConnect = false;
        }
        onPeerChanged:
        {
            console.info("Client socket peer changed: " + peer);
        }
        onPortChanged:
        {
            console.info("Client socket port changed: " + port);
        }
        onError:
        {
            console.info("Client socket disconnected")
        }
    }
    BCIManager
    {
        id:bci;
    }

    Rectangle{
            anchors.top: parent.top
            anchors.topMargin: 42
            anchors.left: parent.left
            anchors.leftMargin: 100
            anchors.right: parent.right
            anchors.rightMargin: 100
            anchors.bottom: parent.bottom
            anchors.bottomMargin: 178
            Row
            {
               anchors.centerIn: parent
               spacing: 80
               Rectangle
               {
                   id:ssvepTenHz
                   width: 520;
                   height: 760;
                   Rectangle
                   {
                        width: 520;
                        height: 450;
                        anchors.top: parent.top
                        color:"#F9FAFD";
                        border.width: 1
                        border.color: "#ADCFDD"
                        radius: 20;
                        Rectangle
                        {
                             id:tenHzHit
                             visible: ssvepTenHzTimer.running
                             width: 100;
                             height: 36;
                             anchors.top: parent.top;
                             anchors.topMargin: 40;
                             anchors.right: parent.right;
                             anchors.rightMargin: 40;
                             color:Qt.rgba(52,196,163,0.1);
                             border.width: 1;
                             border.color: "#34C4A3";
                             radius: 18;

                             Rectangle
                             {
                                  width: 14;
                                  height: 14;
                                  anchors.top: parent.top;
                                  anchors.topMargin: 11;
                                  anchors.left: parent.left;
                                  anchors.leftMargin: 14;
                                  color:"#34C4A3";
                                  border.width: 1;
                                  border.color: "#34C4A3";
                                  radius: 7;
                             }
                             Text {
                                 text: qsTr("训练中")
                                 width: 72;
                                 height: 26;
                                 anchors.top: parent.top;
                                 anchors.topMargin: 4;
                                 anchors.left: parent.left;
                                 anchors.leftMargin: 32;
                                 color: "#10275A";
                                 horizontalAlignment: Text.AlignLeft
                                 verticalAlignment: Text.AlignVCenter
                                 font.pixelSize: 18
                                 font.family: "Medium"
                             }

                        }

                        Text {
                            text: qsTr("上肢训练")
                            width: 144;
                            height: 46;
                            anchors.top: parent.top;
                            anchors.topMargin: 34;
                            anchors.left: parent.left;
                            anchors.leftMargin: 40;
                            color: "#10275A";
                            horizontalAlignment: Text.AlignLeft
                            verticalAlignment: Text.AlignVCenter
                            font.pixelSize: 36;
                            font.family: "Medium";
                            font.bold: true;
                        }

                        Text {
                            text: qsTr("Upper Limbs Training")
                            width: 194;
                            height: 28;
                            anchors.top: parent.top;
                            anchors.topMargin: 84;
                            anchors.left: parent.left;
                            anchors.leftMargin: 40;
                            color: "#8586A9";
                            horizontalAlignment: Text.AlignLeft
                            verticalAlignment: Text.AlignVCenter
                            font.pixelSize: 20;
                            font.family: "Medium";
                        }
                        Image {
                            id: flashingImageTenHz
                            width: 238;
                            height: 238;
                            anchors.top: parent.top;
                            anchors.topMargin: 162;
                            anchors.left: parent.left;
                            anchors.leftMargin: 141;
                            source: "qrc:/DependFile/Source/brainTrain/vision_img_board.png"
                            opacity: 1
                            SequentialAnimation on opacity {
                                id: animationTenHz
                                running: false;
                                loops: Animation.Infinite
                                NumberAnimation { to: 0; duration: 50 }
                                NumberAnimation { to: 1; duration: 50 }
                            }
                        }
                   }
                   Item {
                       width: 520;
                       height: 280;
                       anchors.bottom: parent.bottom
                       Timer {
                           id: ssvepTenHzTimer
                           interval: 70;
                           repeat: true
                           onTriggered: {
                               currentIndexTenHz = (currentIndexTenHz + 1) % imageFilesTenHz.length;
                               imageTenHz.source = imageFilesTenHz[currentIndexTenHz];
                           }
                       }
                       Image {
                           id: imageTenHz
                           anchors.centerIn: parent
                           source: imageFilesTenHz[0]
                       }
                       Image {
                           visible: !ssvepTenHzTimer.running
                           anchors.centerIn: parent
                           source: "qrc:/DependFile/Source/brainTrain/vision_btn_start.png"
                           z:1
                       }
                   }
               }
               Rectangle
               {
                   id:ssvepTwelveHz
                   width: 520;
                   height: 760;
                   Rectangle
                   {
                        width: 520;
                        height: 450;
                        anchors.top: parent.top
                        color:"#F9FAFD";
                        border.width: 1
                        border.color: "#ADCFDD"
                        radius: 20;
                        Rectangle
                        {
                             id:twelveHzHit
                             visible: ssvepTwelveHzTimer.running
                             width: 100;
                             height: 36;
                             anchors.top: parent.top;
                             anchors.topMargin: 40;
                             anchors.right: parent.right;
                             anchors.rightMargin: 40;
                             color:Qt.rgba(52,196,163,0.1);
                             border.width: 1;
                             border.color: "#34C4A3";
                             radius: 18;

                             Rectangle
                             {
                                  width: 14;
                                  height: 14;
                                  anchors.top: parent.top;
                                  anchors.topMargin: 11;
                                  anchors.left: parent.left;
                                  anchors.leftMargin: 14;
                                  color:"#34C4A3";
                                  border.width: 1;
                                  border.color: "#34C4A3";
                                  radius: 7;
                             }
                             Text {
                                 text: qsTr("训练中")
                                 width: 72;
                                 height: 26;
                                 anchors.top: parent.top;
                                 anchors.topMargin: 4;
                                 anchors.left: parent.left;
                                 anchors.leftMargin: 32;
                                 color: "#10275A";
                                 horizontalAlignment: Text.AlignLeft
                                 verticalAlignment: Text.AlignVCenter
                                 font.pixelSize: 18
                                 font.family: "Medium"
                             }

                        }

                        Text {
                            text: qsTr("下肢训练")
                            width: 144;
                            height: 46;
                            anchors.top: parent.top;
                            anchors.topMargin: 34;
                            anchors.left: parent.left;
                            anchors.leftMargin: 40;
                            color: "#10275A";
                            horizontalAlignment: Text.AlignLeft
                            verticalAlignment: Text.AlignVCenter
                            font.pixelSize: 36;
                            font.family: "Medium";
                            font.bold: true;
                        }

                        Text {
                            text: qsTr("Lower Limbs Training")
                            width: 194;
                            height: 28;
                            anchors.top: parent.top;
                            anchors.topMargin: 84;
                            anchors.left: parent.left;
                            anchors.leftMargin: 40;
                            color: "#8586A9";
                            horizontalAlignment: Text.AlignLeft
                            verticalAlignment: Text.AlignVCenter
                            font.pixelSize: 20;
                            font.family: "Medium";
                        }
                        Image {
                            id: flashingImageTwelveHz
                            width: 238;
                            height: 238;
                            anchors.top: parent.top;
                            anchors.topMargin: 162;
                            anchors.left: parent.left;
                            anchors.leftMargin: 141;
                            source: "qrc:/DependFile/Source/brainTrain/vision_img_board.png"
                            opacity: 1
                            SequentialAnimation on opacity {
                                id: animationTwelveHz
                                running: false;
                                loops: Animation.Infinite
                                NumberAnimation { to: 0; duration: 42 }
                                NumberAnimation { to: 1; duration: 42 }
                            }
                        }
                   }
                   Item {
                       width: 520;
                       height: 280;
                       anchors.bottom: parent.bottom
                       Timer {
                           id: ssvepTwelveHzTimer
                           interval: 30;
                           repeat: true
                           onTriggered: {
                               currentIndexTwelevHz = (currentIndexTwelevHz + 1) % imageFilesTwelevHz.length;
                               imageTwelveHz.source = imageFilesTwelevHz[currentIndexTwelevHz];
                           }
                       }
                       Image {
                           id: imageTwelveHz
                           anchors.centerIn: parent
                           source: imageFilesTwelevHz[0]
                       }
                       Image {
                           visible: !ssvepTwelveHzTimer.running
                           anchors.centerIn: parent
                           source: "qrc:/DependFile/Source/brainTrain/vision_btn_start.png"
                           z:1
                       }
                   }
               }
               Rectangle
               {
                   id:ssvepFifteenHz
                   width: 520;
                   height: 760;
                   Rectangle
                   {
                        width: 520;
                        height: 450;
                        anchors.top: parent.top
                        color:"#F9FAFD";
                        border.width: 1
                        border.color: "#ADCFDD"
                        radius: 20;
                        Rectangle
                        {
                             id:fifteenHzHit
                             visible: ssvepFifteenHzTimer.running
                             width: 100;
                             height: 36;
                             anchors.top: parent.top;
                             anchors.topMargin: 40;
                             anchors.right: parent.right;
                             anchors.rightMargin: 40;
                             color:Qt.rgba(52,196,163,0.1);
                             border.width: 1;
                             border.color: "#34C4A3";
                             radius: 18;

                             Rectangle
                             {
                                  width: 14;
                                  height: 14;
                                  anchors.top: parent.top;
                                  anchors.topMargin: 11;
                                  anchors.left: parent.left;
                                  anchors.leftMargin: 14;
                                  color:"#34C4A3";
                                  border.width: 1;
                                  border.color: "#34C4A3";
                                  radius: 7;
                             }
                             Text {
                                 text: qsTr("训练中")
                                 width: 72;
                                 height: 26;
                                 anchors.top: parent.top;
                                 anchors.topMargin: 4;
                                 anchors.left: parent.left;
                                 anchors.leftMargin: 32;
                                 color: "#10275A";
                                 horizontalAlignment: Text.AlignLeft
                                 verticalAlignment: Text.AlignVCenter
                                 font.pixelSize: 18
                                 font.family: "Medium"
                             }

                        }

                        Text {
                            text: qsTr("上下肢训练")
                            width: 144;
                            height: 46;
                            anchors.top: parent.top;
                            anchors.topMargin: 34;
                            anchors.left: parent.left;
                            anchors.leftMargin: 40;
                            color: "#10275A";
                            horizontalAlignment: Text.AlignLeft
                            verticalAlignment: Text.AlignVCenter
                            font.pixelSize: 36;
                            font.family: "Medium";
                            font.bold: true;
                        }

                        Text {
                            text: qsTr("Upper and Lower Limb")
                            width: 194;
                            height: 28;
                            anchors.top: parent.top;
                            anchors.topMargin: 84;
                            anchors.left: parent.left;
                            anchors.leftMargin: 40;
                            color: "#8586A9";
                            horizontalAlignment: Text.AlignLeft
                            verticalAlignment: Text.AlignVCenter
                            font.pixelSize: 20;
                            font.family: "Medium";
                        }
                        Image {
                            id: flashingImageFifteenHz
                            width: 238;
                            height: 238;
                            anchors.top: parent.top;
                            anchors.topMargin: 162;
                            anchors.left: parent.left;
                            anchors.leftMargin: 141;
                            source: "qrc:/DependFile/Source/brainTrain/vision_img_board.png"
                            opacity: 1
                            SequentialAnimation on opacity {
                                id: animationFifteenHz
                                running: false;
                                loops: Animation.Infinite
                                NumberAnimation { to: 0; duration: 33 }
                                NumberAnimation { to: 1; duration: 33 }
                            }
                        }
                   }
                   Item {
                       width: 520;
                       height: 280;
                       anchors.bottom: parent.bottom
                       Timer {
                           id: ssvepFifteenHzTimer
                           interval: 30;
                           repeat: true
                           onTriggered: {
                               currentIndexFifteenHz = (currentIndexFifteenHz + 1) % imageFilesFifteenHz.length;
                               imageFifteenHz.source = imageFilesFifteenHz[currentIndexFifteenHz];
                           }
                       }
                       Image {
                           id: imageFifteenHz
                           anchors.centerIn: parent
                           source: imageFilesFifteenHz[0]
                       }
                       Image {
                           visible: !ssvepFifteenHzTimer.running
                           anchors.centerIn: parent
                           source: "qrc:/DependFile/Source/brainTrain/vision_btn_start.png"
                           z:1
                       }
                   }
               }
            }
    }


    Rectangle
    {
         width: 286;
         height: 88;
         anchors.bottom: parent.bottom;
         anchors.bottomMargin: 60;
         anchors.left: parent.left;
         anchors.leftMargin: 817;
         color:"#41B962";
         border.width: 1
         border.color: "#41B962"
         radius: 10;


         Text {
             id:stimulateText
             text: qsTr("开始训练")
             width: 144;
             height: 51;
             anchors.top: parent.top;
             anchors.topMargin: 18;
             anchors.left: parent.left;
             anchors.leftMargin: 71;
             color: "#FFFFFF";
             horizontalAlignment: Text.AlignHCenter
             verticalAlignment: Text.AlignVCenter
             font.pixelSize: 36;
             font.family: "Medium";
         }
         MouseArea
            {
                anchors.fill: parent
                onClicked: {
                    if(bStimulate)
                    {
                        stimulateText.text = "继续";
                        stopStimulate();
                        clearHit();
                    }else
                    {
                        stimulateText.text = "暂停";
                        startStimulate();
                    }
                    bStimulate = !bStimulate;
                }
            }
    }

    Rectangle
    {
         width: 86;
         height: 88;
         visible: bTest
         anchors.bottom: parent.bottom;
         anchors.bottomMargin: 60;
         anchors.left: parent.left;
         anchors.leftMargin: 1200;
         color:"#41B962";
         border.width: 1
         border.color: "#41B962"
         radius: 10;

         Text {
             text: qsTr("0")
             width: 86;
             height: 51;
             anchors.top: parent.top;
             anchors.topMargin: 18;
             anchors.left: parent.left;
             anchors.leftMargin: 0;
             color: "#FFFFFF";
             horizontalAlignment: Text.AlignHCenter
             verticalAlignment: Text.AlignVCenter
             font.pixelSize: 36;
             font.family: "Medium";
         }
         MouseArea
            {
                anchors.fill: parent
                onClicked: {
                    ssvepHit("0");
                    stopStimulate();
                }
            }
    }

    Rectangle
    {
         width: 86;
         height: 88;
         visible: bTest
         anchors.bottom: parent.bottom;
         anchors.bottomMargin: 60;
         anchors.left: parent.left;
         anchors.leftMargin: 1300;
         color:"#41B962";
         border.width: 1
         border.color: "#41B962"
         radius: 10;

         Text {
             text: qsTr("1")
             width: 86;
             height: 51;
             anchors.top: parent.top;
             anchors.topMargin: 18;
             anchors.left: parent.left;
             anchors.leftMargin: 0;
             color: "#FFFFFF";
             horizontalAlignment: Text.AlignHCenter
             verticalAlignment: Text.AlignVCenter
             font.pixelSize: 36;
             font.family: "Medium";
         }
         MouseArea
            {
                anchors.fill: parent
                onClicked: {
                    ssvepHit("1");
                    stopStimulate();
                }
            }
    }

    Rectangle
    {
         width: 86;
         height: 88;
         visible: bTest
         anchors.bottom: parent.bottom;
         anchors.bottomMargin: 60;
         anchors.left: parent.left;
         anchors.leftMargin: 1400;
         color:"#41B962";
         border.width: 1
         border.color: "#41B962"
         radius: 10;

         Text {
             text: qsTr("2")
             width: 86;
             height: 51;
             anchors.top: parent.top;
             anchors.topMargin: 18;
             anchors.left: parent.left;
             anchors.leftMargin: 0;
             color: "#FFFFFF";
             horizontalAlignment: Text.AlignHCenter
             verticalAlignment: Text.AlignVCenter
             font.pixelSize: 36;
             font.family: "Medium";
         }
         MouseArea
            {
                anchors.fill: parent
                onClicked: {
                    ssvepHit("2");
                    stopStimulate();
                }
            }
    }
    Rectangle
    {
         width: 160;
         height: 70;
         anchors.bottom: parent.bottom;
         anchors.bottomMargin: 60;
         anchors.left: parent.left;
         anchors.leftMargin: 100;
         color:"#EEF7FD";
//         border.width: 1
//         border.color: "#41B962"
         radius: 10;


         Text {
             id:impedance
             text: qsTr("阻抗")
             width: 31;
             height: 32;
             anchors.top: parent.top;
             anchors.topMargin: 18;
             anchors.left: parent.left;
             anchors.leftMargin: 71;
             color: "#0D9DDB";
             horizontalAlignment: Text.AlignHCenter
             verticalAlignment: Text.AlignVCenter
             font.pixelSize: 32;
             font.family: "Medium";
         }
         Image {
                id:impedance_image
                width:32
                height: 32
                anchors.top: parent.top;
                anchors.topMargin: 18;
                anchors.left: parent.left;
                anchors.leftMargin: 20;
                source: "qrc:/DependFile/Source/brainTrain/btn_Z.png"
            }
         MouseArea
            {
                anchors.fill: parent
                onClicked: {
                    popimpedance.show()


                }

            }
    }
    PopImpedance{
        id:popimpedance
    }







}