Ejemplo n.º 1
0
void t4p::FinderActionClass::BackgroundWork() {
    if (!Finder.Prepare()) {
        return;
    }
    Code = t4p::CharToIcu(Utf8Buf);
    int32_t nextIndex(0);
    bool found = Finder.FindNext(Code, nextIndex);
    int32_t matchStart(0);
    int32_t matchLength(0);
    while (found) {
        if (Finder.GetLastMatch(matchStart, matchLength)) {
            // convert match back to UTF-8 ugh
            int utf8Start = t4p::CharToUtf8Pos(Utf8Buf, BufferLength, matchStart);
            int utf8End = t4p::CharToUtf8Pos(Utf8Buf, BufferLength, matchStart + matchLength);

            t4p::FinderHitEventClass hit(GetEventId(), utf8Start, utf8End - utf8Start);
            PostEvent(hit);
            nextIndex = matchStart + matchLength + 1;  // prevent infinite find next's
        } else {
            break;
        }
        found = Finder.FindNext(Code, nextIndex);
    }
    delete[] Utf8Buf;
}
Ejemplo n.º 2
0
void
RegexScan::matchInfo(
  ssize_t & start,
  ssize_t & len,
  unsigned short regNum ) const
{
  start = matchStart( regNum );
  len = matchLength( regNum );
}
Ejemplo n.º 3
0
void FieldViewerPainter::paintObservations(QPaintEvent* event,
                                           messages::VisionField obsv,
                                           messages::RobotLocation loc)
{
    QPainter painter(this);
    //Move origin to bottem left and scale to flip the y axis
    painter.translate(0,FIELD_GREEN_HEIGHT*scaleFactor);
    painter.scale(scaleFactor, -scaleFactor);
    painter.setPen(Qt::black);

    // ToDo: paint orientation/shape
    // Corners

    for (int i=0; i<obsv.visual_corner_size(); i++) {
        if(obsv.visual_corner(i).visual_detection().distance() > 0.f){
                painter.setBrush(Qt::black);
                QPoint relLoc= getRelLoc(loc, obsv.visual_corner(i).visual_detection().distance(),
                                         obsv.visual_corner(i).visual_detection().bearing());
                painter.drawEllipse(relLoc, 10, 10);

                // Paint the possible locations in purple and tiny
                for (int j=0; j<obsv.visual_corner(i).visual_detection().concrete_coords_size(); j++)
                {
                    float concX = obsv.visual_corner(i).visual_detection().concrete_coords(j).x();
                    float concY = obsv.visual_corner(i).visual_detection().concrete_coords(j).y();
                    QPoint relCoord(concX, concY);
                    painter.setBrush(Qt::magenta);
                    painter.drawEllipse(relCoord,5,5);
                    painter.setBrush(Qt::black);
                }
            }
    }

    for (int i=0; i<obsv.visual_line_size(); i++) {
        if((obsv.visual_line(i).start_dist() < 300.f) || (obsv.visual_line(i).end_dist() < 300.f)) {
            man::localization::Line postProcessLine = man::localization::VisionSystem::prepareVisualLine(loc,
                                                                                           obsv.visual_line(i));
            if(postProcessLine.length() > 70.f) {
                QPoint obsvSt (postProcessLine.start.x, postProcessLine.start.y);
                QPoint obsvEnd(postProcessLine.end.x, postProcessLine.end.y);

                painter.setBrush(Qt::black);
                painter.drawLine(obsvSt, obsvEnd);

                // Get and paint the line it matches to
                man::localization::LineErrorMatch match = lineSystem->scoreAndMatchObservation(postProcessLine, false);

                QPoint matchStart(match.startMatch.x, match.startMatch.y);
                QPoint matchEnd  (match.endMatch.x, match.endMatch.y);
                painter.setBrush(Qt::magenta);
                painter.drawLine(matchStart, matchEnd);
           }


        }
    }

    // std::cout << "Est line error:\t"
    //           << visionSystem->getAvgLineError(loc,
    //                                            obsv)
    //           << std::endl;

    if (obsv.has_goal_post_l()) {
        if (obsv.goal_post_l().visual_detection().on()
           && (obsv.goal_post_l().visual_detection().distance() > 0.f)){
            painter.setBrush(Qt::yellow);
            QPoint relLoc= getRelLoc(loc, obsv.goal_post_l().visual_detection().distance(),
                                     obsv.goal_post_l().visual_detection().bearing());
            painter.drawEllipse(relLoc, 10, 10);

            for (int j=0; j<obsv.goal_post_l().visual_detection().concrete_coords_size(); j++)
            {
                float concX = obsv.goal_post_l().visual_detection().concrete_coords(j).x();
                float concY = obsv.goal_post_l().visual_detection().concrete_coords(j).y();
                QPoint relCoord(concX, concY);
                painter.setBrush(Qt::magenta);
                painter.drawEllipse(relCoord,5,5);
            }
        }
    }

    if (obsv.has_goal_post_r()) {
        if (obsv.goal_post_r().visual_detection().on()
           && (obsv.goal_post_r().visual_detection().distance() > 0.f)){
            painter.setBrush(Qt::red);
            QPoint relLoc= getRelLoc(loc, obsv.goal_post_r().visual_detection().distance(),
                                     obsv.goal_post_r().visual_detection().bearing());
            painter.drawEllipse(relLoc, 10, 10);
            for (int j=0; j<obsv.goal_post_r().visual_detection().concrete_coords_size(); j++)
            {
                float concX = obsv.goal_post_r().visual_detection().concrete_coords(j).x();
                float concY = obsv.goal_post_r().visual_detection().concrete_coords(j).y();
                QPoint relCoord(concX, concY);
                painter.setBrush(Qt::magenta);
                painter.drawEllipse(relCoord,5,5);
            }
        }
    }

    if (obsv.has_visual_cross()) {
        if (obsv.visual_cross().distance() > 0.f){
            painter.setBrush(Qt::black);
            QPoint relLoc= getRelLoc(loc, obsv.visual_cross().distance(),
                                     obsv.visual_cross().bearing());
            painter.drawEllipse(relLoc, 10, 10);

            for (int j=0; j<obsv.visual_cross().concrete_coords_size(); j++)
            {
                float concX = obsv.visual_cross().concrete_coords(j).x();
                float concY = obsv.visual_cross().concrete_coords(j).y();

                QPoint relCoord(concX, concY);
                painter.setBrush(Qt::magenta);
                painter.drawEllipse(relCoord,5,5);
            }
        }
    }

    // Paint the line segment in global

}