Re: [Paraview] Incorporating ImplicitPlane widget into ServerManagerXML

2012-08-02 Thread Burlen Loring

In particular, I want a way to get the Camera Normal.
You could get the camera normal inside a custom panel on the client side 
and communicate it to your filter on the server side via the usual sm 
mechanisms. I have written a custom panel for an improved plane source 
in which I wanted to set the camera to look down the normal of a plane. 
Toward the end of that function is some code that sets the camera up 
based on the plane normal. Hope this will give you some ideas.


//-
void pqSQPlaneSource::SnapViewToNormal()
{
  #if defined pqSQPlaneSourceDEBUG
  cerr  :pqSQPlaneSource::SnapViewToNormal  endl;
  #endif

  double o[3];
  this-GetOrigin(o);

  double p1[3];
  this-GetPoint1(p1);

  double p2[3];
  this-GetPoint2(p2);

  // compute the plane's center, this will become the camera focal point.
  double a[3];
  a[0]=o[0]+0.5*(p1[0]-o[0]);
  a[1]=o[1]+0.5*(p1[1]-o[1]);
  a[2]=o[2]+0.5*(p1[2]-o[2]);

  double b[3];
  b[0]=o[0]+0.5*(p2[0]-o[0]);
  b[1]=o[1]+0.5*(p2[1]-o[1]);
  b[2]=o[2]+0.5*(p2[2]-o[2]);

  double cen[3];
  cen[0]=a[0]+b[0]-o[0];
  cen[1]=a[1]+b[1]-o[1];
  cen[2]=a[2]+b[2]-o[2];

  // compute the camera center, 2 plane diagonals along its normal from
  // its center.
  double diag
= sqrt(this-Dims[0]*this-Dims[0]+this-Dims[1]*this-Dims[1]);

  double l_pos[3];
  l_pos[0]=cen[0]+this-N[0]*2.0*diag;
  l_pos[1]=cen[1]+this-N[1]*2.0*diag;
  l_pos[2]=cen[2]+this-N[2]*2.0*diag;

  // compute the camera up from one of the planes axis.
  double up[3];
  if (this-Form-viewUp1-isChecked())
{
up[0]=p1[0]-o[0];
up[1]=p1[1]-o[1];
up[2]=p1[2]-o[2];
}
  else
{
up[0]=p2[0]-o[0];
up[1]=p2[1]-o[1];
up[2]=p2[2]-o[2];
}
  double mup=sqrt(up[0]*up[0]+up[1]*up[1]+up[2]*up[2]);
  up[0]/=mup;
  up[1]/=mup;
  up[2]/=mup;


  pqRenderView *l_view=dynamic_castpqRenderView*(this-view());
  if (!l_view)
{
sqErrorMacro(qDebug(),Failed to get the current view.);
return;
}

  vtkSMRenderViewProxy *l_proxy=l_view-getRenderViewProxy();

  vtkSMDoubleVectorProperty *prop;

  
prop=dynamic_castvtkSMDoubleVectorProperty*(l_proxy-GetProperty(CameraPosition));

  prop-SetElements(l_pos);

  
prop=dynamic_castvtkSMDoubleVectorProperty*(l_proxy-GetProperty(CameraFocalPoint));

  prop-SetElements(cen);

  
prop=dynamic_castvtkSMDoubleVectorProperty*(l_proxy-GetProperty(CameraViewUp));

  prop-SetElements(up);

  
prop=dynamic_castvtkSMDoubleVectorProperty*(l_proxy-GetProperty(CenterOfRotation));

  prop-SetElements(cen);

  l_proxy-UpdateVTKObjects();

  l_view-render();
}

On 08/01/2012 11:40 AM, Alex Rattner wrote:

Hello,

I am trying to develop a compiled paraview filter that takes an input 
plane/direction vector (like the clip or slice filters). Does anyone 
know of example code that shows how to incorporate the ImplicitPlane 
widget into the server manager xml. In particular, I want a way to get 
the Camera Normal. Is this possible?


Thanks,
Alex
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html


Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView


Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview


