示例#1
0
QProgressBar* USNavigation::CreateRangeMeter(int i)
{
  mitk::DataNode::Pointer zone = m_Zones.at(i);

  float zoneColor[3];
  bool success = m_Zones.at(i)->GetColor(zoneColor);
  QString zoneColorString = "#555555";
  if (success)
  {
    QString zoneColorString = QString("#%1%2%3").arg(static_cast<unsigned int>(zoneColor[0]*255), 2, 16, QChar('0'))
      .arg(static_cast<unsigned int>(zoneColor[1]*255), 2, 16, QChar('0')).arg(static_cast<unsigned int>(zoneColor[2]*255), 2, 16, QChar('0'));
  }

  QProgressBar* meter = new QProgressBar();
  meter->setMinimum(0);
  meter->setMaximum(100);
  meter->setValue(0);
  QString zoneName = zone->GetName().c_str();
  meter->setFormat(zoneName + ": No Data");
  QString style = m_RangeMeterStyle;
  style = style.replace("#StartColor#", zoneColorString);
  style = style.replace("#StopColor#", zoneColorString);
  meter->setStyleSheet(style);
  meter->setVisible(true);
  return meter;
}
void RenderWindow::slotUpdateProgressAndStatus(const QString &text, const QString &progressText,
    double progress, cProgressText::enumProgressType progressType)
{
  ui->statusbar->showMessage(text, 0);
  QProgressBar *progressBar = NULL;
  bool isQueue = this->sender() && this->sender()->objectName() == "Queue";
  switch (progressType)
  {
    case cProgressText::progress_IMAGE:
      if (isQueue) progressBar = gMainInterface->progressBarQueueImage;
      else progressBar = gMainInterface->progressBar;
      break;
    case cProgressText::progress_ANIMATION:
      if (isQueue) progressBar = gMainInterface->progressBarQueueAnimation;
      else progressBar = gMainInterface->progressBarAnimation;
      break;
    case cProgressText::progress_QUEUE:
      // nothing to be done, no progress bar for queue in GUI
      break;
  }

  if (progressBar)
  {
    if (!progressBar->isVisible())
    {
      progressBar->setVisible(true);
    }
    progressBar->setValue(progress * 1000.0);
    progressBar->setTextVisible(true);
    progressBar->setFormat(progressText);
  }
}
void RenderWindow::slotUpdateProgressHide(cProgressText::enumProgressType progressType)
{
	QProgressBar *progressBar = NULL;
	switch (progressType)
	{
		case cProgressText::progress_IMAGE: progressBar = gMainInterface->progressBar; break;
		case cProgressText::progress_ANIMATION:
			progressBar = gMainInterface->progressBarAnimation;
			break;
		case cProgressText::progress_QUEUE:
			// nothing to be done, no progress bar for queue in GUI
			break;
	}

	if (progressBar)
	{
		if (progressBar->isVisible()) progressBar->setVisible(false);
	}
}
示例#4
0
void
MolTableView::setMol( adchem::SDFile& file, QProgressBar& progressBar )
{
    if ( file ) {
        adcontrols::ChemicalFormula cformula;

        qtwrapper::waitCursor wait;

        //RDKit::SDMolSupplier& supplier = file.molSupplier();
		model_->setRowCount( file.size() );

        progressBar.setRange( 0, file.size() );
        progressBar.setVisible( true );
        progressBar.setTextVisible( true );

		size_t idx = 0;
		for ( auto mol: file ) {
            progressBar.setValue( idx + 1 );
            try {
                size_t col = 0;
                std::string smiles = RDKit::MolToSmiles( mol );
                if ( ! smiles.empty() ) {
                    model_->setData( model_->index( idx, col++ ), smiles.c_str() );
                    
                    // SVG
                    std::string svg = adchem::drawing::toSVG( mol );
                    model_->setData( model_->index( idx, col ), QByteArray( svg.data(), svg.size() ) );
                    model_->item( idx, col )->setEditable( false );
                }
                col = 2;
                try {
                    mol.updatePropertyCache( false );
                    std::string formula = RDKit::Descriptors::calcMolFormula( mol, true, false );
                    model_->setData( model_->index( idx, col++ ), QString::fromStdString( formula) );
                    model_->setData( model_->index( idx, col++), cformula.getMonoIsotopicMass( formula ) );
                } catch ( std::exception& ex ) {
                    ADDEBUG() << ex.what();
                }
                col = 4;
                // associated data
                std::map< std::string, std::string > data;
                adchem::SDFile::iterator it = file.begin() + idx;
                if ( adchem::SDFile::parseItemText( it.itemText(), data ) ) {
                    for ( auto tag: tags ) {
                        auto it = data.find( tag );
                        if ( it != data.end() )
                            model_->setData( model_->index( idx, col ), it->second.c_str() );
                        ++col;
                    }
				}
				if ( idx == 10 )
					this->update();
            } catch ( std::exception& ex ) {
                ADDEBUG() << boost::current_exception_diagnostic_information() << ex.what();
            } catch ( ... ) {
                ADDEBUG() << boost::current_exception_diagnostic_information();
            }
            ++idx;
        }
        progressBar.setVisible( false );
    }
}