Commit 040b7ee9 authored by T.J. Corona's avatar T.J. Corona Committed by Kitware Robot

Merge topic 'apply-button-wizardry'

3cf945c2 Updates to paraview plugins that simplify resource loading
3d9b9c9f CreateUniformGrid: set mesh collection as model tessellation
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !1329
parents e70cf07a 3cf945c2
Pipeline #122929 failed with stage
in 0 seconds
## Enforce ParaView semantics for apply() on File->Open only
When resoures are loaded via File->Open, ParaView semantics
apply: the apply button must be pressed to complete opening the
file. This matches the functionality of the other ParaView readers
(that are selectable when there are multiple readers for a file type).
When a resource is created via File->New Resource, a modal dialog
is presented to the user. When the user presses apply on the dialog,
the resource is generated and its representation is rendered. The
Properties Panel's apply button is never enabled.
When a resource is created by an operation from the Operation
Panel, the resource is generated and its representation is
rendered. The Properties Panel's apply button is never enabled.
......@@ -26,6 +26,7 @@ set(PQComponentsSrcs
pqSMTKBehavior.cxx
pqSMTKColorByToolBar.cxx
pqSMTKColorByWidget.cxx
pqSMTKRenderResourceBehavior.cxx
pqSMTKExportSimulationBehavior.cxx
pqSMTKImportOperationBehavior.cxx
pqSMTKModelRepresentation.cxx
......@@ -45,6 +46,7 @@ set(PQComponentsHeaders
pqSMTKBehavior.h
pqSMTKColorByToolBar.h
pqSMTKColorByWidget.h
pqSMTKRenderResourceBehavior.h
pqSMTKExportSimulationBehavior.h
pqSMTKImportOperationBehavior.h
pqSMTKModelRepresentation.h
......
......@@ -17,6 +17,7 @@
#include "smtk/extension/paraview/appcomponents/pqSMTKImportOperationBehavior.h"
#include "smtk/extension/paraview/appcomponents/pqSMTKNewResourceBehavior.h"
#include "smtk/extension/paraview/appcomponents/pqSMTKRegisterImportersBehavior.h"
#include "smtk/extension/paraview/appcomponents/pqSMTKRenderResourceBehavior.h"
#include "smtk/extension/paraview/appcomponents/pqSMTKSaveResourceBehavior.h"
#include "smtk/extension/paraview/server/vtkSMSMTKWrapperProxy.h"
......@@ -38,6 +39,7 @@ pqSMTKAppComponentsAutoStart::~pqSMTKAppComponentsAutoStart()
void pqSMTKAppComponentsAutoStart::startup()
{
auto rsrcMgr = pqSMTKBehavior::instance(this);
auto renderResourceBehavior = pqSMTKRenderResourceBehavior::instance(this);
auto rsrcImportOpMgr = pqSMTKImportOperationBehavior::instance(this);
auto rsrcExportSimMgr = pqSMTKExportSimulationBehavior::instance(this);
......@@ -54,6 +56,7 @@ void pqSMTKAppComponentsAutoStart::startup()
if (pqCore)
{
pqCore->registerManager("smtk resource", rsrcMgr);
pqCore->registerManager("smtk render resource", renderResourceBehavior);
pqCore->registerManager("smtk import operation", rsrcImportOpMgr);
pqCore->registerManager("smtk export simulation", rsrcExportSimMgr);
pqCore->registerManager("smtk save resource", rsrcSaveMgr);
......@@ -69,6 +72,7 @@ void pqSMTKAppComponentsAutoStart::shutdown()
if (pqCore)
{
pqCore->unRegisterManager("smtk resource");
pqCore->unRegisterManager("smtk render resource");
pqCore->unRegisterManager("smtk import operation");
pqCore->unRegisterManager("smtk export simulation");
pqCore->unRegisterManager("smtk save resource");
......
......@@ -174,18 +174,6 @@ pqSMTKResource* pqSMTKBehavior::getPVResource(smtk::resource::ResourcePtr resour
return false;
});
// If no pipeline source is associated with the resource, we create one.
if (result == nullptr)
{
pqApplicationCore* pqCore = pqApplicationCore::instance();
pqServer* server = pqActiveObjects::instance().activeServer();
pqObjectBuilder* builder = pqCore->getObjectBuilder();
result = static_cast<pqSMTKResource*>(builder->createSource("sources", "SMTKSource", server));
vtkSMPropertyHelper(result->getProxy(), "ResourceId").Set(resource->id().toString().c_str());
result->getProxy()->UpdateVTKObjects();
}
return result;
}
......
......@@ -28,6 +28,8 @@
#include "smtk/attribute/json/jsonResource.h"
#include "smtk/extension/paraview/appcomponents/pqSMTKBehavior.h"
#include "smtk/extension/paraview/appcomponents/pqSMTKOperationPanel.h"
#include "smtk/extension/paraview/appcomponents/pqSMTKRenderResourceBehavior.h"
#include "smtk/extension/paraview/appcomponents/pqSMTKResource.h"
#include "smtk/extension/paraview/appcomponents/pqSMTKWrapper.h"
#include "smtk/extension/qt/qtOperationView.h"
#include "smtk/extension/qt/qtUIManager.h"
......@@ -105,10 +107,12 @@ void pqNewResourceReaction::newResource()
auto pqCore = pqApplicationCore::instance();
auto builder = pqCore->getObjectBuilder();
pqPipelineSource* src = builder->createSource("sources", "SMTKModelCreator", server);
pqSMTKResource* src =
static_cast<pqSMTKResource*>(builder->createSource("sources", "SMTKModelCreator", server));
vtkSMPropertyHelper(src->getProxy(), "TypeName").Set(typeName.c_str());
vtkSMPropertyHelper(src->getProxy(), "Parameters").Set(parameters.c_str());
src->getProxy()->UpdateVTKObjects();
pqSMTKRenderResourceBehavior::instance()->renderPipelineSource(src);
}
}
......
......@@ -10,6 +10,7 @@
#include "smtk/extension/paraview/appcomponents/pqSMTKOperationPanel.h"
#include "smtk/extension/paraview/appcomponents/pqSMTKBehavior.h"
#include "smtk/extension/paraview/appcomponents/pqSMTKRenderResourceBehavior.h"
#include "smtk/extension/paraview/appcomponents/pqSMTKResource.h"
#include "smtk/extension/paraview/appcomponents/pqSMTKWrapper.h"
......@@ -21,6 +22,9 @@
#include "smtk/attribute/Attribute.h"
#include "smtk/attribute/Resource.h"
#include "smtk/attribute/ResourceItem.h"
#include "smtk/extension/qt/qtOperationView.h"
#include "smtk/resource/Manager.h"
#include "smtk/resource/Resource.h"
......@@ -30,8 +34,9 @@
#include "smtk/io/Logger.h"
#include "pqActiveObjects.h"
#include "pqPipelineSource.h"
#include "vtkSMParaViewPipelineControllerWithRendering.h"
#include "vtkSMPropertyHelper.h"
#include "vtkSMProxy.h"
#include "ui_pqSMTKOperationPanel.h"
......@@ -247,6 +252,43 @@ bool pqSMTKOperationPanel::editOperation(smtk::operation::OperationPtr op)
auto baseView = m_attrUIMgr->setSMTKView(view, m_p->OperationEditor);
didDisplay = baseView ? true : false;
// Connect the signal emitted from the operation view after an operation is
// run to a lambda that extracts any newly added resources and queries the
// singleton pqSMTKBehavior for pipeline sources associated with the resource.
// If there is no pipeline source available, we create one.
if (smtk::extension::qtOperationView* operationView =
dynamic_cast<smtk::extension::qtOperationView*>(baseView))
{
QObject::connect(operationView, &smtk::extension::qtOperationView::operationExecuted,
[&](const smtk::operation::Operation::Result& result) {
// Gather all resource items
std::vector<smtk::attribute::ResourceItemPtr> resourceItems;
std::function<bool(smtk::attribute::ResourceItemPtr)> filter = [](
smtk::attribute::ResourceItemPtr) { return true; };
result->filterItems(resourceItems, filter);
// For each resource item found...
for (auto& resourceItem : resourceItems)
{
// ...for each resource in a resource item...
for (std::size_t i = 0; i < resourceItem->numberOfValues(); i++)
{
// (no need to look at resources that cannot be resolved)
if (!resourceItem->isValid() || resourceItem->value(i) == nullptr)
{
continue;
}
smtk::resource::Resource::Ptr resource = resourceItem->value(i);
if (pqSMTKBehavior::instance()->getPVResource(resource) == nullptr)
{
pqSMTKRenderResourceBehavior::instance()->createPipelineSource(resource);
}
}
}
});
}
auto rsrcMgr = m_rsrc->manager();
if (rsrcMgr)
{
......
//=========================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//=========================================================================
#include "smtk/extension/paraview/appcomponents/pqSMTKRenderResourceBehavior.h"
#include "pqActiveObjects.h"
#include "pqApplicationCore.h"
#include "pqApplyBehavior.h"
#include "pqCameraReaction.h"
#include "pqObjectBuilder.h"
#include "pqPipelineSource.h"
#include "pqProxy.h"
#include "vtkSMPropertyHelper.h"
#include "vtkSMProxy.h"
// pqApplyBehavior is ParaView's behavior for "handling the logic that needs to
// happen after the user hits "Apply" on the pqPropertiesPanel." We require its
// functionality so we can show the proxies for resources that were created
// outside of ParaView's File->Open command.
class pqSMTKApplyBehavior : public pqApplyBehavior
{
public:
virtual ~pqSMTKApplyBehavior() {}
void operator()(pqProxy* proxy) { this->applied(nullptr, proxy); }
};
class pqSMTKRenderResourceBehavior::Internal
{
public:
~Internal() {}
pqSMTKApplyBehavior ApplyBehavior;
};
static pqSMTKRenderResourceBehavior* g_instance = nullptr;
pqSMTKRenderResourceBehavior::pqSMTKRenderResourceBehavior(QObject* parent)
: Superclass(parent)
, m_p(new Internal)
{
}
pqSMTKRenderResourceBehavior* pqSMTKRenderResourceBehavior::instance(QObject* parent)
{
if (!g_instance)
{
g_instance = new pqSMTKRenderResourceBehavior(parent);
}
if (g_instance->parent() == nullptr && parent)
{
g_instance->setParent(parent);
}
return g_instance;
}
pqSMTKRenderResourceBehavior::~pqSMTKRenderResourceBehavior()
{
if (g_instance == this)
{
g_instance = nullptr;
}
QObject::disconnect(this);
}
pqSMTKResource* pqSMTKRenderResourceBehavior::createPipelineSource(
const smtk::resource::Resource::Ptr& resource)
{
pqApplicationCore* pqCore = pqApplicationCore::instance();
pqServer* server = pqActiveObjects::instance().activeServer();
pqObjectBuilder* builder = pqCore->getObjectBuilder();
pqSMTKResource* source =
static_cast<pqSMTKResource*>(builder->createSource("sources", "SMTKSource", server));
vtkSMPropertyHelper(source->getProxy(), "ResourceId").Set(resource->id().toString().c_str());
this->renderPipelineSource(source);
return source;
}
void pqSMTKRenderResourceBehavior::renderPipelineSource(pqSMTKResource* source)
{
source->getProxy()->UpdateVTKObjects();
m_p->ApplyBehavior(source);
pqActiveObjects::instance().activeView()->render();
pqCameraReaction::zoomToData();
}
//=========================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//=========================================================================
#ifndef smtk_extension_paraview_appcomponents_pqSMTKRenderResourceBehavior_h
#define smtk_extension_paraview_appcomponents_pqSMTKRenderResourceBehavior_h
#include "smtk/extension/paraview/appcomponents/Exports.h"
#include "smtk/extension/paraview/appcomponents/pqSMTKResource.h"
#include "smtk/resource/Resource.h"
#include <QObject>
/// Given an SMTK resource, this behavior constructs a pipeline source for the
/// resource and adds it to the active view. Resources created using ParaView's
/// File->Open do not need this functionality, as it occurs internally within
/// ParaView. Other created resources (such as those loaded when resolving links,
/// resources created via the operation panel, etc.) do not automatically go
/// through ParaView's machinations; we duplicate ParaView's source-handling
/// process here.
class SMTKPQCOMPONENTSEXT_EXPORT pqSMTKRenderResourceBehavior : public QObject
{
Q_OBJECT
using Superclass = QObject;
public:
static pqSMTKRenderResourceBehavior* instance(QObject* parent = nullptr);
~pqSMTKRenderResourceBehavior() override;
public slots:
pqSMTKResource* createPipelineSource(const smtk::resource::Resource::Ptr&);
void renderPipelineSource(pqSMTKResource* source);
protected:
pqSMTKRenderResourceBehavior(QObject* parent = nullptr);
class Internal;
Internal* m_p;
private:
Q_DISABLE_COPY(pqSMTKRenderResourceBehavior);
};
#endif // smtk_extension_paraview_appcomponents_pqSMTKRenderResourceBehavior_h
......@@ -11,6 +11,7 @@
#include "smtk/extension/paraview/appcomponents/pqSMTKBehavior.h"
#include "smtk/extension/paraview/appcomponents/pqSMTKModelRepresentation.h"
#include "smtk/extension/paraview/appcomponents/pqSMTKRenderResourceBehavior.h"
#include "smtk/extension/paraview/appcomponents/pqSMTKResource.h"
#include "smtk/extension/paraview/appcomponents/pqSMTKWrapper.h"
......@@ -109,6 +110,12 @@ public:
{
auto view = pqActiveObjects::instance().activeView();
auto pvrc = smtkBehavior->getPVResource(mResource);
// If we are trying to get the value of a resource that has no
// pipeline source, we create one.
if (pvrc == nullptr)
{
pvrc = pqSMTKRenderResourceBehavior::instance()->createPipelineSource(mResource);
}
auto mapr = pvrc ? pvrc->getRepresentation(view) : nullptr;
return mapr ? mapr->isVisible() : 0;
}
......
......@@ -100,7 +100,8 @@
name="ResourceId"
command="SetResourceById"
animateable="0"
number_of_elements="1">
number_of_elements="1"
panel_visibility="never">
<Documentation>
A string representation of a resource Id.
</Documentation>
......@@ -324,7 +325,8 @@
proxyname="SMTKResource">
</Proxy>
<ExposedProperties>
<Property name="ResourceId" />
<Property name="ResourceId"
panel_visibility="never" />
</ExposedProperties>
</SubProxy>
<OutputPort index="0" name="entities"/>
......
......@@ -174,8 +174,9 @@ void qtOperationView::onOperate()
{
if ((!m_applied) && this->Internals->m_instancedView->isValid())
{
this->Internals->m_operator->operate();
auto result = this->Internals->m_operator->operate();
emit this->operationRequested(this->Internals->m_operator);
emit this->operationExecuted(result);
if (this->Internals->m_applyButton)
{ // The button may disappear when a session is closed by an operator.
this->Internals->m_applyButton->setEnabled(false);
......
......@@ -15,6 +15,8 @@
#ifndef __smtk_extension_qtOperationView_h
#define __smtk_extension_qtOperationView_h
#include "smtk/operation/Operation.h"
#include "smtk/extension/qt/Exports.h"
#include "smtk/extension/qt/qtBaseView.h"
......@@ -71,6 +73,12 @@ public slots:
signals:
void operationRequested(const smtk::operation::OperationPtr& brOp);
// Currently, the operation view is responsible for executing the operation.
// Since some processes need to distinguish between results from the operation
// view and results coming from other places, we signal the results of
// operations specifically executed within this view.
void operationExecuted(const smtk::operation::Operation::Result& result);
protected:
void createWidget() override;
void setInfoToBeDisplayed() override;
......
......@@ -151,6 +151,9 @@ CreateUniformGrid::Result CreateUniformGrid::operateInternal()
// session.
collection->setModelResource(resource);
// Also assign the collection to be the model's tessellation
resource->setMeshTessellations(collection);
// Create a model with the appropriate dimension
smtk::model::Model model = resource->addModel(3, 3);
......
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