<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Hello,<br>
      <br>
      thank you again!<br>
      <br>
      I'll try to explain my problem again:<br>
      <br>
      I have this Class ElectrodeDetectorPlugin and there I have some
      vtkData like m_InputData, m_MaximaData etc.<br>
      <br>
      Basically I will load a 3D Model (m_InputData) into my
      renderWindow and at first I just want to transform the object in
      the normal way (spinning, zooming, roation, etc.)<br>
      <br>
      But than, I press a button on my GUI (with QT) and now I want the
      transformations to stop (for that I have Style2) and I than want
      to pick a point with - for example - the right mouse button event
      and the VTK Point Picker. After picking a point I want to do some
      operatios on m_InputData, m_MaximaData and than I want to redraw
      all of them!<br>
      <br>
      The big problem is: MouseInteractorStyle2 doesn't know the
      m_InputData, m_MaximaData objects and all the other functions of
      the ElectrodeDetectorPlugin etc.<br>
      The same is for the callback functions, because they are no
      memberfunctions of the ElectrodeDetectorPlugin (as far as I see).<br>
      <br>
      Maybe it is not even a vtkProblem. Maybe it is more a problem of
      me understanding object-oriented programming C++. (I'm still a
      student and just a beginner in&nbsp; C++)<br>
      <br>
      The only way I was able to connect the Interactor with the member
      functions of ElectrodeDetectorPlugin was this way (But I dont like
      this way):<br>
      &nbsp; <br>
      m_QtSlotConnector-&gt;Connect(&nbsp; &nbsp;&nbsp;&nbsp;
      widget-&gt;GetRenderWindow()-&gt;GetInteractor(),&nbsp;&nbsp;&nbsp;
      vtkCommand::RightButtonPressEvent,&nbsp;
      this,SLOT(RightButtonPressEventHandling(vtkObject*, unsigned long,
      void*, void*)));<br>
      <br>
      thank you again!<br>
      Flo<br>
      <br>
      Am 23.08.2013 00:11, schrieb Alex Malyushytskyy:<br>
    </div>
    <blockquote
