void ListViewEditor::columnPixmapChosen()
{
    Column *c = findColumn( colPreview->item( colPreview->currentItem() ) );
    if ( !c )
	return;

    QPixmap pix;
    if ( colPixmap->pixmap() )
	pix = qChoosePixmap( this, formwindow, *colPixmap->pixmap() );
    else
	pix = qChoosePixmap( this, formwindow, QPixmap() );

    if ( pix.isNull() )
	return;

    c->pixmap = pix;
    colPreview->blockSignals( TRUE );
    if ( !c->pixmap.isNull() )
	colPreview->changeItem( c->pixmap, c->text, colPreview->index( c->item ) );
    else
	colPreview->changeItem( c->text, colPreview->index( c->item ) );
    c->item = colPreview->item( colPreview->currentItem() );
    colPixmap->setPixmap( c->pixmap );
    colPreview->blockSignals( FALSE );
    colDeletePixmap->setEnabled( TRUE );
}
Exemple #2
0
void Table::createColumn(string passInName, string passInType) {
	if(findColumn(passInName) != NULL) {
		throw DatabaseException(21, passInName + " already exists.");
	}

	columnList[passInName] = new Column(passInType);
}
Exemple #3
0
/*
 Create a partial table. Used when querying
*/
Table* Database::createPartialTable(Query_parser* parser, string tableName) {
	//Return the already created table everything is fine
	if (parser->tables.size() == 1)
		return findTable(parser->new_table_name);

	//actual stuff  table size > 1
	vector<string> old_columns = parser->old_columns;
	Table* t = new Table("partial" + tableName);
	if(debug)
		cout<<"partila table is "<<t->printSelf()<<endl;
	Table* t_old = findTable(parser->new_table_name);
	for (int k = 0; k < old_columns.size(); k++) {
		string removed = parser->selectFunctionRemove(old_columns[k]);
		
		Column* col;
		
		vector<string> fullName = globalParse::get_separate_statments(removed,
				".");
		if (fullName[0] != tableName && fullName.size() > 1) {
			//if it isnt this table idc
			continue;
		} else if (fullName.size() == 1) {
			//then it is the joined column
			col = t_old->findColumn(parser->new_columns[removed]);
			if (col == NULL)
				throw DatabaseException(20, removed + " does not exist.");
		} else
			col = findColumn(removed);
		//cout << "DOES IT WORK?" << endl;
		//this may not work
		t->createColumn(parser->new_columns[removed], col);
	}
	return t;
}
void ListViewEditor::currentColumnChanged( QListBoxItem *i )
{
    Column *c = findColumn( i );
    if ( !i || !c ) {
	colText->setEnabled( FALSE );
	colPixmap->setEnabled( FALSE );
	colDeletePixmap->setEnabled( FALSE );
	colText->blockSignals( TRUE );
	colText->setText( "" );
	colText->blockSignals( FALSE );
	colClickable->setEnabled( FALSE );
	colResizable->setEnabled( FALSE );
	return;
    }

    colText->setEnabled( TRUE );
    colPixmap->setEnabled( TRUE );
    colDeletePixmap->setEnabled( i->pixmap() && !i->pixmap()->isNull() );
    colClickable->setEnabled( TRUE );
    colResizable->setEnabled( TRUE );

    colText->blockSignals( TRUE );
    colText->setText( c->text );
    colText->blockSignals( FALSE );
    if ( !c->pixmap.isNull() )
	colPixmap->setPixmap( c->pixmap );
    else
	colPixmap->setText( "" );
    colClickable->setChecked( c->clickable );
    colResizable->setChecked( c->resizable );
}
Exemple #5
0
const GFF4Struct *GDAFile::getRowColumn(size_t row, uint32 hash, size_t &column) const {
	const GFF4Struct *gdaRow = getRow(row);
	if (!gdaRow || ((column = findColumn(hash)) == kInvalidColumn))
		return 0;

	return gdaRow;
}
Exemple #6
0
const GFF4Struct *GDAFile::getRowColumn(size_t row, const Common::UString &name, size_t &column) const {
	const GFF4Struct *gdaRow = getRow(row);
	if (!gdaRow || ((column = findColumn(name)) == kInvalidColumn))
		return 0;

	return gdaRow;
}
void ListViewEditor::columnResizable( bool b )
{
    Column *c = findColumn( colPreview->item( colPreview->currentItem() ) );
    if ( !c )
	return;
    c->resizable = b;
}
Exemple #8
0
void merge(EvaluatorTree::e_node parent, EvaluatorTree::e_node child, bool flag){
    vector<Pair<EvaluatorTree::e_node*, int>> parent_sets;
    int index_parent =findColumn(parent.ref);
    int index_child =findColumn(child.ref);
    if(!flag){//the both columns are not empty, do elimination
        EvaluatorTree::Columns* firstColumn = EvaluatorTree::columns.at(0);
        EvaluatorTree::findNode(parent_sets, parent);
        if(parent_sets.size()==0){//if parent is not in the tree
            //do nothing
        }//if
        else{//else found parent
             vector<EvaluatorTree::e_node*> childrenColumn = EvaluatorTree::columns.at(index_child)->links;
            for(int i=0;i<parent_sets.size();i++){
                int parentRow = parent_sets.at(i).getSecond();
                if (childrenColumn.at(parentRow)->value == child.value){
                    EvaluatorTree::e_node* rowHeader = firstColumn->links.at(parentRow);
                     rowHeader->weights++;
                }//if
            }//for
            /*
             should do deletion
             will done in the future
             */
        }//else found parent
    }//if column is not empty
    else{//else one or two column is empty
        if(index_parent==-1){//if parent is not in the result column
            if(EvaluatorTree::columns.size()==0){//if result table is empty
                EvaluatorTree::Columns parentColumn;
                parentColumn.ref = parent.ref;
                parentColumn.links.push_back(&parent);
                EvaluatorTree::columns.push_back(&parentColumn);
                EvaluatorTree::Columns childrenColumn;
                childrenColumn.ref = child.ref;
                childrenColumn.links.push_back(&child);
                EvaluatorTree::columns.push_back(&childrenColumn);
            }//if first Colunm is empty
            else{//if result table is not empty
                if (index_child==-1) {//if child is also not in the table
                    duplicateAndAdd(parent,child)
                }
            
            }
        }//if parent is not in the result column
    
    }//else one or two column is empty
}
Exemple #9
0
void Table::setPrimaryKey(string colName) {
	
	Column *theCol = findColumn(colName);

	if(theCol == NULL) {
		throw DatabaseException(20, colName + " does not exist.");
	}

	theCol->setPrimary(true);
}
Exemple #10
0
size_t GDAFile::findColumn(const Common::UString &name) const {
	ColumnNameMap::const_iterator c = _columnNameMap.find(name);
	if (c != _columnNameMap.end())
		return c->second;

	size_t column = findColumn(Common::hashStringCRC32(name.toLower(), Common::kEncodingUTF16LE));
	_columnNameMap[name] = column;

	return column;
}
Exemple #11
0
/////////BDB//////Check for matching number of columns/////////////////////
void Table::addRow(vector<string> columnNames, vector<string> rowData) {
	for(int i = 0; i < columnNames.size(); i++) {
		Column *thisCol = findColumn(columnNames[i]);
		if(thisCol == NULL) {
			throw DatabaseException(20, "Column " + columnNames[i] + " does not exist.");
		}
		if(thisCol->isPrimaryKey() && thisCol->valExists(rowData[i])) {
			throw DatabaseException(21, rowData[i] + " already exists in column" + columnNames[i] + ".");
		}
		thisCol->addRow(rowData[i]);
	}
}
Exemple #12
0
void findNode(vector<Pair<EvaluatorTree::e_node*, int>>& results, EvaluatorTree::e_node node){
    int i = findColumn(node.ref);
    if(i!=-1){
        vector<EvaluatorTree::e_node*> temp = EvaluatorTree::columns.at(i)->links;
        for(int j =0; j<temp.size();j++){
            if(temp.at(j)->value == node.value){
                Pair<EvaluatorTree::e_node*, int> pair = Pair<EvaluatorTree::e_node*, int>::Pair(temp.at(j), j);
                results.push_back(pair);
            }
                                            
        }
    }
}
void ListViewEditor::columnTextChanged( const QString &txt )
{
    Column *c = findColumn( colPreview->item( colPreview->currentItem() ) );
    if ( !c )
	return;

    c->text = txt;
    colPreview->blockSignals( TRUE );
    if ( !c->pixmap.isNull() )
	colPreview->changeItem( c->pixmap, c->text, colPreview->index( c->item ) );
    else
	colPreview->changeItem( c->text, colPreview->index( c->item ) );
    c->item = colPreview->item( colPreview->currentItem() );
    colPreview->blockSignals( FALSE );
}
Exemple #14
0
void _PlanOperation::computeDeferredIndexes() {
  _field_definition = _indexed_field_definition;
  if (!_named_field_definition.empty()) {

    if ((_named_field_definition.size() == 1) && (_named_field_definition[0] == "*")) {
      for (size_t field_index = 0; field_index < widthOfInputs(input.getTables()); ++field_index) {
        _field_definition.push_back(field_index);
      }
    } else {
      for (size_t i = 0; i < _named_field_definition.size(); ++i) {
        _field_definition.push_back(findColumn(_named_field_definition[i]));
      }
    }
  }
  assert(_field_definition.size() >= (_indexed_field_definition.size() + _named_field_definition.size()));
}
void ListViewEditor::columnPixmapDeleted()
{
    Column *c = findColumn( colPreview->item( colPreview->currentItem() ) );
    if ( !c )
	return;

    c->pixmap = QPixmap();
    colPreview->blockSignals( TRUE );
    if ( !c->pixmap.isNull() )
	colPreview->changeItem( c->pixmap, c->text, colPreview->index( c->item ) );
    else
	colPreview->changeItem( c->text, colPreview->index( c->item ) );
    c->item = colPreview->item( colPreview->currentItem() );
    colPixmap->setText( "" );
    colPreview->blockSignals( FALSE );
    colDeletePixmap->setEnabled( FALSE );
}
Exemple #16
0
const char *ADBRow::operator[](const char *colName)
{
    const char  *retVal;
    ADBColumn   *tmpCol;
    tmpCol = findColumn(colName);
    if (tmpCol) {
        retVal = tmpCol->Data();
        // Check for empty dates
        if (zeroDatesAsNULL && tmpCol->DataType() == FIELD_TYPE_DATE) {
            if (!strcmp("0000-00-00", tmpCol->Data())) {
                retVal = "";
            }
        }
    } else {
        retVal = NULL;
    }
    return retVal;
}
Exemple #17
0
void VParser::addColumn(const char *name, const char *value)
{
    SElement    *curItem = NULL;
    
    curItem = findColumn(name, currentListRow);
    if (curItem == NULL) {
        curItem = new(SElement);
        curItem->Name  = new(char[strlen(name)  + 1]);
        curItem->Value = new(char[strlen(value) + 1]);
        strcpy(curItem->Name,  name);
        strcpy(curItem->Value, value);
        currentListRow->columns.append(curItem);
    } else {
        delete(curItem->Value);
        curItem->Value = new(char[strlen(value) + 1]);
        strcpy(curItem->Value, value);
    }
}
Exemple #18
0
size_t GDAFile::findRow(uint32 id) const {
	size_t idColumn = findColumn("ID");
	if (idColumn == kInvalidColumn)
		return kInvalidRow;

	// Go through all rows of all GFF4s, and look for the ID

	size_t gff4 = 0;
	for (size_t i = 0, j = 0; i < _rowCount; i++, j++) {
		if (j >= _rows[gff4]->size()) {
			if (++gff4 >= _rows.size())
				break;

			j = 0;
		}

		if ((*_rows[gff4])[j] && ((*_rows[gff4])[j]->getUint(idColumn) == id))
			return i;
	}

	return kInvalidRow;
}
void ListViewEditor::setupItems()
{
    itemColumn->setMinValue( 0 );
    itemColumn->setMaxValue( QMAX( numColumns - 1, 0 ) );
    int i = 0;
    QHeader *header = itemsPreview->header();
    for ( QListBoxItem *item = colPreview->firstItem(); item; item = item->next() ) {
	Column *col = findColumn( item );
	if ( !col )
	    continue;
	if ( i >= itemsPreview->columns() )
	    itemsPreview->addColumn( col->text );
	header->setLabel( i, col->pixmap, col->text );
	header->setResizeEnabled( col->resizable, i );
	header->setClickEnabled( col->clickable, i );
	++i;
    }
    while ( itemsPreview->columns() > i )
	itemsPreview->removeColumn( i );

    itemColumn->setValue( QMIN( numColumns - 1, itemColumn->value() ) );
}
boolean annoStreamerFindBed3Columns(struct annoStreamer *self,
			    int *retChromIx, int *retStartIx, int *retEndIx,
			    char **retChromField, char **retStartField, char **retEndField)