___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview


Re: [Paraview] Incorporating ImplicitPlane widget into ServerManagerXML

2012-08-02 Thread Alex Rattner

Hi Sebastien,

Thank you very much for the advice. I was able to incorporate the 
implicit_function plane property using this xml as a guide.


-Alex

On 08/01/2012 05:48 PM, Sebastien Jourdain wrote:

Hi Alex,

I don't fully understand what you mean but in ParaView the way clip or
slice are doing is by using some subproxy that define the plane. I've
just paste you both clip and slice proxy definition for convenience.

SourceProxy class=vtkPVMetaClipDataSet
  name=Clip
   Documentation long_help=Clip with an implicit plane. Clipping
does not reduce the dimensionality of the data set. The output data
type of this filter is always an unstructured grid.
  short_help=Clip with an implicit plane.The Clip filter
  cuts away a portion of the input data set using an
  implicit plane. This filter operates on all types of data
  sets, and it returns unstructured grid data on
  output./Documentation
   IntVectorProperty command=PreserveInputCells
  default_values=0
  label=Crinkle clip
  name=PreserveInputCells
  number_of_elements=1
 BooleanDomain name=bool /
 DocumentationThis parameter controls whether to extract entire cells
 in the given region or clip those cells so all of the output one stay
 only inside that region./Documentation
   /IntVectorProperty
   InputProperty command=SetInputConnection
  name=Input
 ProxyGroupDomain name=groups
   Group name=sources /
   Group name=filters /
 /ProxyGroupDomain
 DataTypeDomain name=input_type
   DataType value=vtkDataSet /
 /DataTypeDomain
 InputArrayDomain name=input_array
   number_of_components=1
   optional=1 /
 DocumentationThis property specifies the dataset on which the Clip
 filter will operate./Documentation
   /InputProperty
   ProxyProperty command=SetClipFunction
  label=Clip Type
  name=ClipFunction
 ProxyGroupDomain name=groups
   Group name=implicit_functions /
 /ProxyGroupDomain
 ProxyListDomain name=proxy_list
   Proxy group=implicit_functions
  name=Plane /
   Proxy group=implicit_functions
  name=Box /
   Proxy group=implicit_functions
  name=Sphere /
   Proxy group=implicit_functions
  name=Scalar /
 /ProxyListDomain
 DocumentationThis property specifies the parameters of the clip
 function (an implicit plane) used to clip the dataset./Documentation
 Hints
   ShowInSummaryPanel /
 /Hints
   /ProxyProperty
   DoubleVectorProperty information_only=1
 name=InputBounds
 BoundsDomain name=bounds
   RequiredProperties
 Property function=Input
   name=Input /
   /RequiredProperties
 /BoundsDomain
   /DoubleVectorProperty
   StringVectorProperty animateable=0
 command=SetInputArrayToProcess
 element_types=0 0 0 0 2
 label=Scalars
 name=SelectInputScalars
 number_of_elements=5
 ArrayListDomain attribute_type=Scalars
  name=array_list
   RequiredProperties
 Property function=Input
   name=Input /
   /RequiredProperties
 /ArrayListDomain
 FieldDataDomain name=field_list
   RequiredProperties
 Property function=Input
   name=Input /
   /RequiredProperties
 /FieldDataDomain
 DocumentationIf clipping with scalars, this property specifies the
 name of the scalar array on which to perform the clip
 operation./Documentation
   /StringVectorProperty
   DoubleVectorProperty command=SetValue
 default_values=0.0
 name=Value
 number_of_elements=1
 ArrayRangeDomain name=scalar_range
   RequiredProperties
 Property function=Input
   name=Input /
 Property function=ArraySelection
   name=SelectInputScalars /
   /RequiredProperties
 /ArrayRangeDomain
 DoubleRangeDomain name=range /
 DocumentationIf clipping with scalars, this property sets the scalar
 value about which to clip the dataset based on the scalar array chosen.
 (See SelectInputScalars.) If clipping with a clip function, this
 property specifies an 