cite="mid:CAHR9pJ3oRQBkySrbT6PBsBk54xnK8mVMEKvdRiu=A0hzX0oGsw@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>
          <div>
            <div>I am am glad my comment helped somehow.<br>
              <div>I guess you MouseInteractorStyle1 and
                MouseInteractorStyle2 are subclasses of
                vtkInteractorStyle which you want set depending on your
                needs <br>
              </div>
              <div>In this case why would you even need a callback?<br>
              </div>
              <div>Do everything&nbsp; there.<br>
                <br>
              </div>
              <div>Also I do not think your code is valid.<br>
              </div>
              <div>I doubt below code will even compile:<br>
              </div>
              <br>
              <div>
                &nbsp;vtkSmartPointer&lt;MouseInteractorStyle1&gt; style&nbsp; =&nbsp;&nbsp;
                vtkSmartPointer&lt;MouseInteractorStyle1&gt;::New(); //
                Style 1 for manipulation Spin/Pan etc.<br>
                <div>&nbsp;vtkSmartPointer&lt;MouseInteractorStyle2&gt;
                  style&nbsp; =&nbsp;&nbsp;
                  vtkSmartPointer&lt;MouseInteractorStyle2&gt;::New();</div>
                <br>
                <br>
              </div>
              <div>You said you want different behavior for for example
                left mouse release depending on some conditions.<br>
              </div>
              <div>This means you have a few choices:<br>
                <br>
              </div>
              <div>a) subclass interactor style and do all you need
                within that single class.<br>
              </div>
              <div>b) switch between different interactor styles. For
                example check vtkInteractorStyleSwitch.<br>
              </div>
              <div>c) use callbacks. <br>
                <br>
              </div>
              <div>I used a) and b) myself. Even though I have not used
                last approach I guess you would still at least to either
                subclass interactor style so it does nothing if actions
                of your interest happens or find an existent class which
                satisfies above conditions. Otherwise default interactor
                style will interfere with your code (For example
                rotation will happen&nbsp; when you want zoom or both )<br>
                <br>
              </div>
              <div><br>
              </div>
              <div>Hope this helps,<br>
              </div>
              <div>&nbsp; Alex<br>
              </div>
              <br>
            </div>
            <span></span></div>
        </div>
      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">On Thu, Aug 22, 2013 at 3:26 AM,
          Florian Schiffers <span dir="ltr">&lt;<a
              moz-do-not-send="true"
              href="mailto:florian.schiffers@physik.uni-erlangen.de"
              target="_blank">florian.schiffers@physik.uni-erlangen.de</a>&gt;</span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div text="#000000" bgcolor="#FFFFFF">
              <div>Hello,<br>
                <br>
                thx for the answer. It helped me alot, but I still have
                the problem that I cannot access to class member
                variables in a callback function or the
                vtkInteractorStyleTrackballCamera Class.<br>
                <br>
                I have a structure like this:<font face="Times New
                  Roman, Times, serif"><span><br>
                    <br>
                    ( with pastebin: <a moz-do-not-send="true"
                      href="http://pastebin.com/qm42n1xh"
                      target="_blank">http://pastebin.com/qm42n1xh</a> )<br>
                    <br>
                    void</span> ClickCallbackFunction <span>(</span>
                  vtkObject<span>*</span> caller, <span>long</span> <span>unsigned</span>
                  <span>int</span> eventId, <span>void</span><span>*</span>
                  clientData, <span>void</span><span>*</span> callData
                  <span>)</span><span>;</span> </font><br>
                ElectrodeDetectorPlugin::ElectrodeDetectorPlugin(QVTKWidget
                *p): QObject(){<br>
                &nbsp;&nbsp;&nbsp; m_InputData&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =&nbsp;&nbsp;&nbsp; vtkSmartPointer
                &lt;vtkPolyData&gt; :: New();<br>
                &nbsp;&nbsp;&nbsp; m_InputDataActor&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =&nbsp;&nbsp;&nbsp; vtkSmartPointer
                &lt;vtkActor&gt; :: New();<br>
                <br>
                &nbsp;&nbsp;&nbsp; m_MaximaData&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =&nbsp;&nbsp;&nbsp;
                vtkSmartPointer&lt;vtkPolyData&gt;::New();<br>
                &nbsp;&nbsp;&nbsp; m_InputMaximaActor&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =&nbsp;&nbsp;&nbsp;
                vtkSmartPointer&lt;vtkActor&gt;::New();<br>
                <br>
                &nbsp;&nbsp;&nbsp; vtkSmartPointer&lt;MouseInteractorStyle1&gt; style&nbsp;
                =&nbsp;&nbsp; vtkSmartPointer&lt;MouseInteractorStyle1&gt;::New();
                // Style 1 for manipulation Spin/Pan etc.<br>
                &nbsp;&nbsp;&nbsp; vtkSmartPointer&lt;MouseInteractorStyle2&gt; style&nbsp;
                =&nbsp;&nbsp; vtkSmartPointer&lt;MouseInteractorStyle2&gt;::New();<br>
                &nbsp;&nbsp;&nbsp; ... ....<br>
                &nbsp;&nbsp;&nbsp;
                renderWindow-&gt;GetInteractor()-&gt;SetInteractorStyle(
                style );&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
                &nbsp;&nbsp; vtkSmartPointer<span>&lt;</span>vtkCallbackCommand<span>&gt;</span>
                clickCallback <span>=</span> vtkSmartPointer<span>&lt;</span>vtkCallbackCommand<span>&gt;</span><span>::</span><span>New</span><span>(</span><span>)</span><span>;</span>
                clickCallback<span>-</span><span>&gt;</span>SetCallback
                <span>(</span> ClickCallbackFunction <span>)</span><span>;</span>
                &nbsp; renderWindowInteractor<span>-</span><span>&gt;</span>AddObserver
                <span>(</span> vtkCommand<span>::</span><span>LeftButtonPressEvent</span>,
                clickCallback <span>)</span><span>;</span><br>
                <br>
                }<span><br>
                  void</span> ClickCallbackFunction <span>(</span>
                vtkObject<span>*</span> vtkNotUsed<span>(</span>caller<span>)</span>,
                <span>long</span> <span>unsigned</span> <span>int</span>
                vtkNotUsed<span>(</span>eventId<span>)</span>, <span>void</span><span>*</span>
                vtkNotUsed<span>(</span>clientData<span>)</span>, <span>void</span><span>*</span>
                vtkNotUsed<span>(</span>callData<span>)</span> <span>)</span>
                <span>{</span> std<span>::</span><span>cout</span> <span>&lt;&lt;</span>
                <span>"Click callback"</span> <span>&lt;&lt;</span> std<span>::</span><span>endl</span><span>;</span><br>
                <pre>  /<span>/ Get the interactor like this:</span>
  <span>vtkRenderWindowInteractor *iren = </span>
  <span>static_cast&lt;vtkRenderWindowInteractor*&gt;(caller);</span>

  HERE I need to operations on m_InputData, m_MaximaData using PointPicker Methods
  I also want to draw objects etc.
&nbsp;&nbsp;
<span>}</span></pre>
                I tried a lot of stuff, but they all didn't work. Do you
                have any idea?<br>
                <br>
                Thank you for your help!<br>
                <br>
                best regards,<br>
                Flo<br>
                <br>
                Am <a moz-do-not-send="true" href="tel:21.08.2013%2004"
                  value="+12108201304" target="_blank">21.08.2013 04</a>:04,
                schrieb Alex Malyushytskyy:<br>
              </div>
              <div>
                <div class="h5">
                  <blockquote type="cite">
                    <div dir="ltr">
                      <div>
                        <div>
                          <div>I just want to add thet currently set .
                            vtkInteractorStyle is defining which events
                            are handled and how.<br>
                          </div>
                          So subclassing and overriding appropriate
                          functionality is way to go.<br>
                        </div>
                        Also you can create multiple vtkInteractorStyle
                        and set them active according to your needs.<br>
                        <br>
                      </div>
                      <div>Hope this helps.<br>
                        <br>
                      </div>
                      Alex<br>
                    </div>
                    <div class="gmail_extra"><br>
                      <br>
                      <div class="gmail_quote">On Tue, Aug 20, 2013 at
                        4:08 PM, Alex Malyushytskyy <span dir="ltr">&lt;<a
                            moz-do-not-send="true"
                            href="mailto:alexmalvtk@gmail.com"
                            target="_blank">alexmalvtk@gmail.com</a>&gt;</span>
                        wrote:<br>
                        <blockquote class="gmail_quote" style="margin:0
                          0 0 .8ex;border-left:1px #ccc
                          solid;padding-left:1ex">
                          <div dir="ltr">
                            <div>
                              <div>
                                <div>Subclass vtkInteractorStyle (or
                                  derived class ) you are using.<br>
                                  <br>
                                </div>
                                All the operations: rotation, calls as
                                results on Keypressevents are initiated
                                there.<br>
                              </div>
                              Depending on the actual subclass of
                              vtkInteractorStyle things what you need to
                              do are different,<br>
                            </div>
                            For example to suppress Keypressevents for
                            vtkInteractorStyleRubberBand subclass you
                            can just override<br>
                            <div>
                              <div>
                                <div>
                                  <div>void
                                    vtkInteractorStyleRubberBand::OnChar()
                                    to do nothing.<br>
                                    <br>
                                  </div>
                                  <div>Regards,<br>
                                  </div>
                                  <div>&nbsp;&nbsp;&nbsp;&nbsp; Alex<br>
                                  </div>
                                </div>
                              </div>
                            </div>
                          </div>
                          <div>
                            <div>
                              <div class="gmail_extra"><br>
                                <br>
                                <div class="gmail_quote">On Tue, Aug 20,
                                  2013 at 5:59 AM, Phys1k3r <span
                                    dir="ltr">&lt;<a
                                      moz-do-not-send="true"
                                      href="mailto:florian.schiffers@physik.uni-erlangen.de"
                                      target="_blank">florian.schiffers@physik.uni-erlangen.de</a>&gt;</span>
                                  wrote:<br>
                                  <blockquote class="gmail_quote"
                                    style="margin:0 0 0
                                    .8ex;border-left:1px #ccc
                                    solid;padding-left:1ex">Hello,<br>
                                    <br>
                                    I have written a vtk-programm that
                                    allows me to display a 3D data set
                                    (VTK<br>
                                    and QT). Additonally you can
                                    interact with the 3D Data with<br>
                                    'RightButtonPressEvent' and
                                    'MiddleButtonPressEvent'. Both
                                    interaction are<br>
                                    point picker interactions.<br>
                                    <br>
                                    My problem is, that for example,
                                    when I press the 'RightButton' two
                                    things<br>
                                    happen at once:<br>
                                    <br>
                                    1. Point on 3D Data get's picked<br>
                                    2. Camera is zooming in/out (only
                                    when I move mouse during picking,
                                    but this<br>
                                    happens from time to time)<br>
                                    <br>
                                    The same happens with
                                    'MiddleButtonPressEvent', the
                                    objects just get moved<br>
                                    instead.<br>
                                    <br>
                                    So basically I want a button on my
                                    GUI, where I can choose:<br>
                                    &nbsp;1. Either Zoom in/out<br>
                                    &nbsp;2. or pick a point<br>
                                    <br>
                                    As an alternative I would be
                                    satisfied with something like this:<br>
                                    &nbsp;1. Just OnLeftButtonDown() -&gt;
                                    Just Zoom/Pan/Spin<br>
                                    &nbsp;2. OnLeftButtonDown() +
                                    KeePressEvent -&gt; Don't zoom, pick
                                    point instead<br>
                                    <br>
                                    This is how I implemented the
                                    'MiddleButtonPressEventHandling' by
                                    now:<br>
                                    <br>
                                    <br>
                                    <br>
                                    I know, this is not the best way,
                                    but it worked so far. I propably
                                    will<br>
                                    implement it this way in the near
                                    future:<br>
                                    <a moz-do-not-send="true"
href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/MouseEventsObserver"
                                      target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/MouseEventsObserver</a><br>
                                    <br>
                                    But even when I use the
                                    MouseEventsObserver I still have no
                                    Idea how<br>
                                    suppress the Zoom/Pan/Spin Events...<br>
                                    <br>
                                    Than I thought of this method
                                    instead:<br>
                                    <a moz-do-not-send="true"
                                      href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/MouseEvents"
                                      target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Interaction/MouseEvents</a><br>
                                    <br>
                                    First of all, I don't need (and also
                                    don't want) all the features of the<br>
                                    vtkInteractorStyle class like
                                    Keypressevents for p, r, s, u, v e
                                    (as you can<br>
                                    find them here:<br>
                                    <a moz-do-not-send="true"
                                      href="http://www.vtk.org/doc/nightly/html/classvtkInteractorStyle.html"
                                      target="_blank">http://www.vtk.org/doc/nightly/html/classvtkInteractorStyle.html</a>
                                    at Detailed<br>
                                    Description)<br>
                                    <br>
                                    I just need to overwrite
                                    'OnLeftButtonDown',
                                    'OnMiddleButtonDown',<br>
                                    'OnRightButtonDown' etc.<br>
                                    <br>
                                    So basically I tried things like
                                    this, but they don't work, of
                                    course:<br>
                                    <br>
                                    <br>
                                    <br>
                                    <br>
                                    Honestly I have no idea how to solve
                                    my problem... I also haven't found
                                    much<br>
                                    documentary besides the examples.<br>
                                    <br>
                                    Thank you for your help, I really
                                    appreciate it<br>
                                    Phys1k3r<br>
                                    <br>
                                    <br>
                                    <br>
                                    --<br>
                                    View this message in context: <a
                                      moz-do-not-send="true"
href="http://vtk.1045678.n5.nabble.com/VTK-Interactor-problem-tp5722887.html"
                                      target="_blank">http://vtk.1045678.n5.nabble.com/VTK-Interactor-problem-tp5722887.html</a><br>
                                    Sent from the VTK - Users mailing
                                    list archive at Nabble.com.<br>
_______________________________________________<br>
                                    Powered by <a
                                      moz-do-not-send="true"
                                      href="http://www.kitware.com"
                                      target="_blank">www.kitware.com</a><br>
                                    <br>
                                    Visit other Kitware open-source
                                    projects at <a
                                      moz-do-not-send="true"
                                      href="http://www.kitware.com/opensource/opensource.html"
                                      target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
                                    <br>
                                    Please keep messages on-topic and
                                    check the VTK FAQ at: <a
                                      moz-do-not-send="true"
                                      href="http://www.vtk.org/Wiki/VTK_FAQ"
                                      target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
                                    <br>
                                    Follow this link to
                                    subscribe/unsubscribe:<br>
                                    <a moz-do-not-send="true"
                                      href="http://www.vtk.org/mailman/listinfo/vtkusers"
                                      target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
                                  </blockquote>
                                </div>
                                <br>
                              </div>
                            </div>
                          </div>
                        </blockquote>
                      </div>
                      <br>
                    </div>
                  </blockquote>
                  <br>
                </div>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
  </body>
</html>