Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const QRegularExpression regx(QStringLiteral(R"**((?:(X)([-+]?\d*\.?\d+)\s*(Y)([-+]?\d*\.?\d+))|(?:(X)([-+]?\d*\.?\d+))|(?:(Y)([-+]?\d*\.?\d+)))**"));
- QTextStream in(&file);
- while(!in.atEnd()) {
- QString line = in.readLine();
- const QRegularExpressionMatch reMatch = regx.match(line);
- if(reMatch.hasMatch()){
- if(reMatch.lastCapturedIndex()==4){ // matched both X and Y
- const double lx = reMatch.captured(2).toDouble();
- const double ly = reMatch.captured(4).toDouble();
- qDebug()<<"X : " << lx << " ly" << ly;
- if(lx<minX)
- minX=lx;
- else if (lx>maxX)
- maxX=lx;
- if(ly<minY)
- minY=ly;
- else if (ly>maxY)
- maxY=ly;
- }
- else if(reMatch.captured(1).compare(QLatin1String("X"),Qt::CaseInsensitive)==0){ // matched X
- const double lx = reMatch.captured(2).toDouble();
- qDebug()<<"X : " << lx;
- if(lx<minX)
- minX=lx;
- else if (lx>maxX)
- maxX=lx;
- }
- else {// matched Y
- const double ly = reMatch.captured(2).toDouble();
- qDebug() << " ly" << ly;
- if(ly<minY)
- minY=ly;
- else if (ly>maxY)
- maxY=ly;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement