#include <renderwindowinteractor.h>
Inheritance diagram for RenderWindowInteractor:
Signals | |
void | ActorRotated (float xf, float yf) |
This signal is emitted, whenever we have rotated an actor. | |
void | ActorRolled (float angle) |
This signal is emitted, whenever we have rolled an actor Rolling is rotating in the viewplane of the camera. | |
void | Released (int x, int y) |
Public Member Functions | |
RenderWindowInteractor (QWidget *parent=0, const char *name=0) | |
Constructs a new RenderWindowInteractor with the default settings. | |
RenderWindowInteractor (QGLFormat glf, QWidget *parent=0, const char *name=0) | |
Constructs a new RenderWindowInteractor with the default settings. | |
~RenderWindowInteractor () | |
Destructor of RenderWindowInteractor. | |
void | SetLeftButtonFunction (const char *function) |
Sets the function, which will be used, when the left mouse button is pressed. | |
void | SetMiddleButtonFunction (const char *function) |
Sets the function, which will be used, when the middle mouse button is pressed. | |
void | SetRightButtonFunction (const char *function) |
Sets the function, which will be used, when the right mouse button is pressed. | |
void | SetShiftLeftButtonFunction (const char *function) |
Sets the function, which will be used, when the left button and the shift key are pressed. | |
void | SetInteractionActor (vtkActor *actor) |
Sets the actor, which will be used in actor interactions. | |
void | SetActorRotation (float x, float y, float z) |
Sets the point, in actor coordinate system, around which we rotate the current actor. | |
void | SetPlane (float *ebene) |
Sets the plane for the actor interaction ActorPlaneMove() and ActorPlaneRoll(). | |
void | SetInteractionTime (int time) |
Set the time in milliseconds between two interactions. | |
void | SetSensitivity (float t) |
Sets the sensitivity of all interactions. | |
int | GetInteractionTime (void) |
Get the time in milliseconds between two interactions. | |
vtkActor * | GetInteractionActor (void) |
Returns the actor, which is used in actor interactions. | |
float | GetSensitivity () |
Returns the current sensitivity of all interactions. | |
const char * | GetClassName () |
Returns the class name. | |
Protected Slots | |
void | ActorRotate () |
Rotates an actor around a specific point. | |
void | ActorTranslate () |
Translates the actor on the viewplane. | |
void | ActorZoom () |
Zooms the actor on the normal of the viewplane. | |
void | ActorRoll () |
Turns an actor on the viewplane of the camera. | |
void | ActorPlaneRoll () |
Rolls the actor. | |
void | ActorPlaneMove () |
Moves the actor. | |
void | CameraRotate () |
Rotates the camera around the point, which was set with SetCameraRotation(). | |
void | CameraTranslate () |
Translates the camera along the viewplane. | |
void | CameraZoom () |
Zooms the camera along the normal of the viewplane. | |
void | CameraRoll () |
Rotates the camera on the viewplane. | |
void | DoNothing () |
Does nothing. | |
Protected Member Functions | |
void | mousePressEvent (QMouseEvent *event) |
catches the mouse press to react appropriate | |
void | mouseReleaseEvent (QMouseEvent *event) |
Overriden to catch mouseReleaseEvents and to stop the internal timer. | |
void | mouseMoveEvent (QMouseEvent *event) |
catches all movements of the mouse | |
Private Member Functions | |
void | DisplayToWorld (float x, float y, float z, float *worldPoint) |
Computes the display point defined with x, y and z to world coordinates. | |
void | WorldToDisplay (float x, float y, float z, float *displayPoint) |
Computes the world point defined with x, y and z to display coordinates. | |
void | InitRenderWindowInteractor () |
Initialize the RenderWindowInteractor. | |
Private Attributes | |
vtkCellPicker * | cellpicker |
vtkCamera * | currentCamera |
vtkActor * | interactionActor |
vtkActor * | collisionActor |
vtkLight * | currentLight |
float | viewUp [3] |
float | vpNormal [3] |
float | rotateY [3] |
float | renCenter [3] |
float | viewFocus [3] |
float | camPos [3] |
float | deltaElevation |
float | deltaAzimuth |
float | normale [3] |
float | ebenekonstante |
QTimer * | stepTimer |
bool | mouseEventActive |
bool | firstCall |
float | trackballFactor |
float | cameraRotation [3] |
int | interactionTime |
int | currentMousePos [2] |
int | lastMousePos [2] |
char | leftButtonFunction [200] |
char | middleButtonFunction [200] |
char | rightButtonFunction [200] |
char | shiftLeftButtonFunction [200] |
This class implements the interaction to the RenderWindow. There is the possibility to set the according function dynamically during run time for each mouse button. There are 2 interaction possibilites: interaction with an actor and interaction with the camera.
The following interaction functions for interacting with the camera are possible:
$Log: renderwindowinteractor.cpp,v $ Revision 1.3 2000/09/14 14:56:10 jstifter Changes proposed from Kent Vander Velden <graphix@iastate.edu> CameraRotate, CameraTranslate, CameraZoom problems fixed (mostly due to incorrect clipping) Revision 1.2 2000/09/14 13:25:43 jstifter Added Support for *parent, *name in the constructors Revision 1.1.1.1 2000/08/15 09:36:39 jstifter first cvs import
Definition at line 17 of file renderwindowinteractor.h.
|
Constructs a new RenderWindowInteractor with the default settings. The default functions are:
Definition at line 79 of file renderwindowinteractor.cpp. References InitRenderWindowInteractor().
00081 : RenderWindow( parent, name ) { 00082 this->InitRenderWindowInteractor(); 00083 } |
Here is the call graph for this function:
|
Constructs a new RenderWindowInteractor with the default settings. The default functions are:
Definition at line 100 of file renderwindowinteractor.cpp. References InitRenderWindowInteractor().
00102 : RenderWindow( glf, parent, name ) { 00103 this->InitRenderWindowInteractor(); 00104 } |
Here is the call graph for this function:
|
Destructor of RenderWindowInteractor.
Definition at line 111 of file renderwindowinteractor.cpp. References stepTimer.
00111 { 00112 delete this->stepTimer; 00113 } |
|
Moves the actor. Moves the actor, which was set with SetInteractionActor() in the plane, which was set with SetPlane(). Definition at line 805 of file renderwindowinteractor.cpp. References currentMousePos, DisplayToWorld(), ebenekonstante, interactionActor, lastMousePos, normale, and WorldToDisplay().
00805 { 00806 00807 float *center; 00808 float dispCenter[4]; 00809 float newP[4]; 00810 float oldP[4]; 00811 float p0[3],p1[3],t; 00812 float tkonstante = (this->normale[0])*(this->normale[0]) + 00813 (this->normale[1])*(this->normale[1]) + 00814 (this->normale[2])*(this->normale[2]) ; 00815 00816 if( (this->currentMousePos[0] == this->lastMousePos[0]) && 00817 (this->currentMousePos[1] == this->lastMousePos[1]) ) { 00818 return; 00819 } 00820 00821 center = this->interactionActor->GetCenter(); 00822 this->WorldToDisplay( center[0], center[1], center[2], dispCenter ); 00823 00824 this->DisplayToWorld( float(this->currentMousePos[0]), 00825 float(this->height() - this->currentMousePos[1]), 00826 dispCenter[2], 00827 newP ); 00828 00829 this->DisplayToWorld( float(this->lastMousePos[0]), 00830 float(this->height() - this->lastMousePos[1]), 00831 dispCenter[2], 00832 oldP); 00833 00834 oldP[3] = oldP[0]*(this->normale[0]) + 00835 oldP[1]*(this->normale[1]) + 00836 oldP[2]*(this->normale[2]) ; 00837 00838 t = (this->ebenekonstante - oldP[3])/tkonstante; 00839 00840 p0[0] = oldP[0] + t*(this->normale[0]); 00841 p0[1] = oldP[1] + t*(this->normale[1]); 00842 p0[2] = oldP[2] + t*(this->normale[2]); 00843 00844 newP[3] = newP[0]*(this->normale[0]) + 00845 newP[1]*(this->normale[1]) + 00846 newP[2]*(this->normale[2]); 00847 00848 t = (this->ebenekonstante - newP[3])/tkonstante; 00849 00850 p1[0] = newP[0] + t*(this->normale[0]); 00851 p1[1] = newP[1] + t*(this->normale[1]); 00852 p1[2] = newP[2] + t*(this->normale[2]); 00853 00854 this->interactionActor->AddPosition( p1[0]-p0[0], 00855 p1[1]-p0[1], 00856 p1[2]-p0[2] ); 00857 // update 00858 this->updateGL(); 00859 00860 // save mouse pos 00861 this->lastMousePos[0] = this->currentMousePos[0]; 00862 this->lastMousePos[1] = this->currentMousePos[1]; 00863 } |
|
Rolls the actor. Rolls the actor, which was set with SetInteractionActor() in the plane, which was set with SetPlane(). Definition at line 872 of file renderwindowinteractor.cpp. References currentMousePos, firstCall, RenderWindow::GetRenderer(), interactionActor, lastMousePos, renCenter, and trackballFactor.
00872 { 00873 00874 float angle; 00875 00876 // do nothing if mouse is still on the same pos 00877 if( (this->currentMousePos[0] == this->lastMousePos[0]) && 00878 (this->currentMousePos[1] == this->lastMousePos[1]) ) { 00879 return; 00880 } 00881 00882 // first time we do some preprocessing 00883 if( firstCall ) { 00884 this->renCenter[0] = this->GetRenderer()->GetCenter()[0]; 00885 this->renCenter[1] = this->GetRenderer()->GetCenter()[1]; 00886 this->renCenter[2] = this->GetRenderer()->GetCenter()[2]; 00887 firstCall = false; 00888 } 00889 00890 int diffX1 = this->currentMousePos[0] - int(this->renCenter[0]); 00891 int diffY1 = this->currentMousePos[1] - int(this->renCenter[1]); 00892 int diffX2 = this->lastMousePos[0] - int(this->renCenter[0]); 00893 int diffY2 = this->lastMousePos[1] - int(this->renCenter[1]); 00894 00895 double a1 = atan2( double(diffY1), double(diffX1) ); 00896 double a2 = atan2( double(diffY2), double(diffX2) ); 00897 angle = (a2 - a1) / (2.0 * 3.1415926535) * 360.0 / 10.0 * 00898 this->trackballFactor; 00899 this->interactionActor->RotateWXYZ( -angle, this->normale[0], 00900 this->normale[1], 00901 this->normale[2] ); 00902 00903 // update 00904 this->updateGL(); 00905 00906 // save mouse pos 00907 this->lastMousePos[0] = this->currentMousePos[0]; 00908 this->lastMousePos[1] = this->currentMousePos[1]; 00909 00910 } |
|
Turns an actor on the viewplane of the camera. The actor can be set with SetInteractionActor() Definition at line 579 of file renderwindowinteractor.cpp. References ActorRolled(), currentCamera, currentMousePos, firstCall, RenderWindow::GetRenderer(), interactionActor, lastMousePos, renCenter, and trackballFactor.
00579 { 00580 float angle; 00581 00582 // do nothing if mouse is still on the same pos 00583 if( (this->currentMousePos[0] == this->lastMousePos[0]) && 00584 (this->currentMousePos[1] == this->lastMousePos[1]) ) { 00585 return; 00586 } 00587 00588 // first time we do some preprocessing 00589 if( firstCall ) { 00590 this->currentCamera->GetViewPlaneNormal( this->vpNormal ); 00591 this->renCenter[0] = this->GetRenderer()->GetCenter()[0]; 00592 this->renCenter[1] = this->GetRenderer()->GetCenter()[1]; 00593 this->renCenter[2] = this->GetRenderer()->GetCenter()[2]; 00594 firstCall = false; 00595 } 00596 00597 int diffX1 = this->currentMousePos[0] - int(this->renCenter[0]); 00598 int diffY1 = this->currentMousePos[1] - int(this->renCenter[1]); 00599 int diffX2 = this->lastMousePos[0] - int(this->renCenter[0]); 00600 int diffY2 = this->lastMousePos[1] - int(this->renCenter[1]); 00601 00602 double a1 = atan2( double(diffY1), double(diffX1) ); 00603 double a2 = atan2( double(diffY2), double(diffX2) ); 00604 angle = (a2 - a1) / (2.0 * 3.1415926535) * 360.0 / 10.0 * 00605 this->trackballFactor; 00606 this->interactionActor->RotateWXYZ( angle, this->vpNormal[0], 00607 this->vpNormal[1], 00608 this->vpNormal[2] ); 00609 00610 emit ActorRolled( angle ); 00611 00612 // update 00613 this->updateGL(); 00614 00615 // save mouse pos 00616 this->lastMousePos[0] = this->currentMousePos[0]; 00617 this->lastMousePos[1] = this->currentMousePos[1]; 00618 } |
|
This signal is emitted, whenever we have rolled an actor Rolling is rotating in the viewplane of the camera.
Definition at line 136 of file moc_renderwindowinteractor.cpp. Referenced by ActorRoll().
00137 { 00138 if ( signalsBlocked() ) 00139 return; 00140 QConnectionList *clist = receivers( staticMetaObject()->signalOffset() + 1 ); 00141 if ( !clist ) 00142 return; 00143 QUObject o[2]; 00144 static_QUType_ptr.set(o+1,&t0); 00145 activate_signal( clist, o ); 00146 } |
|
Rotates an actor around a specific point. The rotation point can be set with SetActorRotation(), the actor must be set with SetInteractionActor() Definition at line 444 of file renderwindowinteractor.cpp. References ActorRotated(), currentCamera, currentMousePos, deltaAzimuth, deltaElevation, firstCall, RenderWindow::GetRenderer(), RenderWindow::GetRenderWindow(), interactionActor, lastMousePos, and trackballFactor.
00444 { 00445 float xf; 00446 float yf; 00447 00448 // do nothing if mouse is still on the same pos 00449 if( (this->currentMousePos[0] == this->lastMousePos[0]) && 00450 (this->currentMousePos[1] == this->lastMousePos[1]) ) { 00451 return; 00452 } 00453 00454 // basic idea: the change in x of the mouse is used to rotate around the 00455 // view-up vector. the change in y of the mouse is used to rotate around the 00456 // cross of the viewplane-normal and the view-up vector, 00457 00458 // first time we do some preprocessing 00459 if( firstCall ) { 00460 int *size = this->GetRenderWindow()->GetSize(); 00461 float *vp = this->GetRenderer()->GetViewport(); 00462 00463 this->deltaAzimuth = -20.0/((vp[2] - vp[0])*size[0]); 00464 this->deltaElevation = -20.0/((vp[3] - vp[1])*size[1]); 00465 00466 // get the rotation axis: cross of view-up and the normal in the viewplane 00467 this->currentCamera->GetViewUp( this->viewUp ); 00468 this->currentCamera->GetViewPlaneNormal( this->vpNormal ); 00469 vtkMath::Cross( this->vpNormal, this->viewUp, this->rotateY ); 00470 00471 this->firstCall = false; 00472 } 00473 00474 // how much to rotate 00475 xf = (this->currentMousePos[0] - this->lastMousePos[0]) 00476 * this->trackballFactor * deltaAzimuth * (-1); 00477 yf = (this->currentMousePos[1] - this->lastMousePos[1]) 00478 * this->trackballFactor * deltaElevation; 00479 00480 this->interactionActor->RotateWXYZ( xf, this->viewUp[0], this->viewUp[1], 00481 this->viewUp[2] ); 00482 this->interactionActor->RotateWXYZ( yf, this->rotateY[0], this->rotateY[1], 00483 this->rotateY[2] ); 00484 00485 emit ActorRotated( xf, yf ); 00486 00487 // update 00488 this->updateGL(); 00489 00490 // save mouse pos 00491 this->lastMousePos[0] = this->currentMousePos[0]; 00492 this->lastMousePos[1] = this->currentMousePos[1]; 00493 } |
|
This signal is emitted, whenever we have rotated an actor.
Definition at line 122 of file moc_renderwindowinteractor.cpp. Referenced by ActorRotate().
00123 { 00124 if ( signalsBlocked() ) 00125 return; 00126 QConnectionList *clist = receivers( staticMetaObject()->signalOffset() + 0 ); 00127 if ( !clist ) 00128 return; 00129 QUObject o[3]; 00130 static_QUType_ptr.set(o+1,&t0); 00131 static_QUType_ptr.set(o+2,&t1); 00132 activate_signal( clist, o ); 00133 } |
|
Translates the actor on the viewplane. The actor must be set with SetInteractionActor() Definition at line 501 of file renderwindowinteractor.cpp. References currentMousePos, DisplayToWorld(), interactionActor, lastMousePos, and WorldToDisplay().
00501 { 00502 float *center; 00503 float dispCenter[4]; 00504 float newP[4]; 00505 float oldP[4]; 00506 00507 // do nothing if mouse is still on the same pos 00508 if( (this->currentMousePos[0] == this->lastMousePos[0]) && 00509 (this->currentMousePos[1] == this->lastMousePos[1]) ) { 00510 return; 00511 } 00512 00513 center = this->interactionActor->GetCenter(); 00514 this->WorldToDisplay( center[0], center[1], center[2], dispCenter ); 00515 00516 this->DisplayToWorld( float(this->currentMousePos[0]), 00517 float(this->height() - this->currentMousePos[1]), 00518 dispCenter[2], 00519 newP ); 00520 00521 this->DisplayToWorld( float(this->lastMousePos[0]), 00522 float(this->height() - this->lastMousePos[1]), 00523 dispCenter[2], 00524 oldP); 00525 00526 this->interactionActor->AddPosition( newP[0]-oldP[0], 00527 newP[1]-oldP[1], 00528 newP[2]-oldP[2] ); 00529 // update 00530 this->updateGL(); 00531 00532 // save mouse pos 00533 this->lastMousePos[0] = this->currentMousePos[0]; 00534 this->lastMousePos[1] = this->currentMousePos[1]; 00535 } |
|
Zooms the actor on the normal of the viewplane. The actor must be set with SetInteractionActor() Definition at line 543 of file renderwindowinteractor.cpp. References currentCamera, currentMousePos, firstCall, interactionActor, lastMousePos, and trackballFactor.
00543 { 00544 float yf; 00545 00546 // do nothing if mouse is still on the same pos 00547 if( (this->currentMousePos[0] == this->lastMousePos[0]) && 00548 (this->currentMousePos[1] == this->lastMousePos[1]) ) { 00549 return; 00550 } 00551 00552 // first time we do some preprocessing 00553 if( firstCall ) { 00554 this->currentCamera->GetViewPlaneNormal( this->vpNormal ); 00555 firstCall = false; 00556 } 00557 00558 yf = float(this->lastMousePos[1] - this->currentMousePos[1]) / 00559 float(this->height()) * this->trackballFactor * -10.0; 00560 00561 this->interactionActor->AddPosition( this->vpNormal[0] * yf, 00562 this->vpNormal[1] * yf, 00563 this->vpNormal[2] * yf ); 00564 00565 // update 00566 this->updateGL(); 00567 00568 // save mouse pos 00569 this->lastMousePos[0] = this->currentMousePos[0]; 00570 this->lastMousePos[1] = this->currentMousePos[1]; 00571 } |
|
Rotates the camera on the viewplane. This function corresponds to a roll-operation like in airplanes Definition at line 757 of file renderwindowinteractor.cpp. References currentCamera, currentLight, currentMousePos, firstCall, RenderWindow::GetRenderer(), lastMousePos, renCenter, and trackballFactor. Referenced by InitRenderWindowInteractor().
00757 { 00758 float angle; 00759 00760 // do nothing if mouse is still on the same pos 00761 if( (this->currentMousePos[0] == this->lastMousePos[0]) && 00762 (this->currentMousePos[1] == this->lastMousePos[1]) ) { 00763 return; 00764 } 00765 00766 // first time we do some preprocessing 00767 if( firstCall ) { 00768 this->renCenter[0] = this->GetRenderer()->GetCenter()[0]; 00769 this->renCenter[1] = this->GetRenderer()->GetCenter()[1]; 00770 this->renCenter[2] = this->GetRenderer()->GetCenter()[2]; 00771 firstCall = false; 00772 } 00773 00774 // calculate the angle in radians and roll the camera 00775 int diffX1 = this->currentMousePos[0] - int(this->renCenter[0]); 00776 int diffY1 = this->currentMousePos[1] - int(this->renCenter[1]); 00777 int diffX2 = this->lastMousePos[0] - int(this->renCenter[0]); 00778 int diffY2 = this->lastMousePos[1] - int(this->renCenter[1]); 00779 00780 double a1 = atan2( double(diffY1), double(diffX1) ); 00781 double a2 = atan2( double(diffY2), double(diffX2) ); 00782 angle = (a2 - a1) / (2.0 * 3.1415926535) * 360.0 / 10.0 * 00783 this->trackballFactor; 00784 this->currentCamera->Roll( angle ); 00785 00786 // light follows the camera 00787 this->currentLight->SetPosition( this->currentCamera->GetPosition() ); 00788 this->currentLight->SetFocalPoint( this->currentCamera->GetFocalPoint() ); 00789 00790 // update 00791 this->updateGL(); 00792 00793 // save mouse pos 00794 this->lastMousePos[0] = this->currentMousePos[0]; 00795 this->lastMousePos[1] = this->currentMousePos[1]; 00796 } |
|
Rotates the camera around the point, which was set with SetCameraRotation().
Definition at line 625 of file renderwindowinteractor.cpp. References currentCamera, currentLight, currentMousePos, deltaAzimuth, deltaElevation, firstCall, RenderWindow::GetRenderer(), RenderWindow::GetRenderWindow(), lastMousePos, and trackballFactor. Referenced by InitRenderWindowInteractor().
00625 { 00626 float xf; 00627 float yf; 00628 00629 // do nothing if mouse is still on the same pos 00630 if( (this->currentMousePos[0] == this->lastMousePos[0]) && 00631 (this->currentMousePos[1] == this->lastMousePos[1]) ) { 00632 return; 00633 } 00634 00635 // first time we do some preprocessing 00636 if( firstCall ) { 00637 int *size = this->GetRenderWindow()->GetSize(); 00638 float *vp = this->GetRenderer()->GetViewport(); 00639 00640 this->deltaAzimuth = -20.0/((vp[2] - vp[0])*size[0]); 00641 this->deltaElevation = -20.0/((vp[3] - vp[1])*size[1]); 00642 firstCall = false; 00643 } 00644 00645 xf = (this->currentMousePos[0] - this->lastMousePos[0]) * this->deltaAzimuth 00646 * this->trackballFactor; 00647 yf = (this->lastMousePos[1] - this->currentMousePos[1]) * this->deltaElevation 00648 * this->trackballFactor; 00649 00650 this->currentCamera->Azimuth( xf ); 00651 this->currentCamera->Elevation( yf ); 00652 this->currentCamera->OrthogonalizeViewUp(); 00653 this->GetRenderer()->ResetCameraClippingRange(); 00654 00655 // light follows the camera 00656 this->currentLight->SetPosition( this->currentCamera->GetPosition() ); 00657 this->currentLight->SetFocalPoint( this->currentCamera->GetFocalPoint() ); 00658 00659 // update 00660 this->updateGL(); 00661 00662 // save mouse pos 00663 this->lastMousePos[0] = this->currentMousePos[0]; 00664 this->lastMousePos[1] = this->currentMousePos[1]; 00665 } |
|
Translates the camera along the viewplane.
Definition at line 671 of file renderwindowinteractor.cpp. References currentCamera, currentLight, currentMousePos, DisplayToWorld(), lastMousePos, trackballFactor, viewFocus, and WorldToDisplay(). Referenced by InitRenderWindowInteractor().
00671 { 00672 float newP[4]; 00673 float viewFocus[4]; 00674 float viewPoint[3]; 00675 double motionVector[3]; 00676 00677 // do nothing if mouse is still on the same pos 00678 if( (this->currentMousePos[0] == this->lastMousePos[0]) && 00679 (this->currentMousePos[1] == this->lastMousePos[1]) ) { 00680 return; 00681 } 00682 00683 this->currentCamera->GetFocalPoint( viewFocus ); 00684 this->WorldToDisplay( viewFocus[0], viewFocus[1], viewFocus[2], 00685 viewFocus ); 00686 double focalDepth = viewFocus[2]; 00687 00688 this->DisplayToWorld( float(this->width()/2.0 + (this->currentMousePos[0] 00689 - this->lastMousePos[0])), 00690 float(this->height()/2.0 - (this->currentMousePos[1] 00691 - this->lastMousePos[1])), 00692 focalDepth, 00693 newP ); 00694 00695 this->currentCamera->GetFocalPoint( viewFocus ); 00696 this->currentCamera->GetPosition( viewPoint ); 00697 00698 motionVector[0] = this->trackballFactor / 10.0 * ( viewFocus[0] - newP[0] ); 00699 motionVector[1] = this->trackballFactor / 10.0 * ( viewFocus[1] - newP[1] ); 00700 motionVector[2] = this->trackballFactor / 10.0 * ( viewFocus[2] - newP[2] ); 00701 00702 this->currentCamera->SetFocalPoint( motionVector[0] + viewFocus[0], 00703 motionVector[1] + viewFocus[1], 00704 motionVector[2] + viewFocus[2]); 00705 this->currentCamera->SetPosition( motionVector[0] + viewPoint[0], 00706 motionVector[1] + viewPoint[1], 00707 motionVector[2] + viewPoint[2]); 00708 00709 // light follows the camera 00710 this->currentLight->SetPosition( this->currentCamera->GetPosition() ); 00711 this->currentLight->SetFocalPoint( this->currentCamera->GetFocalPoint() ); 00712 00713 // update 00714 this->updateGL(); 00715 00716 // save mouse pos 00717 this->lastMousePos[0] = this->currentMousePos[0]; 00718 this->lastMousePos[1] = this->currentMousePos[1]; 00719 } |
|
Zooms the camera along the normal of the viewplane.
Definition at line 726 of file renderwindowinteractor.cpp. References currentCamera, currentMousePos, RenderWindow::GetRenderer(), lastMousePos, and trackballFactor. Referenced by InitRenderWindowInteractor().
00726 { 00727 float yf; 00728 00729 // do nothing if mouse is still on the same y position 00730 if( this->currentMousePos[1] == this->lastMousePos[1] ) { 00731 return; 00732 } 00733 00734 yf = float(this->currentMousePos[1]-this->lastMousePos[1]) / 00735 float(this->height()) * this->trackballFactor; 00736 // if yf < 0, we need to be between 0..1 00737 yf = pow( 1.1, yf ); 00738 00739 this->currentCamera->Dolly( yf ); 00740 this->GetRenderer()->ResetCameraClippingRange(); 00741 00742 // update 00743 this->updateGL(); 00744 00745 // save mouse pos 00746 this->lastMousePos[0] = this->currentMousePos[0]; 00747 this->lastMousePos[1] = this->currentMousePos[1]; 00748 } |
|
Computes the display point defined with x, y and z to world coordinates.
Definition at line 930 of file renderwindowinteractor.cpp. References RenderWindow::GetRenderer(). Referenced by ActorPlaneMove(), ActorTranslate(), and CameraTranslate().
00931 { 00932 this->GetRenderer()->SetDisplayPoint( x, y, z ); 00933 this->GetRenderer()->DisplayToWorld(); 00934 this->GetRenderer()->GetWorldPoint( worldPoint ); 00935 00936 // normalize 00937 if (worldPoint[3]) { 00938 worldPoint[0] = worldPoint[0] / worldPoint[3]; 00939 worldPoint[1] = worldPoint[1] / worldPoint[3]; 00940 worldPoint[2] = worldPoint[2] / worldPoint[3]; 00941 worldPoint[3] = 1.0; 00942 } 00943 } |
Here is the call graph for this function:
|
Does nothing. This is needed, when a Button should have no interaction meaning. Definition at line 918 of file renderwindowinteractor.cpp. Referenced by SetLeftButtonFunction(), SetMiddleButtonFunction(), SetRightButtonFunction(), and SetShiftLeftButtonFunction().
00918 { 00919 } |
|
Returns the class name.
Definition at line 151 of file renderwindowinteractor.cpp.
00151 { 00152 return( "RenderWindowInteractor" ); 00153 } |
|
Returns the actor, which is used in actor interactions.
Definition at line 318 of file renderwindowinteractor.cpp. References interactionActor.
00318 { 00319 return this->interactionActor; 00320 } |
|
Get the time in milliseconds between two interactions.
Definition at line 433 of file renderwindowinteractor.cpp. References interactionTime.
00433 { 00434 return this->interactionTime; 00435 } |
|
Returns the current sensitivity of all interactions.
Definition at line 185 of file renderwindowinteractor.cpp. References trackballFactor.
00185 { 00186 return this->trackballFactor; 00187 } |
|
Initialize the RenderWindowInteractor. This function is called from the two constructors Definition at line 121 of file renderwindowinteractor.cpp. References CameraRoll(), CameraRotate(), CameraTranslate(), CameraZoom(), collisionActor, currentCamera, currentLight, RenderWindow::GetRenderer(), interactionActor, mouseEventActive, SetInteractionTime(), SetLeftButtonFunction(), SetMiddleButtonFunction(), SetRightButtonFunction(), SetSensitivity(), SetShiftLeftButtonFunction(), and stepTimer. Referenced by RenderWindowInteractor().
00121 { 00122 this->SetLeftButtonFunction( SLOT(CameraRotate()) ); 00123 this->SetMiddleButtonFunction( SLOT(CameraTranslate()) ); 00124 this->SetRightButtonFunction( SLOT(CameraZoom()) ); 00125 this->SetShiftLeftButtonFunction( SLOT(CameraRoll()) ); 00126 00127 this->mouseEventActive = false; 00128 this->SetInteractionTime( 50 ); 00129 this->SetSensitivity( 10.0 ); 00130 00131 this->stepTimer = new QTimer(); 00132 CHECK_PTR( this->stepTimer ); 00133 00134 this->currentCamera = this->GetRenderer()->GetActiveCamera(); 00135 CHECK_PTR( this->currentCamera ); 00136 00137 // get the light we are using 00138 vtkLightCollection *lightCollection = this->GetRenderer()->GetLights(); 00139 lightCollection->InitTraversal(); 00140 this->currentLight = lightCollection->GetNextItem(); 00141 CHECK_PTR( this->currentLight ); 00142 00143 this->interactionActor = NULL; 00144 this->collisionActor = NULL; 00145 } |
Here is the call graph for this function:
|
catches all movements of the mouse Overriden to save the mouse coords, which are needed for the interaction routines. Definition at line 410 of file renderwindowinteractor.cpp. References currentMousePos.
00410 { 00411 this->currentMousePos[0] = event->x(); 00412 this->currentMousePos[1] = event->y(); 00413 } |
|
catches the mouse press to react appropriate Overriden to catch mousePressEvents and to start an internal timer, which calls the appropriate interaction routine. Definition at line 346 of file renderwindowinteractor.cpp. References currentMousePos, firstCall, lastMousePos, mouseEventActive, and stepTimer.
00346 { 00347 if( this->mouseEventActive ) { 00348 return; 00349 } 00350 00351 if( event->button() & LeftButton ) { 00352 if( event->state() & ShiftButton ) { 00353 // left mouse mouse and shift button 00354 this->mouseEventActive = true; 00355 QObject::connect( this->stepTimer, SIGNAL(timeout()), 00356 this->shiftLeftButtonFunction ); 00357 } 00358 else { 00359 // left mouse button without shift button 00360 this->mouseEventActive = true; 00361 QObject::connect( this->stepTimer, SIGNAL(timeout()), 00362 this->leftButtonFunction ); 00363 } 00364 } 00365 else if( event->button() & MidButton ) { 00366 // middle mouse button 00367 this->mouseEventActive = true; 00368 QObject::connect( this->stepTimer, SIGNAL(timeout()), 00369 this->middleButtonFunction ); 00370 } 00371 else if( event->button() & RightButton ) { 00372 // right mouse button 00373 this->mouseEventActive = true; 00374 QObject::connect( this->stepTimer, SIGNAL(timeout()), 00375 this, this->rightButtonFunction ); 00376 } 00377 00378 if( this->mouseEventActive ) { 00379 this->currentMousePos[0] = event->x(); 00380 this->currentMousePos[1] = event->y(); 00381 this->lastMousePos[0] = event->x(); 00382 this->lastMousePos[1] = event->y(); 00383 this->firstCall = true; 00384 this->stepTimer->start( this->interactionTime ); 00385 } 00386 } |
|
Overriden to catch mouseReleaseEvents and to stop the internal timer.
Definition at line 392 of file renderwindowinteractor.cpp. References mouseEventActive, Released(), and stepTimer.
00392 { 00393 if( this->mouseEventActive ) { 00394 this->stepTimer->stop(); 00395 this->mouseEventActive = false; 00396 QObject::disconnect( this->stepTimer, 0, this, 0 ); 00397 } 00398 00399 emit( Released(event->x(), this->height() - event->y()) ); 00400 00401 } |
|
This signal is emitted, when the interaction is finished.
Definition at line 149 of file moc_renderwindowinteractor.cpp. Referenced by mouseReleaseEvent().
00150 { 00151 if ( signalsBlocked() ) 00152 return; 00153 QConnectionList *clist = receivers( staticMetaObject()->signalOffset() + 2 ); 00154 if ( !clist ) 00155 return; 00156 QUObject o[3]; 00157 static_QUType_int.set(o+1,t0); 00158 static_QUType_int.set(o+2,t1); 00159 activate_signal( clist, o ); 00160 } |
|
Sets the point, in actor coordinate system, around which we rotate the current actor. Important: Set first the actor with SetInteractionActor() before using this function.
Definition at line 332 of file renderwindowinteractor.cpp. References interactionActor.
00332 { 00333 ASSERT( this->interactionActor != NULL ); 00334 00335 // set it to the interactionActor 00336 this->interactionActor->SetOrigin( x, y, z ); 00337 } |
|
Sets the actor, which will be used in actor interactions.
Definition at line 310 of file renderwindowinteractor.cpp. References interactionActor.
00310 { 00311 this->interactionActor = actor; 00312 } |
|
Set the time in milliseconds between two interactions. If you have huge objects and the interaction is too fast for the rendering, set the value bigger. Note that on some systems, the timer of qt (QTimer) can not be faster than the internal clock, which is around 16 msec (measured on WinNT 4.0).
Definition at line 426 of file renderwindowinteractor.cpp. References interactionTime. Referenced by InitRenderWindowInteractor().
00426 { 00427 this->interactionTime = time; 00428 } |
|
Sets the function, which will be used, when the left mouse button is pressed. The function can be:
Definition at line 209 of file renderwindowinteractor.cpp. References DoNothing(). Referenced by InitRenderWindowInteractor().
00209 { 00210 if( function == NULL ) { 00211 strncpy( this->leftButtonFunction, SLOT(DoNothing()), 100 ); 00212 } 00213 else { 00214 strncpy( this->leftButtonFunction, function, 100 ); 00215 } 00216 } |
|
Sets the function, which will be used, when the middle mouse button is pressed. The function can be:
Definition at line 238 of file renderwindowinteractor.cpp. References DoNothing(). Referenced by InitRenderWindowInteractor().
00238 { 00239 if( function == NULL ) { 00240 strncpy( this->middleButtonFunction, SLOT(DoNothing()), 100 ); 00241 } 00242 else { 00243 strncpy( this->middleButtonFunction, function, 100 ); 00244 } 00245 } |
|
Sets the plane for the actor interaction ActorPlaneMove() and ActorPlaneRoll().
Definition at line 161 of file renderwindowinteractor.cpp. References ebenekonstante, and normale.
00161 { 00162 00163 this->normale[0] = ebene[0]; 00164 this->normale[1] = ebene[1]; 00165 this->normale[2] = ebene[2]; 00166 this->ebenekonstante = ebene[3]; 00167 00168 } |
|
Sets the function, which will be used, when the right mouse button is pressed. The function can be:
Definition at line 267 of file renderwindowinteractor.cpp. References DoNothing(). Referenced by InitRenderWindowInteractor().
00267 { 00268 if( function == NULL ) { 00269 strncpy( this->rightButtonFunction, SLOT(DoNothing()), 100 ); 00270 } 00271 else { 00272 strncpy( this->rightButtonFunction, function, 100 ); 00273 } 00274 } |
|
Sets the sensitivity of all interactions.
Definition at line 176 of file renderwindowinteractor.cpp. References trackballFactor. Referenced by InitRenderWindowInteractor().
00176 { 00177 this->trackballFactor = t; 00178 } |
|
Sets the function, which will be used, when the left button and the shift key are pressed. The function can be:
Definition at line 296 of file renderwindowinteractor.cpp. References DoNothing(). Referenced by InitRenderWindowInteractor().
00297 { 00298 if( function == NULL ) { 00299 strncpy( this->shiftLeftButtonFunction, SLOT(DoNothing()), 100 ); 00300 } 00301 else { 00302 strncpy( this->shiftLeftButtonFunction, function, 100 ); 00303 } 00304 } |
|
Computes the world point defined with x, y and z to display coordinates.
Definition at line 954 of file renderwindowinteractor.cpp. References RenderWindow::GetRenderer(). Referenced by ActorPlaneMove(), ActorTranslate(), and CameraTranslate().
00955 { 00956 this->GetRenderer()->SetWorldPoint(x, y, z, 1.0 ); 00957 this->GetRenderer()->WorldToDisplay(); 00958 this->GetRenderer()->GetDisplayPoint( displayPoint ); 00959 } |
Here is the call graph for this function:
|
Definition at line 124 of file renderwindowinteractor.h. |
|
Definition at line 114 of file renderwindowinteractor.h. |
|
Definition at line 102 of file renderwindowinteractor.h. |
|
Definition at line 106 of file renderwindowinteractor.h. Referenced by InitRenderWindowInteractor(). |
|
Definition at line 104 of file renderwindowinteractor.h. Referenced by ActorRoll(), ActorRotate(), ActorZoom(), CameraRoll(), CameraRotate(), CameraTranslate(), CameraZoom(), and InitRenderWindowInteractor(). |
|
Definition at line 107 of file renderwindowinteractor.h. Referenced by CameraRoll(), CameraRotate(), CameraTranslate(), and InitRenderWindowInteractor(). |
|
Definition at line 126 of file renderwindowinteractor.h. Referenced by ActorPlaneMove(), ActorPlaneRoll(), ActorRoll(), ActorRotate(), ActorTranslate(), ActorZoom(), CameraRoll(), CameraRotate(), CameraTranslate(), CameraZoom(), mouseMoveEvent(), and mousePressEvent(). |
|
Definition at line 116 of file renderwindowinteractor.h. Referenced by ActorRotate(), and CameraRotate(). |
|
Definition at line 115 of file renderwindowinteractor.h. Referenced by ActorRotate(), and CameraRotate(). |
|
Definition at line 118 of file renderwindowinteractor.h. Referenced by ActorPlaneMove(), and SetPlane(). |
|
Definition at line 122 of file renderwindowinteractor.h. Referenced by ActorPlaneRoll(), ActorRoll(), ActorRotate(), ActorZoom(), CameraRoll(), CameraRotate(), and mousePressEvent(). |
|
Definition at line 105 of file renderwindowinteractor.h. Referenced by ActorPlaneMove(), ActorPlaneRoll(), ActorRoll(), ActorRotate(), ActorTranslate(), ActorZoom(), GetInteractionActor(), InitRenderWindowInteractor(), SetActorRotation(), and SetInteractionActor(). |
|
Definition at line 125 of file renderwindowinteractor.h. Referenced by GetInteractionTime(), and SetInteractionTime(). |
|
Definition at line 127 of file renderwindowinteractor.h. Referenced by ActorPlaneMove(), ActorPlaneRoll(), ActorRoll(), ActorRotate(), ActorTranslate(), ActorZoom(), CameraRoll(), CameraRotate(), CameraTranslate(), CameraZoom(), and mousePressEvent(). |
|
Definition at line 129 of file renderwindowinteractor.h. |
|
Definition at line 130 of file renderwindowinteractor.h. |
|
Definition at line 121 of file renderwindowinteractor.h. Referenced by InitRenderWindowInteractor(), mousePressEvent(), and mouseReleaseEvent(). |
|
Definition at line 117 of file renderwindowinteractor.h. Referenced by ActorPlaneMove(), and SetPlane(). |
|
Definition at line 112 of file renderwindowinteractor.h. Referenced by ActorPlaneRoll(), ActorRoll(), and CameraRoll(). |
|
Definition at line 131 of file renderwindowinteractor.h. |
|
Definition at line 111 of file renderwindowinteractor.h. |
|
Definition at line 132 of file renderwindowinteractor.h. |
|
Definition at line 120 of file renderwindowinteractor.h. Referenced by InitRenderWindowInteractor(), mousePressEvent(), mouseReleaseEvent(), and ~RenderWindowInteractor(). |
|
Definition at line 123 of file renderwindowinteractor.h. Referenced by ActorPlaneRoll(), ActorRoll(), ActorRotate(), ActorZoom(), CameraRoll(), CameraRotate(), CameraTranslate(), CameraZoom(), GetSensitivity(), and SetSensitivity(). |
|
Definition at line 113 of file renderwindowinteractor.h. Referenced by CameraTranslate(). |
|
Definition at line 109 of file renderwindowinteractor.h. |
|
Definition at line 110 of file renderwindowinteractor.h. |