[vtkusers] Drawing a simple line graph (CONTINUES...)

Isidro Moreno morenoisidro at yahoo.com.ar
Wed Jul 4 11:08:03 EDT 2007


OK, here's a simple code:

#include "vtkActor2D.h"
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkPolyDataMapper2D.h"
#include "vtkLineSource.h"
#include "vtkProperty2D.h"

int main(int argc, char *argv[]){

    vtkLineSource *linea=vtkLineSource::New();
    linea->SetPoint1(-100.0,600.0,0.0);
    linea->SetPoint2(-800.0,500.0,0.0);

    vtkPolyDataMapper2D *mapper=vtkPolyDataMapper2D::New();
    mapper->SetInput(linea->GetOutput());

    vtkActor2D *actor=vtkActor2D::New();
    actor->SetMapper(mapper);
    actor->GetProperty()->SetColor(1.0,0.0,0.0);
    actor->SetWidth(0.25);
    actor->SetHeight(0.25);

    vtkRenderer *render=vtkRenderer::New();
    vtkRenderWindow *ventana=vtkRenderWindow::New();
    ventana->AddRenderer(render);

    vtkRenderWindowInteractor *interac=vtkRenderWindowInteractor::New();
    interac->SetRenderWindow(ventana);

    render->AddActor2D(actor);
    render->SetBackground(0.1,0.2,0.4);

    ventana->SetSize(600,400);
    ventana->Render();

    interac->Initialize();
    interac->Start();

    linea->Delete();
    mapper->Delete();
    actor->Delete();
    render->Delete();
    ventana->Delete();
    interac->Delete();

    return 0;}

Now, try to change window's size with your mouse and you'll see that the 
line don't scale and an xyplotactor. There's where my problem started...

3RD) I've already seen the help file. I meant I couldn't find anything in 
vtkActor2D.h.

Isidro.

----- Original Message ----- 
From: "Dean Inglis" <dean.inglis at sympatico.ca>
To: <vtkusers at vtk.org>
Cc: <morenoisidro at yahoo.com.ar>
Sent: Tuesday, July 03, 2007 10:56 PM
Subject: [vtkusers] Drawing a simple line graph (CONTINUES...)


> Hi Isidro,
>
> 1st) if you post code examples, they are useful
> if they are complete and can be compiled and run by
> anybody. Can you post a very simple and complete
> example that illustrates your problem (a tcl script would
> be easiest), for example, a line drawn from
> (-100,600) to (-800, 500).
>
> 2nd) got it.  It might be interesting to show what
> happens if you draw the same line/function on an
> image with vtkImageCanvasSource2D and visualize with
> vtkImageViewer...
>
> (3rd)?
> HOWEVER, I found there is no definition of GetPositionCoordinates()
> and GetPosition2Coordinates() methods in vtkActor2D.h . Where are them
> defined in?
>
> From the vtk documentation:
>
> //
> virtual vtkCoordinate* vtkActor2D::GetPositionCoordinate  (     ) 
> [virtual]
>
>   Get the PositionCoordinate instance of vtkCoordinate. This is used for
> complicated or relative positioning. The position variable controls the
> lower left corner of the Actor2D
>
> Referenced by vtkAxisActor2D::GetPoint1Coordinate().
> //
>
> "Why should I change "reference coordinate" to NULL? In fact, position2 is
> relative to position..."
>
> The documentation (as well as the source code) of vtkCoordinate and any
> examples or
> tests for that class should be more helpful.  Position2 is not necessarily
> relative to position(1).
>
> (4th)?
> "Finally I tried with actor->PrintSelf(cout,0) and everything seemed to be
> OK..."
>
> PrintSelf will not tell you much other than what Set/Get objects or ivars
> are and what they were set to.  Setting an object to, for example,
> myObject->DebugOn() and then capturing the output with the following will
> tell you much more:
>
> #include "vtkOutputWindow.h"
> #include "vtkFileOutputWindow.h"
>
> void myvtkmain(void)
> {
>  vtkOutputWindow* ow = vtkOutputWindow::GetInstance();
>  vtkFileOutputWindow* fow = vtkFileOutputWindow::New();
>  fow->SetFileName("my_debug_log.txt");
>  if(ow)
>    {
>    ow->SetInstance(fow);
>    }
>  fow->Delete();
>
>  vtkSomeObject* myobject = vtkSomeObject::New();
>  myobject->DebugOn();
>
>  // ...
>
>  myobject->Delete();
> }
>
> Dean
>
>
>
> -- 
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.476 / Virus Database: 269.9.12/878 - Release Date: 28/6/2007 
> 17:57
>
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070704/3067edce/attachment.htm>


More information about the vtkusers mailing list