<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi,<br><br>vtkActor2D is not able to do this apparently from itself. Therefore, I have written<br>my own callback-function which simply questions on the mousewheel movement and plots<br>the 2D actor in the desired size anew. <br>I still have the problem with the adaptation of the window size. To find out whether I<br>chaneges the windowframe, I will question permanently on the cursor position. If there<br>is better solution for it (e.g. finished functions), let it me know please.<br><br>.luxtheme.<br><br>my new code: <br><br>//Now you can zoom in or out with your mousewheel<br>#include "vtkRenderWindow.h"<br>#include "vtkRenderWindowInteractor.h"<br>#include "vtkRenderer.h"<br>#include "vtkPolyDataMapper2D.h"<br>#include "vtkCellArray.h"<br>#include "vtkPoints.h"<br>#include "vtkPolyData.h"<br>#include "vtkActor2D.h"<br>#include "vtkProperty2D.h"<br>#include
 "vtkCommand.h"<br><br>#include &lt;cstdlib&gt;<br>#include &lt;ctime&gt;<br><br>//random signal<br>class randomSignal<br>{<br>public:<br>&nbsp;&nbsp;&nbsp; int event_array_time[100];<br>&nbsp;&nbsp;&nbsp; int event_array_bit[100];<br>&nbsp;&nbsp;&nbsp; int timeLine; <br>&nbsp;&nbsp;&nbsp; int array_index;<br><br>&nbsp;&nbsp;&nbsp; randomSignal(): event_array_time(), event_array_bit(), timeLine(2000), array_index(0) { }<br><br>&nbsp;&nbsp;&nbsp; void generate()<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; srand((unsigned)time(0));<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int time = 0;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int start_bit = 0;<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; while(time&lt;timeLine)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; array_index++;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
 event_array_time[array_index-1]=time;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; event_array_bit[array_index-1]=start_bit;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; int random_event = (rand()%500)+1;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; time+=random_event;<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; start_bit=(start_bit+1)%2;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; event_array_time[array_index-1]=timeLine;<br>&nbsp;&nbsp;&nbsp; }<br><br>};<br><br>void drawSignal(randomSignal *random, vtkActor2D *actor, int Xaxis)<br>{<br>&nbsp;&nbsp;&nbsp; int *event_array_time = random-&gt;event_array_time;<br>&nbsp;&nbsp;&nbsp; int *event_array_bit = random-&gt;event_array_bit;<br>&nbsp;&nbsp;&nbsp; int timeLine = random-&gt;timeLine; <br>&nbsp;&nbsp;&nbsp; int array_index = random-&gt;array_index;<br><br>&nbsp;&nbsp;&nbsp; vtkPoints *points =
 vtkPoints::New();<br>&nbsp;&nbsp;&nbsp; vtkCellArray *lines = vtkCellArray::New();<br>&nbsp;&nbsp;&nbsp; int pID = 0;<br><br>&nbsp;&nbsp;&nbsp; vtkPolyData* polyData = vtkPolyData::New();<br>&nbsp;&nbsp;&nbsp; vtkPolyDataMapper2D *mapper = vtkPolyDataMapper2D::New();<br><br>&nbsp;&nbsp;&nbsp; //plot signal<br>&nbsp;&nbsp;&nbsp; points-&gt;InsertNextPoint((double)Xaxis/timeLine*event_array_time[0],300*event_array_bit[0],0);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; points-&gt;InsertNextPoint((double)Xaxis/timeLine*event_array_time[1],300*event_array_bit[0],0);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br><br>&nbsp;&nbsp;&nbsp; lines-&gt;InsertNextCell(2);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; lines-&gt;InsertCellPoint(pID);&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; lines-&gt;InsertCellPoint(pID+1);&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;
 pID+=2;<br><br>&nbsp;&nbsp;&nbsp; for (int i=1; i&lt;array_index-1; i++) {<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // toggle line<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; points-&gt;InsertNextPoint((double)Xaxis/timeLine*event_array_time[i],300*event_array_bit[i],0);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; points-&gt;InsertNextPoint((double)Xaxis/timeLine*event_array_time[i],300*event_array_bit[i+1],0);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; lines-&gt;InsertNextCell(2);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; lines-&gt;InsertCellPoint(pID);&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; lines-&gt;InsertCellPoint(pID+1); <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pID+=2;<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // High-/ Low-line<br>&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp; points-&gt;InsertNextPoint((double)Xaxis/timeLine*event_array_time[i],300*event_array_bit[i],0);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; points-&gt;InsertNextPoint((double)Xaxis/timeLine*event_array_time[i+1],300*event_array_bit[i],0);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; lines-&gt;InsertNextCell(2);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; lines-&gt;InsertCellPoint(pID);&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; lines-&gt;InsertCellPoint(pID+1); <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pID+=2;<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; // Create actor<br>&nbsp;&nbsp;&nbsp; polyData-&gt;SetPoints(points);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; polyData-&gt;SetLines(lines);&nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; mapper-&gt;SetInput(polyData);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; actor-&gt;SetMapper(mapper);<br>&nbsp;&nbsp;&nbsp; actor-&gt;GetProperty()-&gt;SetColor(0,1,1); <br>}<br><br>//mouse moved<br>class callbackZoom: public vtkCommand<br>{<br>public:<br>&nbsp;&nbsp;&nbsp; static callbackZoom *New()<br>&nbsp;&nbsp;&nbsp; { return new callbackZoom; }<br>&nbsp;&nbsp;&nbsp; virtual void Execute(vtkObject *caller, unsigned long eventId, void*)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(eventId == MouseWheelBackwardEvent) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Xaxis=(int)(Xaxis*0.9);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; drawSignal(random, actor, Xaxis);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; renWin-&gt;Render();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
 } <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else if(eventId == MouseWheelForwardEvent) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Xaxis=(int)(Xaxis*1.1);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; drawSignal(random, actor, Xaxis);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; renWin-&gt;Render();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } <br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; callbackZoom() : actor(), Xaxis(tempX), renWin(), random() {}<br>&nbsp;&nbsp;&nbsp; vtkRenderWindow *renWin;<br>&nbsp;&nbsp;&nbsp; randomSignal *random;<br>&nbsp;&nbsp;&nbsp; int tempX;<br>&nbsp;&nbsp;&nbsp; int&amp; Xaxis;<br>&nbsp;&nbsp;&nbsp; vtkActor2D *actor;<br>};<br><br>//MAIN<br>void main()<br>{<br>&nbsp;&nbsp;&nbsp; int Xaxis = 800;<br><br>&nbsp;&nbsp;&nbsp; // generate random signal<br>&nbsp;&nbsp;&nbsp; randomSignal *random = new randomSignal();<br>&nbsp;&nbsp;&nbsp; random-&gt;generate();
 <br>&nbsp;&nbsp;&nbsp; cout &lt;&lt; "\n\nAI: " &lt;&lt; random-&gt;array_index &lt;&lt; endl;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; vtkActor2D *actor = vtkActor2D::New();<br>&nbsp;&nbsp;&nbsp; drawSignal(random, actor, Xaxis);<br><br>&nbsp;&nbsp;&nbsp; // Create a renderer<br>&nbsp;&nbsp;&nbsp; vtkRenderer* ren = vtkRenderer::New();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ren-&gt;SetBackground(0.75,0.25,0.25);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ren-&gt;AddActor(actor);<br><br>&nbsp;&nbsp;&nbsp; // Create a render window<br>&nbsp;&nbsp;&nbsp; vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();<br>&nbsp;&nbsp;&nbsp; vtkRenderWindow* renWin = vtkRenderWindow::New();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; renWin-&gt;AddRenderer(ren);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; renWin-&gt;SetSize( 800,300 );<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; renWin-&gt;SetInteractor( iren
 );<br><br>&nbsp;&nbsp;&nbsp; // Event<br>&nbsp;&nbsp;&nbsp; callbackZoom *cbZoom = callbackZoom::New();<br>&nbsp;&nbsp;&nbsp; cbZoom-&gt;actor = actor;<br>&nbsp;&nbsp;&nbsp; cbZoom-&gt;Xaxis = Xaxis;<br>&nbsp;&nbsp;&nbsp; cbZoom-&gt;renWin = renWin;<br>&nbsp;&nbsp;&nbsp; cbZoom-&gt;random = random;<br>&nbsp;&nbsp;&nbsp; iren-&gt;AddObserver(vtkCommand::MouseWheelBackwardEvent,cbZoom);<br>&nbsp;&nbsp;&nbsp; iren-&gt;AddObserver(vtkCommand::MouseWheelForwardEvent,cbZoom);<br><br>&nbsp;&nbsp;&nbsp; iren-&gt;Initialize();<br>&nbsp;&nbsp;&nbsp; renWin-&gt;Render();<br>&nbsp;&nbsp;&nbsp; iren-&gt;Start();<br><br>&nbsp;&nbsp;&nbsp; //...<br>}<br><br>--- Öner F <i>&lt;luxtheme@yahoo.de&gt;</i> schrieb am <b>Di, 26.5.2009:<br></b><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><b><br>Von: luxtheme &lt;luxtheme@yahoo.de&gt;<br>Betreff: [vtkusers] Is it possible to change size of a vtkActor2D?<br>An:
 vtkusers@vtk.org<br>Datum: Dienstag, 26. Mai 2009, 11:35<br><br></b><div id="yiv1137704513"><style type="text/css"><!--#yiv1137704513 DIV {margin:0px;}--></style><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><div style="font-family: Courier New,courier,monaco,monospace,sans-serif;"><span style="font-family: arial,helvetica,sans-serif;"><b>Hi,</b></span><b><br style="font-family: arial,helvetica,sans-serif;"><br style="font-family: arial,helvetica,sans-serif;"><span style="font-family: arial,helvetica,sans-serif;">I want to display analog &amp; digital signals in a cartesian coordinate system which </span><br style="font-family: arial,helvetica,sans-serif;"><span style="font-family: arial,helvetica,sans-serif;">should be zoomable. I have tried several approaches and simply do not get further.</span><br style="font-family: arial,helvetica,sans-serif;"><span style="font-family: arial,helvetica,sans-serif;">So I need
 help.</span><br style="font-family: arial,helvetica,sans-serif;"><br style="font-family: arial,helvetica,sans-serif;"><span style="font-family: arial,helvetica,sans-serif;">One of the approaches which I try is vtkActor2D. Problem is, that if I change the</span><br style="font-family: arial,helvetica,sans-serif;"><span style="font-family: arial,helvetica,sans-serif;">window size, it does not change the size of the 2D actor. First position of the</span><br style="font-family: arial,helvetica,sans-serif;"><span style="font-family: arial,helvetica,sans-serif;">2D actor I can wonderfully set up, but position2 cannot be changed. Height and</span><br style="font-family: arial,helvetica,sans-serif;"><span style="font-family: arial,helvetica,sans-serif;">width of the 2D actor remains always constant.</span><br style="font-family: arial,helvetica,sans-serif;"><span style="font-family: arial,helvetica,sans-serif;">Is it possible to zoom with vtkActor2D? If so,
 how?</span><br style="font-family: arial,helvetica,sans-serif;"><span style="font-family: arial,helvetica,sans-serif;">Which additional functions do I need?</span><br style="font-family: arial,helvetica,sans-serif;"><br style="font-family: arial,helvetica,sans-serif;"><span style="font-family: arial,helvetica,sans-serif;">.luxtheme.</span><br></b></div></div></div><br></blockquote></td></tr></table><br>