Ejemplo n.º 1
0
void QgsGrassEdit::eraseElement( int line )
{
  QgsDebugMsg( QString( "line = %1" ).arg( line ) );

  int type = mProvider->readLine( NULL, NULL, line );
  if ( type < 0 )
    return;

  // Erase line
  displayElement( line, mSymb[SYMB_BACKGROUND], mSize );

  // Erase nodes
  if ( type & GV_LINES )
  {
    int node1, node2;
    mProvider->lineNodes( line, &node1, &node2 );

    double x, y;
    mProvider->nodeCoor( node1, &x, &y );
    displayIcon( x, y, mSymb[SYMB_BACKGROUND], QgsVertexMarker::ICON_X, mSize );

    mProvider->nodeCoor( node2, &x, &y );
    displayIcon( x, y, mSymb[SYMB_BACKGROUND], QgsVertexMarker::ICON_X, mSize );
  }
}
Ejemplo n.º 2
0
Archivo: lib02.c Proyecto: Josephkzez/c
void displayElements(fifolifo **e) {

	fifolifo *aux;
	char c;
	
	if (isEmpty(*e))
		printf("empty FIFO\n");
		
	else {

		initialize(&aux);
		
		while (!isEmpty(*e)) {
		
			printf("ELEMENT: %c\n", displayElement(*e));
			insertFIFO(&aux, removeElement(e));
			
		}
		
		while (!isEmpty(aux))
			insertFIFO(e, removeElement(&aux));

	}

}
Ejemplo n.º 3
0
void Tree::displaySample(int idSf2, int index, bool repercute)
{
    // Affichage de l'échantillon
    EltID idSmpl(elementSmpl, idSf2, index, -1, -1);
    displayElement(idSmpl);

    // Affichage des instruments utilisant le sample
    if (repercute)
    {
        EltID idInst = idSmpl;
        idInst.typeElement = elementInst;
        EltID idInstSmpl = idSmpl;
        idInstSmpl.typeElement = elementInstSmpl;
        int nbInst = _sf2->count(idInst);
        for (int i = 0; i < nbInst; i++)
        {
            idInst.indexElt = i;
            idInstSmpl.indexElt = i;
            if (!_sf2->get(idInst, champ_hidden).bValue)
            {
                int nbInstSmpl = _sf2->count(idInstSmpl);
                for (int j = 0; j < nbInstSmpl; j++)
                {
                    idInstSmpl.indexElt2 = j;
                    if (!_sf2->get(idInstSmpl, champ_hidden).bValue)
                    {
                        if (_sf2->get(idInstSmpl, champ_sampleID).wValue == index)
                            displayInstrument(idSf2, i, false, true);
                    }
                }
            }
        }
    }
}
Ejemplo n.º 4
0
void QgsGrassEdit::displayMap()
{
  QgsDebugMsg( "entered." );

  mTransform = mCanvas->getCoordinateTransform();

  // re-create pixmap - it's transparent by default
  *mPixmap = QPixmap( mCanvas->size() );
  mPixmap->fill( QColor( 0, 0, 0, 0 ) );

  QPainter *painter = new QPainter();
  painter->begin( mPixmap );

  // Display lines
  int nlines = mProvider->numLines();

  QPen pen;

  // TODO?: 2 loops, first lines, then points
  for ( int line = 1; line <= nlines; line++ )
  {
    displayElement( line, mSymb[mLineSymb[line]], mSize, painter );
  }

  // Display nodes
  int nnodes = mProvider->numNodes();

  pen.setColor( QColor( 255, 0, 0 ) );

  if ( mSymbDisplay[SYMB_NODE_1] || mSymbDisplay[SYMB_NODE_2] )
  {
    for ( int node = 1; node <= nnodes; node++ )
    {
      if ( mNodeSymb[node] == SYMB_NODE_0 )
        continue; // do not display nodes with points only
      displayNode( node, mSymb[mNodeSymb[node]], mSize, painter );
    }
  }

  painter->end();
  delete painter;

  // porting mCanvas->update();
  mCanvasEdit->update();
  mRubberBandIcon->update();
  mRubberBandLine->update();
}
Ejemplo n.º 5
0
void Tree::displayInstrument(int idSf2, int index, bool repercuteSmpl, bool repercutePrst)
{
    EltID idInst(elementInst, idSf2, index, -1, -1);
    displayElement(idInst);

    // Affichage des samples
    if (repercuteSmpl)
    {
        EltID idInstSmpl = idInst;
        idInstSmpl.typeElement = elementInstSmpl;
        int nbElement = _sf2->count(idInstSmpl);
        for (int i = 0; i < nbElement; i++)
        {
            idInstSmpl.indexElt2 = i;
            if (!_sf2->get(idInstSmpl, champ_hidden).bValue)
                displaySample(idSf2, _sf2->get(idInstSmpl, champ_sampleID).wValue, false);
        }
    }

    // Affichage des presets utilisant l'instrument
    if (repercutePrst)
    {
        EltID idPrst = idInst;
        idPrst.typeElement = elementPrst;
        EltID idPrstInst = idInst;
        idPrstInst.typeElement = elementPrstInst;
        int nbPrst = _sf2->count(idPrst);
        for (int i = 0; i < nbPrst; i++)
        {
            idPrst.indexElt = i;
            idPrstInst.indexElt = i;
            if (!_sf2->get(idPrst, champ_hidden).bValue)
            {
                int nbPrstInst = _sf2->count(idPrstInst);
                for (int j = 0; j < nbPrstInst; j++)
                {
                    idPrstInst.indexElt2 = j;
                    if (!_sf2->get(idPrstInst, champ_hidden).bValue)
                    {
                        if (_sf2->get(idPrstInst, champ_instrument).wValue == index)
                            displayPreset(idSf2, i, false);
                    }
                }
            }
        }
    }
}
Ejemplo n.º 6
0
void QgsGrassEdit::postRender( QPainter * )
{
  QgsDebugMsg( "entered." );

  // Warning: it seems that this slot can be called even
  //          after disconnect (is it a queue?)
  //          -> check mValid

  if ( !mValid )
    return;

  displayMap();

  // Redisplay highlighted
  if ( mSelectedLine )
  {
    displayElement( mSelectedLine, mSymb[SYMB_HIGHLIGHT], mSize );
  }
}
Ejemplo n.º 7
0
void Tree::displayPreset(int idSf2, int index, bool repercute)
{
    EltID idPrst(elementPrst, idSf2, index, -1, -1);
    displayElement(idPrst);

    // Affichage des instruments
    if (repercute)
    {
        EltID idPrstInst = idPrst;
        idPrstInst.typeElement = elementPrstInst;
        int nbElement = _sf2->count(idPrstInst);
        for (int i = 0; i < nbElement; i++)
        {
            idPrstInst.indexElt2 = i;
            if (!_sf2->get(idPrstInst, champ_hidden).bValue)
                displayInstrument(idSf2, _sf2->get(idPrstInst, champ_instrument).wValue, true, false);
        }
    }
}
Ejemplo n.º 8
0
void QgsGrassEdit::displayUpdated( void )
{
  QgsDebugMsg( "entered." );

  mTransform = mCanvas->getCoordinateTransform();
  mProjectionEnabled = ( QgsProject::instance()->readNumEntry( "SpatialRefSys", "/ProjectionsEnabled", 0 ) != 0 );

  QPainter *painter = new QPainter();
  painter->begin( mPixmap );

  // Display lines
  int nlines = mProvider->numUpdatedLines();

  for ( int i = 0; i < nlines; i++ )
  {
    int line = mProvider->updatedLine( i );
    if ( !( mProvider->lineAlive( line ) ) )
      continue;

    displayElement( line, mSymb[mLineSymb[line]], mSize, painter );
  }

  // Display nodes
  int nnodes = mProvider->numUpdatedNodes();
  for ( int i = 0; i < nnodes; i++ )
  {
    int node = mProvider->updatedNode( i );
    if ( !( mProvider->nodeAlive( node ) ) )
      continue;
    if ( mNodeSymb[node] == SYMB_NODE_0 )
      continue; // do not display nodes with points only
    displayNode( node, mSymb[mNodeSymb[node]], mSize, painter );
  }

  painter->end();
  delete painter;

  // porting mCanvas->update();
  mCanvasEdit->update();
  mRubberBandIcon->update();
  mRubberBandLine->update();
}
Ejemplo n.º 9
0
void QgsGrassEdit::startTool( int tool )
{
  QgsDebugMsg( QString( "tool = %1" ).arg( tool ) );

  // Delete last dynamic drawing from canvas
  eraseDynamic();
  if ( mSelectedLine > 0 )
    displayElement( mSelectedLine, mSymb[mLineSymb[mSelectedLine]], mSize );

  // close old tool
  if ( mMapTool )
  {
    delete mMapTool;
    mMapTool = NULL;
  }

  // All necessary data were written -> reset mEditPoints etc.
  Vect_reset_line( mEditPoints );
  mSelectedLine = 0;

  // TODO: mTool != NEW_LINE is a hack for lines until more buttons can be received
  if ( mAttributes && mTool != QgsGrassEdit::NEW_LINE && mTool != QgsGrassEdit::NEW_BOUNDARY )
  {
    delete mAttributes;
    mAttributes = 0;
  }

  // Start new tool
  mTool = tool;

  switch ( mTool )
  {
    case NEW_POINT:
      mMapTool = new QgsGrassEditNewPoint( this, false );
      mMapTool->setAction( mNewPointAction );
      break;

    case NEW_CENTROID:
      mMapTool = new QgsGrassEditNewPoint( this, true );
      mMapTool->setAction( mNewCentroidAction );
      break;

    case NEW_LINE:
      mMapTool = new QgsGrassEditNewLine( this, false );
      mMapTool->setAction( mNewLineAction );
      break;

    case NEW_BOUNDARY:
      mMapTool = new QgsGrassEditNewLine( this, true );
      mMapTool->setAction( mNewBoundaryAction );
      break;

    case MOVE_VERTEX:
      mMapTool = new QgsGrassEditMoveVertex( this );
      mMapTool->setAction( mMoveVertexAction );
      break;

    case ADD_VERTEX:
      mMapTool = new QgsGrassEditAddVertex( this );
      mMapTool->setAction( mAddVertexAction );
      break;

    case DELETE_VERTEX:
      mMapTool = new QgsGrassEditDeleteVertex( this );
      mMapTool->setAction( mDeleteVertexAction );
      break;

    case MOVE_LINE:
      mMapTool = new QgsGrassEditMoveLine( this );
      mMapTool->setAction( mMoveLineAction );
      break;

    case DELETE_LINE:
      mMapTool = new QgsGrassEditDeleteLine( this );
      mMapTool->setAction( mDeleteLineAction );
      break;

    case SPLIT_LINE:
      mMapTool = new QgsGrassEditSplitLine( this );
      mMapTool->setAction( mSplitLineAction );
      break;

    case EDIT_ATTRIBUTES:
      mMapTool = new QgsGrassEditAttributes( this );
      mMapTool->setAction( mEditAttributesAction );
      break;

    case EDIT_CATS:
      mTool = NONE;
      QMessageBox::warning( 0, tr( "Warning" ), tr( "Tool not yet implemented." ) );
      break;

    default:
      QgsDebugMsg( "Unknown tool" );
      break;
  }

  // assign newly created tool to map canvas
  mCanvas->setMapTool( mMapTool );
}