Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 60 additions & 86 deletions Common/RenderWindow.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -100,73 +100,28 @@ class MyInteractorStyleTrackballCamera:public
virtual void OnChar ()
{
vtkRenderWindowInteractor *rwi = this->Interactor;
switch (rwi->GetKeyCode ())
{
case '1':
std::string key = rwi->GetKeySym();

if ( key == "F1" )
this->Window->Capture ("Capture.jpg");
return;
case '2':
else if ( key == "F2" )
this->Window->Capture ("Capture.eps");
return;
case '3':
else if ( key == "F3" )
this->Window->Capture ("Capture.png");
return;
case '4' :
else if ( key == "F4" ) {
int Factor;
cout<<"Enter new magnification factor :";
cin>>Factor;
this->Window->SetCaptureMagnificationFactor(Factor);
return;
case 'E' :
int Number;
cout<<"Enter number of interactions to skip :";
cin>>Number;
this->Window->SkipInteractions(Number);
return;
case 'N':
case 'n':
this->Window->EnableNormalMap();
return;

case 'x':
case 'X':
if (this->EdgesDisplay == 0)
{
this->EdgesDisplay = 1;
this->Window->DisplayInputEdges ();
}
else
{
this->EdgesDisplay = 0;
this->Window->SetInputEdges (0);
}
this->Window->Render ();
return;
case 'I':
case 'i':
this->Window->SwitchDisplayIds ();
return;
case 'a':
this->Window->Render();
return;
case 'O':
case 'o':
this->Window->SwitchOrientation();
this->Window->Render();
return;
case '5':
{
} else if ( key == "F5" ) {
char name[100];
cout<<"Save Camera (.view)"<<endl;
cout<<"Enter name : ";
cin>>name;

this->Window->SaveCamera(name);

return;
}
case '6':
{
} else if ( key == "F6" ) {
char name[100];
int flag;
cout<<"Load Camera"<<endl;
Expand All @@ -180,54 +135,77 @@ class MyInteractorStyleTrackballCamera:public
cout<<"Load "<<name<<" -> [OK]"<<endl;
else
cout<<"Load"<<name<<" -> [BUG]"<<endl;

return;
}
case '7':
{
} else if ( key == "F7" ) {
vtkPolyDataWriter * SWriter = vtkPolyDataWriter::New ();
SWriter->SetInputData (this->Window->GetInput ());
SWriter->SetFileName ("mesh.vtk");
SWriter->Write ();
SWriter->Delete ();
return;
}
case '8':
{
} else if ( key == "F8" ) {
vtkOBJExporter * SWriter = vtkOBJExporter::New ();
SWriter->SetInput (this->Window->GetvtkRenderWindow());
SWriter->SetFilePrefix ("mesh");
SWriter->Write ();
SWriter->Delete ();
return;
}
case '9':
{
} else if ( key == "F9" ) {
vtkSTLWriter * SWriter = vtkSTLWriter::New ();
SWriter->SetInputData (this->Window->GetInput ());
SWriter->SetFileName ("mesh.stl");
SWriter->Write ();
SWriter->Delete ();
return;
}
case '0':
{
} else if ( key == "F10" ) {
vtkPLYWriter * Writer = vtkPLYWriter::New ();
Writer->SetInputData (this->Window->GetInput ());
Writer->SetFileName ("mesh.ply");
Writer->Write ();
Writer->Delete ();
return;
}
case '_':
{
} else if ( key == "F11" ) {
vtkVRMLExporter * Writer = vtkVRMLExporter::New ();
Writer->SetInput (this->Window->GetvtkRenderWindow());
Writer->SetFileName ("mesh.wrl");
Writer->Write ();
Writer->Delete ();
return;
}

switch (rwi->GetKeyCode ())
{
case 'E' :
int Number;
cout<<"Enter number of interactions to skip :";
cin>>Number;
this->Window->SkipInteractions(Number);
break;
case 'N':
case 'n':
this->Window->EnableNormalMap();
break;

case 'x':
case 'X':
if (this->EdgesDisplay == 0)
{
this->EdgesDisplay = 1;
this->Window->DisplayInputEdges ();
}
else
{
this->EdgesDisplay = 0;
this->Window->SetInputEdges (0);
}
this->Window->Render ();
break;
case 'I':
case 'i':
this->Window->SwitchDisplayIds ();
break;
case 'a':
this->Window->Render();
break;
case 'O':
case 'o':
this->Window->SwitchOrientation();
this->Window->Render();
break;
case '+':
{
if (this->Window->GetEdgesActor())
Expand All @@ -236,7 +214,6 @@ class MyInteractorStyleTrackballCamera:public
this->Window->GetEdgesActor()->GetProperty()->GetLineWidth()+1);
this->Window->Render();
}
return;
}
case '-':
{
Expand All @@ -246,7 +223,6 @@ class MyInteractorStyleTrackballCamera:public
this->Window->GetEdgesActor()->GetProperty()->GetLineWidth()-1);
this->Window->Render();
}
return;
}
case 'v':
{
Expand Down Expand Up @@ -282,7 +258,6 @@ class MyInteractorStyleTrackballCamera:public
}
cout<<endl;
*/
return;
}
case 't':
{
Expand Down Expand Up @@ -444,7 +419,7 @@ RenderWindow::AddText (char *text, float x, float y, float z, float R,

Actor->SetMapper (Mapper);
Mapper->Delete();
this->GetMeshRenderer()->AddActor2D (Actor);
this->GetMeshRenderer()->AddViewProp (Actor);
}

void
Expand Down Expand Up @@ -995,11 +970,10 @@ RenderWindow::GetEdgesVisibilityArray()
void
RenderWindow::SwitchDisplayIds ()
{
vtkActor2DCollection *Actors = this->GetMeshRenderer()->GetActors2D ();
auto *Actors = this->GetMeshRenderer()->GetViewProps ();

vtkActor2D *Actor;
Actors->InitTraversal ();
Actor = Actors->GetNextActor2D ();
auto Actor = Actors->GetNextProp ();

while (Actor)
{
Expand All @@ -1009,7 +983,7 @@ RenderWindow::SwitchDisplayIds ()
this->SetDisplayIdsOff ();
return;
}
Actor = Actors->GetNextActor2D ();
Actor = Actors->GetNextProp ();

}

Expand Down Expand Up @@ -1137,9 +1111,9 @@ RenderWindow::SetDisplayIdsOn ()
cellLabels->SetMapper (cellMapper);
}

Renderer->AddActor2D (rectActor);
Renderer->AddActor2D (pointLabels);
Renderer->AddActor2D (cellLabels);
Renderer->AddViewProp (rectActor);
Renderer->AddViewProp (pointLabels);
Renderer->AddViewProp (cellLabels);


renWin->Render ();
Expand Down