Пример #1
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);
}
Пример #2
0
		void draw (double x_center, double y_center)
		{
			setPoint(x_center-dimension/2,y_center-dimension/2);
			setPoint(x_center-dimension/2,y_center+dimension/2);
			setPoint(x_center+dimension/2,y_center+dimension/2);
			setPoint(x_center+dimension/2,y_center-dimension/2);
		};
/**
 * This method simply ensures presence of two points and
 * adds the needed points for self associations.
 */
void AssociationLine::calculateInitialEndPoints()
{
    if (m_associationWidget->isSelf() && count() < 4) {
        for (int i = count(); i < 4; ++i) {
            insertPoint(i, QPointF());
        }
        UMLWidget *wid = m_associationWidget->widgetForRole(Uml::RoleType::B);
        if (!wid) {
            uError() << "AssociationWidget is partially constructed."
                "UMLWidget for role B is null.";
            return;
        }
        const QRectF rect = m_associationWidget->mapFromScene(
                mapToScene(wid->rect()).boundingRect()).boundingRect();

        qreal l = rect.left() + .25 * rect.width();
        qreal r = rect.left() + .75 * rect.width();
        bool drawAbove = rect.top() >= SelfAssociationMinimumHeight;
        qreal y = drawAbove ? rect.top() : rect.bottom();
        qreal yOffset = SelfAssociationMinimumHeight;
        if (drawAbove) {
            yOffset *= -1.0;
        }

        setPoint(0, QPointF(l, y));
        setPoint(1, QPointF(l, y + yOffset));
        setPoint(2, QPointF(r, y + yOffset));
        setPoint(3, QPointF(r, y));
    } else if (!m_associationWidget->isSelf() && count() < 2) {
        setEndPoints(QPointF(), QPointF());
    }
}
Пример #4
0
bool TextBuffer::indentToColumn(int col)
{
  // reindent current line so that there are col white spaces before
  // the first non-white char in line
  
  int bol=pointBOL();
  int top=bol+currentIndent();  // current pos of first non-white or eol
  int loc=bol+col;  // goal pos for indentation
  
  setCaretVisible(false);
  setScrollToShowCursor(false);

  if (loc < top)
    {
      //std::cout << "deleting " << top-loc << " spaces.\n";
     setPoint(bol);
     setHighlightedRegion(bol, (top-loc));
     insertTextAtCursor(String::empty);    
    }
  else if (loc > top)
    {
      setPoint(bol);
      String pad=String::empty;
      for (int i=top; i<loc; i++) 
	pad << T(" ");
      //std::cout << "inserting " << pad.length() << " spaces.\n";
      insertTextAtCursor(pad);
    }
  setPoint(loc);
  setCaretVisible(true);
  setScrollToShowCursor(true);
  return (loc!=top);
}
void GraphView::mousePressEvent ( QMouseEvent * me){
    /* Select the closest point */
    Vert p;
    setPoint(me->x(), me->y(), p);

    if(disc){
        double bestdist = DIST_2D(p.x,p.y,disc->verts[0].x,disc->verts[0].y);
        sPoint = 0;
        for(int i = 0; i < disc->numVert; i++){
            cout << DIST_2D(p.x,p.y,disc->verts[i].x,disc->verts[i].y)  << " ";
            if(bestdist > DIST_2D(p.x,p.y,disc->verts[i].x,disc->verts[i].y)){
                bestdist = DIST_2D(p.x,p.y,disc->verts[i].x,disc->verts[i].y);
                sPoint = i;
            }
        }
    }

    cout << disc->vertLabels[sPoint] << " (" << sPoint << ")"<< endl;

    setPoint(me->x(), me->y(), disc->verts[sPoint]);

    emit pointChanged(sPoint,disc->verts[sPoint].x,disc->verts[sPoint].y);
    mouseTrack = 1;
    repaint(true);
}
Пример #6
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);
}
Пример #7
0
bool QPointArray::setPoints( int nPoints, int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3)
{
    if ( !resize(nPoints) )
	return FALSE;
    setPoint( 0, x0, y0 );
    setPoint( 1, x1, y1 );
    setPoint( 2, x2, y2 );
    setPoint( 3, x3, y3 );
    return TRUE;
}
Пример #8
0
void GameTeam::update(float dm)
{
    //CCLOG("GameTeam::update");
    // 首先删除当前处于死亡状态的成员
    removeDeadCharacter();

    // 队伍级别的大脑思考一下
    m_teamBrain->process();

    // 调用该队的所有成员的update
    for (auto tmpIterator = m_members.begin(); tmpIterator != m_members.end(); tmpIterator++)
    {
        (*tmpIterator)->update(dm);
    }

    // 再删除处于死亡状态的队员
    removeDeadCharacter();

    // 更新队伍位置
    auto tmpTeamPos =   m_formation.getFormationAnchor();
    if (iscollectiveForwardState())
    {
        tmpTeamPos.setPoint(tmpTeamPos.x + dm * m_advanceRate, tmpTeamPos.y);
        m_formation.setFormationAnchor(tmpTeamPos);
    }
    else if (isFollowPlayerState())
    {
        // 否则队伍就始终跟随最前面的人
        auto tmpFormationX    =   0;
        for (auto tmpIterator = m_members.begin(); tmpIterator != m_members.end(); tmpIterator++)
        {
            auto tmpXPos    =   (*tmpIterator)->getMovingEntity().getPosition().x;
            if (m_formation.getFormationType() == Formation::FORMATION_TYPE_RIGHT && 
                tmpFormationX < tmpXPos)
            {
                tmpFormationX   =   tmpXPos;
            }
            if (m_formation.getFormationType() == Formation::FORMATION_TYPE_LEFT &&
                tmpFormationX > tmpXPos)
            {
                tmpFormationX   =   tmpXPos;
            }
        }
        tmpTeamPos.setPoint(tmpFormationX, tmpTeamPos.y);
        m_formation.setFormationAnchor(tmpTeamPos);
    }

    // 判断是否可以被删除
    if (m_members.size() == 0)
    {
        setCanRemove();
    }
}
Пример #9
0
void OGRLinearRing::reverseWindingOrder() 

