void QgsMapToolRotatePointSymbols::createPixmapItem( QgsFeature& f ) { if ( !mCanvas ) { return; } //get reference to current render context QgsMapRenderer* mapRenderer = mCanvas->mapRenderer(); if ( !mapRenderer ) { return; } QgsRenderContext* renderContext = mCanvas->mapRenderer()->rendererContext(); if ( !renderContext ) { return; } //get the image that is used for that symbol, but without point rotation QImage pointImage; QgsRenderer* r = 0; QgsFeatureRendererV2* rv2 = 0; if ( mActiveLayer && mActiveLayer->renderer() ) //old symbology { //copy renderer QgsRenderer* r = mActiveLayer->renderer()->clone(); //set all symbol fields of the cloned renderer to -1. Very ugly but necessary QList<QgsSymbol*> symbolList( r->symbols() ); QList<QgsSymbol*>::iterator it = symbolList.begin(); for ( ; it != symbolList.end(); ++it ) { ( *it )->setRotationClassificationField( -1 ); } r->renderFeature( *renderContext, f, &pointImage, false ); } else if ( mActiveLayer && mActiveLayer->rendererV2() ) //symbology-ng { rv2 = mActiveLayer->rendererV2()->clone(); rv2->setRotationField( "" ); rv2->startRender( *renderContext, mActiveLayer ); QgsSymbolV2* symbolV2 = rv2->symbolForFeature( f ); if ( symbolV2 ) { pointImage = symbolV2->bigSymbolPreviewImage(); } rv2->stopRender( *renderContext ); } mRotationItem = new QgsPointRotationItem( mCanvas ); mRotationItem->setSymbol( pointImage ); delete r; delete rv2; }
void RubySupportPart::parse(const QString &fileName) { QFile f(QFile::encodeName(fileName)); if (!f.open(IO_ReadOnly)) return; QTextStream stream(&f); QRegExp classre("^\\s*(class|module)\\s+([A-Z][A-Za-z0-9_]+::)*([A-Z][A-Za-z0-9_]+)\\s*(<\\s*([A-Z][A-Za-z0-9_:]+))?$"); QRegExp methodre("^(\\s*)def\\s+(([A-Z][A-Za-z0-9_:]+|self)\\.)?([A-Za-z0-9_]+[!?=]?|\\[\\]=?|\\*\\*||\\-|[!~+*/%&|><^]|>>|<<||<=>|<=|>=|==|===|!=|=~|!~).*$"); QRegExp accessre("^\\s*(private|protected|public)\\s*((:([A-Za-z0-9_]+[!?=]?|\\[\\]=?|\\*\\*||\\-|[!~+*/%&|><^]|>>|<<||<=>|<=|>=|==|===|!=|=~|!~),?\\s*)*)$"); QRegExp attr_accessorre("^\\s*(attr_accessor|attr_reader|attr_writer)\\s*((:([A-Za-z0-9_]+),?\\s*)*)$"); QRegExp symbolre(":([^,]+),?"); QRegExp line_contre(",\\s*$"); QRegExp slot_signalre("^\\s*(slots|signals|k_dcop|k_dcop_signals)\\s*(('[^)]+\\)',?\\s*)*)$"); QRegExp memberre("'([A-Za-z0-9_ &*]+\\s)?([A-Za-z0-9_]+)\\([^)]*\\)',?"); QRegExp begin_commentre("^*=begin"); QRegExp end_commentre("^*=end"); QRegExp variablere("(@@?[A-Za-z0-9_]+)\\s*=\\s*((?:([A-Za-z0-9_:.]+)\\.new)|[\\[\"'%:/\\?\\{]|%r|<<|true|false|^\\?|0[0-7]+|[-+]?0b[01]+|[-+]?0x[1-9a-fA-F]+|[-+]?[0-9_\\.e]+|nil)?"); QRegExp endre("^(\\s*)end\\s*$"); FileDom m_file = codeModel()->create<FileModel>(); m_file->setName(fileName); ClassDom lastClass; FunctionDom lastMethod; QString lastMethodIndentation; int lastAccess = CodeModelItem::Public; QString rawline; QCString line; int lineNo = 0; while (!stream.atEnd()) { rawline = stream.readLine(); line = rawline.stripWhiteSpace().local8Bit(); if (classre.search(line) != -1) { if (m_file->hasClass(classre.cap(3))) { lastClass = m_file->classByName( classre.cap(3) )[ 0 ]; } else { lastClass = codeModel()->create<ClassModel>(); lastClass->setName(classre.cap(3)); lastClass->setFileName( fileName ); lastClass->setStartPosition( lineNo, 0 ); m_file->addClass( lastClass ); } QString parent = classre.cap(5); if (!parent.isEmpty()) { kdDebug() << "Add parent " << parent << endl; lastClass->addBaseClass( parent ); } lastAccess = CodeModelItem::Public; } else if (methodre.search(line) != -1) { FunctionDom methodDecl; if ( lastClass != 0 && lastClass->hasFunction( methodre.cap(4) ) ) { FunctionList methods = lastClass->functionByName( methodre.cap(4) ); methodDecl = methods[0]; } else { methodDecl = codeModel()->create<FunctionModel>(); methodDecl->setFileName( fileName ); methodDecl->setStartPosition( lineNo, 0 ); methodDecl->setName(methodre.cap(4)); } FunctionDefinitionDom method = codeModel()->create<FunctionDefinitionModel>(); method->setName(methodre.cap(4)); kdDebug() << "Add method: " << method->name() << endl; method->setFileName( fileName ); method->setStartPosition( lineNo, 0 ); if (methodDecl->name() == "initialize") { // Ruby constructors are alway private methodDecl->setAccess( CodeModelItem::Private ); } else { methodDecl->setAccess( lastAccess ); } if (methodre.cap(2) != "") { // A ruby class/singleton method of the form <classname>.<methodname> methodDecl->setStatic( true ); } lastMethodIndentation = methodre.cap(1); lastMethod = method; if (lastClass != 0) { QStringList scope( lastClass->name() ); method->setScope( scope ); methodDecl->setScope( scope ); if( !lastClass->hasFunction(methodDecl->name()) ) { lastClass->addFunction( methodDecl ); } if( !lastClass->hasFunctionDefinition(method->name()) ) { lastClass->addFunctionDefinition( method ); } } else if( !m_file->hasFunctionDefinition(method->name()) ){ m_file->addFunction( methodDecl ); m_file->addFunctionDefinition( method ); lastClass = 0; } } else if (endre.search(line) != -1 && lastMethod != 0 && endre.cap(1) == lastMethodIndentation ) { int endCol, endLine; lastMethod->getEndPosition(&endCol, &endLine); if (endLine == 0) { //hack to set end position of the previous method to the line //where its corresponding "end" is found //there's an assumption that method's "def" statement will have the same //indentation level as method's "end" lastMethod->setEndPosition(lineNo, 0); } } else if (accessre.search(line) != -1 && lastClass != 0) { int currentAccess = lastAccess; if (accessre.cap(1) == "public") { currentAccess = CodeModelItem::Public; } else if (accessre.cap(1) == "protected") { currentAccess = CodeModelItem::Protected; } else if (accessre.cap(1) == "private") { currentAccess = CodeModelItem::Private; } if (accessre.cap(2) == "") { lastAccess = currentAccess; } else { QString symbolList( accessre.cap(2) ); int pos = 0; while ( pos >= 0 ) { pos = symbolre.search( symbolList, pos ); if (pos == -1) { if (line_contre.search(line) != -1) { rawline = stream.readLine(); if (!stream.atEnd()) { line = rawline.stripWhiteSpace().local8Bit(); ++lineNo; symbolList = line; pos = 0; } } } else { if ( lastClass->hasFunction( symbolre.cap(1) ) ) { FunctionList methods = lastClass->functionByName( symbolre.cap(1) ); methods[0]->setAccess( currentAccess ); } pos += symbolre.matchedLength(); } } } } else if (slot_signalre.search(line) != -1 && lastClass != 0) { QString memberList( slot_signalre.cap(2) ); int pos = 0; while ( pos >= 0 ) { pos = memberre.search( memberList, pos ); if (pos == -1) { if (line_contre.search(line) != -1) { rawline = stream.readLine(); if (!stream.atEnd()) { line = rawline.stripWhiteSpace().local8Bit(); ++lineNo; memberList = line; pos = 0; } } } else { FunctionDom method; if ( lastClass->hasFunction( memberre.cap(2) ) ) { FunctionList methods = lastClass->functionByName( memberre.cap(2) ); method = methods[0]; } else { method = codeModel()->create<FunctionModel>(); } QStringList scope( lastClass->name() ); method->setScope( scope ); method->setName(memberre.cap(2)); method->setFileName( fileName ); method->setStartPosition( lineNo, 0 ); if (slot_signalre.cap(1) == "slots" || slot_signalre.cap(1) == "k_dcop") { method->setSlot( true ); } else { method->setSignal( true ); } if ( !lastClass->hasFunction(method->name()) ) { lastClass->addFunction( method ); } pos += memberre.matchedLength(); } } } else if (attr_accessorre.search(line) != -1 && lastClass != 0) { QString attr( attr_accessorre.cap(1) ); QString symbolList( attr_accessorre.cap(2) ); int pos = 0; while ( pos >= 0 ) { pos = symbolre.search( symbolList, pos ); if (pos == -1) { if (line_contre.search(line) != -1) { rawline = stream.readLine(); if (!stream.atEnd()) { line = rawline.stripWhiteSpace().local8Bit(); ++lineNo; symbolList = line; pos = 0; } } } else { QStringList scope( lastClass->name() ); if ( !lastClass->hasFunction(symbolre.cap(1)) && (attr == "attr_accessor" || attr == "attr_reader") ) { FunctionDefinitionDom method = codeModel()->create<FunctionDefinitionModel>(); method->setName(symbolre.cap(1)); kdDebug() << "Add method: " << method->name() << endl; method->setFileName( fileName ); method->setStartPosition( lineNo, 0 ); method->setScope(scope); lastClass->addFunction( model_cast<FunctionDom>(method) ); lastClass->addFunctionDefinition( method ); } if ( !lastClass->hasFunction(symbolre.cap(1) + "=") && (attr == "attr_accessor" || attr == "attr_writer") ) { FunctionDefinitionDom method = codeModel()->create<FunctionDefinitionModel>(); method->setName(symbolre.cap(1) + "="); kdDebug() << "Add method: " << method->name() << endl; method->setFileName( fileName ); method->setStartPosition( lineNo, 0 ); method->setScope(scope); lastClass->addFunction( model_cast<FunctionDom>(method) ); lastClass->addFunctionDefinition( method ); } pos += symbolre.matchedLength(); } } } else if (variablere.search(line) != -1 && lastClass != 0) { VariableDom attr; if ( lastClass->hasVariable( variablere.cap(1) ) ) { attr = lastClass->variableByName( variablere.cap(1) ); } else { attr = codeModel()->create<VariableModel>(); attr->setName( variablere.cap(1) ); attr->setFileName( fileName ); attr->setStartPosition( lineNo, 0 ); attr->setAccess( CodeModelItem::Private ); if (QRegExp("^@@").search(attr->name()) != -1) { attr->setStatic( true ); } lastClass->addVariable( attr ); } // Give priority to any variable initialized in the constructor // Otherwise, take the first one found in the source file if (lastMethod != 0 && lastMethod->name() == "initialize") { attr->setFileName( fileName ); attr->setStartPosition( lineNo, 0 ); } if (QRegExp("^(/|%r)").search(variablere.cap(2)) != -1) { attr->setType( "Regexp" ); } else if (QRegExp("^[\"'%<]").search(variablere.cap(2)) != -1) { attr->setType( "String" ); } else if (QRegExp("^\\[").search(variablere.cap(2)) != -1) { attr->setType( "Array" ); } else if (QRegExp("^\\{").search(variablere.cap(2)) != -1) { attr->setType( "Hash" ); } else if (QRegExp("^:").search(variablere.cap(2)) != -1) { attr->setType( "Symbol" ); } else if (QRegExp("\\.\\.").search(variablere.cap(2)) != -1) { attr->setType( "Range" ); } else if (variablere.cap(2) == "true" || variablere.cap(2) == "false") { attr->setType( "Boolean" ); } else if ( QRegExp("^[-+]?[0-9_]+").exactMatch(variablere.cap(2)) || QRegExp("^[-+]?(0x|0|0b|\\?)").search(variablere.cap(2)) != -1 ) { attr->setType( "Integer" ); } else if (QRegExp("[0-9._]+(e[-+0-9]+)?").exactMatch(variablere.cap(2))) { attr->setType( "Float" ); } else if (variablere.cap(2) != "nil" && variablere.cap(3) != "") { attr->setType( variablere.cap(3) ); } } else if (begin_commentre.search(line) != -1) { while (!stream.atEnd() && end_commentre.search(line) == -1) { rawline = stream.readLine(); line = rawline.stripWhiteSpace().local8Bit(); ++lineNo; } } ++lineNo; } f.close(); codeModel()->addFile( m_file ); }
int main(int argc, char* argv[]) { #ifdef CHECK_MEMLEAK _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #endif //Initialize the ICU calendar UErrorCode status = U_ZERO_ERROR; dateGC = new GregorianCalendar(status); //get all the command line options GetOptionFlags(argc, argv, o); s.username = o.username; s.password = o.password; s.serverName = o.serverName; //set up the log file std::string dateString = GetDateString(dateGC->getNow(), dateGC); std::string fileName = dateString + o.gSymbol; fileName = GetSymbolTableName(fileName, o); fileName += ".log"; gLogFile = fopen(fileName.c_str(), "w+"); if (gLogFile == NULL) { printf("Could not open file %s, exiting. Sucks that I can't log this output\n", fileName.c_str()); exit(-1); } //Initialize IQ Feed InitDataFeed(); //set the SQL pointers based on the data being downloaded SetSQLPointers(o); ///////////////////////////// // Get the symbols ///////////////////////////// if (o.gSymbol.compare("dow30") == 0) o.gSymbol = dow30; boost::char_separator<char> sep(","); boost::tokenizer< boost::char_separator<char> > tokens(o.gSymbol, sep); // Create a list from the tokens std::vector<std::string> symbolList(tokens.begin(), tokens.end()); std::vector<std::string> contractList; std::map<std::string, std::string> contractMap; //get all the symbols if (o.isOption == true || o.isFutures == true) { contractList = convertSymbolsToContracts(symbolList, contractMap); symbolList = contractList; } int numSymbols = symbolList.size(); WriteLog("There are %d symbols\n", numSymbols); //determine if we should use the hashTable, currently only //for ticks and non-contract-related data if (o.useTicks == true)// && (o.isOption == false && o.isFutures == false)) o.useHashTable = true; DBHandles s; s.username = o.username; s.serverName = o.serverName; s.password = o.password; ConnectDB(&s); for (int i = 0; i < numSymbols; i++) { std::string currentSymbol = symbolList[i]; // Get the data from the data feed and stuff into link list link *head = NULL; try { head = GetData(currentSymbol); } catch (const DataException &d) { std::string errorString; ODBCError(&s, errorString); WriteLog("GetData error: %s\n", errorString.c_str()); WriteLog("problem on file %s, line %d\n", d._function.c_str(), d._lineNum); exit(-1); } //if there's no data then move to the next symbol if (head == NULL) continue; //get the symbolTableName and create table if necessary std::string symbolTableName; if (o.useHardcodedTable == true) symbolTableName = o.hardcodedTable; else if (o.isOption == true || o.isFutures == true) symbolTableName = GetSymbolTableName(contractMap[currentSymbol], o); else symbolTableName = GetSymbolTableName(currentSymbol, o); if (CheckTableExists(&s, checkTableExists, symbolTableName.c_str()) == false) { CreateTable(&s, o.gSqlCommand, o.gIndexSQL, (char *) symbolTableName.c_str()); } //get the last chunk for its timestamp //lame could do this better but it's not too expensive for now link *lastChunk = head; while (lastChunk->next != NULL) lastChunk = lastChunk->next; //write the data try { boost::unordered_set<dataPoint> *hash = NULL; if (o.useHashTable == true) hash = GetDBHash(&s, symbolTableName, head->beginTimestamp, lastChunk->endTimestamp, currentSymbol); WriteData(&s, head, currentSymbol, symbolTableName, hash); delete hash; } catch (const DataException &d) { std::string errorString; ODBCError(&s, errorString); WriteLog("WriteData error: %s\n", errorString.c_str()); WriteLog("problem on file %s, line %d\n", d._function.c_str(), d._lineNum); exit(-1); } } DisconnectDB(&s); RemoveClientApp(NULL); }