SongtreeWidget::SongtreeWidget(QWidget *parent) : QWidget(parent), ui(new Ui::SongtreeWidget), collController(0), model(0), tree(0) { ui->setupUi(this); collController = ICore::collectionController(); Q_ASSERT(collController); //TODO: No such slot connect(collController, SIGNAL(mediaCollectionAdded(IMediaCollection*)), this, SLOT(addNewCollection(IMediaCollection*))); searchProxy = new SongtreeProxyModel(); connect(collController, SIGNAL(mediaCollectionRemoved(QUrl)), this, SLOT(removeCollection(QUrl))); connect(ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(loadSongtreeModel(int))); buildHierarchy(); loadSongtreeModel(0); //proxy->setSourceModel(model); searchProxy->setDynamicSortFilter(true); searchProxy->sort(0); connect(this->ui->lineEdit, SIGNAL(textEdited(QString)), this, SLOT(textEdited(QString))); //connect(searchProxy, SIGNAL(expandIndex(QModelIndex)), this->ui->treeView, SLOT(expand(QModelIndex))); connect(this->ui->lineEdit, SIGNAL(returnPressed()), this, SLOT(returnPressed())); this->ui->treeView->setEditTriggers(QAbstractItemView::NoEditTriggers); this->ui->treeView->setModel(searchProxy); this->ui->treeView->setItemDelegate(new SongTreeItemDelegate(this)); }
//============================================================================== // Sector building. //============================================================================== void Galaxy::buildSectors() // Build the galaxy's sectors based on the current build mode. { cout << "building sectors\n"; clearSectors(); sectors = new list<GSector*>(); switch (cluster_mode) { case NONE: case DIRECTORY: buildHierarchy(); break; case NAME: buildByName(); break; case DATE: buildByDate(); break; case SIZE: buildBySize(); break; case TYPE: buildByType(); break; case TAGS: buildByTags(); break; default: break; } cout << "sectors built\n"; if (sectors->size() == 1) (*(sectors->begin()))->setSingleSectorMode(true); else adjustSectorWidths(); }
Mesh::Mesh(std::string fName, std::shared_ptr<Material> mat, Vector position, double scale) { m = mat; std::cout << "Loading " << fName << std::endl; readFile(fName,position,scale); std::cout << "Building hierarchy for " << fName << std::endl; buildHierarchy(); }
void buildHierarchy( osgDB::Input& fr, int level, osgAnimation::Bone* parent ) { bool isRecognized = false; if ( !parent ) return; if ( fr.matchSequence("OFFSET %f %f %f") ) { isRecognized = true; ++fr; osg::Vec3 offset; if ( fr.readSequence(offset) ) { // Process OFFSET section parent->setBindMatrixInBoneSpace( osg::Matrix::translate(offset) ); if ( _drawingFlag && parent->getNumParents() && level>0 ) parent->getParent(0)->addChild( createRefGeometry(offset, 0.5).get() ); } } if ( fr.matchSequence("CHANNELS %i") ) { isRecognized = true; // Process CHANNELS section int noChannels; fr[1].getInt( noChannels ); fr += 2; for ( int i=0; i<noChannels; ++i ) { // Process each channel std::string channelName; fr.readSequence( channelName ); alterChannel( channelName, _joints.back().second ); } } if ( fr.matchSequence("End Site {") ) { isRecognized = true; fr += 3; if ( fr.matchSequence("OFFSET %f %f %f") ) { ++fr; osg::Vec3 offsetEndSite; if ( fr.readSequence(offsetEndSite) ) { // Process End Site section osg::ref_ptr<osgAnimation::Bone> bone = new osgAnimation::Bone( parent->getName()+"End" ); bone->setBindMatrixInBoneSpace( osg::Matrix::translate(offsetEndSite) ); bone->setDataVariance( osg::Object::DYNAMIC ); parent->addChild( bone.get() ); if ( _drawingFlag ) parent->addChild( createRefGeometry(offsetEndSite, 0.5).get() ); } } fr.advanceOverCurrentFieldOrBlock(); } if ( fr.matchSequence("ROOT %w {") || fr.matchSequence("JOINT %w {") ) { isRecognized = true; // Process JOINT section osg::ref_ptr<osgAnimation::Bone> bone = new osgAnimation::Bone( fr[1].getStr() ); bone->setDefaultUpdateCallback(); bone->setDataVariance( osg::Object::DYNAMIC ); parent->addChild( bone.get() ); _joints.push_back( JointNode(bone, 0) ); int entry = fr[1].getNoNestedBrackets(); fr += 3; while ( !fr.eof() && fr[0].getNoNestedBrackets()>entry ) buildHierarchy( fr, entry, bone.get() ); fr.advanceOverCurrentFieldOrBlock(); } if ( !isRecognized ) { osg::notify(osg::WARN) << "BVH Reader: Unrecognized symbol " << fr[0].getStr() << ". Ignore current field or block." << std::endl; fr.advanceOverCurrentFieldOrBlock(); } }
osg::Group* buildBVH( std::istream& stream, const osgDB::ReaderWriter::Options* options ) { if ( options ) { if ( options->getOptionString().find("contours")!=std::string::npos ) _drawingFlag = 1; else if ( options->getOptionString().find("solids")!=std::string::npos ) _drawingFlag = 2; } osgDB::Input fr; fr.attach( &stream ); osg::ref_ptr<osgAnimation::Skeleton> skelroot = new osgAnimation::Skeleton; skelroot->setDefaultUpdateCallback(); osg::ref_ptr<osgAnimation::Animation> anim = new osgAnimation::Animation; while( !fr.eof() ) { if ( fr.matchSequence("HIERARCHY") ) { ++fr; buildHierarchy( fr, 0, skelroot.get() ); } else if ( fr.matchSequence("MOTION") ) { ++fr; buildMotion( fr, anim.get() ); } else { if ( fr[0].getStr()==NULL ) continue; osg::notify(osg::WARN) << "BVH Reader: Unexpected beginning " << fr[0].getStr() << ", neither HIERARCHY nor MOTION. Stopped." << std::endl; break; } } #if 0 std::cout << "Bone number: " << _joints.size() << "\n"; for ( unsigned int i=0; i<_joints.size(); ++i ) { JointNode node = _joints[i]; std::cout << "Bone" << i << " " << node.first->getName() << ": "; std::cout << std::hex << node.second << std::dec << "; "; if ( node.first->getNumParents() ) std::cout << "Parent: " << node.first->getParent(0)->getName(); std::cout << "\n"; } #endif osg::Group* root = new osg::Group; osgAnimation::BasicAnimationManager* manager = new osgAnimation::BasicAnimationManager; root->addChild( skelroot.get() ); root->setUpdateCallback(manager); manager->registerAnimation( anim.get() ); manager->buildTargetReference(); manager->playAnimation( anim.get() ); _joints.clear(); return root; }