/* Scan autoSql for recognized column names corresponding to BED3 columns.
 * Set ret*Ix to list index of each column if found, or -1 if not found.
 * Set ret*Field to column name if found, or NULL if not found.
 * If all three are found, return TRUE; otherwise return FALSE. */
{
struct asColumn *columns = self->asObj->columnList;
if (findColumn(columns, "chrom", retChromIx, retChromField))
    {
    if (findColumn(columns, "chromStart", retStartIx, retStartField))
	return findColumn(columns, "chromEnd", retEndIx, retEndField);
    else return (findColumn(columns, "txStart", retStartIx, retStartField) &&
		 findColumn(columns, "txEnd", retEndIx, retEndField));
    }
else if (findColumn(columns, "tName", retChromIx, retChromField))
    return (findColumn(columns, "tStart", retStartIx, retStartField) &&
	    findColumn(columns, "tEnd", retEndIx, retEndField));
else if (findColumn(columns, "genoName", retChromIx, retChromField))
    return (findColumn(columns, "genoStart", retStartIx, retStartField) &&
	    findColumn(columns, "genoEnd", retEndIx, retEndField));
return FALSE;
}
Exemple #21
0
ADBColumn *ADBRow::col(int colNo)
{
    return findColumn((unsigned int) colNo);
}
Exemple #22
0
ADBColumn *ADBRow::col(const char *colName)
{
    return findColumn(colName);
}
Exemple #23
0
/*
 this is given the partial tables that are returned by the query
 it is also given the columns that are joined
 it will go through all the joined column pairs
 for each pair it will find all of the matching rows
 for each matching row it will combine them
 for each row that is not in both it will add it to the end
*/
void Database::combineTables(vector<Table*> tables, Query_parser* parser,
		Table* into) {

	//tables should have the wored partial on it
	for (int k = 0; k < tables.size(); k++) {
		if (tables[k] == NULL) {
			throw DatabaseException(10, "NULL TABLE does not exist.");
		}
		string name = tables[k]->getTableName();
		name = name.substr(7, name.length());
	}
	
	vector<string> combines = parser->join_columns;
	for (int k = 0; k < combines.size(); k += 2) {
		vector<string> pairOne = globalParse::get_separate_statments(
				combines[k], ".");
		vector<string> pairTwo = globalParse::get_separate_statments(
				combines[k + 1], ".");
		if(debug)
		{
			cout<<"OTHER TABLES IS "<<"partial" + pairOne[0]<<"partial" + pairTwo[0]<<endl;
		}
		Table* table1 = findTable("partial" + pairOne[0]);
		Table* table2 = findTable("partial" + pairTwo[0]);
		if (table1 == NULL) {
			throw DatabaseException(10, pairOne[0] + " does not exist.");
		}
		if (table2 == NULL) {
			throw DatabaseException(10, pairTwo[0] + " does not exist.");
		}
		//tables are not null

		string column1Name = parser->short_name_new_columns[pairOne[1]];
		string column2Name = parser->short_name_new_columns[pairTwo[1]];
	//	cout<<"THESE ARE "<<column1Name<<" "<<pairOne[1]<<endl;


	//	cout<<"THESE ARE "<<column2Name<<" "<<pairTwo[1]<<endl;
		Column* col1;
		if(table1->findColumn(column1Name)==NULL||column1Name==""||column1Name==" ")
		{
	//		cout<<"FIND COLUMN "<<pairOne[1]<<table1->getTableName()<<" "<<combines[k]<<endl;
			col1=findColumn(combines[k]);
		}else
		{
			col1 = table1->findColumn(column1Name);
		}
		Column* col2;
		if(table2->findColumn(column2Name)==NULL||column2Name==""||column1Name==" ")
		{
	//		cout<<"FIND COLUMN "<<pairTwo[1]<<table2->getTableName()<<" "<<combines[k+1]<<endl;
			col2=findColumn(combines[k+1]);
		}else
		{
			col2=table2->findColumn(column2Name);
		}
		if (col1 == NULL) {
			throw DatabaseException(20, column1Name + " does not exist.");
		}
		if (col2 == NULL) {
			throw DatabaseException(20, column2Name + " does not exist.");
		}

		//columns are not null
		if (col1->getColumnType() != col2->getColumnType()) {
			if (tables[k] == NULL) {
				throw DatabaseException(
						13,
						pairOne[1] + " must have the same type as "
								+ pairTwo[1]);
			}
		}
		
		//this will combine the columns into a kinda new table
		//so that it will only loop through the rows
		map<string, Column*> columnNameToColumn;
		//this will be a map that determines whether it is the first table or second
		//true=first, false=second
		map<string, bool> firstOrSecond;
		vector<string> names = into->columnNames();
		for (int nameCount = 0; nameCount < names.size(); nameCount++) {
			string name = names[nameCount];
			Column* table1column = table1->findColumn(name);
			Column* table2column = table2->findColumn(name);
			if (table1column != NULL && table2column != NULL) {
				continue;
			}
			if (table1column != NULL) {
				columnNameToColumn[names[nameCount]] = table1column;
				firstOrSecond[name] = true;
			}
			if (table2column != NULL) {
				columnNameToColumn[names[nameCount]] = table2column;
				firstOrSecond[name] = false;
			}
		}

		map<int, bool> matchedrows;
		//goes through and finds matching rows
		for (int col1C = 0; col1C < col1->rowCount(); col1C++) {
			string value = col1->getValueAtRowIndex(col1C);
			bool matched = false;
			for (int col2C = 0; col2C < col2->rowCount(); col2C++) {
				string value2 = col2->getValueAtRowIndex(col2C);
				if (value == value2) {
					matched = true;
					matchedrows[col2C] = true;
					vector<string> rowdata;
					//We need to combine them now
					for (int nameCount = 0; nameCount < names.size();
							nameCount++) {
						if(debug)
						{
							cout<<names[nameCount]<<endl;
						}
						string name = names[nameCount];
						string data;
						if (name != column1Name) {
							//get the column with the same name  if it is the first get at one index else the other
							int index = firstOrSecond[name] ? col1C : col2C;
							data = columnNameToColumn[name]->getValueAtRowIndex(
									index);

						} else {
							data = value;
						}
						if(debug)
						{
							cout<<"PUSHING BACK "<<data<<endl;
						}
						rowdata.push_back(data);
					}
					into->addRow(names, rowdata);
				} else {

					if (!matchedrows[col2C]) {
						//just to make sure it is set
						matchedrows[col2C] = false;
					}
				}
			}
			if (!matched) {
				vector<string> rowdata;
				for (int nameCount = 0; nameCount < names.size(); nameCount++) {

					string name = names[nameCount];
					//get the column with the same name  if it is the first get at one index else the other
					string data = "";
					if (name == column1Name) {
						data = value;
					} else if (firstOrSecond[name]) {
						data = columnNameToColumn[name]->getValueAtRowIndex(
								col1C);
					} else {
						//leet for default  (it is so that it wont be confused as an actual value)
						data = "D3FAL7";
					}
					if(debug)
					{
						cout<<"PUSHING BACK "<<data<<endl;
					}
					rowdata.push_back(data);
				}

				into->addRow(names, rowdata);
				//left side has one that is not in right side
			}
		}
		map<int, bool>::iterator it;
		for (it = matchedrows.begin(); it != matchedrows.end(); it++) {
			if (!(*it).second) {
				//the right side had one that is not in the left side
				vector<string> rowdata;
				for (int nameCount = 0; nameCount < names.size(); nameCount++) {
					string name = names[nameCount];
					//get the column with the same name  if it is the first get at one index else the other
					string data = "";
					if (name == column2Name) {
						data = col2->getValueAtRowIndex((*it).first);
					} else if (!firstOrSecond[name]) {
						data = columnNameToColumn[name]->getValueAtRowIndex(
								(*it).first);
					} else {
						data = "D3FAL7"; //leet for default  (it is so that it wont be confused as an actual value)
					}
					if(debug)
					{
						cout<<"PUSHING BACK "<<data<<endl;
					}
					rowdata.push_back(data);
				}
				into->addRow(names, rowdata);
			}
		}

	}

	if(debug)
	{
		cerr<<into->printSelf()<<endl;
	}
	//these tables should have items that match up
	//they should actually be in pairs of two!!
	//also they are in order with the table name
}
Exemple #24
0
void testApp::manageStars(){
	
	
	//first tidy up the active stars
		
	for(int i = 0; i < activeStarList.size(); i ++){
		
		if(!activeStarList[i]->isActive){
			int col = findColumn(activeStarList[i]->pos.x);
			
			if(activeStarList[i]->col != col){
				// - ONLY if a different column
				//erase old column reference
				
				vector<star *>::iterator it = remove(stars2d[activeStarList[i]->col].begin(), stars2d[activeStarList[i]->col].end(), 
													   activeStarList[i]);

				stars2d[activeStarList[i]->col].erase(it, stars2d[activeStarList[i]->col].end());
				
				 // put a new star pointer into the relevant column
				stars2d[col].push_back(activeStarList[i]);
				activeStarList[i]->col = col;
			}
			
			activeStarList[i]->twinkle(5);
			ofxOscMessage m;
			m.setAddress("/endStar");
			m.addIntArg(activeStarList[i]->pairedUser->id);
			sender.sendMessage(m);
		
			
		}		
	} 
	
	vector<star *>::iterator it = remove_if(activeStarList.begin(), activeStarList.end(), isStarInactive); //erase all refs to inactive stars
	activeStarList.erase(it, activeStarList.end());
	
	//then call update on all stars
	for(int i = 0; i < stars2d.size(); i ++){
		for(int j = 0; j < stars2d[i].size(); j ++){
	
				stars2d[i][j]->update(); 
				
				if(stars2d[i][j]->isActive){
				
					float a = stars2d[i][j]->active_size/stars2d[i][j]->max_size; //there could ultimately be different max_sizes
					ofxOscMessage m;
					m.setAddress("/updateStar");
					m.addIntArg(stars2d[i][j]->pairedUser->id); //the users id for no searching in sclang
					m.addFloatArg(a); // normalised value for size;
					m.addIntArg(stars2d[i][j]->activeStar->newEvent);
					m.addIntArg(stars2d[i][j]->activeStar->eventTime);
					m.addIntArg(stars2d[i][j]->activeStar->eventPolarity);
					m.addFloatArg(stars2d[i][j]->pos.x/screenWidth);
					sender.sendMessage(m);
				}
			
		}
	}
	
	
	//now handle star lighting
	
	static int msecs = 0;
	static int currentCol = findColumn(-screenWidth/2);
	static int colCount = 0;
	static int sleepTime = 27;
	static int finalMills = 0;
	
	if(sleepTime < 30){
		for(int i = 0; i < stars2d.size(); i ++){  //random twickling ...maybe iterative is not necessary 
			for(int j = 0; j < stars2d[i].size(); j ++){
				
				if(!stars2d[i][j]->twinkling){
					
					float twink = ofRandom(0,1);
					if(twink <= (float)1/numStars * 1/20){
						
							if(stars2d[i][j]->size < 3 && !stars2d[i][j]->isActive)stars2d[i][j]->twinkle(ofRandom(10,20));
					}
					
				} 
				
			} 
		}
	}

	//time counting wave  of stars
	
	int waveWidth = 7;
	int distance = screenWidth + (-rotSpeed * 1800) + (waveWidth-1) * columnWidth;
	int timeInterval = 30000 * columnWidth/distance;
	


	if(sleepTime < 30 & ofGetElapsedTimeMillis() > msecs){
		
		sleepTime += 1;
		msecs = ofGetElapsedTimeMillis() + 1000;
		
		if(sleepTime == 30){
			ofxOscMessage m; //tell superCollider to begin wave
			m.setAddress("/wave");
			sender.sendMessage(m);
		}
		
	}else if(sleepTime == 30 && ofGetElapsedTimeMillis() > msecs){	
		
		if(colCount == 0){ //start of wave
			currentCol = findColumn(-screenWidth/2); //find the first column
			finalMills = (30000 - (waveWidth * 220)) + ofGetElapsedTimeMillis();
		}
		
		msecs = ofGetElapsedTimeMillis() + timeInterval;
		currentCol = (currentCol + 1)%stars2d.size();
		colCount += 1;
		
		if(ofGetElapsedTimeMillis() > finalMills){
			colCount = 0;
			sleepTime = 0;
			msecs = ofGetElapsedTimeMillis() + 1000;
		}
		
	}else if(colCount > 0){
		
		int numCols = min(waveWidth, colCount);
		
		for(int i = 0; i < numCols; i++){
			int c = currentCol - i;
			if(c < 0)c = c + stars2d.size(); //wrapping
			for(int j = 0; j < stars2d[c].size(); j ++){
				
				if(!stars2d[c][j]->twinkling){
					
					float twink = ofRandom(0,1);
					if(twink <= (float)1/(2 * stars2d[c].size())){
						stars2d[c][j]->twinkle(ofRandom(100,220));
						
					}
					
				} 
			}
			
		}
		
		
	}

	

}
 /* {{{ MySQL_ArtResultSet::isNull() -I- */
 bool
 MySQL_ArtResultSet::isNull(const sql::SQLString& columnLabel) const
 {
     CPP_ENTER("MySQL_ArtResultSet::isNull(string)");
     return isNull(findColumn(columnLabel));
 }
 /* {{{ MySQL_ArtResultSet::getString() -I- */
 SQLString
 MySQL_ArtResultSet::getString(const sql::SQLString& columnLabel) const
 {
     CPP_ENTER("MySQL_ArtResultSet::getString(string)");
     return getString(findColumn(columnLabel));
 }
 /* {{{ MySQL_ArtResultSet::getUInt64() -I- */
 uint64_t
 MySQL_ArtResultSet::getUInt64(const sql::SQLString& columnLabel) const
 {
     CPP_ENTER("MySQL_ArtResultSet::getUInt64(string)");
     return getUInt64(findColumn(columnLabel));
 }
 /* {{{ MySQL_ArtResultSet::getDouble() -I- */
 long double
 MySQL_ArtResultSet::getDouble(const sql::SQLString& columnLabel) const
 {
     CPP_ENTER("MySQL_ArtResultSet::getDouble(string)");
     return getDouble(findColumn(columnLabel));
 }
