Example #1
0
void Widget3D::show_hide_actor(QListWidgetItem * itemDuble){

  itemDuble->setSelected(true);

  bool visible = m_source_list.at(m_actor_list->row(itemDuble))->getRepresentation(this->m_RenderView)->isVisible();

  for(int i=0;i<m_actor_list->selectedItems().size();++i)
  {
      QListWidgetItem * item = m_actor_list->selectedItems().at(i);

      //if actor is visible
      if(visible){
        //Hide actor/region : Change icon and text color
        item->setTextColor(Qt::gray);
        item->setIcon(QIcon(":/paraview_icons/pqEyeballd16.png"));
      }else{
        //Show actor/region : Change icon and text color
        item->setTextColor(Qt::black);
        item->setIcon(QIcon(":/paraview_icons/pqEyeball16.png"));
      }

      //Set actor/region visibility
      m_source_list.at(m_actor_list->selectionModel()->selectedRows().at(i).row())
          ->getRepresentation(this->m_RenderView)->setVisible(!visible);

  }

  //be sure the mesh is updated
  m_RenderView->getWidget()->update();
  reset_camera();

}
Example #2
0
Void CViewLog::OnLog( UInt32 lvl, String header, String msg )
{
	Char out[1024];

	if( header )
		Sb::StringSetFormattedText(out, 1024, "%s - %s", header, msg );
	else
		Sb::StringSetFormattedText(out, 1024, "%s", msg );

	QListWidgetItem* item = new QListWidgetItem( out );

	if( lvl == Sb::CLogger::nLevel_Info )
	{
        item->setTextColor( QColor( 40,40,40 ) );
	}
	else if( lvl == Sb::CLogger::nLevel_Warning )
	{
		item->setTextColor( QColor( 255, 127, 0 ) );
	}
	else if( lvl == Sb::CLogger::nLevel_Error )
	{
		item->setTextColor( QColor( 255, 0, 0 ) );
	}
	
	m_TextOutput->addItem( item );
	m_TextOutput->scrollToItem( item );
}
Example #3
0
BOOST_FOREACH( std::list< qt4::QMessage>::const_reference message, messageList ) {
		QListWidgetItem *item = new QListWidgetItem();
		std::stringstream logStream;
		logStream << message.m_module << "(" << message.time_str << ") -> " << message.message ;
		item->setText( logStream.str().c_str() );

		switch ( message.m_level ) {
		case error:

			if( m_Interface.errorCheck->checkState() == Qt::Checked ) {
				item->setTextColor( Qt::red );
				m_Interface.logList->addItem( item );
			}

			break;
		case warning:

			if( m_Interface.warningCheck->checkState() == Qt::Checked ) {
				item->setTextColor( QColor( 218, 165, 32 ) );
				m_Interface.logList->addItem( item );
			}

			break;
		case info:

			if( m_Interface.infoCheck->checkState() == Qt::Checked ) {
				item->setTextColor( Qt::darkBlue );
				m_Interface.logList->addItem( item );
			}

			break;
		case verbose_info:

			if( m_Interface.verboseCheck->checkState() == Qt::Checked ) {
				item->setTextColor( Qt::black );
				m_Interface.logList->addItem( item );
			}

			break;
		case notice:

			if( m_Interface.noticeCheck->checkState() == Qt::Checked ) {
				item->setTextColor( QColor( 34, 139, 34 ) );
				m_Interface.logList->addItem( item );
			}

			break;
		}

	}
