Commit 29be447a authored by Alvaro Sanchez's avatar Alvaro Sanchez

Create and make representations visible by default in new views.

pqApplyBehavior makes the model visible on the initial view. Additional
views need to create and make their representations visible, this is done
through pqSMTKBehavior.
parent 3ca6b18b
Pipeline #86754 passed with stage
......@@ -18,10 +18,14 @@
// Client side
#include "pqApplicationCore.h"
#include "pqDataRepresentation.h"
#include "pqObjectBuilder.h"
#include "pqOutputPort.h"
#include "pqSelectionManager.h"
#include "pqServerManagerModel.h"
#include "pqView.h"
#include "vtkNew.h"
#include "vtkSMParaViewPipelineControllerWithRendering.h"
#include "vtkSMSourceProxy.h"
#include <QObject>
......@@ -242,3 +246,32 @@ void pqSMTKBehavior::handleOldSMTKProxies(pqProxy* pxy)
return;
}
}
bool pqSMTKBehavior::createRepresentation(pqSMTKResource* pvr, pqView* view)
{
auto source = qobject_cast<pqPipelineSource*>(pvr);
auto pqPort = source ? source->getOutputPort(0) : nullptr;
if (!pqPort || !view)
return false;
auto pqCore = pqApplicationCore::instance();
if (!pqCore)
return false;
auto builder = pqCore->getObjectBuilder();
pqDataRepresentation* pqRep = builder->createDataRepresentation(pqPort, view);
if (pqRep)
{
this->setDefaultRepresentationVisibility(pqPort, view);
pqRep->renderViewEventually();
return true;
}
return false;
}
void pqSMTKBehavior::setDefaultRepresentationVisibility(pqOutputPort* pqPort, pqView* view)
{
// ControllerWithRendering finds and uses the appropriate vtkSMRepresentationProxy
vtkNew<vtkSMParaViewPipelineControllerWithRendering> controller;
controller->Show(pqPort->getSourceProxy(), pqPort->getPortNumber(), view->getViewProxy());
}
......@@ -24,6 +24,7 @@ class pqSelectionManager;
class pqServer;
class pqSMTKResource;
class pqSMTKResourceManager;
class pqView;
class vtkSMSMTKResourceManagerProxy;
/** \brief Create and synchronize smtk manager instances on the client and server.
......@@ -79,6 +80,11 @@ public:
virtual void visitResourceManagersOnServers(
const std::function<bool(pqSMTKResourceManager*, pqServer*)>& fn) const;
/**
* Create a pqDataRepresentation and set its default visibility value.
*/
bool createRepresentation(pqSMTKResource* pvr, pqView* view);
signals:
/// Called from within addManagerOnServer (in response to server becoming ready)
void addedManagerOnServer(vtkSMSMTKResourceManagerProxy* mgr, pqServer* server);
......@@ -92,6 +98,11 @@ protected:
void setupSelectionManager();
/**
* Make a representation visible through a ControllerWithRendering instance.
*/
void setDefaultRepresentationVisibility(pqOutputPort* pqPort, pqView* view);
class Internal;
Internal* m_p;
......
......@@ -258,7 +258,7 @@ void pqSMTKResourcePanel::activeViewChanged(pqView* view)
}
else
{
visibleThings[rsrc->id()] = 0;
visibleThings[rsrc->id()] = behavior->createRepresentation(pvr, view) ? 1 : 0;
}
}
std::cout << "Visible things has " << visibleThings.size() << " entries.\n";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment