Ejemplo n.º 1
0
void MantaAudioUnitController::updateButtonColor(int index)
{
    if (buttonMap.count(index) == 0)
    {
        setButtonLedState(index, Manta::Off);
        setButtonColor(index, ofColor::white);
    }
    else if (buttonMap[index]->toggle)
    {
        ofColor synthColor = synths[buttonMap[index]->synthName]->getColor();
        if (buttonMap[index]->parameter == buttonMap[index]->min)
        {
            setButtonColor(index, ofColor(synthColor, 100));
            setButtonLedState(index, Manta::Off);
        }
        else
        {
            setButtonColor(index, synthColor);
            setButtonLedState(index, Manta::Red);
        }
    }
    else
    {
        ofColor synthColor = synths[buttonMap[index]->synthName]->getColor();
        setButtonLedState(index, Manta::Red);
        setButtonColor(index, synthColor);
    }
}
Ejemplo n.º 2
0
void DriverColorsDialog::onResetButtonClicked()
{
    QToolButton *button = static_cast<QToolButton*>(QObject::sender());

    for (int i = 0; i < ui->verticalLayout->count()-2; ++i)
    {
        QHBoxLayout *layout = static_cast<QHBoxLayout*>(ui->verticalLayout->itemAt(i)->layout());
        QToolButton *resetButton = static_cast<QToolButton*>(layout->itemAt(1)->widget());
        QToolButton *colorButton = static_cast<QToolButton*>(layout->itemAt(0)->widget());

        if (button == resetButton)
        {
            setButtonColor(colorButton, ColorsManager::getInstance().getDefaultDriverColors()[i * 2]);
            colors[i * 2] = ColorsManager::getInstance().getDefaultDriverColors()[i * 2];

            return;
        }

        resetButton = static_cast<QToolButton*>(layout->itemAt(4)->widget());
        colorButton = static_cast<QToolButton*>(layout->itemAt(3)->widget());
        if (button == resetButton)
        {
            setButtonColor(colorButton, ColorsManager::getInstance().getDefaultDriverColors()[i * 2 + 1]);
            colors[i * 2 + 1] = ColorsManager::getInstance().getDefaultDriverColors()[i * 2 + 1];

            return;
        }
    }
}
Ejemplo n.º 3
0
void LightInfo::update()
{
    updating = true;

    Magic3D::Object* object = getObject();

    if (object && object->getType() == Magic3D::eOBJECT_LIGHT)
    {
        Magic3D::Light* light = (Magic3D::Light*)object;
        setButtonColor(ui->btnColorAmbient,  light->getColorAmbient());
        setButtonColor(ui->btnColorDiffuse,  light->getColorDiffuse());
        setButtonColor(ui->btnColorSpecular, light->getColorSpecular());

        switch (light->getLightType())
        {
            case Magic3D::eLIGHT_TYPE_DIRECTIONAL: ui->rbDirectional->setChecked(true); break;
            case Magic3D::eLIGHT_TYPE_POINT: ui->rbPoint->setChecked(true); break;
            case Magic3D::eLIGHT_TYPE_SPOT: ui->rbSpot->setChecked(true); break;
        }

        ui->chkShadows->setChecked(light->isShadows());

        if (!ui->txtSpotCutoff->hasFocus())
        {
            ui->txtSpotCutoff->setValue(light->getCutOff());
        }
        ui->sldSpotExponent->setValue(light->getExponent());

        if (!ui->txtAttenuationConstant->hasFocus())
        {
            ui->txtAttenuationConstant->setValue(light->getAttenuationConstant());
        }
        if (!ui->txtAttenuationLinear->hasFocus())
        {
            ui->txtAttenuationLinear->setValue(light->getAttenuationLinear());
        }
        if (!ui->txtAttenuationQuadratic->hasFocus())
        {
            ui->txtAttenuationQuadratic->setValue(light->getAttenuationQuadratic());
        }

        if (!ui->txtRadius->hasFocus())
        {
            ui->txtRadius->setValue(light->getFar());
        }

        ui->chkLens->setChecked(light->isShowingLens());
        ui->chkFlare->setChecked(light->isShowingFlare());
    }

    updating = false;
}
Ejemplo n.º 4
0
void MainWindow::updateView()
{
    for (int x = 0; x < world -> getHeight(); x++) {
        for(int y = 0; y < world -> getWidth(); y++) {
            if (world -> getStatusOfCell(x, y)) {
                setButtonColor(pushButtons[x*world->getHeight() + y], QString::fromStdString(aliveColor));
            }
            else {
                setButtonColor(pushButtons[x*world->getHeight() + y], QString::fromStdString(deathColor));
            }
        }
    }
    setLabelAliveNumber();
}
Ejemplo n.º 5
0
void FileTransferWidget::setupButtons()
{
    switch(fileInfo.status)
    {
    case ToxFile::TRANSMITTING:
        ui->topButton->setIcon(QIcon(":/ui/fileTransferInstance/pause.svg"));
        ui->topButton->setObjectName("pause");
        ui->topButton->setToolTip(tr("Pause transfer"));

        ui->bottomButton->setIcon(QIcon(":/ui/fileTransferInstance/no.svg"));
        ui->bottomButton->setObjectName("cancel");
        ui->bottomButton->setToolTip(tr("Cancel transfer"));

        setButtonColor(Style::getColor(Style::Green));
        break;

    case ToxFile::PAUSED:
        ui->topButton->setIcon(QIcon(":/ui/fileTransferInstance/arrow_white.svg"));
        ui->topButton->setObjectName("resume");
        ui->topButton->setToolTip(tr("Resume transfer"));

        ui->bottomButton->setIcon(QIcon(":/ui/fileTransferInstance/no.svg"));
        ui->bottomButton->setObjectName("cancel");
        ui->bottomButton->setToolTip(tr("Cancel transfer"));

        setButtonColor(Style::getColor(Style::LightGrey));
        break;

    case ToxFile::STOPPED:
    case ToxFile::BROKEN:
        ui->bottomButton->setIcon(QIcon(":/ui/fileTransferInstance/no.svg"));
        ui->bottomButton->setObjectName("cancel");
        ui->bottomButton->setToolTip(tr("Cancel transfer"));

        if (fileInfo.direction == ToxFile::SENDING)
        {
            ui->topButton->setIcon(QIcon(":/ui/fileTransferInstance/pause.svg"));
            ui->topButton->setObjectName("pause");
            ui->topButton->setToolTip(tr("Pause transfer"));
        }
        else
        {
            ui->topButton->setIcon(QIcon(":/ui/fileTransferInstance/yes.svg"));
            ui->topButton->setObjectName("accept");
            ui->topButton->setToolTip(tr("Accept transfer"));
        }
        break;
    }
}
Ejemplo n.º 6
0
void MainWindow::buttonChanged() {
    int x, y;
    x = QObject::sender() -> property("cellPositionX").toInt();
    y = QObject::sender() -> property("cellPositionY").toInt();
    world->setStatusOfCell(x, y, !world->getStatusOfCell(x, y));

    if (world->getStatusOfCell(x, y))
    {
        setButtonColor(pushButtons[x*world->getHeight() + y], QString::fromStdString(aliveColor));
    }
    else
    {
        setButtonColor(pushButtons[x*world->getHeight() + y], QString::fromStdString(deathColor));
    }
   setLabelAliveNumber();
}
Ejemplo n.º 7
0
void DriverColorsDialog::on_pushButton_clicked()
{
    for (int i = 0; i < ui->verticalLayout->count()-2; ++i)
    {
        QHBoxLayout *layout = static_cast<QHBoxLayout*>(ui->verticalLayout->itemAt(i)->layout());
        QToolButton *colorButton = static_cast<QToolButton*>(layout->itemAt(0)->widget());

        setButtonColor(colorButton, ColorsManager::getInstance().getDefaultDriverColors()[i * 2]);
        colors[i * 2] = ColorsManager::getInstance().getDefaultDriverColors()[i * 2];

        colorButton = static_cast<QToolButton*>(layout->itemAt(3)->widget());

        setButtonColor(colorButton, ColorsManager::getInstance().getDefaultDriverColors()[i * 2 + 1]);
        colors[i * 2 + 1] = ColorsManager::getInstance().getDefaultDriverColors()[i * 2 + 1];
    }
}
Ejemplo n.º 8
0
void MainWindow::setWorld(World* world) {
    timer = new QTimer(this);
    this->world = world;

    pushButtons = new QPushButton*[world->getHeight() * world->getWidth()];
    QPushButton* pushButton;

    for (int i =0;i<world->getHeight();i++)
    {
        for(int j=0;j < world->getWidth();j++)
        {
            pushButton = new QPushButton(ui->widget);
            pushButton->setGeometry(i*BUTTON_HEIGHT, j*BUTTON_WIDTH, BUTTON_HEIGHT, BUTTON_WIDTH);
            setButtonColor(pushButton, QString::fromStdString(deathColor));

            pushButton->setProperty("cellPositionX", QVariant(i));
            pushButton->setProperty("cellPositionY", QVariant(j));

            QObject::connect(pushButton, SIGNAL(clicked()), this, SLOT(buttonChanged()));
            pushButtons[i * world->getHeight() + j] = pushButton;
        }
    }

    QObject::connect(ui->pushButtonStep, SIGNAL(clicked()), this, SLOT(doStepWorld()));
    QObject::connect(ui->pushButtonClear, SIGNAL(clicked()), this, SLOT(btnClear()));
    QObject::connect(ui->pushButtonRun, SIGNAL(clicked()), this, SLOT(btnRun()));
    QObject::connect(ui->pushButtonStop, SIGNAL(clicked()), this, SLOT(btnStop()));
    QObject::connect(ui->pushButtonRand, SIGNAL(clicked()), this, SLOT(btnRand()));
    setWindowTitle("The World of Empress");
    world->doStep();
    world->doStep();
    updateView();
}
Ejemplo n.º 9
0
void GraphMarkerDialog::on_colorBtn_clicked()
{
    QColor clr = QColorDialog::getColor(m_color, this);
    if(!clr.isValid())
        return;

    setButtonColor(clr);
}
Ejemplo n.º 10
0
GraphMarkerDialog::GraphMarkerDialog(int axis, QWidget *parent) : QDialog(parent), ui(new Ui::GraphMarkerDialog)
{
    ui->setupUi(this);
    ui->valBox->setRange(-DBL_MAX, DBL_MAX);
    ui->axisBox->setCurrentIndex(axis);

    setButtonColor(Qt::black);
}
Ejemplo n.º 11
0
void GraphCurveAddDialog::selectColor()
{
    QColor color = QColorDialog::getColor(m_color, this);

    if(!color.isValid())
        return;

    setButtonColor(color);
}
Ejemplo n.º 12
0
    //! \brief Load current settings into each settings page
    void SettingsDialog::updateWidgets(QMap<QString, QVariant> map)
    {
        // General group of settings
        ui.checkShowGrid->setChecked(map["gui/gridVisible"].value<bool>());
        setButtonColor(ui.buttonBackground, map["gui/backgroundColor"].value<QColor>());
        setButtonColor(ui.buttonSimulationBackground, map["gui/simulationBackgroundColor"].value<QColor>());
        setButtonColor(ui.buttonForeground, map["gui/foregroundColor"].value<QColor>());
        setButtonColor(ui.buttonLine, map["gui/lineColor"].value<QColor>());
        setButtonColor(ui.buttonSelection, map["gui/selectionColor"].value<QColor>());
        ui.spinWidth->setValue(map["gui/lineWidth"].toInt());

        // Libraries group of settings
        ui.listLibraries->clear();
        ui.listHdlLibraries->clear();

        QStringList libraries = map["libraries/schematic"].toStringList();
        foreach (const QString &library, libraries) {
            ui.listLibraries->addItem(library);
        }
Ejemplo n.º 13
0
void ColorButton::changeButtonColor(void )
{
    const QColor new_color = QColorDialog::getColor(color);
    if (new_color.isValid())
    {
        setButtonColor(new_color);
        color = new_color;
        emit newColor(color);
    }
}
Ejemplo n.º 14
0
    /*!
     * \brief Opens a color selection dialog and sets the selected color to a
     * button.
     */
    void SettingsDialog::colorButtonDialog()
    {
        QPushButton *button = qobject_cast<QPushButton*>(sender());
        if(!button) {
            return;
        }

        QColor color = QColorDialog::getColor(getButtonColor(button), this);
        if(color.isValid()) {
            setButtonColor(button, color);
        }
    }
Ejemplo n.º 15
0
void DeclarativeSettingsPageImpl::addColorField(const QString &key, const DeclarativeSettingsPage::Entry &entry)
{
    QToolButton * control = new QToolButton(pClass_);
    QColor defColor(Qt::black);
    if (entry.defaultValue.isValid()) {
        defColor = QColor(entry.defaultValue.toString());
    }
    setButtonColor(control, defColor);
    connect(control, SIGNAL(clicked()), this, SLOT(showColorDialog()));
    widgets_[key] = control;
    addField(entry.title, control);
}
Ejemplo n.º 16
0
GraphCurveAddDialog::GraphCurveAddDialog(QWidget *parent, std::vector<GraphCurveInfo*> *curves, bool edit) :
    QDialog(parent),ui(new Ui::GraphCurveAddDialog),
    edit_widget_ui(new Ui::GraphCurveEditWidget)
{
    ui->setupUi(this);

    m_edit_widget = new QWidget(this);
    edit_widget_ui->setupUi(m_edit_widget);

    ui->mainLayout->insertWidget(1, m_edit_widget);
    newOrEditCurve(true);

    setButtonColor(Qt::red);

    connect(ui->newRadio,             SIGNAL(toggled(bool)),                SLOT(newOrEditCurve(bool)));
    connect(ui->buttonBox,            SIGNAL(accepted()),                   SLOT(tryAccept()));
    connect(edit_widget_ui->colorBtn, SIGNAL(clicked()),                    SLOT(selectColor()));
    connect(edit_widget_ui->curveBox, SIGNAL(currentIndexChanged(int)),     SLOT(curveChanged(int)));

    static const QString dataTypes[] =
    {
        tr("unsigned 8bit"),
        tr("unsigned 16bit"),
        tr("unsigned 32bit"),
        tr("unsigned 64bit"),

        tr("signed 8bit"),
        tr("signed 16bit"),
        tr("signed 32bit"),
        tr("signed 64bit"),

        tr("float (4 bytes)"),
        tr("double (8 bytes)")
    };

    for(quint8 i = 0; i < NUM_COUNT; ++i)
        edit_widget_ui->dataTypeBox->addItem(dataTypes[i]);

    m_curves = curves;

    ui->setRadio->setEnabled(!m_curves->empty());

    if(edit)
    {
        ui->setRadio->setChecked(true);
        ui->setRadio->setVisible(false);
        ui->newRadio->setVisible(false);

        ui->buttonBox->addButton(QDialogButtonBox::Apply);
        connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), SLOT(buttonBoxClicked(QAbstractButton*)));
    }
}
Ejemplo n.º 17
0
fhColorEdit::fhColorEdit(QWidget* parent)
    : QWidget(parent) {
    auto layout = new QHBoxLayout(this);
    m_button = new QPushButton(this);
    m_vec3edit = new fhVec3Edit(this);

    layout->addWidget(m_button);
    layout->addWidget(m_vec3edit);
    this->setLayout(layout);

    m_vec3edit->setMinimumValue(idVec3(0,0,0));
    m_vec3edit->setMaximumValue(idVec3(1,1,1));
    m_vec3edit->setPrecision(2);
    m_vec3edit->setStepSize(0.01f);
    m_vec3edit->setMaximumWidth(140);

    QObject::connect( m_button, &QPushButton::clicked, [=]() {
        QColorDialog dialog( Vec3ToQColor(this->m_vec3edit->get()), this );

        dialog.setWindowModality( Qt::WindowModal );
        QObject::connect( &dialog, &QColorDialog::currentColorChanged, [&](const QColor& c) {
            setButtonColor(this->m_button, c);
            this->m_vec3edit->set(QColorToVec3(c));
        } );

        dialog.exec();
        this->m_vec3edit->set(QColorToVec3(dialog.currentColor()));
    } );

    QObject::connect( m_vec3edit, &fhVec3Edit::valueChanged, [=](idVec3 value) {
        setButtonColor(this->m_button, Vec3ToQColor(value));
        emit valueChanged(value);
    });

    m_vec3edit->set(idVec3(1,1,1));
    this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    this->setContentsMargins(0,0,0,0);
    layout->setMargin(0);
}
Ejemplo n.º 18
0
void GraphCurveAddDialog::curveChanged(int idx)
{
    if((quint32)idx >= m_curves->size())
        return;

    GraphCurve* curve = m_curves->at(idx)->curve;
    edit_widget_ui->nameEdit->setText(curve->title().text());
    edit_widget_ui->dataTypeBox->setCurrentIndex(curve->getDataType());
    edit_widget_ui->formulaEdit->setText(curve->getFormula());
    edit_widget_ui->axisBox->setCurrentIndex(curve->yAxis());

    setButtonColor(curve->pen().color());
}
Ejemplo n.º 19
0
void DeclarativeSettingsPageImpl::showColorDialog()
{
    QToolButton * b = qobject_cast<QToolButton*>(sender());
    if (!b)
        return;
    QColor c = QColorDialog::getColor(
                buttonColor(b),
                pClass_,
                tr("Choose color")
                );
    if (c.isValid()) {
        setButtonColor(b, c);
    }
}
Ejemplo n.º 20
0
void DeclarativeSettingsPageImpl::init()
{
    if (!settings_) return;
    foreach (const QString & key, entries_.keys()) {
        const DeclarativeSettingsPage::Entry & entry = entries_[key];
        if (entry.type==DeclarativeSettingsPage::Integer) {
            int value = settings_->value(key, entry.defaultValue).toInt();
            QSpinBox * control = 0;
            if (widgets_.contains(key) && QString(widgets_[key]->metaObject()->className())=="QSpinBox")
                control = qobject_cast<QSpinBox*>(widgets_[key]);
            if (control)
                control->setValue(value);
        }
        else if (entry.type==DeclarativeSettingsPage::Color) {
            QColor value = settings_->value(key, entry.defaultValue).toString();
            QToolButton * control = 0;
            if (widgets_.contains(key) && QString(widgets_[key]->metaObject()->className())=="QToolButton")
                control = qobject_cast<QToolButton*>(widgets_[key]);
            if (control)
                setButtonColor(control, value);
        }
        else if (entry.type==DeclarativeSettingsPage::Double) {
            qreal value = settings_->value(key, entry.defaultValue).toDouble();
            QDoubleSpinBox * control = 0;
            if (widgets_.contains(key) && QString(widgets_[key]->metaObject()->className())=="QDoubleSpinBox")
                control = qobject_cast<QDoubleSpinBox*>(widgets_[key]);
            if (control)
                control->setValue(value);
        }
        else if (entry.type==DeclarativeSettingsPage::String) {
            const QString value = settings_->value(key, entry.defaultValue).toString();
            QLineEdit * control = 0;
            if (widgets_.contains(key) && QString(widgets_[key]->metaObject()->className())=="QLineEdit")
                control = qobject_cast<QLineEdit*>(widgets_[key]);
            if (control)
                control->setText(value);
        }
        else if (entry.type==DeclarativeSettingsPage::Bool) {
            bool value = settings_->value(key, entry.defaultValue).toBool();
            QCheckBox * control = 0;
            if (widgets_.contains(key) && QString(widgets_[key]->metaObject()->className())=="QCheckBox")
                control = qobject_cast<QCheckBox*>(widgets_[key]);
            if (control)
                control->setChecked(value);
        }
        else {
            qFatal("Not implemented");
        }
    }
}
Ejemplo n.º 21
0
void DriverColorsDialog::onColorButtonClicked()
{
    QToolButton *button = static_cast<QToolButton*>(QObject::sender());

    for (int i = 0; i < ui->verticalLayout->count()-2; ++i)
    {
        QHBoxLayout *layout = static_cast<QHBoxLayout*>(ui->verticalLayout->itemAt(i)->layout());
        QToolButton *colorButton = static_cast<QToolButton*>(layout->itemAt(0)->widget());

        if (button == colorButton)
        {
            QColor color = QColorDialog::getColor(colors[i * 2], this);

            if (color.isValid())
            {
                setButtonColor(colorButton, color);
                colors[i * 2] = color;
            }

            return;
        }

        colorButton = static_cast<QToolButton*>(layout->itemAt(3)->widget());
        if (button == colorButton)
        {
            QColor color = QColorDialog::getColor(colors[i * 2 + 1], this);

            if (color.isValid())
            {
                setButtonColor(colorButton, color);
                colors[i * 2 + 1] = color;
            }

            return;
        }
    }
}
Ejemplo n.º 22
0
MainWindow::MainWindow(QWidget *parent, IGameManager* gm) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    _gm(gm)
{
    _colors[0] = "grey";
    _colors[1] = "blue";
    _colors[2] = "red";
    _colors[3] = "#333333";
    ui->setupUi(this);
    ui->stackedWidget->setCurrentIndex(1);
    for(int i = 0; i != 19 * 19; ++i)
    {
        GomokuButton* tmp = new GomokuButton(i - 19 * (i / 19), i / 19);

        connect(tmp, &GomokuButton::clicked, [this, tmp](){
            _gm->didClickCase(tmp->getX(), tmp->getY());
            setPlayer1Text(_gm->getGame()->getPlayer(0)->getPoints());
            setPlayer2Text(_gm->getGame()->getPlayer(1)->getPoints());
        });
        tmp->OnMouseMove( [this, tmp] (QMouseEvent*) {
            if (_gm->getGame() && _gm->getGame()->getActivePlayer() && tmp->isEmpty())
                setButtonColor(tmp->getX(), tmp->getY(), static_cast<Case::caseContent>(_gm->getGame()->getActivePlayer()->getColor()));
            if (!tmp->isEmpty())
                for(auto button : _buttons)
                    if (button->isEmpty())
                        button->setStyleSheet(std::string("background-color:grey").c_str());
        });
        _buttons.push_back(tmp);
    }

    connect(ui->PvP, &QPushButton::clicked, [this](){

        this->_gm->createGame(IGame::PVP);
        _mode = IGame::PVP;
        this->ui->AITimeoutBox->setVisible(false);
        this->ui->AILabel->setVisible(false);
    });

    connect(ui->PvE, &QPushButton::clicked, [this](){

        this->_gm->createGame(IGame::PVE);
        _mode = IGame::PVE;
        this->ui->AITimeoutBox->setVisible(true);
        this->ui->AILabel->setVisible(true);
    });

    connect(ui->pushButton, &QPushButton::clicked, [this](){
        this->_gm->removeGame();
        this->reset();
    });

//    connect(ui->doubleThree, &QCheckBox::clicked, [this](bool state) {
//        if (state == false)
//            this->_gm->getJudge()->addRule(new DoubleThree());
//        else
//            this->_gm->getJudge()->removeRule(IRule::DOUBLETHREE);
//    });

//    connect(ui->eatThem, &QCheckBox::clicked, [this](bool state) {
//        if (state == false) {
//            this->_gm->getJudge()->removeRule(IRule::EATTHEM);
//        }
//        else {
//            this->_gm->getJudge()->addRule(new EatThem());
//        }
//    });

    for (auto button : _buttons)
    {
        ui->gridLayout->addWidget(button, button->getY(), button->getX());
    }
    ui->playerTurn->setStyleSheet(std::string("background-color:blue").c_str());
    ui->score1->setStyleSheet(std::string("background-color:blue").c_str());
    ui->score2->setStyleSheet(std::string("background-color:red").c_str());
}
Ejemplo n.º 23
0
void MantaAudioUnitController::setPadFreezingEnabled(bool toFreezePads)
{
    this->toFreezePads = toFreezePads;
    setButtonLedState(1, toFreezePads ? Manta::Red : Manta::Off);
    setButtonColor(1, toFreezePads ? ofColor::blue : ofColor::white);
}
Ejemplo n.º 24
0
void IsoSurfaceDialog::init()
{
    update();

    connect(&m_viewer.trapMesh(), SIGNAL(colorAChanged(QColor)), ui->colorButtonA, SLOT(setButtonColor(QColor)));
    connect(ui->colorButtonA, SIGNAL(selectedColor(QColor)), &m_viewer.trapMesh(), SLOT(setColorA(QColor)));

    connect(&m_viewer.trapMesh(), SIGNAL(colorBChanged(QColor)), ui->colorButtonB, SLOT(setButtonColor(QColor)));
    connect(ui->colorButtonB, SIGNAL(selectedColor(QColor)), &m_viewer.trapMesh(), SLOT(setColorB(QColor)));

    connect(ui->checkBoxVisible, SIGNAL(toggled(bool)), &m_viewer.trapMesh(), SLOT(setVisible(bool)));
    connect(&m_viewer.trapMesh(), SIGNAL(visibleChanged(bool)), ui->checkBoxVisible, SLOT(setChecked(bool)));

    connect(&m_viewer, SIGNAL(canCalculateIsoSurface(bool)), this, SLOT(setCalculateEnabled(bool)));
    connect(&m_viewer, SIGNAL(isoSurfaceProgress(int)), ui->calculateProgress, SLOT(setValue(int)));

    connect(&m_viewer.trapMesh(), SIGNAL(modeChanged(Mesh::Mode)), this, SLOT(updateComboBoxMode(Mesh::Mode)));

    connect(&m_viewer.trapMesh(), SIGNAL(colorAChanged(QColor)), this, SLOT(extractAlpha(QColor)));
    connect(&m_viewer.trapMesh(), SIGNAL(colorBChanged(QColor)), this, SLOT(extractAlpha(QColor)));
    connect(this, SIGNAL(sendAlpha(int)), this, SLOT(updateSpinBoxAlpha(int)));
}
Ejemplo n.º 25
0
void BtStyle::setCurrentStyle(int style) {
    if (style == BtStyle::darkTheme) {

        currentStyle = style;

        BtModuleTextModel::setLinkColor(QColor(0,191,255));
        BtModuleTextModel::setHighlightColor(QColor(255,255,0));
        BtModuleTextModel::setJesusWordsColor(QColor(255,0,0));

        setTextColor(QColor(255,255,255));
        setLinkColor(QColor(0,0,80));
        setTextBackgroundColor(QColor(0,0,0));
        setTextBackgroundHighlightColor(QColor(184,135,11));

        setButtonColor(QColor(0,0,0));
        setButtonBackground(QColor(35,35,100));
        setButtonTextColor(QColor(255,210,0));
        setButtonHighlightedText(QColor(255,255,0));
        setButtonBorder(QColor(110,110,110));
        setButtonRadius(3);
        setButtonGradient0(QColor(125,125,125));
        setButtonGradient1(QColor(60,60,60));
        setButtonGradient2(QColor(50,50,50));
        setButtonGradient3(QColor(20,20,20));

        setWindowTab(QColor(100,100,100));
        setWindowTabSelected(QColor(218,165,3));
        setWindowTabText(QColor(255,255,255));
        setWindowTabTextSelected(QColor(0,0,0));

        setMenu(QColor(255,255,255));
        setMenuBorder(QColor(60,60,60));
        setMenuText(QColor(0,0,0));
        setMenuHeight(34);

        setToolbarColor(QColor(0,0,0));
        setToolbarTextColor(QColor(218,165,3));
        setToolbarButtonText(QColor(255,255,255));
        setToolbarTextPointSize(10);
    }
    else if (style == BtStyle::lightBlueTheme) {

        currentStyle = style;

        BtModuleTextModel::setLinkColor(QColor(0,0,255));
        BtModuleTextModel::setHighlightColor(QColor(0,0,255));
        BtModuleTextModel::setJesusWordsColor(QColor(255,0,0));

        setTextColor(QColor(0,0,0));
        setLinkColor(QColor(0,0,220));
        setTextBackgroundColor(QColor(255,255,255));
        setTextBackgroundHighlightColor(QColor(255,240,170));

        setButtonColor(QColor(0,0,0));
        setButtonBackground(QColor(190,220,255));
        setButtonTextColor(QColor(0,0,0));
        setButtonHighlightedText(QColor(0,0,255));
        setButtonBorder(QColor(80,80,0));
        setButtonRadius(3);
        setButtonGradient0(QColor(180,180,255));
        setButtonGradient1(QColor(255,255,255));
        setButtonGradient2(QColor(255,255,255));
        setButtonGradient3(QColor(180,180,255));

        setWindowTab(QColor(245,245,245));
        setWindowTabSelected(QColor(65,105,225));
        setWindowTabText(QColor(100,100,100));
        setWindowTabTextSelected(QColor(255,255,255));

        setMenu(QColor(255,255,255));
        setMenuBorder(QColor(220,220,220));
        setMenuText(QColor(0,0,0));
        setMenuHeight(40);

        setToolbarColor(QColor(190,220,255));
        setToolbarTextColor(QColor(0,0,0));
        setToolbarButtonText(QColor(0,0,0));
        setToolbarTextPointSize(10);
    }
    else if (style == BtStyle::crimsonTheme) {

        currentStyle = style;

        BtModuleTextModel::setLinkColor(QColor(0,0,255));
        BtModuleTextModel::setHighlightColor(QColor(0,0,255));
        BtModuleTextModel::setJesusWordsColor(QColor(170,0,0));

        setTextColor(QColor(0,0,0));
        setLinkColor(QColor(0,0,220));
        setTextBackgroundColor(QColor(255,255,255));
        setTextBackgroundHighlightColor(QColor(255,240,170));

        setButtonColor(QColor(0,0,0));
        setButtonBackground(QColor(190,220,255));
        setButtonTextColor(QColor(0,0,0));
        setButtonHighlightedText(QColor(0,0,255));
        setButtonBorder(QColor(80,80,0));
        setButtonRadius(3);
        setButtonGradient0(QColor(180,180,255));
        setButtonGradient1(QColor(255,255,255));
        setButtonGradient2(QColor(255,255,255));
        setButtonGradient3(QColor(180,180,255));

        setWindowTab(QColor(245,245,245));
        setWindowTabSelected(QColor(218,165,3));
        setWindowTabText(QColor(100,100,100));
        setWindowTabTextSelected(QColor(0,0,0));

        setMenu(QColor(255,255,255));
        setMenuBorder(QColor(220,220,220));
        setMenuText(QColor(0,0,0));
        setMenuHeight(40);

        setToolbarColor(QColor(99,0,0));
        setToolbarTextColor(QColor(255,255,255));
        setToolbarButtonText(QColor(0,0,0));
        setToolbarTextPointSize(10);
    }
}
Ejemplo n.º 26
0
void MaterialInfo::loadMaterial()
{
    updating = true;
    if (material)
    {
        ui->scrollArea->setEnabled(true);

        setButtonColor(ui->btnColorAmbient,  material->getColorAmbient());
        setButtonColor(ui->btnColorDiffuse,  material->getColorDiffuse());
        setButtonColor(ui->btnColorEmission, material->getColorEmission());
        setButtonColor(ui->btnColorSpecular, material->getColorSpecular());

        ui->sldShininess->setValue(material->getShininess());

        if (!ui->txtAlphaTest->hasFocus())
        {
            ui->txtAlphaTest->setValue(material->getAlphaTest());
        }

        ui->imgTexture1->setIcon(QIcon());
        ui->imgTexture2->setIcon(QIcon());

        QPixmapCache::clear();

        Magic3D::Texture* texture = material->getTexture(0);
        if (texture)
        {
            QString file = UTILS_DEFAULT_PATH + QString::fromStdString(mainWindow->getProject()->getPathData()) +  QString::fromStdString(Magic3D::ResourceManager::getTextures()->getPrefix(texture->type)) + QString::fromStdString(texture->file);

            if (tga1 && tga1->isFinished())
            {
                tga1->wait();
                delete tga1;
                tga1 = NULL;
            }
            if (!tga1)
            {
                tga1 = new LoadThread(ui->imgTexture1, file, texture, 0);

                connect(tga1, SIGNAL(finished(QImage*,QPushButton*,Magic3D::Texture*,int)),
                        SLOT(loadFinished(QImage*,QPushButton*,Magic3D::Texture*,int)));

                tga1->start(QThread::LowestPriority);
            }

            ui->imgTexture1->setAutoFillBackground(false);
            ui->cmbTexture1->setCurrentIndex(ui->cmbTexture1->findText(QString::fromStdString(texture->getName())));

            ui->rbClamp1->setChecked(texture->clamp);
            ui->rbRepeat1->setChecked(!texture->clamp);
        }
        else
        {
            ui->imgTexture1->setStyleSheet(tr("* {background-color : %1}").arg(QColor(128, 128, 128, 255).name()));
            ui->imgTexture1->setAutoFillBackground(true);

            ui->cmbTexture1->setCurrentIndex(ui->cmbTexture1->findText(UTILS_NONE));
        }

        texture = material->getTexture(1);
        if (texture)
        {
            QString file = UTILS_DEFAULT_PATH + QString::fromStdString(mainWindow->getProject()->getPathData()) + QString::fromStdString(Magic3D::ResourceManager::getTextures()->getPrefix(texture->type)) + QString::fromStdString(texture->file);

            if (tga2 && tga2->isFinished())
            {
                tga2->wait();
                delete tga2;
                tga2 = NULL;
            }
            if (!tga2)
            {
                tga2 = new LoadThread(ui->imgTexture2, file, texture, 1);

                connect(tga2, SIGNAL(finished(QImage*,QPushButton*,Magic3D::Texture*,int)),
                        SLOT(loadFinished(QImage*,QPushButton*,Magic3D::Texture*,int)));

                tga2->start(QThread::LowestPriority);
            }

            ui->imgTexture2->setAutoFillBackground(false);
            ui->cmbTexture2->setCurrentIndex(ui->cmbTexture2->findText(QString::fromStdString(texture->getName())));

            ui->rbClamp2->setChecked(texture->clamp);
            ui->rbRepeat2->setChecked(!texture->clamp);
        }
        else
        {
            ui->imgTexture2->setStyleSheet(tr("* {background-color : %1}").arg(QColor(128, 128, 128, 255).name()));
            ui->imgTexture2->setAutoFillBackground(true);

            ui->cmbTexture2->setCurrentIndex(ui->cmbTexture2->findText(UTILS_NONE));
        }

        Magic3D::Shader* shader = material->getShader();
        if (shader)
        {
            ui->cmbShader->setCurrentIndex(ui->cmbShader->findText(QString::fromStdString(shader->getName())));
        }
        else
        {
            ui->cmbShader->setCurrentIndex(ui->cmbShader->findText(UTILS_NONE));
        }

        switch (material->getBlend())
        {
            case Magic3D::eBLEND_ALPHA:    ui->rbAlpha->setChecked(true); break;
            case Magic3D::eBLEND_ADD:      ui->rbAdd->setChecked(true); break;
            case Magic3D::eBLEND_MULTIPLY: ui->rbMultiply->setChecked(true); break;
            case Magic3D::eBLEND_DIVIDE:   ui->rbDivide->setChecked(true); break;
            case Magic3D::eBLEND_INVERT:   ui->rbInvert->setChecked(true); break;
            case Magic3D::eBLEND_COLOR:    ui->rbColor->setChecked(true); break;
            default: break;
        }

        clearVariables();

        ui->gbShaderVars->setVisible(material->getVarCount() > 0);

        for (int i = 0; i < material->getVarCount(); i++)
        {
            Magic3D::MaterialVar* variable = material->getVar(i);

            MaterialVar* pnl = NULL;

            switch (variable->getType())
            {
                case Magic3D::eSHADER_VAR_FLOAT:
                case Magic3D::eSHADER_VAR_FLOAT_VEC2:
                case Magic3D::eSHADER_VAR_FLOAT_VEC3:
                case Magic3D::eSHADER_VAR_FLOAT_VEC4:
                {
                    pnl = new MaterialVar_Float(mainWindow);
                    break;
                }
                case Magic3D::eSHADER_VAR_INT:
                case Magic3D::eSHADER_VAR_INT_VEC2:
                case Magic3D::eSHADER_VAR_INT_VEC3:
                case Magic3D::eSHADER_VAR_INT_VEC4:
                {
                    pnl = new MaterialVar_Integer(mainWindow);
                    break;
                }
                case Magic3D::eSHADER_VAR_BOOL:
                case Magic3D::eSHADER_VAR_BOOL_VEC2:
                case Magic3D::eSHADER_VAR_BOOL_VEC3:
                case Magic3D::eSHADER_VAR_BOOL_VEC4:
                {
                    pnl = new MaterialVar_Boolean(mainWindow);
                    break;
                }
                case Magic3D::eSHADER_VAR_FLOAT_MAT2:
                case Magic3D::eSHADER_VAR_FLOAT_MAT3:
                case Magic3D::eSHADER_VAR_FLOAT_MAT4:
                {
                    pnl = new MaterialVar_Matrix(mainWindow);
                    break;
                }
                case Magic3D::eSHADER_VAR_SAMPLER_2D:
                case Magic3D::eSHADER_VAR_SAMPLER_CUBE:
                {
                    pnl = new MaterialVar_Texture(mainWindow);
                    static_cast<MaterialVar_Texture*>(pnl)->updateTextureCombo(texturesList);
                    break;
                }

                default: break;
            }

            if (pnl)
            {
                pnl->setMaterial(material);
                pnl->setMaterialVarIndex(i);
                pnl->setMaterialInfo(this);
                pnl->update();
                variables.append(pnl);
                ui->layoutShaderVars->addWidget(pnl);
            }
        }
    }
    else
    {
        ui->scrollArea->setEnabled(false);

        setButtonColor(ui->btnColorAmbient,  Magic3D::ColorRGBA());
        setButtonColor(ui->btnColorDiffuse,  Magic3D::ColorRGBA());
        setButtonColor(ui->btnColorEmission, Magic3D::ColorRGBA());
        setButtonColor(ui->btnColorSpecular, Magic3D::ColorRGBA());

        ui->sldShininess->setValue(0);

        ui->imgTexture1->setIcon(QIcon());
        ui->imgTexture2->setIcon(QIcon());

        ui->cmbTexture1->setCurrentIndex(0);
        ui->cmbTexture2->setCurrentIndex(0);

        ui->cmbShader->setCurrentIndex(0);

        ui->txtAlphaTest->setValue(0.0f);

        clearVariables();

        ui->gbShaderVars->setVisible(false);
    }

    ui->actDelete->setEnabled(material);
    updating = false;
}
Ejemplo n.º 27
0
int DriverColorsDialog::exec()
{
    SeasonData &sd = SeasonData::getInstance();
    colors = ColorsManager::getInstance().getDriverColors();
    int i = 0;
    for (; i < sd.getTeams().size(); ++i)
    {
        QList<LTDriver> drivers = sd.getMainDrivers(sd.getTeams()[i]);
        if (drivers.size() != 2)
            continue;

        if ((ui->verticalLayout->count()-2) <= i)
        {
            QHBoxLayout *layout = new QHBoxLayout();
            QLabel *label = new QLabel(this);                        

            label->setText(QString("%1 %2").arg(drivers[0].no).arg(drivers[0].name));
            label->updateGeometry();
            QToolButton *button = new QToolButton(this);
            button->setMaximumHeight(16);
            button->setMaximumWidth(16);
            setButtonColor(button, /*sd.getCarColor(sd.getTeams()[i].driver1No)*/colors[i*2]);
            layout->addWidget(button);
            connect(button, SIGNAL(clicked()), this, SLOT(onColorButtonClicked()));

            button = new QToolButton(this);
            button->setText("Reset");
            button->setMaximumHeight(20);
            layout->addWidget(button);
            connect(button, SIGNAL(clicked()), this, SLOT(onResetButtonClicked()));

            layout->addWidget(label);
            //colors.append(sd.getCarColor(sd.getTeams()[i].driver1No));

//            layout = new QHBoxLayout(this);
            label = new QLabel(this);
            label->setText(QString("%1 %2").arg(drivers[1].no).arg(drivers[1].name));
            label->updateGeometry();
            button = new QToolButton(this);
            button->setMaximumHeight(16);
            button->setMaximumWidth(16);
            setButtonColor(button, /*sd.getCarColor(sd.getTeams()[i].driver2No)*/colors[i*2+1]);
            layout->addWidget(button);
            connect(button, SIGNAL(clicked()), this, SLOT(onColorButtonClicked()));

            button = new QToolButton(this);
            button->setText("Reset");
            button->setMaximumHeight(20);
            layout->addWidget(button);
            connect(button, SIGNAL(clicked()), this, SLOT(onResetButtonClicked()));

            layout->addWidget(label);
            //colors.append(sd.getCarColor(sd.getTeams()[i].driver2No));

            ui->verticalLayout->insertLayout(ui->verticalLayout->count() - 2, layout);
        }
        else
        {
            QHBoxLayout *layout = static_cast<QHBoxLayout*>(ui->verticalLayout->itemAt(i)->layout());
            QLabel *label = static_cast<QLabel*>(layout->itemAt(2)->widget());
            QToolButton *button = static_cast<QToolButton*>(layout->itemAt(0)->widget());

            label->setText(QString("%1 %2").arg(drivers[0].no).arg(drivers[0].name));
            setButtonColor(button, ColorsManager::getInstance().getCarColor(drivers[0].no));

            label->setVisible(true);
            button->setVisible(true);

            button = static_cast<QToolButton*>(layout->itemAt(1)->widget());
            button->setVisible(true);

            label = static_cast<QLabel*>(layout->itemAt(5)->widget());
            button = static_cast<QToolButton*>(layout->itemAt(3)->widget());

            label->setText(QString("%1 %2").arg(drivers[1].no).arg(drivers[1].name));
            setButtonColor(button, ColorsManager::getInstance().getCarColor(drivers[1].no));

            label->setVisible(true);
            button->setVisible(true);

            button = static_cast<QToolButton*>(layout->itemAt(4)->widget());
            button->setVisible(true);
        }
    }
    for (; i < ui->verticalLayout->count()-2; ++i)
    {
        QHBoxLayout *layout = static_cast<QHBoxLayout*>(ui->verticalLayout->itemAt(i)->layout());
        QLabel *label = static_cast<QLabel*>(layout->itemAt(2)->widget());
        QToolButton *button = static_cast<QToolButton*>(layout->itemAt(0)->widget());

        label->setVisible(false);
        button->setVisible(false);

        button = static_cast<QToolButton*>(layout->itemAt(1)->widget());
        button->setVisible(false);

        label = static_cast<QLabel*>(layout->itemAt(5)->widget());
        button = static_cast<QToolButton*>(layout->itemAt(3)->widget());

        label->setVisible(false);
        button->setVisible(false);

        button = static_cast<QToolButton*>(layout->itemAt(4)->widget());
        button->setVisible(false);
    }

    return QDialog::exec();
}