{ 
    int pos = 0; 
    OGRPoint tempPoint; 

    for( int i = 0; i < nPointCount / 2; i++ ) 
    { 
        getPoint( i, &tempPoint ); 
        pos = nPointCount - i - 1; 
        setPoint( i, getX(pos), getY(pos), getZ(pos) ); 
        setPoint( pos, tempPoint.getX(), tempPoint.getY(), tempPoint.getZ() ); 
    } 
} 
Пример #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();
}
Пример #11
0
void QPolygon::setPoints(int nPoints, int firstx, int firsty, ...)
{
    va_list ap;
    resize(nPoints);
    setPoint(0, firstx, firsty);
    int i = 0, x, y;
    va_start(ap, firsty);
    while (--nPoints) {
        x = va_arg(ap, int);
        y = va_arg(ap, int);
        setPoint(++i, x, y);
    }
    va_end(ap);
}
Пример #12
0
/** Reverse order of points.
 */
void OGRLinearRing::reverseWindingOrder()

{
    OGRPoint pointA;
    OGRPoint pointB;

    for( int i = 0; i < nPointCount / 2; i++ )
    {
        getPoint( i, &pointA );
        const int pos = nPointCount - i - 1;
        getPoint( pos, &pointB );
        setPoint( i, &pointB );
        setPoint( pos, &pointA );
    }
}
Пример #13
0
void TextBuffer::changeCase(int flag)
{
  // change case of word at point. 0=lower,1=upper,2=capitalize
  int beg=point();
  forwardWord();
  int end=point();
  String text=getTextSubstring(beg, end);
  if (text==String::empty)
    return;
  deleteRegion(beg,end);
  if (flag==0)
    insertTextAtCursor(text.toLowerCase());
  else if (flag==1)
    insertTextAtCursor(text.toUpperCase());
  else if (flag==2)
    {
      int len=text.length();
      // get first alphachar 
      int loc=skip_syntax(syntax->syntab, text, T("^w"), 0, len);	
      insertTextAtCursor(text.substring(0,loc));
      if (loc<len)
	{
	  insertTextAtCursor(text.substring(loc,loc+1).toUpperCase());
	  insertTextAtCursor(text.substring(loc+1,len));
	}
    }
  beg=point();
  //colorizeAfterChange(CommandIDs::EditorIndent); // recolorize whole line for now..
  setPoint(beg);
  setFlag(EditFlags::NeedsSave);
}
Пример #14
0
void GLEText::moveBy(QPointF offset)
{
	pointHash.clear();
	// Moves relative to storedPointHash
	QPointF start = getQtPoint(ReferencePoint, true);
	setPoint(ReferencePoint, start + offset);
}
Пример #15
0
void Sudoku::setBoard()
{
	// Get file
	string file = promptForString("What file would you like to use? ");
	
	// Get a valid file
	while(!fileExists(file))
	{
		cout << "INVALID FILE" << endl;
		file = promptForString("Which file would you like to use? ");
	}
	
	int point;
	ifstream read(file);

	// Populate the grid now
	for(unsigned int y = 0; y < size_; ++y)
	{
		for(unsigned int x = 0; x < size_; ++x)
		{
			read >> point;
			setPoint(x, y, point);
		}
	}
}
Пример #16
0
void TextBuffer::startMatching(int pos1, int pos2)
{
  setPoint(pos1);
  setColour(TextEditor::caretColourId, Colours::red);
  matchpos=pos2;
  startTimer(1000);
}
Пример #17
0
//-----------------------------------------------
void AflSpriteWnd::move(FLOAT fX,FLOAT fY)
{
	FLOAT fWindowX = -m_fClickPointX+fX + m_fClickPointBaseX;
	FLOAT fWindowY = -m_fClickPointY+fY + m_fClickPointBaseY;
	setPoint(fWindowX,fWindowY);
	onWindowMove(fWindowX,fWindowY);
}
void GraphView::mouseReleaseEvent ( QMouseEvent * me){
    setPoint(me->x(), me->y(), disc->verts[sPoint]);

    emit pointChanged(sPoint,disc->verts[sPoint].x,disc->verts[sPoint].y);
    mouseTrack = 0;
    repaint(true);
}
Пример #19
0
void GLEDrawingObject::linearTransformPt(int pt, const GLELinearEquation& ex, const GLELinearEquation& ey, bool update)
{
	QPointF p = getQtPoint(pt, true);
	p.setX(ex.apply(p.x()));
	p.setY(ey.apply(p.y()));
	setPoint(pt, p, update);
}
Пример #20
0
//Move each point by velocity * dt
void Convex::move(sf::Time* dt)
{
	for (int i = 0; i < getPointCount(); i++)
	{
		setPoint(i, getPoint(i) + _velocity * dt->asSeconds());
	}
}
Пример #21
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;
}
Пример #22
0
/**
 * Moves the point or line if active.
 */
