From 314c8c405ad095ad6f11019cb26233f383cf6928 Mon Sep 17 00:00:00 2001 From: nkv Date: Fri, 30 May 2008 06:53:24 +0000 Subject: [PATCH] View Parameters dialog - initial version --- src/SVTK/Makefile.am | 10 +- src/SVTK/SVTK_Event.h | 7 +- src/SVTK/SVTK_InteractorStyle.cxx | 416 ++++++----- src/SVTK/SVTK_InteractorStyle.h | 6 +- src/SVTK/SVTK_MainWindow.cxx | 54 ++ src/SVTK/SVTK_MainWindow.h | 11 +- src/SVTK/SVTK_ViewParameterDlg.cxx | 735 ++++++++++++++++++++ src/SVTK/SVTK_ViewParameterDlg.h | 153 ++++ src/SVTK/resources/SVTK_images.ts | 12 + src/SVTK/resources/SVTK_msg_en.ts | 107 +++ src/SVTK/resources/vtk_view_parallel.png | Bin 0 -> 878 bytes src/SVTK/resources/vtk_view_parameters.png | Bin 0 -> 706 bytes src/SVTK/resources/vtk_view_perspective.png | Bin 0 -> 831 bytes 13 files changed, 1284 insertions(+), 227 deletions(-) create mode 100755 src/SVTK/SVTK_ViewParameterDlg.cxx create mode 100755 src/SVTK/SVTK_ViewParameterDlg.h create mode 100755 src/SVTK/resources/vtk_view_parallel.png create mode 100755 src/SVTK/resources/vtk_view_parameters.png create mode 100755 src/SVTK/resources/vtk_view_perspective.png diff --git a/src/SVTK/Makefile.am b/src/SVTK/Makefile.am index 427443d5f..f652ecb8c 100755 --- a/src/SVTK/Makefile.am +++ b/src/SVTK/Makefile.am @@ -52,6 +52,7 @@ salomeinclude_HEADERS= \ SVTK_Event.h \ SVTK_ViewModelBase.h \ SVTK_SetRotationPointDlg.h \ + SVTK_ViewParameterDlg.h \ SVTK_Extension.h dist_libSVTK_la_SOURCES= \ @@ -79,6 +80,7 @@ dist_libSVTK_la_SOURCES= \ SVTK_SpaceMouse.cxx \ SVTK_Selector.cxx \ SVTK_SetRotationPointDlg.cxx \ + SVTK_ViewParameterDlg.cxx \ SVTK_Extension.cxx EXTRA_DIST+= SVTK_SelectorDef.h SVTK_Trihedron.h @@ -97,14 +99,18 @@ MOC_FILES= \ SVTK_MainWindow_moc.cxx \ SVTK_ViewModel_moc.cxx \ SVTK_View_moc.cxx \ - SVTK_SetRotationPointDlg_moc.cxx + SVTK_SetRotationPointDlg_moc.cxx \ + SVTK_ViewParameterDlg_moc.cxx nodist_libSVTK_la_SOURCES= $(MOC_FILES) dist_salomeres_DATA=\ resources/vtk_view_graduated_axes.png \ resources/vtk_view_scaling.png \ resources/vtk_view_update_rate.png \ - resources/vtk_view_rotation_point.png + resources/vtk_view_rotation_point.png \ + resources/vtk_view_parallel.png \ + resources/vtk_view_perspective.png \ + resources/vtk_view_parameters.png nodist_salomeres_DATA= \ SVTK_msg_en.qm \ diff --git a/src/SVTK/SVTK_Event.h b/src/SVTK/SVTK_Event.h index 00a9e2c0f..7006785de 100644 --- a/src/SVTK/SVTK_Event.h +++ b/src/SVTK/SVTK_Event.h @@ -62,12 +62,17 @@ namespace SVTK StartFitArea, SetRotateGravity, - StartPointSelection, SetRotateSelected, + StartPointSelection, BBCenterChanged, RotationPointChanged, ChangeRotationPoint, + + SetFocalPointGravity, + SetFocalPointSelected, + StartFocalPointSelection, + FocalPointChanged, LastEvent }; diff --git a/src/SVTK/SVTK_InteractorStyle.cxx b/src/SVTK/SVTK_InteractorStyle.cxx index 4145322cd..0f980090c 100644 --- a/src/SVTK/SVTK_InteractorStyle.cxx +++ b/src/SVTK/SVTK_InteractorStyle.cxx @@ -69,11 +69,9 @@ using namespace std; namespace { - inline - void - GetEventPosition(vtkRenderWindowInteractor* theInteractor, - int& theX, - int& theY) + inline void GetEventPosition(vtkRenderWindowInteractor* theInteractor, + int& theX, + int& theY) { theInteractor->GetEventPosition(theX,theY); theY = theInteractor->GetSize()[1] - theY - 1; @@ -87,15 +85,14 @@ vtkStandardNewMacro(SVTK_InteractorStyle); /*! Constructor */ -SVTK_InteractorStyle -::SVTK_InteractorStyle(): +SVTK_InteractorStyle::SVTK_InteractorStyle(): mySelectionEvent(new SVTK_SelectionEvent()), myPointPicker(vtkPointPicker::New()), myLastHighlitedActor(NULL), myLastPreHighlitedActor(NULL), myControllerIncrement(SVTK_ControllerIncrement::New()), myControllerOnKeyDown(SVTK_ControllerOnKeyDown::New()), - myHighlightRotationPointActor(SVTK_Actor::New()), + myHighlightSelectionPointActor(SVTK_Actor::New()), myRectBand(0) { myPointPicker->Delete(); @@ -123,14 +120,17 @@ SVTK_InteractorStyle myCurrRotationPointType = SVTK::SetRotateGravity; myPrevRotationPointType = myCurrRotationPointType; - myHighlightRotationPointActor->Delete(); - myHighlightRotationPointActor->Initialize(); - myHighlightRotationPointActor->PickableOff(); - myHighlightRotationPointActor->SetVisibility( false ); + myCurrFocalPointType = SVTK::SetFocalPointSelected; + myPrevFocalPointType = myCurrFocalPointType; + + myHighlightSelectionPointActor->Delete(); + myHighlightSelectionPointActor->Initialize(); + myHighlightSelectionPointActor->PickableOff(); + myHighlightSelectionPointActor->SetVisibility( false ); - myHighlightRotationPointActor->GetProperty()->SetPointSize(SALOME_POINT_SIZE+2); - myHighlightRotationPointActor->GetProperty()->SetLineWidth(SALOME_LINE_WIDTH+2); - myHighlightRotationPointActor->GetProperty()->SetRepresentationToPoints(); + myHighlightSelectionPointActor->GetProperty()->SetPointSize(SALOME_POINT_SIZE+2); + myHighlightSelectionPointActor->GetProperty()->SetLineWidth(SALOME_LINE_WIDTH+2); + myHighlightSelectionPointActor->GetProperty()->SetRepresentationToPoints(); myBBFirstCheck = true; } @@ -138,8 +138,7 @@ SVTK_InteractorStyle /*! Destructor */ -SVTK_InteractorStyle -::~SVTK_InteractorStyle() +SVTK_InteractorStyle::~SVTK_InteractorStyle() { endDrawRect(); } @@ -147,9 +146,7 @@ SVTK_InteractorStyle /*! \return widget for rendering */ -QWidget* -SVTK_InteractorStyle -::GetRenderWidget() +QWidget* SVTK_InteractorStyle::GetRenderWidget() { return myInteractor->GetRenderWidget(); } @@ -157,9 +154,7 @@ SVTK_InteractorStyle /*! \return selector */ -SVTK_Selector* -SVTK_InteractorStyle -::GetSelector() +SVTK_Selector* SVTK_InteractorStyle::GetSelector() { return myInteractor->GetSelector(); } @@ -167,9 +162,7 @@ SVTK_InteractorStyle /*! Generate special SVTK_SelectionEvent */ -SVTK_SelectionEvent* -SVTK_InteractorStyle -::GetSelectionEvent() +SVTK_SelectionEvent* SVTK_InteractorStyle::GetSelectionEvent() { mySelectionEvent->mySelectionMode = GetSelector()->SelectionMode(); @@ -187,9 +180,7 @@ SVTK_InteractorStyle /*! Generate special SVTK_SelectionEvent with flipped Y coordinate */ -SVTK_SelectionEvent* -SVTK_InteractorStyle -::GetSelectionEventFlipY() +SVTK_SelectionEvent* SVTK_InteractorStyle::GetSelectionEventFlipY() { mySelectionEvent->mySelectionMode = GetSelector()->SelectionMode(); @@ -204,9 +195,7 @@ SVTK_InteractorStyle return mySelectionEvent.get(); } -void -SVTK_InteractorStyle -::RotateXY(int dx, int dy) +void SVTK_InteractorStyle::RotateXY(int dx, int dy) { /* if(GetCurrentRenderer() == NULL) return; @@ -283,18 +272,13 @@ SVTK_InteractorStyle this->Render(); } -void -SVTK_InteractorStyle -::PanXY(int x, int y, int oldX, int oldY) +void SVTK_InteractorStyle::PanXY(int x, int y, int oldX, int oldY) { TranslateView(x, y, oldX, oldY); this->Render(); } - -void -SVTK_InteractorStyle -::DollyXY(int dx, int dy) +void SVTK_InteractorStyle::DollyXY(int dx, int dy) { if (GetCurrentRenderer() == NULL) return; @@ -308,16 +292,14 @@ SVTK_InteractorStyle if (aCam->GetParallelProjection()) aCam->SetParallelScale(aCam->GetParallelScale()/zoomFactor); else{ - aCam->Dolly(zoomFactor); + aCam->Dolly(zoomFactor); // Move camera in/out along projection direction GetCurrentRenderer()->ResetCameraClippingRange(); } this->Render(); } -void -SVTK_InteractorStyle -::SpinXY(int x, int y, int oldX, int oldY) +void SVTK_InteractorStyle::SpinXY(int x, int y, int oldX, int oldY) { vtkCamera *cam; @@ -343,9 +325,7 @@ SVTK_InteractorStyle /*! To reset reset view */ -void -SVTK_InteractorStyle -::OnConfigure() +void SVTK_InteractorStyle::OnConfigure() { this->FindPokedRenderer(0,0); this->GetCurrentRenderer()->InvokeEvent(vtkCommand::ConfigureEvent,NULL); @@ -354,9 +334,7 @@ SVTK_InteractorStyle /*! To handle mouse move event */ -void -SVTK_InteractorStyle -::OnMouseMove() +void SVTK_InteractorStyle::OnMouseMove() { int x, y; GetEventPosition( this->Interactor, x, y ); @@ -368,9 +346,7 @@ SVTK_InteractorStyle /*! To handle left mouse button down event (reimplemented from vtkInteractorStyle) */ -void -SVTK_InteractorStyle -::OnLeftButtonDown() +void SVTK_InteractorStyle::OnLeftButtonDown() { int x, y; GetEventPosition( this->Interactor, x, y ); @@ -382,9 +358,7 @@ SVTK_InteractorStyle /*! To handle left mouse button up event (reimplemented from vtkInteractorStyle) */ -void -SVTK_InteractorStyle -::OnLeftButtonUp() +void SVTK_InteractorStyle::OnLeftButtonUp() { int x, y; GetEventPosition( this->Interactor, x, y ); @@ -396,9 +370,7 @@ SVTK_InteractorStyle /*! To handle middle mouse button down event (reimplemented from vtkInteractorStyle) */ -void -SVTK_InteractorStyle -::OnMiddleButtonDown() +void SVTK_InteractorStyle::OnMiddleButtonDown() { int x, y; GetEventPosition( this->Interactor, x, y ); @@ -410,9 +382,7 @@ SVTK_InteractorStyle /*! To handle middle mouse button up event (reimplemented from vtkInteractorStyle) */ -void -SVTK_InteractorStyle -::OnMiddleButtonUp() +void SVTK_InteractorStyle::OnMiddleButtonUp() { int x, y; GetEventPosition( this->Interactor, x, y ); @@ -424,9 +394,7 @@ SVTK_InteractorStyle /*! To handle right mouse button down event (reimplemented from vtkInteractorStyle) */ -void -SVTK_InteractorStyle -::OnRightButtonDown() +void SVTK_InteractorStyle::OnRightButtonDown() { int x, y; GetEventPosition( this->Interactor, x, y ); @@ -438,9 +406,7 @@ SVTK_InteractorStyle /*! To handle right mouse button up event (reimplemented from vtkInteractorStyle) */ -void -SVTK_InteractorStyle -::OnRightButtonUp() +void SVTK_InteractorStyle::OnRightButtonUp() { int x, y; GetEventPosition( this->Interactor, x, y ); @@ -452,11 +418,9 @@ SVTK_InteractorStyle /*! To handle mouse move event */ -void -SVTK_InteractorStyle -::OnMouseMove(int vtkNotUsed(ctrl), - int shift, - int x, int y) +void SVTK_InteractorStyle::OnMouseMove(int vtkNotUsed(ctrl), + int shift, + int x, int y) { myShiftState = shift; if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) @@ -468,10 +432,8 @@ SVTK_InteractorStyle /*! To handle left mouse button down event (reimplemented from vtkInteractorStyle) */ -void -SVTK_InteractorStyle -::OnLeftButtonDown(int ctrl, int shift, - int x, int y) +void SVTK_InteractorStyle::OnLeftButtonDown(int ctrl, int shift, + int x, int y) { this->FindPokedRenderer(x, y); if(GetCurrentRenderer() == NULL) @@ -489,7 +451,8 @@ SVTK_InteractorStyle } else { if (ctrl) startOperation(VTK_INTERACTOR_STYLE_CAMERA_ZOOM); - else if ( myCurrRotationPointType == SVTK::StartPointSelection ) + else if ( myCurrRotationPointType == SVTK::StartPointSelection || + myCurrFocalPointType == SVTK::StartFocalPointSelection ) { SVTK_SelectionEvent* aSelectionEvent = GetSelectionEventFlipY(); @@ -507,28 +470,50 @@ SVTK_InteractorStyle int anObjId = anActor->GetNodeObjId( aVtkId ); vtkFloatingPointType* aCoords = anActor->GetNodeCoord(anObjId); - myCurrRotationPointType = SVTK::SetRotateSelected; + if (myCurrRotationPointType == SVTK::StartPointSelection) { + myCurrRotationPointType = SVTK::SetRotateSelected; - // invoke event for update coordinates in SVTK_SetRotationPointDlg - InvokeEvent(SVTK::RotationPointChanged,(void*)aCoords); + // invoke event for update coordinates in SVTK_SetRotationPointDlg + InvokeEvent(SVTK::RotationPointChanged,(void*)aCoords); + } + else if (myCurrFocalPointType == SVTK::StartFocalPointSelection) { + myCurrFocalPointType = SVTK::SetFocalPointSelected; + + // invoke event for update coordinates in SVTK_ViewParameterDlg + InvokeEvent(SVTK::FocalPointChanged,(void*)aCoords); + } } else { - // invoke event with no data (for SVTK_SetRotationPointDlg) - InvokeEvent(SVTK::RotationPointChanged,0); - myCurrRotationPointType = myPrevRotationPointType; + if (myCurrRotationPointType == SVTK::StartPointSelection) { + // invoke event with no data (for SVTK_SetRotationPointDlg) + InvokeEvent(SVTK::RotationPointChanged,0); + myCurrRotationPointType = myPrevRotationPointType; + } + else if (myCurrFocalPointType == SVTK::StartFocalPointSelection) { + // invoke event with no data (for SVTK_ViewParameterDlg) + InvokeEvent(SVTK::FocalPointChanged,0); + myCurrFocalPointType = myPrevFocalPointType; + } } } else { - // invoke event with no data (for SVTK_SetRotationPointDlg) - InvokeEvent(SVTK::RotationPointChanged,0); - myCurrRotationPointType = myPrevRotationPointType; + if (myCurrRotationPointType == SVTK::StartPointSelection) { + // invoke event with no data (for SVTK_SetRotationPointDlg) + InvokeEvent(SVTK::RotationPointChanged,0); + myCurrRotationPointType = myPrevRotationPointType; + } + else if (myCurrFocalPointType == SVTK::StartFocalPointSelection) { + // invoke event with no data (for SVTK_ViewParameterDlg) + InvokeEvent(SVTK::FocalPointChanged,0); + myCurrFocalPointType = myPrevFocalPointType; + } } - myHighlightRotationPointActor->SetVisibility( false ); + myHighlightSelectionPointActor->SetVisibility( false ); if(GetCurrentRenderer() != NULL) - GetCurrentRenderer()->RemoveActor( myHighlightRotationPointActor.GetPointer() ); + GetCurrentRenderer()->RemoveActor( myHighlightSelectionPointActor.GetPointer() ); GetRenderWidget()->setCursor(myDefCursor); } @@ -542,12 +527,10 @@ SVTK_InteractorStyle /*! To handle left mouse button up event (reimplemented from vtkInteractorStyle) */ -void -SVTK_InteractorStyle -::OnLeftButtonUp(int vtkNotUsed(ctrl), - int shift, - int vtkNotUsed(x), - int vtkNotUsed(y)) +void SVTK_InteractorStyle::OnLeftButtonUp(int vtkNotUsed(ctrl), + int shift, + int vtkNotUsed(x), + int vtkNotUsed(y)) { myShiftState = shift; // finishing current viewer operation @@ -560,11 +543,9 @@ SVTK_InteractorStyle /*! To handle middle mouse button down event (reimplemented from vtkInteractorStyle) */ -void -SVTK_InteractorStyle -::OnMiddleButtonDown(int ctrl, - int shift, - int x, int y) +void SVTK_InteractorStyle::OnMiddleButtonDown(int ctrl, + int shift, + int x, int y) { this->FindPokedRenderer(x, y); if(GetCurrentRenderer() == NULL) @@ -590,12 +571,10 @@ SVTK_InteractorStyle /*! To handle middle mouse button up event (reimplemented from vtkInteractorStyle) */ -void -SVTK_InteractorStyle -::OnMiddleButtonUp(int vtkNotUsed(ctrl), - int shift, - int vtkNotUsed(x), - int vtkNotUsed(y)) +void SVTK_InteractorStyle::OnMiddleButtonUp(int vtkNotUsed(ctrl), + int shift, + int vtkNotUsed(x), + int vtkNotUsed(y)) { myShiftState = shift; // finishing current viewer operation @@ -609,11 +588,9 @@ SVTK_InteractorStyle /*! To handle right mouse button down event (reimplemented from vtkInteractorStyle) */ -void -SVTK_InteractorStyle -::OnRightButtonDown(int ctrl, - int shift, - int x, int y) +void SVTK_InteractorStyle::OnRightButtonDown(int ctrl, + int shift, + int x, int y) { this->FindPokedRenderer(x, y); if(GetCurrentRenderer() == NULL) @@ -638,12 +615,10 @@ SVTK_InteractorStyle /*! To handle right mouse button up event (reimplemented from vtkInteractorStyle) */ -void -SVTK_InteractorStyle -::OnRightButtonUp(int vtkNotUsed(ctrl), - int shift, - int vtkNotUsed(x), - int vtkNotUsed(y)) +void SVTK_InteractorStyle::OnRightButtonUp(int vtkNotUsed(ctrl), + int shift, + int vtkNotUsed(x), + int vtkNotUsed(y)) { myShiftState = shift; // finishing current viewer operation @@ -734,9 +709,7 @@ const char* imageRotateCursor[] = { /*! loads cursors for viewer operations - zoom, pan, etc... */ -void -SVTK_InteractorStyle -::loadCursors() +void SVTK_InteractorStyle::loadCursors() { myDefCursor = QCursor(Qt::ArrowCursor); myHandCursor = QCursor(Qt::PointingHandCursor); @@ -752,9 +725,7 @@ SVTK_InteractorStyle /*! Starts Zoom operation (e.g. through menu command) */ -void -SVTK_InteractorStyle -::startZoom() +void SVTK_InteractorStyle::startZoom() { if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) { @@ -769,9 +740,7 @@ SVTK_InteractorStyle /*! Starts Pan operation (e.g. through menu command) */ -void -SVTK_InteractorStyle -::startPan() +void SVTK_InteractorStyle::startPan() { if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) { @@ -785,9 +754,7 @@ SVTK_InteractorStyle /*! Starts Rotate operation (e.g. through menu command) */ -void -SVTK_InteractorStyle -::startRotate() +void SVTK_InteractorStyle::startRotate() { if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) { @@ -801,19 +768,36 @@ SVTK_InteractorStyle /*! Set rotation point selected by user */ -void -SVTK_InteractorStyle -::startPointSelection() +void SVTK_InteractorStyle::startPointSelection() { myCurrRotationPointType = SVTK::StartPointSelection; if(GetCurrentRenderer() != NULL) { - GetCurrentRenderer()->AddActor( myHighlightRotationPointActor.GetPointer() ); + GetCurrentRenderer()->AddActor( myHighlightSelectionPointActor.GetPointer() ); vtkFloatingPointType aColor[3]; GetCurrentRenderer()->GetBackground( aColor ); - myHighlightRotationPointActor->GetProperty()->SetColor(1. - aColor[0], - 1. - aColor[1], - 1. - aColor[2]); + myHighlightSelectionPointActor->GetProperty()->SetColor(1. - aColor[0], + 1. - aColor[1], + 1. - aColor[2]); + } + + setCursor(VTK_INTERACTOR_STYLE_CAMERA_NONE); +} + +/*! + Set focal point selected by user +*/ +void SVTK_InteractorStyle::startFocalPointSelection() +{ + myCurrFocalPointType = SVTK::StartFocalPointSelection; + + if(GetCurrentRenderer() != NULL) { + GetCurrentRenderer()->AddActor( myHighlightSelectionPointActor.GetPointer() ); + vtkFloatingPointType aColor[3]; + GetCurrentRenderer()->GetBackground( aColor ); + myHighlightSelectionPointActor->GetProperty()->SetColor(1. - aColor[0], + 1. - aColor[1], + 1. - aColor[2]); } setCursor(VTK_INTERACTOR_STYLE_CAMERA_NONE); @@ -822,9 +806,7 @@ SVTK_InteractorStyle /*! Starts Spin operation (e.g. through menu command) */ -void -SVTK_InteractorStyle -::startSpin() +void SVTK_InteractorStyle::startSpin() { if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) { @@ -840,9 +822,7 @@ SVTK_InteractorStyle /*! Starts Fit Area operation (e.g. through menu command) */ -void -SVTK_InteractorStyle -::startFitArea() +void SVTK_InteractorStyle::startFitArea() { if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) { @@ -857,9 +837,7 @@ SVTK_InteractorStyle /*! Starts Global Panning operation (e.g. through menu command) */ -void -SVTK_InteractorStyle -::startGlobalPan() +void SVTK_InteractorStyle::startGlobalPan() { if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) { @@ -881,12 +859,10 @@ SVTK_InteractorStyle /*! Fits viewer contents to rect */ -void -SVTK_InteractorStyle -::fitRect(const int left, - const int top, - const int right, - const int bottom) +void SVTK_InteractorStyle::fitRect(const int left, + const int top, + const int right, + const int bottom) { if (GetCurrentRenderer() == NULL) return; @@ -919,9 +895,7 @@ SVTK_InteractorStyle /*! Starts viewer operation (!internal usage!) */ -void -SVTK_InteractorStyle -::startOperation(int operation) +void SVTK_InteractorStyle::startOperation(int operation) { switch(operation) { @@ -951,9 +925,7 @@ SVTK_InteractorStyle /*! Sets proper cursor for window when viewer operation is activated */ -void -SVTK_InteractorStyle -::setCursor(const int operation) +void SVTK_InteractorStyle::setCursor(const int operation) { if (!GetRenderWidget()) return; switch (operation) @@ -985,7 +957,8 @@ SVTK_InteractorStyle break; case VTK_INTERACTOR_STYLE_CAMERA_NONE: default: - if ( myCurrRotationPointType == SVTK::StartPointSelection ) + if ( myCurrRotationPointType == SVTK::StartPointSelection || + myCurrFocalPointType == SVTK::StartFocalPointSelection ) GetRenderWidget()->setCursor(myHandCursor); else GetRenderWidget()->setCursor(myDefCursor); @@ -998,9 +971,7 @@ SVTK_InteractorStyle /*! Called when viewer operation started (!put necessary initialization here!) */ -void -SVTK_InteractorStyle -::onStartOperation() +void SVTK_InteractorStyle::onStartOperation() { if (!GetRenderWidget()) return; @@ -1029,9 +1000,7 @@ SVTK_InteractorStyle /*! Called when viewer operation finished (!put necessary post-processing here!) */ -void -SVTK_InteractorStyle -::onFinishOperation() +void SVTK_InteractorStyle::onFinishOperation() { if (!GetRenderWidget()) return; @@ -1137,9 +1106,7 @@ SVTK_InteractorStyle /*! Called during viewer operation when user moves mouse (!put necessary processing here!) */ -void -SVTK_InteractorStyle -::onOperation(QPoint mousePos) +void SVTK_InteractorStyle::onOperation(QPoint mousePos) { if (!GetRenderWidget()) return; @@ -1191,9 +1158,7 @@ SVTK_InteractorStyle Called when user moves mouse inside viewer window and there is no active viewer operation (!put necessary processing here!) */ -void -SVTK_InteractorStyle -::onCursorMove(QPoint mousePos) +void SVTK_InteractorStyle::onCursorMove(QPoint mousePos) { // processing highlighting SVTK_SelectionEvent* aSelectionEvent = GetSelectionEventFlipY(); @@ -1203,9 +1168,10 @@ SVTK_InteractorStyle SALOME_Actor *anActor = GetSelector()->Pick(aSelectionEvent, GetCurrentRenderer()); - if ( myCurrRotationPointType == SVTK::StartPointSelection ) + if ( myCurrRotationPointType == SVTK::StartPointSelection || + myCurrFocalPointType == SVTK::StartFocalPointSelection ) { - myHighlightRotationPointActor->SetVisibility( false ); + myHighlightSelectionPointActor->SetVisibility( false ); if ( anActor ) { @@ -1216,9 +1182,9 @@ SVTK_InteractorStyle TColStd_IndexedMapOfInteger aMapIndex; aMapIndex.Add( anObjId ); - myHighlightRotationPointActor->MapPoints( anActor, aMapIndex ); + myHighlightSelectionPointActor->MapPoints( anActor, aMapIndex ); - myHighlightRotationPointActor->SetVisibility( true ); + myHighlightSelectionPointActor->SetVisibility( true ); anIsChanged = true; } } @@ -1242,9 +1208,7 @@ SVTK_InteractorStyle /*! Called on finsh GlobalPan operation */ -void -SVTK_InteractorStyle -::Place(const int theX, const int theY) +void SVTK_InteractorStyle::Place(const int theX, const int theY) { if (GetCurrentRenderer() == NULL) return; @@ -1269,9 +1233,7 @@ SVTK_InteractorStyle /*! Translates view from Point to Point */ -void -SVTK_InteractorStyle -::TranslateView(int toX, int toY, int fromX, int fromY) +void SVTK_InteractorStyle::TranslateView(int toX, int toY, int fromX, int fromY) { vtkCamera *cam = GetCurrentRenderer()->GetActiveCamera(); double viewFocus[4], focalDepth, viewPoint[3]; @@ -1302,23 +1264,17 @@ SVTK_InteractorStyle motionVector[2] + viewPoint[2]); } -void -SVTK_InteractorStyle -::IncrementalPan( const int incrX, const int incrY ) +void SVTK_InteractorStyle::IncrementalPan( const int incrX, const int incrY ) { this->PanXY( incrX, incrY, 0, 0 ); } -void -SVTK_InteractorStyle -::IncrementalZoom( const int incr ) +void SVTK_InteractorStyle::IncrementalZoom( const int incr ) { this->DollyXY( incr, incr ); } -void -SVTK_InteractorStyle -::IncrementalRotate( const int incrX, const int incrY ) +void SVTK_InteractorStyle::IncrementalRotate( const int incrX, const int incrY ) { this->RotateXY( incrX, -incrY ); } @@ -1326,9 +1282,7 @@ SVTK_InteractorStyle /*! Redefined in order to add an observer (callback) for custorm event (space mouse event) */ -void -SVTK_InteractorStyle -::SetInteractor( vtkRenderWindowInteractor* theInteractor ) +void SVTK_InteractorStyle::SetInteractor( vtkRenderWindowInteractor* theInteractor ) { // register EventCallbackCommand as observer of standard events (keypress, mousemove, etc) Superclass::SetInteractor( theInteractor ); @@ -1367,15 +1321,17 @@ SVTK_InteractorStyle theInteractor->AddObserver( SVTK::StartPointSelection, EventCallbackCommand, Priority ); theInteractor->AddObserver( SVTK::ChangeRotationPoint, EventCallbackCommand, Priority ); + + theInteractor->AddObserver( SVTK::SetFocalPointGravity, EventCallbackCommand, Priority ); + theInteractor->AddObserver( SVTK::StartFocalPointSelection, EventCallbackCommand, Priority ); + theInteractor->AddObserver( SVTK::SetFocalPointSelected, EventCallbackCommand, Priority ); } } /*! To implement cached rendering */ -void -SVTK_InteractorStyle -::OnTimer() +void SVTK_InteractorStyle::OnTimer() { //vtkInteractorStyle::OnTimer(); this->Interactor->Render(); @@ -1408,16 +1364,12 @@ SVTK_InteractorStyle /*! To invoke #vtkRenderWindowInteractor::CreateTimer */ -void -SVTK_InteractorStyle -::Render() +void SVTK_InteractorStyle::Render() { this->Interactor->CreateTimer(VTKI_TIMER_FIRST); } -void -SVTK_InteractorStyle -::onSpaceMouseMove( double* data ) +void SVTK_InteractorStyle::onSpaceMouseMove( double* data ) { // general things, do SetCurrentRenderer() within FindPokedRenderer() int x, y; @@ -1430,9 +1382,7 @@ SVTK_InteractorStyle IncrementalRotate( (int)data[3], 0 ); // 5. tilt the control forward/backward = rotate around X axis (Z axis of local coordinate system of space mouse) } -void -SVTK_InteractorStyle -::onSpaceMouseButton( int button ) +void SVTK_InteractorStyle::onSpaceMouseButton( int button ) { if( mySMDecreaseSpeedBtn == button ) { ControllerIncrement()->Decrease(); @@ -1444,9 +1394,7 @@ SVTK_InteractorStyle DominantCombinedSwitch(); } -void -SVTK_InteractorStyle -::DominantCombinedSwitch() +void SVTK_InteractorStyle::DominantCombinedSwitch() { printf( "\n--DominantCombinedSwitch() NOT IMPLEMENTED--\n" ); } @@ -1454,9 +1402,7 @@ SVTK_InteractorStyle /*! Draws rectangle by starting and current points */ -void -SVTK_InteractorStyle -::drawRect() +void SVTK_InteractorStyle::drawRect() { if ( !myRectBand ) { myRectBand = new QRubberBand( QRubberBand::Rectangle, GetRenderWidget() ); @@ -1474,9 +1420,7 @@ SVTK_InteractorStyle /*! \brief Delete rubber band on the end on the dragging operation. */ -void -SVTK_InteractorStyle -::endDrawRect() +void SVTK_InteractorStyle::endDrawRect() { if ( myRectBand ) myRectBand->hide(); @@ -1487,12 +1431,10 @@ SVTK_InteractorStyle /*! Main process event method (reimplemented from #vtkInteractorStyle) */ -void -SVTK_InteractorStyle -::ProcessEvents( vtkObject* object, - unsigned long event, - void* clientData, - void* callData ) +void SVTK_InteractorStyle::ProcessEvents( vtkObject* object, + unsigned long event, + void* clientData, + void* callData ) { if ( clientData ) { vtkObject* anObject = reinterpret_cast( clientData ); @@ -1577,9 +1519,9 @@ SVTK_InteractorStyle case SVTK::SetRotateGravity: if ( self->myCurrRotationPointType == SVTK::StartPointSelection ) { - self->myHighlightRotationPointActor->SetVisibility( false ); + self->myHighlightSelectionPointActor->SetVisibility( false ); if( self->GetCurrentRenderer() != NULL ) - self->GetCurrentRenderer()->RemoveActor( self->myHighlightRotationPointActor.GetPointer() ); + self->GetCurrentRenderer()->RemoveActor( self->myHighlightSelectionPointActor.GetPointer() ); self->GetRenderWidget()->setCursor(self->myDefCursor); } self->myPrevRotationPointType = self->myCurrRotationPointType; @@ -1595,9 +1537,9 @@ SVTK_InteractorStyle case SVTK::ChangeRotationPoint: if ( self->myCurrRotationPointType == SVTK::StartPointSelection ) { - self->myHighlightRotationPointActor->SetVisibility( false ); + self->myHighlightSelectionPointActor->SetVisibility( false ); if( self->GetCurrentRenderer() != NULL ) - self->GetCurrentRenderer()->RemoveActor( self->myHighlightRotationPointActor.GetPointer() ); + self->GetCurrentRenderer()->RemoveActor( self->myHighlightSelectionPointActor.GetPointer() ); self->GetRenderWidget()->setCursor(self->myDefCursor); } self->myPrevRotationPointType = self->myCurrRotationPointType; @@ -1607,6 +1549,36 @@ SVTK_InteractorStyle self->myRotationPointY = aSelectedPoint[1]; self->myRotationPointZ = aSelectedPoint[2]; return; + + case SVTK::SetFocalPointGravity: + if ( self->myCurrFocalPointType == SVTK::StartPointSelection ) + { + self->myHighlightSelectionPointActor->SetVisibility( false ); + if( self->GetCurrentRenderer() != NULL ) + self->GetCurrentRenderer()->RemoveActor( self->myHighlightSelectionPointActor.GetPointer() ); + self->GetRenderWidget()->setCursor(self->myDefCursor); + } + self->myCurrFocalPointType = SVTK::SetFocalPointGravity; + if ( ComputeBBCenter(self->GetCurrentRenderer(),aCenter) ) { + // invoke event for update coordinates in SVTK_ViewParameterDlg + self->InvokeEvent(SVTK::BBCenterChanged,(void*)aCenter); + } + return; + case SVTK::StartFocalPointSelection: + self->startFocalPointSelection(); + return; + + case SVTK::SetFocalPointSelected: + if ( self->myCurrFocalPointType == SVTK::StartFocalPointSelection ) + { + self->myHighlightSelectionPointActor->SetVisibility( false ); + if( self->GetCurrentRenderer() != NULL ) + self->GetCurrentRenderer()->RemoveActor( self->myHighlightSelectionPointActor.GetPointer() ); + self->GetRenderWidget()->setCursor(self->myDefCursor); + } + self->myPrevFocalPointType = self->myCurrFocalPointType; + self->myCurrFocalPointType = SVTK::SetFocalPointSelected; + return; } } } diff --git a/src/SVTK/SVTK_InteractorStyle.h b/src/SVTK/SVTK_InteractorStyle.h index b02941bfb..c1985352d 100644 --- a/src/SVTK/SVTK_InteractorStyle.h +++ b/src/SVTK/SVTK_InteractorStyle.h @@ -283,6 +283,7 @@ class SVTK_EXPORT SVTK_InteractorStyle: public vtkInteractorStyle void startSpin(); void startPointSelection(); + void startFocalPointSelection(); protected: void loadCursors(); @@ -336,11 +337,14 @@ class SVTK_EXPORT SVTK_InteractorStyle: public vtkInteractorStyle unsigned long myCurrRotationPointType; unsigned long myPrevRotationPointType; + unsigned long myCurrFocalPointType; + unsigned long myPrevFocalPointType; + double myRotationPointX; double myRotationPointY; double myRotationPointZ; - vtkSmartPointer myHighlightRotationPointActor; + vtkSmartPointer myHighlightSelectionPointActor; vtkSmartPointer myPointPicker; vtkFloatingPointType myBBCenter[3]; diff --git a/src/SVTK/SVTK_MainWindow.cxx b/src/SVTK/SVTK_MainWindow.cxx index edfeb787a..f8a026ec2 100644 --- a/src/SVTK/SVTK_MainWindow.cxx +++ b/src/SVTK/SVTK_MainWindow.cxx @@ -48,6 +48,7 @@ #include "SVTK_UpdateRateDlg.h" #include "SVTK_CubeAxesDlg.h" #include "SVTK_SetRotationPointDlg.h" +#include "SVTK_ViewParameterDlg.h" #include "SVTK_MainWindow.h" #include "SVTK_Event.h" #include "SVTK_Renderer.h" @@ -97,6 +98,8 @@ SVTK_MainWindow myCubeAxesDlg = new SVTK_CubeAxesDlg( action( GraduatedAxes ), this, "SVTK_CubeAxesDlg" ); mySetRotationPointDlg = new SVTK_SetRotationPointDlg ( action( ChangeRotationPointId ), this, "SVTK_SetRotationPointDlg" ); + myViewParameterDlg = new SVTK_ViewParameterDlg + ( action( ViewParametersId ), this, "SVTK_ViewParameterDlg" ); } /*! @@ -538,6 +541,15 @@ SVTK_MainWindow connect(anAction, SIGNAL(activated()), this, SLOT(onRightView())); mgr->registerAction( anAction, RightId ); + // View Parameters + anAction = new QtxAction(tr("MNU_VIEWPARAMETERS_VIEW"), + theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PARAMETERS" ) ), + tr( "MNU_VIEWPARAMETERS_VIEW" ), 0, this); + anAction->setStatusTip(tr("DSC_VIEWPARAMETERS_VIEW")); + anAction->setCheckable(true); + connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onViewParameters(bool))); + mgr->registerAction( anAction, ViewParametersId ); + // Reset anAction = new QtxAction(tr("MNU_RESET_VIEW"), theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RESET" ) ), @@ -624,6 +636,8 @@ SVTK_MainWindow mgr->append( ResetId, myToolBar ); + mgr->append( ViewParametersId, myToolBar ); + mgr->append( UpdateRate, myToolBar ); mgr->append( NonIsometric, myToolBar ); mgr->append( GraduatedAxes, myToolBar ); @@ -725,6 +739,46 @@ SVTK_MainWindow myEventDispatcher->InvokeEvent(SVTK::StartPointSelection,0); } +/*! + Modify view parameters +*/ +void +SVTK_MainWindow +::onViewParameters(bool theIsActivate) +{ + if(theIsActivate){ + myViewParameterDlg->addObserver(); + myViewParameterDlg->show(); + }else + myViewParameterDlg->hide(); +} + +/*! + Set the gravity center as a focal point +*/ +void SVTK_MainWindow::activateSetFocalPointGravity() +{ + myEventDispatcher->InvokeEvent(SVTK::SetFocalPointGravity, 0); +} + +/*! + Set the selected point as a focal point +*/ +void SVTK_MainWindow::activateSetFocalPointSelected() +{ + myEventDispatcher->InvokeEvent(SVTK::SetFocalPointSelected, 0); +} + +/*! + Set the point selected by user as a focal point +*/ +void +SVTK_MainWindow +::activateStartFocalPointSelection() +{ + myEventDispatcher->InvokeEvent(SVTK::StartFocalPointSelection,0); +} + /*! Starts global panning transformation */ diff --git a/src/SVTK/SVTK_MainWindow.h b/src/SVTK/SVTK_MainWindow.h index 510266f73..7bdba4a78 100644 --- a/src/SVTK/SVTK_MainWindow.h +++ b/src/SVTK/SVTK_MainWindow.h @@ -48,6 +48,7 @@ class SVTK_UpdateRateDlg; class SVTK_CubeAxesActor2D; class SVTK_CubeAxesDlg; class SVTK_SetRotationPointDlg; +class SVTK_ViewParameterDlg; class SVTK_Renderer; class SVTK_Selector; @@ -222,6 +223,12 @@ public: void onResetView(); void onFitAll(); + void onViewParameters(bool theIsActivate); + + void activateSetFocalPointGravity(); + void activateSetFocalPointSelected(); + void activateStartFocalPointSelection(); + void onViewTrihedron(); void onViewCubeAxes(); @@ -252,7 +259,8 @@ public: enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, ChangeRotationPointId, RotationId, FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, - ViewTrihedronId, NonIsometric, GraduatedAxes, UpdateRate}; + ViewTrihedronId, NonIsometric, GraduatedAxes, UpdateRate, + ViewParametersId }; SUIT_ViewWindow* myViewWindow; @@ -260,6 +268,7 @@ public: SVTK_UpdateRateDlg* myUpdateRateDlg; SVTK_CubeAxesDlg* myCubeAxesDlg; SVTK_SetRotationPointDlg* mySetRotationPointDlg; + SVTK_ViewParameterDlg* myViewParameterDlg; vtkSmartPointer myEventDispatcher; int myToolBar; diff --git a/src/SVTK/SVTK_ViewParameterDlg.cxx b/src/SVTK/SVTK_ViewParameterDlg.cxx new file mode 100755 index 000000000..057c1ae90 --- /dev/null +++ b/src/SVTK/SVTK_ViewParameterDlg.cxx @@ -0,0 +1,735 @@ +// SALOME VTKViewer : build VTK viewer into Salome desktop +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : +// Author : +// Module : SALOME +// $Header: + +#include "SVTK_ViewParameterDlg.h" +#include "SVTK_MainWindow.h" +#include "SVTK_RenderWindowInteractor.h" +#include "SVTK_Event.h" +#include "SVTK_InteractorStyle.h" + +#include "VTKViewer_Utilities.h" + +#include "QtxAction.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +using namespace std; + +/*! + Constructor +*/ +SVTK_ViewParameterDlg::SVTK_ViewParameterDlg(QtxAction* theAction, + SVTK_MainWindow* theParent, + const char* theName): + SVTK_DialogBase(theAction, theParent, theName), + myMainWindow(theParent), + myPriority(0.0), + myEventCallbackCommand(vtkCallbackCommand::New()), + myRWInteractor(theParent->GetInteractor()) +{ + setWindowTitle(tr("DLG_TITLE")); + setSizeGripEnabled(TRUE); + + // Top layout + QVBoxLayout* aTopLayout = new QVBoxLayout(this); + aTopLayout->setSpacing(6); + aTopLayout->setMargin(11); + + // Projection mode + QGroupBox* aGroupBoxMode = new QGroupBox(tr("PROJECTION_MODE"), this); + QHBoxLayout* aLayout1 = new QHBoxLayout(aGroupBoxMode); + + QRadioButton* aOrtho = new QRadioButton(tr("ORTHOGONAL_MODE"), aGroupBoxMode); + QRadioButton* aPersp = new QRadioButton(tr("PERSPECTIVE_MODE"), aGroupBoxMode); + + aLayout1->addWidget(aOrtho); + aLayout1->addWidget(aPersp); + + myProjectionMode = new QButtonGroup(aGroupBoxMode); + myProjectionMode->addButton(aOrtho, 0); + myProjectionMode->addButton(aPersp, 1); + connect(myProjectionMode, SIGNAL(buttonClicked(int)), SLOT(onProjectionModeChanged(int))); + + // Focal point + QGroupBox* aGroupBoxFocal = new QGroupBox(tr("FOCAL_POINT"), this); + QVBoxLayout* aLayout2 = new QVBoxLayout(aGroupBoxFocal); + + /* + myIsBBCenter = new QCheckBox(tr("USE_BBCENTER"), aGroupBoxFocal); + aLayout2->addWidget(myIsBBCenter); + connect(myIsBBCenter, SIGNAL(stateChanged(int)), SLOT(onBBCenterChecked())); + */ + + myToBBCenter = new QPushButton(aGroupBoxFocal); + myToBBCenter->setText(tr("LBL_TOBBCENTER")); + aLayout2->addWidget(myToBBCenter); + connect(myToBBCenter, SIGNAL(clicked()), this, SLOT(onToBBCenter())); + + myToOrigin = new QPushButton(aGroupBoxFocal); + myToOrigin->setText(tr("LBL_TOORIGIN")); + aLayout2->addWidget(myToOrigin); + connect(myToOrigin, SIGNAL(clicked()), this, SLOT(onToOrigin())); + + mySelectPoint = new QPushButton(aGroupBoxFocal); + mySelectPoint->setText(tr("LBL_SELECTPOINT")); + mySelectPoint->setCheckable(true); + aLayout2->addWidget(mySelectPoint); + connect(mySelectPoint, SIGNAL(clicked()), this, SLOT(onSelectPoint())); + + // Focal point coordinates + myFocalCoords = new QFrame(aGroupBoxFocal); + myFocalCoords->setObjectName("FocalPointCoordinates"); + + QHBoxLayout* aCoordLayout = new QHBoxLayout(myFocalCoords); + aCoordLayout->setSpacing(6); + aCoordLayout->setMargin(0); + + QLabel* aLabelX = new QLabel(tr("LBL_X"), myFocalCoords); + aLabelX->setFixedWidth(25); + myFocalX = new QLineEdit(myFocalCoords); + myFocalX->setValidator(new QDoubleValidator(myFocalX)); + myFocalX->setText(QString::number(0.0)); + connect(myFocalX, SIGNAL(textChanged(const QString&)), SLOT(onFocalCoordChanged())); + + QLabel* aLabelY = new QLabel(tr("LBL_Y"), myFocalCoords); + aLabelY->setFixedWidth(25); + myFocalY = new QLineEdit(myFocalCoords); + myFocalY->setValidator(new QDoubleValidator(myFocalY)); + myFocalY->setText(QString::number(0.0)); + connect(myFocalY, SIGNAL(textChanged(const QString&)), SLOT(onFocalCoordChanged())); + + QLabel* aLabelZ = new QLabel(tr("LBL_Z"), myFocalCoords); + aLabelZ->setFixedWidth(25); + myFocalZ = new QLineEdit(myFocalCoords); + myFocalZ->setValidator(new QDoubleValidator(myFocalZ)); + myFocalZ->setText(QString::number(0.0)); + connect(myFocalZ, SIGNAL(textChanged(const QString&)), SLOT(onFocalCoordChanged())); + + aCoordLayout->addWidget(aLabelX); + aCoordLayout->addWidget(myFocalX); + aCoordLayout->addWidget(aLabelY); + aCoordLayout->addWidget(myFocalY); + aCoordLayout->addWidget(aLabelZ); + aCoordLayout->addWidget(myFocalZ); + aLayout2->addWidget(myFocalCoords); + + // Camera position + QGroupBox* aGroupBoxCamera = new QGroupBox(tr("CAMERA_POSITION"), this); + QVBoxLayout* aLayout3 = new QVBoxLayout(aGroupBoxCamera); + + QRadioButton* aWorld = new QRadioButton(tr("WORLD_COORDINATES"), aGroupBoxCamera); + QRadioButton* aRelative = new QRadioButton(tr("FOCAL_RELATIVE"), aGroupBoxCamera); + + QHBoxLayout* aHLayout = new QHBoxLayout; + aHLayout->addWidget(aWorld); + aHLayout->addWidget(aRelative); + aLayout3->addLayout(aHLayout); + + myCameraPositionMode = new QButtonGroup(aGroupBoxCamera); + myCameraPositionMode->addButton(aWorld, 0); + myCameraPositionMode->addButton(aRelative, 1); + connect(myCameraPositionMode, SIGNAL(buttonClicked(int)), SLOT(onPositionModeChanged(int))); + + // Camera coordinates + myCameraCoords = new QFrame(aGroupBoxCamera); + myCameraCoords->setObjectName("CameraCoordinates"); + + aCoordLayout = new QHBoxLayout(myCameraCoords); + aCoordLayout->setSpacing(6); + aCoordLayout->setMargin(0); + + aLabelX = new QLabel(tr("LBL_X"), myCameraCoords); + aLabelX->setFixedWidth(25); + myCameraX = new QLineEdit(myCameraCoords); + myCameraX->setValidator(new QDoubleValidator(myCameraX)); + myCameraX->setText(QString::number(0.0)); + connect(myCameraX, SIGNAL(textChanged(const QString&)), SLOT(onCameraCoordChanged())); + + aLabelY = new QLabel(tr("LBL_Y"), myCameraCoords); + aLabelY->setFixedWidth(25); + myCameraY = new QLineEdit(myCameraCoords); + myCameraY->setValidator(new QDoubleValidator(myCameraY)); + myCameraY->setText(QString::number(0.0)); + connect(myCameraY, SIGNAL(textChanged(const QString&)), SLOT(onCameraCoordChanged())); + + aLabelZ = new QLabel(tr("LBL_Z"), myCameraCoords); + aLabelZ->setFixedWidth(25); + myCameraZ = new QLineEdit(myCameraCoords); + myCameraZ->setValidator(new QDoubleValidator(myCameraZ)); + myCameraZ->setText(QString::number(1.0)); + connect(myCameraZ, SIGNAL(textChanged(const QString&)), SLOT(onCameraCoordChanged())); + + aCoordLayout->addWidget(aLabelX); + aCoordLayout->addWidget(myCameraX); + aCoordLayout->addWidget(aLabelY); + aCoordLayout->addWidget(myCameraY); + aCoordLayout->addWidget(aLabelZ); + aCoordLayout->addWidget(myCameraZ); + aLayout3->addWidget(myCameraCoords); + + // Projection direction + QFrame* line1 = new QFrame(aGroupBoxCamera); + line1->setFrameStyle(QFrame::HLine | QFrame::Sunken); + aLayout3->addWidget(line1); + + QLabel* aLabel = new QLabel(tr("PROJECTION_DIRECTION"), aGroupBoxCamera); + aLayout3->addWidget(aLabel); + + myProjDirection = new QFrame(aGroupBoxCamera); + myProjDirection->setObjectName("ProjectionDirection"); + + aCoordLayout = new QHBoxLayout(myProjDirection); + aCoordLayout->setSpacing(6); + aCoordLayout->setMargin(0); + + aLabelX = new QLabel(tr("LBL_DX"), myProjDirection); + aLabelX->setFixedWidth(25); + myProjDirX = new QLineEdit(myProjDirection); + myProjDirX->setValidator(new QDoubleValidator(myProjDirX)); + myProjDirX->setText(QString::number(0.0)); + connect(myProjDirX, SIGNAL(textChanged(const QString&)), SLOT(onDirectionChanged())); + + aLabelY = new QLabel(tr("LBL_DY"), myProjDirection); + aLabelY->setFixedWidth(25); + myProjDirY = new QLineEdit(myProjDirection); + myProjDirY->setValidator(new QDoubleValidator(myProjDirY)); + myProjDirY->setText(QString::number(0.0)); + connect(myProjDirY, SIGNAL(textChanged(const QString&)), SLOT(onDirectionChanged())); + + aLabelZ = new QLabel(tr("LBL_DZ"), myProjDirection); + aLabelZ->setFixedWidth(25); + myProjDirZ = new QLineEdit(myProjDirection); + myProjDirZ->setValidator(new QDoubleValidator(myProjDirZ)); + myProjDirZ->setText(QString::number(-1.0)); + connect(myProjDirZ, SIGNAL(textChanged(const QString&)), SLOT(onDirectionChanged())); + + aCoordLayout->addWidget(aLabelX); + aCoordLayout->addWidget(myProjDirX); + aCoordLayout->addWidget(aLabelY); + aCoordLayout->addWidget(myProjDirY); + aCoordLayout->addWidget(aLabelZ); + aCoordLayout->addWidget(myProjDirZ); + aLayout3->addWidget(myProjDirection); + + // Distance to focal point + QHBoxLayout* aHorLayout = new QHBoxLayout; + aHorLayout->setSpacing(6); + + aLabel = new QLabel(tr("FOCAL_DISTANCE"), aGroupBoxCamera); + myDistance = new QLineEdit(aGroupBoxCamera); + QDoubleValidator* aVal = new QDoubleValidator(myDistance); + aVal->setBottom(0.0002); // VTK minimal distance + myDistance->setValidator(aVal); + myDistance->setText(QString::number(1.0)); + connect(myDistance, SIGNAL(textChanged(const QString&)), SLOT(onDistanceChanged())); + + aHorLayout->addWidget(aLabel); + aHorLayout->addWidget(myDistance); + aLayout3->addLayout(aHorLayout); + + // View Up direction + QFrame* line2 = new QFrame(aGroupBoxCamera); + line2->setFrameStyle(QFrame::HLine | QFrame::Sunken); + aLayout3->addWidget(line2); + + aLabel = new QLabel(tr("VIEW_UP_DIRECTION"), aGroupBoxCamera); + aLayout3->addWidget(aLabel); + + myViewDirection = new QFrame(aGroupBoxCamera); + myViewDirection->setObjectName("ViewUpDirection"); + aLayout3->addWidget(myViewDirection); + + aCoordLayout = new QHBoxLayout(myViewDirection); + aCoordLayout->setSpacing(6); + aCoordLayout->setMargin(0); + + aLabelX = new QLabel(tr("LBL_DX"), myViewDirection); + aLabelX->setFixedWidth(25); + myViewDirX = new QLineEdit(myViewDirection); + myViewDirX->setValidator(new QDoubleValidator(myViewDirX)); + myViewDirX->setText(QString::number(0.0)); + connect(myViewDirX, SIGNAL(textChanged(const QString&)), SLOT(onViewDirectionChanged())); + + aLabelY = new QLabel(tr("LBL_DY"), myViewDirection); + aLabelY->setFixedWidth(25); + myViewDirY = new QLineEdit(myViewDirection); + myViewDirY->setValidator(new QDoubleValidator(myViewDirY)); + myViewDirY->setText(QString::number(1.0)); + connect(myViewDirY, SIGNAL(textChanged(const QString&)), SLOT(onViewDirectionChanged())); + + aLabelZ = new QLabel(tr("LBL_DZ"), myViewDirection); + aLabelZ->setFixedWidth(25); + myViewDirZ = new QLineEdit(myViewDirection); + myViewDirZ->setValidator(new QDoubleValidator(myViewDirZ)); + myViewDirZ->setText(QString::number(0.0)); + connect(myViewDirZ, SIGNAL(textChanged(const QString&)), SLOT(onViewDirectionChanged())); + + aCoordLayout->addWidget(aLabelX); + aCoordLayout->addWidget(myViewDirX); + aCoordLayout->addWidget(aLabelY); + aCoordLayout->addWidget(myViewDirY); + aCoordLayout->addWidget(aLabelZ); + aCoordLayout->addWidget(myViewDirZ); + + // Zooming + QGroupBox* aGroupBoxZoom = new QGroupBox(tr("ZOOMING"), this); + QVBoxLayout* aLayout4 = new QVBoxLayout(aGroupBoxZoom); + + // Parallel scale + myScaleBox = new QFrame(aGroupBoxZoom); + myScaleBox->setObjectName("ScaleValue"); + + aHorLayout = new QHBoxLayout(myScaleBox); + aHorLayout->setSpacing(6); + aHorLayout->setMargin(0); + + aLabel = new QLabel(tr("LBL_SCALE"), myScaleBox); + myScale = new QLineEdit(myScaleBox); + QDoubleValidator* aVal2 = new QDoubleValidator(myScale); + aVal2->setBottom(0.000001); // VTK minimal scale + myScale->setValidator(aVal2); + myScale->setText(QString::number(1.0)); + connect(myScale, SIGNAL(textChanged(const QString&)), SLOT(onZoomChanged())); + + aHorLayout->addWidget(aLabel); + aHorLayout->addWidget(myScale); + aLayout4->addWidget(myScaleBox); + + // View Angle + myViewAngleBox = new QFrame(aGroupBoxZoom); + myViewAngleBox->setObjectName("ViewAngle"); + + aHorLayout = new QHBoxLayout(myViewAngleBox); + aHorLayout->setSpacing(6); + aHorLayout->setMargin(0); + + aLabel = new QLabel(tr("LBL_VIEW_ANGLE"), myViewAngleBox); + myViewAngle = new QLineEdit(myViewAngleBox); + QDoubleValidator* aVal3 = new QDoubleValidator(myViewAngle); + aVal3->setBottom(0.000001); // VTK minimal scale + aVal3->setTop(179); // VTK minimal scale + myViewAngle->setValidator(aVal3); + myViewAngle->setText(QString::number(30.0)); + connect(myViewAngle, SIGNAL(textChanged(const QString&)), SLOT(onZoomChanged())); + + aHorLayout->addWidget(aLabel); + aHorLayout->addWidget(myViewAngle); + aLayout4->addWidget(myViewAngleBox); + + // "Close" button + QGroupBox* aGroupBox = new QGroupBox(this); + QHBoxLayout* aHBoxLayout2 = new QHBoxLayout(aGroupBox); + aHBoxLayout2->setMargin(11); + aHBoxLayout2->setSpacing(6); + + QPushButton* m_bClose = new QPushButton(tr("&Close"), aGroupBox ); + m_bClose->setObjectName("m_bClose"); + m_bClose->setAutoDefault(TRUE); + m_bClose->setFixedSize(m_bClose->sizeHint()); + connect(m_bClose, SIGNAL(clicked()), this, SLOT(onClickClose())); + + // Layout buttons + aHBoxLayout2->addWidget(m_bClose); + + // Layout top level widgets + aTopLayout->addWidget(aGroupBoxMode); + aTopLayout->addWidget(aGroupBoxFocal); + aTopLayout->addWidget(aGroupBoxCamera); + aTopLayout->addWidget(aGroupBoxZoom); + aTopLayout->addWidget(aGroupBox); + aTopLayout->addStretch(); + + // initial state + myProjectionMode->button(0)->setChecked(true); + myCameraPositionMode->button(0)->setChecked(true); + + setEnabled(myCameraCoords, myCameraPositionMode->checkedId() == 0); + + myScaleBox->setVisible(myProjectionMode->checkedId() == 0); + myViewAngleBox->setVisible(myProjectionMode->checkedId() == 1); + + updateData(); + + this->resize(400, this->sizeHint().height()); + + myEventCallbackCommand->Delete(); + myEventCallbackCommand->SetClientData(this); + myEventCallbackCommand->SetCallback(SVTK_ViewParameterDlg::ProcessEvents); + myIsObserverAdded = false; + myBusy = false; +} + +/* + * Destroys the object and frees any allocated resources + */ +SVTK_ViewParameterDlg::~SVTK_ViewParameterDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + +void SVTK_ViewParameterDlg::addObserver() +{ + if ( !myIsObserverAdded ) { + vtkInteractorStyle* aIStyle = myRWInteractor->GetInteractorStyle(); + aIStyle->AddObserver(SVTK::BBCenterChanged, myEventCallbackCommand.GetPointer(), myPriority); + aIStyle->AddObserver(SVTK::FocalPointChanged, myEventCallbackCommand.GetPointer(), myPriority); + + vtkRenderer *aRenderer = myRWInteractor->getRenderer(); + aRenderer->AddObserver(vtkCommand::EndEvent, myEventCallbackCommand.GetPointer(), myPriority); + + myIsObserverAdded = true; + } +} + +/*! + Processes events +*/ +void SVTK_ViewParameterDlg::ProcessEvents(vtkObject* vtkNotUsed(theObject), + unsigned long theEvent, + void* theClientData, + void* theCallData) +{ + SVTK_ViewParameterDlg* self = reinterpret_cast(theClientData); + vtkFloatingPointType* aCoord; + switch ( theEvent ) { + case SVTK::BBCenterChanged: + if ( theCallData ) + { + aCoord = (vtkFloatingPointType*)theCallData; + self->myBusy = true; + self->myFocalX->setText( QString::number(aCoord[0]) ); + self->myFocalY->setText( QString::number(aCoord[1]) ); + self->myFocalZ->setText( QString::number(aCoord[2]) ); + self->myBusy = false; + self->onFocalCoordChanged(); + } + break; + case SVTK::FocalPointChanged: + if ( theCallData ) + { + aCoord = (vtkFloatingPointType*)theCallData; + self->myBusy = true; + self->myFocalX->setText( QString::number(aCoord[0]) ); + self->myFocalY->setText( QString::number(aCoord[1]) ); + self->myFocalZ->setText( QString::number(aCoord[2]) ); + self->myBusy = false; + self->onFocalCoordChanged(); + } + break; + case vtkCommand::EndEvent: + if ( self->myRWInteractor->getRenderer()->GetActiveCamera()->GetMTime() > self->myCameraMTime ) + self->updateData(); + break; + } +} + +void SVTK_ViewParameterDlg::updateData() +{ + myBusy = true; + vtkCamera* aCamera = myRWInteractor->getRenderer()->GetActiveCamera(); + + int aParallel = aCamera->GetParallelProjection(); + myProjectionMode->button(aParallel?0:1)->setChecked(true); + + double focal[3], pos[3], vup[3], proj[3], dist, scale, angle; + + aCamera->GetFocalPoint(focal); + myFocalX->setText(QString::number(focal[0])); + myFocalY->setText(QString::number(focal[1])); + myFocalZ->setText(QString::number(focal[2])); + + aCamera->GetPosition(pos); + myCameraX->setText(QString::number(pos[0])); + myCameraY->setText(QString::number(pos[1])); + myCameraZ->setText(QString::number(pos[2])); + + aCamera->GetDirectionOfProjection(proj); + myProjDirX->setText(QString::number(proj[0])); + myProjDirY->setText(QString::number(proj[1])); + myProjDirZ->setText(QString::number(proj[2])); + + aCamera->GetViewUp(vup); + myViewDirX->setText(QString::number(vup[0])); + myViewDirY->setText(QString::number(vup[1])); + myViewDirZ->setText(QString::number(vup[2])); + + dist = aCamera->GetDistance(); + myDistance->setText(QString::number(dist)); + + scale = aCamera->GetParallelScale(); + myScale->setText(QString::number(scale)); + + angle = aCamera->GetViewAngle(); + myViewAngle->setText(QString::number(angle)); + + myCameraMTime.Modified(); + myBusy = false; +} + +void SVTK_ViewParameterDlg::setEnabled(QFrame* theWidget, const bool theState) +{ + QObjectList aChildren(theWidget->children()); + QObject* anObj; + for(int i = 0; i < aChildren.size(); i++) + { + anObj = aChildren.at(i); + if (anObj !=0 && anObj->inherits("QLineEdit")) + ((QLineEdit*)anObj)->setReadOnly(!theState); + if (anObj !=0 && anObj->inherits("QPushButton")) + ((QLineEdit*)anObj)->setEnabled(theState); + } + +} + +void SVTK_ViewParameterDlg::onProjectionModeChanged(int mode) +{ + int aBtn = myProjectionMode->checkedId(); + + vtkCamera* aCamera = myRWInteractor->getRenderer()->GetActiveCamera(); + aCamera->SetParallelProjection(aBtn == 0); + myRWInteractor->getRenderer()->Render(); + + myScaleBox->setVisible(aBtn == 0); + myViewAngleBox->setVisible(aBtn == 1); +} + +void SVTK_ViewParameterDlg::onPositionModeChanged(int mode) +{ + setEnabled(myCameraCoords, myCameraPositionMode->checkedId() == 0); +} + +void SVTK_ViewParameterDlg::onToBBCenter() +{ + if ( mySelectPoint->isChecked() ) + mySelectPoint->toggle(); + + myMainWindow->activateSetFocalPointGravity(); +} + +void SVTK_ViewParameterDlg::onToOrigin() +{ + if ( mySelectPoint->isChecked() ) + mySelectPoint->toggle(); + + myBusy = true; + myFocalX->setText(QString::number(0.0)); + myFocalY->setText(QString::number(0.0)); + myFocalZ->setText(QString::number(0.0)); + myBusy = false; + + onFocalCoordChanged(); +} + +void SVTK_ViewParameterDlg::onSelectPoint() +{ + if ( mySelectPoint->isChecked() ) + myMainWindow->activateStartFocalPointSelection(); + else + mySelectPoint->toggle(); +} + +void SVTK_ViewParameterDlg::onFocalCoordChanged() +{ + if ( myBusy ) return; + + if ( mySelectPoint->isChecked() ) + mySelectPoint->toggle(); + + vtkCamera* aCamera = myRWInteractor->getRenderer()->GetActiveCamera(); + aCamera->SetFocalPoint(myFocalX->text().toDouble(), + myFocalY->text().toDouble(), + myFocalZ->text().toDouble()); + myRWInteractor->getRenderer()->Render(); + + myMainWindow->activateSetFocalPointSelected(); + + //updateProjection(); +} + +void SVTK_ViewParameterDlg::onCameraCoordChanged() +{ + if ( myBusy ) return; + + vtkCamera* aCamera = myRWInteractor->getRenderer()->GetActiveCamera(); + aCamera->SetPosition(myCameraX->text().toDouble(), + myCameraY->text().toDouble(), + myCameraZ->text().toDouble()); + + //updateProjection(); +} + +void SVTK_ViewParameterDlg::onDirectionChanged() +{ + if ( myBusy ) return; + + updateCoordinates(); +} + +void SVTK_ViewParameterDlg::onDistanceChanged() +{ + if ( myBusy ) return; + + updateCoordinates(); +} + +void SVTK_ViewParameterDlg::onViewDirectionChanged() +{ + if ( myBusy ) return; + + vtkCamera* aCamera = myRWInteractor->getRenderer()->GetActiveCamera(); + aCamera->SetViewUp(myViewDirX->text().toDouble(), + myViewDirY->text().toDouble(), + myViewDirZ->text().toDouble()); + myRWInteractor->getRenderer()->Render(); +} + +void SVTK_ViewParameterDlg::onZoomChanged() +{ + if ( myBusy ) return; + + vtkCamera* aCamera = myRWInteractor->getRenderer()->GetActiveCamera(); + + switch( myProjectionMode->checkedId() ) { + case 0: + aCamera->SetParallelScale(myScale->text().toDouble()); + break; + case 1: + aCamera->SetViewAngle(myViewAngle->text().toDouble()); + break; + } + myRWInteractor->getRenderer()->Render(); +} + +void SVTK_ViewParameterDlg::onClickClose() +{ + reject(); +} + +void SVTK_ViewParameterDlg::updateProjection() +{ + double pnt[3], pos[3], dir[3], dist; + + pnt[0] = myFocalX->text().toDouble(); + pnt[1] = myFocalY->text().toDouble(); + pnt[2] = myFocalZ->text().toDouble(); + + pos[0] = myCameraX->text().toDouble(); + pos[1] = myCameraY->text().toDouble(); + pos[2] = myCameraZ->text().toDouble(); + + dir[0] = pnt[0] - pos[0]; + dir[1] = pnt[1] - pos[1]; + dir[2] = pnt[2] - pos[2]; + + dist = sqrt( dir[0]*dir[0] + dir[1]*dir[1] + dir[2]*dir[2] ); + + if ( dist > 0.0002 ) { + dir[0] = dir[0] / dist; + dir[1] = dir[1] / dist; + dir[2] = dir[2] / dist; + } + + myBusy = true; + myProjDirX->setText(QString::number(dir[0])); + myProjDirY->setText(QString::number(dir[1])); + myProjDirZ->setText(QString::number(dir[2])); + + myDistance->setText(QString::number(dist)); + myBusy = false; +} + +void SVTK_ViewParameterDlg::updateCoordinates() +{ + double pnt[3], pos[3], dir[3], dist; + + pnt[0] = myFocalX->text().toDouble(); + pnt[1] = myFocalY->text().toDouble(); + pnt[2] = myFocalZ->text().toDouble(); + + pos[0] = myCameraX->text().toDouble(); + pos[1] = myCameraY->text().toDouble(); + pos[2] = myCameraZ->text().toDouble(); + + dir[0] = myProjDirX->text().toDouble(); + dir[1] = myProjDirY->text().toDouble(); + dir[2] = myProjDirZ->text().toDouble(); + + dist = myDistance->text().toDouble(); + + if (myCameraPositionMode->checkedId() == 1) { + // recompute camera position + dir[0] = -dir[0]; dir[1] = -dir[1]; dir[2] = -dir[2]; + if (computePoint(pnt, dir, dist, pos)) { + myBusy = true; + myCameraX->setText(QString::number(pos[0])); + myCameraY->setText(QString::number(pos[1])); + myCameraZ->setText(QString::number(pos[2])); + myBusy = false; + onCameraCoordChanged(); + } + } + else { + // recompute focal point + if (computePoint(pos, dir, dist, pnt)) { + if (mySelectPoint->isChecked()) + mySelectPoint->toggle(); + myBusy = true; + myFocalX->setText(QString::number(pnt[0])); + myFocalY->setText(QString::number(pnt[1])); + myFocalZ->setText(QString::number(pnt[2])); + myBusy = false; + onFocalCoordChanged(); + } + } +} + +bool SVTK_ViewParameterDlg::computePoint(const double start[3], + const double dir[3], + const double dist, + double result[3]) +{ + double d = sqrt(dir[0]*dir[0]+dir[1]*dir[1]+dir[2]*dir[2]); + if ( d < 0.0002 ) return false; + + for (int i = 0; i < 3; i++) + result[i] = start[i] + dir[i] * dist / d; + + return true; +} diff --git a/src/SVTK/SVTK_ViewParameterDlg.h b/src/SVTK/SVTK_ViewParameterDlg.h new file mode 100755 index 000000000..c5722ec02 --- /dev/null +++ b/src/SVTK/SVTK_ViewParameterDlg.h @@ -0,0 +1,153 @@ +// SALOME VTKViewer : build VTK viewer into Salome desktop +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : +// Author : +// Module : SALOME +// $Header: + +#ifndef SVTK_VIEWPARAMETERDLG_H +#define SVTK_VIEWPARAMETERDLG_H + +#include "SVTK.h" + +#include "SVTK_DialogBase.h" + +#include +#include + +class SVTK_MainWindow; +class SVTK_RenderWindowInteractor; + +class QtxAction; + +class QLineEdit; +class QPushButton; +class QFrame; +class QCheckBox; +class QButtonGroup; + +class vtkCallbackCommand; +class vtkObject; + +class SVTK_EXPORT SVTK_ViewParameterDlg : public SVTK_DialogBase +{ + Q_OBJECT; + +public: + SVTK_ViewParameterDlg(QtxAction* theAction, + SVTK_MainWindow* theParent, + const char* theName); + + ~SVTK_ViewParameterDlg(); + + void addObserver(); + +protected: + SVTK_MainWindow *myMainWindow; + SVTK_RenderWindowInteractor* myRWInteractor; + bool myIsObserverAdded; + bool myBusy; + + QButtonGroup* myProjectionMode; + + QPushButton* myToBBCenter; + QPushButton* myToOrigin; + QPushButton* mySelectPoint; + + QFrame* myFocalCoords; + QLineEdit* myFocalX; + QLineEdit* myFocalY; + QLineEdit* myFocalZ; + + QButtonGroup* myCameraPositionMode; + + QFrame* myCameraCoords; + QLineEdit* myCameraX; + QLineEdit* myCameraY; + QLineEdit* myCameraZ; + + QFrame* myProjDirection; + QLineEdit* myProjDirX; + QLineEdit* myProjDirY; + QLineEdit* myProjDirZ; + + QLineEdit* myDistance; + + QFrame* myViewDirection; + QLineEdit* myViewDirX; + QLineEdit* myViewDirY; + QLineEdit* myViewDirZ; + + QFrame* myScaleBox; + QLineEdit* myScale; + + QFrame* myViewAngleBox; + QLineEdit* myViewAngle; + + void setEnabled(QFrame* theWidget, const bool theState); + bool computePoint(const double start[3], const double dir[3], + const double dist, double result[3]); + void updateProjection(); + void updateCoordinates(); + + void updateData(); + + //---------------------------------------------------------------------------- + // Priority at which events are processed + vtkFloatingPointType myPriority; + + // Used to process events + vtkSmartPointer myEventCallbackCommand; + + // Used to update camera + vtkTimeStamp myCameraMTime; + + // Description: + // Main process event method + static void ProcessEvents(vtkObject* object, + unsigned long event, + void* clientdata, + void* calldata); + +protected slots: + void onProjectionModeChanged(int); + void onPositionModeChanged(int); + + void onToBBCenter(); + void onToOrigin(); + void onSelectPoint(); + + void onFocalCoordChanged(); + void onCameraCoordChanged(); + void onDirectionChanged(); + void onDistanceChanged(); + void onViewDirectionChanged(); + + void onZoomChanged(); + + void onClickClose(); + +}; + +#endif // SVTK_VIEWPARAMETERDLG_H diff --git a/src/SVTK/resources/SVTK_images.ts b/src/SVTK/resources/SVTK_images.ts index 060908a75..62c3d318a 100644 --- a/src/SVTK/resources/SVTK_images.ts +++ b/src/SVTK/resources/SVTK_images.ts @@ -17,5 +17,17 @@ ICON_SVTK_UPDATE_RATE vtk_view_update_rate.png + + ICON_SVTK_VIEW_PARAMETERS + vtk_view_parameters.png + + + ICON_SVTK_VIEW_PARALLEL + vtk_view_parallel.png + + + ICON_SVTK_VIEW_PERSPECTIVE + vtk_view_perspective.png + diff --git a/src/SVTK/resources/SVTK_msg_en.ts b/src/SVTK/resources/SVTK_msg_en.ts index dad1d0226..58b41d087 100644 --- a/src/SVTK/resources/SVTK_msg_en.ts +++ b/src/SVTK/resources/SVTK_msg_en.ts @@ -153,6 +153,14 @@ SVTK_IMAGE_FILES Images Files (*.bmp *.png *.jpg *.jpeg *.pdf *.ps *.eps) + + MNU_VIEWPARAMETERS_VIEW + Change View Parameters + + + DSC_VIEWPARAMETERS_VIEW + Change the parameters of the view + SVTK_AxisWidget @@ -340,6 +348,105 @@ Set Rotation Point + + SVTK_ViewParameterDlg + + LBL_X + X : + + + LBL_Y + Y : + + + LBL_Z + Z : + + + LBL_DX + DX : + + + LBL_DY + DY : + + + LBL_DZ + DZ : + + + PROJECTION_MODE + Projection Mode + + + ORTHOGONAL_MODE + Orthogonal + + + PERSPECTIVE_MODE + Perspective + + + USE_BBCENTER + Use Bounding Box Center + + + LBL_TOBBCENTER + Set to Bounding Box Center + + + LBL_TOORIGIN + Set to Origin + + + LBL_SELECTPOINT + Select Point from View + + + FOCAL_POINT + Focal Point + + + CAMERA_POSITION + Camera Position + + + WORLD_COORDINATES + World Coordinates + + + FOCAL_RELATIVE + Relative to Focal Point + + + PROJECTION_DIRECTION + Projection Direction : + + + FOCAL_DISTANCE + Focal Distance : + + + VIEW_UP_DIRECTION + View Up Direction : + + + ZOOMING + Zooming + + + LBL_SCALE + Scale + + + LBL_VIEW_ANGLE + View Angle + + + DLG_TITLE + View Parameters + + SVTK_UpdateRateDlg diff --git a/src/SVTK/resources/vtk_view_parallel.png b/src/SVTK/resources/vtk_view_parallel.png new file mode 100755 index 0000000000000000000000000000000000000000..dd7a67600aba030f774e43a65346a159d32974a5 GIT binary patch literal 878 zcmV-!1CjiRP)z@;j(q!3lK=n!AY({UO#lFTB>(_`g8%^e{{R4h=>PzA zFaQARU;qF*m;eA5Z<1fdMgRZ;c4;gGW_}T2P_BU|N8Zd;rsXR3}3%~WtcHz1|v2D0RjkaAV@JtqpEWT z!#^PX=Pv`pzkiV60FfZ(Um)@O?|+7$zyC3WzJ2?D_3G7}K&ceK=FTI!+!nw&!89C&*0+X@*Sv^1KB`;0D>C` z^2!gOVmYULhGR>r7{2@f8usHa7=Ql$m*MLVgrOjHKY@lCC(UCpH8n*s6d-`$UjFjs z3&S^{OF&*y@@Zh$H7Nlc49I|ykr9kRVGHsRC|p5UUtj92SpNC_gW=E5?+m|xd}X-1xeg?)0K^Xf0toJ9P=tVzB)(J$ zjvSz2|Ns4E`1j{G!{1*ZL%)Ju2?UxzEC3KdOvo<$19TzCcCaQK2_7U0Ht_EshQEJ) z0$utOsQw>FN&pm=00G2;94Wt`2LAa6Nq1l;Gcw{a6k;&cKrjFZAh>~`FayOP#B~f{ zMgRZ*1BM$Dc0<8F_zzZt3;+TMZs6z7pMkFY1`L}&V1=NV{Pp7t&@3i!%tE3B0{;H_ z1rEF4Kfi&)5jl7O0tjy4sZ*yEfBlNMZxk~D=pA74`Td*W`=>WRV;Dj1K#47ofxm&4 z{RSEO;~OkezyKhCSdd)%z@;j(q!3lK=n!AY({UO#lFTB>(_`g8%^e{{R4h=>PzA zFaQARU;qF*m;eA5Z<1fdMgRZ;I7vi7RCwBA{Qv(y12q9a05KA)P(eWf!{!GM9$@GP z2p|?xY(L%6!SM6N3x)?LPB6p(F%ZZC@f)Bozk^-J$jAT?KuqMi4l4c#NQoee0R#}( zKy7Vp6bK04>g1noexze48(pQmp+*=;Xl;H zbAY%5Bo2~?MJ_-9F~AIgN*I77(fFKD3}R;^88!*ThpB-X2oOMw=-xvHSFc|62g+{* z(u`0;)q&U=8X1p)_$Uyc2dM=b$OwuQfB*u=vSC~g1E-`0iebk(eL%sn5y{KnfcPeq zF9*b+2s!`O$A{tg^XH%#204riAb{Yp%*BGhFaWX$1X5E|-+*EhNP`Up(i>rhgA79g z>Hq-*_A*Q(GC04e1lj9lQ19JDQwB;hH=yjvAZ-8v#DcCFEez)ZElh@b8Kn6wni5dB zCV@Ny695PxMrc6$0X25P3;@wk`EOAC7Un`=EWZJ!Kjg$Li)7$=fB*suKx4WdnyxyK z_=(Wu;{sBLmJVS_g%fHh2y+4i5Xj4KkW2?jen;ZpgvofQ=6}(6pig-Aq|%B7Y1EDu4hYwt(e?#-uCM5EuX%v>O!OAa8@h5Fmhv oEnr~*e*-xvU}26Nh5!Ku0E0c`Z2~>u6aWAK07*qoM6N<$f*ytcd;kCd literal 0 HcmV?d00001 diff --git a/src/SVTK/resources/vtk_view_perspective.png b/src/SVTK/resources/vtk_view_perspective.png new file mode 100755 index 0000000000000000000000000000000000000000..36cdd4c318ccffba87d264a108027878feb6ab99 GIT binary patch literal 831 zcmV-F1Hk-=P)z@;j(q!3lK=n!AY({UO#lFTB>(_`g8%^e{{R4h=>PzA zFaQARU;qF*m;eA5Z<1fdMgRZ;wMj%lRCwBA{Qv(y12q9a0I|RrjEsy#X{fBM{Qvv+ zZ-!sLelbj%Gzmi!Kmf52V@Pdn?SGI@{{8#MAY_%p@aG=`!*3vw`u+R=*|TSJ0hN4* zsRaliMwpk;U07FF_a9^cNM6J`hvDx(pn*W8Ao|Z=2>uN;_|fJ{h9yguzzqcmAQS_u ztE>OR3>LA@25SOI11X^E{=*IZ10)`Atz`gt{qNtuV7z+uYOtXI0R;DQSy|bCVW4+F z;2+SGpT8jnzzhT7$J^_{F8=f955rekUxt4`gZ};f!@zQHJxH4>5Z?v}Ah>}b?>*b! z%OGM`1lA04#oxaOLqM+hF6RefgDe2@{{s#C`{y?UBajUQdO-XZAb{Wof?`d~v7F)2 zjux;BVBUcl0&+D2I7}J9{Qv)et^?x#|Nk;TgH0HSxc~wPZs5fmjIYS`@?G+#oK876fo6Kmg$^ZIA#b)KC<|q2e%_ z0qTft00Bfyc?fdxQzXNmU@@ElD*g>1fQWG+F)oLN`8$9B0{|1GxpE literal 0 HcmV?d00001 -- 2.39.2