예제 #1
0
void savePlacemarks( QDataStream &out, const GeoDataContainer *container, MarbleClock* clock )
{
    qreal lon;
    qreal lat;
    qreal alt;

    const QVector<GeoDataPlacemark*> placemarks = container->placemarkList();
    QVector<GeoDataPlacemark*>::const_iterator it = placemarks.constBegin();
    QVector<GeoDataPlacemark*>::const_iterator const end = placemarks.constEnd();
    for (; it != end; ++it ) {
        out << (*it)->name();
        (*it)->coordinate().geoCoordinates( lon, lat, alt );

        // Use double to provide a single cache file format across architectures
        out << (double)(lon) << (double)(lat) << (double)(alt);
        out << QString( (*it)->role() );
        out << QString( (*it)->description() );
        out << QString( (*it)->countryCode() );
        out << QString( (*it)->state() );
        out << (double) (*it)->area();
        out << (qint64) (*it)->population();
        out << ( qint16 ) ( (*it)->extendedData().value("gmt").value().toInt() );
        out << ( qint8 ) ( (*it)->extendedData().value("dst").value().toInt() );
    }

    const QVector<GeoDataFolder*> folders = container->folderList();
    QVector<GeoDataFolder*>::const_iterator cont = folders.constBegin();
    QVector<GeoDataFolder*>::const_iterator endcont = folders.constEnd();
    for (; cont != endcont; ++cont ) {
            savePlacemarks( out, *cont, clock );
    }
}
예제 #2
0
void QgsDxfExport::writeLinestyle( const QString& styleName, const QVector<qreal>& pattern, QgsSymbolV2::OutputUnit u )
{
  double length = 0;
  QVector<qreal>::const_iterator dashIt = pattern.constBegin();
  for ( ; dashIt != pattern.constEnd(); ++dashIt )
  {
    length += ( *dashIt * mapUnitScaleFactor( mSymbologyScaleDenominator, u, mMapUnits ) );
  }

  writeGroup( 0, "LTYPE" );
  writeGroup( 2, styleName );
  writeGroup( 70, 64 );
  writeGroup( 3, "" );
  writeGroup( 72, 65 );
  writeGroup( 73, pattern.size() );
  writeGroup( 40, length );

  dashIt = pattern.constBegin();
  bool isSpace = false;
  for ( ; dashIt != pattern.constEnd(); ++dashIt )
  {
    //map units or mm?
    double segmentLength = ( isSpace ? -*dashIt : *dashIt );
    segmentLength *= mapUnitScaleFactor( mSymbologyScaleDenominator, u, mMapUnits );
    writeGroup( 49, segmentLength );
    isSpace = !isSpace;
  }
}
예제 #3
0
QDomElement QgsWFSServer::createCoordinateElem( const QVector<QgsPoint> points, QDomDocument& doc ) const
{
  QDomElement coordElem = doc.createElement( "gml:coordinates" );
  coordElem.setAttribute( "cs", "," );
  coordElem.setAttribute( "ts", " " );

  //precision 4 for meters / feet, precision 8 for degrees
  int precision = 8;
  /*
  if ( mSourceCRS.mapUnits() == QGis::Meters
       || mSourceCRS.mapUnits() == QGis::Feet )
  {
    precision = 4;
  }
  */

  QString coordString;
  QVector<QgsPoint>::const_iterator pointIt = points.constBegin();
  for ( ; pointIt != points.constEnd(); ++pointIt )
  {
    if ( pointIt != points.constBegin() )
    {
      coordString += " ";
    }
    coordString += QString::number( pointIt->x(), 'f', precision );
    coordString += ",";
    coordString += QString::number( pointIt->y(), 'f', precision );
  }

  QDomText coordText = doc.createTextNode( coordString );
  coordElem.appendChild( coordText );
  return coordElem;
}
예제 #4
0
inline void printHistogram(int width, int height,
                           const QVector<int> &histogram,
                           const QVector<int> &thresholds=QVector<int>())
{
    // Create the graph.
    QString graph((width + 1) * height, ' ');

    // Split each line.
    for (int y = 0; y < height; y++)
        graph[width + y * (width + 1)] = '\n';

    int maxValue = *std::max_element(histogram.constBegin(), histogram.constEnd());

    // Draw values.
    for (int x = 0; x < width; x++) {
        int h = (height - 1)
                * histogram[(histogram.size() - 1) * x / (width - 1)]
                / maxValue;

        for (int y = height - 1; y >= (height - h - 1); y--)
            graph[x + y * (width + 1)] = '*';
    }

    // Draw the trhesholds.
    foreach (int x, thresholds) {
        int w = (width - 1) * x / (histogram.size() - 1);

        for (int y = 0; y < height; y++)
            graph[w + y * (width + 1)] = '|';
    }
예제 #5
0
bool QgsVectorLayerEditUtils::boundingBoxFromPointList( const QVector<QgsPointXY> &list, double &xmin, double &ymin, double &xmax, double &ymax ) const
{
  if ( list.empty() )
  {
    return false;
  }

  xmin = std::numeric_limits<double>::max();
  xmax = -std::numeric_limits<double>::max();
  ymin = std::numeric_limits<double>::max();
  ymax = -std::numeric_limits<double>::max();

  for ( QVector<QgsPointXY>::const_iterator it = list.constBegin(); it != list.constEnd(); ++it )
  {
    if ( it->x() < xmin )
    {
      xmin = it->x();
    }
    if ( it->x() > xmax )
    {
      xmax = it->x();
    }
    if ( it->y() < ymin )
    {
      ymin = it->y();
    }
    if ( it->y() > ymax )
    {
      ymax = it->y();
    }
  }

  return true;
}
예제 #6
0
bool clipByRect( QLineF& line, const QPolygonF& rect )
{
  QVector<QLineF> borderLines;
  borderLines << QLineF( rect.at( 0 ), rect.at( 1 ) );
  borderLines << QLineF( rect.at( 1 ), rect.at( 2 ) );
  borderLines << QLineF( rect.at( 2 ), rect.at( 3 ) );
  borderLines << QLineF( rect.at( 3 ), rect.at( 0 ) );

  QVector<QPointF> intersectionList;
  QVector<QLineF>::const_iterator it = borderLines.constBegin();
  for ( ; it != borderLines.constEnd(); ++it )
  {
    QPointF intersectionPoint;
    if ( it->intersect( line, &intersectionPoint ) == QLineF::BoundedIntersection )
    {
      intersectionList.push_back( intersectionPoint );
      if ( intersectionList.size() >= 2 )
      {
        break; //we already have two intersections, skip further tests
      }
    }
  }
  if ( intersectionList.size() < 2 ) return false; // no intersection

  line = QLineF( intersectionList.at( 0 ), intersectionList.at( 1 ) );
  return true;
}
예제 #7
0
void BenchSuite::probe_objectAdded()
{
  Probe::createProbe(false);

  static const int NUM_OBJECTS = 10000;
  QVector<QObject*> objects;
  objects.reserve(NUM_OBJECTS + 1);
  // fill it
  for(int i = 0; i < NUM_OBJECTS; ++i) {
    QObject *obj = new QObject;
    objects << obj;
  }

  QVector<QObject*>::const_iterator it = objects.constBegin();
  QVector<QObject*>::const_iterator end = objects.constEnd();
  QBENCHMARK_ONCE {
    while (it != end) {
      Probe::objectAdded(*it);
      ++it;
    }
  }

  qDeleteAll(objects);
  delete Probe::instance();
}
예제 #8
0
void MarbleLegendBrowser::initTheme()
{
    mDebug() << "initTheme";

    // Check for a theme specific legend.html first
    if ( d->m_marbleModel != 0 && d->m_marbleModel->mapTheme() != 0 )
    {
        GeoSceneDocument *currentMapTheme = d->m_marbleModel->mapTheme();

        QVector<GeoSceneProperty*> allProperties = currentMapTheme->settings()->allProperties();

        d->m_checkBoxMap.clear();

        QVector<GeoSceneProperty*>::const_iterator it = allProperties.constBegin();
        QVector<GeoSceneProperty*>::const_iterator const end = allProperties.constEnd();
        for (; it != end; ++it ) {
            if ( (*it)->available() ) {
                d->m_checkBoxMap[ (*it)->name() ] = (*it)->value();
            }
        }

        disconnect ( currentMapTheme, SIGNAL( valueChanged( QString, bool ) ), 0, 0 );
        connect ( currentMapTheme, SIGNAL( valueChanged( QString, bool ) ),
                  this, SLOT( setCheckedProperty( QString, bool ) ) );
    }
예제 #9
0
bool ZipDirIteratorPrivate::matchesFilters(const QString &fileName, CentralDirFileHeader* header ) const
{
    Q_ASSERT(!fileName.isEmpty());

    // Pass all entries through name filters
    if ( !nameFilters.isEmpty() )
    {
        bool matched = false;
        for (QVector<QRegExp>::const_iterator iter = nameRegExps.constBegin(), end = nameRegExps.constEnd(); iter != end; ++iter)
        {
            QRegExp copy = *iter;
            if (copy.exactMatch(fileName))
            {
                matched = true;
                break;
            }
        }
        if (!matched)
            return false;
    }

    // skip directories
    if ( (options & AbZip::IgnoreFolders) && header->isDirectory())
        return false;

    // skip files
    if ( (options & AbZip::IgnoreFiles) && !header->isDirectory())
        return false;

    return true;
}
예제 #10
0
//------------------------------------------------------------------------------
void CModel::computeNormals(QVector<SVertex> &vertices, const QVector<SFace> &faces)
{
  for(int32 v = 0; v < vertices.size(); v++)
  {
    /*if(!(v % 10000))
      qDebug(QString("%1").arg(v).toStdString().c_str());*/
    vertices[v].normal = QVector3D(0.0, 1.0, 0.0);
    uint32 found = 0;

    for(auto f = faces.constBegin(); f != faces.constEnd(); f++)
    {
      if(f->contains(v))
      {
        QVector3D n = QVector3D::normal(vertices[f->vertex0].position, vertices[f->vertex1].position, vertices[f->vertex2].position);
        if(!found)
          vertices[v].normal = n;
        else
          vertices[v].normal += n;
        found++;
      }
    }

    vertices[v].normal.normalize();
  }
}
void QuickSceneGraphModel::populateFromNode(QSGNode *node, bool emitSignals)
{
  if (!node) {
    return;
  }

  QVector<QSGNode*> &childList  = m_parentChildMap[node];
  QVector<QSGNode*> newChildList;

  newChildList.reserve(node->childCount());
  for (QSGNode *childNode = node->firstChild(); childNode; childNode = childNode->nextSibling()) {
    newChildList.append(childNode);
  }

  QModelIndex myIndex; // don't call indexForNode(node) here yet, in the common case of few changes we waste a lot of time here
  bool hasMyIndex = false;

  std::sort(newChildList.begin(), newChildList.end());

  QVector<QSGNode*>::iterator i = childList.begin();
  QVector<QSGNode*>::const_iterator j = newChildList.constBegin();

  while (i != childList.end() && j != newChildList.constEnd()) {
    if (*i < *j) { // handle deleted node
      emit nodeDeleted(*i);
      GET_INDEX
      if (emitSignals) {
        const auto idx = std::distance(childList.begin(), i);
        beginRemoveRows(myIndex, idx, idx);
      }
      pruneSubTree(*i);
      i = childList.erase(i);
      if (emitSignals)
        endRemoveRows();
    } else if (*i > *j) { // handle added node
예제 #12
0
void QuickSceneGraphModel::populateFromNode(QSGNode *node)
{
  if (!node)
    return;

  QVector<QSGNode*> &childList  = m_parentChildMap[node];
  QVector<QSGNode*> &oldChildList  = m_oldParentChildMap[node];
  QVector<QSGNode*> newChildList;

  for (int i = 0; i < node->childCount(); i++) {
    QSGNode *childNode = node->childAtIndex(i);

    newChildList.append(childNode);
  }

  QModelIndex myIndex = indexForNode(node);

  std::sort(newChildList.begin(), newChildList.end());

  QVector<QSGNode*>::iterator i = oldChildList.begin();
  QVector<QSGNode*>::const_iterator j = newChildList.constBegin();

  while (i != oldChildList.end() && j != newChildList.constEnd()) {
    if (*i < *j) { // We don't have to do anything but inform the client about the change
      beginRemoveRows(myIndex, childList.size(), childList.size());
      endRemoveRows();
      emit nodeDeleted(*i);
      i++;
    } else if (*i > *j) { // Add to new list and inform the client about the change
      beginInsertRows(myIndex, childList.size(), childList.size());
      m_childParentMap.insert(*j, node);
      childList.append(*j);
      endInsertRows();
      populateFromNode(*j);
      j++;
    } else { // Adopt to new list, without informing the client (as nothing really changed)
      m_childParentMap.insert(*j, node);
      childList.append(*j);
      populateFromNode(*j);
      j++;
      i++;
    }
  }
  if (i == oldChildList.end() && j != newChildList.constEnd()) { // Add remaining new items to list and inform the client
    beginInsertRows(myIndex, childList.size(), childList.size() + std::distance(j, newChildList.constEnd()) - 1);
    for (;j != newChildList.constEnd(); j++) {
      m_childParentMap.insert(*j, node);
      childList.append(*j);
      populateFromNode(*j);
    }
    endInsertRows();
  } else if (i != oldChildList.end()) { // Inform the client about the removed rows
    beginRemoveRows(myIndex, childList.size(), childList.size() + std::distance(i, oldChildList.end()) - 1);
    endRemoveRows();
    for (; i != oldChildList.end(); i++)
      emit nodeDeleted(*i);
  }
}
예제 #13
0
void SectorHistogram::construct( const Billon &billon, const Interval<uint> &sliceInterval, const Interval<int> &intensity,
								 const uint &zMotionMin, const int &radiusAroundPith )
{
	clear();

	if ( billon.hasPith() && sliceInterval.isValid() && sliceInterval.width() > 0 )
	{
		const int &width = billon.n_cols;
		const int &height = billon.n_rows;
		const qreal squareRadius = qPow(radiusAroundPith,2);

		fill(0.,PieChartSingleton::getInstance()->nbSectors());

		QVector<int> circleLines;
		circleLines.reserve(2*radiusAroundPith+1);
		for ( int lineIndex=-radiusAroundPith ; lineIndex<=radiusAroundPith ; ++lineIndex )
		{
			circleLines.append(qSqrt(squareRadius-qPow(lineIndex,2)));
		}

		QVector<int>::ConstIterator circlesLinesIterator;
		int iRadius;
		uint diff;
		iCoord2D currentPos;

		// Calcul du diagramme en parcourant les tranches du billon comprises dans l'intervalle
		for ( uint k=sliceInterval.min() ; k<=sliceInterval.max() ; ++k )
		{
			const Slice &currentSlice = billon.slice(k);
			const Slice &previousSlice = billon.previousSlice(k);
			const iCoord2D &currentPithCoord = billon.pithCoord(k);
			currentPos.y = currentPithCoord.y-radiusAroundPith;
			for ( circlesLinesIterator = circleLines.constBegin() ; circlesLinesIterator != circleLines.constEnd() ; ++circlesLinesIterator )
			{
				iRadius = *circlesLinesIterator;
				currentPos.x = currentPithCoord.x-iRadius;
				iRadius += currentPithCoord.x;
				while ( currentPos.x <= iRadius )
				{
					if ( currentPos.x < width && currentPos.y < height && intensity.containsOpen(currentSlice.at(currentPos.y,currentPos.x)) &&
						 intensity.containsOpen(previousSlice.at(currentPos.y,currentPos.x)) )
					{
						diff = billon.zMotion(currentPos.x,currentPos.y,k);
						//if ( motionInterval.containsClosed(diff) )
						if ( diff >= zMotionMin )
						{
							(*this)[PieChartSingleton::getInstance()->sectorIndexOfAngle( currentPithCoord.angle(currentPos) )] += diff-zMotionMin;
						}
					}
					currentPos.x++;
				}
				currentPos.y++;
			}
		}
	}
}
예제 #14
0
ThumbnailWidget* ThumbnailListPrivate::itemFor( const QPoint & p ) const
{
    QVector< ThumbnailWidget * >::const_iterator tIt = m_thumbnails.constBegin(), tEnd = m_thumbnails.constEnd();
    for ( ; tIt != tEnd; ++tIt )
    {
        if ( (*tIt)->rect().contains( p ) )
            return (*tIt);
    }
    return 0;
}
예제 #15
0
double QgsCompoundCurve::segmentLength( QgsVertexId startVertex ) const
{
  QVector< QPair<int, QgsVertexId> > curveIds = curveVertexId( startVertex );
  double length = 0.0;
  for ( auto it = curveIds.constBegin(); it != curveIds.constEnd(); ++it )
  {
    length += mCurves.at( it->first )->segmentLength( it->second );
  }
  return length;
}
예제 #16
0
ThumbnailWidget* ThumbnailListPrivate::getPageByNumber( int page ) const
{
    QVector< ThumbnailWidget * >::const_iterator tIt = m_thumbnails.constBegin(), tEnd = m_thumbnails.constEnd();
    for ( ; tIt != tEnd; ++tIt )
    {
        if ( (*tIt)->pageNumber() == page )
            return (*tIt);
    }
    return 0;
}
예제 #17
0
void QgsDxfExport::writeLinestyleAC1018( QTextStream& stream, const QString& styleName, const QVector<qreal>& pattern, QgsSymbolV2::OutputUnit u )
{
  double length = 0;
  QVector<qreal>::const_iterator dashIt = pattern.constBegin();
  for ( ; dashIt != pattern.constEnd(); ++dashIt )
  {
    length += *dashIt;
  }

  stream << "  0\n";
  stream << "LTYPE\n";
  stream << "  5\n";
  stream << QString( "%1\n" ).arg( mNextHandleId++ );
  stream << "100\n";
  stream << "AcDbSymbolTableRecord\n";
  stream << "100\n";
  stream << "AcDbLinetypeTableRecord\n";
  stream << "  2\n";
  stream << QString( "%1\n" ).arg( styleName );
  stream << "  70\n";
  stream << "64\n";
  stream << "  3\n";
  stream << "\n";
  stream << " 72\n";
  stream << "65\n";
  stream << " 73\n";
  stream << QString( "%1\n" ).arg( pattern.size() ); //number of segments
  stream << " 40\n"; //total length of segments
  stream << QString( "%1\n" ).arg( length );

  dashIt = pattern.constBegin();
  bool isSpace = false;
  for ( ; dashIt != pattern.constEnd(); ++dashIt )
  {
    stream << " 49\n";

    //map units or mm?
    double segmentLength = ( isSpace ? -*dashIt : *dashIt );
    segmentLength *= mapUnitScaleFactor( mSymbologyScaleDenominator, u, mMapUnits );
    stream << QString( "%1\n" ).arg( segmentLength );
    isSpace = !isSpace;
  }
}
예제 #18
0
파일: client.cpp 프로젝트: suy/GammaRay
void Client::messageReceived(const Message& msg)
{
  // server version must be the very first message we get
  if (!m_versionChecked) {
    if (msg.address() != endpointAddress() || msg.type() != Protocol::ServerVersion) {
      qCritical() << "Protocol violation - first message is not the server version.";
      exit(1);
    }
    qint32 serverVersion;
    msg.payload() >> serverVersion;
    if (serverVersion != Protocol::version()) {
      qCritical() << "Server version is" << serverVersion << ", was expecting" << Protocol::version() << " - aborting";
      exit(1);
    }
    m_versionChecked = true;
    emit connectionEstablished();
    return;
  }

  if (msg.address() == endpointAddress()) {
    switch (msg.type()) {
      case Protocol::ObjectAdded:
      {
        QString name;
        Protocol::ObjectAddress addr;
        msg.payload() >> name >> addr;
        qDebug() << Q_FUNC_INFO << "ObjectAdded" << name << addr;
        registerObjectInternal(name, addr);
        break;
      }
      case Protocol::ObjectRemoved:
      {
        QString name;
        msg.payload() >> name;
        unregisterObjectInternal(name);
        break;
      }
      case Protocol::ObjectMapReply:
      {
        QVector<QPair<Protocol::ObjectAddress, QString> > objects;
        msg.payload() >> objects;
        for (QVector<QPair<Protocol::ObjectAddress, QString> >::const_iterator it = objects.constBegin(); it != objects.constEnd(); ++it) {
          if (it->first != endpointAddress())
            registerObjectInternal(it->second, it->first);
        }
        qDebug() << Q_FUNC_INFO << "ObjectMapReply" << objectAddresses();
      }
      default:
        qDebug() << Q_FUNC_INFO << "Got unhandled message:" << msg.type();
        return;
    }
  }

  dispatchMessage(msg);
}
예제 #19
0
void DiffHighlighter::setFormats(const QVector<QTextCharFormat> &s)
{
    if (s.size() == Internal::NumDiffFormats) {
        qCopy(s.constBegin(), s.constEnd(), m_d->m_formats);
        // Display trailing blanks with colors swapped
        m_d->m_addedTrailingWhiteSpaceFormat =
                invertedColorFormat(m_d->m_formats[Internal::DiffInFormat]);
    } else {
        qWarning("%s: insufficient setting size: %d", Q_FUNC_INFO, s.size());
    }
}
예제 #20
0
파일: icon.cpp 프로젝트: acacid/qt-creator
static QPixmap combinedPlainPixmaps(const QVector<IconMaskAndColor> &images)
{
    QPixmap result(StyleHelper::dpiSpecificImageFile(images.first().first));
    auto pixmap = images.constBegin();
    pixmap++;
    for (;pixmap != images.constEnd(); ++pixmap) {
        const QPixmap overlay(StyleHelper::dpiSpecificImageFile((*pixmap).first));
        result.paintEngine()->painter()->drawPixmap(0, 0, overlay);
    }
    return result;
}
예제 #21
0
void StackedTileLoader::downloadTile( TileId const & stackedTileId )
{
    QVector<GeoSceneTexture const *> const textureLayers = d->findRelevantTextureLayers( stackedTileId );
    QVector<GeoSceneTexture const *>::const_iterator pos = textureLayers.constBegin();
    QVector<GeoSceneTexture const *>::const_iterator const end = textureLayers.constEnd();
    for (; pos != end; ++pos ) {
        GeoSceneTexture const * const textureLayer = *pos;
        TileId const tileId( textureLayer->sourceDir(), stackedTileId.zoomLevel(),
                             stackedTileId.x(), stackedTileId.y() );
        d->m_tileLoader->downloadTile( tileId );
    }
}
예제 #22
0
bool TextProcessingMachine::doProcessCharacter( QString::const_iterator character, State<CharTransitionInterface> *state )
{
  const QVector<Transition*> transitions = state->transitions();
  QVector<Transition*>::const_iterator it = transitions.constBegin();
  const QVector<Transition*>::const_iterator end = transitions.constEnd();
  for ( ; it != end; ++it ) {
    if ( ( *it )->characterTest( character ) ) {
      executeTransition( state, *it );
      return true;
    }
  }
  return false;
}
예제 #23
0
int findMatchingRule(const QVector<Rule>& rules, const QString& source, const QString& target,
                    QVector<StartLen>& positions)
{
    for(QVector<Rule>::const_iterator it=rules.constBegin();it!=rules.constEnd();it++)
    {
        if (it->sources.first().indexIn(source)!=-1)
        {
            if (it->falseFriends.first().indexIn(target)!=-1)
            {
                if (positions.size())
                {
                    positions[0].start=it->sources.first().pos();
                    positions[0].len=it->sources.first().matchedLength();
                    positions[1].start=it->falseFriends.first().pos();
                    positions[1].len=it->falseFriends.first().matchedLength();
                }
                return it-rules.constBegin();
            }
        }
    }
    return -1;
}
예제 #24
0
std::unique_ptr<QgsMultiPolygon> QgsTessellator::asMultiPolygon() const
{
  std::unique_ptr< QgsMultiPolygon > mp = qgis::make_unique< QgsMultiPolygon >();
  const QVector<float> data = mData;
  for ( auto it = data.constBegin(); it != data.constEnd(); )
  {
    QgsPoint p1 = getPointFromData( it );
    QgsPoint p2 = getPointFromData( it );
    QgsPoint p3 = getPointFromData( it );
    mp->addGeometry( new QgsTriangle( p1, p2, p3 ) );
  }
  return mp;
}
예제 #25
0
void RoutingInputWidgetPrivate::createBookmarkActions( QMenu* menu, GeoDataFolder* bookmarksFolder, QObject *parent )
{
    QVector<GeoDataPlacemark*> bookmarks = bookmarksFolder->placemarkList();
    QVector<GeoDataPlacemark*>::const_iterator i = bookmarks.constBegin();
    QVector<GeoDataPlacemark*>::const_iterator end = bookmarks.constEnd();

    for (; i != end; ++i ) {
        QAction *bookmarkAction = new QAction( (*i)->name(), parent );
        bookmarkAction->setData( qVariantFromValue( (*i)->coordinate() ) );
        menu->addAction( bookmarkAction );
        QObject::connect( menu, SIGNAL(triggered(QAction*)), parent, SLOT(setBookmarkPosition(QAction*)) );
    }
}
예제 #26
0
/*!
  Draw the shape in response to an update event.
  */
void QgsRubberBand::paint( QPainter* p )
{
  QList<QgsPoint> currentList;
  if ( mPoints.size() > 0 )
  {
    p->setBrush( mBrush );

    for ( int i = 0; i < mPoints.size(); ++i )
    {
      QVector<QPointF> pts;
      QList<QgsPoint>::const_iterator it = mPoints.at( i ).constBegin();
      for ( ; it != mPoints.at( i ).constEnd(); ++it )
      {
        pts.append( toCanvasCoordinates( QgsPoint( it->x() + mTranslationOffsetX, it->y() + mTranslationOffsetY ) ) - pos() );
      }

      switch ( mGeometryType )
      {
        case QGis::Polygon:
        {
          mPen.setWidth( mWidth );
          p->setPen( mPen );
          p->drawPolygon( pts );
        }
        break;

        case QGis::Point:
        {
          mPen.setWidth( 1 );
          p->setPen( mPen );
          QVector<QPointF>::const_iterator ptIt = pts.constBegin();
          for ( ; ptIt != pts.constEnd(); ++ptIt )
          {
            p->drawEllipse(( *ptIt ).x() - mWidth / 2, ( *ptIt ).y() - mWidth / 2, mWidth, mWidth );
          }
        }
        break;

        case QGis::Line:
        default:
        {
          mPen.setWidth( mWidth );
          p->setPen( mPen );
          p->drawPolyline( pts );
        }
        break;
      }
    }
  }
}
예제 #27
0
void TraceLoader::findCallIndex(int index)
{
    int frameIdx = callInFrame(index);
    ApiTraceFrame *frame = m_createdFrames[frameIdx];
    QVector<ApiTraceCall*> calls = fetchFrameContents(frame);
    QVector<ApiTraceCall*>::const_iterator itr;
    ApiTraceCall *call = 0;
    for (itr = calls.constBegin(); itr != calls.constEnd(); ++itr) {
        if ((*itr)->index() == index) {
            call = *itr;
        }
    }
    Q_ASSERT(call);
    emit foundCallIndex(call);
}
예제 #28
0
int ReqMsgUnsubscribe::SendRequest(const QVector<Subscriber>& vecSubscriber)
{
	QJsonObject json;

	QJsonObject jsonSub;

	for (QVector<Subscriber>::const_iterator citor = vecSubscriber.constBegin();
		citor != vecSubscriber.constEnd(); ++citor)
	{
		citor->Apply(jsonSub);
	}

	json.insert(szAttributeName[AN_SYMBOLLIST], jsonSub);

	return SendJson(json);
}
예제 #29
0
bool QgsCompoundCurve::moveVertex( QgsVertexId position, const QgsPoint &newPos )
{
  QVector< QPair<int, QgsVertexId> > curveIds = curveVertexId( position );
  QVector< QPair<int, QgsVertexId> >::const_iterator idIt = curveIds.constBegin();
  for ( ; idIt != curveIds.constEnd(); ++idIt )
  {
    mCurves.at( idIt->first )->moveVertex( idIt->second, newPos );
  }

  bool success = !curveIds.isEmpty();
  if ( success )
  {
    clearCache(); //bbox changed
  }
  return success;
}
예제 #30
0
void CylindricalProjectionPrivate::translatePolygons( const QVector<QPolygonF *> &polygons,
                                                      QVector<QPolygonF *> &translatedPolygons,
                                                      qreal xOffset )
{
    // mDebug() << "Translation: " << xOffset;

    QVector<QPolygonF *>::const_iterator itPolygon = polygons.constBegin();
    QVector<QPolygonF *>::const_iterator itEnd = polygons.constEnd();

    for( ; itPolygon != itEnd; ++itPolygon ) {
        QPolygonF * polygon = new QPolygonF;
        *polygon = **itPolygon;
        polygon->translate( xOffset, 0 );
        translatedPolygons.append( polygon );
    }
}