C++
Tutorial
Part 3b

Total SUU Webserver Pagehits by Month

Download this file:

This visualization is the total page hits for a month for the selected pages.



This visualization is fairly easy to do. I have the data in the monthDay.txt file. In the file the amount the page was hit is before the page name. Here is some code on how I did it.

vtkCubeSource *cube[size];
vtkPolyDataMapper * cubeMapper[size];
vtkActor *cubeActor[size];
vtkRenderer *ren= vtkRenderer::New();

vtkTextSource *textSource[size];
vtkPolyDataMapper *textMapper[size];
vtkActor *textActor[size];

for(int i = 0; i < size; i++) {
data >> x;
data.getline(c, 256);
cube[i] = vtkCubeSource::New();
cube[i]->SetXLength( 1.0 );
cube[i]->SetYLength( x/1000 );
cube[i]->SetZLength( 1.0 );

cubeMapper[i] = vtkPolyDataMapper::New();
cubeMapper[i]->SetInput( cube[i]->GetOutput() );

cubeActor[i] = vtkActor::New();

cubeActor[i]->SetMapper( cubeMapper[i] );
cubeActor[i]->SetPosition(i+i,x/2000,0);
cubeActor[i]->GetProperty()->SetColor(r,b,g);

textSource[i] = vtkTextSource::New();
textSource[i]->SetText(&c[1]);
textSource[i]->BackingOff();

textMapper[i] = vtkPolyDataMapper::New();
textMapper[i]->SetInput(textSource[i]->GetOutput());

textActor[i] = vtkActor::New();
textActor[i]->SetMapper(textMapper[i]);
textActor[i]->RotateWXYZ(270,0,1,0);
textActor[i]->RotateWXYZ(270,0,0,1);
textActor[i]->AddPosition((i+i)b-1,0,3);
textActor[i]->SetScale(.1,.1,.1);

ren->AddActor( cubeActor[i] );
ren->AddActor(textActor[i]);


if(r == 0)
r = 1;
else if(r == 1){
r = 0;
if(b == 0)
b = 1;
else if(b == 1){
b = 0;
if(g == 0)
g = 1;
else if(g == 1)
g = 0;
}
}
cout <<c<<endl;
}

The way I did it was to just create an array for the cubeSource, cubeActor, ect. Then just loop around grabbing data from file and adding it to actors and then adding that to the window.

Home
C++ Tutorial
Python Tutorial
TCL/TK Tutorial

Downloads
Homework
About Us
Contact
Links

C++ Tutorial
Part 1: VS 6
Part 2: VS .NET
Part 3: SUU Logs