pqViewFrame *pqMultiViewWidget::newFrame(vtkSMProxy *view)
{
pqViewFrame *frame = new pqViewFrame();
QObject::connect(frame, SIGNAL(buttonPressed(int)), this, SLOT(standardButtonPressed(int)));
QObject::connect(frame, SIGNAL(swapPositions(const QString &)), this, SLOT(swapPositions(const QString &)), Qt::QueuedConnection);
// 从服务管理器中查找可用的pqView
pqServerManagerModel *smmodel = pqApplicationCore::instance()->getServerManagerModel();
pqView *pqview = smmodel->findItem<pqView *>(view);
// 将 pqView 与 显示的pqViewFrame进行联接
// it's possible that pqview is nullptr, if the view proxy hasn't been registered
// yet. This happens often when initialization state is being loaded in
// collaborative sessions.
ConnectFrameToView(frame, pqview);
// Search for view frame actions plugins and allow them to decide
// whether to add their actions to this view type's frame or not.
pqInterfaceTracker *tracker = pqApplicationCore::instance()->interfaceTracker();
Q_FOREACH (pqViewFrameActionsInterface *vfai, tracker->interfaces<pqViewFrameActionsInterface *>())
{
vfai->frameConnected(frame, pqview);
}
return frame;
}
void ConnectFrameToView(pqViewFrame *frame, pqView *pqview)
{
assert(frame);
// if pqview == nullptr, then the frame is either being assigned to a empty
// view, or pqview for a view-proxy just isn't present yet.
// it's possible that pqview is nullptr, if the view proxy hasn't been registered
// yet. This happens often when initialization state is being loaded in
// collaborative sessions.
if (pqview != nullptr)
{
// 把 pqView 中的 widget 放入 pqViewFrame 的容器中
QWidget *viewWidget = pqview->widget();
frame->setCentralWidget(viewWidget, pqview);
}
}