vtkProperties
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include "ContextPanel.h"
|
||||
#include "ContextModel.h"
|
||||
#include "PropertyWidgets.h"
|
||||
#include "PropertiesPanel.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
@@ -8,12 +10,10 @@
|
||||
#include <QList>
|
||||
#include <QShortcut>
|
||||
#include <QItemSelectionModel>
|
||||
#include <Vtk/vtkQViewport.h>
|
||||
#include <Vtk/vtkObjectsContext.h>
|
||||
|
||||
ContextPanel::ContextPanel(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
, m_vtkContext(nullptr) {
|
||||
, m_context(nullptr) {
|
||||
m_layout = new QVBoxLayout(this);
|
||||
m_layout->setContentsMargins(0, 0, 0, 0);
|
||||
m_layout->setSpacing(0);
|
||||
@@ -43,11 +43,11 @@ ContextPanel::ContextPanel(QWidget* parent)
|
||||
m_splitter = new QSplitter(Qt::Vertical, this);
|
||||
m_splitter->addWidget(m_treeView);
|
||||
|
||||
m_vtkView = new uLib::Vtk::QViewport(m_splitter);
|
||||
m_splitter->addWidget(m_vtkView);
|
||||
m_propertiesPanel = new PropertiesPanel(m_splitter);
|
||||
m_splitter->addWidget(m_propertiesPanel);
|
||||
|
||||
QList<int> sizes;
|
||||
sizes << 400 << 200;
|
||||
sizes << 400 << 600;
|
||||
m_splitter->setSizes(sizes);
|
||||
|
||||
m_layout->addWidget(m_splitter);
|
||||
@@ -60,7 +60,6 @@ ContextPanel::ContextPanel(QWidget* parent)
|
||||
auto selectedIndexes = m_treeView->selectionModel()->selectedIndexes();
|
||||
if (selectedIndexes.isEmpty() || !m_context) return;
|
||||
|
||||
// Collect objects to remove to avoid iterator invalidation issues if context signal emits during removal
|
||||
std::vector<uLib::Object*> toRemove;
|
||||
for (const auto& idx : selectedIndexes) {
|
||||
if (idx.column() == 0) {
|
||||
@@ -80,47 +79,6 @@ void ContextPanel::setContext(uLib::ObjectsContext* context) {
|
||||
m_context = context;
|
||||
m_model->setContext(context);
|
||||
m_treeView->expandAll();
|
||||
|
||||
if (m_vtkContext) {
|
||||
m_vtkView->RemovePuppet(*m_vtkContext);
|
||||
delete m_vtkContext;
|
||||
}
|
||||
m_vtkContext = new uLib::Vtk::vtkObjectsContext(context);
|
||||
// m_vtkView->AddPuppet(*m_vtkContext); // redundant: child puppets are added individually
|
||||
|
||||
// Render viewport and add child puppets when context is updated
|
||||
if (context) {
|
||||
uLib::Object::connect(m_vtkContext, &uLib::Vtk::vtkObjectsContext::PuppetAdded, [this](uLib::Vtk::Puppet* p) {
|
||||
if (this->m_vtkView && p) {
|
||||
this->m_vtkView->AddPuppet(*p);
|
||||
this->m_vtkView->ZoomAuto();
|
||||
this->m_vtkView->Render();
|
||||
}
|
||||
});
|
||||
|
||||
uLib::Object::connect(m_vtkContext, &uLib::Vtk::vtkObjectsContext::PuppetRemoved, [this](uLib::Vtk::Puppet* p) {
|
||||
if (this->m_vtkView && p) {
|
||||
this->m_vtkView->RemovePuppet(*p);
|
||||
this->m_vtkView->Render();
|
||||
}
|
||||
});
|
||||
|
||||
// Add any puppets that were created during m_vtkContext's construction
|
||||
for (auto* obj : context->GetObjects()) {
|
||||
if (auto* p = m_vtkContext->GetPuppet(obj)) {
|
||||
this->m_vtkView->AddPuppet(*p);
|
||||
}
|
||||
}
|
||||
|
||||
uLib::Object::connect(context, &uLib::Object::Updated, [this]() {
|
||||
if (this->m_vtkView) {
|
||||
this->m_vtkView->ZoomAuto();
|
||||
this->m_vtkView->Render();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
m_vtkView->Render();
|
||||
}
|
||||
|
||||
void ContextPanel::onSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected) {
|
||||
@@ -131,8 +89,5 @@ void ContextPanel::onSelectionChanged(const QItemSelection& selected, const QIte
|
||||
|
||||
emit objectSelected(target);
|
||||
|
||||
if (m_vtkContext) {
|
||||
auto* puppet = m_vtkContext->GetPuppet(target);
|
||||
m_vtkView->SelectPuppet(puppet);
|
||||
}
|
||||
m_propertiesPanel->setObject(target);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user