Exemple #1
0
/**
 * @brief KmlExport::preparseLogFile Ensures that the logfile has data to export
 * @return Returns true if the logfile has data, false otherwise
 */
bool KmlExport::preparseLogFile()
{
    //Read all log timestamps into array
    timestampBuffer.clear(); //Save beginning of log for later use
    timestampPos.clear();
    quint64 logFileStartIdx = logFile.pos();
    quint32 lastTimeStamp = 0;

    while (!logFile.atEnd()){
        qint64 dataSize;

        //Get time stamp position
        timestampPos.append(logFile.pos());

        //Read timestamp and logfile packet size
        logFile.read((char *) &lastTimeStamp, sizeof(lastTimeStamp));
        logFile.read((char *) &dataSize, sizeof(dataSize));

        //Check if dataSize sync bytes are correct.
        //TODO: LIKELY AS NOT, THIS WILL FAIL TO RESYNC BECAUSE THERE IS TOO LITTLE INFORMATION IN THE STRING OF SIX 0x00
        if ((dataSize & 0xFFFFFFFFFFFF0000)!=0){
            qDebug() << "Wrong sync byte. At file location 0x"  << QString("%1").arg(logFile.pos(),0,16) << "Got 0x" << QString("%1").arg(dataSize & 0xFFFFFFFFFFFF0000,0,16) << ", but expected 0x""00"".";
            logFile.seek(timestampPos.last()+1);
            timestampPos.pop_back();
            continue;
        }

        //Check if timestamps are sequential.
        if (!timestampBuffer.isEmpty() && lastTimeStamp < timestampBuffer.last()){
            QMessageBox msgBox;
            msgBox.setText("Corrupted file.");
            msgBox.setInformativeText("Timestamps are not sequential. Playback may have unexpected behavior"); //<--TODO: add hyperlink to webpage with better description.
            msgBox.exec();

            qDebug() << "Timestamp: " << timestampBuffer.last() << " " << lastTimeStamp;
        }

        timestampBuffer.append(lastTimeStamp);

        logFile.seek(timestampPos.last()+sizeof(lastTimeStamp)+sizeof(dataSize)+dataSize);
    }

    //Check if any timestamps were successfully read
    if (timestampBuffer.size() == 0){
        QMessageBox msgBox;
        msgBox.setText("Empty logfile.");
        msgBox.setInformativeText("No log data can be found.");
        msgBox.exec();

        stopExport();
        return false;
    }

    //Reset to log beginning, including the timestamp.
    logFile.seek(logFileStartIdx);

    return true;
}
Exemple #2
0
/**
 * @brief KmlExport::parseLogFile Parses logfile and exports results to KML file
 */
void KmlExport::parseLogFile()
{
    qint64 packetSize;
    quint32 timeStampIdx;

    //Read packets
    while (!logFile.atEnd())
    {
        if(logFile.bytesAvailable() < 4) {
            break;
        }

        //Read timestamp and logfile packet size
        logFile.read((char *) &timeStamp, sizeof(timeStamp));
        logFile.read((char *) &packetSize, sizeof(packetSize));

        if (packetSize<1 || packetSize>(1024*1024)) {
            qDebug() << "Error: Logfile corrupted! Unlikely packet size: " << packetSize << "\n";
            QMessageBox::critical(new QWidget(),"Corrupted file", "Incorrect packet size. Stopping export. Data up to this point will be saved.");

            break;
        }

        if(logFile.bytesAvailable() < packetSize) {
            break;
        }

        // Read the data packet from the file.
        QByteArray dataBuffer;
        dataBuffer.append(logFile.read(packetSize));

        // Parse the packet. This operation passes the data to the kmlTalk object, which internally parses the data
        // and then emits objectUpdated(UAVObject *) signals. These signals are connected to in the KmlExport constructor.
        for (int i=0; i < dataBuffer.size(); i++) {
            kmlTalk->processInputByte(dataBuffer[i]);
        }

        timeStampIdx++;
    }

    stopExport();
}
void KisAnimationExporter::frameReadyToSave()
{
    QString frameNumber = QString("%1").arg(m_d->currentFrame, 4, 10, QChar('0'));
    QString filename = m_d->filenamePrefix + frameNumber + m_d->filenameSuffix;

    if (m_d->tmpDoc->exportDocument(QUrl::fromLocalFile(filename))) {

        if (m_d->exporting && m_d->currentFrame < m_d->lastFrame) {
            if (!m_d->batchMode) {
                emit m_d->document->sigProgress((m_d->currentFrame - m_d->firstFrame) * 100 /
                                                (m_d->lastFrame - m_d->firstFrame));
            }
            m_d->currentFrame++;
            m_d->image->animationInterface()->requestFrameRegeneration(m_d->currentFrame, m_d->image->bounds());
            return; //continue
        }
    } else {
        //error
        m_d->status = KisImportExportFilter::InternalError;
    }
    stopExport(); //finish
}
void KisAnimationExporter::cancel()
{
    m_d->status = KisImportExportFilter::ProgressCancelled;
    stopExport();
}