Hi Jana,<br /><br />
much better!<br />
Here we go:<br />
<pre>#<span style=' color: Blue;'>include</span> &lt;vtkVersion.h&gt;
#<span style=' color: Blue;'>include</span> &lt;vtkPolyDataMapper.h&gt;
#<span style=' color: Blue;'>include</span> &lt;vtkActor.h&gt;
#<span style=' color: Blue;'>include</span> &lt;vtkRenderWindow.h&gt;
#<span style=' color: Blue;'>include</span> &lt;vtkRenderer.h&gt;
#<span style=' color: Blue;'>include</span> &lt;vtkRenderWindowInteractor.h&gt;
#<span style=' color: Blue;'>include</span> &lt;vtkPolyData.h&gt;
#<span style=' color: Blue;'>include</span> &lt;vtkSphereSource.h&gt;
#<span style=' color: Blue;'>include</span> &lt;vtkOrientationMarkerWidget.h&gt;
#<span style=' color: Blue;'>include</span> &lt;vtkAxesActor.h&gt;
#<span style=' color: Blue;'>include</span> &lt;vtkPropAssembly.h&gt;
#<span style=' color: Blue;'>include</span> &lt;vtkSmartPointer.h&gt;
#<span style=' color: Blue;'>include</span> &lt;vtkInteractorStyleTrackballCamera.h&gt;
#<span style=' color: Blue;'>include</span> &lt;vtkCommand.h&gt;
#<span style=' color: Blue;'>include</span> &lt;vtkCamera.h&gt;
#<span style=' color: Blue;'>include</span> &lt;vtkCallbackCommand.h&gt;
#<span style=' color: Blue;'>include</span> &lt;vtkObjectFactory.h&gt;
#<span style=' color: Blue;'>include</span> &lt;vtkMatrix4x4.h&gt;

<span style=' color: Blue;'>class</span> MySphereSource : <span style=' color: Blue;'>public</span> vtkSphereSource {
<span style=' color: Blue;'>public</span>:
  vtkTypeMacro(MySphereSource, vtkSphereSource);
  <span style=' color: Blue;'>static</span> MySphereSource* New(); 
  
  <span style=' color: Blue;'>void</span> MySphereSource::printDirectionOfProjection(<span style=' color: Blue;'>double</span>* dirOfProj)
  {
    <span style=' color: Blue;'>cout</span> &lt;&lt; <span style=' color: Maroon;'>"direction of view: "</span> &lt;&lt; dirOfProj[<span style=' color: Maroon;'>0</span>] &lt;&lt; <span style=' color: Maroon;'>" "</span> &lt;&lt; dirOfProj[<span style=' color: Maroon;'>1</span>] &lt;&lt; <span style=' color: Maroon;'>" "</span> &lt;&lt; dirOfProj[<span style=' color: Maroon;'>2</span>] &lt;&lt; <span style=' color: Blue;'>endl</span>;
  }
    
<span style=' color: Blue;'>protected</span>:
    MySphereSource(){};
   ~MySphereSource(){};

};

vtkStandardNewMacro(MySphereSource);



