JackPort JackClient::registerPort (const String& name, const String& type, int flags, int bufferSize) { returnValueIfNull (client, JackPort (*this)); String clientName = name; if (clientName.length() >= nameSize()) clientName = clientName.substring (0, nameSize()); jack_port_t* const cport = jack_port_register (client, clientName.toUTF8(), type.toUTF8(), flags, bufferSize); return JackPort (*this, cport); }
Action::ResultE LODSetupGraphOp::traverseEnter(Node * const node) { if(node->getCore()->getType().isDerivedFrom(DistanceLOD::getClassType())) { return Action::Skip; } // clear out the old sets _mSets.clear(); UInt32 numChildren = node->getNChildren(); // check node's children for LOD name tags. UInt32 i = 0; UInt32 j = 0; for(i = 0; i < numChildren; ++i) { const Char8 *namePtr = OSG::getName(node->getChild(i)); if(namePtr != NULL) { std::string curNodeName(namePtr ); size_t nameSize (curNodeName.size()); for(j = 0; j < _mLODs.size(); ++j) { // we only check for the tags at the end of the strings size_t searchLoc = (nameSize > _mLODs[j].mTag.size()) ? (nameSize - _mLODs[j].mTag.size()) : 0; size_t loc = curNodeName.find(_mLODs[j].mTag, searchLoc); if(loc != std::string::npos) { std::string baseName(curNodeName); baseName.erase(loc, _mLODs[j].mTag.size()); bool createNewSet = true; for(UInt32 k = 0; k < _mSets.size(); ++k) { if(baseName.compare(_mSets[k].mBaseName) == 0) { _mSets[k].addLODPair(_mLODs[j].mLOD, node->getChild(i)); createNewSet = false; break; } } if(createNewSet == true) { LODSet newSet; newSet.mBaseName = baseName; newSet.addLODPair(_mLODs[j].mLOD, node->getChild(i)); _mSets.push_back(newSet); break; } } }// end for(_mLODs.size()) } //end if(namePtr != NULL) } // end for(numChildren) // now we add as many LODs as we can int madeNow = 0; if(_mSets.size() > 0) { for(i = 0; i < _mSets.size(); ++i) { if(_mSets[i].mLODPairs.size() > 1) { DistanceLODRecPtr TheLODCore = DistanceLOD::create(); MFReal32 *ranges = TheLODCore->editMFRange(); NodeRecPtr newLODNode = Node::create(); newLODNode->setCore(TheLODCore); // also set the name of the node now OSG::setName(newLODNode, _mSets[i].mBaseName + "_LODNode"); node->addChild(newLODNode); bool centerIsSet = false; for(j = 0; j < _mSets[i].mLODPairs.size(); ++j) { LODPair cur = _mSets[i].mLODPairs[j]; if((cur.first != -1 ) && (cur.second != NULL) && (getRange(cur.first) > 0.0f) ) { ranges ->push_back(getRange(cur.first)); newLODNode->addChild (cur.second ); if(!centerIsSet) { Pnt3f volCenter; cur.second->getVolume().getCenter(volCenter); TheLODCore->setCenter(volCenter); centerIsSet = true; } madeNow++; } } } } if(madeNow > 0) { _totalNumMade += madeNow; return Action::Skip; } } return Action::Continue; }
void QTorrentItemDelegat::drawTorrent(QPainter* painter, const QStyleOptionViewItem& option, const Torrent& tor, const QModelIndex& index) const { QStyleOptionViewItemV4 opt = option; initStyleOption(&opt, index); QStyle* style; if(opt.widget != NULL) { style = opt.widget->style(); } else { style = QApplication::style(); } const int iconSize(style->pixelMetric(QStyle::PM_LargeIconSize)); QFont nameFont(option.font); nameFont.setWeight(QFont::Bold); const QFontMetrics nameFM(nameFont); const QIcon mimeIcon(tor.GetMimeTypeIcon()); QString nameStr(tor.GetName()); QSize nameSize(nameFM.size(0, nameStr)); QFont statusFont(option.font); statusFont.setPointSize(int (option.font.pointSize() * 0.9)); const QFontMetrics statusFM(statusFont); QString statusStr(GetStatusString(tor)); int statusWidth = statusFM.width(statusStr); QFont progressFont(statusFont); const QFontMetrics progressFM(progressFont); QString progressStr(GetProgressString(tor)); bool isPaused(tor.isPaused()); painter->save(); painter->setRenderHint(QPainter::Antialiasing); style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget); /* if (option.state & QStyle::State_Selected) { QPalette::ColorGroup cg = option.state & QStyle::State_Enabled ? QPalette::Active : QPalette::Disabled; if (cg == QPalette::Normal && !(option.state & QStyle::State_Active)) cg = QPalette::Inactive; painter->fillRect(option.rect, opt.backgroundBrush); }*/ //style->drawControl(QStyle::CE_ItemViewItem,&option,painter); QIcon::Mode im; if(isPaused || !(option.state & QStyle::State_Enabled)) { im = QIcon::Disabled; } else if(option.state & QStyle::State_Selected) { im = QIcon::Selected; } else { im = QIcon::Normal; } QIcon::State qs; if(isPaused) { qs = QIcon::Off; } else { qs = QIcon::On; } QPalette::ColorGroup cg = QPalette::Normal; if(isPaused || !(option.state & QStyle::State_Enabled)) { cg = QPalette::Disabled; } if(cg == QPalette::Normal && !(option.state & QStyle::State_Active)) { cg = QPalette::Inactive; } QPalette::ColorRole cr; if(option.state & QStyle::State_Selected) { cr = QPalette::HighlightedText; } cr = QPalette::Text; // layout const QSize m(margin(*style)); QRect fillArea(option.rect); fillArea.adjust(m.width(), m.height(), -m.width(), -m.height()); QRect iconArea(fillArea.x(), fillArea.y() + (fillArea.height() - iconSize) / 2, iconSize, iconSize); QRect nameArea(iconArea.x() + iconArea.width() + GUI_PAD, fillArea.y(), fillArea.width() - GUI_PAD - iconArea.width(), nameSize.height()); if (nameArea.width() + nameArea.x() > opt.rect.width()) { nameArea.setWidth(opt.rect.width() - nameArea.x()); } QRect barArea(nameArea.x(), nameArea.y() + statusFM.lineSpacing() + GUI_PAD / 2, nameArea.width(), BAR_HEIGHT); QRect progArea(nameArea.x(), barArea.y() + barArea.height() + GUI_PAD / 2, barArea.width() - statusWidth, nameArea.height()); QRect statusArea(progArea.x() + progArea.width(), progArea.y(), statusWidth, progArea.height()); if(tor.hasError()) { painter->setPen(QColor("red")); } else { painter->setPen(opt.palette.color(cg, cr)); } mimeIcon.paint(painter, iconArea, Qt::AlignCenter, im, qs); painter->setFont(nameFont); nameStr = nameFM.elidedText(nameStr, Qt::ElideRight, nameArea.width()); style->drawItemText(painter, nameArea, Qt::AlignLeft, opt.palette, option.state & QStyle::State_Enabled, nameStr); painter->setFont(statusFont); statusStr = statusFM.elidedText(statusStr, Qt::ElideRight, statusArea.width()); style->drawItemText(painter, statusArea, Qt::AlignRight, opt.palette, option.state & QStyle::State_Enabled, statusStr); painter->setFont(progressFont); progressStr = statusFM.elidedText(progressStr, Qt::ElideRight, progArea.width()); style->drawItemText(painter, progArea, Qt::AlignLeft, opt.palette, option.state & QStyle::State_Enabled, progressStr); int progressPercentage = tor.GetProgress(); myProgressBarStyle->resize(barArea.size()); myProgressBarStyle->setValue(progressPercentage); //painter->translate(barArea.topLeft()); //myProgressBarStyle->render(painter); QStyleOptionProgressBarV2 pbStyleOpt; myProgressBarStyle->initilizeStyleOption(&pbStyleOpt); pbStyleOpt.rect = barArea; /*myProgressBarStyle->rect = barArea; if ( tor.isDownloading() ) { myProgressBarStyle->palette.setBrush( QPalette::Highlight, blueBrush ); myProgressBarStyle->palette.setColor( QPalette::Base, blueBack ); myProgressBarStyle->palette.setColor( QPalette::Background, blueBack ); } else if ( tor.isSeeding() ) { myProgressBarStyle->palette.setBrush( QPalette::Highlight, greenBrush ); myProgressBarStyle->palette.setColor( QPalette::Base, greenBack ); myProgressBarStyle->palette.setColor( QPalette::Background, greenBack ); } myProgressBarStyle->state = progressBarState; setProgressBarPercentDone( option, tor ); */ style->drawControl(QStyle::CE_ProgressBar, &pbStyleOpt, painter, myProgressBarStyle); painter->restore(); }