Commit 119721c3 authored by Sebastien Jourdain's avatar Sebastien Jourdain
Browse files

Add new view proxy to only support one representation at a time

Change-Id: I2f4ec3ef1dcf8b0d90369efa3330ace094efe2d5
parent f0f8655d
......@@ -56,6 +56,8 @@ IF(PARAVIEW_BUILD_QT_GUI)
ADD_PARAVIEW_PLUGIN(MultiSliceView "1.0"
SERVER_MANAGER_SOURCES
vtkMultiSliceRepresentation.cxx
vtkOrthogonalSliceFilter.cxx
vtkSMMultiSliceViewProxy.cxx
SERVER_MANAGER_XML
SliceViews.xml
GUI_INTERFACES
......
<ServerManagerConfiguration>
<ProxyGroup name="views">
<RenderViewProxy name="MultiSlice" class="vtkPVRenderView"
<MultiSliceViewProxy name="MultiSlice" class="vtkPVRenderView"
processes="client|renderserver|dataserver"
base_proxygroup="views" base_proxyname="RenderView"
representation_name="vtkMultiSliceRepresentation">
</RenderViewProxy>
</MultiSliceViewProxy>
<RenderViewProxy name="ThreeSlice" class="vtkPVRenderView"
processes="client|renderserver|dataserver"
......
/*=========================================================================
Program: Visualization Toolkit
Module: vtkOrthogonalSliceFilter.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm 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 "vtkOrthogonalSliceFilter.h"
#include "vtkAppendPolyData.h"
#include "vtkContourValues.h"
#include "vtkCutter.h"
#include "vtkDataSet.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkNew.h"
#include "vtkObjectFactory.h"
#include "vtkPlane.h"
#include <math.h>
vtkStandardNewMacro(vtkOrthogonalSliceFilter);
//----------------------------------------------------------------------------
vtkOrthogonalSliceFilter::vtkOrthogonalSliceFilter()
{
this->SliceAlongX = vtkCutter::New();
this->SliceAlongY = vtkCutter::New();
this->SliceAlongZ = vtkCutter::New();
vtkNew<vtkPlane> planeX;
planeX->SetNormal(1,0,0);
planeX->SetOrigin(0,0,0);
this->SliceAlongX->SetCutFunction(planeX.GetPointer());
vtkNew<vtkPlane> planeY;
planeY->SetNormal(0,1,0);
planeY->SetOrigin(0,0,0);
this->SliceAlongY->SetCutFunction(planeY.GetPointer());
vtkNew<vtkPlane> planeZ;
planeZ->SetNormal(0,0,1);
planeZ->SetOrigin(0,0,0);
this->SliceAlongZ->SetCutFunction(planeZ.GetPointer());
this->CombinedFilteredInput = vtkAppendPolyData::New();
this->CombinedFilteredInput->AddInputConnection(this->SliceAlongX->GetOutputPort());
this->CombinedFilteredInput->AddInputConnection(this->SliceAlongY->GetOutputPort());
this->CombinedFilteredInput->AddInputConnection(this->SliceAlongZ->GetOutputPort());
}
//----------------------------------------------------------------------------
vtkOrthogonalSliceFilter::~vtkOrthogonalSliceFilter()
{
this->SliceAlongX->Delete();
this->SliceAlongY->Delete();
this->SliceAlongZ->Delete();
this->SliceAlongX = this->SliceAlongY = this->SliceAlongZ = NULL;
this->CombinedFilteredInput->Delete();
this->CombinedFilteredInput = NULL;
}
//----------------------------------------------------------------------------
unsigned long vtkOrthogonalSliceFilter::GetMTime()
{
unsigned long mTime=this->Superclass::GetMTime();
unsigned long internalMTime = 0;
// Test slice along X
internalMTime = this->SliceAlongX->GetMTime();
mTime = ( internalMTime > mTime ? internalMTime : mTime );
// Test slice along Y
internalMTime = this->SliceAlongY->GetMTime();
mTime = ( internalMTime > mTime ? internalMTime : mTime );
// Test slice along Z
internalMTime = this->SliceAlongZ->GetMTime();
mTime = ( internalMTime > mTime ? internalMTime : mTime );
// Test Append filter
internalMTime = this->CombinedFilteredInput->GetMTime();
mTime = ( internalMTime > mTime ? internalMTime : mTime );
return mTime;
}
//----------------------------------------------------------------------------
void vtkOrthogonalSliceFilter::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
//----------------------------------------------------------------------------
void vtkOrthogonalSliceFilter::SetSliceX(int index, double value)
{
this->SetSlice(this->SliceAlongX, index, value);
}
//----------------------------------------------------------------------------
void vtkOrthogonalSliceFilter::SetNumberOfSliceX(int size)
{
this->SetNumberOfSlice(this->SliceAlongX, size);
}
//----------------------------------------------------------------------------
void vtkOrthogonalSliceFilter::SetSliceY(int index, double value)
{
this->SetSlice(this->SliceAlongY, index, value);
}
//----------------------------------------------------------------------------
void vtkOrthogonalSliceFilter::SetNumberOfSliceY(int size)
{
this->SetNumberOfSlice(this->SliceAlongY, size);
}
//----------------------------------------------------------------------------
void vtkOrthogonalSliceFilter::SetSliceZ(int index, double value)
{
this->SetSlice(this->SliceAlongZ, index, value);
}
//----------------------------------------------------------------------------
void vtkOrthogonalSliceFilter::SetNumberOfSliceZ(int size)
{
this->SetNumberOfSlice(this->SliceAlongZ, size);
}
//----------------------------------------------------------------------------
void vtkOrthogonalSliceFilter::SetSlice(vtkCutter* slice, int index, double value)
{
if(slice->GetValue(index) != value)
{
slice->SetValue(index, value);
this->Modified();
}
}
//----------------------------------------------------------------------------
void vtkOrthogonalSliceFilter::SetNumberOfSlice(vtkCutter* slice, int size)
{
if(size != slice->GetNumberOfContours())
{
slice->SetNumberOfContours(size);
this->Modified();
}
}
//-----------------------------------------------------------------------
int vtkOrthogonalSliceFilter::FillInputPortInformation(int, vtkInformation *info)
{
info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataSet");
return 1;
}
//-----------------------------------------------------------------------
int vtkOrthogonalSliceFilter::RequestData( vtkInformation *,
vtkInformationVector **inputVector,
vtkInformationVector *outputVector)
{
// get the info objects
vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
vtkInformation *outInfo = outputVector->GetInformationObject(0);
// get the input and output
vtkDataSet *input =
vtkDataSet::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
vtkPolyData *output =
vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
this->SliceAlongX->SetInputData(input);
this->SliceAlongY->SetInputData(input);
this->SliceAlongZ->SetInputData(input);
// Update the internal pipeline
this->CombinedFilteredInput->Update();
// Copy generated output to filter output
output->ShallowCopy(this->CombinedFilteredInput->GetOutput());
return 1;
}
/*=========================================================================
Program: Visualization Toolkit
Module: vtkOrthogonalSliceFilter.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm 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.
=========================================================================*/
// .NAME vtkOrthogonalSliceFilter - Cut vtkDataSet with 3 orthogonal planes
// .SECTION Description
// vtkOrthogonalSliceFilter is a filter to cut through data using 3 orthogonal
// plane that could be duplicated along each axis.
#ifndef __vtkOrthogonalSliceFilter_h
#define __vtkOrthogonalSliceFilter_h
#include "vtkPolyDataAlgorithm.h"
class vtkCutter;
class vtkAppendPolyData;
class vtkOrthogonalSliceFilter : public vtkPolyDataAlgorithm
{
public:
vtkTypeMacro(vtkOrthogonalSliceFilter,vtkPolyDataAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Construct with user-specified implicit function; initial value of 0.0; and
// generating cut scalars turned off.
static vtkOrthogonalSliceFilter *New();
// Description:
// Override GetMTime because we rely on internal filters that have their own MTime
unsigned long GetMTime();
// Description:
// Manage slices normal to X
void SetSliceX(int index, double sliceValue);
void SetNumberOfSliceX(int size);
// Description:
// Manage slices normal to Y
void SetSliceY(int index, double sliceValue);
void SetNumberOfSliceY(int size);
// Description:
// Manage slices normal to Z
void SetSliceZ(int index, double sliceValue);
void SetNumberOfSliceZ(int size);
protected:
vtkOrthogonalSliceFilter();
~vtkOrthogonalSliceFilter();
virtual int FillInputPortInformation(int port, vtkInformation *info);
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
vtkCutter* SliceAlongX;
vtkCutter* SliceAlongY;
vtkCutter* SliceAlongZ;
vtkAppendPolyData* CombinedFilteredInput;
void SetSlice(vtkCutter* slice, int index, double value);
void SetNumberOfSlice(vtkCutter* slice, int size);
private:
vtkOrthogonalSliceFilter(const vtkOrthogonalSliceFilter&); // Not implemented.
void operator=(const vtkOrthogonalSliceFilter&); // Not implemented.
};
#endif
/*=========================================================================
Program: ParaView
Module: vtkSMMultiSliceViewProxy.cxx
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html 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 "vtkSMMultiSliceViewProxy.h"
#include "vtkObjectFactory.h"
#include "vtkSMInputProperty.h"
#include "vtkSMPropertyHelper.h"
#include "vtkSMProxyManager.h"
#include "vtkSMSessionProxyManager.h"
#include "vtkSMRepresentationProxy.h"
#include "vtkSMSourceProxy.h"
#include <assert.h>
vtkStandardNewMacro(vtkSMMultiSliceViewProxy);
//----------------------------------------------------------------------------
vtkSMMultiSliceViewProxy::vtkSMMultiSliceViewProxy()
{
}
//----------------------------------------------------------------------------
vtkSMMultiSliceViewProxy::~vtkSMMultiSliceViewProxy()
{
}
//----------------------------------------------------------------------------
vtkSMRepresentationProxy* vtkSMMultiSliceViewProxy::CreateDefaultRepresentation(
vtkSMProxy* source, int opport)
{
if (!source)
{
return 0;
}
assert("Session should be valid" && this->GetSession());
vtkSMSessionProxyManager* pxm = this->GetSessionProxyManager();
// Update with time to avoid domains updating without time later.
vtkSMSourceProxy* sproxy = vtkSMSourceProxy::SafeDownCast(source);
if (sproxy)
{
double view_time = vtkSMPropertyHelper(this, "ViewTime").GetAsDouble();
sproxy->UpdatePipeline(view_time);
}
// Choose which type of representation proxy to create.
vtkSMProxy* prototype = pxm->GetPrototypeProxy("representations",
"MultiSliceRepresentation");
vtkSMInputProperty* pp = vtkSMInputProperty::SafeDownCast(
prototype->GetProperty("Input"));
pp->RemoveAllUncheckedProxies();
pp->AddUncheckedInputConnection(source, opport);
bool sg = (pp->IsInDomains()>0);
pp->RemoveAllUncheckedProxies();
if (sg)
{
vtkSMRepresentationProxy* repr = vtkSMRepresentationProxy::SafeDownCast(
pxm->NewProxy("representations", "MultiSliceRepresentation"));
return repr;
}
// Currently only images can be shown
vtkErrorMacro("This view only supports Multi-Slice representation.");
return 0;
}
//----------------------------------------------------------------------------
void vtkSMMultiSliceViewProxy::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
/*=========================================================================
Program: ParaView
Module: vtkSMMultiSliceViewProxy.h
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html 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.
=========================================================================*/
// .NAME vtkSMMultiSliceViewProxy
// .SECTION Description
// Custom RenderViewProxy to override CreateDefaultRepresentation method
// so only the Multi-Slice representation will be available to the user
#ifndef __vtkSMMultiSliceViewProxy_h
#define __vtkSMMultiSliceViewProxy_h
#include "vtkSMRenderViewProxy.h"
class VTK_EXPORT vtkSMMultiSliceViewProxy : public vtkSMRenderViewProxy
{
public:
static vtkSMMultiSliceViewProxy* New();
vtkTypeMacro(vtkSMMultiSliceViewProxy, vtkSMRenderViewProxy);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Create a default representation for the given source proxy.
// Returns a new proxy.
virtual vtkSMRepresentationProxy* CreateDefaultRepresentation(vtkSMProxy*, int);
//BTX
protected:
vtkSMMultiSliceViewProxy();
~vtkSMMultiSliceViewProxy();
private:
vtkSMMultiSliceViewProxy(const vtkSMMultiSliceViewProxy&); // Not implemented
void operator=(const vtkSMMultiSliceViewProxy&); // Not implemented
//ETX
};
#endif
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