Example #4
0
void DeviceDiscoveryDialog::pairingDone(const QBluetoothAddress &address, QBluetoothLocalDevice::Pairing pairing)
{
    QList<QListWidgetItem *> items = ui->list->findItems(address.toString(), Qt::MatchContains);

    if (pairing == QBluetoothLocalDevice::Paired || pairing == QBluetoothLocalDevice::AuthorizedPaired ) {
        for (int var = 0; var < items.count(); ++var) {
            QListWidgetItem *item = items.at(var);
            item->setTextColor(QColor(Qt::green));
        }
    } else {
        for (int var = 0; var < items.count(); ++var) {
            QListWidgetItem *item = items.at(var);
            item->setTextColor(QColor(Qt::red));
        }
    }
}
Example #5
0
void DeviceDiscoveryDialog::addDevice(const QBluetoothDeviceInfo &info)
{
    QString label = QString("%1 %2").arg(info.address().toString()).arg(info.name());
    QList<QListWidgetItem *> items = ui->list->findItems(label, Qt::MatchExactly);
    if(items.empty()) {
        QListWidgetItem *item = new QListWidgetItem(label);
        QBluetoothLocalDevice::Pairing pairingStatus = localDevice->pairingStatus(info.address());
        if (pairingStatus == QBluetoothLocalDevice::Paired || pairingStatus == QBluetoothLocalDevice::AuthorizedPaired )
            item->setTextColor(QColor(Qt::green));
        else
            item->setTextColor(QColor(Qt::black));

        ui->list->addItem(item);
    }

}
Example #6
0
void Dialog::on_pushButton_clicked()
{
    QListWidgetItem *itm = ui->listWidget->currentItem();
    itm->setText("Fuzzy bunny");
    itm->setTextColor(Qt::cyan);
    itm->setBackgroundColor(Qt::black);
}
//----------------------------------------------------
void MainWindow::onADBErrorReadyRead()
{
	QProcess* process = (QProcess*) QObject::sender();

	QByteArray stdErr = process->readAllStandardError();
	QString stdErrLine = QString(stdErr).trimmed();

	if (stdErrLine.contains("device not found"))
	{
		mServiceShouldRun = false;
		QMessageBox::critical(this, "Device not found or unplugged", "Cannot find an Android device connected via ADB. Make sure USB Debugging is enabled on your device, and that the ADB drivers are installed. Follow the guide on our website for more information.");
	}
	else if (stdErrLine.contains("device offline")) 
	{
		mServiceShouldRun = false;
		QMessageBox::critical(this, "Device offline", "An Android device is connected but reports as offline. Check your device for any additional information, or try to unplug and replug your device");
	}
	else if (stdErrLine.contains("unauthorized"))
	{
		mServiceShouldRun = false;
		QMessageBox::critical(this, "Device unauthorized", "An Android device is connected but reports as unauthorized. Please check the confirmation dialog on your device.");
	}

	if (!stdErrLine.isEmpty())
	{
		mADBErrorLog.push_back(stdErrLine);

		if (mDebugWidget != nullptr)
		{
			QListWidgetItem* item = new QListWidgetItem(stdErrLine);
			item->setTextColor(QColor(255, 0, 0));
			mDebugWidget->addItem(item);
		}
	}
}
bool AnnotationConfigurationHandler::startElement( 
    const QString & /* namespaceURI */,
    const QString & /* localName */,
    const QString &qName,
    const QXmlAttributes &attributes )
{
  if ( !metAnnotationConfigurationTag && qName != "annotationConfiguration" )
  {
    errorStr = QObject::tr( "The file is not an Annotation Configuration file." );
    return false;
  }

  if ( qName == "annotationConfiguration" )
  {
    metAnnotationConfigurationTag = true;
  }
  else if ( qName == "entity" )
  {
    QListWidgetItem *item = new QListWidgetItem(listWidget);
    item->setFlags( item->flags() | Qt::ItemIsEditable );
    if (m_isEditor)
    {
      item->setFlags( item->flags() | Qt::ItemIsUserCheckable);
    }
    item->setText( attributes.value( "name" ) );
    QColor color( attributes.value( "color" ) );
    QColor white( Qt::white );
    QBrush brush( color );
    
    colors->push_back( QColor( attributes.value( "color" ).toLower() ) );
    (*colorNames2EntityTypes)[attributes.value( "color" ).toLower()] = attributes.value( "name" );
    /// @todo setBackgroundColor is deprecated in QT 4.2, replace by
    /// setBackground below after upgrading.
    /// item->setBackgroundColor  ( QColor( attributes.value( "color" ) ) );
    if (attributes.value("recursive") == "true")
    {
      m_recursiveEntityTypes->push_back(attributes.value( "name" ));
      QFont font = item->font();
      font.setItalic(true);
      font.setBold(true);
      item->setFont(font);
      if (m_isEditor)
      {
        item->setCheckState(Qt::Checked);
      }
    }
    else
    {
      if (m_isEditor)
      {
        item->setCheckState(Qt::Unchecked);
      }
    }
    item->setBackground  ( brush );
    item->setTextColor  ( white );
  }

  return true;
}
Example #9
0
void Class20::on_pushButton_clicked()
{
	//ui.listWidget->currentItem()->setText("Busy Boy");
	QListWidgetItem *itm = ui.listWidget->currentItem();
	itm->setText("Busy Boy");
	itm->setTextColor(Qt::red);
	itm->setBackgroundColor(Qt::black);
}
Example #10
0
void MyDialog::on_pushButton_2_clicked()
{
    //ui->listWidget->currentItem()->setText("Fussy");
    QListWidgetItem *item = ui->listWidget->currentItem();
    item->setText("Fussy bunny");
    item->setTextColor(Qt::red);
    item->setBackground(Qt::black);
}
Example #11
0
//-----------------------------------------------------------------------------------------------------------------------------
void Console::addItem(QString texte, QColor couleur, bool gras)
{
    QListWidgetItem *item = new QListWidgetItem(texte);
    QFont grasFont;
    grasFont.setBold(gras);
    item->setFont(grasFont);
    item->setTextColor(couleur);
    liste->addItem(item);

    emit newItem(liste->item(liste->count()-1));
}
Example #12
0
void Dialog::on_pushButton_clicked()
{
    // create a pointer to the current item..
    // easier than writing this code over and over again
    // D.R.Y. !!
    QListWidgetItem *item = ui->listWidget->currentItem();

    // plethora of things you can do with the list widget item
    // QListWidgetItem is a class from the QListWidget class
    item->setText("Chubby Bunny");
    item->setTextColor(Qt::white);
    item->setBackgroundColor(Qt::black);
}
//----------------------------------------------------
void MainWindow::onClickShowDebugLog()
{
	if (mDebugWidget != nullptr) {
		delete mDebugWidget;
	}
	mDebugWidget = new QListWidget();
	mDebugWidget->addItems(mADBLog);

	for (auto it = mADBErrorLog.begin(); it != mADBErrorLog.end(); ++it) {
		QListWidgetItem* item = new QListWidgetItem(*it);
		item->setTextColor(QColor(255, 0, 0));
		mDebugWidget->addItem(item);
	}

	mDebugWidget->show();
}
Example #14
0
void ezQtDataDirsDlg::FillList()
{
  if (m_Config.m_DataDirs.IsEmpty())
    m_iSelection = -1;

  if (m_iSelection != -1)
    m_iSelection = ezMath::Clamp<ezInt32>(m_iSelection, 0, m_Config.m_DataDirs.GetCount() - 1);

  ListDataDirs->blockSignals(true);

  ListDataDirs->clear();

  for (auto dd : m_Config.m_DataDirs)
  {
    QListWidgetItem* pItem = new QListWidgetItem(ListDataDirs);
    pItem->setFlags(Qt::ItemFlag::ItemIsEnabled | Qt::ItemFlag::ItemIsSelectable /*| Qt::ItemFlag::ItemIsUserCheckable*/);

    QString sPath = QString::fromUtf8(dd.m_sDataDirSpecialPath.GetData());

    pItem->setText(sPath);
    ListDataDirs->addItem(pItem);

    if (dd.m_bHardCodedDependency)
    {
      QColor col;
      col.setNamedColor("Orange");
      pItem->setTextColor(col);
      pItem->setToolTip("This data directory is a hard dependency and cannot be removed.");
      pItem->setData(Qt::UserRole + 1, false); // can remove ?
    }
    else
    {
      pItem->setData(Qt::UserRole + 1, true); // can remove ?
    }
  }

  ListDataDirs->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection);

  if (m_iSelection == -1)
    ListDataDirs->clearSelection();
  else
    ListDataDirs->setItemSelected(ListDataDirs->item(m_iSelection), true);

  ListDataDirs->blockSignals(false);

  on_ListDataDirs_itemSelectionChanged();
}
Example #15
0
void AutoImportWindow::resetSelectedScriptsContainer() {
    selectedScriptsCont->clear();
    whileImportScriptCount_ = 0;
    QStringList importScripts = ProjectPreferences().scripts("import");
    for(QString script : importScripts) {
        QListWidgetItem* item = new QListWidgetItem(script);
        item->setTextColor(Qt::blue);
        selectedScriptsCont->addItem(item);
        whileImportScriptCount_++;
    } 
    
    QStringList selectedScripts = ProjectPreferences().scripts("process");
    for(QString script : selectedScripts) {
        QListWidgetItem* item = new QListWidgetItem(script);
        selectedScriptsCont->addItem(item);
    }    
}
void TikzCommandInserter::addListWidgetItems(QListWidget *listWidget, const TikzCommandList &commandList, bool addChildren)
{
	QFont titleFont = qApp->font();
	titleFont.setBold(true);
//	QColor titleBg(QApplication::style()->standardPalette().color(QPalette::Normal, QPalette::Highlight));
//	titleBg = titleBg.lighter(120);
	QColor titleBg(QApplication::style()->standardPalette().color(QPalette::Normal, QPalette::Window));
	titleBg = titleBg.darker(200);
	QColor titleFg(QApplication::style()->standardPalette().color(QPalette::Normal, QPalette::HighlightedText));
	QColor separatorBg(QApplication::style()->standardPalette().color(QPalette::Normal, QPalette::AlternateBase));
	if (separatorBg == QApplication::style()->standardPalette().color(QPalette::Normal, QPalette::Base))
		separatorBg = separatorBg.darker(110);

	for (int i = 0; i < commandList.commands.size(); ++i)
	{
		if (commandList.commands.at(i).type == -1) // if we have an empty command corresponding to a submenu, then don't add the command, the submenus will be added later
			continue;

		QListWidgetItem *item = new QListWidgetItem(listWidget);
		QString itemText = commandList.commands.at(i).name;
		item->setText(itemText.remove('&'));

		if (itemText.isEmpty())
			item->setBackgroundColor(separatorBg);
		else
			item->setData(Qt::UserRole, commandList.commands.at(i).number); // link to the corresponding item in m_tikzCommandsList
	}

	if (!addChildren) return;

	for (int i = 0; i < commandList.children.size(); ++i)
	{
		QListWidgetItem *item = new QListWidgetItem(listWidget);
		QString itemText = commandList.children.at(i).title;
		item->setText(itemText.remove('&'));

		item->setBackgroundColor(titleBg);
		item->setTextColor(titleFg);
		item->setFont(titleFont);

		addListWidgetItems(listWidget, commandList.children.at(i));
	}
}
Example #17
0
/**
 * @brief MainWindow::chargerListWidgetProduits
 * Vide la liste widget produit
 * Charge la combobox avec les rayons
 * Vide les vecteur associés a la liste widget produits
 * Charge la listWidgetProduits avec les produits dans les rayons
 */
