bool removeTimer(int id)
    {
        if (id >= timerInfos.size())
            return false;

        WinRTTimerInfo &info = timerInfos[id];
        if (info.timerId == INVALID_TIMER_ID)
            return false;

        if (info.interval > 0 && (!timerIdToHandle.contains(id) || !timerIdToCancelHandle.contains(id)))
            return false;

        info.timerId = INVALID_TIMER_ID;

        // Remove invalid timerinfos from the vector's end, if the timer with the highest id was removed
        int lastTimer = timerInfos.size() - 1;
        while (lastTimer >= 0 && timerInfos.at(lastTimer).timerId == INVALID_TIMER_ID)
            --lastTimer;
        if (lastTimer >= 0 && lastTimer != timerInfos.size() - 1)
            timerInfos.resize(lastTimer + 1);
        timerIdToObject.remove(id);
        // ... remove handle from all lists
        if (info.interval > 0) {
            HANDLE handle = timerIdToHandle.take(id);
            timerHandleToId.remove(handle);
            SetEvent(timerIdToCancelHandle.take(id));
        }
        return true;
    }
Example #2
0
void CROCDlg::fitPlotData(QVector<QPointF> &data)
{
	fitData = true;
	if(m_pSeries != NULL)
		delete m_pSeries;

	// get mean of hyperbola constant
	m_K = 0.0F;
	int count = 0;
	for(int i=0; i<(int)data.size(); i++)
	{
		if( (data[i].x() > FLT_EPSILON) && (data[i].x() < 1.0F) )
		{
			m_K += data[i].x()*data[i].y();
			count++;
		}
	}
	m_K /= (float)count;

	// create 100 Point plot of hyperbola
	QVector<QPointF> regression;
	QPointF P(0.0F,0.0F);
	regression.push_back(P);	// plot the 0,0 point
	for(float x=0.0F; x<1.0F; x += 0.01F)
	{
		P.setX(x);
		P.setY(1.0F - m_K / x);
		if(P.y()>0.0F)
			regression.push_back(P);
	}
	m_pSeries = new QwtPointSeriesData(regression);

	m_pPlotCurve->setData(m_pSeries);
	m_pPlotCurve->attach(ui.ROCPlot);
}
Example #3
0
void UmlClassView::generate()
{
    QVector<UmlItem*> ch = UmlItem::children();

    for (unsigned index = 0; index != ch.size(); index += 1)
        ch[index]->generate();
}
Example #4
0
int SaveBursts(const QVector<Burst> &burstVector, const BurstSearchParams_t BurstSearchParams, const QString filename)
{
    QFile file;
    if(filename.isEmpty()) qFatal("SaveBursts: enter a valid filename");
    else file.setFileName(filename);

    if(burstVector.size()==0) {
        AlexEvalLog::warning("vector is empty");
        return EXIT_FAILURE;
    }
    if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
        AlexEvalLog::warning(file.errorString());
        return EXIT_FAILURE;
    }
    QTextStream out(&file);
    out << BurstSearchParams.toString("# ","\t") //Burst Search with parameters\tM="<<BurstSearchParams.M<<"\tL="<<BurstSearchParams.L()<<" \tT="<<BurstSearchParams.T*1e6<<" us.\t"
       <<".\t" <<burstVector.size()<<" bursts were found.\n";
    out <<"# start photon \tstart time in s \tnumber of photons \tburst duration in ms\n";
    out.setRealNumberPrecision(11);
    for(int i=0;i<burstVector.size();++i) {
        out <<burstVector[i].startIdx<<"\t"<<burstVector[i].startTime<<"\t"
           <<burstVector[i].numberOfPhotons<<"\t"<<burstVector[i].duration*1e3<<"\n";
    }

    AlexEvalLog::text(burstVector.size() + "bursts written to file " + file.fileName());
    file.close();
    return EXIT_SUCCESS;

}
Example #5
0
void KDescendantsProxyModelPrivate::processPendingParents()
{
    Q_Q(KDescendantsProxyModel);
    const QVector<QPersistentModelIndex>::iterator begin = m_pendingParents.begin();
    QVector<QPersistentModelIndex>::iterator it = begin;

    const QVector<QPersistentModelIndex>::iterator end = m_pendingParents.end();

    QVector<QPersistentModelIndex> newPendingParents;

    while (it != end && it != m_pendingParents.end()) {
        const QModelIndex sourceParent = *it;
        if (!sourceParent.isValid() && m_rowCount > 0) {
            // It was removed from the source model before it was inserted.
            it = m_pendingParents.erase(it);
            continue;
        }
        const int rowCount = q->sourceModel()->rowCount(sourceParent);

        Q_ASSERT(rowCount > 0);
        const QPersistentModelIndex sourceIndex = q->sourceModel()->index(rowCount - 1, 0, sourceParent);

        Q_ASSERT(sourceIndex.isValid());

        const QModelIndex proxyParent = q->mapFromSource(sourceParent);

        Q_ASSERT(sourceParent.isValid() == proxyParent.isValid());
        const int proxyEndRow = proxyParent.row() + rowCount;
        const int proxyStartRow = proxyEndRow - rowCount + 1;

        if (!m_relayouting) {
            q->beginInsertRows(QModelIndex(), proxyStartRow, proxyEndRow);
        }

        updateInternalIndexes(proxyStartRow, rowCount);
        m_mapping.insert(sourceIndex, proxyEndRow);
        it = m_pendingParents.erase(it);
        m_rowCount += rowCount;

        if (!m_relayouting) {
            q->endInsertRows();
        }

        for (int sourceRow = 0; sourceRow < rowCount; ++sourceRow) {
            static const int column = 0;
            const QModelIndex child = q->sourceModel()->index(sourceRow, column, sourceParent);
            Q_ASSERT(child.isValid());

            if (q->sourceModel()->hasChildren(child)) {
                Q_ASSERT(q->sourceModel()->rowCount(child) > 0);
                newPendingParents.append(child);
            }
        }
    }
    m_pendingParents += newPendingParents;
    if (!m_pendingParents.isEmpty()) {
        processPendingParents();
    }
//   scheduleProcessPendingParents();
}
Example #6
0
void UmlClassView::write(FileOut & out)
{
    if (_gen_views) {
        out.indent();
        out << ((_uml_20) ? "<ownedMember" : "<packagedElement")
            << " xmi:type=\"uml:Package\"";
        out.id(this);
        out << " name =\"class view ";
        out.quote(name());
        out << "\">\n";
        out.indent(+1);
        write_description_properties(out);
    }

    const QVector<UmlItem*> ch = children();
    unsigned n = ch.size();

    for (unsigned i = 0; i != n; i += 1)
        ch[i]->write(out);

    if (_gen_views) {
        while (! _relations.isEmpty())
            _relations.takeAt(0)->write(out, FALSE);

        out.indent(-1);
        out.indent();
        out << ((_uml_20) ? "</ownedMember>\n" : "</packagedElement>\n");
    }
}
Example #7
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void InsertAtoms::setupFilterParameters()
{
  FilterParameterVector parameters;
  parameters.push_back(FloatVec3FilterParameter::New("Lattice Constants (Angstroms)", "LatticeConstants", getLatticeConstants(), FilterParameter::Parameter));
  {
    ChoiceFilterParameter::Pointer parameter = ChoiceFilterParameter::New();
    parameter->setHumanLabel("Crystal Basis");
    parameter->setPropertyName("Basis");

    QVector<QString> choices;
    choices.push_back("Simple Cubic");
    choices.push_back("Body Centered Cubic");
    choices.push_back("Face Centered Cubic");
    parameter->setChoices(choices);
    parameter->setCategory(FilterParameter::Parameter);
    parameters.push_back(parameter);
  }
  parameters.push_back(SeparatorFilterParameter::New("Face Data", FilterParameter::RequiredArray));
  {
    DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateRequirement(DREAM3D::TypeNames::Int32, 2, DREAM3D::AttributeMatrixType::Face, DREAM3D::GeometryType::TriangleGeometry);
    parameters.push_back(DataArraySelectionFilterParameter::New("Face Labels", "SurfaceMeshFaceLabelsArrayPath", getSurfaceMeshFaceLabelsArrayPath(), FilterParameter::RequiredArray, req));
  }
  parameters.push_back(SeparatorFilterParameter::New("Cell Feature Data", FilterParameter::RequiredArray));
  {
    DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateRequirement(DREAM3D::TypeNames::Float, 4, DREAM3D::AttributeMatrixType::CellFeature, DREAM3D::GeometryType::ImageGeometry);
    parameters.push_back(DataArraySelectionFilterParameter::New("Average Quaternions", "AvgQuatsArrayPath", getAvgQuatsArrayPath(), FilterParameter::RequiredArray, req));
  }
  parameters.push_back(StringFilterParameter::New("Data Container", "VertexDataContainerName", getVertexDataContainerName(), FilterParameter::CreatedArray));
  parameters.push_back(SeparatorFilterParameter::New("Vertex Data", FilterParameter::CreatedArray));
  parameters.push_back(StringFilterParameter::New("Vertex Attribute Matrix", "VertexAttributeMatrixName", getVertexAttributeMatrixName(), FilterParameter::CreatedArray));
  parameters.push_back(StringFilterParameter::New("Atom Feature Labels", "AtomFeatureLabelsArrayName", getAtomFeatureLabelsArrayName(), FilterParameter::CreatedArray));
  setFilterParameters(parameters);
}
void PropertySyncer::propertyChanged()
{
    const auto *obj = sender();
    Q_ASSERT(obj);
    const auto it = std::find_if(m_objects.constBegin(), m_objects.constEnd(), [obj](const ObjectInfo &info) {
        return info.obj == obj;
    });
    Q_ASSERT(it != m_objects.constEnd());

    if ((*it).recursionLock || !(*it).enabled)
        return;

    const auto sigIndex = senderSignalIndex();
    QVector<QPair<QString, QVariant> > changes;
    for (int i = qobjectPropertyOffset(); i < obj->metaObject()->propertyCount(); ++i) {
        const auto prop = obj->metaObject()->property(i);
        if (prop.notifySignalIndex() != sigIndex)
            continue;
        changes.push_back(qMakePair(QString(prop.name()), prop.read(obj)));
    }
    Q_ASSERT(!changes.isEmpty());

    Message msg(m_address, Protocol::PropertyValuesChanged);
    msg.payload() << (*it).addr << (quint32)changes.size();
    foreach (const auto &change, changes)
        msg.payload() << change.first << change.second;
    emit message(msg);
}
Example #9
0
static inline int addVertex(iIMDShape *s, int i, const iIMDPoly *p, int frameidx)
{
	// if texture animation flag is present, fetch animation coordinates for this polygon
	// otherwise just show the first set of texel coordinates
	int frame = (p->flags & iV_IMD_TEXANIM) ? frameidx : 0;

	// See if we already have this defined, if so, return reference to it.
	for (int j = 0; j < vertexCount; j++)
	{
		if (texcoords[j * 2 + 0] == p->texCoord[frame * 3 + i].x
		    && texcoords[j * 2 + 1] == p->texCoord[frame * 3 + i].y
		    && vertices[j * 3 + 0] == s->points[p->pindex[i]].x
		    && vertices[j * 3 + 1] == s->points[p->pindex[i]].y
		    && vertices[j * 3 + 2] == s->points[p->pindex[i]].z
		    && normals[j * 3 + 0] == p->normal.x
		    && normals[j * 3 + 1] == p->normal.y
		    && normals[j * 3 + 2] == p->normal.z)
		{
			return j;
		}
	}
	// We don't have it, add it.
	normals.append(p->normal.x);
	normals.append(p->normal.y);
	normals.append(p->normal.z);
	texcoords.append(p->texCoord[frame * 3 + i].x);
	texcoords.append(p->texCoord[frame * 3 + i].y);
	vertices.append(s->points[p->pindex[i]].x);
	vertices.append(s->points[p->pindex[i]].y);
	vertices.append(s->points[p->pindex[i]].z);
	vertexCount++;
	return vertexCount - 1;
}
QgsGeometry QgsInternalGeometryEngine::densifyByDistance( double distance ) const
{
  if ( !mGeometry )
  {
    return QgsGeometry();
  }

  if ( QgsWkbTypes::geometryType( mGeometry->wkbType() ) == QgsWkbTypes::PointGeometry )
  {
    return QgsGeometry( mGeometry->clone() ); // point geometry, nothing to do
  }

  if ( const QgsGeometryCollection *gc = qgsgeometry_cast< const QgsGeometryCollection *>( mGeometry ) )
  {
    int numGeom = gc->numGeometries();
    QVector< QgsAbstractGeometry * > geometryList;
    geometryList.reserve( numGeom );
    for ( int i = 0; i < numGeom; ++i )
    {
      geometryList << densifyGeometry( gc->geometryN( i ), -1, distance );
    }

    QgsGeometry first = QgsGeometry( geometryList.takeAt( 0 ) );
    for ( QgsAbstractGeometry *g : qgis::as_const( geometryList ) )
    {
      first.addPart( g );
    }
    return first;
  }
  else
  {
    return QgsGeometry( densifyGeometry( mGeometry, -1, distance ) );
  }
}
Example #11
0
void TransferFunctionEditor::loadState(Value& in)
{
	transferFunction.loadState(in);
	
	setRange(transferFunction.GetMin(), transferFunction.GetMax());

  transferFunctionAlphaScalingSlider.setValue(int(transferFunction.GetScale() * (transferFunctionAlphaScalingSlider.minimum() + transferFunctionAlphaScalingSlider.maximum())));

	QVector<QPointF> points;
	for (int i = 0; i < transferFunction.GetAlphas().size(); i++)
		points.push_back(QPointF(transferFunction.GetAlphas()[i].x, transferFunction.GetAlphas()[i].y));

  transferFunctionAlphaWidget.setPoints(points);

	if (in.HasMember("Colormap"))
	{
		ColorMap cmap;
		cmap.loadState(in["Colormap"]);

		int colorMapIndex;
		for(colorMapIndex = 0; colorMapIndex < colorMaps.size(); colorMapIndex++)
			if (colorMaps[colorMapIndex].getName() == cmap.getName())
				break;

		if (colorMapIndex == colorMaps.size())
			addColorMap(VColorMap(cmap));

		colorMapComboBox.setCurrentIndex(colorMapIndex);
	}

}
QgsGeometry QgsInternalGeometryEngine::orthogonalize( double tolerance, int maxIterations, double angleThreshold ) const
{
  if ( !mGeometry || ( QgsWkbTypes::geometryType( mGeometry->wkbType() ) != QgsWkbTypes::LineGeometry
                       && QgsWkbTypes::geometryType( mGeometry->wkbType() ) != QgsWkbTypes::PolygonGeometry ) )
  {
    return QgsGeometry();
  }

  double lowerThreshold = std::cos( ( 90 - angleThreshold ) * M_PI / 180.00 );
  double upperThreshold = std::cos( angleThreshold * M_PI / 180.0 );

  if ( const QgsGeometryCollection *gc = qgsgeometry_cast< const QgsGeometryCollection *>( mGeometry ) )
  {
    int numGeom = gc->numGeometries();
    QVector< QgsAbstractGeometry * > geometryList;
    geometryList.reserve( numGeom );
    for ( int i = 0; i < numGeom; ++i )
    {
      geometryList << orthogonalizeGeom( gc->geometryN( i ), maxIterations, tolerance, lowerThreshold, upperThreshold );
    }

    QgsGeometry first = QgsGeometry( geometryList.takeAt( 0 ) );
    for ( QgsAbstractGeometry *g : qgis::as_const( geometryList ) )
    {
      first.addPart( g );
    }
    return first;
  }
  else
  {
    return QgsGeometry( orthogonalizeGeom( mGeometry, maxIterations, tolerance, lowerThreshold, upperThreshold ) );
  }
}
Example #13
0
void TabDialog::importContainerInfo()
{
    QVector<Car> import;
    for(int i = 0; i < catalog.size();i++)
    {
        if(catalog[i].getType() != findWidget->getCurrentType())
            continue;
        if(catalog[i].getState() != findWidget->getCurrentState())
            continue;
        if(catalog[i].getBrand() != findWidget->getCurrentBrand() && findWidget->getCurrentBrand() != "Любая")
            continue;
        if(catalog[i].getModel() != findWidget->getCurrentModel() && findWidget->getCurrentModel() != "Любая")
            continue;
        if(catalog[i].getBodyType() != findWidget->getCurrentBodyType() && findWidget->getCurrentBodyType() != "Любой")
            continue;
        if(catalog[i].getRegion() != findWidget->getCurrentRegion() && findWidget->getCurrentRegion() != "Любой")
            continue;
        if(catalog[i].getCurrency() != findWidget->getCurrentCurrency())
            continue;
        if(((catalog[i].getYear() >= findWidget->getMinimumYear()) && (catalog[i].getYear() <= findWidget->getMaximumYear()))
                || ((findWidget->getMinimumYear() != 0) && (findWidget->getMaximumYear() != 0)))
            continue;
        if(catalog[i].getPrice() <= findWidget->getMinimumPrice() || catalog[i].getPrice() >= findWidget->getMaximumPrice())
            continue;
        import.push_back(catalog[i]);
    }
    emit infoToTable(import.size(),import);
}
Example #14
0
QVector<QPair<QString, QString>> CameraDevice::getDeviceList()
{
    QVector<QPair<QString, QString>> devices;

    devices.append({"none", QObject::tr("None", "No camera device set")});

    if (!getDefaultInputFormat())
            return devices;

    if (!iformat);
#ifdef Q_OS_WIN
    else if (iformat->name == QString("dshow"))
        devices += DirectShow::getDeviceList();
#endif
    else
        devices += getRawDeviceListGeneric();

    if (idesktopFormat)
    {
        if (idesktopFormat->name == QString("x11grab"))
            devices.push_back(QPair<QString,QString>{"x11grab#:0", QObject::tr("Desktop", "Desktop as a camera input for screen sharing")});
        if (idesktopFormat->name == QString("gdigrab"))
            devices.push_back(QPair<QString,QString>{"gdigrab#desktop", QObject::tr("Desktop", "Desktop as a camera input for screen sharing")});
    }

    return devices;
}
Example #15
0
void MainWindow::on_btn_start_clicked()
{
    rsim->reset();
    scene->clear();
    graphicalInit();
    ui->liste_tributs_1->clear();
    ui->liste_tributs_2->clear();
    g_billes.clear();
    photos_g.clear();
    outlight_g.clear();

    int n = ui->nbilles_dial->value();

    for(int i=0;i<n;i++) {
        if(i%2 == 0) {
            ui->liste_tributs_1->addItem("Palmer?");
        } else if(i%2 == 1) {
            ui->liste_tributs_2->addItem("Palmer?");
        }
    }

    rsim->start(n);
    QVector<b2Body*> b=rsim->getBalls();

    for(int i=0;i<b.size();i++) {
        QGraphicsEllipseItem* g_bille = scene->addEllipse(-10,-10,35,35,QPen(), QBrush(QColor(200,86,23)));
        g_billes.append(g_bille);

        QGraphicsPixmapItem* p = scene->addPixmap(unknown);

        if(n<= 12) {
            p->setScale(0.5f);

            int total_height = (ceil(b.size()/2.0))*150+40;
            p->setPos(i%2==0? -540 : 520-100, -total_height/2+(i/2)*150);
        } else {
            float scale = 0.5*12/(float)n;
            p->setScale(scale);

            float height = 150*12/(float) n;
            int total_height = (ceil(b.size()/2.0))*height+40;
            p->setPos(i%2==0? -540 : 520-100*12/(float)n, -total_height/2+(i/2)*height);

        }
        photos_g.append(p);

        QVector<QPointF> points;
        points.append(QPointF(0,0));
        points.append(QPointF(1500,0));
        points.append(QPointF(1500*cos(1/48.0*2*3.14159),1500*sin(1/48.0*2*3.14159)));

        QGraphicsPolygonItem* outlight = scene->addPolygon(QPolygonF(points),QPen(QColor(255,255,255,128)),QBrush(QColor(255,192+(rand()%64 - 32),0,96)));
        outlight->setZValue(-1);
        outlight->setTransformOriginPoint(QPointF(0,0));
        outlight->setVisible(false);
        outlight_g.append(outlight);

    }

}
int SoccerView::UpdateBalls ( QVector<QPointF> &_balls, int cameraID )
{
  QVector<QGraphicsEllipseItem*> tmp;
  while(cameraID+1>ballItems.size())
    ballItems.append(tmp);

  if ( ballItems[cameraID].size() < _balls.size() ){
    //need to allocate some space for the new balls
    QPen pen ( QColor ( 0xcd,0x59,0x00,0xff ) );
    pen.setWidth ( 4 );
    QBrush brush ( QColor ( 0xff,0x81,0x00,0xff ),Qt::SolidPattern );
    while(_balls.size()>ballItems[cameraID].size()){
      ballItems[cameraID].append ( scene->addEllipse ( 0,0,42,42,pen,brush ) );
      ballItems[cameraID][ballItems[cameraID].size()-1]->setZValue(2);
    }
  }
  else if ( ballItems[cameraID].size() >_balls.size() ){
    //need to delete some balls
    while(ballItems[cameraID].size()>_balls.size()){
      scene->removeItem ( ballItems[cameraID][0] );
      ballItems[cameraID].remove(0);
    }
  }

  for ( int i=0;i<_balls.size();i++ ){
    //Let's update the ball positions now
    ballItems[cameraID][i]->setPos ( _balls[i].x()-21,-_balls[i].y()-21 );
  }

  int balls = ballItems[cameraID].size();
  return balls;
}
bool Api::adminSelectInformation(const AdminSelectInformationRequestPackage &requestPackage, QVector<Information_DataPackage> &target, QVector<QString> &target2)
{
    target.clear();
    target2.clear();

    Jdn::Set send, accepted;
    Information_DataPackage buf;
    QString buf2;
    send.push_back_single_data(requestPackage);

    if(JasonQt_Tcp::standardHandleProcess(*m_client, send, accepted, OKNum, ErrorNum) == "OK")
    {
        QMap<Information_DataPackage, QString> buf3;

        while(accepted.next())
        {
            if(accepted.copy_current_from_single_data(buf))
            {
                accepted.next();
                buf2 = accepted.currentNodeQString();

                buf3.insert(buf, buf2);
            }
        }

        for(auto it = buf3.begin(); it != buf3.end(); it++)
        {
            target.push_back(it.key());
            target2.push_back(it.value());
        }

        return true;
    }
    return false;
}
QVector<bool> TagsManager::writeTags(const QVector<SongFile>& songs)
{
    QVector<bool> result;

    for (SongFile const& song : songs)
    {
        bool success = false;

        if (!song.getAuthors().isEmpty() || !song.getTitle().isEmpty())
        {
            const QString songFilePath = song.getFilepath();
            TagLib::FileRef file(songFilePath.toStdString().c_str());

            if (!file.isNull() && file.tag())
            {
                TagLib::Tag *tag = file.tag();

                tag->setArtist(song.getAuthors().join(";").toStdString());
                tag->setTitle(song.getTitle().toStdString());

                success = file.save();
            }
        }

        result.append(success);
    }

    return result;
}
Example #19
0
QVector<Vector3> Geom::Box::getGridSamples( int N )
{
	QVector<Vector3> samples;

	// the size of regular grid
	double gridV = this->volume() / N;
	double gridSize = pow(gridV, 1.0/3);
	int nbX = (int)ceil(2 * Extent[0] / gridSize);
	int nbY = (int)ceil(2 * Extent[1] / gridSize);
	int nbZ = (int)ceil(2 * Extent[2] / gridSize);
	double stepX = 2.0 / nbX;
	double stepY = 2.0 / nbY;
	double stepZ = 2.0 / nbZ;

	for (int i = 0; i <= nbX; i++)
	for (int j = 0; j <= nbY; j++)
	for (int k = 0; k <= nbZ; k++)
	{
		double ci = -1 + i * stepX;
		double cj = -1 + j * stepY;
		double ck = -1 + k * stepZ;
		samples.push_back(this->getPosition(Vector3(ci, cj, ck)));
	}

	return samples;
}
void QgsCoordinateTransform::transformInPlace(
  QVector<double> &x, QVector<double> &y, QVector<double> &z,
  TransformDirection direction ) const
{

  if ( !d->mIsValid || d->mShortCircuit )
    return;

  Q_ASSERT( x.size() == y.size() );

  // Apparently, if one has a std::vector, it is valid to use the
  // address of the first element in the vector as a pointer to an
  // array of the vectors data, and hence easily interface with code
  // that wants C-style arrays.

  try
  {
    transformCoords( x.size(), &x[0], &y[0], &z[0], direction );
  }
  catch ( const QgsCsException & )
  {
    // rethrow the exception
    QgsDebugMsg( QStringLiteral( "rethrowing exception" ) );
    throw;
  }
}
QVector<QAspectJobPtr> QRenderAspect::jobsToExecute(qint64 time)
{
    Q_D(QRenderAspect);
    d->m_time = time;

    // Create jobs that will get exectued by the threadpool
    QVector<QAspectJobPtr> jobs;

    // Create jobs to load in any meshes that are pending
    if (d->m_renderer != Q_NULLPTR && !d->m_shuttingDown) {
        d->m_framePreparationJob.reset(new Render::FramePreparationJob(d->m_renderer, d->m_renderer->renderSceneRoot()));
        d->m_cleanupJob.reset(new Render::FrameCleanupJob(d->m_renderer));
        d->m_worldTransformJob.reset(new Render::UpdateWorldTransformJob(d->m_renderer->renderSceneRoot()));
        d->m_boundingVolumeJob.reset(new Render::UpdateBoundingVolumeJob(d->m_renderer->renderSceneRoot()));

        QHash<QNodeId, QAbstractMeshFunctorPtr> meshSources = d->m_renderer->meshDataManager()->meshesPending();
        Q_FOREACH (const QNodeId &meshId, meshSources.keys()) {
            Render::LoadMeshDataJobPtr loadMeshJob(new Render::LoadMeshDataJob(meshSources[meshId], meshId));
            loadMeshJob->setRenderer(d->m_renderer);
            jobs.append(loadMeshJob);
        }

        QVector<QNodeId> texturesPending = d->m_renderer->textureDataManager()->texturesPending();
        Q_FOREACH (const QNodeId &textureId, texturesPending) {
            Render::LoadTextureDataJobPtr loadTextureJob(new Render::LoadTextureDataJob(textureId));
            loadTextureJob->setRenderer(d->m_renderer);
            jobs.append(loadTextureJob);
        }
Example #22
0
void GLSLTextEditorWidget::setFontSettings(const TextEditor::FontSettings &fs)
{
    TextEditor::BaseTextEditorWidget::setFontSettings(fs);
    Highlighter *highlighter = qobject_cast<Highlighter*>(baseTextDocument()->syntaxHighlighter());
    if (!highlighter)
        return;

    /*
        NumberFormat,
        StringFormat,
        TypeFormat,
        KeywordFormat,
        LabelFormat,
        CommentFormat,
        VisualWhitespace,
     */
    static QVector<TextEditor::TextStyle> categories;
    if (categories.isEmpty()) {
        categories << TextEditor::C_NUMBER
                   << TextEditor::C_STRING
                   << TextEditor::C_TYPE
                   << TextEditor::C_KEYWORD
                   << TextEditor::C_OPERATOR
                   << TextEditor::C_PREPROCESSOR
                   << TextEditor::C_LABEL
                   << TextEditor::C_COMMENT
                   << TextEditor::C_DOXYGEN_COMMENT
                   << TextEditor::C_DOXYGEN_TAG
                   << TextEditor::C_VISUAL_WHITESPACE
                   << TextEditor::C_REMOVED_LINE;
    }

    highlighter->setFormats(fs.toTextCharFormats(categories));
    highlighter->rehighlight();
}
Example #23
0
//***提取测试记录
QVector<testRecord> CDatabase::getTest(QString id)
{
    QVector<testRecord> t;

    QSqlQuery sql(_db);
    sql.exec("select * from test where meter='" + id + "'");
    int i=0;
    while(sql.next())
    {
        testRecord a;
        a._id       = sql.value(0).toInt();
        a._meter    = sql.value(1).toString();
        a._user     = sql.value(2).toString();
        a._date     = sql.value(3).toInt();
        a._inittest = sql.value(4).toInt();
        a._fulltest = sql.value(5).toInt();
        a._adjusttest   = sql.value(6).toInt();
        a._functiontest = sql.value(7).toInt();
        a._comment      = sql.value(8).toString();

        t.insert(i++,1,a);
    }

    return t;
}
void DialogActiveRunways::setActive(ActiveAirport &airport)
{
    QString airportCode = airport.airportCode;
    bool dep = airport.dep;
    bool arr = airport.arr;
    QStringList depRwys = airport.depRwys;
    QStringList arrRwys = airport.arrRwys;

    QVector<QModelIndex> indexes;

    for(int i = 0; i < model->rowCount(); i++)
    {
        QModelIndex currentIndex = model->index(i, 2);
        if(currentIndex.data().toString() == airportCode) indexes.append(currentIndex);
    }

    for(int i = 0; i < indexes.size(); i++)
    {
        int row = indexes.at(i).row();

        if(dep) static_cast<QCheckBox*>(uiInner->tableViewRunways->indexWidget(model->index(row, 0))->layout()->itemAt(0)->widget())->setChecked(true);
        if(arr) static_cast<QCheckBox*>(uiInner->tableViewRunways->indexWidget(model->index(row, 1))->layout()->itemAt(0)->widget())->setChecked(true);

        for(int j = 0; j < depRwys.size(); j++)
        {
            if(depRwys.at(j) == model->index(row, 3).data().toString()) static_cast<QCheckBox*>(uiInner->tableViewRunways->indexWidget(model->index(row, 4))->layout()->itemAt(0)->widget())->setChecked(true);
        }

        for(int j = 0; j < arrRwys.size(); j++)
        {
            if(arrRwys.at(j) == model->index(row, 3).data().toString()) static_cast<QCheckBox*>(uiInner->tableViewRunways->indexWidget(model->index(row, 5))->layout()->itemAt(0)->widget())->setChecked(true);
        }
    }
}
static PyObject *convertFrom_QVector_0600QPair_2400_0100QVariant(void *sipCppV, PyObject *sipTransferObj)
{
   QVector<QPair<qreal,QVariant> > *sipCpp = reinterpret_cast<QVector<QPair<qreal,QVariant> > *>(sipCppV);

#line 257 "/Users/Kunwiji/Dropbox/Spectroscopy_paper/PyQt-mac-gpl-4.11.2/sip/QtCore/qvector.sip"
    // Create the list.
    PyObject *l;

    if ((l = PyList_New(sipCpp->size())) == NULL)
        return NULL;

    // Set the list elements.
    for (int i = 0; i < sipCpp->size(); ++i)
    {
        const QPair<qreal, QVariant> &p = sipCpp->at(i);
        QVariant *pt = new QVariant(p.second);
        PyObject *pobj;

        if ((pobj = sipBuildResult(NULL, "(dN)", p.first, pt, sipType_QVariant, sipTransferObj)) == NULL)
        {
            Py_DECREF(l);
            delete pt;

            return NULL;
        }

        PyList_SET_ITEM(l, i, pobj);
    }

    return l;
#line 166 "/Users/Kunwiji/Dropbox/Spectroscopy_paper/PyQt-mac-gpl-4.11.2/QtCore/sipQtCoreQVector0600QPair24000100QVariant.cpp"
}
// Convert OpenCV Mat to QImage format
QImage ViosGui::Mat2QImage(const Mat& mat)
{
    // 8-bits unsigned, NO. OF CHANNELS=1
    if(mat.type()==CV_8UC1)
    {
        // Set the color table (used to translate colour indexes to qRgb values)
        QVector<QRgb> colorTable;
        for (int i=0; i<256; i++)
            colorTable.push_back(qRgb(i,i,i));
        // Copy input Mat
        const uchar *qImageBuffer = (const uchar*)mat.data;
        // Create QImage with same dimensions as input Mat
        QImage img(qImageBuffer, mat.cols, mat.rows, mat.step, QImage::Format_Indexed8);
        img.setColorTable(colorTable);
        return img;
    }
    // 8-bits unsigned, NO. OF CHANNELS=3
    if(mat.type()==CV_8UC3)
    {
        // Copy input Mat
        const uchar *qImageBuffer = (const uchar*)mat.data;
        // Create QImage with same dimensions as input Mat
        QImage img(qImageBuffer, mat.cols, mat.rows, mat.step, QImage::Format_RGB888);
        return img.rgbSwapped();
    }
    else
    {
        qDebug() << "ERROR: Mat could not be converted to QImage.";
        return QImage();
    }
} // MatToQImage()
Example #27
0
void SidebarWidget::mousePressEvent(QMouseEvent *event)
{
    int fh = fontMetrics().lineSpacing();
    int ys = event->pos().y();
    int index = -1;
    int xofs = width() - foldIndicatorWidth;

    // Calculate the line number corresponding to the click coordinates
    for (int i = 0; i<lineNumbers.size(); i++) {
        if (lineNumbers[i].position < ys && (lineNumbers[i].position + fh) > ys) {
            index = i;
            break;
        }
    }

    if (index >= 0) {
        JSEdit *editor = qobject_cast<JSEdit*>(parent());
        if (lineNumbers.at(index).foldable) {
            if (foldIndicatorWidth > 0) {
                if (event->pos().x() > xofs) {
                    if (editor) {
                        editor->toggleFold(lineNumbers.at(index).number);
                    }
                }
            }
        }

        if (event->pos().x() < xofs) {
            if (editor) {
                editor->toggleBreakPoint(lineNumbers.at(index).number);
            }
        }
    }
}
Example #28
0
CgalTriCadInterface::CgalTriCadInterface(vtkUnstructuredGrid *grid)
{
  m_BGrid = vtkUnstructuredGrid::New();
  makeCopy(grid, m_BGrid);
  m_BPart.setGrid(m_BGrid, true);

  double feature_angle;

  EG_STOPDATE("2015-01-01");
  //getXmlSetting("engrid/surface/settings", "feature_angle", feature_angle);
  getSet("surface meshing", "feature angle", 20, feature_angle);
  feature_angle = GeometryTools::deg2rad(feature_angle);

  // build triangle tree
  {
    m_Triangles.clear();
    QVector<vtkIdType> tris;
    getAllCellsOfType(VTK_TRIANGLE, tris, m_BGrid);
    m_Triangles.fill(Triangle(), tris.size());
    m_Tri2Grid.fill(-1, tris.size());
    int i = 0;
    foreach (vtkIdType id_cell, tris) {
      EG_GET_CELL(id_cell, m_BGrid);
      vec3_t a, b, c;
      m_BGrid->GetPoint(pts[0], a.data());
      m_BGrid->GetPoint(pts[1], b.data());
      m_BGrid->GetPoint(pts[2], c.data());
      m_Triangles[i] = Triangle(Point(a[0], a[1], a[2]), Point(b[0], b[1], b[2]), Point(c[0], c[1], c[2]));
      m_Tri2Grid[i] = id_cell;
      ++i;
    }
    m_TriangleTree.rebuild(m_Triangles.begin(), m_Triangles.end());
    m_TriangleTree.accelerate_distance_queries();
  }
Example #29
0
QDataStream &operator<<(QDataStream &s, const QPen &p)
{
    QPenData *dd = static_cast<QPenData *>(p.d);
    if (s.version() < 3) {
        s << (quint8)p.style();
    } else if (s.version() < QDataStream::Qt_4_3) {
        s << (quint8)(p.style() | p.capStyle() | p.joinStyle());
    } else {
        s << (quint16)(p.style() | p.capStyle() | p.joinStyle());
        s << (bool)(dd->cosmetic);
    }

    if (s.version() < 7) {
        s << (quint8)p.width();
        s << p.color();
    } else {
        s << double(p.widthF());
        s << p.brush();
        s << double(p.miterLimit());
        if (sizeof(qreal) == sizeof(double)) {
            s << p.dashPattern();
        } else {
            // ensure that we write doubles here instead of streaming the pattern
            // directly; otherwise, platforms that redefine qreal might generate
            // data that cannot be read on other platforms.
            QVector<qreal> pattern = p.dashPattern();
            s << quint32(pattern.size());
            for (int i = 0; i < pattern.size(); ++i)
                s << double(pattern.at(i));
        }
        if (s.version() >= 9)
            s << double(p.dashOffset());
    }
    return s;
}
Example #30
0
void plotBoxesToPainter(QPainter& painter,
			const Numpy1DObj& x1, const Numpy1DObj& y1,
			const Numpy1DObj& x2, const Numpy1DObj& y2,
			const QRectF* clip, bool autoexpand)
{
  // if autoexpand, expand rectangle by line width
  QRectF clipcopy(QPointF(-32767,-32767), QPointF(32767,32767));
  if ( clip != 0 && autoexpand )
    {
      const qreal lw = painter.pen().widthF();
      qreal x1, y1, x2, y2;
      clip->getCoords(&x1, &y1, &x2, &y2);
      clipcopy.setCoords(x1, y1, x2, y2);
      clipcopy.adjust(-lw, -lw, lw, lw);
    }

  const int maxsize = min(x1.dim, x2.dim, y1.dim, y2.dim);

  QVector<QRectF> rects;
  for(int i = 0; i < maxsize; ++i)
    {
      QPointF pt1(x1(i), y1(i));
      QPointF pt2(x2(i), y2(i));
      const QRectF rect(pt1, pt2);

      if( clipcopy.intersects(rect) )
	{
	  rects << clipcopy.intersected(rect);
	}
    }

  if( ! rects.isEmpty() )
    painter.drawRects(rects);
}