RepoEditor::RepoEditor( QWidget *parent ) : QDialog( parent ) , ui( new Ui::RepoEditor ) { ui->setupUi( this ); repoConf = new RepoConf(); addRepoDialog = new AddRepo( this ); ui->tableView->setModel( repoConf ); ui->tableView->setItemDelegateForColumn( 0, new CheckBoxDelegate( this) ); ui->tableView->setItemDelegateForColumn( 2, new OptionsDelegate( this) ); ui->tableView->setColumnWidth( 1, 133 ); ui->backupFile->setText( repoConf->getConfPath() + ".bak" ); connect( ui->moveUp, SIGNAL( clicked() ), SLOT( moveUp() ) ); connect( ui->moveDown, SIGNAL( clicked() ), SLOT( moveDown() ) ); QItemSelectionModel *selModel = ui->tableView->selectionModel(); connect( selModel, SIGNAL( selectionChanged( QItemSelection,QItemSelection ) ), SLOT( updateMovers( QItemSelection,QItemSelection ) ) ); connect( ui->buttonBox->button( QDialogButtonBox::Reset ), SIGNAL( clicked() ), repoConf, SLOT( reload() ) ); connect( ui->buttonBox->button( QDialogButtonBox::Save ), SIGNAL( clicked() ), SLOT( apply() ) ); connect( ui->buttonBox->button( QDialogButtonBox::Discard ), SIGNAL( clicked() ), SLOT( discard() ) ); connect( ui->remove, SIGNAL( clicked() ), SLOT( removeEntry() ) ); connect( ui->add, SIGNAL( clicked() ), SLOT( addEntry() ) ); connect( ui->edit, SIGNAL( clicked() ), SLOT( editEntry() ) ); connect( ui->loadBackup, SIGNAL( clicked() ), SLOT( loadBackup() ) ); ui->tableView->selectRow(0); }
//-------------------------------------------------------------- void testApp::update(){ for (int i = 0; i < simSpeed; i++){ for (int i = 0; i < nbLedProjector; i++){ spots[i].set(0); } //updatePerlinNoise(); updateMovers(); updateSpotFromMoversGaussian(); } float hue = ofMap(temperature, -5, 32, 0, 260/360.); for (int i = 0; i < nbLedProjector; i++){ spots[i].setHsb(hue,colorSaturation/100.,spots[i].getBrightness()); } #ifdef SHADER_RENDERING display.update(spots); #endif updateDmx(); updateOsc(); ofSetWindowTitle(ofToString(ofGetFrameRate())); }
//-------------------------------------------------------------- void ofApp::update() { for (int i = 0; i < trains.size(); i++) { if (trains[i].pos.x > 1047/2 && trains[i].pos.x < 1047) { if (trains[i].pos.y + trains[i].vel.y >= 304 && trains[i].pos.y < 304) { Wave wave; wave.a = 1.1f; wave.b = 3.0*(curWidth/4.0); wave.c = 100.0; wave.bVel = 10.0; if (ofRandom(1.0)>0.5) { wave.bVel*=-1.0; } wave.growing = true; waves.push_back(wave); pulseRightGrowing = true; } else if (trains[i].pos.y + trains[i].vel.y >= 373 && trains[i].pos.y < 373) { Wave wave; wave.a = 1.1f; wave.b = 3.0*(curWidth/4.0); wave.c = 100.0; wave.bVel = 10.0; if (ofRandom(1.0)>0.5) { wave.bVel*=-1.0; } wave.growing = true; waves.push_back(wave); pulseRightGrowing = true; } else if (trains[i].pos.y + trains[i].vel.y >= 595 && trains[i].pos.y < 595) { Wave wave; wave.a = 1.1f; wave.b = 3.0*(curWidth/4.0); wave.c = 100.0; wave.bVel = 10.0; if (ofRandom(1.0)>0.5) { wave.bVel*=-1.0; } wave.growing = true; waves.push_back(wave); pulseRightGrowing = true; } else if (trains[i].pos.y + trains[i].vel.y >= 659 && trains[i].pos.y < 659) { Wave wave; wave.a = 1.1f; wave.b = 3.0*(curWidth/4.0); wave.c = 100.0; wave.bVel = 10.0; if (ofRandom(1.0)>0.5) { wave.bVel*=-1.0; } wave.growing = true; waves.push_back(wave); pulseRightGrowing = true; } } else { if (trains[i].pos.y + trains[i].vel.y <= 292 && trains[i].pos.y >= 292) { cout << i << endl; Wave wave; wave.a = 1.1f; wave.b = (curWidth/4.0); wave.c = 100.0; wave.bVel = 10.0; if (ofRandom(1.0)>0.5) { wave.bVel*=-1.0; } wave.growing = true; waves.push_back(wave); pulseLeftGrowing = true; } else if (trains[i].pos.y + trains[i].vel.y <= 647 && trains[i].pos.y >= 647) { cout << i << endl; Wave wave; wave.a = 1.1f; wave.b = (curWidth/4.0); wave.c = 100.0; wave.bVel = 10.0; if (ofRandom(1.0)>0.5) { wave.bVel*=-1.0; } wave.growing = true; waves.push_back(wave); pulseLeftGrowing = true; } } } // if (autoMode) { // if (ofRandom(1.0)>0.99) { // float newProb = ofRandom(4.0); // if (newProb >= 0.0 && newProb <= 1.0) { // addCars(4); // } else if (newProb >= 1.0 && newProb <= 2.0) { // addTrains(); // } else if (newProb >= 2.0 && newProb <= 3.0) { // addPeople(20); // } else { // addBikes(4); // } // } // if (ofRandom(1.0) > 0.99) { // if (ofRandom(1.0) > 0.5) { // Wave wave; // wave.a = 1.1f; // wave.b = (curWidth/4.0); // wave.c = 100.0; // wave.bVel = 10.0; // if (ofRandom(1.0)>0.5) { // wave.bVel*=-1.0; // } // wave.growing = true; // waves.push_back(wave); // pulseLeftGrowing = true; // } else { // Wave wave; // wave.a = 1.1f; // wave.b = 3.0*(curWidth/4.0); // wave.c = 100.0; // wave.bVel = 10.0; // if (ofRandom(1.0)>0.5) { // wave.bVel*=-1.0; // } // wave.growing = true; // waves.push_back(wave); // pulseRightGrowing = true; // } // } // } for (int i = 0; i < waves.size(); i++) { for (int x = 0; x < 1280; x++) { float top = pow(x-waves[i].b,2); float bottom = 2*pow(waves[i].c,2); waves[i].curve[x] = waves[i].a*exp(-(top/bottom)); } waves[i].b += waves[i].bVel; if (waves[i].b >= ofGetWidth() || waves[i].b <= 0) { waves[i].bVel*=-1; } if (waves[i].a < (curHeight/4.0) - 6.0 && waves[i].growing) { waves[i].a*=aGrowthRate; } else { waves[i].growing = false; waves[i].a*=decayRate; } if (!waves[i].growing) { waves[i].bVel*=bAccel; } waves[i].c*=growthRate; } vector<int> toErase; for (int i = 0; i < waves.size(); i++) { if (waves[i].a < 1.0) { toErase.push_back(i); } } for (int i = 0; i < toErase.size(); i++) { int pos = toErase[i]; waves.erase(waves.begin() + pos); } if (trainGrowing) { ambientLevel *= trainGrowthRate; if (ambientLevel >= 255.0) { ambientLevel = 255.0; trainGrowing = false; } } else if (!trainGrowing && ambientLevel > 51.0) { ambientLevel *= trainDecay; if (ambientLevel <= 51.0) { ambientLevel = 51.0; } } for (int x = 0; x < 1280; x++) { float newVal = 0.0; for (int i = 0; i < waves.size(); i++) { newVal += waves[i].curve[x]; } gaussian[x] = ofMap(ofClamp(newVal,0.0,255.0), 0.0, 255.0, ambientLevel, 255.0); } cars = updateMovers(cars); trains = updateMovers(trains); people = updateMovers(people); bikes = updateMovers(bikes); }