void UICanvasTestEdit::UnbindCanvas() { Scene::ScenePtr scene = framework_->GetDefaultWorldScene(); if (scene.get()) { Scene::EntityPtr entity = scene->GetEntity(last_entity_id_); if (entity.get()) { EC_UICanvas* ec = entity->GetComponent<EC_UICanvas>().get(); if (ec) { // Get proxy widget from 3D canvas boost::shared_ptr<QtUI::UICanvas> canvas = ec->GetCanvas(); QGraphicsProxyWidget *proxy_widget = canvas->Remove3DProxyWidget(); proxy_widget->widget()->setWindowFlags(Qt::Dialog); ec->ClearSubmeshes(); // Remove proxy widget from local QList so it we wont try to delete in decostructor proxy_widget_canvases_.removeOne(canvas); // Get QtModule and delete the 3D canvas Foundation::ModuleSharedPtr qt_module = framework_->GetModuleManager()->GetModule("QtModule").lock(); QtUI::QtModule *qt_ui = dynamic_cast<QtUI::QtModule*>(qt_module.get()); if (qt_ui) qt_ui->DeleteCanvas(canvas->GetID()); // Add proxy widget back to 2D scene boost::shared_ptr<UiServices::UiModule> ui_module = framework_->GetModuleManager()->GetModule<UiServices::UiModule>(Foundation::Module::MT_UiServices).lock(); ui_module->GetSceneManager()->AddProxyWidget((UiServices::UiProxyWidget *)proxy_widget); } } } }
void UICanvasTestEdit::RefreshSubmeshes() { if (!editor_widget_) return; uint numsubmeshes = 0; Scene::ScenePtr scene = framework_->GetDefaultWorldScene(); if (scene.get()) { Scene::EntityPtr entity = scene->GetEntity(last_entity_id_); if (entity.get()) { OgreRenderer::EC_OgreMesh* mesh = entity->GetComponent<OgreRenderer::EC_OgreMesh>().get(); OgreRenderer::EC_OgreCustomObject* custom = entity->GetComponent<OgreRenderer::EC_OgreCustomObject>().get(); if (mesh) numsubmeshes = mesh->GetNumMaterials(); if (custom) numsubmeshes = custom->GetNumMaterials(); } } QComboBox* combo = editor_widget_->findChild<QComboBox*>("combo_subobject"); if (!combo) return; combo->clear(); for (uint i = 0; i < numsubmeshes; ++i) combo->addItem(QString::fromStdString(ToString<uint>(i))); }
Console::CommandResult ScenePersistenceModule::StartPersistenceCommand(const StringVector ¶ms) { StartPersistingStorage("world.db"); const Scene::ScenePtr scene = framework_->GetDefaultWorldScene(); connect(scene.get(), SIGNAL(EntityCreated(Scene::Entity*, AttributeChange::Type)), this, SLOT(EntityCreated(Scene::Entity*, AttributeChange::Type))); connect(scene.get(), SIGNAL(EntityRemoved(Scene::Entity*, AttributeChange::Type)), this, SLOT(EntityRemoved(Scene::Entity*, AttributeChange::Type))); connect(scene.get(), SIGNAL(ComponentAdded(Scene::Entity*, IComponent*, AttributeChange::Type)), this, SLOT(ComponentAdded(Scene::Entity*, IComponent*, AttributeChange::Type))); connect(scene.get(), SIGNAL(ComponentRemoved(Scene::Entity*, IComponent*, AttributeChange::Type)), this, SLOT(ComponentRemoved(Scene::Entity*, IComponent*, AttributeChange::Type))); connect(scene.get(), SIGNAL(AttributeChanged(IComponent*, IAttribute*, AttributeChange::Type)), this, SLOT(AttributeChanged(IComponent*, IAttribute*, AttributeChange::Type))); return Console::ResultSuccess(); }
void UICanvasTestEdit::BindCanvas() { // Get ui elements QComboBox* combo_s = editor_widget_->findChild<QComboBox*>("combo_subobject"); if (!combo_s) return; QComboBox* combo_c = editor_widget_->findChild<QComboBox*>("combo_canvas"); if (!combo_c) return; // Get QtModule Foundation::ModuleSharedPtr qt_module = framework_->GetModuleManager()->GetModule("QtModule").lock(); QtUI::QtModule *qt_ui = dynamic_cast<QtUI::QtModule*>(qt_module.get()); // Get UiModule boost::shared_ptr<UiServices::UiModule> ui_module = framework_->GetModuleManager()->GetModule<UiServices::UiModule>(Foundation::Module::MT_UiServices).lock(); // Get Scene Scene::ScenePtr scene = framework_->GetDefaultWorldScene(); if (scene.get()) { Scene::EntityPtr entity = scene->GetEntity(last_entity_id_); if (entity.get()) { uint submesh = combo_s->currentIndex(); QString proxy_widget_name = combo_c->currentText(); boost::shared_ptr<QtUI::UICanvas> canvas; // Get proxy widget for selected name UiServices::UiProxyWidget *proxy_widget = ui_module->GetSceneManager()->GetProxyWidget(proxy_widget_name); if (proxy_widget) { ui_module->GetSceneManager()->RemoveProxyWidgetFromScene(proxy_widget); proxy_widget->widget()->setWindowFlags(Qt::Widget); canvas = qt_ui->CreateCanvas(QtUI::UICanvas::Internal).lock(); canvas->SetSize(proxy_widget->size().width(), proxy_widget->size().height()); canvas->SetPosition(100,100); canvas->AddProxyWidget(proxy_widget); canvas->Show(); proxy_widget->show(); proxy_widget_canvases_.append(canvas); EC_UICanvas* ec = dynamic_cast<EC_UICanvas*>(qt_ui->CreateEC_UICanvasToEntity(entity.get(), canvas).get()); if (ec) ec->SetSubmeshes(submesh); } } } }