[Paraview] Incorporating ImplicitPlane widget into ServerManagerXML
Burlen Loring
bloring at lbl.gov
Thu Aug 2 12:16:40 EDT 2012
> 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_cast<pqRenderView*>(this->view());
if (!l_view)
{
sqErrorMacro(qDebug(),"Failed to get the current view.");
return;
}
vtkSMRenderViewProxy *l_proxy=l_view->getRenderViewProxy();
vtkSMDoubleVectorProperty *prop;
prop=dynamic_cast<vtkSMDoubleVectorProperty*>(l_proxy->GetProperty("CameraPosition"));
prop->SetElements(l_pos);
prop=dynamic_cast<vtkSMDoubleVectorProperty*>(l_proxy->GetProperty("CameraFocalPoint"));
prop->SetElements(cen);
prop=dynamic_cast<vtkSMDoubleVectorProperty*>(l_proxy->GetProperty("CameraViewUp"));
prop->SetElements(up);
prop=dynamic_cast<vtkSMDoubleVectorProperty*>(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
More information about the ParaView
mailing list