Commit 260d7067 authored by Yumin Yuan's avatar Yumin Yuan
Browse files

Add X-Y-Z slices at dataset center for Slice View default

Change-Id: I8d27f8c103bd607b664f73ece4756f854f06e6b1
parent e414502e
......@@ -14,7 +14,9 @@
=========================================================================*/
#include "vtkSMMultiSliceViewProxy.h"
#include "vtkBoundingBox.h"
#include "vtkObjectFactory.h"
#include "vtkPVDataInformation.h"
#include "vtkSMInputProperty.h"
#include "vtkSMPropertyHelper.h"
#include "vtkSMProxyManager.h"
......@@ -23,6 +25,7 @@
#include "vtkSMSourceProxy.h"
#include <assert.h>
#include <vector>
vtkStandardNewMacro(vtkSMMultiSliceViewProxy);
//----------------------------------------------------------------------------
......@@ -68,6 +71,7 @@ vtkSMRepresentationProxy* vtkSMMultiSliceViewProxy::CreateDefaultRepresentation(
{
vtkSMRepresentationProxy* repr = vtkSMRepresentationProxy::SafeDownCast(
pxm->NewProxy("representations", "CompositeMultiSliceRepresentation"));
this->InitDefaultSlices(sproxy, opport);
return repr;
}
......@@ -76,6 +80,48 @@ vtkSMRepresentationProxy* vtkSMMultiSliceViewProxy::CreateDefaultRepresentation(
return 0;
}
//-----------------------------------------------------------------------------
void vtkSMMultiSliceViewProxy::InitDefaultSlices(
vtkSMSourceProxy* source, int opport)
{
if (!source)
{
return;
}
double bounds[6] = { VTK_DOUBLE_MAX, VTK_DOUBLE_MIN,
VTK_DOUBLE_MAX, VTK_DOUBLE_MIN,
VTK_DOUBLE_MAX, VTK_DOUBLE_MIN};
vtkPVDataInformation* info = source->GetDataInformation(opport);
if(info)
{
info->GetBounds(bounds);
if(vtkBoundingBox::IsValid(bounds))
{
double center[3];
for(int i=0;i<3;i++)
{
center[i] = (bounds[2*i] + bounds[2*i+1])/2.0;
}
// Add orthogonal X,Y,Z slices based on center position.
std::vector<double> xSlices =
vtkSMPropertyHelper(this, "XSlicesValues").GetDoubleArray();
std::vector<double> ySlices =
vtkSMPropertyHelper(this, "YSlicesValues").GetDoubleArray();
std::vector<double> zSlices =
vtkSMPropertyHelper(this, "ZSlicesValues").GetDoubleArray();
xSlices.push_back(center[0]);
ySlices.push_back(center[1]);
zSlices.push_back(center[2]);
vtkSMPropertyHelper(this, "XSlicesValues").Set(&xSlices[0], xSlices.size());
vtkSMPropertyHelper(this, "YSlicesValues").Set(&ySlices[0], ySlices.size());
vtkSMPropertyHelper(this, "ZSlicesValues").Set(&zSlices[0], ySlices.size());
}
}
}
//----------------------------------------------------------------------------
void vtkSMMultiSliceViewProxy::PrintSelf(ostream& os, vtkIndent indent)
{
......
......@@ -45,6 +45,11 @@ protected:
vtkSMMultiSliceViewProxy();
~vtkSMMultiSliceViewProxy();
// Description:
// Use the center of the source to initialize the view with three orthogonal
// slices in x, y, z.
void InitDefaultSlices(vtkSMSourceProxy* source, int opport);
private:
vtkSMMultiSliceViewProxy(const vtkSMMultiSliceViewProxy&); // Not implemented
void operator=(const vtkSMMultiSliceViewProxy&); // Not implemented
......
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