<span style=' color: Green;'>// Command</span>
<span style=' color: Blue;'>class</span> vtkCameraObserver : <span style=' color: Blue;'>public</span> vtkCommand
{
<span style=' color: Blue;'>public</span>:
  <span style=' color: Blue;'>static</span> vtkCameraObserver *New()
  {<span style=' color: Blue;'>return</span> <span style=' color: Blue;'>new</span> vtkCameraObserver();};

  <span style=' color: Blue;'>void</span> SetPolyDataAlgorithm(MySphereSource* mySphereSource) {
    <span style=' color: Blue;'>this</span>-&gt;mySphereSource = mySphereSource;
  }

    
<span style=' color: Blue;'>protected</span>:
  vtkCameraObserver() {};
  ~vtkCameraObserver(){}
    
  <span style=' color: Blue;'>virtual</span> <span style=' color: Blue;'>void</span> Execute(vtkObject* caller, <span style=' color: Blue;'>unsigned</span> <span style=' color: Blue;'>long</span> event, <span style=' color: Blue;'>void</span> *calldata)
  {
    <span style=' color: Blue;'>cout</span> &lt;&lt; <span style=' color: Maroon;'>"Camera modified event"</span> &lt;&lt; <span style=' color: Blue;'>endl</span>;
    vtkCamera* cam = <span style=' color: Blue;'>reinterpret_cast</span>&lt;vtkCamera*&gt; (caller);
    <span style=' color: Blue;'>double</span>* direction = cam-&gt;GetDirectionOfProjection();
    mySphereSource-&gt;printDirectionOfProjection(direction);
    
    <span style=' color: Green;'>// In case you would need this too:</span>
    <span style=' color: Green;'>//vtkMatrix4x4* mat = cam-&gt;GetViewTransformMatrix();</span>
     
    <span style=' color: Green;'>//cout &lt;&lt; "View matrix: " &lt;&lt; endl; </span>
    <span style=' color: Green;'>//cout &lt;&lt; "================================================================================= " &lt;&lt; endl; </span>
    <span style=' color: Green;'>//cout &lt;&lt; mat-&gt;GetElement(0, 0) &lt;&lt; "\t" &lt;&lt; mat-&gt;GetElement(0, 1) &lt;&lt; "\t" &lt;&lt; mat-&gt;GetElement(0, 2) &lt;&lt; "\t" &lt;&lt; mat-&gt;GetElement(0, 3) &lt;&lt; "\t" &lt;&lt; endl;</span>
    <span style=' color: Green;'>//cout &lt;&lt; mat-&gt;GetElement(1, 0) &lt;&lt; "\t" &lt;&lt; mat-&gt;GetElement(1, 1) &lt;&lt; "\t" &lt;&lt; mat-&gt;GetElement(1, 2) &lt;&lt; "\t" &lt;&lt; mat-&gt;GetElement(1, 3) &lt;&lt; "\t" &lt;&lt; endl;</span>
    <span style=' color: Green;'>//cout &lt;&lt; mat-&gt;GetElement(2, 0) &lt;&lt; "\t" &lt;&lt; mat-&gt;GetElement(2, 1) &lt;&lt; "\t" &lt;&lt; mat-&gt;GetElement(2, 2) &lt;&lt; "\t" &lt;&lt; mat-&gt;GetElement(2, 3) &lt;&lt; "\t" &lt;&lt; endl;</span>
    <span style=' color: Green;'>//cout &lt;&lt; mat-&gt;GetElement(3, 0) &lt;&lt; "\t" &lt;&lt; mat-&gt;GetElement(3, 1) &lt;&lt; "\t" &lt;&lt; mat-&gt;GetElement(3, 2) &lt;&lt; "\t" &lt;&lt; mat-&gt;GetElement(3, 3) &lt;&lt; "\t" &lt;&lt; endl;</span>
    <span style=' color: Green;'>//cout &lt;&lt; "================================================================================= " &lt;&lt; endl; </span>
    <span style=' color: Green;'>//double* x = cam-&gt;GetOrientation();</span>
    <span style=' color: Green;'>//cout &lt;&lt; "Orientation : " &lt;&lt; x[0] &lt;&lt; " " &lt;&lt; x[1] &lt;&lt; " " &lt;&lt; x[2] &lt;&lt; endl;</span>
  }

<span style=' color: Blue;'>private</span> :
  MySphereSource* mySphereSource;
};



