dlggain.cpp 5.12 KB
Newer Older
Alexander Steffens's avatar
Alexander Steffens committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
#include <QMessageBox>
#include "dlggain.h"
#include "dlglog.h"
#include "maroc_def.h"
#include "ui_dlggain.h"
#include "messages.h"

DlgGain::DlgGain(QWidget *parent, QObject *part) :
    QDialog(parent),
    ui(new Ui::DlgGain)
{
    Partner = part;
    ui->setupUi(this);

    connect(this,      SIGNAL(OSetValue(int,int,QVariant)), Partner,SLOT(ISetValue(int,int,QVariant)));
    connect(this,      SIGNAL(OGetValue(int,int)),          Partner,SLOT(IGetValue(int,int)));
    connect(Partner,   SIGNAL(OSetValue(int,int,QVariant)), this,   SLOT(ISetValue(int,int,QVariant)));


    QString str = "Gain";
    this->setWindowTitle(str);

    sbAry[0]    = ui->sb00;
    sbAry[1]    = ui->sb01;
    sbAry[2]    = ui->sb02;
    sbAry[3]    = ui->sb03;
    sbAry[4]    = ui->sb04;
    sbAry[5]    = ui->sb05;
    sbAry[6]    = ui->sb06;
    sbAry[7]    = ui->sb07;
    sbAry[8]    = ui->sb08;
    sbAry[9]    = ui->sb09;
    sbAry[10]    = ui->sb10;
    sbAry[11]    = ui->sb11;
    sbAry[12]    = ui->sb12;
    sbAry[13]    = ui->sb13;
    sbAry[14]    = ui->sb14;
    sbAry[15]    = ui->sb15;
    sbAry[16]    = ui->sb16;
    sbAry[17]    = ui->sb17;
    sbAry[18]    = ui->sb18;
    sbAry[19]    = ui->sb19;
    sbAry[20]    = ui->sb20;
    sbAry[21]    = ui->sb21;
    sbAry[22]    = ui->sb22;
    sbAry[23]    = ui->sb23;
    sbAry[24]    = ui->sb24;
    sbAry[25]    = ui->sb25;
    sbAry[26]    = ui->sb26;
    sbAry[27]    = ui->sb27;
    sbAry[28]    = ui->sb28;
    sbAry[29]    = ui->sb29;
    sbAry[30]    = ui->sb30;
    sbAry[31]    = ui->sb31;
    sbAry[32]    = ui->sb32;
    sbAry[33]    = ui->sb33;
    sbAry[34]    = ui->sb34;
    sbAry[35]    = ui->sb35;
    sbAry[36]    = ui->sb36;
    sbAry[37]    = ui->sb37;
    sbAry[38]    = ui->sb38;
    sbAry[39]    = ui->sb39;
    sbAry[40]    = ui->sb40;
    sbAry[41]    = ui->sb41;
    sbAry[42]    = ui->sb42;
    sbAry[43]    = ui->sb43;
    sbAry[44]    = ui->sb44;
    sbAry[45]    = ui->sb45;
    sbAry[46]    = ui->sb46;
    sbAry[47]    = ui->sb47;
    sbAry[48]    = ui->sb48;
    sbAry[49]    = ui->sb49;
    sbAry[50]    = ui->sb50;
    sbAry[51]    = ui->sb51;
    sbAry[52]    = ui->sb52;
    sbAry[53]    = ui->sb53;
    sbAry[54]    = ui->sb54;
    sbAry[55]    = ui->sb55;
    sbAry[56]    = ui->sb56;
    sbAry[57]    = ui->sb57;
    sbAry[58]    = ui->sb58;
    sbAry[59]    = ui->sb59;
    sbAry[60]    = ui->sb60;
    sbAry[61]    = ui->sb61;
    sbAry[62]    = ui->sb62;
    sbAry[63]    = ui->sb63;

    GetAllValues();
}

DlgGain::~DlgGain()
{
    delete ui;
}

void DlgGain::on_xx_valueChanged(int arg1, int nr)
{
    emit OSetValue(mM_Gain,nr,arg1);
}

void DlgGain::on_SetAllToMax_clicked()
{
    QMessageBox::StandardButton reply;
    reply = QMessageBox::question(this, "Set all to MAX", "Do you realy want to set\nALL channels to maximum Gain ?", QMessageBox::Yes|QMessageBox::No);
    if (reply == QMessageBox::Yes) {
        for (int i=0; i<MAROC_MAXMAROCCHANNELS; i++) {
            emit OSetValue(mM_Gain,i,MAROC_MAXGAIN);
            emit OGetValue(mM_Gain,i);
        }
    }
}

void DlgGain::on_SetAllToMin_clicked()
{
    QMessageBox::StandardButton reply;
    reply = QMessageBox::question(this, "Set all to MAX", "Do you realy want to set\nALL channels to minimum Gain ?", QMessageBox::Yes|QMessageBox::No);
    if (reply == QMessageBox::Yes) {
        for (int i=0; i<MAROC_MAXMAROCCHANNELS; i++) {
            emit OSetValue(mM_Gain,i,MAROC_MINGAIN);
            emit OGetValue(mM_Gain,i);
        }
    }
}

void DlgGain::on_CopyCh00ToAll_clicked()
{
    QMessageBox::StandardButton reply;
    reply = QMessageBox::question(this, "Copy gain", "Do you realy want to\ncopy ch. 0 gain to all channel ?", QMessageBox::Yes|QMessageBox::No);
    if (reply == QMessageBox::Yes) {
        qDebug("Copy gain to all channel !");
//        dm->AddToLog(LOG_NEWLINE,"Copy gain to all channel !");
        int g = sbAry[0]->value();
        for (int i=1; i<MAROC_MAXMAROCCHANNELS; i++) {
            emit OSetValue(mM_Gain,i,g);
            emit OGetValue(mM_Gain,i);
        }
    }
}

void DlgGain::on_WriteToChip_clicked()
{
    emit OSetValue(mM_WriteToChip,MAROC_SHOWINFO,MAROC_TODISK);
}

void DlgGain::on_Close_clicked()
{
    close();
}


void DlgGain::GetAllValues()
{
    for (int i=0; i<MAROC_MAXMAROCCHANNELS; i++) {
        sbAry[i]->setRange(0,255);
        emit OGetValue(mM_Gain,i);
    }
}

void DlgGain::ISetValue(int id, int idx, QVariant val)
{
    switch(id)
    {
        case mM_Gain:       sbAry[idx]->setValue(val.toInt()); break;
    }
}

void DlgGain::on_AddToAll_clicked()
{
    QMessageBox::StandardButton reply;
    reply = QMessageBox::question(this, "Add to All", "Do you realy want to\nadd Value to all channel ?", QMessageBox::Yes|QMessageBox::No);
    if (reply == QMessageBox::Yes) {
        qDebug("Add value to all channel !");
        int g = ui->Offset->value();
        for (int i=0; i<MAROC_MAXMAROCCHANNELS; i++) {
            emit OSetValue(mM_Gain,i,sbAry[i]->value()+g);
            emit OGetValue(mM_Gain,i);
        }
    }
}