#include "ris_setting.h"
#include "ui_ris_setting.h"


////pokracovani kodu z ris_setting    === tato cast se tyka metody cis


void ris_setting::cis_btn_clicked(){

    if(this->ciss==NULL && this->image_ref!=NULL){
        my_image * pom=form->apply_filt(image_ref);
        QTime time;
        time.start();

        ciss=new cis(pom,form->Count_Cis_pocet,form->Count_Cis_dif);

        Time_C_ref = time.elapsed();
        ui->label_time_cis->setText(QString::number(Time_C_ref));

        delete pom;
        CanCis_Run=true;
        ui->Btn_cis->setEnabled(false);

        if(this->image!=NULL)ui->Btn_cis_start->setEnabled(true);
        std::cout<<"CiSS trida vytvorena \n"<<std::endl;
    }
}

void ris_setting::cis_btn_run_clicked(){
    if(CanCis_Run)
        {
            std::cout<<"CISS trida zacina hledat \n"<<std::endl;
            this->ui->Btn_cis_start->setEnabled(false);
            my_image * pom=form->apply_filt(image);
            QTime time;
            time.start();

            ciss->find(pom);

            Time_C = time.elapsed();
            ui->label_time_cis_find->setText(QString::number(Time_C));

            delete pom;
            std::vector<BOD> ff(ciss->body.begin(),ciss->body.begin()+10+1);
            this->position_ciss=ff;
            this->ui->Btn_cis_show->setEnabled(true);
            if(this->CanRisCis_Run)
                    this->ui->Btn_riscis_start->setEnabled(true);
            this->ResultIsValid_ciss=true;
            std::cout<<"CISS trida hledala \n"<<std::endl;
        }
}


void ris_setting::cis_btn_show_clicked(){
    if(ResultIsValid_ciss){
        show_point_on_image(this->image_ref,this->position_ciss,this->image->Width());
    }
    std::cout<<"Zobrazil jsem \n"<<std::endl;

}


/////////////////////////////////////////////////////////////////
////////////////CIS + RASS
////////////////////////////////////////////////////////////////

void ris_setting::riscis_btn_clicked(){
    if(this->riscis==NULL && this->image_ref!=NULL){
        my_image * pom=form->apply_filt(image_ref);

        QTime time;
        time.start();

        riscis=new ris(pom,form->Count_Cis2Ris_pocet,form->Count_Cis2Ris_delka);

        int difference = time.elapsed();
        ui->label_time_riscis->setText(QString::number(difference));

        delete pom;
        CanRisCis_Run=true;
        ui->Btn_riscis->setEnabled(false);

        if(this->image!=NULL && this->ResultIsValid_ciss)ui->Btn_riscis_start->setEnabled(true);
        std::cout<<"RIS+CIS trida vytvorena \n"<<std::endl;
    }
}

void ris_setting::riscis_btn_run_clicked(){
    if(CanRisCis_Run)
        {
            std::cout<<"RISS+CISS trida zacina hledat \n"<<std::endl;
            this->ui->Btn_riscis_start->setEnabled(false);
            my_image* pom=form->apply_filt(image);

            QTime time;
            time.start();

            riscis->find(pom,this->position_ciss);

            Time_RC = time.elapsed();
            ui->label_time_riscis_find->setText(QString::number(Time_RC));


            std::vector<BOD> ff(riscis->body.begin(),riscis->body.begin()+form->Count_Cis2Ris_CIS+1);
            this->position_riscis=ff;
            this->ui->Btn_riscis_show->setEnabled(true);

            this->ResultIsValid_rissciss=true;
            std::cout<<"RIS+CISS trida hledala \n"<<std::endl;
        }
}

void ris_setting::riscis_btn_show_clicked(){
    if(ResultIsValid_rissciss){
        show_point_on_image(this->image_ref,this->position_riscis,this->image->Width());
    }
    std::cout<<"Zobrazil jsem \n"<<std::endl;

}