Exemple #29
0
void printGraph(char *commits[], int numcommits)
{ // please pretend this isn't hideous!
    memset(columns, -1, 10*sizeof(int));
    node *commit, *tempone, *temptwo, *childptr;
    char smallHash[6];
    char *p = printBuffer;
    char line[200];
    
    int i, j, parents, children, numbranches;

    // handle root first
    memset(line, '\0', 100*sizeof(char));
    commit = getNode(commits[0]);
    getFirstSix(commit->commitHash, smallHash);
    columnInsert(commit->key, 0);
    asciiCommit(1, 0, line);
    strcat(line, smallHash);
    printf("%s\n", line);
    numbranches = 1;
    childptr = commit->children[0];
    columns[0] = childptr->key;
    for (i = 1; i < commit->numchildren; i++) {
        columnInsert((commit->children[i])->key, i);
        printf("yikes!\n");
    }

    int numpar, numchild, index1, index2;
    // the rest of the commits!
    for (i = 1; i < numcommits; i++) {
        memset(line, '\0', 100*sizeof(char));
        commit = getNode(commits[i]);
        getFirstSix(commit->commitHash, smallHash);
        numpar = commit->numparents;
        numchild = commit->numchildren;

            /* MERGING */

        if (numpar > 1) { 
            for (j = 1; j < numpar; j++) {
                tempone = commit->parents[j-1];
                index1 = findColumn(commit->commitHash, 9);
                temptwo = commit->parents[j];
                index2 = findColumn(commit->commitHash, index1-1);
                if (index1 < index2) {
                    asciiMerge(index1, index2, numbranches - index2, line);
                    columnDelete(index2);
                }
                else {
                    asciiMerge(index2, index1, numbranches - index1 -1, line);
                    columnDelete(index1);
                }
                numbranches--;
            }
        }   
        
            /* COMMIT LINE */

        index1 = findColumn(commit->commitHash, 9);
        asciiCommit(numbranches, index1, line);
        strcat(line, smallHash);
        strcat(line, "\n");

            /* BRANCHING */

        if (numchild == 1) { // don't branch
            childptr = commit->children[0];
            columns[index1] = childptr->key;
        } else if (numchild == 0) {
        } else { // need to branch
            childptr = commit->children[0];
            columns[index1] = childptr->key;
            for (j = 1; j < numchild; j++) {
                childptr = commit->children[j];
                columnInsert(childptr->key, index1+j);
                numbranches++;
            }
            asciiSplit(numchild, index1, line);
        }
        strcpy(p, line);
        p += strlen(line);
    }
    printf("%s\n", printBuffer);
}