[Paraview-developers] Writing a plugin that automatically adds a source after ParaView client starts up
Cory Quammen
cquammen at cs.unc.edu
Fri Jul 29 11:15:37 EDT 2011
Hi all,
I'm trying to write a plugin that will add a source to ParaView
immediately after the client starts up. I've figured out the code
needed to create the source. Now, the only problem is figuring out
when to call this code.
I'm attempting to do this with an autostart plugin. The problem is
that plugins appear to be loaded *before* everything my plugin needs
is set up, so setting up the source within the onStartup() method in
my autostart plugin does not work.
What I'd like to be able to do is set up a slot in my plugin that
connects to a Qt signal that is fired after everything necessary for
adding a source is set up. Unfortunately, the signals I've tried
(listed below) appear to be emitted too early:
pqServerManagerModel::serverAdded(pqServer *)
pqActiveObjects::serverChanged(pqServer *)
Specifically, I am getting an error in pqPipelineModel.cxx:934, "Could
not locate server on which the source is being added." It seems the
server hasn't yet been added to the pqPipelineModel.
Does anyone have a suggestion for a signal that is emitted towards the
very end of the client program startup? Other suggestions on how to
add a source after startup are also appreciated. I'd like to avoid
modifying the ParaView application code itself if at all possible.
Thanks,
Cory
P.S.
In case it is helpful, here is the code I'm using to set up the source:
pqActiveObjects* activeObjects = &pqActiveObjects::instance();
pqApplicationCore* app = pqApplicationCore::instance();
pqObjectBuilder* builder = app->getObjectBuilder();
pqPipelineSource *text = builder->createSource("sources",
"TextSource",
pqActiveObjects::instance().activeServer());
text->rename(tr("Text"));
text->setModifiedState(pqProxy::UNMODIFIED);
pqDisplayPolicy* displayPolicy =
pqApplicationCore::instance()->getDisplayPolicy();
displayPolicy->setRepresentationVisibility(
text->getOutputPort(0), pqActiveObjects::instance().activeView(), true);
--
Cory Quammen
Research Associate
Department of Computer Science
University of North Carolina at Chapel Hill
http://www.cs.unc.edu/~cquammen
More information about the Paraview-developers
mailing list