Building a Custom Paraview Application to Only Output to a Single Window

Hi, I have setup a remote bewoulf cluster that I run a pvserver on. Using the paraview gui client, I first connect to the server, load a pvd file, apply some inbuilt and custom filters and then volume render the data. What I want to do is, build a custom application that does all of the above steps programmatically but only displays the output render on a window that I can interact with. I don’t want any other gui related things. Just a simple application. Although I am struggling to do so. I have downloaded and built the paraview source. I can also run the examples but am having a hard time figuring out how do I create it from scratch. I have gone through the customising paraview guide but cannot wrap my head around it. I would be grateful, If anyone can help me or point in the right direction. Any help would be greatly appreciated.
Thank You

Sounds like you want a pvpython script instead.

Just use File->SaveState->state.py, add Interact() at the end and run with pvpython.

If that doesnt do it for you, I will help with customizing paraview.

Hi, thanks for the response.
I want to connect to the cluster, run the pvpython script in parallel (which I assume is done by pvbatch) and display the output on a client. Which I am not able to do so due to my limited knowledge.
I actually want to write a custom application because I later want to send the data over to hololens and display it there. I just want to use the paraview’s capabilities to load and distribute data, read pvd files, do volume rendering, apply filters etc. I will also be dynamically extracting the subsets according to the input from the client in the application and updating the renders (like loading in more subsets, removing others etc.). This is the reason I thought writing a custom application would be a better choice.
Thanks

Sounds like a standard Trame usecase to me. But it can be done with a custome ParaView based application, look at https://gitlab.kitware.com/paraview/paraview/-/tree/master/Examples/CustomApplications/SimpleParaView?ref_type=heads

@jourdain

Ok, I will look into Trame. In the meanwhile, I tried modifying the Demo1 example

#include "mainWindow.h"
#include "ui_mainWindow.h"

#include <pqActiveObjects.h>
#include <pqApplicationCore.h>
#include <pqObjectBuilder.h>
#include <pqRenderView.h>
#include <pqServerResource.h>
#include <pqLoadDataReaction.h>
#include <pqDataRepresentation.h>
#include <vtkSMPropertyHelper.h>
#include <vtkPVGeneralSettings.h>

mainWindow::mainWindow(QWidget* parent, Qt::WindowFlags flags) : Superclass(parent, flags)
{
	Ui::mainWindow ui;
	ui.setupUi(this);

	// make a connection to the builtin server
	pqApplicationCore* core = pqApplicationCore::instance();
	core->getObjectBuilder()->createServer(pqServerResource("builtin:"));
	
	// Use auto apply to show data automatically
	vtkPVGeneralSettings::GetInstance()->SetAutoApply(true);

	// create render view
	pqRenderView* view = qobject_cast<pqRenderView*>(core->getObjectBuilder()->createView(
		pqRenderView::renderViewType(), pqActiveObjects::instance().activeServer()));
	pqActiveObjects::instance().setActiveView(view);

	QStringList files;
	files << "/mnt/c/DEV/Torso.pvd";

	pqPipelineSource* pipelineSource = pqLoadDataReaction::loadData(files, "sources", "PVDReader");
	pipelineSource->updatePipeline();

	pqObjectBuilder *builder = pqApplicationCore::instance()->getObjectBuilder();

	pqDataRepresentation *drep = builder->createDataRepresentation(pipelineSource->getOutputPort(0), view);
	vtkSMPropertyHelper(drep->getProxy(), "Representation").Set("Volume");
	drep->getProxy()->UpdateVTKObjects();
	drep->setVisible(true);

	view->render();
	
	this->setCentralWidget(view->widget());
}

mainWindow::~mainWindow() = default;


This how I have modified the Demo1 example. The window opens but there is not data loaded in it. Could please point out where the issues are?

Hi, I am able to load and render the pvd data in the representation modes “Outline” and “Surface”. But when I set it to “Volume” it does not display anything. What might be the reason behind this?

	// create data representation and add it to render view
	pqDataRepresentation *drep = builder->createDataRepresentation(pipelineSource->getOutputPort(0), view);
    // Changing this to "Volume"
	vtkSMPropertyHelper(drep->getProxy(), "Representation").Set("Outline");
	drep->getProxy()->UpdateVTKObjects();
	drep->setVisible(true);

I believe it is due this property. It switches to MetaImage when I set the representation type to Volume in ParaView. How do I replicate this behaviour in script?

Thanks

You need to set the scalars for rendering, it is a representation property. Use the trace in ParaView to understands how it works in python, it will help you figure out the right C++ code.

Hi, I have got it working with the following:

// create data representation and add it to render view
pqDataRepresentation *drep = builder->createDataRepresentation(pipelineSource->getOutputPort(0), view);
auto dProxy = drep->getProxy();
vtkSMPropertyHelper(dProxy, "Representation").Set("Volume");
// use color and opacity from original data
vtkSMPropertyHelper(dProxy, "UseSeparateColorMap").Set(1);
vtkSMPVRepresentationProxy::SetScalarColoring(dProxy, "MetaImage", vtkDataObject::POINT);
vtkSMPVRepresentationProxy::RescaleTransferFunctionToDataRange(dProxy, false, false);

Thanks

1 Like