void MainWindow::chargerListWidgetProduits(){
    //vide la liste widget produit
    ui->listWidgetProduits->clear();
    //charge la combobox avec les rayons
    chargerComboBoxRayons();
    //vide les vecteur associés a la liste widget produits
    vectorRayonsProduits.clear();
    vectorPositionInListOfRayon.clear();
    int i=0;
    QString rayon;
    //requete qui permet d'afficher les produits dans les rayons
    QSqlQuery req("select produitId, produitLib, rayonLib from produit natural join rayon where produitLib like '%"+ui->lineEditRechercheProduits->text()+"%' order by rayonId , produitLib");
    while(req.next())
    {
        QListWidgetItem *item;
        if(req.value(2).toString()!=rayon) // si on change de rayon
        {
            item=new QListWidgetItem(req.value(2).toString());
            item->setBackground(Qt::gray);//change le fond en gris (ligne du rayon)
            item->setTextColor(Qt::white);//change la couleur en blanc (ligne du rayon)
            item->setTextAlignment(Qt::AlignCenter);//centre le rayon au milieu de la listwidget
            item->setFlags(Qt::ItemIsEnabled);//empéche le clique sur le rayon
            item->setToolTip("Rayon");//définie le tooltip si rayon
            vectorPositionInListOfRayon.push_back(i);
            vectorRayonsProduits.push_back(req.value(2).toString());
            ui->listWidgetProduits->addItem(item);
            rayon=req.value(2).toString();
            i++;
        }
        item=new QListWidgetItem(req.value(1).toString());
        item->setToolTip("Produit");//définie le tooltip si produit
        vectorRayonsProduits.push_back(req.value(0).toString());
        ui->listWidgetProduits->addItem(item);
        i++;
    }
    if(i==0)
    {
        ui->listWidgetProduits->addItem("Aucun produit trouvé");

    }
}
Example #18
0
void MobileApp::updateDownloadableList()
{
    QList <QString> dl;
    groups.clear();

    ReadFileToList(SAVEDBOOKLIST, dl, "UTF-8");
    parseDLFile(dl);

    //show aprorpriate widgets
    ui->downloadSTKWidget->setCurrentIndex(1);


    //Clear the old list
    ui->downloadListWidget->clear();

    //Build the new list
    for (int i=0; i<groups.size(); i++)
    {
        if (groups[i].downloadState != 0)
        {
            QListWidgetItem *lwi;
            lwi= new QListWidgetItem(groups[i].name + " (" + QString::number(groups[i].downloadSize)
                                     + /* "/" + QString::number(groups[i].fullSize) + */ " MB)");
            if (autoInstallKukBooksFlag && groups[i].name.contains("הרחבה"))
                lwi->setCheckState(Qt::Checked);
            else
                lwi->setCheckState(Qt::Unchecked);
            lwi->setWhatsThis(stringify(i));
            lwi->setToolTip("False");
            if(groups[i].hidden)
                lwi->setTextColor(QColor("gray"));

            ui->downloadListWidget->addItem(lwi);
            ui->downloadListWidget->setEnabled(true);
        }
    }

    if(autoInstallKukBooksFlag)
        downloadStart();

}
Example #19
0
void WtEditor::logCallback(void* opaque, const tdchar* tag, enum TdTraceLevel level, const tdchar* message){
	WtEditor* thiz = static_cast<WtEditor*>(opaque);

	QListWidgetItem* item = new QListWidgetItem(thiz->ui.logList);

	item->setText(QString(tag) + " : " + message);

	QColor color;

	switch(level){
	case eTD_LEVEL_VERBOSE:
		color = QColor(127, 127, 127);
		break;
	case eTD_LEVEL_DEBUG:
		color = QColor(255, 255, 255);
		break;
	case eTD_LEVEL_INFO:
		color = QColor(0, 255, 0);
		break;
	case eTD_LEVEL_WARNING:
		color = QColor(255, 100, 100);
		break;
	case eTD_LEVEL_ERROR:
		color = QColor(255, 0, 0);
		break;
	}

	item->setBackgroundColor(QColor(0, 0, 0));
	item->setTextColor(color);

	thiz->ui.logList->addItem(item);

	thiz->ui.logList->scrollToItem(item);
	thiz->ui.logList->setCurrentItem(item);

	if(thiz->ui.logList->count() > 10){
		thiz->ui.logList->removeItemWidget( thiz->ui.logList->item(0) );
		//delete thiz->ui.logList->takeItem(0);
	}
}
FileExplorer::FileExplorer(QWidget *parent)
    : QWidget(parent)
{
    QVBoxLayout *mainLayout = new QVBoxLayout(this);
    QHBoxLayout *modeLayout = new QHBoxLayout();
    mainLayout->addLayout(modeLayout);

    QLabel *label = new QLabel();
    modeLayout->addWidget(label, 1);
    m_modeCombo = new QComboBox();
    m_modeCombo->addItem("List");
    m_modeCombo->addItem("Icon");
    connect(m_modeCombo, SIGNAL(currentTextChanged(QString))
            ,this, SLOT(onViewModeChanged(QString)));
    modeLayout->addWidget(m_modeCombo);
    m_list = new QListWidget();
    connect(m_list, SIGNAL(currentTextChanged(QString)),
            label, SLOT(setText(QString)));
    QListWidgetItem *item = new QListWidgetItem(
                QIcon(":/folder"), "folder");
    item->setTextColor(Qt::blue);
    m_list->addItem(item);
    item = new QListWidgetItem(
                QIcon(":/images/videoFile.png"), "one.mp4");
    m_list->addItem(item);
    item = new QListWidgetItem(
                QIcon(":/images/audioFile.png"), "love.mp3");
    m_list->addItem(item);
    m_list->addItem(new QListWidgetItem(
                        QIcon(":/images/imageFile.png"), "love.mp3"));
    m_list->addItem("text file.txt");
    mainLayout->addWidget(m_list, 1);
    m_list->setSelectionMode(QAbstractItemView::SingleSelection);
    m_list->setSpacing(6);
    m_list->setCurrentRow(0);
}
Example #21
0
void GroupTab::consolidatePeers(map<string,string> peers, map<QString,Tab*> *tabPt, QTabWidget *tabs) {
	/*
	* TODO:
	* Cleanup this entire function
	*/
	// Create map of peers by IP
	map<string,string> peers_by_IP;
	map<string,string>::iterator it0;
	for (it0 = peers.begin(); it0 != peers.end(); it0++) {
		peers_by_IP.insert(std::pair<string,string>(it0->second,it0->first));
	}
	// Create a map of tabs open by <IP:Port,*Tab>
	map<QString,Tab*> ipMap;
	map<QString,Tab*>::iterator it1;
	for (it1 = tabPt->begin(); it1 != tabPt->end(); it1++) {
		ipMap.insert(std::pair<QString,Tab*>(it1->second->toolTip(),it1->second));
		// If peer has disconnected disable tab
		if (it1->second->tabType().compare("PEER") == 0 &&
		        peers_by_IP.find(it1->second->toolTip().toStdString()) == peers_by_IP.end()) {
			it1->second->setEnabled(false);
		}
	}

	// Iterator for peer map
	map<string,string>::iterator it;

	// Clear old peers
	online->clear();

	for (it=peers.begin(); it != peers.end(); it++) {
		// Check if tab is open by IP
		map<QString,Tab*>::iterator oldTab = ipMap.find(QString::fromStdString(it->second));
		if (oldTab != ipMap.end()) {
			// If open, enable and set nickname
			oldTab->second->setEnabled(true);
			// Change peername in tabPt
			tabPt->erase(tabs->tabText(tabs->indexOf(oldTab->second)));
			tabPt->insert(std::pair<QString,Tab*>(QString::fromStdString(it->first),oldTab->second));
			// Set tab text to new peer name
			tabs->setTabText(tabs->indexOf(oldTab->second),QString::fromStdString(it->first));
			// Change peer name in PeerTab, so it sends to the right person
			(static_cast<PeerTab *>(oldTab->second))->peer(QString::fromStdString(it->first));
		}

		QListWidgetItem *item = new QListWidgetItem(QString::fromStdString(it->first));

		// Set tooltip as IP:Port
		item->setToolTip(QString::fromStdString(it->second));

		online->addItem(item);
		// Check if it's you
		if (client->nick().compare(it->first) == 0) {
			// Set background color to red
			item->setBackgroundColor(QColor(255,0,0,20));
		} else {
			// Assign color to peers
			// Make it look good to (use scaling hue along HSV scale)
			item->setTextColor(QColor::fromHsv(nextHue(),255,175));
		}
	}
}
bool FormMaterialIndicesManager::updateMaterials(QImage& image){
    bSkipUpdating = true;

    // Calculate image color map
    colorIndices.clear();
    for(int w = 0 ; w < image.width() ; w++){
        for(int h = 0 ; h < image.height() ; h++){
            QRgb pixel          = image.pixel(w,h);
            QColor bgColor = QColor(pixel);
            int indeks = bgColor.red()*255*255 + bgColor.green()*255 + bgColor.blue();
            colorIndices[indeks] = pixel;

    }}
    if(colorIndices.size() > 32){
    QMessageBox msgBox;
        msgBox.setText("Error: too much colors!");
        msgBox.setInformativeText(" Sorry, but this image does not look like a material texture.\n"
                                  " Your image contains more than 32 different colors");
        msgBox.setStandardButtons(QMessageBox::Cancel);
        msgBox.exec();
        bSkipUpdating = false;
        return false;
    }

    typedef std::map<int,QRgb>::iterator it_type;
    ui->listWidgetMaterialIndices->clear();

    // generate materials list
    int indeks = 1;
    for(it_type iterator = colorIndices.begin(); iterator != colorIndices.end(); iterator++) {
           qDebug() << "Material index:  " << iterator->first << " Color :" << QColor(iterator->second);

           QListWidgetItem* pItem =new QListWidgetItem("Material"+QString::number(indeks++));
           QColor mColor = QColor(iterator->second);
           pItem->setForeground(mColor); // sets red text
           pItem->setBackground(mColor); // sets green background
           QColor textColor = QColor(255-mColor.red(),255-mColor.green(),255-mColor.blue());
           pItem->setTextColor(textColor);
           ui->listWidgetMaterialIndices->addItem(pItem);

    }


    qDebug() << "Updating material indices. Total indices count:" << ui->listWidgetMaterialIndices->count();
    for(int i = 0 ; i < METALLIC_TEXTURE ; i++){
        materialIndices[i].clear();
        for(int m = 0 ; m < ui->listWidgetMaterialIndices->count() ; m++){
            QString m_name = ui->listWidgetMaterialIndices->item(m)->text();
            FBOImageProporties tmp;
            tmp.copySettings(imagesPointers[i]->imageProp);
            materialIndices[i][m_name] = tmp;
        }
    }


    lastMaterialIndex = 0;
    QString cText = ui->listWidgetMaterialIndices->item(lastMaterialIndex)->text();
    ui->listWidgetMaterialIndices->item(lastMaterialIndex)->setText(cText+" (selected material)");

    QColor bgColor = ui->listWidgetMaterialIndices->item(lastMaterialIndex)->backgroundColor();
    FBOImageProporties::currentMaterialIndeks = bgColor.red()*255*255 + bgColor.green()*255 + bgColor.blue();

    bSkipUpdating = false;



    return true;
}
Example #23
0
void ezTimeWidget::UpdateStats()
{
  if (!isVisible())
    return;

  if (!ezTelemetry::IsConnectedToServer())
  {
    ListClocks->setEnabled(false);
    return;
  }

  ListClocks->setEnabled(true);

  if (m_bClocksChanged)
  {
    m_bClocksChanged = false;

    ListClocks->blockSignals(true);
    ListClocks->clear();

    for (ezMap<ezString, ezTimeWidget::ClockData>::Iterator it = m_ClockData.GetIterator(); it.IsValid(); ++it)
    {
      ListClocks->addItem(it.Key().GetData());

      QListWidgetItem* pItem = ListClocks->item(ListClocks->count() - 1);
      pItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
      pItem->setCheckState (it.Value().m_bDisplay ? Qt::Checked : Qt::Unchecked);
      pItem->setData(Qt::UserRole, QString(it.Key().GetData()));

      pItem->setTextColor(s_Colors[it.Value().m_iColor % s_uiMaxColors]);

      it.Value().m_pListItem = pItem;
    }

    ListClocks->blockSignals(false);
  }

  QPainterPath pp[s_uiMaxColors];

  ezTime tMin = ezTime::Seconds(100.0);
  ezTime tMax = ezTime::Seconds(0.0);

  for (ezMap<ezString, ClockData>::Iterator it = s_pWidget->m_ClockData.GetIterator(); it.IsValid(); ++it)
  {
    if (it.Value().m_TimeSamples.IsEmpty() || !it.Value().m_bDisplay)
      continue;

    const ezUInt32 uiColorPath = it.Value().m_iColor % s_uiMaxColors;
    ClockData& Clock = it.Value();
    const ezDeque<TimeSample>& Samples = Clock.m_TimeSamples;

    ezUInt32 uiFirstSample = 0;

    while ((uiFirstSample < Samples.GetCount()) && (m_MaxGlobalTime - Samples[uiFirstSample].m_AtGlobalTime > m_DisplayInterval))
      ++uiFirstSample;

    if (uiFirstSample < Samples.GetCount())
    {
      pp[uiColorPath].moveTo (QPointF((Samples[uiFirstSample].m_AtGlobalTime - m_MaxGlobalTime).GetSeconds(), Samples[uiFirstSample].m_Timestep.GetSeconds()));

      for (ezUInt32 i = uiFirstSample + 1; i < Samples.GetCount(); ++i)
      {
        pp[uiColorPath].lineTo (QPointF ((Samples[i].m_AtGlobalTime - m_MaxGlobalTime).GetSeconds(), Samples[i].m_Timestep.GetSeconds()));

        tMin = ezMath::Min(tMin, Samples[i].m_Timestep);
        tMax = ezMath::Max(tMax, Samples[i].m_Timestep);
      }
    }
  }

  for (ezUInt32 i = 0; i < s_uiMaxColors; ++i)
    m_pPath[i]->setPath(pp[i]);

  // render the helper lines for time values
  {
    QPainterPath pMax;

    for (ezUInt32 i = 1; i < 10; ++i)
    {
      pMax.moveTo(QPointF (-m_DisplayInterval.GetSeconds(), ezTime::Milliseconds(10.0 * i).GetSeconds()));
      pMax.lineTo(QPointF (0, ezTime::Milliseconds(10.0 * i).GetSeconds()));
    }

    m_pPathMax->setPath(pMax);
  }

  ezTime tShowMax = ezTime::Seconds(1.0 / 10.0);

  for (ezUInt32 t = 25; t < 100; t += 25)
  {
    tShowMax = ezTime::Milliseconds(1) * t;

    if (tMax < tShowMax)
      break;
  }

  {
    TimeView->setSceneRect (QRectF (-m_DisplayInterval.GetSeconds(), 0, m_DisplayInterval.GetSeconds(), tShowMax.GetSeconds()));
    TimeView->fitInView    (QRectF (-m_DisplayInterval.GetSeconds(), 0, m_DisplayInterval.GetSeconds(), tShowMax.GetSeconds()));
  }

  // once a second update the display of the clocks in the list
  if (ezTime::Now() - m_LastUpdatedClockList > ezTime::Seconds(1))
  {
    m_LastUpdatedClockList = ezTime::Now();

    ezStringBuilder s;
    s.Format("Max: %.0fms", tShowMax.GetMilliseconds());
    LabelMaxTime->setText(s.GetData());

    for (ezMap<ezString, ezTimeWidget::ClockData>::Iterator it = m_ClockData.GetIterator(); it.IsValid(); ++it)
    {
      const ezTimeWidget::ClockData& Clock = it.Value();

      if (!Clock.m_pListItem || Clock.m_TimeSamples.IsEmpty())
        continue;

      ezStringBuilder sTooltip;
      sTooltip.Format("<p>Clock: %s<br>Max Time Step: <b>%.2fms</b><br>Min Time Step: <b>%.2fms</b><br></p>",
        it.Key().GetData(), Clock.m_MaxTimestep.GetMilliseconds(), Clock.m_MinTimestep.GetMilliseconds());

      Clock.m_pListItem->setToolTip(sTooltip.GetData());
    }
  }
}