Re: [Paraview] Incorporating ImplicitPlane widget into ServerManagerXML

2012-08-02 Thread Alex Rattner

Hi Burlen,

Thank you for sharing the code. I will check it out soon.

-Alex

On 08/02/2012 10:16 AM, Burlen Loring wrote:

In particular, I want a way to get the Camera Normal.
You could get the camera normal inside a custom panel on the client 
side and communicate it to your filter on the server side via the 
usual sm mechanisms. I have written a custom panel for an improved 
plane source in which I wanted to set the camera to look down the 
normal of a plane. Toward the end of that function is some code that 
sets the camera up based on the plane normal. Hope this will give you 
some ideas.


//- 


void pqSQPlaneSource::SnapViewToNormal()
{
  #if defined pqSQPlaneSourceDEBUG
  cerr  :pqSQPlaneSource::SnapViewToNormal  endl;
  #endif

  double o[3];
  this-GetOrigin(o);

  double p1[3];
  this-GetPoint1(p1);

  double p2[3];
  this-GetPoint2(p2);

  // compute the plane's center, this will become the camera focal point.
  double a[3];
  a[0]=o[0]+0.5*(p1[0]-o[0]);
  a[1]=o[1]+0.5*(p1[1]-o[1]);
  a[2]=o[2]+0.5*(p1[2]-o[2]);

  double b[3];
  b[0]=o[0]+0.5*(p2[0]-o[0]);
  b[1]=o[1]+0.5*(p2[1]-o[1]);
  b[2]=o[2]+0.5*(p2[2]-o[2]);

  double cen[3];
  cen[0]=a[0]+b[0]-o[0];
  cen[1]=a[1]+b[1]-o[1];
  cen[2]=a[2]+b[2]-o[2];

  // compute the camera center, 2 plane diagonals along its normal from
  // its center.
  double diag
= sqrt(this-Dims[0]*this-Dims[0]+this-Dims[1]*this-Dims[1]);

  double l_pos[3];
  l_pos[0]=cen[0]+this-N[0]*2.0*diag;
  l_pos[1]=cen[1]+this-N[1]*2.0*diag;
  l_pos[2]=cen[2]+this-N[2]*2.0*diag;

  // compute the camera up from one of the planes axis.
  double up[3];
  if (this-Form-viewUp1-isChecked())
{
up[0]=p1[0]-o[0];
up[1]=p1[1]-o[1];
up[2]=p1[2]-o[2];
}
  else
{
up[0]=p2[0]-o[0];
up[1]=p2[1]-o[1];
up[2]=p2[2]-o[2];
}
  double mup=sqrt(up[0]*up[0]+up[1]*up[1]+up[2]*up[2]);
  up[0]/=mup;
  up[1]/=mup;
  up[2]/=mup;


  pqRenderView *l_view=dynamic_castpqRenderView*(this-view());
  if (!l_view)
{
sqErrorMacro(qDebug(),Failed to get the current view.);
return;
}

  vtkSMRenderViewProxy *l_proxy=l_view-getRenderViewProxy();

  vtkSMDoubleVectorProperty *prop;

  
prop=dynamic_castvtkSMDoubleVectorProperty*(l_proxy-GetProperty(CameraPosition));

  prop-SetElements(l_pos);

  
prop=dynamic_castvtkSMDoubleVectorProperty*(l_proxy-GetProperty(CameraFocalPoint));

  prop-SetElements(cen);

  
prop=dynamic_castvtkSMDoubleVectorProperty*(l_proxy-GetProperty(CameraViewUp));

  prop-SetElements(up);

  
prop=dynamic_castvtkSMDoubleVectorProperty*(l_proxy-GetProperty(CenterOfRotation));

  prop-SetElements(cen);

  l_proxy-UpdateVTKObjects();

  l_view-render();
}

On 08/01/2012 11:40 AM, Alex Rattner wrote:

Hello,

I am trying to develop a compiled paraview filter that takes an input 
plane/direction vector (like the clip or slice filters). Does anyone 
know of example code that shows how to incorporate the ImplicitPlane 
widget into the server manager xml. In particular, I want a way to 
get the Camera Normal. Is this possible?


