Commit 4eb139ee authored by Sebastien Jourdain's avatar Sebastien Jourdain
Browse files

Update the code base of ThreeSliceView

Change-Id: I9ada2488fe86c8238e482229392ff5f5c1f1049a
parent 1997ccbb
......@@ -58,8 +58,10 @@ IF(PARAVIEW_BUILD_QT_GUI)
SERVER_MANAGER_SOURCES
vtkCompositeMultiSliceRepresentation.cxx
vtkMultiSliceRepresentation.cxx
vtkThreeSliceFilter.cxx
vtkPVThreeSliceView.cxx
vtkSMMultiSliceViewProxy.cxx
vtkSMThreeSliceViewProxy.cxx
vtkThreeSliceFilter.cxx
SERVER_MANAGER_XML
SliceViews.xml
......
......@@ -6,10 +6,147 @@
representation_name="CompositeMultiSliceRepresentation">
</MultiSliceViewProxy>
<RenderViewProxy name="ThreeSlice" class="vtkPVRenderView"
processes="client|renderserver|dataserver"
base_proxygroup="views" base_proxyname="RenderView">
</RenderViewProxy>
<ThreeSliceViewProxy name="ThreeSlice" class="vtkPVThreeSliceView"
processes="client">
<SubProxy>
<Proxy name="TopLeft" proxygroup="views" proxyname="RenderView"/>
</SubProxy>
<SubProxy>
<Proxy name="TopRight" proxygroup="views" proxyname="RenderView"/>
</SubProxy>
<SubProxy>
<Proxy name="BottomLeft" proxygroup="views" proxyname="RenderView"/>
</SubProxy>
<SubProxy>
<Proxy name="BottomRight" proxygroup="views" proxyname="RenderView"/>
<ExposedProperties>
<Property name="LODThreshold" />
<Property name="LODResolution" />
<Property name="ResetCamera" />
<Property name="UseLight" />
<!-- Light -->
<Property name="LightAmbientColor" />
<Property name="LightDiffuseColor" />
<Property name="LightSpecularColor" />
<Property name="LightIntensity" />
<Property name="LightSwitch" />
<!-- LightKit -->
<Property name="KeyLightWarmth" />
<Property name="KeyLightIntensity" />
<Property name="KeyLightElevation" />
<Property name="KeyLightAzimuth" />
<Property name="FillLightWarmth" />
<Property name="FillLightK:F Ratio" />
<Property name="FillLightElevation" />
<Property name="FillLightAzimuth" />
<Property name="BackLightWarmth" />
<Property name="BackLightK:B Ratio" />
<Property name="BackLightElevation" />
<Property name="BackLightAzimuth" />
<Property name="HeadLightWarmth" />
<Property name="HeadLightK:H Ratio" />
<Property name="MaintainLuminance" />
<!-- ActiveCamera -->
<Property name="CameraPositionInfo" />
<Property name="CameraPosition" />
<Property name="CameraFocalPointInfo" />
<Property name="CameraFocalPoint" />
<Property name="CameraViewUpInfo" />
<Property name="CameraViewUp" />
<Property name="CameraViewAngle" />
<Property name="CameraClippingRangeInfo" />
<Property name="CameraClippingRange" />
<Property name="CameraParallelScale" />
<Property name="CameraParallelScaleInfo" />
<Property name="CameraParallelProjection" />
<Property name="EyeAngle" />
<!-- Interactor -->
<Property name="InteractionMode" />
<Property name="Camera3DManipulators" />
<Property name="Camera2DManipulators" />
<Property name="CenterOfRotation" />
<!-- Annotations -->
<Property name="CenterAxesVisibility" />
<Property name="OrientationAxesInteractivity" />
<Property name="OrientationAxesVisibility" />
<Property name="OrientationAxesLabelColor" />
<Property name="OrientationAxesOutlineColor" />
<!-- Renderer -->
<Property name="Background" />
<Property name="Background2" />
<Property name="BackgroundTexture" />
<Property name="UseGradientBackground" />
<Property name="UseTexturedBackground" />
<Property name="StereoRender" />
<Property name="StereoType" />
<!-- RenderWindow -->
</ExposedProperties>
</SubProxy>
<Property name="Trigger" command="Update"/>
<ProxyProperty name="Representations"
argument_type="SMProxy"
command="AddRepresentation"
remove_command="RemoveRepresentation"
repeatable="1">
<Documentation>Representations in this view.</Documentation>
</ProxyProperty>
<DoubleVectorProperty command="SetViewTime"
default_values="none"
name="ViewTime"
number_of_elements="1"
state_ignored="1">
<DoubleRangeDomain name="range" />
<Documentation>The pipeline update time for this view. This gets passed
to all representations added to this view.</Documentation>
</DoubleVectorProperty>
<DoubleVectorProperty default_values="none"
name="CacheKey"
number_of_elements="1"
state_ignored="1">
<DoubleRangeDomain name="range" />
<Documentation>This is the cache key used to indentify which cache
entry to use for rendering when caching is enabled.</Documentation>
</DoubleVectorProperty>
<IntVectorProperty default_values="0"
name="UseCache"
number_of_elements="1"
state_ignored="1">
<BooleanDomain name="bool" />
<Documentation>Indicates whether to use cache for subsequent
renderings.</Documentation>
</IntVectorProperty>
<IntVectorProperty default_values="0 0"
name="ViewPosition"
number_of_elements="2">
<Hints>
<NoDefault />
</Hints>
<Documentation>Set the position on this view in the multiview
configuration.</Documentation>
</IntVectorProperty>
<IntVectorProperty default_values="400 400"
ignore_synchronization="1"
name="ViewSize"
number_of_elements="2"
state_ignored="1">
<Hints>
<NoDefault />
</Hints>
<Documentation>Set the size of this view in the multiview
configuration.</Documentation>
</IntVectorProperty>
</ThreeSliceViewProxy>
</ProxyGroup>
<!-- ================================================================== -->
......@@ -21,7 +158,6 @@
base_proxygroup="representations"
base_proxyname="SurfaceRepresentation">
<DoubleVectorProperty name="XSlicesValues"
command="SetSliceX"
repeat_command="1"
......@@ -29,6 +165,16 @@
number_of_elements_per_command="1"
use_index="1"/>
<DoubleVectorProperty name="XSlicesNormal"
command="SetSliceXNormal"
number_of_elements="3"
default_values="1 0 0"/>
<DoubleVectorProperty name="XSlicesOrigin"
command="SetSliceXOrigin"
number_of_elements="3"
default_values="0 0 0"/>
<DoubleVectorProperty name="YSlicesValues"
command="SetSliceY"
repeat_command="1"
......@@ -36,14 +182,47 @@
number_of_elements_per_command="1"
use_index="1"/>
<DoubleVectorProperty name="YSlicesNormal"
command="SetSliceYNormal"
number_of_elements="3"
default_values="0 1 0"/>
<DoubleVectorProperty name="YSlicesOrigin"
command="SetSliceYOrigin"
number_of_elements="3"
default_values="0 0 0"/>
<DoubleVectorProperty name="ZSlicesValues"
command="SetSliceZ"
repeat_command="1"
set_number_command="SetNumberOfSliceZ"
number_of_elements_per_command="1"
use_index="1"/>
<DoubleVectorProperty name="ZSlicesNormal"
command="SetSliceZNormal"
number_of_elements="3"
default_values="0 0 1"/>
<DoubleVectorProperty name="ZSlicesOrigin"
command="SetSliceZOrigin"
number_of_elements="3"
default_values="0 0 0"/>
<IntVectorProperty command="SetPortToUse"
default_values="0"
name="OutputType"
number_of_elements="1">
<EnumerationDomain name="enum">
<Entry text="ALL" value="0" />
<Entry text="SLICE_X" value="1" />
<Entry text="SLICE_Y" value="2" />
<Entry text="SLICE_Z" value="3" />
</EnumerationDomain>
</IntVectorProperty>
</RepresentationProxy>
<PVRepresentationProxy name="CompositeMultiSliceRepresentation"
class="vtkCompositeMultiSliceRepresentation"
processes="client|renderserver|dataserver">
......@@ -176,6 +355,15 @@
<Property name="XSlicesValues" panel_visibility="never"/>
<Property name="YSlicesValues" panel_visibility="never"/>
<Property name="ZSlicesValues" panel_visibility="never"/>
<Property name="XSlicesNormal" panel_visibility="never"/>
<Property name="YSlicesNormal" panel_visibility="never"/>
<Property name="ZSlicesNormal" panel_visibility="never"/>
<Property name="XSlicesOrigin" panel_visibility="never"/>
<Property name="YSlicesOrigin" panel_visibility="never"/>
<Property name="ZSlicesOrigin" panel_visibility="never"/>
<PropertyGroup type="ColorEditor" panel_visibility="default">
<Property name="AllowSpecularHighlightingWithScalarColoring"/>
<Property name="Ambient" />
......@@ -209,6 +397,7 @@
<Property name="StaticMode" panel_visibility="never" />
<Property name="SuppressLOD" panel_visibility="never" />
<Property name="Texture" panel_visibility="never" />
<Property name="OutputType" panel_visibility="never" />
</ExposedProperties>
</SubProxy>
......
......@@ -27,11 +27,15 @@
#include "vtkMath.h"
#include "vtkNew.h"
#include "vtkPVRenderView.h"
#include "vtkSMMultiSliceViewProxy.h"
#include "vtkSMProperty.h"
#include "vtkSMPropertyHelper.h"
#include "vtkSMPropertyLink.h"
#include "vtkSMRenderViewProxy.h"
#include "vtkSMRepresentationProxy.h"
#include "vtkSMSessionProxyManager.h"
#include "vtkSMThreeSliceViewProxy.h"
#include "vtkSMThreeSliceViewProxy.h"
#include "vtkSmartPointer.h"
#include "vtkView.h"
......@@ -41,19 +45,23 @@
class pqThreeSliceView::pqInternal
{
public:
QPointer<QVTKWidget> MainWidget;
QPointer<pqThreeSliceView> Parent;
QPointer<QVTKWidget> TopLeftWidget;
QPointer<QVTKWidget> TopRightWidget;
QPointer<QVTKWidget> BottomLeftWidget;
QPointer<QVTKWidget> BottomRightWidget;
QPointer<pqRenderView> TopLeftRenderer;
QPointer<pqRenderView> TopRightRenderer;
QPointer<pqRenderView> BottomLeftRenderer;
QPointer<pqRenderView> BottomRightRenderer;
vtkSmartPointer<vtkSMViewProxy> ViewProxy;
vtkSmartPointer<vtkSMThreeSliceViewProxy> ViewProxy;
vtkSmartPointer<vtkSMRenderViewProxy> TopLeftProxy;
vtkSmartPointer<vtkSMRenderViewProxy> TopRightProxy;
vtkSmartPointer<vtkSMRenderViewProxy> BottomLeftProxy;
vtkSmartPointer<vtkSMRenderViewProxy> BottomRightProxy;
std::vector<vtkSmartPointer<vtkSMPropertyLink> > Links;
......@@ -67,16 +75,9 @@ public:
// ------
void AddLink(const char* property)
pqInternal(pqThreeSliceView* parent)
{
vtkNew<vtkSMPropertyLink> link;
link->AddLinkedProperty(this->ViewProxy, property, vtkSMLink::INPUT);
link->AddLinkedProperty(this->TopLeftProxy, property, vtkSMLink::OUTPUT);
link->AddLinkedProperty(this->TopRightProxy, property, vtkSMLink::OUTPUT);
link->AddLinkedProperty(this->BottomLeftProxy, property, vtkSMLink::OUTPUT);
// Keep it with auto-delete
this->Links.push_back(link.GetPointer());
this->Parent = parent;
}
// ------
......@@ -109,6 +110,37 @@ public:
const char* position = "CameraPosition";
const char* viewUp = "CameraViewUp";
// Update slice origin + normal
foreach(pqRepresentation* rep, this->Parent->getRepresentations())
{
if( rep->isWidgetType() ||
!rep->getProxy()->GetProperty("XSlicesValues"))
{
continue;
}
vtkSMRepresentationProxy* smRep =
vtkSMRepresentationProxy::SafeDownCast(rep->getProxy());
vtkSMPropertyHelper(smRep, "XSlicesOrigin").Set(this->SlicesOrigin, 3);
vtkSMPropertyHelper(smRep, "YSlicesOrigin").Set(this->SlicesOrigin, 3);
vtkSMPropertyHelper(smRep, "ZSlicesOrigin").Set(this->SlicesOrigin, 3);
double value[1] = {0.0};
vtkSMPropertyHelper(smRep, "XSlicesValues").Set(value, 1);
vtkSMPropertyHelper(smRep, "YSlicesValues").Set(value, 1);
vtkSMPropertyHelper(smRep, "ZSlicesValues").Set(value, 1);
vtkSMPropertyHelper(smRep, "XSlicesNormal").Set(this->TopLeftNormal, 3);
vtkSMPropertyHelper(smRep, "YSlicesNormal").Set(this->TopRightNormal, 3);
vtkSMPropertyHelper(smRep, "ZSlicesNormal").Set(this->BottomLeftNormal, 3);
smRep->UpdateVTKObjects();
}
// Invalidate the proxy
this->Parent->getThreeSliceViewProxy()->MarkDirty(NULL);
this->Parent->getThreeSliceViewProxy()->Update();
// Update X (Top-Left)
vtkSMPropertyHelper(this->TopLeftProxy, focalPoint).Get(cameraPosition, 3);
vtkMath::Add(cameraPosition, this->TopLeftNormal, cameraPosition);
......@@ -129,6 +161,8 @@ public:
vtkSMPropertyHelper(this->BottomLeftProxy, position).Set(cameraPosition, 3);
vtkSMPropertyHelper(this->BottomLeftProxy, viewUp).Set(this->BottomLeftViewUp, 3);
this->BottomLeftProxy->InvokeCommand("ResetCamera");
this->Parent->render();
}
// ------
......@@ -136,26 +170,19 @@ public:
void Initialize(pqServer* server, const QString& viewType, const QString& group,
const QString& name, vtkSMViewProxy* mainViewProxy, QObject* p)
{
vtkSMSessionProxyManager* spxm = server->proxyManager();
const char* g = "views";
const char* t = "2DRenderView";
this->ResetToDefault();
this->ViewProxy = mainViewProxy;
this->TopLeftProxy = vtkSMRenderViewProxy::SafeDownCast(spxm->NewProxy(g,t));
this->TopLeftProxy->FastDelete();
this->TopRightProxy = vtkSMRenderViewProxy::SafeDownCast(spxm->NewProxy(g,t));
this->TopRightProxy->FastDelete();
this->ViewProxy = vtkSMThreeSliceViewProxy::SafeDownCast(mainViewProxy);
this->BottomLeftProxy = vtkSMRenderViewProxy::SafeDownCast(spxm->NewProxy(g,t));
this->BottomLeftProxy->FastDelete();
this->TopLeftProxy = this->ViewProxy->GetTopLeftViewProxy();
this->TopRightProxy = this->ViewProxy->GetTopRightViewProxy();
this->BottomLeftProxy = this->ViewProxy->GetBottomLeftViewProxy();
this->BottomRightProxy = this->ViewProxy->GetBottomRightViewProxy();
this->TopLeftRenderer = new pqRenderView(viewType, group, name, this->TopLeftProxy, server, p);
this->TopRightRenderer = new pqRenderView(viewType, group, name, this->TopRightProxy, server, p);
this->BottomLeftRenderer = new pqRenderView(viewType, group, name, this->BottomLeftProxy, server, p);
this->BottomRightRenderer = new pqRenderView(viewType, group, name, this->BottomRightProxy, server, p);
}
// ------
......@@ -163,7 +190,7 @@ public:
QWidget* CreateWidget(pqThreeSliceView* view)
{
// Get the internal widget that we want to decorate
this->MainWidget = qobject_cast<QVTKWidget*>(view->pqRenderView::createWidget());
this->BottomRightWidget = qobject_cast<QVTKWidget*>(this->BottomRightRenderer->getWidget());
this->TopLeftWidget = qobject_cast<QVTKWidget*>(this->TopLeftRenderer->getWidget());
this->TopRightWidget = qobject_cast<QVTKWidget*>(this->TopRightRenderer->getWidget());
this->BottomLeftWidget = qobject_cast<QVTKWidget*>(this->BottomLeftRenderer->getWidget());
......@@ -174,26 +201,18 @@ public:
container->setAutoFillBackground(true);
QGridLayout* gridLayout = new QGridLayout(container);
this->MainWidget->setParent(container);
gridLayout->addWidget(this->TopLeftWidget, 0, 0); // TOP-LEFT
gridLayout->addWidget(this->TopRightWidget, 0, 1); // TOP-RIGHT
gridLayout->addWidget(this->BottomLeftWidget, 1, 0); // BOTTOM-LEFT
gridLayout->addWidget(this->MainWidget, 1, 1); // BOTTOM-RIGHT
gridLayout->addWidget(this->BottomRightWidget,1, 1); // BOTTOM-RIGHT
gridLayout->setContentsMargins(0,0,0,0);
gridLayout->setSpacing(0);
// Properly do the binding between the proxy and the 3D widget
vtkSMRenderViewProxy* renModule = view->getRenderViewProxy();
if (this->MainWidget && renModule)
{
this->MainWidget->SetRenderWindow(renModule->GetRenderWindow());
}
// For axis
this->TopLeftWidget->SetRenderWindow(this->TopLeftProxy->GetRenderWindow());
this->TopRightWidget->SetRenderWindow(this->TopRightProxy->GetRenderWindow());
this->BottomLeftWidget->SetRenderWindow(this->BottomLeftProxy->GetRenderWindow());
this->BottomRightWidget->SetRenderWindow(this->BottomRightProxy->GetRenderWindow());
return container;
}
......@@ -205,43 +224,8 @@ pqThreeSliceView::pqThreeSliceView(
vtkSMViewProxy* viewProxy, pqServer* server, QObject* p)
: pqRenderView(viewType, group, name, viewProxy, server, p)
{
this->Internal = new pqInternal();
this->Internal = new pqInternal(this);
this->Internal->Initialize(server, viewType, group, name, viewProxy, this);
// Bind properties across views
this->Internal->AddLink("UseLight");
this->Internal->AddLink("LightSwitch");
this->Internal->AddLink("CenterAxesVisibility");
this->Internal->AddLink("OrientationAxesVisibility");
this->Internal->AddLink("KeyLightWarmth");
this->Internal->AddLink("KeyLightIntensity");
this->Internal->AddLink("KeyLightElevation");
this->Internal->AddLink("KeyLightAzimuth");
this->Internal->AddLink("FillLightWarmth");
this->Internal->AddLink("FillLightK:F Ratio");
this->Internal->AddLink("FillLightElevation");
this->Internal->AddLink("FillLightAzimuth");
this->Internal->AddLink("BackLightWarmth");
this->Internal->AddLink("BackLightK:B Ratio");
this->Internal->AddLink("BackLightElevation");
this->Internal->AddLink("BackLightAzimuth");
this->Internal->AddLink("HeadLightWarmth");
this->Internal->AddLink("HeadLightK:H Ratio");
this->Internal->AddLink("MaintainLuminance");
this->Internal->AddLink("Background");
this->Internal->AddLink("Background2");
this->Internal->AddLink("BackgroundTexture");
this->Internal->AddLink("UseGradientBackground");
this->Internal->AddLink("UseTexturedBackground");
this->Internal->AddLink("LightAmbientColor");
this->Internal->AddLink("LightSpecularColor");
this->Internal->AddLink("LightDiffuseColor");
this->Internal->AddLink("LightIntensity");
this->Internal->AddLink("LightType");
// TMP for debuging/testing
this->Internal->AddLink("Representations");
this->Internal->AddLink("ResetCamera");
}
//-----------------------------------------------------------------------------
......@@ -265,20 +249,19 @@ QWidget* pqThreeSliceView::createWidget()
//-----------------------------------------------------------------------------
void pqThreeSliceView::resetCamera()
{
this->pqRenderView::resetCamera();
this->Internal->TopLeftProxy->InvokeCommand("ResetCamera");
this->Internal->TopRightProxy->InvokeCommand("ResetCamera");
this->Internal->BottomLeftProxy->InvokeCommand("ResetCamera");
this->Internal->BottomRightProxy->InvokeCommand("ResetCamera");
this->render();
}
//-----------------------------------------------------------------------------
void pqThreeSliceView::render()
{
this->pqRenderView::render();
this->Internal->TopLeftRenderer->render();
this->Internal->TopRightRenderer->render();
this->Internal->BottomLeftRenderer->render();
this->Internal->BottomRightRenderer->render();
}
//-----------------------------------------------------------------------------
const double* pqThreeSliceView::getTopLeftNormal() const
......@@ -385,3 +368,15 @@ void pqThreeSliceView::resetDefaultSettings()
this->Internal->ResetToDefault();
this->Internal->UpdateSlices();
}
//-----------------------------------------------------------------------------
vtkSMThreeSliceViewProxy* pqThreeSliceView::getThreeSliceViewProxy() const
{
return vtkSMThreeSliceViewProxy::SafeDownCast(this->getProxy());
}
//-----------------------------------------------------------------------------
vtkSMRenderViewProxy* pqThreeSliceView::getRenderViewProxy() const
{
return vtkSMRenderViewProxy::SafeDownCast(
this->getThreeSliceViewProxy()->GetBottomRightViewProxy());
}
......@@ -12,7 +12,8 @@
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME pqThreeSliceView - QT GUI that allow 3 slice control across 4 view embedded as 1
// .NAME pqThreeSliceView - QT GUI that allow 3 slice control across 4 views
// embedded as 1
#ifndef __pqThreeSliceView_h
#define __pqThreeSliceView_h
......@@ -25,8 +26,8 @@
class QVTKWidget;
class pqRenderView;
class vtkSMPropertyLink;
class vtkSMThreeSliceViewProxy;
class vtkSMViewProxy;
class vtkEventQtSlotConnect;
class pqThreeSliceView : public pqRenderView
{
......@@ -46,9 +47,6 @@ public:
QObject* p);
virtual ~pqThreeSliceView();
/// Override to decorate the QVTKWidget
virtual QWidget* createWidget();
/// Redirect reset camera to all views
virtual void resetCamera();
......@@ -89,6 +87,16 @@ public:
/// Reset Normal/ViewUp/Origin to their defaults
void resetDefaultSettings();
/// Returns the ThreeSlice view proxy.
vtkSMThreeSliceViewProxy* getThreeSliceViewProxy() const;
/// Returns the root render view in the ThreeSlice view.
virtual vtkSMRenderViewProxy* getRenderViewProxy() const;
protected:
/// Override to decorate the QVTKWidget
virtual QWidget* createWidget();
public slots:
/// Request a StillRender on idle. Multiple calls are collapsed into one.
virtual void render();
......
......@@ -12,14 +12,11 @@
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkPVCompositeRepresentation - a data-representation used by ParaView.
// .NAME vtkCompositeMultiSliceRepresentation - a data-representation used by ParaView.
// .SECTION Description
// vtkPVCompositeRepresentation is a data-representation used by ParaView for showing
// a type of data-set in the render view. It is a composite-representation with
// some fixed representations for showing things like selection and cube-axes.
// This representation has two input ports:
// \li 0: the dataset to show
// \li 1: the extracted selection to show
// vtkCompositeMultiSliceRepresentation is similar to
// vtkPVCompositeRepresentation but with a MultiSlice Representation as only
// choice underneath.
#ifndef __vtkCompositeMultiSliceRepresentation_h
#define __vtkCompositeMultiSliceRepresentation_h
......
......@@ -15,20 +15,22 @@
#include "vtkMultiSliceRepresentation.h"
#include "vtkAppendFilter.h"
#include "vtkCommand.h"
#include "vtkCompositePolyDataMapper2.h"
#include "vtkCutter.h"
#include "vtkHardwareSelectionPolyDataPainter.h"
#include "vtkMapper.h"
#include "vtkNew.h"
#include "vtkObjectFactory.h"
#include "vtkThreeSliceFilter.h"
#include "vtkPlane.h"
#include "vtkSelection.h"
#include "vtkThreeSliceFilter.h"
vtkStandardNewMacro(vtkMultiSliceRepresentation);
//----------------------------------------------------------------------------
vtkMultiSliceRepresentation::vtkMultiSliceRepresentation()
{
this->PortToUse = 0; // All the slices by default