Exemple #1
0
// move:
void move(int order){
	if(order == BALL1);
	if(order == BALL2){
		findLine();
		turnLeftLine();
		moveLine();
	}
	if(order == BALL3){
		moveBack1();
		turnLeft();
	}
	if(order == BALL4){
		moveBack2();
		turnBack();
	}
	if(order == STORAGE1){
		turnBack();
		moveBack();
		turnLeft();
		}
	if(order == STORAGE2){
		findLine();
		turnRight();
	}
}
Exemple #2
0
void TextBuffer::backwardWord()
{
  // Emacs M-b word motion. search line by line scanning for next
  // word.
  String str;
  int pos, bol, len, loc;
  pos = point(); // pos is EXCLUSIVE upper bound
  bol = pointBOL();
  while (true)
    {
      len=pos-bol;
      if (len > 0)
	{
	  str = getTextSubstring(bol,pos);
	  loc = skip_syntax(syntax->syntab, str, T("^w_"), len-1, -1);
	  if (loc > -1) 
	    {
	      loc = skip_syntax(syntax->syntab, str, T("w_"), loc, -1);
	      // loc is now -1 or on nonword
	      setPoint(bol+loc+1);
	      return;
	    }
	}
      if (moveLine(-1))
	{
	  bol=point();
	  pos=pointEOL();
	}
      else
	break;
    }
  setPoint(bol);
}
Exemple #3
0
void TextBuffer::forwardWord()
{
  // Emacs M-f word motion. process buffer line by line scanning for
  // next word.
  String str;
  int pos, eol, len, loc;
  pos = point();
  eol = pointEOL();
  while (true)
    {
      len=eol-pos;
      if (len > 0)
	{
	  str = getTextSubstring(pos, eol);
	  // skip over white space
	  loc = skip_syntax(syntax->syntab, str, T("^w_"), 0, len);
	  if (loc < len)
	    {
	      loc = skip_syntax(syntax->syntab, str, T("w_"), loc, len);
	      setPoint(pos+loc);
	      return;
	    }
	}
      if (moveLine(1)) 
	{
	  pos=point();
	  eol=pointEOL();
	}
      else
	break;
    }
  setPoint(eol);
}
Exemple #4
0
void TextBuffer::killWhite()
{
  // search buffer for next non-white char and delete up to that
  // position
  String white=T(" \t\n");
  int from=point();
  int to;
  while (true)
    {
      bool go=true;
      to=point();
      String line=getTextSubstring(to,pointEOL());
      for (int i=0; i<line.length() && go; i++)
	if (white.containsChar(line[i])) 
	  to++;
	else
	  go=false;
      if (!go)
	break;
      else if (!moveLine(1)) // point now at next bol
	break;
    }
  deleteRegion(from,to);
  setFlag(EditFlags::NeedsSave);
}
Exemple #5
0
String TextBuffer::backwardTopLevelText()
{
  // return all the text from point() back to the start of the nearest
  // top-level form before it
  setCaretVisible(false);
  setScrollToShowCursor(false);
  String line, text = String::empty;
  int here=point();
  int pos=here;
  int bol=pointBOL();
  
  for (int i=0; ; i++)
    {
      line = getTextSubstring(bol, pos);
      if ( i == 0 ) 
	text=line;
      else
	text = line + T("\n") + text;
      if ( syntax->isTopLevel(line) || ! moveLine(-1) )
	break;
      else {
	bol=point();
	pos=pointEOL();
      }
    }
  setPoint(here);
  setCaretVisible(true);
  setScrollToShowCursor(true);
  return text;
}
Exemple #6
0
void ConnectorLine::move( QPointF delta )
{
   int myindex = m_pConnector->lineList()->indexOf( this );
   if( ( myindex == 0 ) || ( myindex == m_pConnector->lineList()->size()-1 ) )
       return;    //avoid moving first or last line

   moveLine( delta.toPoint() );
}
Exemple #7
0
// move:
void move(int order){
	if(order == 1);
	if(order == 2){
		turnLeftLine();
		moveLine();
	}
	if(order == 3){
		
	}
}
void CCardLabel::mouseMoveEvent(QMouseEvent *ev)
{
    if (mLockButton)
    {
        mLockButton->setVisible(mLockButton->isChecked()
            || (mCard.isValid() && mLockButton->geometry().contains(ev->pos())));
    }
    if (mLastLeftClickPos && mCard.isValid())
    {
        QLineF moveLine(ev->globalPos(), *mLastLeftClickPos);
        if (moveLine.length() >= QApplication::startDragDistance())
        {
            QDrag *drag = new QDrag(this);
            QMimeData *dragData = createCardLabelDropData(*this);
            drag->setMimeData(dragData);
            drag->setHotSpot(ev->pos());

            const QPixmap *unitImg = pixmap();
            if (unitImg)
            {
                int w = unitImg->width() / 2;
                int h = unitImg->height() / 2;
                QPixmap dragImg(w, h);
                dragImg.fill(Qt::transparent);
                QPainter painter(&dragImg);
                painter.setOpacity(0.75);
                painter.drawPixmap(0, 0, w, h, unitImg->scaled(w, h, Qt::KeepAspectRatio, Qt::SmoothTransformation));
                painter.end();
                drag->setPixmap(dragImg);
            }

            if (QApplication::keyboardModifiers() == Qt::ControlModifier || !acceptDrops())
            {     
                drag->exec(Qt::CopyAction);
            }
            else
            {
                CCard cardBuf = mCard;
                bool lockBuf = isLocked();
                setCard(CCard::INVALID_CARD);
                setLocked(false);
                if (!drag->exec(Qt::MoveAction))
                {
                    setCard(cardBuf);
                    setLocked(lockBuf);
                }
            }
            delete mLastLeftClickPos;
            mLastLeftClickPos = 0;
            emit unitDragged();
        }
    }
}
Exemple #9
0
String TextBuffer::forwardTopLevelText()
{
  // return all the text starting at point() up to, but not including,
  // the next top-level line that begins after at least one non-white
  // line has been encountered. in other words, a toplevel line that
  // is preceded only by whitespace will not stop the forward
  // exclusive search (else return text would just be whitespace.)
  setCaretVisible(false);
  setScrollToShowCursor(false);
  String line, text = String::empty;
  int here=point();
  int pos=here;
  int eol=pointEOL();
  bool nonw=false; // non-white line flag
  
  for (int i=0; ; i++)
    {
      if (eol > pos)
	{
	  line = getTextSubstring(pos, eol);
	  if (syntax->isWhiteBetween(line, 0, line.length()))
	    text += line;
	  else if (i == 0)
	    {
	      // collect first line no matter what
	      text += line;
	      nonw=true;
	    }
	  else if (nonw && syntax->isTopLevel(line))
	    break;
	  else 
	    {
	      text += line;
	      nonw=true;
	    }
	}
      text += T("\n");
      if (moveLine(1))
	{
	  pos=point();
	  eol=pointEOL();
	}
      else 
	{
	  break;
	}
    }
  setPoint(here);
  setCaretVisible(true);
  setScrollToShowCursor(true);
  return text;
}
Exemple #10
0
void TextBuffer::forwardExpr()
{
  if (isSyntax(TextIDs::Sal) || isSyntax(TextIDs::Sal2))
    {
      String text = forwardTopLevelText();
      int typ, loc, pos=point(), end=text.length();
      typ=scan_sexpr(syntax->syntab,text,0,end,SCAN_CODE,&loc,NULL);
      if (typ == SCAN_UNLEVEL)
	PlatformUtilities::beep();
      else if (typ == SCAN_UNMATCHED)
	PlatformUtilities::beep();
      else
	setPoint(pos+loc);
    }
  else if (isSyntax(TextIDs::Lisp) )
    {
      String text;
      int end, typ, loc;
      int top=-1;
      int pos=point();
      gotoEOL();
      while (true)
	{
	  text=getTextSubstring(pos, point());
	  end=text.length();
	  typ=scan_sexpr(syntax->syntab,text,0,end,SCAN_CODE,&loc,NULL);
	  if ((typ==SCAN_LIST) || (typ==SCAN_TOKEN) || (typ==SCAN_STRING))
	    {
	      top=pos+loc;
	      break;
	    }
	  if (!moveLine(1))
	    break;
	}
      
      if (top>-1)
	{
	  //std::cout << "parsed='" << getTextSubstring(pos,top).toUTF8()
	  //<< "'\n";
	  setPoint(top);
	}
      else
	{
	  PlatformUtilities::beep();
	  setPoint(pos);
	}
    }
  else
    PlatformUtilities::beep();
}
Exemple #11
0
void TextBuffer::backwardLine()
{
  // Emacs C-p motion including goal column
  static int goal=0;
  int col;
  if (prev != CommandIDs::EmacsLineBackward)
    goal=pointColumn();
  moveLine(-1);
  col=pointColumn();
  if (col<goal)
    if (pointLineLength()>=goal)
      incPoint(goal-col);
    else
      gotoEOL();
}
Exemple #12
0
void TextBuffer::forwardLine()
{
  // Emacs C-n motion with goal column
  static int goal=0;
  int col;
  if (prev != CommandIDs::EmacsLineForward)
    goal=pointColumn();
  moveLine(1); // cursor now on bol
  col=pointColumn();
  if (col<goal)
    if (pointLineLength()>=goal)
      incPoint(goal-col);
    else
      gotoEOL();
}
Exemple #13
0
void ConnectorLine::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
{
   event->accept();

   int myindex = m_pConnector->lineList()->indexOf( this );

   if( myindex == 0 )
       m_pConnector->addConLine( p1().x(), p1().y(), p1().x(), p1().y(), myindex );

   else if( myindex == m_pConnector->lineList()->size()-1 )
       m_pConnector->addConLine( p2().x(), p2().y(), p2().x(), p2().y(), myindex + 1 );

   QPoint delta = togrid( event->scenePos() ).toPoint() - togrid(event->lastScenePos()).toPoint();

   moveLine( delta );
}
Exemple #14
0
// move:
void move(int order){
	if(order == 1){
		mrp(LM, LM_SP_STR2, BALL_1_DIS);
		mrp(RM, RM_SP_STR2, BALL_1_DIS);
		bmd(LM);
		bmd(RM);
		ao();
	}
	if(order == 2){
		findLine();
		turnLeftLine();
		moveLine();
	}
	if(order == 3){
		
	}
}
Exemple #15
0
void QgsGrassEdit::keyPress( QKeyEvent *e )
{
  QgsDebugMsg( "entered." );
  // This does not work:
  //keyPressEvent(e);

  // TODO: this is not optimal
  switch ( e->key() )
  {
    case Qt::Key_F1: newPoint(); break;
    case Qt::Key_F2: newLine(); break;
    case Qt::Key_F3: newBoundary(); break;
    case Qt::Key_F4: newCentroid(); break;
    case Qt::Key_F5: moveVertex(); break;
    case Qt::Key_F6: addVertex(); break;
    case Qt::Key_F7: deleteVertex(); break;
    case Qt::Key_F9: moveLine(); break;
    case Qt::Key_F10: splitLine(); break;
    case Qt::Key_F11: deleteLine(); break;
    default: break;
  }
}
Exemple #16
0
void QgsGrassEdit::init()
{
  if ( !( mProvider->isGrassEditable() ) )
  {
    QMessageBox::warning( 0, tr( "Warning" ),
                          tr( "You are not owner of the mapset, cannot open the vector for editing." ) );
    return;
  }

  if ( !( mProvider->startEdit() ) )
  {
    QMessageBox::warning( 0, tr( "Warning" ), tr( "Cannot open vector for update." ) );
    return;
  }

  mRubberBandLine = new QgsRubberBand( mCanvas );
  mRubberBandIcon = new QgsVertexMarker( mCanvas );
  mRubberBandLine->setZValue( 20 );
  mRubberBandIcon->setZValue( 20 );

  connect( mCanvas, SIGNAL( keyPressed( QKeyEvent * ) ), this, SLOT( keyPress( QKeyEvent * ) ) );


  mToolBar = addToolBar( tr( "Edit tools" ) );

  mNewPointAction = new QAction(
    QgsGrassPlugin::getThemeIcon( "grass_new_point.png" ), tr( "New point" ), this );
  mNewPointAction->setShortcut( QKeySequence( Qt::Key_F1 ) );
  mToolBar->addAction( mNewPointAction );
  connect( mNewPointAction, SIGNAL( triggered() ), this, SLOT( newPoint() ) );

  mNewLineAction = new QAction(
    QgsGrassPlugin::getThemeIcon( "grass_new_line.png" ), tr( "New line" ), this );
  mNewLineAction->setShortcut( QKeySequence( Qt::Key_F2 ) );
  mToolBar->addAction( mNewLineAction );
  connect( mNewLineAction, SIGNAL( triggered() ), this, SLOT( newLine() ) );

  mNewBoundaryAction = new QAction(
    QgsGrassPlugin::getThemeIcon( "grass_new_boundary.png" ), tr( "New boundary" ), this );
  mNewBoundaryAction->setShortcut( QKeySequence( Qt::Key_F3 ) );
  mToolBar->addAction( mNewBoundaryAction );
  connect( mNewBoundaryAction, SIGNAL( triggered() ), this, SLOT( newBoundary() ) );

  mNewCentroidAction = new QAction(
    QgsGrassPlugin::getThemeIcon( "grass_new_centroid.png" ), tr( "New centroid" ), this );
  mNewCentroidAction->setShortcut( QKeySequence( Qt::Key_F4 ) );
  mToolBar->addAction( mNewCentroidAction );
  connect( mNewCentroidAction, SIGNAL( triggered() ), this, SLOT( newCentroid() ) );

  mMoveVertexAction = new QAction(
    QgsGrassPlugin::getThemeIcon( "grass_move_vertex.png" ), tr( "Move vertex" ), this );
  mMoveVertexAction->setShortcut( QKeySequence( Qt::Key_F5 ) );
  mToolBar->addAction( mMoveVertexAction );
  connect( mMoveVertexAction, SIGNAL( triggered() ), this, SLOT( moveVertex() ) );

  mAddVertexAction = new QAction(
    QgsGrassPlugin::getThemeIcon( "grass_add_vertex.png" ), tr( "Add vertex" ), this );
  mAddVertexAction->setShortcut( QKeySequence( Qt::Key_F6 ) );
  mToolBar->addAction( mAddVertexAction );
  connect( mAddVertexAction, SIGNAL( triggered() ), this, SLOT( addVertex() ) );

  mDeleteVertexAction = new QAction(
    QgsGrassPlugin::getThemeIcon( "grass_delete_vertex.png" ), tr( "Delete vertex" ), this );
  mDeleteVertexAction->setShortcut( QKeySequence( Qt::Key_F7 ) );
  mToolBar->addAction( mDeleteVertexAction );
  connect( mDeleteVertexAction, SIGNAL( triggered() ), this, SLOT( deleteVertex() ) );

  mMoveLineAction = new QAction(
    QgsGrassPlugin::getThemeIcon( "grass_move_line.png" ), tr( "Move element" ), this );
  mMoveLineAction->setShortcut( QKeySequence( Qt::Key_F9 ) );
  mToolBar->addAction( mMoveLineAction );
  connect( mMoveLineAction, SIGNAL( triggered() ), this, SLOT( moveLine() ) );

  mSplitLineAction = new QAction(
    QgsGrassPlugin::getThemeIcon( "grass_split_line.png" ), tr( "Split line" ), this );
  mSplitLineAction->setShortcut( QKeySequence( Qt::Key_F10 ) );
  mToolBar->addAction( mSplitLineAction );
  connect( mSplitLineAction, SIGNAL( triggered() ), this, SLOT( splitLine() ) );

  mDeleteLineAction = new QAction(
    QgsGrassPlugin::getThemeIcon( "grass_delete_line.png" ), tr( "Delete element" ), this );
  mDeleteLineAction->setShortcut( QKeySequence( Qt::Key_F11 ) );
  mToolBar->addAction( mDeleteLineAction );
  connect( mDeleteLineAction, SIGNAL( triggered() ), this, SLOT( deleteLine() ) );

  mEditAttributesAction = new QAction(
    QgsGrassPlugin::getThemeIcon( "grass_edit_attributes.png" ), tr( "Edit attributes" ), this );
  mToolBar->addAction( mEditAttributesAction );
  connect( mEditAttributesAction, SIGNAL( triggered() ), this, SLOT( editAttributes() ) );

  mCloseEditAction = new QAction(
    QgsGrassPlugin::getThemeIcon( "grass_close_edit.png" ), tr( "Close" ), this );
  mToolBar->addAction( mCloseEditAction );
  connect( mCloseEditAction, SIGNAL( triggered() ), this, SLOT( closeEdit() ) );

  mNewPointAction->setCheckable( true );
  mNewLineAction->setCheckable( true );
  mNewBoundaryAction->setCheckable( true );
  mNewCentroidAction->setCheckable( true );
  mMoveVertexAction->setCheckable( true );
  mAddVertexAction->setCheckable( true );
  mDeleteVertexAction->setCheckable( true );
  mMoveLineAction->setCheckable( true );
  mSplitLineAction->setCheckable( true );
  mDeleteLineAction->setCheckable( true );
  mEditAttributesAction->setCheckable( true );

  QActionGroup *ag = new QActionGroup( this );
  ag->addAction( mNewPointAction );
  ag->addAction( mNewLineAction );
  ag->addAction( mNewBoundaryAction );
  ag->addAction( mNewCentroidAction );
  ag->addAction( mMoveVertexAction );
  ag->addAction( mAddVertexAction );
  ag->addAction( mDeleteVertexAction );
  ag->addAction( mMoveLineAction );
  ag->addAction( mSplitLineAction );
  ag->addAction( mDeleteLineAction );
  ag->addAction( mEditAttributesAction );

  mEditPoints = Vect_new_line_struct();
  mPoints = Vect_new_line_struct();
  mCats = Vect_new_cats_struct();

  // Set lines symbology from map
  int nlines = mProvider->numLines();
  mLineSymb.resize( nlines + 1000 );
  for ( int line = 1; line <= nlines; line++ )
  {
    mLineSymb[line] = lineSymbFromMap( line );
  }

  // Set nodes symbology from map
  int nnodes = mProvider->numNodes();
  mNodeSymb.resize( nnodes + 1000 );
  for ( int node = 1; node <= nnodes; node++ )
  {
    mNodeSymb[node] = nodeSymbFromMap( node );
  }

  // Set default colors
  mSymb.resize( SYMB_COUNT );
  mSymb[SYMB_BACKGROUND].setColor( QColor( 255, 255, 255 ) );       // white
  mSymb[SYMB_HIGHLIGHT].setColor( QColor( 255, 255,   0 ) );        // yellow
  mSymb[SYMB_DYNAMIC].setColor( QColor( 125, 125, 125 ) );          // grey
  mSymb[SYMB_POINT].setColor( QColor( 0,   0,   0 ) );              // black
  mSymb[SYMB_LINE].setColor( QColor( 0,   0,   0 ) );               // black
  mSymb[SYMB_BOUNDARY_0].setColor( QColor( 255,   0,   0 ) );       // red
  mSymb[SYMB_BOUNDARY_1].setColor( QColor( 255, 125,   0 ) );       // orange
  mSymb[SYMB_BOUNDARY_2].setColor( QColor( 0, 255,   0 ) );         // green
  mSymb[SYMB_CENTROID_IN].setColor( QColor( 0, 255,   0 ) );        // green
  mSymb[SYMB_CENTROID_OUT].setColor( QColor( 255,   0,   0 ) );     // red
  mSymb[SYMB_CENTROID_DUPL].setColor( QColor( 255,   0, 255 ) );    // magenta
  mSymb[SYMB_NODE_1].setColor( QColor( 255,   0,   0 ) );           // red
  mSymb[SYMB_NODE_2].setColor( QColor( 0, 255,   0 ) );             // green

  // Set mSymbDisplay
  mSymbDisplay.resize( SYMB_COUNT );
  mSymbDisplay[SYMB_BACKGROUND] = true;
  mSymbDisplay[SYMB_HIGHLIGHT] = true;
  mSymbDisplay[SYMB_DYNAMIC] = true;
  mSymbDisplay[SYMB_POINT] = true;
  mSymbDisplay[SYMB_LINE] = true;
  mSymbDisplay[SYMB_BOUNDARY_0] = true;
  mSymbDisplay[SYMB_BOUNDARY_1] = true;
  mSymbDisplay[SYMB_BOUNDARY_2] = true;
  mSymbDisplay[SYMB_CENTROID_IN] = true;
  mSymbDisplay[SYMB_CENTROID_OUT] = true;
  mSymbDisplay[SYMB_CENTROID_DUPL] = true;
  mSymbDisplay[SYMB_NODE_1] = true;
  mSymbDisplay[SYMB_NODE_2] = true;

  // Set symbology names
  mSymbName.resize( SYMB_COUNT );
  mSymbName[SYMB_BACKGROUND]    = tr( "Background" );
  mSymbName[SYMB_HIGHLIGHT]     = tr( "Highlight" );
  mSymbName[SYMB_DYNAMIC]       = tr( "Dynamic" );
  mSymbName[SYMB_POINT]         = tr( "Point" );
  mSymbName[SYMB_LINE]          = tr( "Line" );
  mSymbName[SYMB_BOUNDARY_0]    = tr( "Boundary (no area)" );
  mSymbName[SYMB_BOUNDARY_1]    = tr( "Boundary (1 area)" );
  mSymbName[SYMB_BOUNDARY_2]    = tr( "Boundary (2 areas)" );
  mSymbName[SYMB_CENTROID_IN]   = tr( "Centroid (in area)" );
  mSymbName[SYMB_CENTROID_OUT]  = tr( "Centroid (outside area)" );
  mSymbName[SYMB_CENTROID_DUPL] = tr( "Centroid (duplicate in area)" );
  mSymbName[SYMB_NODE_1]        = tr( "Node (1 line)" );
  mSymbName[SYMB_NODE_2]        = tr( "Node (2 lines)" );

  // Restore symbology
  QString spath = "/GRASS/edit/symb/";
  QSettings settings;

  mLineWidth = settings.value(
                 spath + "lineWidth", 1 ).toInt();
  mSize = settings.value(
            spath + "markerSize", 9 ).toInt();
  mLineWidthSpinBox->setValue( mLineWidth );
  mMarkerSizeSpinBox->setValue( mSize );

  for ( int i = 0; i < SYMB_COUNT; i++ )
  {
    bool ok = settings.contains(
                spath + "display/" + QString::number( i ) );
    bool displ = settings.value(
                   spath + "display/" + QString::number( i ),
                   true ).toBool();
    if ( ok )
    {
      mSymbDisplay[i] = displ;
    }

    ok = settings.contains(
           spath + "color/" + QString::number( i ) );
    QString colorName = settings.value(
                          spath + "color/" + QString::number( i ),
                          "" ).toString();
    if ( ok )
    {
      QColor color( colorName );
      mSymb[i].setColor( color );
      // Use the 'dynamic' color for mRubberBand
      if ( i == SYMB_DYNAMIC )
      {
        mRubberBandLine->setColor( QColor( colorName ) );
      }
    }
    mSymb[i].setWidth( mLineWidth );
  }

  // Set Symbology in dialog
  symbologyList->setColumnWidth( 0, 40 );
  symbologyList->setColumnWidth( 1, 50 );
  symbologyList->setColumnWidth( 2, 200 );

  for ( int i = 0; i < SYMB_COUNT; i++ )
  {
    if ( i == SYMB_NODE_0 )
      continue;

    QPixmap pm( 40, 15 );
    pm.fill( mSymb[i].color() );
    QString index;
    index.sprintf( "%d", i );

    QTreeWidgetItem *item = new QTreeWidgetItem( symbologyList );
    if ( !( i == SYMB_BACKGROUND || i == SYMB_HIGHLIGHT || i == SYMB_DYNAMIC ) )
    {
      item->setCheckState( 0, mSymbDisplay[i] ? Qt::Checked : Qt::Unchecked );
    }
    item->setIcon( 1, pm );
    item->setText( 2, mSymbName[i] );
    item->setText( 3, index );
  }

  connect( symbologyList, SIGNAL( itemPressed( QTreeWidgetItem *, int ) ),
           this, SLOT( changeSymbology( QTreeWidgetItem *, int ) ) );

  // Init table tab
  mAttributeTable->setItemDelegate( new QgsGrassEditAttributeTableItemDelegate( this ) );
  mAttributeTable->verticalHeader()->hide();

  int ndblinks = mProvider->numDbLinks();

  if ( ndblinks > 0 )
  {
    for ( int i = 0; i < ndblinks; i++ )
    {
      int f = mProvider->dbLinkField( i );

      QString str;
      str.sprintf( "%d", f );
      mTableField->addItem( str );
      mFieldBox->addItem( str );
      if ( i == 0 )
      {
        setAttributeTable( f );
      }
    }
    mTableField->setCurrentIndex( 0 );
    mFieldBox->setCurrentIndex( 0 );
  }
  else
  {
    mTableField->addItem( "1" );
    setAttributeTable( 1 );

    mFieldBox->addItem( "1" );
  }

  connect( mAttributeTable, SIGNAL( cellChanged( int, int ) ), this, SLOT( columnTypeChanged( int, int ) ) );

  // Set variables
  mSelectedLine = 0;
  mAttributes = 0;

  // Read max cats
  for ( int i = 0; i < mProvider->cidxGetNumFields(); i++ )
  {
    int field = mProvider->cidxGetFieldNumber( i );
    if ( field > 0 )
    {
      int cat = mProvider->cidxGetMaxCat( i );
      MaxCat mc;
      mc.field = field;
      mc.maxCat = cat;
      mMaxCats.push_back( mc );
    }
  }

  connect( mCanvas, SIGNAL( renderComplete( QPainter * ) ), this, SLOT( postRender( QPainter * ) ) );

  mCanvasEdit = new QgsGrassEditLayer( mCanvas );

  mPixmap = &mCanvasEdit->pixmap();

  // Init GUI values
  mCatModeBox->addItem( tr( "Next not used" ), CAT_MODE_NEXT );
  mCatModeBox->addItem( tr( "Manual entry" ), CAT_MODE_MANUAL );
  mCatModeBox->addItem( tr( "No category" ), CAT_MODE_NOCAT );
  catModeChanged( );

  // TODO: how to get keyboard events from canvas (shortcuts)

  restorePosition();

  mValid = true;
  mInited = true;
}
/**
 *	This method fills in the adjacentState reference with
 *	the state for a given adjacency.
 *
 *	@param index			Index of adjacency
 *	@param adjacency	State of adjacency is copied here
 *	@param goal				Goal state
 *
 *	@return True if this is a valid adjacency.
 */