Thanks,
Alex
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html


Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView


Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview




___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview


Re: [Paraview] Incorporating ImplicitPlane widget into ServerManagerXML

2012-08-01 Thread Sebastien Jourdain
Hi Alex,

I don't fully understand what you mean but in ParaView the way clip or
slice are doing is by using some subproxy that define the plane. I've
just paste you both clip and slice proxy definition for convenience.

SourceProxy class=vtkPVMetaClipDataSet
 name=Clip
  Documentation long_help=Clip with an implicit plane. Clipping
does not reduce the dimensionality of the data set. The output data
type of this filter is always an unstructured grid.
 short_help=Clip with an implicit plane.The Clip filter
 cuts away a portion of the input data set using an
 implicit plane. This filter operates on all types of data
 sets, and it returns unstructured grid data on
 output./Documentation
  IntVectorProperty command=PreserveInputCells
 default_values=0
 label=Crinkle clip
 name=PreserveInputCells
 number_of_elements=1
BooleanDomain name=bool /
DocumentationThis parameter controls whether to extract entire cells
in the given region or clip those cells so all of the output one stay
only inside that region./Documentation
  /IntVectorProperty
  InputProperty command=SetInputConnection
 name=Input
ProxyGroupDomain name=groups
  Group name=sources /
  Group name=filters /
/ProxyGroupDomain
DataTypeDomain name=input_type
  DataType value=vtkDataSet /
/DataTypeDomain
InputArrayDomain name=input_array
  number_of_components=1
  optional=1 /
DocumentationThis property specifies the dataset on which the Clip
filter will operate./Documentation
  /InputProperty
  ProxyProperty command=SetClipFunction
 label=Clip Type
 name=ClipFunction
ProxyGroupDomain name=groups
  Group name=implicit_functions /
/ProxyGroupDomain
ProxyListDomain name=proxy_list
  Proxy group=implicit_functions
 name=Plane /
  Proxy group=implicit_functions
 name=Box /
  Proxy group=implicit_functions
 name=Sphere /
  Proxy group=implicit_functions
 name=Scalar /
/ProxyListDomain
DocumentationThis property specifies the parameters of the clip
function (an implicit plane) used to clip the dataset./Documentation
Hints
  ShowInSummaryPanel /
/Hints
  /ProxyProperty
  DoubleVectorProperty information_only=1
name=InputBounds
BoundsDomain name=bounds
  RequiredProperties
Property function=Input
  name=Input /
  /RequiredProperties
/BoundsDomain
  /DoubleVectorProperty
  StringVectorProperty animateable=0
command=SetInputArrayToProcess
element_types=0 0 0 0 2
label=Scalars
name=SelectInputScalars
number_of_elements=5
ArrayListDomain attribute_type=Scalars
 name=array_list
  RequiredProperties
Property function=Input
  name=Input /
  /RequiredProperties
/ArrayListDomain
FieldDataDomain name=field_list
  RequiredProperties
Property function=Input
  name=Input /
  /RequiredProperties
/FieldDataDomain
DocumentationIf clipping with scalars, this property specifies the
name of the scalar array on which to perform the clip
operation./Documentation
  /StringVectorProperty
  DoubleVectorProperty command=SetValue
default_values=0.0
name=Value
number_of_elements=1
ArrayRangeDomain name=scalar_range
  RequiredProperties
Property function=Input
  name=Input /
Property function=ArraySelection
  name=SelectInputScalars /
  /RequiredProperties
/ArrayRangeDomain
DoubleRangeDomain name=range /
DocumentationIf clipping with scalars, this property sets the scalar
value about which to clip the dataset based on the scalar array chosen.
(See SelectInputScalars.) If clipping with a clip function, this
property specifies an offset from the clip function to use in the
clipping operation. Neither functionality is currently available in
ParaView's user interface./Documentation
  /DoubleVectorProperty
  IntVectorProperty command=SetInsideOut
 default_values=0