//Display Sound Wave void displayWave(signed short int s[], double df[]){ int i, j; double sum, rms, dBrms, sumdf; #ifdef DEBUG_INFO for(i=0; i<80;i++){ for(j=0, sum=0.0; j<200;j++){ sum+=s[i*200+j]*s[i*200+j]; } rms=sqrt(sum)/200; dBrms = 20*log10(rms); printf("Chunk %d: rms:%.3f in dB: %.3f\n", i, rms, dBrms); } #else //not define DEBUG_INFO for(i=0;i<80;i++){ for(j=0, rms=0,sum=0;j<200;j++){ sum+=s[i*200+j]*s[i*200+j]; } rms=sqrt(sum)/200; //calculate rms value of sound dBrms = 20*log10(rms); //change to dB value if(dBrms>40) setColors(YELLOW, bg(BLACK)); //if dBrms value is more than 40, change color to Yellow else setColors(WHITE, bg(BLACK)); //else keep White default color dispBar(i+1, 30-round(dBrms/2.5),30); //display Bar chart with gained parameters resetColors(); puts(""); } #endif for(i=0;i<FASTSIZE;i++){ for(j=0,sumdf=0.0;j<SAMPLE_PER_SEC/FASTSIZE;j++){ //8 values for rms sumdf += s[i*2000+j]*s[i*2000+j]; } rms = sqrt(sumdf)/2000; df[i]=20*log10(rms); } }
void reset(struct Node* x) { stack.len = 0; cycle.len = 0; joinPointFound = NULL; resetColors(x); stack.len = 0; }
void resetColors(struct Node* x) { if (x == NULL) return; if (traversed(x)) { return; } add(&stack, x, NULL); x->color = 0; resetColors(x->next); int i; for (i = 0; i < x->nYields; i++) { resetColors(x->yields[i]); } }
bool WidgetsBase::qt_invoke( int _id, QUObject* _o ) { switch ( _id - staticMetaObject()->slotOffset() ) { case 0: resetColors(); break; case 1: setColor(); break; case 2: updateClock(); break; case 3: languageChange(); break; case 4: init(); break; case 5: destroy(); break; case 6: setColor((const QString&)static_QUType_QString.get(_o+1)); break; case 7: updateColorTest((const QString&)static_QUType_QString.get(_o+1)); break; case 8: updateDateTimeString(); break; default: return QWidget::qt_invoke( _id, _o ); } return TRUE; }
void InstrumentRenderer::reset() { resetColors(); resetPickColors(); for (auto &texture : m_textures) { texture.buildColorTextures(m_colors, m_isUsingLayers, m_layer); texture.buildPickTextures(m_pickColors, m_isUsingLayers, m_layer); } /// Invalidate the OpenGL display lists to force full re-drawing of the /// instrument and creation of new lists. for (size_t i = 0; i < 2; ++i) { if (m_displayListId[i] != 0) { glDeleteLists(m_displayListId[i], 1); m_displayListId[i] = 0; m_useDisplayList[i] = false; } } }
//construct the cluster tree for interRing display according to the arrays; //parameters: int num_nodes-number of nodes. //parameters: array nodes-nodes stored in an array according to their ids. nodes[0] must be the root node. //parameters: array parent_ids-corresponding nodes' parent' ids. nodes[0](the root node)'s parent id is //-1. Other parent ids should be larger than -1. bool InterRingClusterTree::constructInterRingClusterTree(int num_nodes, std::vector<InterRingCluster *> nodes, std::vector<int> parent_ids) { //if can't find the root node, return false if ( parent_ids[0] != -1 || nodes[0] == NULL) return false; //link the clusters into a tree root = nodes[0]; for ( int i = 1; i < num_nodes; i++ ) { if ( parent_ids[i] < 0 || parent_ids[i] >= num_nodes ) return false; if ( nodes[parent_ids[i]] == NULL ) return false; nodes[parent_ids[i]]->addChild(nodes[i]); } resetLevels(); resetAngles(); resetColors(); return true; }
QgsUniqueValueDialog::QgsUniqueValueDialog( QgsVectorLayer* vl ): QDialog(), mVectorLayer( vl ), sydialog( vl, true ) { setupUi( this ); setOrientation( Qt::Vertical ); //find out the fields of mVectorLayer if ( mVectorLayer ) { //we cannot use unique values for not-commited fields because QgsVectorLayer has no 'unique values' method... QgsVectorDataProvider* provider = mVectorLayer->dataProvider(); if ( provider ) { const QgsFieldMap & fields = provider->fields(); QString str; for ( QgsFieldMap::const_iterator it = fields.begin(); it != fields.end(); ++it ) { str = ( *it ).name(); str = mVectorLayer->attributeDisplayName( it.key() ); mClassificationComboBox->addItem( str, it.key() ); } } } mClassListWidget->setSelectionMode( QAbstractItemView::ExtendedSelection ); mClassListWidget->setEditTriggers( QAbstractItemView::DoubleClicked | QAbstractItemView::EditKeyPressed | QAbstractItemView::AnyKeyPressed ); mClassListWidget->setSortingEnabled( true ); if ( mVectorLayer ) { const QgsUniqueValueRenderer* renderer = dynamic_cast<const QgsUniqueValueRenderer *>( mVectorLayer->renderer() ); if ( renderer ) { mClassListWidget->clear(); QString field = mVectorLayer->attributeDisplayName( renderer->classificationField() ); mOldClassificationAttribute = field; mClassificationComboBox->setCurrentIndex( mClassificationComboBox->findText( field ) ); const QList<QgsSymbol*> list = renderer->symbols(); //fill the items of the renderer into mValues for ( QList<QgsSymbol*>::const_iterator iter = list.begin(); iter != list.end(); ++iter ) { QgsSymbol* symbol = *iter; QString symbolvalue = symbol->lowerValue(); QgsSymbol* sym = new QgsSymbol( mVectorLayer->geometryType(), symbol->lowerValue(), symbol->upperValue(), symbol->label() ); sym->setPen( symbol->pen() ); sym->setCustomTexture( symbol->customTexture() ); sym->setBrush( symbol->brush() ); sym->setNamedPointSymbol( symbol->pointSymbolName() ); sym->setPointSize( symbol->pointSize() ); sym->setPointSizeUnits( symbol->pointSizeUnits() ); sym->setScaleClassificationField( symbol->scaleClassificationField() ); sym->setRotationClassificationField( symbol->rotationClassificationField() ); mValues.insert( symbolvalue, sym ); QListWidgetItem *item = new QListWidgetItem( symbolvalue ); mClassListWidget->addItem( item ); updateEntryIcon( symbol, item ); item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled ); item->setData( Qt::UserRole, symbol->lowerValue() ); item->setToolTip( symbol->label() ); } } } mDeletePushButton->setEnabled( false ); connect( mClassifyButton, SIGNAL( clicked() ), this, SLOT( changeClassificationAttribute() ) ); connect( mAddButton, SIGNAL( clicked() ), this, SLOT( addClass() ) ); connect( mDeletePushButton, SIGNAL( clicked() ), this, SLOT( deleteSelectedClasses() ) ); connect( mRandomizeColors, SIGNAL( clicked() ), this, SLOT( randomizeColors() ) ); connect( mResetColors, SIGNAL( clicked() ), this, SLOT( resetColors() ) ); connect( mClassListWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( selectionChanged() ) ); connect( mCommonPropertyLock, SIGNAL( clicked() ), this, SLOT( selectionChanged() ) ); connect( mClassListWidget, SIGNAL( itemChanged( QListWidgetItem * ) ), this, SLOT( itemChanged( QListWidgetItem * ) ) ); connect( &sydialog, SIGNAL( settingsChanged() ), this, SLOT( applySymbologyChanges() ) ); mSymbolWidgetStack->addWidget( &sydialog ); mSymbolWidgetStack->setCurrentWidget( &sydialog ); }
void Menu::start() { isRunning = true; current = 0; resetColors(); loadText(); }
void Menu::decreaseCurrent() { current = (current + layout.size()-1) % layout.size(); resetColors(); }
void Menu::increaseCurrent() { current = (current + 1) % layout.size(); resetColors(); }
int main(int argc, char *argv[]) { wireframe = 1; cubecount = 0; cubemax = 10000; int dir = 1; int camdir = 1; short gameon = 1; int tracker = -100; int trackerprime = -tracker; int zdist = -50; int cubesize = 50; int cubeloc = 0; int cubelocy = 50; double stepcount = 0; double turncount = 0; camry = 0; camrx = 0; camrz = 0; camx = 0; camy = 0; camz = -250; //world objects cubes = malloc(cubemax*sizeof(shape*)); for(int i = 0; i < cubemax; i++){ cubes[i] = malloc(sizeof(shape)); } init_time(); startengine(); //initialize stuff //create floor int ctrack = 0; for(int x = -1000; x < 1000; x += cubesize){ for(int z = -1000; z < 1000; z += cubesize){ short colr; if(ctrack%2 == 0) colr = COLOR_BLUE; else colr = COLOR_GREEN; *(cubes[cubecount]) = cube(x, 100, z, cubesize, colr); cubecount++;ctrack++; } ctrack++; } //place some bridges for(int i = cubesize * 0; i >= 0; i -= cubesize){ rainbowstairs(tracker - 2*i,cubeloc+cubesize*6,cubesize,cubelocy); rainbowstairs(-tracker + 2*i,cubeloc+cubesize*6,cubesize,cubelocy); rainbowstairs(tracker - 2*i,cubeloc,cubesize,cubelocy); rainbowstairs(-tracker + 2*i,cubeloc,cubesize,cubelocy); rainbowstairs(tracker - 2*i,cubeloc-cubesize*6,cubesize,cubelocy); rainbowstairs(-tracker + 2*i,cubeloc-cubesize*6,cubesize,cubelocy); rainbowstairs(tracker - 2*i,cubeloc+cubesize*12,cubesize,cubelocy); rainbowstairs(-tracker + 2*i,cubeloc+cubesize*12,cubesize,cubelocy); } //test *(cubes[cubecount]) = cube(0, -50,-100, cubesize,COLOR_RED); cubecount++; *(cubes[cubecount]) = cube(0, -50,300, cubesize,COLOR_YELLOW); cubecount++; //pyramid(-500,-25,0,50); //variables to track movement int rotateleft = -1; int rotateright = -1; int movingforward = -1; int movingbackward = -1; double timepassed = 0; lasttime = get_time(); if(argc > 1 && strcmp(argv[1],"t") == 0) wireframe = 0; //main loop while(gameon){ getmaxyx(stdscr,row,col); r = row; c = col; for(int i = 0; i < cubecount; i++){ translatecube(cubes[i]); } //sort cubes every 10 frames if(!(ccount%10)) qsort((void*)cubes,cubecount,sizeof(shape*),cubesort); //draw cubes to buffer for(int i = 0; i < cubecount; i++){ if(argc > 1 && strcmp(argv[1],"1") == 0) drawCube(cubes[i],1); else drawCube(cubes[i],0); free(cubes[i]->v2); } //copy buffer to screen drawscreen(); ccount++; refresh(); move(0,0); resetColors(); resetZBuffer(); currtime = get_time(); framerate = (double)(1.0/((currtime - lasttime)*0.000001)); timepassed = (double)(currtime - lasttime); lasttime = currtime; //get keyboard input ch = getch(); if(ch != ERR){ if(ch == KEY_RIGHT || ch =='d'){ if(rotateright == 1 && turncount > 0){ turncount = 0; } else{ rotateleft = 1; turncount = 0.15; } rotateright = -1; } else if(ch == KEY_LEFT || ch == 'a'){ if(rotateleft == 1 && turncount > 0){ turncount = 0; } else{ rotateright = 1; turncount = 0.15; } rotateleft = -1; } else if(ch == KEY_UP || ch == 'w'){ if(movingbackward != 1){ movingforward = 1; stepcount = 0.15; } else movingbackward = -1; } else if(ch == KEY_DOWN || ch == 's'){ if(movingforward != 1){ movingbackward = 1; stepcount = 0.15; } else movingforward = -1; } else if(ch == ' '){ turncount = 0; } else if(ch == 'q') gameon = 0; } double ff = timepassed/1500; int speed = ff; if(rotateleft == 1){ if(turncount > 0){ camry-=ff/2; turncount -= 1/framerate; } } if(rotateright == 1){ if(turncount > 0){ camry+=ff/2; turncount -= 1/framerate; } } if(movingforward == 1){ if(stepcount > 0){ camz += speed*cos(0.01*camry); camx -= speed*sin(0.01*camry); //camz+=ff/2; stepcount -= 1/framerate; } } if(movingbackward == 1){ if(stepcount > 0){ camz -= speed*cos(0.01*camry); camx += speed*sin(0.01*camry); //camz-=ff/2; stepcount -= 1/framerate; } } zval = camz + 500; dist = -camz; //usleep(16000); } for(int i = 0; i < cubemax; i++){ free(cubes[i]->v3); free(cubes[i]); } free(cubes); killengine();//prevent memory leaks return 0; }