void ProgressBar::changed(ConstFieldMaskArg whichField, 
                            UInt32            origin,
                            BitVector         details)
{
    Inherited::changed(whichField, origin, details);

    //Do not respond to changes that have a Sync origin
    if(origin & ChangedOrigin::Sync)
    {
        return;
    }

    if((whichField & SizeFieldMask))
    {
        setupProgressBar();
    }
    if(whichField & RangeModelFieldMask)
    {
        _ProgressStateChangedConnection.disconnect();
        if(getRangeModel() != NULL)
        {
            _ProgressStateChangedConnection = getRangeModel()->connectStateChanged(boost::bind(&ProgressBar::handleProgressStateChanged, this, _1));
        }
    }
}
示例#2
0
void ProgressBar::setupIndeterminateProgressBar(const Time& Elps)
{
	_IndeterminateBarPosition += Elps * getIndeterminateBarMoveRate();
	if(_IndeterminateBarPosition > 2.0)
	{
		_IndeterminateBarPosition -= 2.0f*osgFloor(_IndeterminateBarPosition/2.0f);
	}
	setupProgressBar();
}
示例#3
0
void ProgressBar::handleProgressStateChanged(ChangeEventDetails* const e)
{
	setupProgressBar();
}
示例#4
0
void ProgressBar::endIndeterminate(void)
{
    setIndeterminate(false);
    _ProgressUpdateConnection.disconnect();
    setupProgressBar();
}
示例#5
0
bool FastaReader::readFile(QString fileName)
{
    string file = fileName.toStdString();

    //Make sure that we were requested to open a file
    if(file.empty())
    {
        return false;
    }
    ui->print(file);

    setupProgressBar();

    //Parse the name of the chromosome from the file name and send it to glwidget to be stored
    storeChrName(file);

    //Clear out anything that may be left in the sequence string and set initial pad character
    sequence.clear();
    sequence = "";
    sequence.reserve(5);
    sequence = string(">");

    //Clear out anything that may be in the ifstream then open the new file
    wordfile.clear();
    wordfile.open(file.c_str(), ifstream::in | ifstream::binary);
    //See if we opened the file successfully
    if(wordfile.fail())
    {
        ErrorBox msg("Could not read the file. Either Skittle doesn't have file permissions or the file does not exist.");
        return false;
    }

    //Get how many characters are in the file
    wordfile.seekg(0, ios::beg);
    int begin = wordfile.tellg();
    wordfile.seekg(0, ios::end);
    int end = wordfile.tellg();
    bytesInFile = end - begin;

    //Discovered Reserve is different than malloc by creating a memory iterator
    //The iterator takes old size, then virtually allocates a new vector to new size while at the same time copying start/end memory to this new location
    //Then it destroys the old vector and walks through physical storage looking for a contiguous slot open, then dumps into the start and end location of new slot
    sequence.reserve(bytesInFile);

    //Start progress bar at 0
    int progress = bytesInFile / 20;
    progressBar->setValue(progress);

    QApplication::processEvents();

    //Return to the beginning of the file
    wordfile.seekg(0, ios::beg);
    //Skip the first line of the file as this is the chromosome name/info
    wordfile.ignore(500, '\n');

    //Read in the rest of the file
    char current;
    int i = 0;
    cancelled = false;
    do
    {
        //If the cancel button was pushed, go ahead and exit fasta reader
        if(cancelled){
            return false;
        }

        //Read the next character
        wordfile >> current;

        //If it is a letter, uppercase it
        current = upperCase(current);

        //if(current == 65 || current == 67 || current == 71 || current == 84 || current == 78) //A C G T N
        if(current != '\n' && current != '\r')
        {
            sequence.push_back(current);
        }

        if(i != 0 && i % progress == 0)
        {
            progressBar->setValue(progressBar->value() + 5);
            QApplication::processEvents();
        }

        i++;
    }
    while(!wordfile.eof() && !wordfile.fail() && !cancelled);

    //Close up everything
    progressBar->reset();
    progressBar->close();
    if(progressBar)
    {
        delete progressBar;
        progressBar = NULL;
    }
    wordfile.close();

    ui->print("Done loading file!");
    emit newFileRead(seq());

    return true;
}