void renderStrokeLine(float x, float y, float z, char* line, float size) { string string_line(line); glPushMatrix(); glTranslatef(x - getTextWidth(&string_line, size) * 0.5f, y - (36.0f*size), z); //glRasterPos3f(x - getTextWidth(&string_line, size) * 0.5f, y - (36.0f*size), z); glScalef(size, size, 1.0f); for (unsigned int c = 0; line[c] != 0; c++) { glutStrokeCharacter(GLUT_STROKE_ROMAN, line[c]); //glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, line[c]); } glPopMatrix(); }
//==================================== // readDict... //------------------------------------ Q3Dict<QString> SCCFile::readDict (void) { // .../ // read the contents of the file whereas the file format // has to use a KEY=VALUE description. Comments starting // with a "#" are allowed // ---- char line[MAX_LINE_LENGTH]; while ((mHandle->readLine(line,MAX_LINE_LENGTH)) != 0) { QString string_line(line); string_line.truncate(string_line.length()-1); if ((string_line[0] == '#') || (string_line.isEmpty())) { if (mHandle->atEnd()) { break; } continue; } QString key; QString* val = new QString(); QStringList tokens = QStringList::split ( "=", string_line ); key = tokens.first(); *val = tokens.last(); *val = val->stripWhiteSpace(); key = key.stripWhiteSpace(); int bslash = val->find ('\\'); if (bslash >= 0) { *val = val->replace (bslash,2,"\n"); while ( 1 ) { bslash = val->find ('\\'); if (bslash >= 0) { *val = val->replace (bslash,2,"\n"); } else { break; } } } gtx.insert (key,val); if (mHandle->atEnd()) { break; } } mHandle->close(); return (gtx); }
//==================================== // readList... //------------------------------------ QList<QString> SCCFile::readList (void) { // .../ // read the contents of the file whereas the file format // can be a simple list. Comments starting with a "#" are // allowed // ---- char line[MAX_LINE_LENGTH]; while ((mHandle->readLine(line,MAX_LINE_LENGTH)) != 0) { QString string_line(line); string_line.truncate(string_line.length()-1); if ((string_line[0] == '#') || (string_line.isEmpty())) { if (mHandle->atEnd()) { break; } continue; } gtxlist.append ( string_line); if (mHandle->atEnd()) { break; } } mHandle->close(); return (gtxlist); }
bool PointCloudReader::ReadPoint(CloudPoint& point) { char* line = &_line[0]; std::vector<double> vOut; while (!_ifstream.eof()) { _ifstream.getline(line, 4095); std::string string_line(line); Tokenize(string_line, _separators, vOut); size_t numColumns = vOut.size(); if (_ptsread == 0) // first point! { if (numColumns == 3) { // Reading XYZ Point Cloud _pct = PCT_XYZ; } if (numColumns == 4) { // Reading XYZI Point Cloud _pct = PCT_XYZI; } else if (numColumns == 6) { // Reading XYZRGB Point Cloud! _pct = PCT_XYZRGB; } else if (numColumns == 7) { // Reading XYZIRGB Point Cloud! _pct = PCT_XYZIRGB; } else { // pc is not valid! _pct = PCT_INVALID; return false; } } if (vOut.size() >= 3 && vOut.size() == numColumns) { point.x = vOut[0]; point.y = vOut[1]; point.elevation = vOut[2]; if (_pct == PCT_XYZI) { point.intensity = (int)vOut[3]; } else if (_pct == PCT_XYZRGB) { point.r = (unsigned char)vOut[3]; point.g = (unsigned char)vOut[4]; point.b = (unsigned char)vOut[5]; } else if (_pct == PCT_XYZIRGB) { point.intensity = (int)vOut[3]; point.r = (unsigned char)vOut[4]; point.g = (unsigned char)vOut[5]; point.b = (unsigned char)vOut[6]; } _ptsread++; return true; } } return false; }
//==================================== // storeDataCDB... //------------------------------------ void SaXProcess::storeDataCDB (int fileID) { // .../ //! Store CDB based group records into the CDB //! dictionary. The given file ID must be able to //! become resolved into a valid CDB file // ---- QString file; switch (fileID) { case CDB_CARDS: file = CDBCARDS; break; case CDB_MONITORS: file = CDBMONITORS; break; case CDB_PENS: file = CDBPENS; break; case CDB_PADS: file = CDBPADS; break; case CDB_POINTERS: file = CDBPOINTERS; break; case CDB_TABLETS: file = CDBTABLETS; break; case CDB_TOUCHERS: file = CDBTOUCHERS; break; default: excCDBFileFailed (); qError (errorString(),EXC_CDBFILEFAILED); break; } //==================================== // search all entries for file //------------------------------------ DIR* CDBDir = 0; struct dirent* entry = 0; CDBDir = opendir (CDBDIR); QList<QString> fileList; if (! CDBDir) { excFileOpenFailed ( errno ); qError (errorString(),EXC_FILEOPENFAILED); return; } while (1) { entry = readdir (CDBDir); if (! entry) { break; } QString* updateFile = new QString(); QTextOStream (updateFile) << CDBDIR << entry->d_name; if (*updateFile == file) { continue; } if ((updateFile->contains(file)) && (entry->d_type != DT_DIR)) { fileList.append (*updateFile); } } closedir (CDBDir); fileList.append (file); QString it; //==================================== // read in file list //------------------------------------ foreach (it,fileList) { QFile* handle = new QFile (it.ascii()); if (! handle -> open(IO_ReadOnly)) { excFileOpenFailed ( errno ); qError (errorString(),EXC_FILEOPENFAILED); return; } char line[MAX_LINE_LENGTH]; QString group,key,val; while ((handle->readLine (line,MAX_LINE_LENGTH)) != 0) { QString string_line(line); string_line.truncate(string_line.length()-1); if ((string_line[0] == '#') || (string_line.isEmpty())) { if (handle->atEnd()) { break; } continue; } int bp = string_line.find('{'); if (bp >= 0) { QStringList tokens = QStringList::split ( ":", string_line ); QString vendor = tokens.first(); QString name = tokens.last(); name.truncate( name.find('{') ); name = name.stripWhiteSpace(); vendor = vendor.stripWhiteSpace(); group = vendor+":"+name; } else { bp = string_line.find('}'); if (bp >= 0) { continue; } QStringList tokens = QStringList::split ( "=", string_line ); key = tokens.first(); val = tokens.last(); val = val.stripWhiteSpace(); key = key.stripWhiteSpace(); // ... / // CDB keys and ISAX keys are not the same, // check this and adapt to ISAX keys // --- if (key == "Hsync") { key = "HorizSync"; } if (key == "Vsync") { key = "VertRefresh"; } if (key == "Modeline") { key = "SpecialModeline"; } addGroup (group,key,val); } if (handle->atEnd()) { break; } } handle -> close(); }