[vtkusers] Using a boxwidgets transform to rotate a non-vtk 3D model?
Totte Karlsson
totte at dunescientific.com
Wed Aug 5 20:54:29 EDT 2015
Hello,
I'm using vtk to visualize 3D models of molecules.
The actual molecular model is decoupled from vtk code, and visualization
is implemented using a model-view kind of design.
Currently I have the following challenge. If a user wants to manipulate
the absolute orientation of the molecule, it is done by manipulating the
underlying model using rotation functions, like RotateX, RotateY,
RotateAboutVector, and translation functions TranslateX, Y etc.
For now 3D rotations are simply done using two scrollbars, one
horizontal and one vertical, causing the underlying model being rotated
about the vtk viewUP vector and the vtk cameraPlane normal
respectively. This works fine, but is not so intuitive for the user.
Instead I believe allowing interaction with something like a box widget
that encapsulates the molecule view, (with disabled handles), would be
better.
The challenge is how to figure out how to capture the boxwidgets
orientation in a callback, and using this information in order to
manipulate the underlying molecular model.
For example, a boxwidget callback (from boxwidget example at
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Widgets/BoxWidget):
class vtkMyCallback : public vtkCommand
{
public:
static vtkMyCallback *New() { return new
vtkMyCallback; }
virtual void Execute(vtkObject *caller, unsigned long, void*)
{
vtkSmartPointer<vtkTransform> t =
vtkSmartPointer<vtkTransform>::New();
vtkBoxWidget *widget = reinterpret_cast<vtkBoxWidget*>(caller);
widget->GetTransform(t);
double* angles?? = t->GetOrientation();
if(aMoleculeModel)
{
//Use some secret(!) code to manipulate orientation of a
molecule to 'rotate' it together with the boxWidget
aMoleculeModel->RotateZ(??);
aMoleculeModel->RotateY(??);
aMoleculeModel->RotateZ(??);
}
}
Molecule* aMoleculeModel;
Anyone seeing how to do this or have some pointers?
Cheers,
tk
More information about the vtkusers
mailing list