#include "guipertinency.h"

GUIpertinency::GUIpertinency(Ui_MainWindow *ui) { this->ui = ui; }

void GUIpertinency::onConnectionChange(bool stat) {
  if (stat) {
    this->ui->connectButton->setEnabled(false);
    this->ui->disconnectButton->setEnabled(true);
    this->ui->playButton->setEnabled(true);
    this->ui->stopButton->setEnabled(false);
    this->ui->snapshotButton->setEnabled(true);
    this->ui->setAllButton->setEnabled(true);
    this->ui->setRegsButton->setEnabled(true);
    this->ui->defaultSettButton->setEnabled(true);

    this->enableExposure(true);
    this->enableGain(true);

    this->ui->saveCMOSsettings->setEnabled(true);
    this->ui->loadCMOSsettings->setEnabled(true);

    this->ui->setLineSelectMode->setEnabled(true);
  } else {
    this->ui->connectButton->setEnabled(true);
    this->ui->disconnectButton->setEnabled(false);
    this->ui->playButton->setEnabled(false);
    this->ui->stopButton->setEnabled(false);
    this->ui->snapshotButton->setEnabled(false);
    this->ui->setAllButton->setEnabled(false);
    this->ui->setRegsButton->setEnabled(false);
    this->ui->actionNextTest->setEnabled(false);
    this->ui->defaultSettButton->setEnabled(false);

    this->enableAEC(false);
    this->enableAGC(false);
    this->enableHDR(false);
    this->enableROI(false);
    this->enableBrightness(false);
    this->enableExposure(false);
    this->enableGain(false);
    this->enableBinning(false);
    this->enableFlip(false);
    this->enableTest(false);

    this->ui->saveCMOSsettings->setEnabled(false);
    this->ui->loadCMOSsettings->setEnabled(false);
    this->ui->setLineSelectMode->setEnabled(false);
  }
}

void GUIpertinency::onContinuosTransChange(bool stat) {
  if (stat) {
    this->ui->playButton->setEnabled(false);
    this->ui->stopButton->setEnabled(true);
    this->ui->snapshotButton->setEnabled(false);
  } else {
    this->ui->playButton->setEnabled(true);
    this->ui->stopButton->setEnabled(false);
    this->ui->snapshotButton->setEnabled(true);
  }
}

void GUIpertinency::enableAEC(bool stat) {
  this->ui->AECCheck->setEnabled(stat);
  this->ui->setAECButton->setEnabled(stat);
  this->ui->refreshAEC->setEnabled(stat);
}

void GUIpertinency::enableAGC(bool stat) {
  this->ui->AGCCheck->setEnabled(stat);
  this->ui->setAGCButton->setEnabled(stat);
  this->ui->refreshAGC->setEnabled(stat);
}

void GUIpertinency::enableHDR(bool stat) {
  this->ui->HDRCheck->setEnabled(stat);
  this->ui->setHDRButton->setEnabled(stat);
  this->ui->refreshHDR->setEnabled(stat);
}

void GUIpertinency::enableROI(bool stat) {
  this->ui->ROIlabel->setEnabled(stat);
  this->ui->setROIButton->setEnabled(stat);
  this->ui->refreshROI->setEnabled(stat);
}

void GUIpertinency::enableBrightness(bool stat) {
  this->ui->brightLabel->setEnabled(stat);
  this->ui->brightnessSpin->setEnabled(stat);
  this->ui->setBrightnessButton->setEnabled(stat);
  this->ui->refreshBright->setEnabled(stat);
}

void GUIpertinency::enableExposure(bool stat) {
  this->ui->exposureLabel->setEnabled(stat);
  this->ui->exposureSpin->setEnabled(stat);
  this->ui->setExposureButton->setEnabled(stat);
  this->ui->refreshExposure->setEnabled(stat);
}

void GUIpertinency::enableGain(bool stat) {
  this->ui->gainSpin->setEnabled(stat);
  this->ui->gainLabel->setEnabled(stat);
  this->ui->setGainButton->setEnabled(stat);
  this->ui->refreshGain->setEnabled(stat);
}

void GUIpertinency::enableBinning(bool stat) {
  this->ui->binColBox->setEnabled(stat);
  this->ui->binColLabel->setEnabled(stat);
  this->ui->binRowBox->setEnabled(stat);
  this->ui->binRowLabel->setEnabled(stat);
  this->ui->binningLabel->setEnabled(stat);
  this->ui->setBinningButton->setEnabled(stat);
  this->ui->refreshBinning->setEnabled(stat);
}

void GUIpertinency::enableFlip(bool stat) {
  this->ui->flipColBox->setEnabled(stat);
  this->ui->flipLabel->setEnabled(stat);
  this->ui->flipRowBox->setEnabled(stat);
  this->ui->setFlipButton->setEnabled(stat);
  this->ui->refreshFlip->setEnabled(stat);
}

void GUIpertinency::onScaleChange() {
  if (this->ui->imageScaleSelect->currentIndex() == 4) {
    this->ui->imageScaleArb->setEnabled(true);
  } else {
    this->ui->imageScaleArb->setEnabled(false);
  }
}

void GUIpertinency::enableTest(bool stat) {
  this->ui->actionTestMode->setEnabled(stat);
}