void AssociationLine::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
    UMLScene* scene = m_associationWidget->umlScene();

    QPointF oldPos = event->scenePos();
    QPointF newPos(
        scene->snappedX(oldPos.x()),
        scene->snappedY(oldPos.y())
    );

    // Prevent the moving vertex from disappearing underneath a widget
    // (else there's no way to get it back.)
    UMLWidget *onW = scene->widgetAt(newPos);
    if (onW && onW->baseType() != WidgetBase::wt_Box) {  // boxes are transparent
        const qreal pX = newPos.x();
        const qreal pY = newPos.y();
        const qreal wX = onW->x();
        const qreal wY = onW->y();
        const qreal wWidth = onW->width();
        const qreal wHeight = onW->height();
        if (pX > wX && pX < wX + wWidth) {
            const qreal midX = wX + wWidth / 2.0;
            if (pX <= midX)
                newPos.setX(wX);
            else
                newPos.setX(wX + wWidth);
        }
        if (pY > wY && pY < wY + wHeight) {
            const qreal midY = wY + wHeight / 2.0;
            if (pY <= midY)
                newPos.setY(wY);
            else
                newPos.setY(wY + wHeight);
        }
    }

    if (m_activePointIndex != -1) {
        // Move a single point (snap behaviour)
        setPoint(m_activePointIndex, newPos);
    }
    else if (m_activeSegmentIndex != -1 && !isEndSegmentIndex(m_activeSegmentIndex)) {
        // Move a segment (between two points, snap behaviour not implemented)
        QPointF delta = event->scenePos() - event->lastScenePos();
        setPoint(m_activeSegmentIndex, m_points[m_activeSegmentIndex] + delta);
        setPoint(m_activeSegmentIndex + 1, m_points[m_activeSegmentIndex + 1] + delta);
    }
}
Пример #23
0
void initCamera(struct Camera *camera) {
    camera->x = 40;
    camera->y = 20;
    camera->z = -40;
    camera->direction = 0;
    camera->yPoint = 0;
    setPoint(camera);
}
Пример #24
0
void TextBuffer::openLine()
{
  // C-o new line does not change point
  int here=point();
  insertTextAtCursor(T("\n"));
  setPoint(here);
  setFlag(EditFlags::NeedsSave);
}
void 
GlobeMapMovingInterface::setPoint(const MC2Coordinate& newCoord,
                                  const MC2Point& screenPoint,
                                  double angleDegrees )
{
   setPoint( newCoord, screenPoint );
   setAngle( angleDegrees, screenPoint ); 
}
Пример #26
0
bool MgBaseShape::_offset(const Vector2d& vec, int)
{
    for (int i = 0; i < getPointCount(); i++) {
        setPoint(i, getPoint(i) + vec);
    }
    update();
    return true;
}
Пример #27
0
bool PointModel::setPointType(int row, uint type)
{
    if (row<0 || row> pointList.count()-1) return false;
    if (type!=0) {
        for (int i=0;i<pointList.count()-1;i++) {
            if (pointList.at(i).pntType==type) {
                favPoints_t point =  pointList[i];
                point.pntType=0;
                setPoint(i,point);
            }//if ==
            }//for
        }//!=0
    favPoints_t point = pointList.at(row);
    point.pntType = type;
    setPoint(row, point);
    return true;
}
Пример #28
0
/**
 * Sets the start and end points.
 */
bool LinePath::setStartEndPoints( const QPoint &start, const QPoint &end )
{
    int count = m_LineList.count();
    if( count == 0 ) {
        Q3CanvasLine * line = new Q3CanvasLine(getScene() );
        line -> setPoints( start.x(), start.y(),end.x(),end.y() );
        line -> setZ( -2 );
        line -> setPen( getPen() );
        line -> setVisible( true );
        m_LineList.append( line );
        return true;
    }
    bool status = setPoint( 0, start );
    if( status)
        return setPoint(count,end);
    return false;
}
Пример #29
0
void QPolygon::putPoints(int index, int nPoints, int firstx, int firsty, ...)
{
    va_list ap;
    if (index + nPoints > size())
        resize(index + nPoints);
    if (nPoints <= 0)
        return;
    setPoint(index, firstx, firsty);
    int i = index, x, y;
    va_start(ap, firsty);
    while (--nPoints) {
        x = va_arg(ap, int);
        y = va_arg(ap, int);
        setPoint(++i, x, y);
    }
    va_end(ap);
}
Пример #30
0
int TextBuffer::gotoEOL()
{
  int pos=findCharForward('\n');
  if (pos<0) 
    return gotoEOB();
  else 
    return setPoint(pos);
}