void DlgInspector::setNodeNames(Gui::Document* doc) { std::vector<Gui::ViewProvider*> vps = doc->getViewProvidersOfType (Gui::ViewProviderDocumentObject::getClassTypeId()); QHash<SoNode*, QString> nodeNames; for (std::vector<Gui::ViewProvider*>::iterator it = vps.begin(); it != vps.end(); ++it) { Gui::ViewProviderDocumentObject* vp = static_cast<Gui::ViewProviderDocumentObject*>(*it); App::DocumentObject* obj = vp->getObject(); if (obj) { QString label = QString::fromUtf8(obj->Label.getValue()); nodeNames[vp->getRoot()] = label; } std::vector<std::string> modes = vp->getDisplayMaskModes(); for (std::vector<std::string>::iterator jt = modes.begin(); jt != modes.end(); ++jt) { SoNode* node = vp->getDisplayMaskMode(jt->c_str()); if (node) { nodeNames[node] = QString::fromStdString(*jt); } } } SceneModel* model = static_cast<SceneModel*>(ui->treeView->model()); model->setNodeNames(nodeNames); }
/*! * Returns true if the \a m_nodetypeList contains the type of the element defined with \a sourceRow and \a sourceParent */ bool NodesFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { SceneModel* sceneModel = dynamic_cast< SceneModel* > ( sourceModel() ); QModelIndex index = sceneModel->index(sourceRow, 0, sourceParent); InstanceNode* nodeInstance = sceneModel->NodeFromIndex( index ); if( !nodeInstance ) return false; SoNode* node = nodeInstance->GetNode(); if( !node ) return false; if( node->getTypeId().isDerivedFrom( TSeparatorKit::getClassTypeId() ) ) return ( true ); if( node->getTypeId().isDerivedFrom( TShapeKit::getClassTypeId() ) ) { if( m_shapeTypeList.count() < 1 ) return ( true ); TShapeKit* shapeKit = static_cast< TShapeKit* >( node ); if(!shapeKit) return ( false ); TShape* shape = static_cast< TShape* >( shapeKit->getPart( "shape", false ) ); if( shape && m_shapeTypeList.contains( shape->getTypeId().getName().getString() ) ) return ( true ); } return ( false ); }
void DlgInspector::setNode(SoNode* node) { SceneModel* model = static_cast<SceneModel*>(ui->treeView->model()); model->setNode(node); QHeaderView* header = ui->treeView->header(); header->setResizeMode(0, QHeaderView::Stretch); header->setMovable(false); }
//============================================================================= // モデルの切り替え //============================================================================= void MotionModel::ChangeModel(char * pFileName, int NumModel) { if (NumModel < m_MaxParts) { SceneModel* pBackup = m_pParts[NumModel]; m_pParts[NumModel] = new SceneModel(pFileName, m_pParts[NumModel]->GetPos(), m_pParts[NumModel]->GetParent()); pBackup->Release(); } }
bool SceneFilter::insertRows(int row, int count, const QModelIndex &parent) { beginInsertRows(parent, row, row+(count-1)); SceneModel *sceneModel = (SceneModel *) sourceModel(); qDebug() << "[+] scene filter - add " << count << "scenes at" << row; bool res = sceneModel->insertRows(row, count, mPlotline, parent); endInsertRows(); return res; }
void DlgInspector::on_refreshButton_clicked() { View3DInventor* child = qobject_cast<View3DInventor*>(getMainWindow()->activeWindow()); if (child) { View3DInventorViewer* viewer = child->getViewer(); setNode(viewer->getSceneGraph()); ui->treeView->expandToDepth(3); } else { SceneModel* model = static_cast<SceneModel*>(ui->treeView->model()); model->clear(); } }
void DlgInspector::setNode(SoNode* node) { SceneModel* model = static_cast<SceneModel*>(ui->treeView->model()); model->setNode(node); QHeaderView* header = ui->treeView->header(); #if QT_VERSION >= 0x050000 header->setSectionResizeMode(0, QHeaderView::Stretch); header->setSectionsMovable(false); #else header->setResizeMode(0, QHeaderView::Stretch); header->setMovable(false); #endif }
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ WorkbenchService::pSceneModel_type WorkbenchService::createSceneModel(pExplorerNode_type _pNode, I_Project* _pProject, I_SceneModel::pUserData_type _pUserData) { // TODO The primary key for the document is _pNode->getNodeId(); // TODO Cache the document so that a duplicate document is not created. SceneModel* pRawDocument = new SceneModel(*this, _pProject, _pUserData); // TODO This should return a future so that the load() can be done in the background pSceneModel_type pDocument(pRawDocument, boost::bind(&WorkbenchService::destroySceneModel, this, _1)); pRawDocument->load(_pNode); return pDocument; }
void DlgInspector::on_refreshButton_clicked() { Gui::Document* doc = Application::Instance->activeDocument(); if (doc) { setNodeNames(doc); View3DInventor* view = qobject_cast<View3DInventor*>(doc->getActiveView()); if (view) { View3DInventorViewer* viewer = view->getViewer(); setNode(viewer->getSceneGraph()); ui->treeView->expandToDepth(3); } } else { SceneModel* model = static_cast<SceneModel*>(ui->treeView->model()); model->clear(); } }