bool WaypointState::getAdjacency(int index,
		WaypointState& adjacency, const WaypointGoalState& goal) const
{
	Vector2 src, dst, p1, p2, movementVector, next;
	float p, cp1, cp2;

	// If this edge on waypoint is not passable, forget it.

	const WaypointSet * pAdjSet = pWaypoint_->adjacentWaypointSet(index);
	if (pWaypoint_->adjacentWaypoint(index) == NULL && pAdjSet == NULL)
		return false;

	// We need 2d vectors for intersection tests.

	src.x = position_.x;
	src.y = position_.z;
	dst.x = goal.position_.x;
	dst.y = goal.position_.z;
	movementVector = dst - src;

	p1 = pWaypoint_->vertexPosition(index);
	p2 = pWaypoint_->vertexPosition((index + 1) % pWaypoint_->vertexCount());

	// move the pts towards each other if we have extra radius
	if (goal.extraRadius() > 0.f)
	{
		const float ger = goal.extraRadius();
		Vector2 edir( p2 - p1 );
		const float elen = edir.length();

		// for now can only pass edges that are long enough
		// (need to only move in conditionally, e.g. if adj to black)
		if (elen < ger * 2.f) return false;

		edir *= ger / elen;
		p1 += edir;
		p2 -= edir;
	}

	cp1 = movementVector.crossProduct(p1 - src);
	cp2 = movementVector.crossProduct(p2 - src);

	// If our desired path takes us through this line segment,
	// find the intersection and use it. Otherwise use the
	// vertex whose crossproduct is closest to zero.

	if(cp1 > 0.0f && cp2 < 0.0f)
	{
		LineEq moveLine(src, dst, true);
		LineEq edgeLine(p1, p2, true);
		p = moveLine.intersect(edgeLine);
		next = moveLine.param(p);
	}
	else if(fabs(cp1) < fabs(cp2))
	{
		next = p1;
	}
	else
	{
		next = p2;
	}

	adjacency.pWPSet_ = (pAdjSet == NULL) ? pWPSet_ : pAdjSet;
	adjacency.waypointID_ = pWaypoint_->adjacentID(index);
	adjacency.pWaypoint_ = pWaypoint_->adjacentWaypoint(index);
	adjacency.position_.x = next.x;
	adjacency.position_.y = position_.y;
	adjacency.position_.z = next.y;
	adjacency.distanceFromParent_ = (position_ - adjacency.position_).length();
	return true;
}
Exemple #18
0
void TextBuffer::colorizeAfterChange(CommandID cmd)
{
  if (testFlag(EditFlags::HiliteOff) ||
      !syntax->highlighting())
    return;
  int loc=0, bot=0, top=0;
  switch (cmd)
    {
    case CommandIDs::EditorBackspace:
    case CommandIDs::EditorTextChanged:
    case CommandIDs::EditorDelete:
    case CommandIDs::EmacsKillChar:
    case CommandIDs::EmacsKillLine:
    case CommandIDs::EmacsKillWord:
    case CommandIDs::EmacsKillWhite:
    case CommandIDs::EmacsKillExpr:
    case CommandIDs::EmacsYank:
    case CommandIDs::EditorIndent:
    case CommandIDs::EmacsUppercase:
    case CommandIDs::EmacsLowercase:
    case CommandIDs::EmacsCapitalize:
      // colorize current line
      bot=pointBOL();
      top=pointEOL();
      break;
    case CommandIDs::EditorNewline:
      // include previous line in recolor
      loc=point();
      bot=pointBOL();
      top=pointEOL();
      if (moveLine(-1)) 
	{
	  bot=point();
	  setPoint(loc);
	}
      break;
    case CommandIDs::EditorPaste:  
      // point is after pasted material. colorize from bol before
      // previous point to eol AFTER pasted
      loc=point();
      top=pointEOL();
      bot=loc-SystemClipboard::getTextFromClipboard().length();
      setPoint(bot);
      bot=pointBOL();
      setPoint(loc);
      break;
    case CommandIDs::EmacsOpenLine:
      // include new line in recolor
      loc=point();
      bot=pointBOL();
      top=pointEOL();
       if ( moveLine(1) )
	{
	  top=pointEOL();
	  setPoint(loc);
	}
      break;
    default:
      return;
    }
  if (bot!=top) 
    {
      // std::cout << "ColorizeAfterChange: " 
      //   << CommandIDs::toString(cmd).toUTF8() << "\n";
      colorize(bot, top, true);
    }
}