// groupedSliders are in the upper set of sliders void TriangleDensityWidget::groupedSliderChangedSlot(int value) { TriangleList triangles = triangleScene->triangles(); double norm = getNorm(); triangles.at(grouped_slider_idx)->xform()->density = (double)value / 1000. * norm; resetSliders(norm); emit dataChanged(); }
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Setup previous scene ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ void ControlPanel::prevScene(){ curSceneIndex--; if ( curSceneIndex < 0 ) curSceneIndex = (int)world->size() - 1; // wraparound std::cerr << "Prev scene " << curSceneIndex << "\n"; resetSliders(); glui->sync_live(); curScene = world->at( curSceneIndex ); redraw(); }
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Setup next scene ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ void ControlPanel::nextScene(){ curSceneIndex++; if ( curSceneIndex >= (int)world->size() ) curSceneIndex = 0; // wraparound std::cerr << "Next scene " << curSceneIndex << "\n"; resetSliders(); glui->sync_live(); curScene = world->at( curSceneIndex ); redraw(); }
MainWindow::MainWindow (QWidget *parent):QWidget(parent){ //objects botaoReset = new QPushButton("Reset"); botaoSair = new QPushButton("Sair"); textoRed = new QLabel("Red"); textoGreen = new QLabel("Green"); char* name = NULL; textoBlue = new QLabel(name); spinBoxRed = new QSpinBox; spinBoxGreen= new QSpinBox; spinBoxBlue = new QSpinBox; //properties spinBoxRed->setRange(0, 255); spinBoxGreen->setRange (0, 255); spinBoxBlue->setRange (0, 255); sliderRed = new QSlider(Qt::Horizontal); sliderGreen = new QSlider(Qt::Horizontal); sliderBlue = new QSlider(Qt::Horizontal); sliderRed->setRange(0, 255); sliderGreen->setRange(0, 255); sliderBlue->setRange(0, 255); // Signals and slots : connect ( spinBoxRed, SIGNAL(valueChanged( int)), sliderRed, SLOT(setValue (int))); connect ( sliderRed, SIGNAL(valueChanged( int)), spinBoxRed, SLOT(setValue (int))); connect ( spinBoxGreen, SIGNAL(valueChanged(int )), sliderGreen, SLOT(setValue (int))); connect ( sliderGreen, SIGNAL(valueChanged(int)), spinBoxGreen, SLOT(setValue (int))); connect ( spinBoxBlue, SIGNAL(valueChanged(int)), sliderBlue, SLOT(setValue (int))); connect ( sliderBlue, SIGNAL(valueChanged( int)), spinBoxBlue, SLOT(setValue (int ))); connect ( botaoSair, SIGNAL(clicked()), this, SLOT(close ())); connect ( botaoReset, SIGNAL(clicked()), this, SLOT(resetSliders())); // Layouts : QGridLayout *layoutCores = new QGridLayout; layoutCores->addWidget(textoRed, 0, 0, 1, 1); layoutCores->addWidget(spinBoxRed, 0, 1, 1,1); layoutCores->addWidget(sliderRed,0, 2, 1, 1); layoutCores->addWidget(textoGreen, 1, 0, 1, 1); layoutCores->addWidget(spinBoxGreen, 1, 1, 1, 1); layoutCores->addWidget(sliderGreen, 1, 2, 1, 1); layoutCores->addWidget(textoBlue,2, 0, 1, 1 ); layoutCores->addWidget(spinBoxBlue, 2, 1, 1, 1); layoutCores->addWidget(sliderBlue, 2, 2, 1, 1); QHBoxLayout *layoutControlo = new QHBoxLayout; layoutControlo->addWidget(botaoReset); layoutControlo->addWidget(botaoSair); QVBoxLayout *layoutJanela = new QVBoxLayout; layoutJanela->addLayout(layoutCores); layoutJanela->addLayout(layoutControlo); setLayout(layoutJanela); }
void TriangleDensityWidget::reset() { TriangleList triangles = triangleScene->triangles(); // make more sliders if necessary while (sliders.size() < triangles.size()) { GroupedSlider* s = new GroupedSlider(Qt::Horizontal, this, sliders.size()); QLabel* name = new QLabel(QString::number(sliders.size() + 1)); QHBoxLayout* hl = new QHBoxLayout(); hl->addWidget(name); hl->addWidget(s); dynamic_cast<QVBoxLayout*> (m_scrollAreaWidgetContents->layout())->insertLayout(-1,hl,0); s->setRange(0, 1000); s->setVisible(false); sliders.append(s); slider_names.append(name); connect(s, SIGNAL(valueChanged(int)), this, SLOT(groupedSliderChangedSlot(int))); connect(s, SIGNAL(sliderPressed()), this, SLOT(groupedSliderPressedSlot())); connect(s, SIGNAL(undoStateSignal()), this, SIGNAL(undoStateSignal())); } // hide non-used sliders for (int n = triangles.size() ; n < sliders.size() ; n++) { sliders.at(n)->setVisible(false); slider_names.at(n)->setVisible(false); } resetSliders(getNorm()); QStringList items; items << tr("None"); for (int n = 1 ; n <= genome->size() ; n++) items << QString::number(n); int n = m_crossComboBox->currentIndex(); m_crossComboBox->blockSignals(true); m_crossComboBox->clear(); m_crossComboBox->addItems(items); m_crossComboBox->setCurrentIndex(n); m_crossComboBox->blockSignals(false); }