<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><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;">Hi,</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;">I want to display analog & 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><br><span style="font-family: arial,helvetica,sans-serif;">my code:</span><br><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 "vtkcamera.h"<br><br>#include <cstdlib><br>#include <ctime><br><br>//random signal<br>void random_Signal (int timeLine, int *event_array_time, <br> int *event_array_bit, int &array_index) <br>{<br> srand((unsigned)time(0));<br>
int time=0;<br> int counter=0;<br> int start_bit = 0;<br><br> while(time<timeLine)<br> {<br> counter++;<br> event_array_time[counter-1]=time;<br> event_array_bit[counter-1]=start_bit;<br><br> int random_event = (rand()%500)+1;<br> time+=random_event;<br> start_bit=(start_bit+1)%2;<br> }<br> event_array_time[counter-1]=timeLine;<br><br> array_index=counter;<br>}<br><br>//line<br>void create_Line(double x1, double y1, double x2, double y2, <br> vtkPoints *points, vtkCellArray *lines, int &pID)<br>{<br>
points->InsertNextPoint(x1,y1,0); <br> points->InsertNextPoint(x2,y2,0); <br><br> lines->InsertNextCell(2); <br> lines->InsertCellPoint(pID); <br> lines->InsertCellPoint(pID+1); <br><br> pID+=2; <br>}<br><br>//MAIN<br>void main()<br>{<br> const int events=100; <br> int event_array_time[events];<br> int event_array_bit[events];<br> int timeLine = 2000; <br> int array_index = 0;<br><br> vtkPoints *points =
vtkPoints::New();<br> vtkCellArray *lines = vtkCellArray::New();<br> int pID = 0;<br><br> // generate random signal<br> random_Signal(timeLine, event_array_time, event_array_bit, array_index);<br> cout << "\n\nAI: " << array_index << endl;<br><br> //plot signal<br> create_Line(800.0/timeLine*event_array_time[0],<br> 300*event_array_bit[0], //position1<br> 800.0/timeLine*event_array_time[1], <br> 300*event_array_bit[0], //position2<br> points,
lines, pID);<br><br> for (int i=1; i<array_index-1; i++) {<br><br> // toggle line<br> create_Line(800.0/timeLine*event_array_time[i], 300*event_array_bit[i],<br> 800.0/timeLine*event_array_time[i], 300*event_array_bit[i+1],<br> points, lines, pID);<br><br> // High-/ Low-line<br> create_Line(800.0/timeLine*event_array_time[i], 300*event_array_bit[i],<br> 800.0/timeLine*event_array_time[i+1], 300*event_array_bit[i],<br> points, lines, pID);<br> }<br><br> // Create 2d-actor<br> vtkPolyData* polyData =
vtkPolyData::New();<br> polyData->SetPoints(points); <br> polyData->SetLines(lines); <br><br> vtkPolyDataMapper2D *mapper = vtkPolyDataMapper2D::New();<br> mapper->SetInput(polyData); <br><br> vtkActor2D *actor = vtkActor2D::New();<br> actor->SetMapper(mapper);<br> //actor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport(); //OK<br> //actor->GetPositionCoordinate()->SetValue(.2,.5); //OK<br> actor->SetWidth(0.7); // no effect<br> actor->SetHeight(0.1); // no
effect<br> //actor->SetPosition(0.1,0.1); //OK<br> actor->GetPosition2Coordinate()->SetCoordinateSystemToNormalizedViewport(); <br> //^no effect<br> actor->GetPosition2Coordinate()->SetValue(.2,.5); //no effect<br> actor->SetPosition2(0.9,0.9); //no effect<br><br> // Create a renderer<br> vtkRenderer* ren = vtkRenderer::New();<br> ren->SetBackground(0.75,0.25,0.25);<br> ren->AddActor(actor);<br> ren->GetActiveCamera()->ParallelProjectionOff(); //no effect<br> ren->GetActiveCamera()->Zoom(5); //no effect<br><br> // Create a render
window<br> vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();<br> vtkRenderWindow* renWin = vtkRenderWindow::New();<br> renWin->AddRenderer(ren);<br> renWin->SetSize( 800,300 );<br> renWin->SetInteractor( iren );<br><br> iren->Initialize();<br> renWin->Render();<br> iren->Start();<br><br> //...<br>}<br><br></div></div><br>
</body></html>