<span style=' color: Blue;'>int</span> main (<span style=' color: Blue;'>int</span>, <span style=' color: Blue;'>char</span> *[])
{
  vtkSmartPointer&lt;MySphereSource&gt; sphereSource = 
  vtkSmartPointer&lt;MySphereSource&gt;::New();
  sphereSource-&gt;SetCenter(<span style=' color: Maroon;'>0</span><span style=' color: Maroon;'>.0</span>, <span style=' color: Maroon;'>0</span><span style=' color: Maroon;'>.0</span>, <span style=' color: Maroon;'>0</span><span style=' color: Maroon;'>.0</span>);
  sphereSource-&gt;SetRadius(<span style=' color: Maroon;'>1</span><span style=' color: Maroon;'>.23</span>);
  sphereSource-&gt;Update();
    
  vtkPolyData* polydata = sphereSource-&gt;GetOutput();
    
  <span style=' color: Green;'>// Create a mapper</span>
  vtkSmartPointer&lt;vtkPolyDataMapper&gt; mapper = 
  vtkSmartPointer&lt;vtkPolyDataMapper&gt;::New();
<span style=' color: Blue;'>#if</span> VTK_MAJOR_VERSION &lt;= <span style=' color: Maroon;'>5</span>
  mapper-&gt;SetInput(polydata);
  <span style=' color: Blue;'>#else</span>
  mapper-&gt;SetInputData(polydata);
<span style=' color: Blue;'>#endif</span>
    
  <span style=' color: Green;'>// Create an actor</span>
  vtkSmartPointer&lt;vtkActor&gt; actor = 
  vtkSmartPointer&lt;vtkActor&gt;::New();
  actor-&gt;SetMapper(mapper);
    
  <span style=' color: Green;'>// A renderer and render window</span>
  vtkSmartPointer&lt;vtkRenderer&gt; renderer = 
  vtkSmartPointer&lt;vtkRenderer&gt;::New();
  vtkSmartPointer&lt;vtkRenderWindow&gt; renderWindow = 
  vtkSmartPointer&lt;vtkRenderWindow&gt;::New();
  renderWindow-&gt;AddRenderer(renderer);
    
  <span style=' color: Green;'>// An interactor</span>
  vtkSmartPointer&lt;vtkRenderWindowInteractor&gt; renderWindowInteractor = 
  vtkSmartPointer&lt;vtkRenderWindowInteractor&gt;::New();
  renderWindowInteractor-&gt;SetRenderWindow(renderWindow);
    
  vtkInteractorStyleTrackballCamera *style = 
  vtkInteractorStyleTrackballCamera::New();
  renderWindowInteractor-&gt;SetInteractorStyle(style);
    
  <span style=' color: Green;'>// Add the actors to the scene</span>
  renderer-&gt;AddActor(actor);
  renderer-&gt;SetBackground(<span style=' color: Maroon;'>.2</span>, <span style=' color: Maroon;'>.3</span>, <span style=' color: Maroon;'>.4</span>);
  <span style=' color: Green;'>//*************************************************************************************</span>
  <span style=' color: Green;'>// Create observer</span>
  vtkSmartPointer&lt;vtkCameraObserver&gt; observer = vtkSmartPointer&lt;vtkCameraObserver&gt;::New();
  <span style=' color: Green;'>// tell observer on which object to operate on</span>
  observer-&gt;SetPolyDataAlgorithm(sphereSource);
  <span style=' color: Green;'>// hook observer into camera's modified event</span>
  vtkCamera* cam = renderer-&gt;GetActiveCamera();
  cam-&gt;AddObserver(vtkCommand::ModifiedEvent, observer);
  <span style=' color: Green;'>//*************************************************************************************</span>
    
  <span style=' color: Green;'>// Add widget</span>
  vtkSmartPointer&lt;vtkAxesActor&gt; axes = 
  vtkSmartPointer&lt;vtkAxesActor&gt;::New();
    
  vtkSmartPointer&lt;vtkOrientationMarkerWidget&gt; widget = 
  vtkSmartPointer&lt;vtkOrientationMarkerWidget&gt;::New();
  widget-&gt;SetOutlineColor( <span style=' color: Maroon;'>0</span><span style=' color: Maroon;'>.9300</span>, <span style=' color: Maroon;'>0</span><span style=' color: Maroon;'>.5700</span>, <span style=' color: Maroon;'>0</span><span style=' color: Maroon;'>.1300</span> );
  widget-&gt;SetOrientationMarker( axes );
  widget-&gt;SetInteractor( renderWindowInteractor );
  widget-&gt;SetViewport( <span style=' color: Maroon;'>0</span><span style=' color: Maroon;'>.0</span>, <span style=' color: Maroon;'>0</span><span style=' color: Maroon;'>.0</span>, <span style=' color: Maroon;'>0</span><span style=' color: Maroon;'>.4</span>, <span style=' color: Maroon;'>0</span><span style=' color: Maroon;'>.4</span> );
  widget-&gt;SetEnabled( <span style=' color: Maroon;'>1</span> );
  widget-&gt;InteractiveOn();
    
  renderer-&gt;ResetCamera();
  renderWindow-&gt;Render();
    
  <span style=' color: Green;'>// Begin mouse interaction</span>
  renderWindowInteractor-&gt;Start();
    
  <span style=' color: Blue;'>return</span> EXIT_SUCCESS;
}</pre><br/>
best regards<br/>
Jochen
        
<br/><hr align="left" width="300" />
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/How-to-forward-mouse-move-event-to-polydata-algorithm-and-get-there-direction-of-projection-tp5714021p5714029.html">Re: How to forward mouse move event to polydata algorithm and get there direction of projection</a><br/>
Sent from the <a href="http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html">VTK - Users mailing list archive</a> at Nabble.com.<br/>