void NASM::parseLstFile(QFile &lst, QVector<Assembler::LineNum> &lines, quint64 offset) { bool inTextSection = false; QRegExp sectionTextRegExp("SECTION\\s+\\.?(text|code)"); sectionTextRegExp.setCaseSensitivity(Qt::CaseInsensitive); QRegExp sectionRegExp("SECTION"); sectionRegExp.setCaseSensitivity(Qt::CaseInsensitive); QList<QPair<quint64, QString> > instrList; QTextStream lstStream(&lst); lstStream.seek(0); while (!lstStream.atEnd()) { QString line = lstStream.readLine(); if (line.indexOf(QRegExp("^ +[0-9]+ +<[0-9]+>")) != -1) { //macro continue; } if (line.indexOf(sectionTextRegExp) != -1) { inTextSection = true; } else if (line.indexOf(sectionRegExp) != -1) { inTextSection = false; } //! omit strings with data only //! if in list : line number, address, data and it is all (without instruction) - //! omit this string and subtract 1 from offset if (line.indexOf(QRegExp("^(\\s+[^\\s]+){4}")) == -1) { continue; } if (inTextSection) { QRegExp lineRegExp("^\\s+[0-9]+\\s+([0-9a-fA-F]+)\\s+\\S+\\s+(.*)"); lineRegExp.setMinimal(false); if (lineRegExp.indexIn(line) == 0) { quint64 address = lineRegExp.cap(1).toULongLong(0, 16); QString instruction = lineRegExp.cap(2).trimmed(); instrList.append(QPair<quint64, QString>(address + offset, instruction)); } } } QFile programFile(Common::pathInTemp("program.asm")); programFile.open(QFile::ReadOnly); QTextStream programStream(&programFile); //! Offset in list int i = 0; int numInCode = 0; while (!programStream.atEnd()) { if (i >= instrList.size()) { break; } QString line = programStream.readLine(); numInCode++; line = line.trimmed(); if (line == instrList[i].second) { LineNum l; l.numInCode = numInCode; l.numInMem = instrList[i].first; lines.append(l); i++; } } programFile.close(); }
void QSGTextMaskMaterial::populate(const QPointF &p, const QVector<quint32> &glyphIndexes, const QVector<QPointF> &glyphPositions, QSGGeometry *geometry, QRectF *boundingRect, QPointF *baseLine, const QMargins &margins) { Q_ASSERT(m_font.isValid()); QVector<QFixedPoint> fixedPointPositions; for (int i=0; i<glyphPositions.size(); ++i) fixedPointPositions.append(QFixedPoint::fromPointF(glyphPositions.at(i))); QTextureGlyphCache *cache = glyphCache(); QRawFontPrivate *fontD = QRawFontPrivate::get(m_font); cache->populate(fontD->fontEngine, glyphIndexes.size(), glyphIndexes.constData(), fixedPointPositions.data()); cache->fillInPendingGlyphs(); int margin = fontD->fontEngine->glyphMargin(cache->glyphFormat()); qreal glyphCacheScaleX = cache->transform().m11(); qreal glyphCacheScaleY = cache->transform().m22(); qreal glyphCacheInverseScaleX = 1.0 / glyphCacheScaleX; qreal glyphCacheInverseScaleY = 1.0 / glyphCacheScaleY; Q_ASSERT(geometry->indexType() == GL_UNSIGNED_SHORT); geometry->allocate(glyphIndexes.size() * 4, glyphIndexes.size() * 6); QVector4D *vp = (QVector4D *)geometry->vertexDataAsTexturedPoint2D(); Q_ASSERT(geometry->sizeOfVertex() == sizeof(QVector4D)); ushort *ip = geometry->indexDataAsUShort(); QPointF position(p.x(), p.y() - m_font.ascent()); bool supportsSubPixelPositions = fontD->fontEngine->supportsSubPixelPositions(); for (int i=0; i<glyphIndexes.size(); ++i) { QFixed subPixelPosition; if (supportsSubPixelPositions) subPixelPosition = fontD->fontEngine->subPixelPositionForX(QFixed::fromReal(glyphPositions.at(i).x())); QTextureGlyphCache::GlyphAndSubPixelPosition glyph(glyphIndexes.at(i), subPixelPosition); const QTextureGlyphCache::Coord &c = cache->coords.value(glyph); QPointF glyphPosition = glyphPositions.at(i) + position; // On a retina screen the glyph positions are not pre-scaled (as opposed to // eg. the raster paint engine). To ensure that we get the same behavior as // the raster engine (and CoreText itself) when it comes to rounding of the // coordinates, we need to apply the scale factor before rounding, and then // apply the inverse scale to get back to the coordinate system of the node. qreal x = (qFloor(glyphPosition.x() * glyphCacheScaleX) * glyphCacheInverseScaleX) + (c.baseLineX * glyphCacheInverseScaleX) - margin; qreal y = (qRound(glyphPosition.y() * glyphCacheScaleY) * glyphCacheInverseScaleY) - (c.baseLineY * glyphCacheInverseScaleY) - margin; qreal w = c.w * glyphCacheInverseScaleX; qreal h = c.h * glyphCacheInverseScaleY; *boundingRect |= QRectF(x + margin, y + margin, w, h); float cx1 = x - margins.left(); float cx2 = x + w + margins.right(); float cy1 = y - margins.top(); float cy2 = y + h + margins.bottom(); float tx1 = c.x - margins.left(); float tx2 = c.x + c.w + margins.right(); float ty1 = c.y - margins.top(); float ty2 = c.y + c.h + margins.bottom(); if (baseLine->isNull()) *baseLine = glyphPosition; vp[4 * i + 0] = QVector4D(cx1, cy1, tx1, ty1); vp[4 * i + 1] = QVector4D(cx2, cy1, tx2, ty1); vp[4 * i + 2] = QVector4D(cx1, cy2, tx1, ty2); vp[4 * i + 3] = QVector4D(cx2, cy2, tx2, ty2); int o = i * 4; ip[6 * i + 0] = o + 0; ip[6 * i + 1] = o + 2; ip[6 * i + 2] = o + 3; ip[6 * i + 3] = o + 3; ip[6 * i + 4] = o + 1; ip[6 * i + 5] = o + 0; } }
QVector<QgsDataItem *> QgsWMSConnectionItem::createChildren() { QVector<QgsDataItem *> children; QgsDataSourceUri uri; uri.setEncodedUri( mUri ); QgsDebugMsg( "mUri = " + mUri ); QgsWmsSettings wmsSettings; if ( !wmsSettings.parseUri( mUri ) ) { children.append( new QgsErrorItem( this, tr( "Failed to parse WMS URI" ), mPath + "/error" ) ); return children; } bool res = mCapabilitiesDownload->downloadCapabilities( wmsSettings.baseUrl(), wmsSettings.authorization() ); if ( !res ) { children.append( new QgsErrorItem( this, tr( "Failed to download capabilities" ), mPath + "/error" ) ); return children; } QgsWmsCapabilities caps; if ( !caps.parseResponse( mCapabilitiesDownload->response(), wmsSettings.parserSettings() ) ) { children.append( new QgsErrorItem( this, tr( "Failed to parse capabilities" ), mPath + "/error" ) ); return children; } // Attention: supportedLayers() gives tree leafs, not top level QVector<QgsWmsLayerProperty> layerProperties = caps.supportedLayers(); if ( !layerProperties.isEmpty() ) { QgsWmsCapabilitiesProperty capabilitiesProperty = caps.capabilitiesProperty(); const QgsWmsCapabilityProperty &capabilityProperty = capabilitiesProperty.capability; for ( const QgsWmsLayerProperty &layerProperty : qgis::as_const( capabilityProperty.layers ) ) { // Attention, the name may be empty QgsDebugMsg( QString::number( layerProperty.orderId ) + ' ' + layerProperty.name + ' ' + layerProperty.title ); QString pathName = layerProperty.name.isEmpty() ? QString::number( layerProperty.orderId ) : layerProperty.name; QgsWMSLayerItem *layer = new QgsWMSLayerItem( this, layerProperty.title, mPath + '/' + pathName, capabilitiesProperty, uri, layerProperty ); children << layer; } } QList<QgsWmtsTileLayer> tileLayers = caps.supportedTileLayers(); if ( !tileLayers.isEmpty() ) { QHash<QString, QgsWmtsTileMatrixSet> tileMatrixSets = caps.supportedTileMatrixSets(); const auto constTileLayers = tileLayers; for ( const QgsWmtsTileLayer &l : constTileLayers ) { QString title = l.title.isEmpty() ? l.identifier : l.title; QgsDataItem *layerItem = l.styles.size() == 1 ? this : new QgsDataCollectionItem( this, title, mPath + '/' + l.identifier ); if ( layerItem != this ) { layerItem->setCapabilities( layerItem->capabilities2() & ~QgsDataItem::Fertile ); layerItem->setState( QgsDataItem::Populated ); layerItem->setToolTip( title ); children << layerItem; } for ( const QgsWmtsStyle &style : qgis::as_const( l.styles ) ) { QString styleName = style.title.isEmpty() ? style.identifier : style.title; if ( layerItem == this ) styleName = title; // just one style so no need to display it QgsDataItem *styleItem = l.setLinks.size() == 1 ? layerItem : new QgsDataCollectionItem( layerItem, styleName, layerItem->path() + '/' + style.identifier ); if ( styleItem != layerItem ) { styleItem->setCapabilities( styleItem->capabilities2() & ~QgsDataItem::Fertile ); styleItem->setState( QgsDataItem::Populated ); styleItem->setToolTip( styleName ); if ( layerItem == this ) children << styleItem; else layerItem->addChildItem( styleItem ); } for ( const QgsWmtsTileMatrixSetLink &setLink : qgis::as_const( l.setLinks ) ) { QString linkName = setLink.tileMatrixSet; if ( styleItem == layerItem ) linkName = styleName; // just one link so no need to display it QgsDataItem *linkItem = l.formats.size() == 1 ? styleItem : new QgsDataCollectionItem( styleItem, linkName, styleItem->path() + '/' + setLink.tileMatrixSet ); if ( linkItem != styleItem ) { linkItem->setCapabilities( linkItem->capabilities2() & ~QgsDataItem::Fertile ); linkItem->setState( QgsDataItem::Populated ); linkItem->setToolTip( linkName ); if ( styleItem == this ) children << linkItem; else styleItem->addChildItem( linkItem ); } for ( const QString &format : qgis::as_const( l.formats ) ) { QString name = format; if ( linkItem == styleItem ) name = linkName; // just one format so no need to display it QgsDataItem *tileLayerItem = new QgsWMTSLayerItem( linkItem, name, linkItem->path() + '/' + name, uri, l.identifier, format, style.identifier, setLink.tileMatrixSet, tileMatrixSets[ setLink.tileMatrixSet ].crs, title ); tileLayerItem->setToolTip( name ); if ( linkItem == this ) children << tileLayerItem; else linkItem->addChildItem( tileLayerItem ); } } } } } return children; }
void warn(QString msg) { qWarning()<<"W:" <<msg; m_errors.append("WARNING: "+msg); }
void QRecipeTableItem::compile(QSqlDatabase &db, int nSceneId,int &count,int index) { count++; QVisableItem::compile(db, nSceneId, count,index); int nItemID = count; if(sPro.enableTouch && !sPro.byGroups_T) { //触控受位控制 增一个地址表 count++; } if(sPro.bNotice) { //触控解锁通知到地址 增加一个地址表 count++; } if(sPro.enableVisable && !sPro.byGroups_V) { //显现受位控制 增加一个地址表 count++; } QRectF rect = this->sceneBoundingRect(); QSqlQuery sqlquery(db); bool bReasult = false; bReasult = sqlquery.prepare("INSERT INTO recipeDisplay(nItemId,nSceneId,nStartPosX,nStartPosY,nWidth," "nHeight,nRecipeGroupId,bShowRecipeID,bShowDescrip,eTextAlignType," "nLanguaId,nRowShowNum,nColumShowNum,nHHeadTextColor,nHHeadBackColor," "nHHeadFontSize,sHHeadFontFamily,nVHeadTextColor,nVHeadBackColor," "nVHeadFontSize,sVHeadFontFamily,nDataTextColor,nDataBackColor," "nDataFontSize,nLineColor,nTransparent,nZvalue,nCollidindId,nShowPropId)" "VALUES (:nItemId,:nSceneId,:nStartPosX,:nStartPosY,:nWidth," ":nHeight,:nRecipeGroupId,:bShowRecipeID,:bShowDescrip,:eTextAlignType," ":nLanguaId,:nRowShowNum,:nColumShowNum,:nHHeadTextColor,:nHHeadBackColor," ":nHHeadFontSize,:sHHeadFontFamily,:nVHeadTextColor,:nVHeadBackColor," ":nVHeadFontSize,:sVHeadFontFamily,:nDataTextColor,:nDataBackColor," ":nDataFontSize,:nLineColor,:nTransparent,:nZvalue,:nCollidindId,:nShowPropId)"); sqlquery.bindValue(":nItemId",QVariant(nItemID)); sqlquery.bindValue(":nSceneId",QVariant(nSceneId)); sqlquery.bindValue(":nStartPosX",QVariant(rect.x())); sqlquery.bindValue(":nStartPosY",QVariant(rect.y())); sqlquery.bindValue(":nWidth",QVariant(rect.width())); sqlquery.bindValue(":nHeight",QVariant(rect.height())); sqlquery.bindValue(":nRecipeGroupId",QVariant(m_SaveInfo.nRecipeGroupId)); sqlquery.bindValue(":bShowRecipeID",QVariant(m_SaveInfo.bShowRecipeID)); sqlquery.bindValue(":bShowDescrip",QVariant(m_SaveInfo.bShowDescrip)); int nAlign = 0; if(0 == m_SaveInfo.eTextAlignType)//center { nAlign = 2; } else if(1 == m_SaveInfo.eTextAlignType)//left { nAlign = 1; } else { nAlign = 3; } sqlquery.bindValue(":eTextAlignType",QVariant(nAlign)); sqlquery.bindValue(":nLanguaId",QVariant(m_SaveInfo.nLanguaId)); sqlquery.bindValue(":nRowShowNum",QVariant(m_SaveInfo.nRowShowNum)); sqlquery.bindValue(":nColumShowNum",QVariant(m_SaveInfo.nColumShowNum)); sqlquery.bindValue(":nHHeadTextColor",QVariant(ColorToInt(m_SaveInfo.nHHeadTextColor))); sqlquery.bindValue(":nHHeadBackColor",QVariant(ColorToInt(m_SaveInfo.nHHeadBackColor))); sqlquery.bindValue(":nHHeadFontSize",QVariant(m_SaveInfo.nHHeadFontSize + 5)); sqlquery.bindValue(":sHHeadFontFamily",QVariant(m_SaveInfo.sHHeadFontFamily)); sqlquery.bindValue(":nVHeadTextColor",QVariant(ColorToInt(m_SaveInfo.nVHeadTextColor))); sqlquery.bindValue(":nVHeadBackColor",QVariant(ColorToInt(m_SaveInfo.nVHeadBackColor))); sqlquery.bindValue(":nVHeadFontSize",QVariant(m_SaveInfo.nVHeadFontSize + 5)); sqlquery.bindValue(":sVHeadFontFamily",QVariant(m_SaveInfo.sVHeadFontFamily)); sqlquery.bindValue(":nDataTextColor",QVariant(ColorToInt(m_SaveInfo.nDataTextColor))); sqlquery.bindValue(":nDataBackColor",QVariant(ColorToInt(m_SaveInfo.nDataBackColor))); sqlquery.bindValue(":nDataFontSize",QVariant(m_SaveInfo.nDataFontSize + 5)); sqlquery.bindValue(":nLineColor",QVariant(ColorToInt(m_SaveInfo.nLineColor))); sqlquery.bindValue(":nTransparent",QVariant(ColorToInt(m_SaveInfo.nTransparent))); sqlquery.bindValue(":nZvalue",QVariant(zValue())); sqlquery.bindValue(":nCollidindId",QVariant(index)); sqlquery.bindValue(":nShowPropId",QVariant(-1)); bReasult = sqlquery.exec(); qDebug()<<"INSERT INTO recipeDisplay"<<bReasult; QList<QGraphicsItem *> list = childItems(); QString sName = ""; QVector<qreal> vVLine; //用来存垂直线的数据 QVector<qreal> vHLine; //用来存水平线的数据 vVLine.clear(); vHLine.clear(); vVLine.append(rect.x()); vHLine.append(rect.y()); //vTileTex.clear(); foreach(QGraphicsItem *pItem,list) { QPointF pos = pItem->boundingRect().topLeft()+pItem->scenePos(); sName = pItem->data(GROUP_NAME_KEY).toString(); if(sName.contains("VLine")) //垂直线 { vVLine.append(pos.x()); } if(sName.contains("HLine")) //水平线 { vHLine.append(pos.y()); } }
/* * Load the file with chosen filename and emit the signal sendFileData() when the file is read. */ void ConvertEcgToIbi::run() { QFile myFile(fname); if (myFile.open(QIODevice::ReadOnly | QIODevice::Text)) { time.start(); QTextStream ecgInfo(&myFile); QVector<int > ecgVals; QVector<double> timeData; int iterations; if (!ecgInfo.atEnd()) { QString strVals = ecgInfo.readLine(); ecgInfo.readLine(); ecgInfo.readLine(); double tmp; int i=0; while (!ecgInfo.atEnd()) { strVals = ecgInfo.readLine(); QStringList strPieces = strVals.split(QRegularExpression("\\s+")); if (strPieces.length()==4) { tmp=strPieces[2].toDouble(); ecgVals.append((tmp*500)); ///< @todo normalize input to work with more files } else if (strPieces.length()==3) { tmp=strPieces[2].toDouble(); ecgVals.append((tmp*500)); } else if (strPieces.length()==5){ tmp=strPieces[2].toDouble(); ecgVals.append((tmp*500)); } else { std::cerr << "Wrong File" << std::endl; return; } i++; } QVector<double> qrsPeaks; extractRtoR(&ecgVals, &qrsPeaks); qrsPeaks.takeFirst();// Remove the influense of the QRS-detectors learning period qrsPeaks.takeFirst();// Remove the influense of the QRS-detectors learning period qrsPeaks.takeFirst();// Remove the influense of the QRS-detectors learning period tmp=0; for (int i; i<qrsPeaks.length(); i++){ tmp=tmp+(qrsPeaks.at(i)); timeData.append(tmp); } if (qrsPeaks.length()>10){ ///@todo FIX this check neater emit sendFileData(qrsPeaks,timeData); saveAsIbiFile(&qrsPeaks); } else std::cerr << "Not enough R peaks detected" << std::endl; qDebug("Time elapsed: %d ms", time.elapsed()); } ecgInfo.flush(); myFile.close(); } }
void AddMember(QVector<PublicIdentity> &group, const Id &id = Id()) { group.append(CreateMember(id)); }
void ChartPlot::propertiesChart() { if (! plotPropGui) { plotPropGui = new PlotPropertiesGUI(this); plotPropGui->consistGUI(( QList<InternalCurve *> *) &internalCurves); } // Creates chart objects back-up QPalette plotterPalette = palette(); int plotterMargin = margin(); int plotterLWidth = lineWidth(); QPalette canvasPalette = canvas()->palette(); QFont titleFont = title().font(), axesFont = axisTitle(QwtPlot::xBottom).font(); QFont scalesFont = axisFont(QwtPlot::xBottom), legendFont = legend()->font(); QVector<CurveBkp> curvesBkp; for (int i = 0; i < internalCurves.size(); i++) { CurveBkp bkp; bkp.pen = internalCurves.at(i)->plotCurve->pen(); bkp.style = internalCurves.at(i)->plotCurve->style(); bkp.symbol = internalCurves.at(i)->plotCurve->symbol(); curvesBkp.append(bkp); } if (! plotPropGui->exec()) { // Roll-backs plotter objects setPalette(plotterPalette); setMargin(plotterMargin); setLineWidth(plotterLWidth); // Title QwtText text = title(); text.setFont(titleFont); setTitle(text); // Axes text = axisTitle(QwtPlot::xBottom); text.setFont(axesFont); setAxisTitle(QwtPlot::xBottom, text); text = axisTitle(QwtPlot::yLeft); text.setFont(axesFont); setAxisTitle(QwtPlot::yLeft, text); // Scale setAxisFont(QwtPlot::xBottom, scalesFont); setAxisFont(QwtPlot::yLeft, scalesFont); legend()->setFont(legendFont); canvas()->setPalette(canvasPalette); for (int i = 0; i < curvesBkp.size(); i++) { CurveBkp bkp = curvesBkp.at(i); internalCurves.at(i)->plotCurve->setPen(bkp.pen); internalCurves.at(i)->plotCurve->setStyle(bkp.style); internalCurves.at(i)->plotCurve->setSymbol(bkp.symbol); } } }
void ShaderNode::bindOutputBuffers( QVector<GLenum> &Buffers, QList< QSharedPointer<InterfacePin> > &OutPinLst, int &W, int &H, int &D ) { for( QList< QSharedPointer<InterfacePin> >::iterator it = OutPinLst.begin() ; it != OutPinLst.end() ; it++ ) { QSharedPointer<InterfacePin> OutPin = *it; if( !OutPin->isConnected() ) { continue; } QSharedPointer<InterfacePin> DstPin = OutPin->connectedPin(); if( DstPin == 0 ) { continue; } QSharedPointer<InterfacePinControl> DstControl = DstPin->control(); if( DstControl == 0 ) { continue; } InterfaceTexture *DstTexture = qobject_cast<InterfaceTexture *>( DstControl->object() ); if( DstTexture == 0 ) { continue; } if( DstTexture->textureId() == 0 ) { DstTexture->update( 0, 0 ); if( DstTexture->textureId() == 0 ) { continue; } } if( Buffers.empty() ) { W = DstTexture->size().at( 0 ); H = DstTexture->size().at( 1 ); D = DstTexture->size().at( 2 ); } //glBindTexture( DstTexture->target(), 0 ); if( mFrameBufferId == 0 ) { glGenFramebuffers( 1, &mFrameBufferId ); if( mFrameBufferId == 0 ) { continue; } } glBindFramebuffer( GL_FRAMEBUFFER, mFrameBufferId ); switch( DstTexture->target() ) { case GL_TEXTURE_1D: glFramebufferTexture1D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + Buffers.size(), DstTexture->target(), DstTexture->textureId(), 0 ); break; case GL_TEXTURE_2D: case GL_TEXTURE_RECTANGLE: glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + Buffers.size(), DstTexture->target(), DstTexture->textureId(), 0 ); break; case GL_TEXTURE_3D: glFramebufferTexture3D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + Buffers.size(), DstTexture->target(), DstTexture->textureId(), 0, 0 ); break; } OPENGL_PLUGIN_DEBUG; Buffers.append( GL_COLOR_ATTACHMENT0 + Buffers.size() ); } }
QT_BEGIN_NAMESPACE QVector<EGLint> q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format) { int redSize = format.redBufferSize(); int greenSize = format.greenBufferSize(); int blueSize = format.blueBufferSize(); int alphaSize = format.alphaBufferSize(); int depthSize = format.depthBufferSize(); int stencilSize = format.stencilBufferSize(); int sampleCount = format.samples(); // QPlatformWindowFormat uses a magic value of -1 to indicate "don't care", even when a buffer of that // type has been requested. So we must check QPlatformWindowFormat's booleans too if size is -1: if (format.alpha() && alphaSize <= 0) alphaSize = 1; if (format.depth() && depthSize <= 0) depthSize = 1; if (format.stencil() && stencilSize <= 0) stencilSize = 1; if (format.sampleBuffers() && sampleCount <= 0) sampleCount = 1; // We want to make sure 16-bit configs are chosen over 32-bit configs as they will provide // the best performance. The EGL config selection algorithm is a bit stange in this regard: // The selection criteria for EGL_BUFFER_SIZE is "AtLeast", so we can't use it to discard // 32-bit configs completely from the selection. So it then comes to the sorting algorithm. // The red/green/blue sizes have a sort priority of 3, so they are sorted by first. The sort // order is special and described as "by larger _total_ number of color bits.". So EGL will // put 32-bit configs in the list before the 16-bit configs. However, the spec also goes on // to say "If the requested number of bits in attrib_list for a particular component is 0, // then the number of bits for that component is not considered". This part of the spec also // seems to imply that setting the red/green/blue bits to zero means none of the components // are considered and EGL disregards the entire sorting rule. It then looks to the next // highest priority rule, which is EGL_BUFFER_SIZE. Despite the selection criteria being // "AtLeast" for EGL_BUFFER_SIZE, it's sort order is "smaller" meaning 16-bit configs are // put in the list before 32-bit configs. So, to make sure 16-bit is preffered over 32-bit, // we must set the red/green/blue sizes to zero. This has an unfortunate consequence that // if the application sets the red/green/blue size to 5/6/5 on the QPlatformWindowFormat, // they will probably get a 32-bit config, even when there's an RGB565 config available. // Now normalize the values so -1 becomes 0 redSize = redSize > 0 ? redSize : 0; greenSize = greenSize > 0 ? greenSize : 0; blueSize = blueSize > 0 ? blueSize : 0; alphaSize = alphaSize > 0 ? alphaSize : 0; depthSize = depthSize > 0 ? depthSize : 0; stencilSize = stencilSize > 0 ? stencilSize : 0; sampleCount = sampleCount > 0 ? sampleCount : 0; QVector<EGLint> configAttributes; configAttributes.append(EGL_RED_SIZE); configAttributes.append(redSize); configAttributes.append(EGL_GREEN_SIZE); configAttributes.append(greenSize); configAttributes.append(EGL_BLUE_SIZE); configAttributes.append(blueSize); configAttributes.append(EGL_ALPHA_SIZE); configAttributes.append(alphaSize); configAttributes.append(EGL_DEPTH_SIZE); configAttributes.append(depthSize); configAttributes.append(EGL_STENCIL_SIZE); configAttributes.append(stencilSize); configAttributes.append(EGL_SAMPLES); configAttributes.append(sampleCount); configAttributes.append(EGL_SAMPLE_BUFFERS); configAttributes.append(sampleCount? 1:0); return configAttributes; }
QVector<QgsPoint> QgsSimplifyFeature::simplifyPoints( const QVector<QgsPoint>& pts, double tolerance ) { //just safety precaution if ( tolerance < 0 ) return pts; // Douglas-Peucker simplification algorithm int anchor = 0; int floater = pts.size() - 1; QList<StackEntry> stack; StackEntry temporary; StackEntry entry = {anchor, floater}; stack.append( entry ); QSet<int> keep; double anchorX; double anchorY; double seg_len; double max_dist; int farthest; double dist_to_seg; double vecX; double vecY; while ( !stack.empty() ) { temporary = stack.takeLast(); anchor = temporary.anchor; floater = temporary.floater; // initialize line segment if ( pts[floater] != pts[anchor] ) { anchorX = pts[floater].x() - pts[anchor].x(); anchorY = pts[floater].y() - pts[anchor].y(); seg_len = sqrt( anchorX * anchorX + anchorY * anchorY ); // get the unit vector anchorX /= seg_len; anchorY /= seg_len; } else { anchorX = anchorY = seg_len = 0.0; } // inner loop: max_dist = 0.0; farthest = anchor + 1; for ( int i = anchor + 1; i < floater; i++ ) { dist_to_seg = 0.0; // compare to anchor vecX = pts[i].x() - pts[anchor].x(); vecY = pts[i].y() - pts[anchor].y(); seg_len = sqrt( vecX * vecX + vecY * vecY ); // dot product: double proj = vecX * anchorX + vecY * anchorY; if ( proj < 0.0 ) { dist_to_seg = seg_len; } else { // compare to floater vecX = pts[i].x() - pts[floater].x(); vecY = pts[i].y() - pts[floater].y(); seg_len = sqrt( vecX * vecX + vecY * vecY ); // dot product: proj = vecX * ( -anchorX ) + vecY * ( -anchorY ); if ( proj < 0.0 ) { dist_to_seg = seg_len; } else { // calculate perpendicular distance to line (pythagorean theorem): dist_to_seg = sqrt( qAbs( seg_len * seg_len - proj * proj ) ); } if ( max_dist < dist_to_seg ) { max_dist = dist_to_seg; farthest = i; } } } if ( max_dist <= tolerance ) { // # use line segment keep.insert( anchor ); keep.insert( floater ); } else { StackEntry s = {anchor, farthest}; stack.append( s ); StackEntry r = {farthest, floater}; stack.append( r ); } } QList<int> keep2 = keep.toList(); qSort( keep2 ); QVector<QgsPoint> result; int position; while ( !keep2.empty() ) { position = keep2.takeFirst(); result.append( pts[position] ); } return result; }
EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, bool highestPixelFormat, int surfaceType) { EGLConfig cfg = 0; QVector<EGLint> configureAttributes = q_createConfigAttributesFromFormat(format); configureAttributes.append(EGL_SURFACE_TYPE); //we only support eglconfigs for windows for now configureAttributes.append(surfaceType); configureAttributes.append(EGL_RENDERABLE_TYPE); if (format.windowApi() == QPlatformWindowFormat::OpenVG) { configureAttributes.append(EGL_OPENVG_BIT); } else { configureAttributes.append(EGL_OPENGL_ES2_BIT); } configureAttributes.append(EGL_NONE); do { // Get the number of matching configurations for this set of properties. EGLint matching = 0; if (!eglChooseConfig(display, configureAttributes.constData(), 0, 0, &matching) || !matching) continue; // If we want the best pixel format, then return the first // matching configuration. if (highestPixelFormat) { eglChooseConfig(display, configureAttributes.constData(), &cfg, 1, &matching); if (matching < 1) continue; return cfg; } // Fetch all of the matching configurations and find the // first that matches the pixel format we wanted. int i = configureAttributes.indexOf(EGL_RED_SIZE); int confAttrRed = configureAttributes.at(i+1); i = configureAttributes.indexOf(EGL_GREEN_SIZE); int confAttrGreen = configureAttributes.at(i+1); i = configureAttributes.indexOf(EGL_BLUE_SIZE); int confAttrBlue = configureAttributes.at(i+1); i = configureAttributes.indexOf(EGL_ALPHA_SIZE); int confAttrAlpha = configureAttributes.at(i+1); EGLint size = matching; EGLConfig *configs = new EGLConfig [size]; eglChooseConfig(display, configureAttributes.constData(), configs, size, &matching); for (EGLint index = 0; index < size; ++index) { EGLint red, green, blue, alpha; eglGetConfigAttrib(display, configs[index], EGL_RED_SIZE, &red); eglGetConfigAttrib(display, configs[index], EGL_GREEN_SIZE, &green); eglGetConfigAttrib(display, configs[index], EGL_BLUE_SIZE, &blue); eglGetConfigAttrib(display, configs[index], EGL_ALPHA_SIZE, &alpha); if (red == confAttrRed && green == confAttrGreen && blue == confAttrBlue && (confAttrAlpha == 0 || alpha == confAttrAlpha)) { cfg = configs[index]; delete [] configs; return cfg; } } delete [] configs; } while (q_reduceConfigAttributes(&configureAttributes)); qWarning("Cant find EGLConfig, returning null config"); return 0; }
void BaseEditorProperty::addChild(BaseEditorProperty* child) { child->m_parent = this; m_children.append(child); }
void NASM::fillHighligherRules(QVector<Assembler::HighlightingRule> &highlightingRules, QList<QTextCharFormat *> &formats, bool &multiLineComments, QRegExp &commentStartExpression, QRegExp &commentEndExpression) { typedef Assembler::HighlightingRule HighlightingRule; QTextCharFormat &keywordFormat = *formats[0]; QTextCharFormat ®isterFormat = *formats[1]; QTextCharFormat &numberFormat = *formats[2]; QTextCharFormat &memoryFormat = *formats[3]; QTextCharFormat &labelFormat = *formats[4]; QTextCharFormat &commentFormat = *formats[5]; QTextCharFormat &systemFormat = *formats[6]; QTextCharFormat &iomacrosFormat = *formats[7]; QTextCharFormat "ationFormat = *formats[8]; QTextCharFormat &labelWithDotFormat = *formats[9]; //! Setting up regular expressions HighlightingRule rule; //! Keywords QStringList keywordPatterns; keywordPatterns << "\\bAAA\\b" << "\\bAAD\\b" << "\\bAAM\\b" << "\\bAAS\\b" << "\\bADC\\b" << "\\bADD\\b" << "\\bAND\\b" << "\\bCALL\\b" << "\\bCBW\\b" << "\\bCLC\\b" << "\\bCLD\\b" << "\\bCLI\\b" << "\\bCMC\\b" << "\\bCMP\\b" << "\\bCMPSB\\b" << "\\bCMPSW\\b" << "\\bCWD\\b" << "\\bDAA\\b" << "\\bDAS\\b" << "\\bDEC\\b" << "\\bDIV\\b" << "\\bESC\\b" << "\\bHLT\\b" << "\\bIDIV\\b" << "\\bIMUL\\b" << "\\bIN\\b" << "\\bINC\\b" << "\\bINT\\b" << "\\bINTO\\b" << "\\bIRET\\b" << "\\bJA\\b" << "\\bJAE\\b" << "\\bJB\\b" << "\\bJBE\\b" << "\\bJC\\b" << "\\bJCXZ\\b" << "\\bJE\\b" << "\\bJG\\b" << "\\bJGE\\b" << "\\bJL\\b" << "\\bJLE\\b" << "\\bJNA\\b" << "\\bJNAE\\b" << "\\bJNB\\b" << "\\bJNBE\\b" << "\\bJNC\\b" << "\\bJNE\\b" << "\\bJNG\\b" << "\\bJNGE\\b" << "\\bJNL\\b" << "\\bJNLE\\b" << "\\bJNO\\b" << "\\bJNP\\b" << "\\bJNS\\b" << "\\bJNZ\\b" << "\\bJO\\b" << "\\bJP\\b" << "\\bJPE\\b" << "\\bJPO\\b" << "\\bJS\\b" << "\\bJZ\\b" << "\\bJMP\\b" << "\\bLAHF\\b" << "\\bLDS\\b" << "\\bLEA\\b" << "\\bLES\\b" << "\\bLOCK\\b" << "\\bLODSB\\b" << "\\bLODSW\\b" << "\\bLOOP\\b" << "\\bLOOPE\\b" << "\\bLOOPNE\\b" << "\\bLOOPNZ\\b" << "\\bLOOPZ\\b" << "\\bMOV\\b" << "\\bMOVSB\\b" << "\\bMOVSW\\b" << "\\bMUL\\b" << "\\bNEG\\b" << "\\bNOP\\b" << "\\bNOT\\b" << "\\bOR\\b" << "\\bOUT\\b" << "\\bPOP\\b" << "\\bPOPF\\b" << "\\bPUSH\\b" << "\\bPUSHF\\b" << "\\bRCL\\b" << "\\bRCR\\b" << "\\bREP\\b" << "\\bREPE\\b" << "\\bREPNE\\b" << "\\bREPNZ\\b" << "\\bREPZ\\b" << "\\bRET\\b" << "\\bRETN\\b" << "\\bRETF\\b" << "\\bROL\\b" << "\\bROR\\b" << "\\bSAHF\\b" << "\\bSAL\\b" << "\\bSAR\\b" << "\\bSBB\\b" << "\\bSCASB\\b" << "\\bSCASW\\b" << "\\bSHL\\b" << "\\bSHR\\b" << "\\bSTC\\b" << "\\bSTD\\b" << "\\bSTI\\b" << "\\bSTOSB\\b" << "\\bSTOSW\\b" << "\\bSUB\\b" << "\\bTEST\\b" << "\\bWAIT\\b" << "\\bXCHG\\b" << "\\bXLAT\\b" << "\\bXOR\\b" << "\\bBOUND\\b" << "\\bENTER\\b" << "\\bINS\\b" << "\\bLEAVE\\b" << "\\bOUTS\\b" << "\\bPOPA\\b" << "\\bPUSHA\\b" << "\\bARPL\\b" << "\\bCLTS\\b" << "\\bLAR\\b" << "\\bLGDT\\b" << "\\bLIDT\\b" << "\\bLLDT\\b" << "\\bLMSW\\b" << "\\bLOADALL\\b" << "\\bLSL\\b" << "\\bLTR\\b" << "\\bSGDT\\b" << "\\bSIDT\\b" << "\\bSLDT\\b" << "\\bSMSW\\b" << "\\bSTR\\b" << "\\bVERR\\b" << "\\bVERW\\b" << "\\bBSF\\b" << "\\bBSR\\b" << "\\bBT\\b" << "\\bBTC\\b" << "\\bBTR\\b" << "\\bBTS\\b" << "\\bCDQ\\b" << "\\bCMPSD\\b" << "\\bCWDE\\b" << "\\bINSD\\b" << "\\bIRET\\b" << "\\bIRETW\\b" << "\\bIRETD\\b" << "\\bJCXZ\\b" << "\\bJECXZ\\b" << "\\bLFS\\b" << "\\bLGS\\b" << "\\bLSS\\b" << "\\bLODSD\\b" << "\\bMOVSD\\b" << "\\bMOVSX\\b" << "\\bMOVZX\\b" << "\\bOUTSD\\b" << "\\bPOPAD\\b" << "\\bPOPFD\\b" << "\\bPUSHAD\\b" << "\\bPUSHFD\\b" << "\\bSCASD\\b" << "\\bSETA\\b" << "\\bSETAE\\b" << "\\bSETB\\b" << "\\bSETBE\\b" << "\\bSETC\\b" << "\\bSETE\\b" << "\\bSETG\\b" << "\\bSETGE\\b" << "\\bSETL\\b" << "\\bSETLE\\b" << "\\bSETNA\\b" << "\\bSETNAE\\b" << "\\bSETNB\\b" << "\\bSETNBE\\b" << "\\bSETNC\\b" << "\\bSETNE\\b" << "\\bSETNG\\b" << "\\bSETNGE\\b" << "\\bSETNL\\b" << "\\bSETNLE\\b" << "\\bSETNO\\b" << "\\bSETNP\\b" << "\\bSETNS\\b" << "\\bSETNZ\\b" << "\\bSETO\\b" << "\\bSETP\\b" << "\\bSETPE\\b" << "\\bSETPO\\b" << "\\bSETS\\b" << "\\bSETZ\\b" << "\\bSHLD\\b" << "\\bSHRD\\b" << "\\bSTOSD\\b" << "\\bPOPAD\\b" << "\\bPOPFD\\b" << "\\bPUSHAD\\b" << "\\bPUSHFD\\b" << "\\bSCASD\\b" << "\\bBSWAP\\b" << "\\bCMPXCHG\\b" << "\\bINVD\\b" << "\\bINVLPG\\b" << "\\bWBINVD\\b" << "\\bXADD\\b" << "\\bCPUID\\b" << "\\bCMPXCHG8B\\b" << "\\bRDMSR\\b" << "\\bRDTSC\\b" << "\\bWRMSR\\b" << "\\bRSM\\b" << "\\bRDPMC\\b" << "\\bCMOVA\\b" << "\\bCMOVAE\\b" << "\\bCMOVB\\b" << "\\bCMOVBE\\b" << "\\bCMOVC\\b" << "\\bCMOVE\\b" << "\\bCMOVG\\b" << "\\bCMOVGE\\b" << "\\bCMOVL\\b" << "\\bCMOVLE\\b" << "\\bCMOVNA\\b" << "\\bCMOVNAE\\b" << "\\bCMOVNB\\b" << "\\bCMOVNBE\\b" << "\\bCMOVNC\\b" << "\\bCMOVNE\\b" << "\\bCMOVNG\\b" << "\\bCMOVNGE\\b" << "\\bCMOVNL\\b" << "\\bCMOVNLE\\b" << "\\bCMOVNO\\b" << "\\bCMOVNP\\b" << "\\bCMOVNS\\b" << "\\bCMOVNZ\\b" << "\\bCMOVO\\b" << "\\bCMOVP\\b" << "\\bCMOVPE\\b" << "\\bCMOVPO\\b" << "\\bCMOVS\\b" << "\\bCMOVZ\\b" << "\\bF2XM1\\b" << "\\bFABS\\b" << "\\bFADD\\b" << "\\bFADDP\\b" << "\\bFBLD\\b" << "\\bFBSTP\\b" << "\\bFCHS\\b" << "\\bFCLEX\\b" << "\\bFCOM\\b" << "\\bFCOMP\\b" << "\\bFCOMPP\\b" << "\\bFDECSTP\\b" << "\\bFDISI\\b" << "\\bFDIV\\b" << "\\bFDIVP\\b" << "\\bFDIVR\\b" << "\\bFDIVRP\\b" << "\\bFENI\\b" << "\\bFFREE\\b" << "\\bFIADD\\b" << "\\bFICOM\\b" << "\\bFICOMP\\b" << "\\bFIDIV\\b" << "\\bFIDIVR\\b" << "\\bFILD\\b" << "\\bFIMUL\\b" << "\\bFINCSTP\\b" << "\\bFINIT\\b" << "\\bFIST\\b" << "\\bFISTP\\b" << "\\bFISUB\\b" << "\\bFISUBR\\b" << "\\bFLD\\b" << "\\bFLD1\\b" << "\\bFLDCW\\b" << "\\bFLDENV\\b" << "\\bFLDENVW\\b" << "\\bFLDL2E\\b" << "\\bFLDL2T\\b" << "\\bFLDLG2\\b" << "\\bFLDLN2\\b" << "\\bFLDPI\\b" << "\\bFLDZ\\b" << "\\bFMUL\\b" << "\\bFMULP\\b" << "\\bFNCLEX\\b" << "\\bFNDISI\\b" << "\\bFNENI\\b" << "\\bFNINIT\\b" << "\\bFNOP\\b" << "\\bFNSAVE\\b" << "\\bFNSAVEW\\b" << "\\bFNSTCW\\b" << "\\bFNSTENV\\b" << "\\bFNSTENVW\\b" << "\\bFNSTSW\\b" << "\\bFPATAN\\b" << "\\bFPREM\\b" << "\\bFPTAN\\b" << "\\bFRNDINT\\b" << "\\bFRSTOR\\b" << "\\bFRSTORW\\b" << "\\bFSAVE\\b" << "\\bFSAVEW\\b" << "\\bFSCALE\\b" << "\\bFSQRT\\b" << "\\bFST\\b" << "\\bFSTCW\\b" << "\\bFSTENV\\b" << "\\bFSTENVW\\b" << "\\bFSTP\\b" << "\\bFSTSW\\b" << "\\bFSUB\\b" << "\\bFSUBP\\b" << "\\bFSUBR\\b" << "\\bFSUBRP\\b" << "\\bFTST\\b" << "\\bFWAIT\\b" << "\\bFXAM\\b" << "\\bFXCH\\b" << "\\bFXTRACT\\b" << "\\bFYL2X\\b" << "\\bFYL2XP1\\b" << "\\bFSETPM\\b" << "\\bFCOS\\b" << "\\bFLDENVD\\b" << "\\bFSAVED\\b" << "\\bFSTENVD\\b" << "\\bFPREM1\\b" << "\\bFRSTORD\\b" << "\\bFSIN\\b" << "\\bFSINCOS\\b" << "\\bFSTENVD\\b" << "\\bFUCOM\\b" << "\\bFUCOMP\\b" << "\\bFUCOMPP\\b" << "\\bFCMOVB\\b" << "\\bFCMOVBE\\b" << "\\bFCMOVE\\b" << "\\bFCMOVNB\\b" << "\\bFCMOVNBE\\b" << "\\bFCMOVNE\\b" << "\\bFCMOVNU\\b" << "\\bFCMOVU\\b" << "\\bFCOMI\\b" << "\\bFCOMIP\\b" << "\\bFUCOMI\\b" << "\\bFUCOMIP\\b" << "\\bCDQE\\b" << "\\bCQO\\b" << "\\bMOVMSKPS\\b" << "\\bMOVMSKPD\\b" << "\\bPOPCNT\\b" << "\\bLZCNT\\b" << "\\bCMPSQ\\b" << "\\bSCASQ\\b" << "\\bMOVSQ\\b" << "\\bLODSQ\\b" << "\\bSTOSQ\\b" << "\\bJRCXZ\\b" << "\\bIRETQ\\b" << "\\bPUSHFQ\\b" << "\\bPOPFQ\\b" << "\\bCMPXCHG16B\\b" << "\\bJRCXZ\\b" << "\\bINSB\\b" << "\\bINSW\\b" << "\\bOUTSB\\b" << "\\bOUTSW\\b" << "\\bLFENCE\\b" << "\\bSFENCE\\b" << "\\bMFENCE\\b" << "\\bPREFETCH\\b" << "\\bPREFETCHL\\b" << "\\bPREFETCHW\\b" << "\\bCLFLUSH\\b" << "\\bSYSENTER\\b" << "\\bSYSEXIT\\b" << "\\bSYSCALL\\b" << "\\bSYSRET\\b"; foreach (const QString &pattern, keywordPatterns) { rule.pattern = QRegExp(pattern); rule.pattern.setCaseSensitivity(Qt::CaseInsensitive); rule.format = keywordFormat; highlightingRules.append(rule); }
void GradientLine::paintEvent(QPaintEvent *event) { QWidget::paintEvent(event); QPainter p(this); if (!isEnabled()) { p.setBrush(Qt::NoBrush); p.setPen(QColor(0x444444)); p.drawRect(9, 31, width() - 14, height() - 32); p.drawTiledPixmap(10, 32, width() - 16, height() - 34, tilePixMap(8)); } else { QLinearGradient linearGradient(QPointF(0, 0), QPointF(width(), 0)); for (int i =0; i < m_stops.size(); i++) linearGradient.setColorAt(m_stops.at(i), m_colorList.at(i)); p.setBrush(Qt::NoBrush); p.setPen(QColor(0x444444)); p.drawRect(9, 31, width() - 14, height() - 32); p.drawTiledPixmap(9, 31, width() - 16, height() - 34, tilePixMap(8)); p.setBrush(linearGradient); p.setPen(QColor(0x222222)); p.drawRect(8, 30, width() - 14, height() - 32); p.setPen(QColor(255, 255, 255, 40)); p.drawRect(9, 31, width() - 16, height() - 34); p.setPen(Qt::black); for (int i =0; i < m_colorList.size(); i++) { int localYOffset = 0; QColor arrowColor(Qt::black); if (i == currentColorIndex()) { localYOffset = m_yOffset; arrowColor = QColor(0x909090); } p.setPen(arrowColor); if (i == 0 || i == (m_colorList.size() - 1)) localYOffset = 0; int pos = qreal((width() - 16)) * m_stops.at(i) + 9; p.setBrush(arrowColor); QVector<QPointF> points; if (localYOffset < -8) p.setOpacity(0.5); points.append(QPointF(pos + 0.5, 28.5 + localYOffset)); //triangle points.append(QPointF(pos - 3.5, 22.5 + localYOffset)); points.append(QPointF(pos + 4.5, 22.5 + localYOffset)); p.setRenderHint(QPainter::Antialiasing, true); p.drawPolygon(points); p.setRenderHint(QPainter::Antialiasing, false); p.setBrush(Qt::NoBrush); p.setPen(QColor(0x424242)); p.drawRect(pos - 4, 9 + localYOffset, 10, 11); p.drawTiledPixmap(pos - 4, 9 + localYOffset, 9, 10, tilePixMap(5)); p.setPen(QColor(0x424242)); p.setBrush(m_colorList.at(i)); p.drawRect(pos - 5, 8 + localYOffset, 10, 11); p.setBrush(Qt::NoBrush); p.setPen(QColor(255, 255, 255, 30)); p.drawRect(pos - 4, 9 + localYOffset, 8, 9); p.setOpacity(1); } } }
void GDLProver_Test::Prover_01(){ debug("Current directory ", QDir::current().path()); QString filenameTTT; #ifdef TARGET_OS_MAC filenameTTT = "../../../../"; #endif filenameTTT = filenameTTT.append("tictactoe.kif"); GDLProver prover; prover.setup(filenameTTT); QCOMPARE(prover.getInitPropositions().size(), 10); QCOMPARE(prover.getRoles().size(), 2); QVector<LRelation> initState = prover.getInitState(); prover.loadTempRelations(initState); Parser parser; // Initial state LRelation relation1 = parser.parseRelation(QString("(legal ?x noop)")); QCOMPARE(prover.evaluate(relation1).size(), 1); LRelation relation2 = parser.parseRelation(QString("(legal ?x ?y)")); QCOMPARE(prover.evaluate(relation2).size(), 10); LRelation relation3 = parser.parseRelation(QString("(terminal)")); QCOMPARE(prover.evaluate(relation3).size(), 0); LRelation relation4 = parser.parseRelation(QString("(open)")); QCOMPARE(prover.evaluate(relation4).size(), 1); LRelation relation5 = parser.parseRelation(QString("(line ?x)")); QCOMPARE(prover.evaluate(relation5).size(), 1); // Does a move QVector<LRelation> doesMove; doesMove.append(prover.manageRelation(parser.parseRelation("(does white (mark 1 1))"))); prover.loadAdditionalTempRelations(doesMove); QCOMPARE(prover.evaluate(relation1).size(), 1); QCOMPARE(prover.evaluate(relation2).size(), 10); QCOMPARE(prover.evaluate(relation3).size(), 0); QCOMPARE(prover.evaluate(relation4).size(), 1); QCOMPARE(prover.evaluate(relation5).size(), 1); LRelation relation6 = parser.parseRelation(QString("(next_cell 1 1 b)")); QCOMPARE(prover.evaluate(relation6).size(), 0); LRelation relation6a = parser.parseRelation(QString("(next_cell 1 1 x)")); QCOMPARE(prover.evaluate(relation6a).size(), 1); LRelation relation6b = parser.parseRelation(QString("(next_cell ?x ?y ?z)")); QCOMPARE(prover.evaluate(relation6b).size(), 9); LRelation relation7 = parser.parseRelation(QString("(next_cell ?x ?y b)")); QCOMPARE(prover.evaluate(relation7).size(), 8); }
void DialogCommandChangeState::operation(QVector<QString>& command) const{ if (ui->radioButtonReplace->isChecked()) command.append("0"); else if (ui->radioButtonAdd->isChecked()) command.append("1"); else if (ui->radioButtonRemove->isChecked()) command.append("2"); }
QVector<QXmlName> AccelTree::namespaceBindings(const QXmlNodeModelIndex &ni) const { /* We get a hold of the ancestor, and loop them in reverse document * order(first the parent, then the parent's parent, etc). As soon * we find a binding that hasn't already been added, we add it to the * result list. In that way, declarations appearing further down override * those further up. */ const PreNumber preNumber = toPreNumber(ni); const QXmlNodeModelIndex::Iterator::Ptr it(new AncestorIterator<true>(this, preNumber)); QVector<QXmlName> result; QXmlNodeModelIndex n(it->next()); /* Whether xmlns="" has been encountered. */ bool hasUndeclaration = false; while(!n.isNull()) { const QVector<QXmlName> &forNode = namespaces.value(toPreNumber(n)); const int len = forNode.size(); bool stopInheritance = false; for(int i = 0; i < len; ++i) { const QXmlName &nsb = forNode.at(i); if(nsb.namespaceURI() == StandardNamespaces::StopNamespaceInheritance) { stopInheritance = true; continue; } if(nsb.prefix() == StandardPrefixes::empty && nsb.namespaceURI() == StandardNamespaces::empty) { hasUndeclaration = true; continue; } if(!hasPrefix(result, nsb.prefix())) { /* We've already encountered an undeclaration, so we're supposed to skip * them. */ if(hasUndeclaration && nsb.prefix() == StandardPrefixes::empty) continue; else result.append(nsb); } } if(stopInheritance) break; else n = it->next(); } result.append(QXmlName(StandardNamespaces::xml, StandardLocalNames::empty, StandardPrefixes::xml)); return result; }
void SemanticHighlighter::incrementalApplyExtraAdditionalFormats( SyntaxHighlighter *highlighter, const QFuture<HighlightingResult> &future, int from, int to, const QHash<int, QTextCharFormat> &kindToFormat) { if (to <= from) return; const int firstResultBlockNumber = future.resultAt(from).line - 1; // blocks between currentBlockNumber and the last block with results will // be cleaned of additional extra formats if they have no results int currentBlockNumber = 0; for (int i = from - 1; i >= 0; --i) { const HighlightingResult &result = future.resultAt(i); const int blockNumber = result.line - 1; if (blockNumber < firstResultBlockNumber) { // stop! found where last format stopped currentBlockNumber = blockNumber + 1; // add previous results for the same line to avoid undoing their formats from = i + 1; break; } } QTextDocument *doc = highlighter->document(); QTC_ASSERT(currentBlockNumber < doc->blockCount(), return); QTextBlock b = doc->findBlockByNumber(currentBlockNumber); HighlightingResult result = future.resultAt(from); for (int i = from; i < to && b.isValid(); ) { const int blockNumber = result.line - 1; QTC_ASSERT(blockNumber < doc->blockCount(), return); // clear formats of blocks until blockNumber while (currentBlockNumber < blockNumber) { QVector<QTextLayout::FormatRange> noFormats; highlighter->setExtraFormats(b, noFormats); b = b.next(); ++currentBlockNumber; } // collect all the formats for the current line QVector<QTextLayout::FormatRange> formats; formats.reserve(to - from); forever { QTextLayout::FormatRange formatRange; formatRange.format = textCharFormatForResult(result, kindToFormat); if (formatRange.format.isValid()) { formatRange.start = result.column - 1; formatRange.length = result.length; formats.append(formatRange); } ++i; if (i >= to) break; result = future.resultAt(i); const int nextBlockNumber = result.line - 1; if (nextBlockNumber != blockNumber) break; } highlighter->setExtraFormats(b, formats); b = b.next(); ++currentBlockNumber; } }
template <typename T> void qc_init_metatype() { MetaTypeImpl<T>::instance = new MetaTypeImpl<T>(); gMetaTypes.append( MetaTypeImpl<T>::instance ); }
void fail(QString msg) { qWarning()<<"E:" <<msg; m_ok=false; m_errors.append("ERROR: "+msg); }
/* # define identifier replacement-list new-line # define identifier lparen identifier-list[opt] ) replacement-list new-line # define identifier lparen ... ) replacement-list new-line # define identifier lparen identifier-list, ... ) replacement-list new-line */ bool Preprocessor::parseDefineDirective(Item *group) { Q_ASSERT(group->toItemComposite()); const TokenSection line = readLine(); const QVector<int> cleanedLine = cleanTokenRange(line); if(cleanedLine.count() < 3) return false; // get identifier const int identifier = cleanedLine.at(2); //skip "#" and "define" DefineDirective *defineDirective = 0; int replacementListStart; // check if this is a macro function if (cleanedLine.count() >= 4 && m_tokenContainer.text(cleanedLine.at(3)) == "(" && !isWhiteSpace(cleanedLine.at(3) - 1)) { MacroFunctionDefinition *macro; macro = createNode<MacroFunctionDefinition>(m_memoryPool, group); int tokenIndex = 4; //point to first argument or ')' QVector<int> macroParameterList; while(tokenIndex < cleanedLine.count()) { QByteArray currentText = m_tokenContainer.text(cleanedLine.at(tokenIndex)); ++tokenIndex; if(currentText == ")") break; if(currentText == ",") continue; macroParameterList.append(cleanedLine.at(tokenIndex - 1)); } macro->setParameters(TokenList(m_tokenContainer, macroParameterList)); defineDirective = macro; replacementListStart = tokenIndex; } else { MacroDefinition *macro; macro = createNode<MacroDefinition>(m_memoryPool, group); defineDirective = macro; replacementListStart = 3; } Q_ASSERT(defineDirective); // This is a bit hackish.. we want the replacement list with whitepspace // tokens, but cleanedLine() has already removed those. And we can't use // the original line, because that may contain escaped newline tokens. // So we remove the esacped newlines and search for the token number // given by cleanedLine.at(replacementListStart) QVector<int> replacementList; const QVector<int> noEscNewline = cleanEscapedNewLines(line); if (replacementListStart < cleanedLine.count()) { const int cleanedLineReplacementListStart = cleanedLine.at(replacementListStart); const int rListStart = noEscNewline.indexOf(cleanedLineReplacementListStart); if (rListStart != -1) { const int skipNewLineToken = 1; for (int i = rListStart; i < noEscNewline.count() - skipNewLineToken; ++i) { const int tokenContainerIndex = noEscNewline.at(i); const Type type = m_tokenTypeList.at(tokenContainerIndex); // Don't append comment tokens. if (type != Token_line_comment && type != Token_multiline_comment) { replacementList.append(tokenContainerIndex); } } } } defineDirective->setTokenSection(line); defineDirective->setIdentifier(TokenList(m_tokenContainer, QVector<int>() << identifier)); defineDirective->setReplacementList(TokenList(m_tokenContainer, replacementList)); group->toItemComposite()->add(defineDirective); return true; }
void info (QString msg) { qDebug()<<"I:" <<msg; m_errors.append("INFO : "+msg); }
bool RTRModel::loadModelFromObjFile(const QString& filePath) { QFileInfo info(filePath); modelPath = info.dir().path(); QFile objModelFile(filePath); if(!objModelFile.open(QIODevice::ReadOnly)) { return false; } QTextStream objModelStream(&objModelFile); QString currentObjectName = ""; QString currentGroupName = ""; QString materialName = ""; QVector<RTRModelVertex*> tempVertexPositions; QVector<RTRVector3D> tempVertexNormals; QVector<RTRVector2D> tempVertexUVPositions; bool currentSmoothShading = true; while(!objModelStream.atEnd()) { //Read a line, spaces and begin and end are trimmed QString line = objModelStream.readLine().trimmed(); //Ignore empty lines and comment lines if (line.isEmpty()) continue; if (line[0] == '#') continue; QStringList param = line.split(' ', QString::SkipEmptyParts); QString command = param[0]; command.toLower(); param.removeFirst(); if (command == "mtllib") loadMaterialLibraryFromMtlFile(modelPath + "/" + param[0]); else if (command == "usemtl") materialName = param[0]; else if (command == "o") currentObjectName = param[0]; else if (command == "g") { currentGroupName = param[0]; } else if (command == "s") { if (param[0] == "off") currentSmoothShading = false; else currentSmoothShading = true; } else if (command == "v") { tempVertexPositions.append( addVertex(param[0].toDouble(), param[1].toDouble(), param[2].toDouble())); } else if (command == "vn") { tempVertexNormals.append(RTRVector3D(param[0].toDouble(), param[1].toDouble(), param[2].toDouble())); tempVertexNormals.back().vectorNormalize(); } else if (command == "vt") { tempVertexUVPositions.append(RTRVector2D(param[0].toDouble(), param[1].toDouble())); } else if (command == "f") { RTRModelPolygen* poly = new RTRModelPolygen(); poly->objectName = currentObjectName; poly->groupName = currentGroupName; poly->materialName = materialName; poly->smoothShading = currentSmoothShading; for (int i = 0; i < param.size(); i++) { QStringList list = param[i].split("/"); switch (list.size()) { case 1: poly->vertices.append(tempVertexPositions[list[0].toInt() - 1]); break; case 2: poly->vertices.append(tempVertexPositions[list[0].toInt() - 1]); poly->uvMaps.append(tempVertexUVPositions[list[1].toInt() - 1]); break; case 3: poly->vertices.append(tempVertexPositions[list[0].toInt() - 1]); if (!list[1].isEmpty()) poly->uvMaps.append(tempVertexUVPositions[list[1].toInt() - 1]); poly->normals.append(tempVertexNormals[list[2].toInt() - 1]); break; default: break; } } polygens.insert(poly); } else { qDebug() << "Ignoring Unsupported Line : " << command << param; } } objModelFile.close(); return true; }
QVector<QPoint> ImageProcessor::findOcculsionFaster(QImage input) { int radius = (int) (.1 * input.height()); //qDebug()<<"radius: " <<radius; //left side int bestLeftY=0; int bestLeftYval=INT_MAX; for(int currentY=radius;currentY<input.height()-radius;currentY++) { int sum =0; foreach(int x,ImageProcessor::regionVals(0,currentY,radius,input)) { sum+=x; } if(sum < bestLeftYval) { bestLeftY = currentY; bestLeftYval = sum; } } //right side int bestRightY=0; int bestRightYval=INT_MAX; for(int currentY=radius;currentY<input.height()-radius;currentY++) { int sum =0; foreach(int x,ImageProcessor::regionVals(input.width()-1,currentY,radius,input)) { sum+=x; } //qDebug()<<"Sum was: " <<sum; if(sum < bestRightYval) { bestRightY = currentY; bestRightYval = sum; } } int yPen = bestLeftY; QVector<QPoint> returnMe; for(int x=0;x<input.width();x++) { //go from left to right int diff = bestRightY - yPen; if(qAbs(diff) == (input.width() - x)) { int movementDir = qAbs(diff)/diff; //+1 or -1 to push it in the right direction yPen += movementDir; } else { float penUpTotal= ImageProcessor::calculateCenterValue(input,x,yPen+1); float penRightTotal=ImageProcessor::calculateCenterValue(input,x,yPen); float penDownTotal=ImageProcessor::calculateCenterValue(input,x,yPen-1); float lowest = qMin(qMin(penUpTotal,penRightTotal),penDownTotal); if(penUpTotal == lowest) { yPen++; } else if(penDownTotal == lowest) { yPen--; } } returnMe.append(QPoint(x,yPen)); } return returnMe; }
void Homepage::initialUI() { QString langImagePath = g_appPath + QString("/data/image_cn/homepage/english_n.png"); QString helpImagePath = g_appPath + QString("/data/image_cn/homepage/help_n.png"); Utility::addButton(QImage(langImagePath).size(), HM_LANG_POS, g_appPath + "/data/image_cn/homepage/english_n.png*" + g_appPath + "/data/image_cn/homepage/english_p.png", g_appPath + "/data/image_en/homepage/chinese_n.png*" + g_appPath + "/data/image_en/homepage/chinese_p.png", this, SLOT(onLocaleChanged()), QString(""), this); Utility::addButton(QImage(helpImagePath).size(), HM_HELP_POS, g_appPath + "/data/image_cn/homepage/help_n.png*" + g_appPath + "/data/image_cn/homepage/help_p.png", g_appPath + "/data/image_en/homepage/help_n.png*" + g_appPath + "/data/image_en/homepage/help_p.png", this, SLOT(sltHelp()), QString(""), this); QVector<QString> adFiles; QDir dir(g_appPath + QString("/data/ads/banner_cn/")); QFileInfoList f_list=dir.entryInfoList(); dir.setFilter(QDir::Files|QDir::NoDot|QDir::NoDotAndDotDot|QDir::NoSymLinks); qDebug() << trUtf8("--------从本地获取广告文件 begin--------"); for(int i=0;i<f_list.count();i++){ QFileInfo f_info=f_list.at(i); QString stt=f_info.fileName(); if(stt != QString(".") && stt != QString("..")) { qDebug() << stt; adFiles.append(stt); } } qDebug() << trUtf8("--------从本地获取广告文件 end--------"); AdWgt* adWgt = new AdWgt(this); adWgt->resize(QSize(720, 485)); adWgt->move(60, 110); for(int i = 0; i < adFiles.count(); i++) { QString suffix = adFiles.at(i).right(3); if(suffix == QString("jpg") || suffix == QString("png")) { adWgt->addAdItem(AdWgt::AdItemType_Picture, adFiles.at(i)); } if(suffix == QString("avi")) { adWgt->addAdItem(AdWgt::AdItemType_Video, adFiles.at(i)); } } adWgt->show(); adWgt->startAnimation(true); // 4; QSize imageBtnSize = QImage(g_appPath + QString("/data/image_cn/homepage/courierin_n.png")).size(); Utility::addButton(imageBtnSize, HM_CJ_POS, g_appPath + "/data/image_cn/homepage/courierin_n.png*" + g_appPath + "/data/image_cn/homepage/courierin_p.png", g_appPath + "/data/image_en/homepage/courierin_n.png*" + g_appPath + "/data/image_en/homepage/courierin_p.png", this, SLOT(sltCj()), QString(""), this); Utility::addButton(imageBtnSize, HM_QJ_POS, g_appPath + "/data/image_cn/homepage/fetch_n.png*" + g_appPath + "/data/image_cn/homepage/fetch_p.png", g_appPath + "/data/image_en/homepage/fetch_n.png*" + g_appPath + "/data/image_en/homepage/fetch_p.png", this, SLOT(sltQj()), QString(""), this); Utility::addButton(imageBtnSize, HM_CX_POS, g_appPath + "/data/image_cn/homepage/query_n.png*" + g_appPath + "/data/image_cn/homepage/query_p.png", g_appPath + "/data/image_en/homepage/query_n.png*" + g_appPath + "/data/image_en/homepage/query_p.png", this, SLOT(sltCx()), QString(""), this); // Utility::addButton(imageBtnSize, HM_JJ_POS, // g_appPath + "/data/pic/main/jj.jpg*" + g_appPath + "/data/pic/main/jj_2.jpg", // g_appPath + "/data/piceng/main/jj.jpg*" + g_appPath + "/data/piceng/main/jj_2.jpg", // this, SLOT(sltJj()), // QString(""), this); TerminalConfig info = g_transaction->terminalConfig(); sltAdInfoChanged(info.adInfo); }
void StatsExplorer::loadStakeChart(bool firstRun) { // if(fShutdown) // return; nTimeData.clear(); netStakeData.clear(); myStakeData.clear(); difficultyData.clear(); velTimeData.clear(); velAmountData.clear(); // go back this many blocks max int max = ui->spinBox->value(); int i = 0; int64_t diffMax = 0; // int64_t hashMax = 0; double velMax = 0; BOOST_FOREACH(const PAIRTYPE(uint256, CBlockIndex*)& item, mapBlockIndex) { if(i >= max) break; CBlockIndex* pindex = item.second; nTimeData.append(pindex->nTime); netStakeData.append(0); velTimeData.append(pindex->nTime); // if(pindex->IsProofOfStake()) if (true) { // netStakeData.append(pindex->nMint / COIN); netStakeData.append(0); // Read the block in and check if the coinstake is ours CBlock block; ReadBlockFromDisk(block, pindex, Params().GetConsensus()); // if(block.IsProofOfStake()) // this should always be true here if(true) // this should always be true here { velTimeData.append(pindex->nTime); double blockOutAmount = 0; for(uint j=0; j<block.vtx.size(); j++) { // FIXME: check dereferencing CTransaction vtx = *block.vtx[j]; blockOutAmount += vtx.GetValueOut() / COIN; } velMax = std::max<double>(velMax, blockOutAmount); velAmountData.append(blockOutAmount); int64_t d = GetDifficulty(pindex); diffMax = std::max<int64_t>(diffMax, d); difficultyData.append(d); // if(IsMine(block.vtx[1])) if(false) { // myStakeData.append(pindex->nMint / COIN); myStakeData.append(0); } else { myStakeData.append(0); } } else { myStakeData.append(0); // should never happen } } ++i; } if(!firstRun) { uint64_t nMinWeight = 0, nMaxWeight = 0; // uint64_t nWeight = 0; // nWeight = nMinWeight * nMaxWeight; // pwalletMain->GetStakeWeight(*pwalletMain, nMinWeight, nMaxWeight, nWeight); // uint64_t nNetworkWeight = 0; // if(pindexBest) // nNetworkWeight = GetPoSKernelPS(); // bool staking = nLastCoinStakeSearchInterval && nWeight; // bool staking = false; // int nExpectedTime = staking ? (nTargetSpacing * nNetworkWeight / nWeight) : -1; /* ui->stakingLabel->setText(staking ? "Enabled" : "Disabled"); bool pindexBest = true; if(pindexBest) ui->difficultyLabel->setText(QString::number(GetDifficulty(mapBlockIndex[chainActive.Tip()->GetBlockHash()]))); ui->weightLabel->setText(QString::number(nWeight)); ui->netWeightLabel->setText(QString::number(nNetworkWeight)); ui->timeToStakeLabel->setText(QString::number(nExpectedTime) + " secs"); */ } QLinearGradient plotGradient; plotGradient.setStart(0, 0); plotGradient.setFinalStop(0, 350); plotGradient.setColorAt(0, QColor(10, 10, 10)); plotGradient.setColorAt(1, QColor(0, 0, 0)); QLinearGradient diffPlotGradient; diffPlotGradient.setStart(0, 0); diffPlotGradient.setFinalStop(0, 350); diffPlotGradient.setColorAt(0, QColor(10, 10, 10)); diffPlotGradient.setColorAt(1, QColor(0, 0, 0)); QLinearGradient velPlotGradient; velPlotGradient.setStart(0, 0); velPlotGradient.setFinalStop(0, 150); velPlotGradient.setColorAt(0, QColor(10, 10, 10)); velPlotGradient.setColorAt(1, QColor(0, 0, 0)); ui->difficultyPlot->clearPlottables(); ui->difficultyPlot->clearGraphs(); ui->difficultyPlot->clearItems(); ui->difficultyPlot->addGraph(); ui->difficultyPlot->graph(0)->setPen(QPen(QColor(43, 239, 209))); // line color orange for first graph ui->difficultyPlot->graph(0)->setBrush(QBrush(QColor(43, 239, 209, 20))); // first orange will be filled with translucent green ui->difficultyPlot->graph(0)->setData(nTimeData, difficultyData); ui->difficultyPlot->setBackground(diffPlotGradient); // ui->difficultyPlot->xAxis->setRangeLower(nTimeData.first()); // ui->difficultyPlot->xAxis->setRangeUpper(nTimeData.last()); ui->difficultyPlot->yAxis->setRangeLower(0); ui->difficultyPlot->yAxis->setRangeUpper(diffMax+(diffMax/10)); ui->difficultyPlot->xAxis->grid()->setVisible(false); ui->difficultyPlot->yAxis->grid()->setVisible(false); ui->difficultyPlot->xAxis->grid()->setSubGridVisible(false); ui->difficultyPlot->yAxis->grid()->setSubGridVisible(false); ui->difficultyPlot->xAxis->setAutoTickStep(false); ui->difficultyPlot->xAxis->setTickStep(3600 * 24); // 24 hr tickstep ui->difficultyPlot->xAxis->setTickLabelType(QCPAxis::ltDateTime); ui->difficultyPlot->xAxis->setDateTimeSpec(Qt::UTC); ui->difficultyPlot->xAxis->setDateTimeFormat("dd MMM"); ui->difficultyPlot->xAxis->setTickLabelRotation(33); ui->difficultyPlot->xAxis->setTickLabelColor(QColor(43, 239, 209, 95)); ui->difficultyPlot->yAxis->setTickLabelColor(QColor(43, 239, 209, 95)); ui->difficultyPlot->rescaleAxes(); ui->difficultyPlot->yAxis->setTickStep(0.00005); ui->difficultyPlot->xAxis->setLabelColor(QColor(43, 239, 209, 95)); ui->difficultyPlot->yAxis->setLabelColor(QColor(43, 239, 209, 95)); ui->difficultyPlot->yAxis->setLabel("Difficulty"); ui->difficultyPlot->xAxis->setTickLabels(true); //ui->difficultyPlot->xAxis->setLabel("Time"); ui->difficultyPlot->replot(); /* ui->customPlot->clearPlottables(); ui->customPlot->clearGraphs(); ui->customPlot->clearItems(); ui->customPlot->addGraph(); ui->customPlot->graph(0)->setPen(QPen(QColor(43, 239, 209))); // line color cream for first graph ui->customPlot->graph(0)->setBrush(QBrush(QColor(0, 255, 139, 20))); // first graph will be filled with translucent cream ui->customPlot->addGraph(); ui->customPlot->graph(1)->setPen(QPen(QColor(43, 239, 209))); // line color orange for second graph ui->customPlot->graph(1)->setBrush(QBrush(QColor(0, 255, 139, 20))); if(ui->networkCheckBox->isChecked()) ui->customPlot->graph(0)->setData(nTimeData, netStakeData); ui->customPlot->graph(1)->setData(nTimeData, myStakeData); ui->customPlot->setBackground(plotGradient); ui->customPlot->xAxis->setRangeLower(nTimeData.first()); ui->customPlot->xAxis->setRangeUpper(nTimeData.last()); ui->customPlot->xAxis->grid()->setVisible(false); ui->customPlot->yAxis->grid()->setVisible(false); ui->customPlot->xAxis->grid()->setSubGridVisible(false); ui->customPlot->yAxis->grid()->setSubGridVisible(false); ui->customPlot->xAxis->setAutoTickStep(false); ui->customPlot->xAxis->setTickStep(3600 * 24); // 24 hr tickstep ui->customPlot->xAxis->setTickLabelType(QCPAxis::ltDateTime); ui->customPlot->xAxis->setDateTimeSpec(Qt::UTC); ui->customPlot->xAxis->setDateTimeFormat("dd. MMM hh:mm"); ui->customPlot->xAxis->setTickLabelRotation(33); ui->customPlot->xAxis->setTickLabelColor(QColor(43, 239, 209, 95)); ui->customPlot->yAxis->setTickLabelColor(QColor(43, 239, 209, 95)); ui->customPlot->rescaleAxes(); ui->customPlot->xAxis->setLabelColor(QColor(43, 239, 209, 95)); ui->customPlot->yAxis->setLabelColor(QColor(43, 239, 209, 95)); ui->customPlot->yAxis->setLabel("VCN Minted"); ui->customPlot->xAxis->setLabel("Stake Block Generation Time"); ui->customPlot->replot(); */ ui->velocityPlot->clearPlottables(); ui->velocityPlot->clearGraphs(); ui->velocityPlot->clearItems(); ui->velocityPlot->addGraph(); ui->velocityPlot->graph(0)->setPen(QPen(QColor(43, 239, 209))); // line color orange for first graph ui->velocityPlot->graph(0)->setBrush(QBrush(QColor(43, 239, 209, 20))); // first graph will be filled with translucent orange ui->velocityPlot->graph(0)->setData(velTimeData, velAmountData); ui->velocityPlot->setBackground(velPlotGradient); // ui->velocityPlot->xAxis->setRangeLower(velTimeData.first()); // ui->velocityPlot->xAxis->setRangeUpper(velTimeData.last()); ui->velocityPlot->yAxis->setRangeLower(0); ui->velocityPlot->yAxis->setRangeUpper(velMax+(velMax/10)); ui->velocityPlot->xAxis->grid()->setVisible(false); ui->velocityPlot->yAxis->grid()->setVisible(false); ui->velocityPlot->xAxis->grid()->setSubGridVisible(false); ui->velocityPlot->yAxis->grid()->setSubGridVisible(false); ui->velocityPlot->xAxis->setAutoTickStep(false); ui->velocityPlot->xAxis->setTickStep(3600 * 24); // 24 hr tickstep ui->velocityPlot->xAxis->setTickLabelType(QCPAxis::ltDateTime); ui->velocityPlot->xAxis->setDateTimeSpec(Qt::UTC); ui->velocityPlot->xAxis->setDateTimeFormat("dd MMM"); ui->velocityPlot->xAxis->setTickLabelRotation(33); ui->velocityPlot->xAxis->setTickLabelColor(QColor(43, 239, 209, 95)); ui->velocityPlot->yAxis->setTickLabelColor(QColor(43, 239, 209, 95)); ui->velocityPlot->yAxis->setScaleType(QCPAxis::stLogarithmic); ui->velocityPlot->yAxis->setTickStep(1000); ui->velocityPlot->xAxis->setLabelColor(QColor(43, 239, 209, 95)); ui->velocityPlot->yAxis->setLabelColor(QColor(43, 239, 209, 95)); ui->velocityPlot->yAxis->setLabel("VCN"); ui->velocityPlot->xAxis->setTickLabels(true); //ui->velocityPlot->xAxis->setLabel("Financial Velocity"); ui->velocityPlot->rescaleAxes(); ui->velocityPlot->replot(); }
void AndroidAssetsFileEngineHandler::prepopulateCache() const { Q_ASSERT(!m_hasTriedPrepopulatingCache); m_hasTriedPrepopulatingCache = true; Q_ASSERT(m_assetsCache.isEmpty()); // Failsafe: Don't read cache files that are larger than 1MB static qint64 maxPrepopulatedCacheSize = qMax(1024LL * 1024LL, qgetenv("QT_ANDROID_MAX_PREPOPULATED_ASSETS_CACHE_SIZE").toLongLong()); const char *fileName = "--Added-by-androiddeployqt--/qt_cache_pregenerated_file_list"; AAsset *asset = AAssetManager_open(m_assetManager, fileName, AASSET_MODE_BUFFER); if (asset) { m_hasPrepopulatedCache = true; AndroidAbstractFileEngine fileEngine(asset, QString::fromLatin1(fileName)); if (fileEngine.open(QIODevice::ReadOnly)) { qint64 size = fileEngine.size(); if (size <= maxPrepopulatedCacheSize) { QByteArray bytes(size, Qt::Uninitialized); qint64 read = fileEngine.read(bytes.data(), size); if (read != size) { qWarning("Failed to read prepopulated cache"); return; } QDataStream stream(&bytes, QIODevice::ReadOnly); stream.setVersion(QDataStream::Qt_5_3); if (stream.status() != QDataStream::Ok) { qWarning("Failed to read prepopulated cache"); return; } while (!stream.atEnd()) { QString directoryName; stream >> directoryName; int fileCount; stream >> fileCount; QVector<QString> fileList; fileList.reserve(fileCount); while (fileCount--) { QString fileName; stream >> fileName; fileList.append(fileName); } QSharedPointer<AndroidAssetDir> *aad = new QSharedPointer<AndroidAssetDir>(new AndroidAssetDir(0)); (*aad)->m_items = fileList; // Cost = 0, because we should always cache everything if there's a prepopulated cache QByteArray key = directoryName != QLatin1String("/") ? QByteArray("assets:/") + directoryName.toUtf8() : QByteArray("assets:"); bool ok = m_assetsCache.insert(key, aad, 0); if (!ok) qWarning("Failed to insert in cache: %s", qPrintable(directoryName)); } } else {
//The function receives the data from Add Filter and filters the data. The filtered sheet is then used to further processing Sheet* PivotMain::filter() { Sheet *const sheet1 = d->selection->lastSheet(); const QRect range2 = d->selection->lastRange(); Map *mymap=sheet1->map(); Sheet* sheet2=mymap->createSheet("Filtered Sheet"); int r= range2.right(); int b=range2.bottom(); int row=range2.top(); QVector<QString> vect; QVector<int> filtered; if(d->filterVect.count()<3) return sheet1; for(int k=row+1;k<=b;k++) { bool pass=true; if(d->filterVect.count()==3) { pass=checkCondition(d->filterVect.at(0),d->filterVect.at(1),d->filterVect.at(2),k); } else if(d->filterVect.count()==7) { if(d->filterVect.at(3)=="And") pass= checkCondition(d->filterVect.at(0),d->filterVect.at(1),d->filterVect.at(2),k) && checkCondition(d->filterVect.at(4),d->filterVect.at(5),d->filterVect.at(6),k); if(d->filterVect.at(3)=="Or") pass= checkCondition(d->filterVect.at(0),d->filterVect.at(1),d->filterVect.at(2),k) || checkCondition(d->filterVect.at(4),d->filterVect.at(5),d->filterVect.at(6),k); } else if(d->filterVect.count()==11) { if(d->filterVect.at(3)=="And") pass= checkCondition(d->filterVect.at(0),d->filterVect.at(1),d->filterVect.at(2),k) && checkCondition(d->filterVect.at(4),d->filterVect.at(5),d->filterVect.at(6),k); if(d->filterVect.at(3)=="Or") pass= checkCondition(d->filterVect.at(0),d->filterVect.at(1),d->filterVect.at(2),k) || checkCondition(d->filterVect.at(4),d->filterVect.at(5),d->filterVect.at(6),k); if(d->filterVect.at(7)=="And") pass= pass && checkCondition(d->filterVect.at(9),d->filterVect.at(10),d->filterVect.at(11),k); if(d->filterVect.at(7)=="Or") pass= pass || checkCondition(d->filterVect.at(4),d->filterVect.at(5),d->filterVect.at(6),k); } if(pass==true) filtered.append(k); } for(int j=1;j<=r;j++) Cell(sheet2,j,1).setValue(Cell(sheet1,j,1).value()); for(int i=0;i<filtered.count();i++) { for(int j=1;j<=r;j++) { Cell(sheet2,j,i+2).setValue(Cell(sheet1,j,filtered.at(i)).value()); } } d->filtersize=filtered.count()+1; return sheet2; }
InsitucCADMainWindow::InsitucCADMainWindow(QWidget * parent) : QMainWindow(parent) , ui(new Ui::InsitucCADMainWindow) { ui->setupUi(this); tableModelGlobalVariables = new TableModelGlobalVariables(this); tableModelGlobalVariablesValues = new TableModelGlobalVariables(this); tableGlobalVariablesValuesProxyModel = new TableGlobalVariablesProxyModel(this); tableGlobalVariablesValuesProxyModel->setSourceModel(tableModelGlobalVariablesValues); ui->tableViewGlobalVariables->setModel(tableModelGlobalVariables); ui->tableViewGlobalVariablesValues->setModel(tableGlobalVariablesValuesProxyModel); ui->tableViewGlobalVariables->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); ui->tableViewGlobalVariables->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); ui->tableViewGlobalVariablesValues->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); ui->tableViewGlobalVariablesValues->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); { connect(tableModelGlobalVariables, SIGNAL(rowsInserted(QModelIndex const &, int, int)), SLOT(on_globalVariablesChanged())); connect(tableModelGlobalVariables, SIGNAL(rowsRemoved(QModelIndex const &, int, int)), SLOT(on_globalVariablesChanged())); connect(tableModelGlobalVariables, SIGNAL(dataChanged(QModelIndex const &, QModelIndex const &, QVector< int > const &)), SLOT(on_globalVariablesChanged())); connect(tableModelGlobalVariables, SIGNAL(modelReset()), SLOT(on_globalVariablesChanged())); } connect(ui->tableViewGlobalVariables->selectionModel(), SIGNAL(selectionChanged(QItemSelection const &, QItemSelection const &)), SLOT(on_globalVariablesSelectionChanged())); { treeModelTranfsormations = new TreeModelTranfsormations(this); //delete new ModelTest(treeModelTranfsormations, this); ui->treeViewTransformations->setModel(treeModelTranfsormations); editorChooseGlobalVariable = new EditorChooseGlobalVariable(this); ui->treeViewTransformations->setItemDelegateForColumn(0, editorChooseGlobalVariable); ui->toolButtonAddTransformation->setDefaultAction(ui->actionAddTransformation); ui->toolButtonAddChildTransformation->setDefaultAction(ui->actionAddSuccessiveTransformation); ui->toolButtonRemoveTransformation->setDefaultAction(ui->actionRemoveTransformation); ui->treeViewTransformations->header()->setSectionResizeMode(QHeaderView::ResizeToContents); } setupTextEditorMonospace(ui->textEditSource); setupTextEditorHighlighter(ui->textEditSource); setupTextEditorMonospace(ui->textEditAst); setupTextEditorHighlighter(ui->textEditAst); setupTextEditorMonospace(ui->textEditAssembly); ui->toolButtonAddGlobalVariable->setDefaultAction(ui->actionAddGlobalVariable); ui->toolButtonRemoveGlobalVariable->setDefaultAction(ui->actionRemoveGlobalVariable); ui->toolButtonParse->setDefaultAction(ui->actionParse); ui->toolButtonTransform->setDefaultAction(ui->actionTransform); ui->toolButtonBuild->setDefaultAction(ui->actionBuild); ui->toolButtonInterpret->setDefaultAction(ui->actionInterpret); ui->toolButtonCompile->setDefaultAction(ui->actionCompile); { QPalette termPalette = ui->textEditAssembly->palette(); termPalette.setColor(QPalette::Base, Qt::black); termPalette.setColor(QPalette::Text, Qt::white); ui->textEditAssembly->setPalette(termPalette); } ui->tabWidget->setCurrentIndex(0); ui->textEditSource->setFocus(); ui->textEditSource->setPlainText("function Gauss(x)\n\treturn a * pow2(-sqr(r * (x / m - one)))\nend"); QVector< QPair< QString, QString > > globalVariables; globalVariables.append(QPair< QString, QString >("a", "1")); globalVariables.append(QPair< QString, QString >("r", "1")); globalVariables.append(QPair< QString, QString >("m", "0")); tableModelGlobalVariables->populateWithData(globalVariables); }