From: ouv Date: Mon, 26 May 2008 10:14:10 +0000 (+0000) Subject: VISU 2008 - Unification of the VISU selection functionality (debug) X-Git-Tag: TG_VISU_2008_2008-06-26~37 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3555840950f993d8059c23fbb36cc2c0b14f0e24;p=modules%2Fvisu.git VISU 2008 - Unification of the VISU selection functionality (debug) --- diff --git a/resources/Makefile.am b/resources/Makefile.am index 148851d3..1daf455b 100644 --- a/resources/Makefile.am +++ b/resources/Makefile.am @@ -33,8 +33,12 @@ SalomeApp.xml \ sprite_alpha.bmp \ sprite_texture.bmp \ Vertex_Program_ARB.txt \ +Visu_actor_selection.png \ Visu_add.png \ +Visu_apply.png \ Visu_anim.png \ +Visu_cell_selection.png \ +Visu_close.png \ VISU.config \ Visu_cutlines.png \ Visu_cutplanes.png \ @@ -43,14 +47,18 @@ Visu_deformed.png \ VISU_en.xml \ Visu_eraseall.png \ VISU_fr.xml \ +Visu_gauss_point_selection.png \ Visu_gauss_points.png \ Visu_graduated_axes.png \ +Visu_help.png \ Visu_import_med.png \ Visu_isosurfaces.png \ Visu_load_texture.png \ +Visu_ok.png \ Visu_PlaneSegmentation.png \ Visu_plot2d.png \ Visu_plot3d.png \ +Visu_point_selection.png \ Visu_points.png \ Visu_recording_pause.png \ Visu_recording_play.png \ @@ -63,6 +71,7 @@ Visu_scalars_anim.png \ Visu_scalars.png \ Visu_scaling.png \ Visu_selectall.png \ +Visu_selection_panel.png \ Visu_selectionactor.png \ Visu_selectioncell.png \ Visu_selectionedge.png \ diff --git a/resources/SalomeApp.xml b/resources/SalomeApp.xml index dfd869d5..b7e6fed1 100644 --- a/resources/SalomeApp.xml +++ b/resources/SalomeApp.xml @@ -119,8 +119,10 @@ + + diff --git a/resources/Visu_actor_selection.png b/resources/Visu_actor_selection.png new file mode 100644 index 00000000..f94b29d1 Binary files /dev/null and b/resources/Visu_actor_selection.png differ diff --git a/resources/Visu_apply.png b/resources/Visu_apply.png new file mode 100644 index 00000000..3a225a1d Binary files /dev/null and b/resources/Visu_apply.png differ diff --git a/resources/Visu_cell_selection.png b/resources/Visu_cell_selection.png new file mode 100644 index 00000000..8e2dc4f5 Binary files /dev/null and b/resources/Visu_cell_selection.png differ diff --git a/resources/Visu_close.png b/resources/Visu_close.png new file mode 100644 index 00000000..d5f353e3 Binary files /dev/null and b/resources/Visu_close.png differ diff --git a/resources/Visu_gauss_point_selection.png b/resources/Visu_gauss_point_selection.png new file mode 100644 index 00000000..8129a9e2 Binary files /dev/null and b/resources/Visu_gauss_point_selection.png differ diff --git a/resources/Visu_help.png b/resources/Visu_help.png new file mode 100644 index 00000000..452b45f6 Binary files /dev/null and b/resources/Visu_help.png differ diff --git a/resources/Visu_ok.png b/resources/Visu_ok.png new file mode 100644 index 00000000..8ce1457b Binary files /dev/null and b/resources/Visu_ok.png differ diff --git a/resources/Visu_point_selection.png b/resources/Visu_point_selection.png new file mode 100644 index 00000000..bcc92033 Binary files /dev/null and b/resources/Visu_point_selection.png differ diff --git a/resources/Visu_selection_panel.png b/resources/Visu_selection_panel.png new file mode 100644 index 00000000..4c95efe1 Binary files /dev/null and b/resources/Visu_selection_panel.png differ diff --git a/src/OBJECT/Makefile.am b/src/OBJECT/Makefile.am index 3dcac5f0..60acb9b0 100644 --- a/src/OBJECT/Makefile.am +++ b/src/OBJECT/Makefile.am @@ -31,6 +31,7 @@ lib_LTLIBRARIES= libVisuObject.la salomeinclude_HEADERS = \ VISU_BoostSignals.h \ VISU_ActorFactory.h \ + VISU_PickingSettings.h \ VISU_GaussPtsSettings.h \ VISU_GaussPtsActorFactory.h \ VISU_Event.h \ @@ -46,6 +47,7 @@ dist_libVisuObject_la_SOURCES = \ VISU_DataSetActor.cxx \ VISU_MeshAct.cxx \ VISU_ScalarMapAct.cxx \ + VISU_PickingSettings.cxx \ VISU_GaussPtsDeviceActor.cxx \ VISU_GaussPtsSettings.cxx \ VISU_GaussPtsAct.cxx \ diff --git a/src/OBJECT/VISU_Actor.cxx b/src/OBJECT/VISU_Actor.cxx index 8d448e7f..58c84091 100644 --- a/src/OBJECT/VISU_Actor.cxx +++ b/src/OBJECT/VISU_Actor.cxx @@ -27,7 +27,14 @@ // $Header$ #include "VISU_Actor.h" + +#include "VISU_PickingSettings.h" +#include "VISU_GaussPtsDeviceActor.h" + #include "VISU_PipeLine.hxx" + +#include "SVTK_Event.h" + #include "VTKViewer_ShrinkFilter.h" #include "VTKViewer_GeometryFilter.h" #include "SALOME_InteractiveObject.hxx" @@ -58,6 +65,10 @@ #include #include +#include +#include +#include + #include #include "utilities.h" @@ -82,6 +93,8 @@ static int MYDEBUG = 0; //---------------------------------------------------------------------------- VISU_Actor ::VISU_Actor(): + myEventCallbackCommand(vtkCallbackCommand::New()), + myPriority(0.0), myIsVTKMapping(false), myPrs3d(NULL), myActorFactory(NULL), @@ -89,7 +102,10 @@ VISU_Actor myIsShrinkable(false), myShrinkFilter(VTKViewer_ShrinkFilter::New()), myAnnotationMapper(vtkTextMapper::New()), - myAnnotationActor(vtkTextActor::New()) + myAnnotationActor(vtkTextActor::New()), + myTextActor(VISU_FramedTextActor::New()), + myLastSelectionMode(ActorSelection), + myIsSubElementsHighlighted(false) { if(MYDEBUG) MESSAGE("VISU_Actor::VISU_Actor - this = "<Delete(); myAnnotationActor->SetVisibility(0); + + myTextActor->Delete(); + myTextActor->SetVisibility(false); + myTextActor->SetPickable(false); + + myEventCallbackCommand->Delete(); + myEventCallbackCommand->SetClientData(this); + myEventCallbackCommand->SetCallback(VISU_Actor::ProcessEvents); + + if( VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get() ) + aPickingSettings->AddObserver(VISU::UpdatePickingSettingsEvent, + myEventCallbackCommand.GetPointer(), + myPriority); } //---------------------------------------------------------------------------- @@ -358,6 +387,7 @@ VISU_Actor { Superclass::AddToRender(theRenderer); theRenderer->AddActor(myAnnotationActor.GetPointer()); + theRenderer->AddActor(myTextActor.GetPointer()); } //================================================================== @@ -369,6 +399,7 @@ VISU_Actor ::RemoveFromRender(vtkRenderer* theRenderer) { theRenderer->RemoveActor(myAnnotationActor.GetPointer()); + theRenderer->RemoveActor(myTextActor.GetPointer()); Superclass::RemoveFromRender(theRenderer); myDestroySignal(this); } @@ -486,6 +517,86 @@ VISU_Actor //---------------------------------------------------------------------------- bool VISU_Actor +::isSubElementsHighlighted() +{ + return myIsSubElementsHighlighted; +} + + +//---------------------------------------------------------------------------- +inline +void +ChangeZoom(vtkFloatingPointType theZoomFactor, + vtkRenderer* theRenderer, + vtkIdType theInitialHasIndex, + vtkIdType theCurrentHasIndex) +{ + //printf( "VISU_Actor::ChangeZoom( %d, %d )", theInitialHasIndex, theCurrentHasIndex ); + if(theInitialHasIndex + theCurrentHasIndex == 1){ + vtkCamera *aCamera = theRenderer->GetActiveCamera(); + + double aScale = aCamera->GetParallelScale(); + if ( !theInitialHasIndex && theCurrentHasIndex ) { + //printf( " : +%f", theZoomFactor ); + aCamera->SetParallelScale( aScale / theZoomFactor ); + } + else { + //printf( " - +%f", theZoomFactor ); + aCamera->SetParallelScale( aScale * theZoomFactor ); + } + } + //printf( "\n" ); +} + +/*! + Updates visibility of the highlight devices +*/ +void +VISU_Actor +::highlight(bool theIsHighlight) +{ + //printf( "VISU_Actor::highlight( %d )\n", (int)theIsHighlight ); + VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); + + bool aShowTextActor = /*aPickingSettings->GetIsActive() && */aPickingSettings->GetInfoWindowEnabled(); + if( theIsHighlight && mySelectionMode != myLastSelectionMode ) + { + if( mySelectionMode == ActorSelection ) + ResetTextActor(); + else + aShowTextActor = false; + myLastSelectionMode = mySelectionMode; + } + + myTextActor->SetVisibility( GetVisibility() && theIsHighlight && aShowTextActor ); + + bool anInitialHasIndex = isHighlighted(); + bool aCurrentHasIndex = theIsHighlight; + + vtkFloatingPointType aZoomFactor = aPickingSettings->GetZoomFactor(); + if( !theIsHighlight && mySelectionMode == ActorSelection && isSubElementsHighlighted() ) + { + aZoomFactor *= aZoomFactor; + myIsSubElementsHighlighted = false; + } + + // Zoom + if( GetVisibility() && aPickingSettings->GetCameraMovementEnabled() ) + { + ChangeZoom(aZoomFactor, + GetRenderer(), + anInitialHasIndex, + aCurrentHasIndex); + } + + Superclass::highlight(theIsHighlight); +} + +/*! + To process prehighlight (called from SVTK_InteractorStyle) +*/ +bool +VISU_Actor ::PreHighlight(vtkInteractorStyle* theInteractorStyle, SVTK_SelectionEvent* theSelectionEvent, bool theIsHighlight) @@ -509,7 +620,7 @@ VISU_Actor if(myCellPicker->GetActor() != this) return false; - + vtkIdType aVTKId = myCellPicker->GetCellId(); if(aVTKId >= 0 && mySelector->IsValid(this,aVTKId,true) && hasIO()){ vtkIdType anObjId = GetElemObjId(aVTKId); @@ -550,7 +661,7 @@ VISU_Actor theSelectionEvent->myY, 0.0, aRenderer); - + if(myPointPicker->GetActor() != this) return false; @@ -587,3 +698,314 @@ VISU_Actor return aRet; } + +//---------------------------------------------------------------------------- +template std::string getScalar(TData* theData, int theId) +{ + std::ostringstream aStr; + if (vtkDataArray *aScalar = theData->GetScalars()){ + vtkFloatingPointType aVal = aScalar->GetTuple1(theId); + aStr << "\nScalar: " << aVal; + } + return aStr.str(); +} + +template std::string getVector(TData* theData, int theId) +{ + std::ostringstream aStr; + if (vtkDataArray *aVector = theData->GetVectors()) { + vtkFloatingPointType *aVal = aVector->GetTuple3(theId); + aStr << "\nVector: " << "{" << aVal[0] << "; " << aVal[1] << "; " << aVal[2] << "}"; + } + return aStr.str(); +} + +/*! + To process highlight (called from SVTK_InteractorStyle) +*/ +bool +VISU_Actor +::Highlight(vtkInteractorStyle* theInteractorStyle, + SVTK_SelectionEvent* theSelectionEvent, + bool theIsHighlight) +{ + //printf( "VISU_Actor::Highlight( %d )\n", (int)theIsHighlight ); + bool aRet = Superclass::Highlight(theInteractorStyle, + theSelectionEvent, + theIsHighlight); + + VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); + + bool anInitialHasIndex = isSubElementsHighlighted() && mySelectionMode != ActorSelection; + + TColStd_IndexedMapOfInteger aMapIndex; + mySelector->GetIndex( getIO(), aMapIndex ); + bool aCurrentHasIndex = aMapIndex.Extent() == 1; + + myIsSubElementsHighlighted = theIsHighlight ? aCurrentHasIndex : false; + + vtkFloatingPointType aFlyToCoord[3] = { 0.0, 0.0, 0.0 }; + vtkRenderer* aRenderer = theInteractorStyle->GetCurrentRenderer(); + + if(theIsHighlight){ + vtkDataSet* aDataSet = GetMapper()->GetInput(); + switch(mySelectionMode){ + case ActorSelection:{ + vtkFloatingPointType aCoord[6]; + GetBounds(aCoord); + + aFlyToCoord[0] = ( aCoord[0] + aCoord[1] ) / 2; + aFlyToCoord[1] = ( aCoord[2] + aCoord[3] ) / 2; + aFlyToCoord[2] = ( aCoord[4] + aCoord[5] ) / 2; + + ResetTextActor(); + + aRet = true; + break; + } + case CellSelection:{ + myCellPicker->Pick(theSelectionEvent->myX, + theSelectionEvent->myY, + 0.0, + aRenderer); + + if(myCellPicker->GetActor() != this) + { + aRet = false; + break; + } + + vtkCellData* aCellData = aDataSet->GetCellData(); + + vtkIdType aVTKId = myCellPicker->GetCellId(); + if(aVTKId >= 0 && mySelector->IsValid(this,aVTKId,true) && hasIO()){ + vtkIdType anObjId = GetElemObjId(aVTKId); + if(vtkCell* aCell = GetElemCell(anObjId)){ + vtkPoints* aPts = aCell->GetPoints(); + if(int aNbPts = aCell->GetNumberOfPoints()){ + vtkFloatingPointType aCoord[3] = {0.0, 0.0, 0.0}; + for(int i = 0; i < aNbPts; i++){ + vtkFloatingPointType *aPntCoord = aPts->GetPoint(i); + aCoord[0] += aPntCoord[0]; + aCoord[1] += aPntCoord[1]; + aCoord[2] += aPntCoord[2]; + } + + aFlyToCoord[0] = aCoord[0] / aNbPts; + aFlyToCoord[1] = aCoord[1] / aNbPts; + aFlyToCoord[2] = aCoord[2] / aNbPts; + + vtkFloatingPointType aWorldCoord[4] = {aCoord[0]/aNbPts, aCoord[1]/aNbPts, aCoord[2]/aNbPts, 1.0}; + aRenderer->SetWorldPoint(aWorldCoord); + aRenderer->WorldToDisplay(); + vtkFloatingPointType aSelectionPoint[3]; + aRenderer->GetDisplayPoint(aSelectionPoint); + myTextActor->SetPosition(aSelectionPoint); + myTextActor->SetModePosition(aPickingSettings->GetInfoWindowPosition()); + myTextActor->SetTransparency(aPickingSettings->GetInfoWindowTransparency()); + myTextActor->SetWorldPoint(aWorldCoord); + + std::ostringstream aStr; + aStr << "Cell ID: " << anObjId; + + vtkCell* aCell = GetElemCell(anObjId); + int aVTKID = GetElemVTKID(anObjId); + if (aCell) { + int aNbOfPoints = aCell->GetNumberOfPoints(); + if ( aNbOfPoints > 0 ) { + aStr << getScalar(aCellData, aVTKID); + aStr << getVector(aCellData, aVTKID); + } + } + + std::string aString = aStr.str(); + myTextActor->SetText(aString.c_str()); + + aRet = true; + } + } + } + break; + } + case NodeSelection:{ + myPointPicker->Pick(theSelectionEvent->myX, + theSelectionEvent->myY, + 0.0, + aRenderer); + + if(myPointPicker->GetActor() != this) + { + aRet = false; + break; + } + + vtkPointData* aPntData = aDataSet->GetPointData(); + + vtkIdType aVtkId = myPointPicker->GetPointId(); + if(aVtkId >= 0 && mySelector->IsValid(this,aVtkId,true) && hasIO()){ + vtkIdType anObjId = GetNodeObjId( aVtkId ); + if(vtkFloatingPointType* aCoord = GetNodeCoord(anObjId)){ + aFlyToCoord[0] = aCoord[0]; + aFlyToCoord[1] = aCoord[1]; + aFlyToCoord[2] = aCoord[2]; + + vtkFloatingPointType aWorldCoord[4] = {aCoord[0], aCoord[1], aCoord[2], 1.0}; + aRenderer->SetWorldPoint(aWorldCoord); + aRenderer->WorldToDisplay(); + vtkFloatingPointType aSelectionPoint[3]; + aRenderer->GetDisplayPoint(aSelectionPoint); + myTextActor->SetPosition(aSelectionPoint); + myTextActor->SetModePosition(aPickingSettings->GetInfoWindowPosition()); + myTextActor->SetTransparency(aPickingSettings->GetInfoWindowTransparency()); + myTextActor->SetWorldPoint(aWorldCoord); + + std::ostringstream aStr; + aStr << "Point ID: " << anObjId; + + int aVTKID = GetNodeVTKID(anObjId); + if(aVTKID >= 0) { + aStr << getScalar(aPntData, aVTKID); + aStr << getVector(aPntData, aVTKID); + } + + const VISU::PIDMapper& aMapper = GetPipeLine()->GetIDMapper(); + VISU::TIdTypeVector aVec = aMapper->GetIndexesOfNode(anObjId); + + aStr << "\nCoordinates: " << "["; + aStr << aCoord[0]; + if( aVec.size() > 0 ) + aStr << " (" << aVec[0] << ")"; + aStr << "; "; + + aStr << aCoord[1]; + if( aVec.size() > 1 ) + aStr << " (" << aVec[1] << ")"; + aStr << "; "; + + aStr << aCoord[2]; + if( aVec.size() > 2 ) + aStr << " (" << aVec[2] << ")"; + aStr << "]"; + + std::string aString = aStr.str(); + myTextActor->SetText(aString.c_str()); + + aRet = true; + } + } + break; + } + case EdgeOfCellSelection: + break; + default: + break; + } + } + + // Zoom + if( GetVisibility() && aPickingSettings->GetCameraMovementEnabled() ) + { + vtkFloatingPointType aZoomFactor = aPickingSettings->GetZoomFactor(); + ChangeZoom(aZoomFactor, + GetRenderer(), + anInitialHasIndex, + aCurrentHasIndex); + } + + // FlyTo + if( GetVisibility() && aPickingSettings->GetCameraMovementEnabled() ) + { + vtkRenderWindowInteractor* anInteractor = myInteractor; + vtkFloatingPointType aDollyWas = anInteractor->GetDolly(); + int aNumberOfFlyFramesWas = anInteractor->GetNumberOfFlyFrames(); + + anInteractor->SetDolly(0.0); + anInteractor->SetNumberOfFlyFrames(aPickingSettings->GetStepNumber()); + anInteractor->FlyTo(aRenderer, aFlyToCoord); + aRenderer->ResetCameraClippingRange(); + anInteractor->SetDolly(aDollyWas); + anInteractor->SetNumberOfFlyFrames(aNumberOfFlyFramesWas); + anInteractor->InvokeEvent(SVTK::ChangeRotationPoint, aFlyToCoord); + } + + return aRet; +} + +//------------------------------------------------------------------------- +void +VISU_Actor +::Highlight(bool theIsHighlight) +{ + Superclass::Highlight(theIsHighlight); +} + +//------------------------------------------------------------------------- +void +VISU_Actor +::ResetTextActor() +{ + VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); + + vtkFloatingPointType aCoord[6]; + GetBounds(aCoord); + + vtkFloatingPointType aWorldCoord[4] = { ( aCoord[0] + aCoord[1] ) / 2, + ( aCoord[2] + aCoord[3] ) / 2, + ( aCoord[4] + aCoord[5] ) / 2, 1.0}; + vtkRenderer* aRenderer = GetRenderer(); + aRenderer->SetWorldPoint(aWorldCoord); + aRenderer->WorldToDisplay(); + vtkFloatingPointType aSelectionPoint[3]; + aRenderer->GetDisplayPoint(aSelectionPoint); + myTextActor->SetPosition(aSelectionPoint); + myTextActor->SetModePosition(aPickingSettings->GetInfoWindowPosition()); + myTextActor->SetTransparency(aPickingSettings->GetInfoWindowTransparency()); + myTextActor->SetWorldPoint(aWorldCoord); + + std::ostringstream aStr; + /* + if( const char* aName = getName() ) + aStr << aName << "\n"; + */ + aStr << "Position: " << "[" << aCoord[0] << "; " << aCoord[2] << "; " << aCoord[4] << "]"; + aStr << "\nSize: " << "[" << + fabs(aCoord[1]-aCoord[0]) << "; " << + fabs(aCoord[3]-aCoord[2]) << "; " << + fabs(aCoord[5]-aCoord[4]) << "]"; + + std::string aString = aStr.str(); + myTextActor->SetText(aString.c_str()); +} + +//------------------------------------------------------------------------- +void +VISU_Actor +::ProcessEvents(vtkObject* vtkNotUsed(theObject), + unsigned long theEvent, + void* theClientData, + void* vtkNotUsed(theCallData)) +{ + if(vtkObject* anObject = reinterpret_cast(theClientData)) + if(VISU_Actor* self = dynamic_cast(anObject)) { + if(theEvent == VISU::UpdatePickingSettingsEvent) + self->UpdatePickingSettings(); + } +} + +//---------------------------------------------------------------------------- +void +VISU_Actor +::UpdatePickingSettings() +{ + //printf( "VISU_Actor::UpdatePickingSettings()\n" ); + VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); + if( !aPickingSettings ) + return; + + myTextActor->SetModePosition(aPickingSettings->GetInfoWindowPosition()); + myTextActor->SetTransparency(aPickingSettings->GetInfoWindowTransparency()); + + highlight(isHighlighted()); + + Update(); +} diff --git a/src/OBJECT/VISU_Actor.h b/src/OBJECT/VISU_Actor.h index 96289417..8377ec94 100644 --- a/src/OBJECT/VISU_Actor.h +++ b/src/OBJECT/VISU_Actor.h @@ -43,9 +43,12 @@ class vtkProperty; class vtkTextMapper; class vtkTextActor; class vtkInteractorStyle; +class vtkCallbackCommand; class VTKViewer_ShrinkFilter; class VISU_PipeLine; +class VISU_FramedTextActor; + #ifdef _WIN32 #define VTKOCC_EXPORT __declspec (dllexport) #else @@ -186,12 +189,30 @@ class VTKOCC_EXPORT VISU_Actor : RemoveFromRender( vtkRenderer* ); //---------------------------------------------------------------------------- + //! Just to update visibility of the highlight devices + virtual + void + highlight(bool theHighlight); + + //! To process prehighlight (called from #SVTK_InteractorStyle) virtual bool PreHighlight(vtkInteractorStyle* theInteractorStyle, SVTK_SelectionEvent* theSelectionEvent, bool theIsHighlight); + //! To process highlight (called from #SVTK_InteractorStyle) + virtual + bool + Highlight(vtkInteractorStyle* theInteractorStyle, + SVTK_SelectionEvent* theSelectionEvent, + bool theIsHighlight); + + //! Internal highlight. + virtual + void + Highlight(bool theIsHighlight); + virtual void SetVTKMapping(bool theIsVTKMapping); @@ -234,6 +255,11 @@ class VTKOCC_EXPORT VISU_Actor : vtkCell* GetElemCell(vtkIdType theObjID); + //---------------------------------------------------------------------------- + //! Apply the picking settings on the actor. + void + UpdatePickingSettings(); + //---------------------------------------------------------------------------- protected: VISU_Actor(); @@ -250,6 +276,28 @@ class VTKOCC_EXPORT VISU_Actor : GetCurrentPL(); //---------------------------------------------------------------------------- + bool + isSubElementsHighlighted(); + + //---------------------------------------------------------------------------- + vtkSmartPointer myEventCallbackCommand; + + //! Main process VTK event method + static + void + ProcessEvents(vtkObject* theObject, + unsigned long theEvent, + void* theClientData, + void* theCallData); + + //---------------------------------------------------------------------------- + private: + void + ResetTextActor(); + + //---------------------------------------------------------------------------- + protected: + vtkFloatingPointType myPriority; bool myIsVTKMapping; VISU::Prs3d_i* myPrs3d; vtkSmartPointer myPipeLine; @@ -264,6 +312,11 @@ class VTKOCC_EXPORT VISU_Actor : vtkSmartPointer myAnnotationMapper; vtkSmartPointer myAnnotationActor; + + vtkSmartPointer myTextActor; + + Selection_Mode myLastSelectionMode; + bool myIsSubElementsHighlighted; }; #endif //VISU_ACTOR_H diff --git a/src/OBJECT/VISU_GaussPtsAct.cxx b/src/OBJECT/VISU_GaussPtsAct.cxx index 8d30e245..e5eadc85 100644 --- a/src/OBJECT/VISU_GaussPtsAct.cxx +++ b/src/OBJECT/VISU_GaussPtsAct.cxx @@ -30,6 +30,7 @@ #include "VISU_GaussPointsPL.hxx" #include "VISU_GaussPtsSettings.h" #include "VISU_GaussPtsDeviceActor.h" +#include "VISU_PickingSettings.h" #include "VISU_WidgetCtrl.hxx" #include "VISU_SphereWidget.hxx" #include "VISU_OpenGLPointSpriteMapper.hxx" @@ -122,14 +123,12 @@ VISU_GaussPtsAct myWidgetCtrl(NULL), myGaussPointsPL(NULL), myLastPreHighlightObjID(-1), - myTextActor(VISU_FramedTextActor::New()), myCursorPyramid(VISU_CursorPyramid::New()), myCursorPyramidSelected(VISU_CursorPyramid::New()), myCellSource(vtkUnstructuredGrid::New()), myCellActor(SVTK_Actor::New()), myScalarBarCtrl(VISU_ScalarBarCtrl::New()), myBarVisibility(true), - myPickingSettings(NULL), myInsideCursorSettings(NULL), myCurrentPL(NULL), myMapper(vtkPolyDataMapper::New()) @@ -138,7 +137,6 @@ VISU_GaussPtsAct myEventCallbackCommand->Delete(); myDeviceActor->Delete(); - myTextActor->Delete(); myCursorPyramid->Delete(); myCursorPyramid->SetPickable(0); @@ -158,9 +156,6 @@ VISU_GaussPtsAct myDeviceActor->SetVisibility(true); myDeviceActor->SetPickable(false); - myTextActor->SetVisibility(false); - myTextActor->SetPickable(false); - myCellSource->Allocate(); myCellActor->Initialize(); myCellActor->SetRepresentation(VTK_WIREFRAME); @@ -174,6 +169,11 @@ VISU_GaussPtsAct myScalarBarCtrl->Delete(); myMapper->Delete(); + + if( VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get() ) + aPickingSettings->AddObserver(VISU::UpdatePickingSettingsEvent, + myEventCallbackCommand.GetPointer(), + myPriority); } VISU_GaussPtsAct @@ -182,7 +182,6 @@ VISU_GaussPtsAct if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::~VISU_GaussPtsAct - this = "<AddToRender(theRenderer); - theRenderer->AddActor(myTextActor.GetPointer()); theRenderer->AddActor(myCellActor.GetPointer()); myCursorPyramid->AddToRender(theRenderer); myCursorPyramidSelected->AddToRender(theRenderer); myScalarBarCtrl->AddToRender(theRenderer); - - SetPickingSettings( VISU_PickingSettings::Get() ); } void @@ -309,7 +305,6 @@ VISU_GaussPtsAct myDeviceActor->RemoveFromRender(theRenderer); - theRenderer->RemoveActor(myTextActor.GetPointer()); theRenderer->RemoveActor(myCellActor.GetPointer()); myCursorPyramid->RemoveFromRender(theRenderer); @@ -717,6 +712,8 @@ VISU_GaussPtsAct bool anIsChanged = (mySelectionMode != aSelectionMode); bool anIsPreselected = myIsPreselected; myIsPreselected = false; + + VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); if(aSelectionMode == GaussPointSelection && theIsHighlight){ myPointPicker->Pick(theSelectionEvent->myX, @@ -739,7 +736,7 @@ VISU_GaussPtsAct vtkDataSet* aDataSet = GetInput(); vtkPointData* aPointData = aDataSet->GetPointData(); if(vtkDataArray *aScalarArray = aPointData->GetScalars()){ - vtkFloatingPointType aPyramidHeight = myPickingSettings->GetPyramidHeight(); + vtkFloatingPointType aPyramidHeight = aPickingSettings->GetPyramidHeight(); aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize(); //vtkFloatingPointType aColor[3] = myPreHighlightActor->GetProperty()->GetColor(); vtkFloatingPointType aColor[3]; @@ -749,7 +746,7 @@ VISU_GaussPtsAct aColor[2] = 1. - aColor[2]; myCursorPyramid->Init(aPyramidHeight, - myPickingSettings->GetCursorSize(), + aPickingSettings->GetCursorSize(), GetRadius(anObjId,aVtkId,aScalarArray), GetMagnification(anObjId), GetClamp(anObjId), @@ -799,12 +796,13 @@ VISU_GaussPtsAct SVTK_SelectionEvent* theSelectionEvent, bool theIsHighlight) { + //printf( "VISU_GaussPtsAct::Highlight( %d )\n", (int)theIsHighlight ); if ( !GetPickable() ) return false; - // int anInitialHasIndex = myIsHighlighted && mySelectionMode == GaussPointSelection; + // int anInitialHasIndex = myIsSubElementsHighlighted && mySelectionMode == GaussPointSelection; Handle(SALOME_InteractiveObject) anIO = getIO(); - // myIsHighlighted = false; + // myIsSubElementsHighlighted = false; Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode; @@ -916,7 +914,7 @@ VISU_GaussPtsAct Selection_Mode aSelectionMode = mySelector->SelectionMode(); - bool anInitialHasIndex = isHighlighted() && mySelectionMode == GaussPointSelection; + bool anInitialHasIndex = isSubElementsHighlighted() && mySelectionMode == GaussPointSelection; TColStd_IndexedMapOfInteger aMapIndex; mySelector->GetIndex( getIO(), aMapIndex ); @@ -932,10 +930,12 @@ VISU_GaussPtsAct myCursorPyramidSelected->SetVisibility(anIsVisible); //GetScalarBarCtrl()->Update(); - myIsHighlighted = aCurrentHasIndex; + myIsSubElementsHighlighted = aCurrentHasIndex; + + VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); // Zoom if necessary - ChangeZoom(myPickingSettings, + ChangeZoom(aPickingSettings, GetRenderer(), anInitialHasIndex, aCurrentHasIndex); @@ -978,7 +978,7 @@ VISU_GaussPtsAct int aNumberOfFlyFramesWas = anInteractor->GetNumberOfFlyFrames(); anInteractor->SetDolly(0.0); - anInteractor->SetNumberOfFlyFrames(myPickingSettings->GetStepNumber()); + anInteractor->SetNumberOfFlyFrames(aPickingSettings->GetStepNumber()); anInteractor->FlyTo(aRenderer, aNodeCoord); aRenderer->ResetCameraClippingRange(); anInteractor->SetDolly(aDollyWas); @@ -1004,10 +1004,10 @@ VISU_GaussPtsAct GetScalarBarCtrl()->SetMarkValue(aVal); GetScalarBarCtrl()->Update(); // - vtkFloatingPointType aPyramidHeight = myPickingSettings->GetPyramidHeight(); + vtkFloatingPointType aPyramidHeight = aPickingSettings->GetPyramidHeight(); aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize(); myCursorPyramidSelected->Init(aPyramidHeight, - myPickingSettings->GetCursorSize(), + aPickingSettings->GetCursorSize(), GetRadius(anObjId,aVtkId,aScalarArray), GetMagnification(anObjId), GetClamp(anObjId), @@ -1049,14 +1049,14 @@ VISU_GaussPtsAct // // myTextActor std::string aString = aStr.str(); - myTextActor->SetModePosition(myPickingSettings->GetInfoWindowPosition()); - myTextActor->SetTransparency(myPickingSettings->GetInfoWindowTransparency()); + myTextActor->SetModePosition(aPickingSettings->GetInfoWindowPosition()); + myTextActor->SetTransparency(aPickingSettings->GetInfoWindowTransparency()); myTextActor->SetWorldPoint(aWorldCoord); myTextActor->SetText(aString.c_str()); myTextActor->SetVisibility(anIsVisible && theIsHighlight); // // myCellActor - if(myPickingSettings->GetDisplayParentMesh()){ + if(aPickingSettings->GetDisplayParentMesh()){ const VISU::PGaussPtsIDMapper& aGaussPtsIDMapper = myGaussPointsPL->GetGaussPtsIDMapper(); VISU::TNamedIDMapper* aParent = aGaussPtsIDMapper->GetParent(); @@ -1076,46 +1076,25 @@ VISU_GaussPtsAct } } - -//---------------------------------------------------------------- -void -VISU_GaussPtsAct -::SetPickingSettings(VISU_PickingSettings* thePickingSettings) -{ - if(myPickingSettings == thePickingSettings) - return; - - if(myPickingSettings) - myPickingSettings->RemoveObserver(myEventCallbackCommand.GetPointer()); - - myPickingSettings = thePickingSettings; - - if(thePickingSettings) - { - thePickingSettings->AddObserver(VISU::UpdatePickingSettingsEvent, - myEventCallbackCommand.GetPointer(), - myPriority); - this->UpdatePickingSettings(); - } -} - void VISU_GaussPtsAct ::UpdatePickingSettings() { - if(!myPickingSettings || myPickingSettings->GetInitial()) + //printf( "VISU_GaussPtsAct::UpdatePickingSettings()\n" ); + VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); + if(!aPickingSettings) return; - myTextActor->SetModePosition(myPickingSettings->GetInfoWindowPosition()); - myTextActor->SetTransparency(myPickingSettings->GetInfoWindowTransparency()); + myTextActor->SetModePosition(aPickingSettings->GetInfoWindowPosition()); + myTextActor->SetTransparency(aPickingSettings->GetInfoWindowTransparency()); - vtkFloatingPointType aHeight = myGaussPointsPL->GetMaxPointSize()*myPickingSettings->GetPyramidHeight(); - vtkFloatingPointType aCursorSize = myPickingSettings->GetCursorSize(); + vtkFloatingPointType aHeight = myGaussPointsPL->GetMaxPointSize()*aPickingSettings->GetPyramidHeight(); + vtkFloatingPointType aCursorSize = aPickingSettings->GetCursorSize(); myCursorPyramid->SetPreferences(aHeight,aCursorSize); myCursorPyramidSelected->SetPreferences(aHeight,aCursorSize); - myHighlightActor->GetProperty()->SetColor( myPickingSettings->GetColor() ); - myPointPicker->SetTolerance( myPickingSettings->GetPointTolerance() ); + myHighlightActor->GetProperty()->SetColor( aPickingSettings->GetColor() ); + myPointPicker->SetTolerance( aPickingSettings->GetPointTolerance() ); Highlight(isHighlighted()); diff --git a/src/OBJECT/VISU_GaussPtsAct.h b/src/OBJECT/VISU_GaussPtsAct.h index 5cf5086f..b4105a2b 100644 --- a/src/OBJECT/VISU_GaussPtsAct.h +++ b/src/OBJECT/VISU_GaussPtsAct.h @@ -60,7 +60,6 @@ class vtkInteractorObserver; class vtkCallbackCommand; class VISU_ScalarBarCtrl; -class VISU_PickingSettings; class VISU_InsideCursorSettings; class VISU_OutsideCursorSettings; @@ -232,9 +231,6 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_Actor UpdateInsideCursorSettings( PDeviceActor ); //---------------------------------------------------------------------------- - void - SetPickingSettings(VISU_PickingSettings* thePickingSettings); - //! Apply the picking settings on the actor. void UpdatePickingSettings(); @@ -318,8 +314,6 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_Actor vtkIdType myLastPreHighlightObjID; - vtkSmartPointer myTextActor; - vtkSmartPointer myCursorPyramid; vtkSmartPointer myCursorPyramidSelected; @@ -330,7 +324,6 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_Actor vtkSmartPointer myScalarBarCtrl; VISU_InsideCursorSettings* myInsideCursorSettings; - VISU_PickingSettings* myPickingSettings; }; diff --git a/src/OBJECT/VISU_GaussPtsDeviceActor.cxx b/src/OBJECT/VISU_GaussPtsDeviceActor.cxx index c4b084da..92586516 100644 --- a/src/OBJECT/VISU_GaussPtsDeviceActor.cxx +++ b/src/OBJECT/VISU_GaussPtsDeviceActor.cxx @@ -586,7 +586,7 @@ VISU_FramedTextActor::VISU_FramedTextActor() myTextProperty->SetFontFamilyToArial(); // myTextMapper=vtkTextMapper::New(); - myTextMapper->SetInput("some text"); + myTextMapper->SetInput(""); myTextMapper->GetTextProperty()->ShallowCopy(myTextProperty); myTextActor=vtkActor2D::New(); myTextActor->SetMapper(myTextMapper); diff --git a/src/OBJECT/VISU_GaussPtsSettings.cxx b/src/OBJECT/VISU_GaussPtsSettings.cxx index 196e5c6c..1518c8ee 100644 --- a/src/OBJECT/VISU_GaussPtsSettings.cxx +++ b/src/OBJECT/VISU_GaussPtsSettings.cxx @@ -28,6 +28,9 @@ #include "VISU_GaussPtsSettings.h" +#include "SUIT_ResourceMgr.h" +#include "SUIT_Session.h" + #include #include @@ -35,7 +38,6 @@ vtkStandardNewMacro( VISU_GaussPtsSettings ); vtkStandardNewMacro( VISU_InsideCursorSettings ); vtkStandardNewMacro( VISU_OutsideCursorSettings ); -vtkStandardNewMacro( VISU_PickingSettings ); //---------------------------------------------------------------- VISU_GaussPtsSettings::VISU_GaussPtsSettings() @@ -82,31 +84,3 @@ VISU_OutsideCursorSettings::VISU_OutsideCursorSettings() : VISU_OutsideCursorSettings::~VISU_OutsideCursorSettings() { } - -//---------------------------------------------------------------- -VISU_PickingSettings* VISU_PickingSettings::Get() -{ - static VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::New(); - return aPickingSettings; -} - -VISU_PickingSettings::VISU_PickingSettings() -{ - this->Initial = true; - - this->PyramidHeight = -1; - this->CursorSize = -1; - this->PointTolerance = -1; - this->Color[0] = -1; - this->Color[1] = -1; - this->Color[2] = -1; - this->InfoWindowTransparency = -1; - this->InfoWindowPosition = -1; - this->ZoomFactor = -1; - this->StepNumber = -1; - this->DisplayParentMesh = false; -} - -VISU_PickingSettings::~VISU_PickingSettings() -{ -} diff --git a/src/OBJECT/VISU_GaussPtsSettings.h b/src/OBJECT/VISU_GaussPtsSettings.h index 3d738952..11435aeb 100644 --- a/src/OBJECT/VISU_GaussPtsSettings.h +++ b/src/OBJECT/VISU_GaussPtsSettings.h @@ -44,7 +44,6 @@ namespace VISU const vtkIdType UpdateFromSettingsEvent = vtkCommand::UserEvent + 100; const vtkIdType UpdateInsideSettingsEvent = vtkCommand::UserEvent + 101; const vtkIdType UpdateOutsideSettingsEvent = vtkCommand::UserEvent + 102; - const vtkIdType UpdatePickingSettingsEvent = vtkCommand::UserEvent + 103; } @@ -162,78 +161,4 @@ class VTKOCC_EXPORT VISU_OutsideCursorSettings : public VISU_GaussPtsSettings vtkFloatingPointType Color[3]; }; - -//! Class of Picking settings. -/*! - * Contains information about the following parameters: - * Cursor Pyramid height, Info Window transparency, - * Info Window position, Zoom factor on first selected point, - * Camera movement steps number and Display parent mesh. - * Used by Gauss Points Actor. - */ -class VTKOCC_EXPORT VISU_PickingSettings : public vtkObject -{ - public: - enum { BelowPoint = 0, TopLeftCorner }; - - public: - vtkTypeMacro( VISU_PickingSettings, vtkObject ); - - static - VISU_PickingSettings* - Get(); - - static - VISU_PickingSettings* - New(); - - vtkSetMacro( Initial, bool ); - vtkGetMacro( Initial, bool ); - - vtkSetMacro( PyramidHeight, vtkFloatingPointType ); - vtkGetMacro( PyramidHeight, vtkFloatingPointType ); - - vtkSetMacro( CursorSize, vtkFloatingPointType ); - vtkGetMacro( CursorSize, vtkFloatingPointType ); - - vtkSetVector3Macro( Color, vtkFloatingPointType ); - vtkGetVector3Macro( Color, vtkFloatingPointType ); - - vtkSetMacro( PointTolerance, vtkFloatingPointType ); - vtkGetMacro( PointTolerance, vtkFloatingPointType ); - - vtkSetMacro( InfoWindowTransparency, vtkFloatingPointType ); - vtkGetMacro( InfoWindowTransparency, vtkFloatingPointType ); - - vtkSetMacro( InfoWindowPosition, int ); - vtkGetMacro( InfoWindowPosition, int ); - - vtkSetMacro( ZoomFactor, vtkFloatingPointType ); - vtkGetMacro( ZoomFactor, vtkFloatingPointType ); - - vtkSetMacro( StepNumber, int ); - vtkGetMacro( StepNumber, int ); - - vtkSetMacro( DisplayParentMesh, bool ); - vtkGetMacro( DisplayParentMesh, bool ); - -private: - VISU_PickingSettings(); - virtual ~VISU_PickingSettings(); - -private: - bool Initial; - - vtkFloatingPointType PyramidHeight; - vtkFloatingPointType CursorSize; - vtkFloatingPointType PointTolerance; - vtkFloatingPointType Color[3]; - vtkFloatingPointType InfoWindowTransparency; - int InfoWindowPosition; - vtkFloatingPointType ZoomFactor; - int StepNumber; - bool DisplayParentMesh; -}; - - #endif diff --git a/src/OBJECT/VISU_PickingSettings.cxx b/src/OBJECT/VISU_PickingSettings.cxx new file mode 100644 index 00000000..ae295653 --- /dev/null +++ b/src/OBJECT/VISU_PickingSettings.cxx @@ -0,0 +1,90 @@ +// VISU OBJECT : interactive object for VISU entities implementation +// +// 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 : VISU_PickingSettings.cxx +// Author : Oleg UVAROV +// Module : VISU + +#include "VISU_PickingSettings.h" + +#include "SUIT_ResourceMgr.h" +#include "SUIT_Session.h" + +#include + +vtkStandardNewMacro( VISU_PickingSettings ); + +VISU_PickingSettings* VISU_PickingSettings::Get() +{ + static VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::New(); + + if( aPickingSettings->GetIsInitial() ) + { + SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr(); + + aPickingSettings->SetCursorSize( aResourceMgr->doubleValue( "VISU", "picking_cursor_size", 0.5 ) ); + aPickingSettings->SetPyramidHeight( aResourceMgr->doubleValue( "VISU", "picking_pyramid_height", 10.0 ) ); + aPickingSettings->SetPointTolerance( aResourceMgr->doubleValue( "VISU", "picking_point_tolerance", 0.1 ) ); + aPickingSettings->SetInfoWindowEnabled( aResourceMgr->booleanValue( "VISU", "picking_info_window", false ) ); + aPickingSettings->SetInfoWindowTransparency( aResourceMgr->integerValue( "VISU", "picking_transparency", 50 ) / 100.0 ); + aPickingSettings->SetInfoWindowPosition( aResourceMgr->integerValue( "VISU", "picking_position", VISU_PickingSettings::BelowPoint ) ); + aPickingSettings->SetCameraMovementEnabled( aResourceMgr->booleanValue( "VISU", "picking_camera_movement", false ) ); + aPickingSettings->SetZoomFactor( aResourceMgr->doubleValue( "VISU", "picking_zoom_factor", 1.5 ) ); + aPickingSettings->SetStepNumber( aResourceMgr->integerValue( "VISU", "picking_step_number", 10 ) ); + aPickingSettings->SetDisplayParentMesh( aResourceMgr->booleanValue( "VISU", "picking_display_parent_mesh", false ) ); + + QColor aSelectionColor = aResourceMgr->colorValue( "VISU", "picking_selection_color", Qt::yellow ); + vtkFloatingPointType aColor[3]; + aColor[0] = aSelectionColor.red() / 255.0; + aColor[1] = aSelectionColor.green() / 255.0; + aColor[2] = aSelectionColor.blue() / 255.0; + aPickingSettings->SetColor( aColor ); + + aPickingSettings->SetIsInitial( false ); + } + + return aPickingSettings; +} + +VISU_PickingSettings::VISU_PickingSettings() +{ + this->IsInitial = true; + + this->PyramidHeight = -1; + this->CursorSize = -1; + this->PointTolerance = -1; + this->Color[0] = -1; + this->Color[1] = -1; + this->Color[2] = -1; + this->InfoWindowEnabled = false; + this->InfoWindowTransparency = -1; + this->InfoWindowPosition = -1; + this->CameraMovementEnabled = false; + this->ZoomFactor = -1; + this->StepNumber = -1; + this->DisplayParentMesh = false; +} + +VISU_PickingSettings::~VISU_PickingSettings() +{ +} diff --git a/src/OBJECT/VISU_PickingSettings.h b/src/OBJECT/VISU_PickingSettings.h new file mode 100644 index 00000000..c5f30b38 --- /dev/null +++ b/src/OBJECT/VISU_PickingSettings.h @@ -0,0 +1,128 @@ +// VISU OBJECT : interactive object for VISU entities implementation +// +// 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 : VISU_PickingSettings.cxx +// Author : Oleg UVAROV +// Module : VISU + +#ifndef VISU_PickingSettings_HeaderFile +#define VISU_PickingSettings_HeaderFile + +#include +#include + +#include "VTKViewer.h" + +#include "VISU_Actor.h" + +//============================================================================ +namespace VISU +{ + const vtkIdType UpdatePickingSettingsEvent = vtkCommand::UserEvent + 103; +} + +//! Class of Picking settings. +/*! + * Contains information about the following parameters: + * Cursor Pyramid height, Info Window transparency, + * Info Window position, Zoom factor on first selected point, + * Camera movement steps number and Display parent mesh. + */ +class VTKOCC_EXPORT VISU_PickingSettings : public vtkObject +{ + public: + enum { BelowPoint = 0, TopLeftCorner }; + + public: + vtkTypeMacro( VISU_PickingSettings, vtkObject ); + + static + VISU_PickingSettings* + Get(); + + static + VISU_PickingSettings* + New(); + + vtkSetMacro( IsInitial, bool ); + vtkGetMacro( IsInitial, bool ); + + vtkSetMacro( PyramidHeight, vtkFloatingPointType ); + vtkGetMacro( PyramidHeight, vtkFloatingPointType ); + + vtkSetMacro( CursorSize, vtkFloatingPointType ); + vtkGetMacro( CursorSize, vtkFloatingPointType ); + + vtkSetVector3Macro( Color, vtkFloatingPointType ); + vtkGetVector3Macro( Color, vtkFloatingPointType ); + + vtkSetMacro( PointTolerance, vtkFloatingPointType ); + vtkGetMacro( PointTolerance, vtkFloatingPointType ); + + vtkSetMacro( InfoWindowEnabled, bool ); + vtkGetMacro( InfoWindowEnabled, bool ); + + vtkSetMacro( InfoWindowTransparency, vtkFloatingPointType ); + vtkGetMacro( InfoWindowTransparency, vtkFloatingPointType ); + + vtkSetMacro( InfoWindowPosition, int ); + vtkGetMacro( InfoWindowPosition, int ); + + vtkSetMacro( CameraMovementEnabled, bool ); + vtkGetMacro( CameraMovementEnabled, bool ); + + vtkSetMacro( ZoomFactor, vtkFloatingPointType ); + vtkGetMacro( ZoomFactor, vtkFloatingPointType ); + + vtkSetMacro( StepNumber, int ); + vtkGetMacro( StepNumber, int ); + + vtkSetMacro( DisplayParentMesh, bool ); + vtkGetMacro( DisplayParentMesh, bool ); + +private: + VISU_PickingSettings(); + virtual ~VISU_PickingSettings(); + +private: + bool IsInitial; + + vtkFloatingPointType PyramidHeight; + vtkFloatingPointType CursorSize; + + vtkFloatingPointType PointTolerance; + + vtkFloatingPointType Color[3]; + + bool InfoWindowEnabled; + vtkFloatingPointType InfoWindowTransparency; + int InfoWindowPosition; + + bool CameraMovementEnabled; + vtkFloatingPointType ZoomFactor; + int StepNumber; + + bool DisplayParentMesh; +}; + +#endif diff --git a/src/VISUGUI/VISU_images.ts b/src/VISUGUI/VISU_images.ts index 46aac25d..12a5e828 100644 --- a/src/VISUGUI/VISU_images.ts +++ b/src/VISUGUI/VISU_images.ts @@ -2,10 +2,26 @@ @default + + ICON_ACTOR_SELECTION + Visu_actor_selection.png + ICON_ADD Visu_add.png + + ICON_APPLY + Visu_apply.png + + + ICON_CELL_SELECTION + Visu_cell_selection.png + + + ICON_CLOSE + Visu_close.png + ICON_CUBE_AXES Visu_graduated_axes.png @@ -30,6 +46,10 @@ ICON_GAUSS_NEW_VIEWER Visu_points.png + + ICON_GAUSS_POINT_SELECTION + Visu_gauss_point_selection.png + ICON_GAUSS_POINTS Visu_gauss_points.png @@ -38,6 +58,10 @@ ICON_GLOBAL_SELECTION Visu_selectall.png + + ICON_HELP + Visu_help.png + ICON_HOLO_RENDER Visu_holo_render.png @@ -74,6 +98,10 @@ ICON_OBJBROWSER_Visu Visu_tree_visu.png + + ICON_OK + Visu_ok.png + ICON_PARTIAL_SELECTION Visu_selectonly.png @@ -86,6 +114,10 @@ ICON_PLOT_3D Visu_plot3d.png + + ICON_POINT_SELECTION + Visu_point_selection.png + ICON_POINTS Visu_points.png @@ -106,6 +138,10 @@ ICON_SCALING Visu_scaling.png + + ICON_SELECTION_PANEL + Visu_selection_panel.png + ICON_SLIDER_AVI Visu_slider_avi.png diff --git a/src/VISUGUI/VISU_msg_en.ts b/src/VISUGUI/VISU_msg_en.ts index ceacca2e..46313199 100644 --- a/src/VISUGUI/VISU_msg_en.ts +++ b/src/VISUGUI/VISU_msg_en.ts @@ -864,6 +864,10 @@ Please, refer to the documentation. IMPORT_FROM_FILE Import from File + + MEN_ACTOR_SELECTION + Actor Selection + MEN_ARRANGE_ACTORS Arrange Actors @@ -876,6 +880,10 @@ Please, refer to the documentation. MEN_CELL_COLOR Cell color + + MEN_CELL_SELECTION + Cell Selection + MEN_CLEAR_CONTAINER Clear @@ -980,6 +988,10 @@ Please, refer to the documentation. MEN_FREE_SCALAR_BARS Use Field Range + + MEN_GAUSS_POINT_SELECTION + Gauss Point Selection + MEN_GLOBAL_SELECTION Global Selection @@ -1068,6 +1080,10 @@ Please, refer to the documentation. MEN_PLOT_3D Plot3D + + MEN_POINT_SELECTION + Point Selection + MEN_POINTS Points @@ -1184,6 +1200,10 @@ Please, refer to the documentation. TOOL_REPRESENTATION Representation Toolbar + + TOOL_SELECTION + Selection Toolbar + TOOL_VISUALISATION Visualization Toolbar @@ -1900,7 +1920,7 @@ Please, provide non-empty resulting presentation. VisuGUI_GaussPointsSelectionPane BELOW_POINT - Centered below the point + Centered CAMERA_TITLE @@ -1947,8 +1967,12 @@ Please, provide non-empty resulting presentation. Selection cursor color : - STEP_NUMBER - Number of steps between two positions : + STEP_NUMBER_DSC + Number of steps : + + + STEP_NUMBER_TIP + Number of steps between two positions TOLERANCE_TITLE @@ -1956,15 +1980,19 @@ Please, provide non-empty resulting presentation. TOP_LEFT_CORNER - Top-left corner of the 3D view + Top-left corner TRANSPARENCY Transparency : - ZOOM_FACTOR - Zoom at first selected point (ratio) : + ZOOM_FACTOR_DSC + Zoom factor : + + + ZOOM_FACTOR_TIP + Zoom at first selected point (ratio) DATA_POSITION @@ -3158,7 +3186,7 @@ Please, refer to the documentation. VisuGUI_SelectionPanel WINDOW_TITLE - Data on elements + Selection info MODE_TITLE @@ -3232,6 +3260,46 @@ Please, refer to the documentation. ACTOR_DATA_SIZE_TITLE Size + + BELOW_POINT + Centered + + + CAMERA_TITLE + Movement of the camera + + + INFO_WINDOW_TITLE + Information window + + + POSITION + Position : + + + STEP_NUMBER_DSC + Number of steps : + + + STEP_NUMBER_TIP + Number of steps between two positions + + + TOP_LEFT_CORNER + Top-left corner + + + TRANSPARENCY + Transparency : + + + ZOOM_FACTOR_DSC + Zoom factor : + + + ZOOM_FACTOR_TIP + Zoom at first selected point (ratio) + VisuGUI_BarPrefDlg diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 3ce326cd..242de278 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -1787,8 +1787,6 @@ VisuGUI { if (GetActiveViewWindow(this)) { - if( !mySelectionPanel ) - mySelectionPanel = new VisuGUI_SelectionPanel( this ); inputPanel()->showPanel( mySelectionPanel ); } else @@ -1797,6 +1795,45 @@ VisuGUI tr("ERR_ACTIVATE_VIEW3D") ); } +//---------------------------------------------------------------------------- +void +VisuGUI +::OnToggleSelectionPanel() +{ + if (GetActiveViewWindow(this)) + { + VisuGUI_SelectionPanel* aSelectionPanel = selectionPanel(); + VisuGUI_InputPanel* anInputPanel = inputPanel(); + if( !anInputPanel->isShown( aSelectionPanel ) ) + anInputPanel->showPanel( aSelectionPanel ); + else + anInputPanel->hidePanel( aSelectionPanel ); + } + else + SUIT_MessageBox::warning(GetDesktop(this), + tr("WRN_VISU"), + tr("ERR_ACTIVATE_VIEW3D") ); +} + +//---------------------------------------------------------------------------- +void +VisuGUI +::OnSwitchSelectionMode() +{ + QAction* anAction = dynamic_cast( sender() ); + if( !anAction ) + return; + + for( int anId = VISU_ACTOR_SELECTION; anId <= VISU_GAUSS_POINT_SELECTION; anId++ ) + { + QAction* aRefAction = action( anId ); + if( anAction != aRefAction ) + aRefAction->setChecked( false ); + else + mySelectionPanel->setSelectionMode( anId - VISU_ACTOR_SELECTION ); + } +} + //---------------------------------------------------------------------------- void VisuGUI @@ -1948,7 +1985,12 @@ VisuGUI createMenus(); createToolBars(); createPopupMenus(); + createInputPanel(); + createSelectionPanel(); + + // tmp + action( VISU_ACTOR_SELECTION )->setChecked( true ); } void @@ -2265,6 +2307,31 @@ VisuGUI tr("MEN_PARTIAL_SELECTION"), "", 0, aParent, false, this); + aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SELECTION_PANEL")); + createAction( VISU_SELECTION_PANEL, tr("MEN_SELECTION_PANEL"), QIcon(aPixmap), + tr("MEN_SELECTION_PANEL"), "", 0, aParent, false, + this, SLOT(OnToggleSelectionPanel())); + + aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ACTOR_SELECTION")); + createAction( VISU_ACTOR_SELECTION, tr("MEN_ACTOR_SELECTION"), QIcon(aPixmap), + tr("MEN_ACTOR_SELECTION"), "", 0, aParent, true, + this, SLOT(OnSwitchSelectionMode())); + + aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CELL_SELECTION")); + createAction( VISU_CELL_SELECTION, tr("MEN_CELL_SELECTION"), QIcon(aPixmap), + tr("MEN_CELL_SELECTION"), "", 0, aParent, true, + this, SLOT(OnSwitchSelectionMode())); + + aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_POINT_SELECTION")); + createAction( VISU_POINT_SELECTION, tr("MEN_POINT_SELECTION"), QIcon(aPixmap), + tr("MEN_POINT_SELECTION"), "", 0, aParent, true, + this, SLOT(OnSwitchSelectionMode())); + + aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_GAUSS_POINT_SELECTION")); + createAction( VISU_GAUSS_POINT_SELECTION, tr("MEN_GAUSS_POINT_SELECTION"), QIcon(aPixmap), + tr("MEN_GAUSS_POINT_SELECTION"), "", 0, aParent, true, + this, SLOT(OnSwitchSelectionMode())); + createAction( VISU_SHOW_ANIMATION, tr("MEN_SHOW_ANIMATION"), QIcon(), tr("MEN_SHOW_ANIMATION"), "", 0, aParent, false, this, SLOT(OnShowAnimation())); @@ -2362,6 +2429,14 @@ VisuGUI createTool( VISU_ERASE_ALL, aToolId ); createTool( VISU_GLOBAL_SELECTION, aToolId ); createTool( VISU_PARTIAL_SELECTION, aToolId ); + + aToolId = createTool(tr("TOOL_SELECTION")); + createTool( VISU_SELECTION_PANEL, aToolId ); + createTool( separator(), aToolId ); + createTool( VISU_ACTOR_SELECTION, aToolId ); + createTool( VISU_CELL_SELECTION, aToolId ); + createTool( VISU_POINT_SELECTION, aToolId ); + createTool( VISU_GAUSS_POINT_SELECTION, aToolId ); } void @@ -2675,10 +2750,17 @@ VisuGUI void VisuGUI::createInputPanel() { myInputPanel = new VisuGUI_InputPanel(); + myInputPanel->hide(); //myInputPanel->resize( getApp()->objectBrowser()->width(), myInputPanel->height() ); GetDesktop(this)->addDockWidget( Qt::RightDockWidgetArea, myInputPanel ); } +void VisuGUI::createSelectionPanel() +{ + mySelectionPanel = new VisuGUI_SelectionPanel( this ); + mySelectionPanel->update(); +} + //*************************************************************************** void VisuGUI::contextMenuPopup( const QString& theClient, QMenu* theMenu, QString& theTitle ) { diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index 8dc56b13..560f7c2e 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -85,6 +85,7 @@ public: getScalarBarsMap(); VisuGUI_InputPanel* inputPanel() const { return myInputPanel; } + VisuGUI_SelectionPanel* selectionPanel() const { return mySelectionPanel; } signals: void moduleDeactivated(); @@ -131,6 +132,9 @@ protected slots: virtual void OnErasePrs(); // virtual void OnEraseAll(); + void OnToggleSelectionPanel(); + void OnSwitchSelectionMode(); + void OnMakeSurfaceframe(); void OnMakeInsideframe(); void OnMakeWireframe(); @@ -194,7 +198,9 @@ private: void createMenus(); void createToolBars(); void createPopupMenus(); + void createInputPanel(); + void createSelectionPanel(); private: VisuGUI_InputPanel* myInputPanel; diff --git a/src/VISUGUI/VisuGUI_ActionsDef.h b/src/VISUGUI/VisuGUI_ActionsDef.h index 40ef7783..7ea0936e 100644 --- a/src/VISUGUI/VisuGUI_ActionsDef.h +++ b/src/VISUGUI/VisuGUI_ActionsDef.h @@ -124,4 +124,10 @@ #define VISU_MULTIPR_LOW_RES 4097 #define VISU_MULTIPR_HIDE 4098 +#define VISU_SELECTION_PANEL 4100 +#define VISU_ACTOR_SELECTION 4101 +#define VISU_CELL_SELECTION 4102 +#define VISU_POINT_SELECTION 4103 +#define VISU_GAUSS_POINT_SELECTION 4104 + #endif diff --git a/src/VISUGUI/VisuGUI_BasePanel.cxx b/src/VISUGUI/VisuGUI_BasePanel.cxx index 4c6dcf70..4d131cf2 100755 --- a/src/VISUGUI/VisuGUI_BasePanel.cxx +++ b/src/VISUGUI/VisuGUI_BasePanel.cxx @@ -24,13 +24,17 @@ // Author : Oleg Uvarov // Module : VISU -#include +#include "VisuGUI_BasePanel.h" +#include "VisuGUI_Tools.h" + +#include "SUIT_ResourceMgr.h" #include -#include #include #include #include +#include +//#include /*! \class MainFrame @@ -45,7 +49,7 @@ public: \brief Constructor. \param theParent parent widget */ - MainFrame( QWidget* theParent ) + MainFrame( QWidget* theParent = 0 ) : QFrame( theParent ) { } @@ -78,20 +82,24 @@ public: VisuGUI_BasePanel::VisuGUI_BasePanel( const QString& theName, QWidget* theParent, const int theBtns ) -: QGroupBox( theName, theParent ) + : QGroupBox( theName, theParent ), + myOK( 0 ), + myApply( 0 ), + myClose( 0 ), + myHelp( 0 ) { // Create scroll view //myView = new QScrollArea( this ); - //myView->setFrameStyle( QFrame::NoFrame ); - - //myView->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded ); - //myView->viewport()->setBackgroundMode( Qt::PaletteButton ); - //myView->setResizePolicy( QScrollView::AutoOneFit ); // Create main frame - myMainFrame = new MainFrame( this/*myView->viewport()*/ ); - //myView->setViewport( myMainFrame ); - + myMainFrame = new MainFrame( this/*myView*/ ); + //myMainFrame->setFrameStyle( QFrame::Plain | QFrame::NoFrame ); + /* + myView->setWidget( myMainFrame ); + myView->setAlignment( Qt::AlignCenter ); + myView->setWidgetResizable( true ); + myView->setMinimumWidth( myMainFrame->sizeHint().width() + MARGIN_SIZE * 2 ); + */ // Create buttons QWidget* aBtnWg = new QWidget( this ); QHBoxLayout* aBtnWgLayout = new QHBoxLayout( aBtnWg ); @@ -101,24 +109,32 @@ VisuGUI_BasePanel::VisuGUI_BasePanel( const QString& theName, if( theBtns & OKBtn ) { + //myOK = new QToolButton( aBtnWg ); + //myOK->setIcon( VISU::GetResourceMgr()->loadPixmap("VISU", tr( "ICON_OK" ) ) ); myOK = new QPushButton( tr( "BUT_OK" ), aBtnWg ); aBtnWgLayout->addWidget( myOK ); connect( myOK, SIGNAL( clicked() ), SLOT( onOK() ) ); } if( theBtns & ApplyBtn ) { + //myApply = new QToolButton( aBtnWg ); + //myApply->setIcon( VISU::GetResourceMgr()->loadPixmap("VISU", tr( "ICON_APPLY" ) ) ); myApply = new QPushButton( tr( "BUT_APPLY" ), aBtnWg ); aBtnWgLayout->addWidget( myApply ); connect( myApply, SIGNAL( clicked() ), SLOT( onApply() ) ); } if( theBtns & CloseBtn ) { + //myClose = new QToolButton( aBtnWg ); + //myClose->setIcon( VISU::GetResourceMgr()->loadPixmap("VISU", tr( "ICON_CLOSE" ) ) ); myClose = new QPushButton( tr( "BUT_CLOSE" ), aBtnWg ); aBtnWgLayout->addWidget( myClose ); connect( myClose, SIGNAL( clicked() ), SLOT( onClose() ) ); } if( theBtns & HelpBtn ) { + //myHelp = new QToolButton( aBtnWg ); + //myHelp->setIcon( VISU::GetResourceMgr()->loadPixmap("VISU", tr( "ICON_HELP" ) ) ); myHelp = new QPushButton( tr( "BUT_HELP" ), aBtnWg ); aBtnWgLayout->addWidget( myHelp ); connect( myHelp, SIGNAL( clicked() ), SLOT( onHelp() ) ); @@ -130,7 +146,7 @@ VisuGUI_BasePanel::VisuGUI_BasePanel( const QString& theName, QVBoxLayout* aLay = new QVBoxLayout( this ); aLay->setContentsMargins( 0, 0, 0, 0 ); aLay->setSpacing( 5 ); - aLay->addWidget( myMainFrame/*myView*/ ); + aLay->addWidget( myMainFrame/*myView*/, 1 ); aLay->addWidget( aBtnWg ); } diff --git a/src/VISUGUI/VisuGUI_BasePanel.h b/src/VISUGUI/VisuGUI_BasePanel.h index 822e85d4..775a9426 100755 --- a/src/VISUGUI/VisuGUI_BasePanel.h +++ b/src/VISUGUI/VisuGUI_BasePanel.h @@ -69,7 +69,7 @@ protected: QFrame* mainFrame(); protected: - //QScrollArea* myView; + QScrollArea* myView; QFrame* myMainFrame; QPushButton* myOK; diff --git a/src/VISUGUI/VisuGUI_GaussPointsSelectionPane.cxx b/src/VISUGUI/VisuGUI_GaussPointsSelectionPane.cxx index 2d8ddef9..98ed64ed 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsSelectionPane.cxx +++ b/src/VISUGUI/VisuGUI_GaussPointsSelectionPane.cxx @@ -29,6 +29,7 @@ #include "VISU_GaussPtsAct.h" #include "VISU_GaussPtsSettings.h" #include "VISU_GaussPointsPL.hxx" +#include "VISU_PickingSettings.h" #include "SUIT_MessageBox.h" #include "SUIT_ResourceMgr.h" @@ -259,9 +260,6 @@ VisuGUI_GaussPointsSelectionPane::VisuGUI_GaussPointsSelectionPane( const Salome myEventCallbackCommand->SetClientData(this); myEventCallbackCommand->SetCallback(VisuGUI_GaussPointsSelectionPane::ProcessEvents); - //setWindowTitle( tr( "PICKING_DLG_TITLE" ) ); - //setSizeGripEnabled(TRUE); - QVBoxLayout* TopLayout = new QVBoxLayout( this ); TopLayout->setSpacing(6); TopLayout->setMargin(11); @@ -302,6 +300,10 @@ VisuGUI_GaussPointsSelectionPane::VisuGUI_GaussPointsSelectionPane( const Salome BoxLayout->addWidget( CursorGroup ); + connect( myCursorSizeSpinBox, SIGNAL( valueChanged( double ) ), this, SLOT( onApplyCursorSize( double ) ) ); + connect( myPyramidHeightSpinBox, SIGNAL( valueChanged( double ) ), this, SLOT( onApplyPyramidHeight( double ) ) ); + connect( mySelectionColorButton, SIGNAL( changed( QColor )), this, SLOT( onApplySelectionColor( QColor ) ) ); + // Tolerance QGroupBox* ToleranceGroup = new QGroupBox( tr( "TOLERANCE_TITLE" ), aBox ); QGridLayout* ToleranceGroupLayout = new QGridLayout (ToleranceGroup); @@ -318,55 +320,7 @@ VisuGUI_GaussPointsSelectionPane::VisuGUI_GaussPointsSelectionPane( const Salome BoxLayout->addWidget( ToleranceGroup ); - // Information window - QGroupBox* InfoWindowGroup = new QGroupBox( tr( "INFO_WINDOW_TITLE" ), aBox ); - QGridLayout* InfoWindowGroupLayout = new QGridLayout (InfoWindowGroup); - InfoWindowGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter); - InfoWindowGroupLayout->setSpacing(6); - InfoWindowGroupLayout->setMargin(11); - - QLabel* TransparencyLabel = new QLabel( tr( "TRANSPARENCY" ), InfoWindowGroup ); - myTransparencySpinBox = new QtxIntSpinBox( 0, 100, 10, InfoWindowGroup ); - myTransparencySpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - - InfoWindowGroupLayout->addWidget( TransparencyLabel, 0, 0 ); - InfoWindowGroupLayout->addWidget( myTransparencySpinBox, 0, 1 ); - - QLabel* PositionLabel = new QLabel( tr( "POSITION" ), InfoWindowGroup ); - myPositionComboBox = new QComboBox( InfoWindowGroup ); - myPositionComboBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - - myPositionComboBox->addItem( tr( "BELOW_POINT" ) ); - myPositionComboBox->addItem( tr( "TOP_LEFT_CORNER" ) ); - - InfoWindowGroupLayout->addWidget( TransparencyLabel, 0, 0 ); - InfoWindowGroupLayout->addWidget( myTransparencySpinBox, 0, 1 ); - InfoWindowGroupLayout->addWidget( PositionLabel, 1, 0 ); - InfoWindowGroupLayout->addWidget( myPositionComboBox, 1, 1 ); - - BoxLayout->addWidget( InfoWindowGroup ); - - // Movement of the camera - QGroupBox* CameraGroup = new QGroupBox( tr( "CAMERA_TITLE" ), aBox ); - QGridLayout* CameraGroupLayout = new QGridLayout (CameraGroup); - CameraGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter); - CameraGroupLayout->setSpacing(6); - CameraGroupLayout->setMargin(11); - - QLabel* ZoomFactorLabel = new QLabel( tr( "ZOOM_FACTOR" ), CameraGroup ); - myZoomFactorSpinBox = new QtxDoubleSpinBox( 0.1, 10.0, 0.1, CameraGroup ); - myZoomFactorSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - - QLabel* StepNumberLabel = new QLabel( tr( "STEP_NUMBER" ), CameraGroup ); - myStepNumberSpinBox = new QtxIntSpinBox( 1, 100, 1, CameraGroup ); - myStepNumberSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - - CameraGroupLayout->addWidget( ZoomFactorLabel, 0, 0 ); - CameraGroupLayout->addWidget( myZoomFactorSpinBox, 0, 1 ); - CameraGroupLayout->addWidget( StepNumberLabel, 1, 0 ); - CameraGroupLayout->addWidget( myStepNumberSpinBox, 1, 1 ); - - BoxLayout->addWidget( CameraGroup ); + connect( myPointToleranceSpinBox, SIGNAL( valueChanged( double ) ), this, SLOT( onApplyPointTolerance( double ) ) ); // Display parent mesh element QGroupBox* PositionGroup = new QGroupBox( tr( "DATA_POSITION" ), aBox ); @@ -380,11 +334,19 @@ VisuGUI_GaussPointsSelectionPane::VisuGUI_GaussPointsSelectionPane( const Salome connect( myParentElementLineEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( onSelectionValidate() ) ); connect( myParentElementLineEdit, SIGNAL( returnPressed() ), this, SLOT( onSelectionApply() ) ); + QToolButton* ParentElementBtn = new QToolButton( PositionGroup ); + ParentElementBtn->setIcon( VISU::GetResourceMgr()->loadPixmap("VISU", tr( "ICON_OK" ) ) ); + connect(ParentElementBtn, SIGNAL(clicked()), this, SLOT(onSelectionApply())); + QLabel* LocalPointLabel = new QLabel( tr( "LOCAL_POINT" ), PositionGroup ); myLocalPointLineEdit = new VisuGUI_ValidatedLineEdit( PositionGroup ); connect( myLocalPointLineEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( onSelectionValidate() ) ); connect( myLocalPointLineEdit, SIGNAL( returnPressed() ), this, SLOT( onSelectionApply() ) ); + QToolButton* LocalPointBtn = new QToolButton( PositionGroup ); + LocalPointBtn->setIcon( VISU::GetResourceMgr()->loadPixmap("VISU", tr( "ICON_OK" ) ) ); + connect(LocalPointBtn, SIGNAL(clicked()), this, SLOT(onSelectionApply())); + myCellIDValidator = new GaussCellIDValidator( myLocalPointLineEdit, myModule, myParentElementLineEdit ); myParentElementLineEdit->setValidator( myCellIDValidator ); @@ -395,12 +357,16 @@ VisuGUI_GaussPointsSelectionPane::VisuGUI_GaussPointsSelectionPane( const Salome PositionGroupLayout->addWidget( ParentElementLabel, 0, 0, 1, 3 ); PositionGroupLayout->addWidget( myParentElementLineEdit, 0, 3 ); + PositionGroupLayout->addWidget( ParentElementBtn, 0, 4 ); PositionGroupLayout->addWidget( LocalPointLabel, 1, 0, 1, 3 ); PositionGroupLayout->addWidget( myLocalPointLineEdit, 1, 3 ); - PositionGroupLayout->addWidget( myDisplayParentMeshCheckBox, 2, 0, 1, 4 ); + PositionGroupLayout->addWidget( LocalPointBtn, 1, 4 ); + PositionGroupLayout->addWidget( myDisplayParentMeshCheckBox, 2, 0, 1, 5 ); BoxLayout->addWidget( PositionGroup ); + connect( myDisplayParentMeshCheckBox, SIGNAL(), this, SLOT( onApplyDisplayParentMesh( bool ) ) ); + TopLayout->addWidget( aBox ); } @@ -408,109 +374,41 @@ VisuGUI_GaussPointsSelectionPane::~VisuGUI_GaussPointsSelectionPane() { } -void VisuGUI_GaussPointsSelectionPane::AddActor( VISU_GaussPtsAct* theActor ) -{ - theActor->SetPickingSettings( myPickingSettings.GetPointer() ); -} - -void VisuGUI_GaussPointsSelectionPane::RemoveActor( VISU_GaussPtsAct* theActor ) -{ - theActor->SetPickingSettings( NULL ); -} - void VisuGUI_GaussPointsSelectionPane::Update() { //printf( "VisuGUI_GaussPointsSelectionPane::Update()\n" ); - myPickingSettings = VISU_PickingSettings::Get(); - - float aCursorSize = 0.5; - float aPyramidHeight = 10.0; - float aPointTolerance = 0.1; - QColor aColor = Qt::yellow; - int anInfoWindowTransparency = 50; - int anInfoWindowPosition = VISU_PickingSettings::BelowPoint; - float aZoomFactor = 1.5; - int aStepNumber = 10; - bool aDisplayParentMesh = false; - - if( !myPickingSettings->GetInitial() ) - { - myCursorSizeSpinBox->setValue( myPickingSettings->GetCursorSize() ); - myPyramidHeightSpinBox->setValue( myPickingSettings->GetPyramidHeight() ); - myPointToleranceSpinBox->setValue( myPickingSettings->GetPointTolerance() ); - myTransparencySpinBox->setValue( int(myPickingSettings->GetInfoWindowTransparency() * 100.0) ); - myPositionComboBox->setCurrentIndex( myPickingSettings->GetInfoWindowPosition() ); - myZoomFactorSpinBox->setValue( myPickingSettings->GetZoomFactor() ); - myStepNumberSpinBox->setValue( myPickingSettings->GetStepNumber() ); - myDisplayParentMeshCheckBox->setChecked( myPickingSettings->GetDisplayParentMesh() ); - - vtkFloatingPointType* aColor = myPickingSettings->GetColor(); - mySelectionColorButton->setColor( - QColor( ( int )( aColor[0] * 255.0 ), - ( int )( aColor[1] * 255.0 ), - ( int )( aColor[2] * 255.0 ) ) ); - - return; - } - - SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr(); + VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); - aCursorSize = aResourceMgr->doubleValue( "VISU", "picking_cursor_size", aCursorSize ); - myCursorSizeSpinBox->setValue( aCursorSize ); + myCursorSizeSpinBox->setValue( aPickingSettings->GetCursorSize() ); + myPyramidHeightSpinBox->setValue( aPickingSettings->GetPyramidHeight() ); + myPointToleranceSpinBox->setValue( aPickingSettings->GetPointTolerance() ); + myDisplayParentMeshCheckBox->setChecked( aPickingSettings->GetDisplayParentMesh() ); - aPyramidHeight = aResourceMgr->doubleValue( "VISU", "picking_pyramid_height", aPyramidHeight ); - myPyramidHeightSpinBox->setValue( aPyramidHeight ); - - aPointTolerance = aResourceMgr->doubleValue( "VISU", "picking_point_tolerance", aPointTolerance ); - myPointToleranceSpinBox->setValue( aPointTolerance ); - - aColor = aResourceMgr->colorValue( "VISU", "picking_selection_color", aColor ); - mySelectionColorButton->setColor( aColor ); - - anInfoWindowTransparency = aResourceMgr->integerValue( "VISU", "picking_transparency", anInfoWindowTransparency ); - myTransparencySpinBox->setValue( anInfoWindowTransparency ); - - anInfoWindowPosition = aResourceMgr->integerValue( "VISU", "picking_position", anInfoWindowPosition ); - myPositionComboBox->setCurrentIndex( anInfoWindowPosition ); - - aZoomFactor = aResourceMgr->doubleValue( "VISU", "picking_zoom_factor", aZoomFactor ); - myZoomFactorSpinBox->setValue( aZoomFactor ); - - aStepNumber = aResourceMgr->integerValue( "VISU", "picking_step_number", aStepNumber ); - myStepNumberSpinBox->setValue( aStepNumber ); - - aDisplayParentMesh = aResourceMgr->booleanValue( "VISU", "picking_display_parent_mesh", aDisplayParentMesh ); - myDisplayParentMeshCheckBox->setChecked( aDisplayParentMesh ); - - Apply(); -} - -VISU_PickingSettings* -VisuGUI_GaussPointsSelectionPane -::GetPickingSettings() -{ - return myPickingSettings.GetPointer(); + vtkFloatingPointType* aColor = aPickingSettings->GetColor(); + mySelectionColorButton->setColor( QColor( ( int )( aColor[0] * 255.0 ), + ( int )( aColor[1] * 255.0 ), + ( int )( aColor[2] * 255.0 ) ) ); } void VisuGUI_GaussPointsSelectionPane::SetInteractor( SVTK_RenderWindowInteractor* theInteractor ) { //printf( "VisuGUI_GaussPointsSelectionPane::SetInteractor( %p )\n", theInteractor ); vtkGenericRenderWindowInteractor* aDevice = theInteractor->GetDevice(); - if( !aDevice->HasObserver(vtkCommand::KeyPressEvent) ) - { - //printf( "AddObserver(vtkCommand::KeyPressEvent)\n" ); - aDevice->AddObserver(vtkCommand::KeyPressEvent, - myEventCallbackCommand.GetPointer(), - myPriority); - } + if( aDevice->HasObserver(vtkCommand::KeyPressEvent) ) + aDevice->RemoveObservers(vtkCommand::KeyPressEvent); - if( !aDevice->HasObserver(vtkCommand::EndPickEvent) ) - { - //printf( "AddObserver(vtkCommand::EndPickEvent)\n" ); - aDevice->AddObserver(vtkCommand::EndPickEvent, - myEventCallbackCommand.GetPointer(), - myPriority); - } + //printf( "AddObserver(vtkCommand::KeyPressEvent)\n" ); + aDevice->AddObserver(vtkCommand::KeyPressEvent, + myEventCallbackCommand.GetPointer(), + myPriority); + + if( aDevice->HasObserver(vtkCommand::EndPickEvent) ) + aDevice->RemoveObservers(vtkCommand::EndPickEvent); + + //printf( "AddObserver(vtkCommand::EndPickEvent)\n" ); + aDevice->AddObserver(vtkCommand::EndPickEvent, + myEventCallbackCommand.GetPointer(), + myPriority); } SVTK_RenderWindowInteractor* VisuGUI_GaussPointsSelectionPane::GetInteractor() @@ -545,14 +443,16 @@ void VisuGUI_GaussPointsSelectionPane::ProcessEvents(vtkObject* vtkNotUsed(theOb void VisuGUI_GaussPointsSelectionPane::KeyPressed() { + //printf( "VisuGUI_GaussPointsSelectionPane::KeyPressed()\n" ); if( GetInteractor()->GetDevice()->GetKeyCode() == 'P' ) { - bool aDisplayParentMesh = !myPickingSettings->GetDisplayParentMesh(); - myPickingSettings->SetDisplayParentMesh( aDisplayParentMesh ); + VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); + bool aDisplayParentMesh = !aPickingSettings->GetDisplayParentMesh(); myDisplayParentMeshCheckBox->setChecked( aDisplayParentMesh ); - myPickingSettings->InvokeEvent(VISU::UpdatePickingSettingsEvent,NULL); + aPickingSettings->SetDisplayParentMesh( aDisplayParentMesh ); + aPickingSettings->InvokeEvent(VISU::UpdatePickingSettingsEvent,NULL); } } @@ -560,26 +460,27 @@ void VisuGUI_GaussPointsSelectionPane::SelectionEvent() { //printf( "VisuGUI_GaussPointsSelectionPane::SelectionEvent()\n" ); SelectorHelper aHelper( myModule ); - if ( !aHelper.get() ) - return; - - const TColStd_IndexedMapOfInteger& aMapIndex = aHelper.myMapIndex; - if ( aMapIndex.Extent() != 1 ) - return; - - int anObjId = aHelper.myMapIndex(1); - - VISU::TGaussPointID aGaussPointID = aHelper.myPipeLine->GetObjID( anObjId ); - - VISU::TCellID aCellId = aGaussPointID.first; - myParentElementLineEdit->setText( QString::number( aCellId ) ); + if( aHelper.get() ) + { + const TColStd_IndexedMapOfInteger& aMapIndex = aHelper.myMapIndex; + if( aMapIndex.Extent() == 1 ) + { + int anObjId = aHelper.myMapIndex(1); + VISU::TGaussPointID aGaussPointID = aHelper.myPipeLine->GetObjID( anObjId ); + VISU::TCellID aCellID = aGaussPointID.first; + VISU::TLocalPntID aLocalPntID = aGaussPointID.second; - VISU::TLocalPntID aLocalPntId = aGaussPointID.second; - myLocalPointLineEdit->setText( QString::number( aLocalPntId ) ); + myParentElementLineEdit->setText( QString::number( aCellID ) ); + myLocalPointLineEdit->setText( QString::number( aLocalPntID ) ); - myPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL ); + VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); + aPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL ); - SetSelected( aCellId, aLocalPntId ); + SetSelected( aCellID, aLocalPntID ); + return; + } + } + ClearIDControls(); } void VisuGUI_GaussPointsSelectionPane::onSelectionValidate() @@ -600,12 +501,12 @@ void VisuGUI_GaussPointsSelectionPane::SetSelected( VISU::TCellID theCellId, VIS { //printf( "VisuGUI_GaussPointsSelectionPane::SetSelected( %d, %d )\n", theCellId, theLocalPntId ); SelectorHelper aHelper( myModule ); - if ( !aHelper.get() ) + if( !aHelper.get() ) return; VISU::PGaussPtsIDMapper anIDMapper = aHelper.myPipeLine->GetGaussPtsIDMapper(); vtkIdType anObjVtkId = anIDMapper->GetVTKID( VISU::TGaussPointID( theCellId, theLocalPntId ) ); - if ( anObjVtkId < 0 ) + if( anObjVtkId < 0 ) return; aHelper.myMapIndex.Clear(); @@ -615,34 +516,15 @@ void VisuGUI_GaussPointsSelectionPane::SetSelected( VISU::TCellID theCellId, VIS GetInteractor()->GetDevice()->CreateTimer( VTKI_TIMER_FIRST ); } -void VisuGUI_GaussPointsSelectionPane::Apply() +void VisuGUI_GaussPointsSelectionPane::ClearIDControls() { - myPickingSettings->SetInitial( false ); - - myPickingSettings->SetCursorSize( myCursorSizeSpinBox->value() ); - myPickingSettings->SetPyramidHeight( myPyramidHeightSpinBox->value() ); - myPickingSettings->SetPointTolerance( myPointToleranceSpinBox->value() ); - myPickingSettings->SetInfoWindowTransparency( myTransparencySpinBox->value() / 100.0 ); - myPickingSettings->SetInfoWindowPosition( myPositionComboBox->currentIndex() ); - myPickingSettings->SetZoomFactor( myZoomFactorSpinBox->value() ); - myPickingSettings->SetStepNumber( myStepNumberSpinBox->value() ); - myPickingSettings->SetDisplayParentMesh( myDisplayParentMeshCheckBox->isChecked() ); - - QColor aButtonColor = mySelectionColorButton->color(); - vtkFloatingPointType aColor[3]; - aColor[0] = aButtonColor.red() / 255.0; - aColor[1] = aButtonColor.green() / 255.0; - aColor[2] = aButtonColor.blue() / 255.0; - myPickingSettings->SetColor( aColor ); - - myPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL ); - - onSelectionApply(); + myParentElementLineEdit->setText( "" ); + myLocalPointLineEdit->setText( "" ); } -void VisuGUI_GaussPointsSelectionPane::Close() +void VisuGUI_GaussPointsSelectionPane::UnselectAll() { - //printf( "VisuGUI_GaussPointsSelectionPane::Close()\n" ); + //printf( "VisuGUI_GaussPointsSelectionPane::UnselectAll()\n" ); SelectorHelper aHelper( myModule ); if( aHelper.get() ) { @@ -658,12 +540,76 @@ void VisuGUI_GaussPointsSelectionPane::Close() vtkIdType anObjVtkId = anIDMapper->GetVTKID( VISU::TGaussPointID( aCellID, aLocalPntID ) ); if( anObjVtkId >= 0 ) { + //printf( "anObjVtkId = %d\n", anObjVtkId ); aHelper.myActor->Highlight( false ); aHelper.myMapIndex.Clear(); } } } + ClearIDControls(); +} + +void VisuGUI_GaussPointsSelectionPane::Apply() +{ + /* + VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); + aPickingSettings->SetCursorSize( myCursorSizeSpinBox->value() ); + aPickingSettings->SetPyramidHeight( myPyramidHeightSpinBox->value() ); + aPickingSettings->SetPointTolerance( myPointToleranceSpinBox->value() ); + aPickingSettings->SetDisplayParentMesh( myDisplayParentMeshCheckBox->isChecked() ); + + QColor aButtonColor = mySelectionColorButton->color(); + vtkFloatingPointType aColor[3]; + aColor[0] = aButtonColor.red() / 255.0; + aColor[1] = aButtonColor.green() / 255.0; + aColor[2] = aButtonColor.blue() / 255.0; + aPickingSettings->SetColor( aColor ); + + aPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL ); + */ + onSelectionApply(); +} + +void VisuGUI_GaussPointsSelectionPane::onApplyCursorSize( double theValue ) +{ + VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); + aPickingSettings->SetCursorSize( theValue ); + aPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL ); + //onSelectionApply(); } + +void VisuGUI_GaussPointsSelectionPane::onApplyPyramidHeight( double theValue ) +{ + VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); + aPickingSettings->SetPyramidHeight( theValue ); + aPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL ); +} + +void VisuGUI_GaussPointsSelectionPane::onApplySelectionColor( QColor theValue ) +{ + VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); + vtkFloatingPointType aColor[3]; + aColor[0] = theValue.red() / 255.0; + aColor[1] = theValue.green() / 255.0; + aColor[2] = theValue.blue() / 255.0; + aPickingSettings->SetColor( aColor ); + aPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL ); +} + +void VisuGUI_GaussPointsSelectionPane::onApplyPointTolerance( double theValue ) +{ + VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); + aPickingSettings->SetPointTolerance( theValue ); + aPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL ); +} + +void VisuGUI_GaussPointsSelectionPane::onApplyDisplayParentMesh( bool theValue ) +{ + VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); + aPickingSettings->SetDisplayParentMesh( theValue ); + aPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL ); +} + /* void VisuGUI_GaussPointsSelectionPane::Help() { diff --git a/src/VISUGUI/VisuGUI_GaussPointsSelectionPane.h b/src/VISUGUI/VisuGUI_GaussPointsSelectionPane.h index c70f37df..a00f47f2 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsSelectionPane.h +++ b/src/VISUGUI/VisuGUI_GaussPointsSelectionPane.h @@ -68,19 +68,14 @@ public: ~VisuGUI_GaussPointsSelectionPane(); - //! Make an actor to listen the event of Update Picking Settings event. - void AddActor( VISU_GaussPtsAct* ); - void RemoveActor( VISU_GaussPtsAct* ); - //! Update dialog contents. void Update(); - VISU_PickingSettings* GetPickingSettings(); - void SetInteractor( SVTK_RenderWindowInteractor* ); + void UnselectAll(); + void Apply(); - void Close(); //void Help(); protected: @@ -90,6 +85,13 @@ protected slots: void onSelectionValidate(); void onSelectionApply(); +private slots: + void onApplyCursorSize( double ); + void onApplyPyramidHeight( double ); + void onApplySelectionColor( QColor ); + void onApplyPointTolerance( double ); + void onApplyDisplayParentMesh( bool ); + private: static void ProcessEvents(vtkObject* theObject, unsigned long theEvent, @@ -101,6 +103,7 @@ private: //void keyPressEvent( QKeyEvent* e ); void SetSelected( VISU::TCellID, VISU::TLocalPntID ); + void ClearIDControls(); private: const SalomeApp_Module* myModule; @@ -109,14 +112,9 @@ private: QtxDoubleSpinBox* myPyramidHeightSpinBox; QtxColorButton* mySelectionColorButton; QtxDoubleSpinBox* myPointToleranceSpinBox; - QtxIntSpinBox* myTransparencySpinBox; - QComboBox* myPositionComboBox; - QtxDoubleSpinBox* myZoomFactorSpinBox; - QtxIntSpinBox* myStepNumberSpinBox; QCheckBox* myDisplayParentMeshCheckBox; QtxAction* myAction; - vtkSmartPointer myPickingSettings; VisuGUI_ValidatedLineEdit* myParentElementLineEdit; VisuGUI_ValidatedLineEdit* myLocalPointLineEdit; diff --git a/src/VISUGUI/VisuGUI_InputPanel.cxx b/src/VISUGUI/VisuGUI_InputPanel.cxx index 246d2997..e634ac8f 100755 --- a/src/VISUGUI/VisuGUI_InputPanel.cxx +++ b/src/VISUGUI/VisuGUI_InputPanel.cxx @@ -26,15 +26,9 @@ #include "VisuGUI_InputPanel.h" #include "VisuGUI_BasePanel.h" -#include "VisuGUI_Module.h" - -#include #include -#include -#include - /*! * \brief Constructor creates enmpty docable window with invisible QVBox to be used as container of child widgets @@ -77,9 +71,13 @@ void VisuGUI_InputPanel::showPanel( VisuGUI_BasePanel* thePanel ) myGrp->layout()->addWidget( thePanel ); connect( thePanel, SIGNAL( bpClose() ), this, SLOT( onClosePanel() ) ); } - + + if( isEmpty() ) + show(); + thePanel->show(); myCurrentPanel = thePanel; + myPanels[ thePanel ] = true; setUpdatesEnabled( true ); repaint(); @@ -96,6 +94,10 @@ void VisuGUI_InputPanel::hidePanel( VisuGUI_BasePanel* thePanel ) thePanel->hide(); myCurrentPanel = 0; + myPanels[ thePanel ] = false; + + if( isEmpty() ) + hide(); } /*! @@ -107,6 +109,28 @@ void VisuGUI_InputPanel::clear() hidePanel( myCurrentPanel ); } +/*! + \brief Returns true if no panels are shown +*/ +bool VisuGUI_InputPanel::isEmpty() const +{ + QMap::const_iterator it = myPanels.begin(), itEnd = myPanels.end(); + for( ; it != itEnd; ++it ) + { + if( it.value() ) + return false; + } + return true; +} + +/*! + \brief Returns true if the panel is shown +*/ +bool VisuGUI_InputPanel::isShown( VisuGUI_BasePanel* thePanel ) const +{ + return myPanels[ thePanel ]; +} + /*! \brief Close panel which emits signal close(). */ diff --git a/src/VISUGUI/VisuGUI_InputPanel.h b/src/VISUGUI/VisuGUI_InputPanel.h index 2e576476..b295b0b1 100755 --- a/src/VISUGUI/VisuGUI_InputPanel.h +++ b/src/VISUGUI/VisuGUI_InputPanel.h @@ -49,14 +49,15 @@ public: void hidePanel( VisuGUI_BasePanel* thePanel ); void clear(); - VisuGUI_BasePanel* getCurrentPanel() const; + bool isEmpty() const; + bool isShown( VisuGUI_BasePanel* thePanel ) const; protected slots: void onClosePanel(); private: QWidget* myGrp; - QMap< VisuGUI_BasePanel*, bool > myPanels; + QMap myPanels; VisuGUI_BasePanel* myCurrentPanel; }; diff --git a/src/VISUGUI/VisuGUI_SelectionPanel.cxx b/src/VISUGUI/VisuGUI_SelectionPanel.cxx index 43d8984d..9a7b6711 100644 --- a/src/VISUGUI/VisuGUI_SelectionPanel.cxx +++ b/src/VISUGUI/VisuGUI_SelectionPanel.cxx @@ -39,6 +39,9 @@ #include "VISU_PrsObject_i.hh" #include "VISU_Prs3d_i.hh" #include "VISU_PipeLine.hxx" +#include "VISU_GaussPointsPL.hxx" +#include "VISU_GaussPtsSettings.h" +#include "VISU_PickingSettings.h" #include "SalomeApp_Study.h" #include "SalomeApp_Application.h" @@ -60,6 +63,9 @@ #include "SVTK_Selector.h" #include "SVTK_RenderWindowInteractor.h" +#include "QtxDoubleSpinBox.h" +#include "QtxIntSpinBox.h" + #include "utilities.h" // OCCT Includes @@ -75,6 +81,7 @@ #include #include #include +#include #include #include #include @@ -84,6 +91,8 @@ #include #include #include +#include +#include // VTK Includes #include @@ -97,14 +106,16 @@ using namespace std; +#define MARGIN_SIZE 11 + VisuGUI_SelectionPanel::VisuGUI_SelectionPanel( const SalomeApp_Module* theModule, QWidget* theParent ) : - VisuGUI_BasePanel( tr("WINDOW_TITLE" ), theParent, ApplyBtn | CloseBtn | HelpBtn ), + VisuGUI_BasePanel( tr("WINDOW_TITLE" ), theParent, /*ApplyBtn | */CloseBtn | HelpBtn ), myModule( theModule ), mySelectionMgr( 0 ) { QVBoxLayout* TopLayout = new QVBoxLayout ( mainFrame() ); TopLayout->setSpacing(6); - TopLayout->setMargin(11); + TopLayout->setMargin(MARGIN_SIZE); QWidget* aNamePane = new QWidget (mainFrame()); QGridLayout* aNameLay = new QGridLayout (aNamePane); @@ -144,12 +155,17 @@ VisuGUI_SelectionPanel::VisuGUI_SelectionPanel( const SalomeApp_Module* theModul myIDValLbl->setValidator(aIntValidator); connect(myIDValLbl, SIGNAL(returnPressed()), this, SLOT(onPointIdEdit())); + QToolButton* anIDBtn = new QToolButton( aDataGrp ); + anIDBtn->setIcon( VISU::GetResourceMgr()->loadPixmap("VISU", tr( "ICON_OK" ) ) ); + aGridLay->addWidget( anIDBtn, 0, 2 ); + connect(anIDBtn, SIGNAL(clicked()), this, SLOT(onPointIdEdit())); + myScalarValLbl = new QLabel ("", aDataGrp); - aGridLay->addWidget( myScalarValLbl, 1, 1 ); + aGridLay->addWidget( myScalarValLbl, 1, 1, 1, 2 ); myVectorValLbl = new QLabel ("", aDataGrp); myVectorValLbl->setMinimumWidth(150); - aGridLay->addWidget( myVectorValLbl, 2, 1 ); + aGridLay->addWidget( myVectorValLbl, 2, 1, 1, 2 ); aVBoxLayout->addWidget( aDataGrp ); @@ -201,12 +217,17 @@ VisuGUI_SelectionPanel::VisuGUI_SelectionPanel( const SalomeApp_Module* theModul aGridLay->addWidget( myCellIDValLbl, 0, 1); connect(myCellIDValLbl, SIGNAL(returnPressed()), this, SLOT(onCellIdEdit())); + QToolButton* aCellIDBtn = new QToolButton( aDataGrp ); + aCellIDBtn->setIcon( VISU::GetResourceMgr()->loadPixmap("VISU", tr( "ICON_OK" ) ) ); + aGridLay->addWidget( aCellIDBtn, 0, 2 ); + connect(aCellIDBtn, SIGNAL(clicked()), this, SLOT(onCellIdEdit())); + aGridLay->addWidget( new QLabel (tr("DATA_SCALAR_LBL"), aCellGrp), 1, 0); myCellScalarValLbl = new QLabel ("", aCellGrp); - aGridLay->addWidget( myCellScalarValLbl, 1, 1); + aGridLay->addWidget( myCellScalarValLbl, 1, 1, 1, 2); aGridLay->addWidget( new QLabel (tr("DATA_VECTOR_LBL"), aCellGrp), 2, 0); myCellVectorValLbl = new QLabel ("", aCellGrp); - aGridLay->addWidget(myCellVectorValLbl , 2, 1); + aGridLay->addWidget(myCellVectorValLbl , 2, 1, 1, 2); aCellLayout->addWidget(aCellGrp, 0, 0); @@ -274,18 +295,89 @@ VisuGUI_SelectionPanel::VisuGUI_SelectionPanel( const SalomeApp_Module* theModul aVBoxLayout->addStretch(); // Gauss Points Pane - myGaussPointsPane = new VisuGUI_GaussPointsSelectionPane( myModule, mainFrame() ); + QScrollArea* aGaussPointsScrollArea = new QScrollArea( mainFrame() ); + myGaussPointsPane = new VisuGUI_GaussPointsSelectionPane( myModule, aGaussPointsScrollArea ); + + aGaussPointsScrollArea->setWidget( myGaussPointsPane ); + aGaussPointsScrollArea->setAlignment( Qt::AlignCenter ); + aGaussPointsScrollArea->setWidgetResizable( true ); + aGaussPointsScrollArea->setMinimumWidth( myGaussPointsPane->sizeHint().width() + MARGIN_SIZE ); // Add panes to tab widget myTabWidget->addTab(myActorsPane, tr("MODE_ACTOR")); myTabWidget->addTab(myCellsPane, tr("MODE_CELL")); myTabWidget->addTab(myPointsPane, tr("MODE_POINT")); - myTabWidget->addTab(myGaussPointsPane, tr("MODE_GAUSS_POINT")); + myTabWidget->addTab(aGaussPointsScrollArea, tr("MODE_GAUSS_POINT")); connect(myTabWidget, SIGNAL(currentChanged(int)), this, SLOT(onSelectionModeChanged(int))); TopLayout->addWidget(myTabWidget); + // Information window + myInfoWindowGroup = new QGroupBox( tr( "INFO_WINDOW_TITLE" ), mainFrame() ); + myInfoWindowGroup->setCheckable( true ); + + QGridLayout* InfoWindowGroupLayout = new QGridLayout (myInfoWindowGroup); + InfoWindowGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter); + InfoWindowGroupLayout->setSpacing(6); + InfoWindowGroupLayout->setMargin(11); + + QLabel* TransparencyLabel = new QLabel( tr( "TRANSPARENCY" ), myInfoWindowGroup ); + myTransparencySpinBox = new QtxIntSpinBox( 0, 100, 10, myInfoWindowGroup ); + myTransparencySpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + InfoWindowGroupLayout->addWidget( TransparencyLabel, 0, 0 ); + InfoWindowGroupLayout->addWidget( myTransparencySpinBox, 0, 1 ); + + QLabel* PositionLabel = new QLabel( tr( "POSITION" ), myInfoWindowGroup ); + myPositionComboBox = new QComboBox( myInfoWindowGroup ); + myPositionComboBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + myPositionComboBox->addItem( tr( "BELOW_POINT" ) ); + myPositionComboBox->addItem( tr( "TOP_LEFT_CORNER" ) ); + + InfoWindowGroupLayout->addWidget( TransparencyLabel, 0, 0 ); + InfoWindowGroupLayout->addWidget( myTransparencySpinBox, 0, 1 ); + InfoWindowGroupLayout->addWidget( PositionLabel, 1, 0 ); + InfoWindowGroupLayout->addWidget( myPositionComboBox, 1, 1 ); + + TopLayout->addWidget( myInfoWindowGroup ); + + connect( myInfoWindowGroup, SIGNAL( toggled( bool ) ), this, SLOT( onApplyInfoWindow( bool ) ) ); + connect( myTransparencySpinBox, SIGNAL( valueChanged( int ) ), this, SLOT( onApplyTransparency( int ) ) ); + connect( myPositionComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onApplyPosition( int ) ) ); + + // Movement of the camera + myCameraGroup = new QGroupBox( tr( "CAMERA_TITLE" ), mainFrame() ); + myCameraGroup->setCheckable( true ); + + QGridLayout* CameraGroupLayout = new QGridLayout (myCameraGroup); + CameraGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter); + CameraGroupLayout->setSpacing(6); + CameraGroupLayout->setMargin(11); + + QLabel* ZoomFactorLabel = new QLabel( tr( "ZOOM_FACTOR_DSC" ), myCameraGroup ); + ZoomFactorLabel->setToolTip( tr( "ZOOM_FACTOR_TIP" ) ); + myZoomFactorSpinBox = new QtxDoubleSpinBox( 0.1, 10.0, 0.1, myCameraGroup ); + myZoomFactorSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + QLabel* StepNumberLabel = new QLabel( tr( "STEP_NUMBER_DSC" ), myCameraGroup ); + StepNumberLabel->setToolTip( tr( "STEP_NUMBER_TIP" ) ); + myStepNumberSpinBox = new QtxIntSpinBox( 1, 100, 1, myCameraGroup ); + myStepNumberSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + CameraGroupLayout->addWidget( ZoomFactorLabel, 0, 0 ); + CameraGroupLayout->addWidget( myZoomFactorSpinBox, 0, 1 ); + CameraGroupLayout->addWidget( StepNumberLabel, 1, 0 ); + CameraGroupLayout->addWidget( myStepNumberSpinBox, 1, 1 ); + + TopLayout->addWidget( myCameraGroup ); + + connect( myCameraGroup, SIGNAL( toggled( bool ) ), this, SLOT( onApplyCamera( bool ) ) ); + connect( myZoomFactorSpinBox, SIGNAL( valueChanged( double ) ), this, SLOT( onApplyZoomFactor( double ) ) ); + connect( myStepNumberSpinBox, SIGNAL( valueChanged( int ) ), this, SLOT( onApplyStepNumber( int ) ) ); + + SalomeApp_Application* anApp = dynamic_cast (SUIT_Session::session()->activeApplication()); mySelectionMgr = anApp->selectionMgr(); @@ -306,13 +398,31 @@ VisuGUI_SelectionPanel::~VisuGUI_SelectionPanel() { } -void VisuGUI_SelectionPanel::onSelectionModeChanged (int theId) +void VisuGUI_SelectionPanel::update() +{ + VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); + + myInfoWindowGroup->setChecked( aPickingSettings->GetInfoWindowEnabled() ); + myTransparencySpinBox->setValue( int(aPickingSettings->GetInfoWindowTransparency() * 100.0) ); + myPositionComboBox->setCurrentIndex( aPickingSettings->GetInfoWindowPosition() ); + myCameraGroup->setChecked( aPickingSettings->GetCameraMovementEnabled() ); + myZoomFactorSpinBox->setValue( aPickingSettings->GetZoomFactor() ); + myStepNumberSpinBox->setValue( aPickingSettings->GetStepNumber() ); +} + +void VisuGUI_SelectionPanel::setSelectionMode( int theId ) +{ + //printf( "VisuGUI_SelectionPanel::setSelectionMode( %d )\n", theId ); + myTabWidget->setCurrentIndex( theId ); +} + +void VisuGUI_SelectionPanel::onSelectionModeChanged( int theId ) { //printf( "VisuGUI_SelectionPanel::onSelectionModeChanged( %d )\n", theId ); SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(myModule); if (!aViewWindow) return; - myGaussPointsPane->Close(); // unselect gauss points + myGaussPointsPane->UnselectAll(); // unselect gauss points switch (theId) { case 0: // Actor @@ -335,11 +445,14 @@ void VisuGUI_SelectionPanel::onSelectionModeChanged (int theId) } } - -void VisuGUI_SelectionPanel::closeEvent (QCloseEvent* theEvent) +void VisuGUI_SelectionPanel::showEvent( QShowEvent* theEvent ) { - myTabWidget->setCurrentWidget(myActorsPane); + VisuGUI_BasePanel::showEvent(theEvent); +} +void VisuGUI_SelectionPanel::closeEvent( QCloseEvent* theEvent ) +{ + onClose(); VisuGUI_BasePanel::closeEvent(theEvent); } @@ -361,8 +474,6 @@ template QString getVector(TData* theData, int theId){ } } -#define ABS(a) (a>=0)?a:-a - void VisuGUI_SelectionPanel::onSelectionEvent() { SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(myModule); if (!aViewWindow) @@ -410,6 +521,7 @@ void VisuGUI_SelectionPanel::onSelectionEvent() { } } + clearFields(); if (aPrs3d) { QString aMeshName("NULL"), aFieldName("NULL"); @@ -433,9 +545,9 @@ void VisuGUI_SelectionPanel::onSelectionEvent() { myYPosLbl->setText(QString::number( aCoord[2] )); myZPosLbl->setText(QString::number( aCoord[4] )); - myDXLbl->setText(QString::number( ABS(aCoord[1]-aCoord[0]) )); - myDYLbl->setText(QString::number( ABS(aCoord[3]-aCoord[2]) )); - myDZLbl->setText(QString::number( ABS(aCoord[5]-aCoord[4]) )); + myDXLbl->setText(QString::number( fabs(aCoord[1]-aCoord[0]) )); + myDYLbl->setText(QString::number( fabs(aCoord[3]-aCoord[2]) )); + myDZLbl->setText(QString::number( fabs(aCoord[5]-aCoord[4]) )); TColStd_IndexedMapOfInteger aMapIndex; typedef std::vector TCoordArray; @@ -447,8 +559,10 @@ void VisuGUI_SelectionPanel::onSelectionEvent() { vtkDataSet* aDataSet = anVISUActor->GetMapper()->GetInput(); vtkPointData* aPntData = aDataSet->GetPointData(); - for (int ind = 1; ind <= aMapIndex.Extent(); ind++) { - int anID = aMapIndex(ind); + // controls are cleared in case of multi-selection of sub-elements + //for (int ind = 1; ind <= aMapIndex.Extent(); ind++) { + if( aMapIndex.Extent() == 1 ) { + int anID = aMapIndex(1); switch (aType) { case 2: @@ -550,18 +664,15 @@ void VisuGUI_SelectionPanel::onSelectionEvent() { //for(int aColumnId = 0; aColumnId < 9; aColumnId++) myListPoints->resizeColumnsToContents(); } - } else { - clearFields(); } myFl = false; } -#undef ABS - void VisuGUI_SelectionPanel::clearFields() { int aType = myTabWidget->currentIndex(); switch (aType) { case 2: + myIDValLbl->setText( "" ); myXValLbl->setText( "" ); myYValLbl->setText( "" ); myZValLbl->setText( "" ); @@ -572,6 +683,7 @@ void VisuGUI_SelectionPanel::clearFields() { myVectorValLbl->setText(""); break; case 1: + myCellIDValLbl->setText( "" ); myCellScalarValLbl->setText(""); myCellVectorValLbl->setText(""); myListPoints->setRowCount(0); @@ -619,6 +731,10 @@ bool onIdEdit (const QString& theText, if (aPrs3d) { int anObjId = theText.toInt(); VISU_PipeLine* aPipeLine = aPrs3d->GetPipeLine(); + + if( dynamic_cast( aPipeLine ) ) + return false; + int aVTKId = (aPipeLine->*theMethod)(anObjId); if(aVTKId < 0) return false; @@ -628,6 +744,14 @@ bool onIdEdit (const QString& theText, aSelector->AddOrRemoveIndex(anIO, newIndices, false); aViewWindow->highlight(anIO, true, true); + if( SVTK_MainWindow* aMainWindow = aViewWindow->getMainWindow() ) + { + SVTK_RenderWindowInteractor* anInteractor = aMainWindow->GetInteractor(); + VISU_Actor* anActor = SVTK::Find(anInteractor->getRenderer()->GetActors(), + SVTK::TIsSameIObject( anIO )); + //anActor->Highlight( anIO ); + } + return true; } else { @@ -673,33 +797,56 @@ void VisuGUI_SelectionPanel::onCellIdEdit () clearFields(); } -void VisuGUI_SelectionPanel::onApply() +void VisuGUI_SelectionPanel::onApplyInfoWindow( bool theValue ) { - //printf( "VisuGUI_SelectionPanel::onApply()\n" ); - int aType = myTabWidget->currentIndex(); - switch( aType ) - { - case 1: // Cells - onCellIdEdit(); - break; - case 2: // Points - onPointIdEdit(); - break; - case 3: // Gauss Points - myGaussPointsPane->Apply(); - break; - default: - break; - } + VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); + aPickingSettings->SetInfoWindowEnabled( theValue ); + aPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL ); +} + +void VisuGUI_SelectionPanel::onApplyTransparency( int theValue ) +{ + VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); + aPickingSettings->SetInfoWindowTransparency( theValue / 100.0 ); + aPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL ); +} + +void VisuGUI_SelectionPanel::onApplyPosition( int theValue ) +{ + VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); + aPickingSettings->SetInfoWindowPosition( theValue ); + aPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL ); +} + +void VisuGUI_SelectionPanel::onApplyCamera( bool theValue ) +{ + VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); + aPickingSettings->SetCameraMovementEnabled( theValue ); + aPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL ); +} + +void VisuGUI_SelectionPanel::onApplyZoomFactor( double theValue ) +{ + VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); + aPickingSettings->SetZoomFactor( theValue ); + aPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL ); +} + +void VisuGUI_SelectionPanel::onApplyStepNumber( int theValue ) +{ + VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); + aPickingSettings->SetStepNumber( theValue ); + aPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL ); +} +void VisuGUI_SelectionPanel::onApply() +{ VisuGUI_BasePanel::onApply(); } void VisuGUI_SelectionPanel::onClose() { - //printf( "VisuGUI_SelectionPanel::onClose()\n" ); close(); - VisuGUI_BasePanel::onClose(); } diff --git a/src/VISUGUI/VisuGUI_SelectionPanel.h b/src/VISUGUI/VisuGUI_SelectionPanel.h index 01c4f77a..17aad529 100644 --- a/src/VISUGUI/VisuGUI_SelectionPanel.h +++ b/src/VISUGUI/VisuGUI_SelectionPanel.h @@ -31,11 +31,18 @@ #include +#include + +class QComboBox; +class QGroupBox; class QLabel; class QLineEdit; class QTableWidget; class QTabWidget; +class QtxDoubleSpinBox; +class QtxIntSpinBox; + class LightApp_SelectionMgr; class SalomeApp_Application; class SalomeApp_Module; @@ -51,17 +58,30 @@ public: VisuGUI_SelectionPanel( const SalomeApp_Module* theModule, QWidget* theParent = 0 ); virtual ~VisuGUI_SelectionPanel (); +public: + void update(); + + void setSelectionMode( int theId ); + private: void keyPressEvent( QKeyEvent* theEvent ); protected: - void closeEvent( QCloseEvent* theEvent ); + virtual void showEvent( QShowEvent* theEvent ); + virtual void closeEvent( QCloseEvent* theEvent ); private slots: virtual void onApply(); virtual void onClose(); virtual void onHelp(); + void onApplyInfoWindow( bool ); + void onApplyTransparency( int ); + void onApplyPosition( int ); + void onApplyCamera( bool ); + void onApplyZoomFactor( double ); + void onApplyStepNumber( int ); + void onSelectionModeChanged( int theId ); void onSelectionEvent(); void onPointIdEdit(); @@ -105,6 +125,14 @@ private: VisuGUI_GaussPointsSelectionPane* myGaussPointsPane; + QGroupBox* myInfoWindowGroup; + QtxIntSpinBox* myTransparencySpinBox; + QComboBox* myPositionComboBox; + + QGroupBox* myCameraGroup; + QtxDoubleSpinBox* myZoomFactorSpinBox; + QtxIntSpinBox* myStepNumberSpinBox; + const SalomeApp_Module* myModule; LightApp_SelectionMgr* mySelectionMgr; bool myFl; diff --git a/src/VVTK/VVTK_PickingDlg.cxx b/src/VVTK/VVTK_PickingDlg.cxx index 75670122..06b7f26e 100644 --- a/src/VVTK/VVTK_PickingDlg.cxx +++ b/src/VVTK/VVTK_PickingDlg.cxx @@ -24,7 +24,7 @@ #include "VVTK_PickingDlg.h" #include "VISU_GaussPtsAct.h" -#include "VISU_GaussPtsSettings.h" +#include "VISU_PickingSettings.h" #include "VISU_GaussPointsPL.hxx" #include "SUIT_MessageBox.h" @@ -454,12 +454,12 @@ VVTK_PickingDlg::~VVTK_PickingDlg() void VVTK_PickingDlg::AddActor( VISU_GaussPtsAct* theActor ) { - theActor->SetPickingSettings( myPickingSettings.GetPointer() ); + //theActor->SetPickingSettings( myPickingSettings.GetPointer() ); } void VVTK_PickingDlg::RemoveActor( VISU_GaussPtsAct* theActor ) { - theActor->SetPickingSettings( NULL ); + //theActor->SetPickingSettings( NULL ); } void VVTK_PickingDlg::Update() @@ -474,7 +474,7 @@ void VVTK_PickingDlg::Update() int aStepNumber = 10; bool aDisplayParentMesh = false; - if( !myPickingSettings->GetInitial() ) + //if( !myPickingSettings->GetInitial() ) { myCursorSizeSpinBox->setValue( myPickingSettings->GetCursorSize() ); myPyramidHeightSpinBox->setValue( myPickingSettings->GetPyramidHeight() ); @@ -634,7 +634,7 @@ void VVTK_PickingDlg::KeyPressed() void VVTK_PickingDlg::onClickApply() { - myPickingSettings->SetInitial( false ); + //myPickingSettings->SetInitial( false ); myPickingSettings->SetCursorSize( myCursorSizeSpinBox->value() ); myPickingSettings->SetPyramidHeight( myPyramidHeightSpinBox->value() ); diff --git a/src/VVTK/VVTK_Renderer.cxx b/src/VVTK/VVTK_Renderer.cxx index 8b56aede..d0e3d6a1 100644 --- a/src/VVTK/VVTK_Renderer.cxx +++ b/src/VVTK/VVTK_Renderer.cxx @@ -194,7 +194,7 @@ VVTK_Renderer anActor->SetHighlightProperty(myGaussHighlightProperty.GetPointer()); anActor->SetInsideCursorSettings(myInsideCursorSettings); - anActor->SetPickingSettings(myPickingSettings); + //anActor->SetPickingSettings(myPickingSettings); } } @@ -210,7 +210,7 @@ VVTK_Renderer anActor->SetHighlightProperty(NULL); anActor->SetInsideCursorSettings(NULL); - anActor->SetPickingSettings(NULL); + //anActor->SetPickingSettings(NULL); } }