From f24ec45eb935ae327b5da15cbff9c3317396bc58 Mon Sep 17 00:00:00 2001 From: apo Date: Thu, 17 Nov 2005 12:24:58 +0000 Subject: [PATCH] Fix for Bug GVIEW10539 selction info dialog --- src/OBJECT/VISU_Event.h | 3 + src/OBJECT/VISU_GaussPtsAct.cxx | 99 +++++++++++++++---------------- src/VISUGUI/VisuGUI.cxx | 2 +- src/VISUGUI/VisuGUI_Selection.cxx | 58 +++++++++--------- src/VISUGUI/VisuGUI_Selection.h | 4 +- src/VVTK/VVTK_InteractorStyle.cxx | 4 +- src/VVTK/VVTK_MainWindow.cxx | 3 +- 7 files changed, 88 insertions(+), 85 deletions(-) diff --git a/src/OBJECT/VISU_Event.h b/src/OBJECT/VISU_Event.h index e9850df9..7c613cf2 100644 --- a/src/OBJECT/VISU_Event.h +++ b/src/OBJECT/VISU_Event.h @@ -30,6 +30,7 @@ #define VISU_Event_h #include "SVTK_Event.h" +#include "SVTK_Selection.h" namespace VISU { @@ -40,5 +41,7 @@ namespace VISU LastEvent }; } + +const Selection_Mode GaussPointSelection = 100; #endif diff --git a/src/OBJECT/VISU_GaussPtsAct.cxx b/src/OBJECT/VISU_GaussPtsAct.cxx index 97f3c6f0..99b2585a 100644 --- a/src/OBJECT/VISU_GaussPtsAct.cxx +++ b/src/OBJECT/VISU_GaussPtsAct.cxx @@ -506,60 +506,54 @@ bool VISU_GaussPtsAct::PreHighlight(vtkInteractorStyle* theInteractorStyle, if(aSelectionMode == ActorSelection || !theIsHighlight) return Superclass::PreHighlight(theInteractorStyle, theSelectionEvent, - theIsHighlight); + theIsHighlight); bool anIsChanged = (mySelectionMode != aSelectionMode); bool anIsPreselected = myIsPreselected; + myIsPreselected = false; - if(theIsHighlight){ - switch(mySelectionMode){ - case NodeSelection: - case CellSelection: - { - myPointPicker->Pick(theSelectionEvent->myX, - theSelectionEvent->myY, - 0.0, - theInteractorStyle->GetCurrentRenderer()); - - if(myPointPicker->GetActor() != this) - return false; - - vtkIdType aVtkId = myPointPicker->GetPointId(); - - if(aVtkId >= 0 && mySelector->IsValid(this,aVtkId,true) && hasIO()){ - vtkIdType anObjId = GetNodeObjId( aVtkId ); - myIsPreselected = (anObjId >= 0); - if(myIsPreselected){ - anIsChanged = (myLastObjPointID != anObjId); - if(anIsChanged){ - float* aNodeCoord = GetNodeCoord(anObjId); - vtkDataSet* aDataSet = GetInput(); - vtkCellData* aCellData = aDataSet->GetCellData(); - if(vtkDataArray *aScalarArray = aCellData->GetScalars()){ - float aRadius = myGaussPointsPL->GetPointSize(aVtkId,aScalarArray); - float aPyramidHeight = myPickingSettings->GetPyramidHeight(); - aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize(); - //float aColor[3] = myPreHighlightActor->GetProperty()->GetColor(); - float aColor[3]; - theInteractorStyle->GetCurrentRenderer()->GetBackground( aColor ); - aColor[0] = 1. - aColor[0]; - aColor[1] = 1. - aColor[1]; - aColor[2] = 1. - aColor[2]; - myCursorPyramid->Init(aPyramidHeight, - aRadius, - aNodeCoord, - aColor); - } - myLastObjPointID = anObjId; + if(aSelectionMode == GaussPointSelection && theIsHighlight){ + myPointPicker->Pick(theSelectionEvent->myX, + theSelectionEvent->myY, + 0.0, + theInteractorStyle->GetCurrentRenderer()); + + if(myPointPicker->GetActor() != this) + return (anIsPreselected != myIsPreselected); + + vtkIdType aVtkId = myPointPicker->GetPointId(); + + if(aVtkId >= 0 && mySelector->IsValid(this,aVtkId,true) && hasIO()){ + vtkIdType anObjId = GetNodeObjId( aVtkId ); + myIsPreselected = (anObjId >= 0); + if(myIsPreselected){ + anIsChanged = (myLastObjPointID != anObjId); + if(anIsChanged){ + float* aNodeCoord = GetNodeCoord(anObjId); + vtkDataSet* aDataSet = GetInput(); + vtkCellData* aCellData = aDataSet->GetCellData(); + if(vtkDataArray *aScalarArray = aCellData->GetScalars()){ + float aRadius = myGaussPointsPL->GetPointSize(aVtkId,aScalarArray); + float aPyramidHeight = myPickingSettings->GetPyramidHeight(); + aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize(); + //float aColor[3] = myPreHighlightActor->GetProperty()->GetColor(); + float aColor[3]; + theInteractorStyle->GetCurrentRenderer()->GetBackground( aColor ); + aColor[0] = 1. - aColor[0]; + aColor[1] = 1. - aColor[1]; + aColor[2] = 1. - aColor[2]; + myCursorPyramid->Init(aPyramidHeight, + aRadius, + aNodeCoord, + aColor); } - myCursorPyramid->SetVisibility(true); + myLastObjPointID = anObjId; } + myCursorPyramid->SetVisibility(true); } } - break; - } } - + mySelectionMode = aSelectionMode; anIsChanged |= (anIsPreselected != myIsPreselected); @@ -599,7 +593,10 @@ bool VISU_GaussPtsAct::Highlight(vtkInteractorStyle* theInteractorStyle, { Handle(SALOME_InteractiveObject) anIO = getIO(); int anInitialHasIndex = mySelector->HasIndex(anIO); - if(!theIsHighlight){ + + Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode; + // + if(!theIsHighlight && aSelectionMode == GaussPointSelection){ mySelector->RemoveIObject(anIO); ChangeZoom(myPickingSettings, @@ -615,15 +612,13 @@ bool VISU_GaussPtsAct::Highlight(vtkInteractorStyle* theInteractorStyle, return false; } // - Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode; - // if(aSelectionMode == ActorSelection){ return Superclass::Highlight(theInteractorStyle, theSelectionEvent, theIsHighlight); } // - if(!theSelectionEvent->myIsRectangle){ + if(aSelectionMode == GaussPointSelection && !theSelectionEvent->myIsRectangle){ vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer(); myPointPicker->Pick(theSelectionEvent->myX, @@ -713,8 +708,12 @@ VISU_GaussPtsAct bool anIsVisible = GetVisibility(); - if(mySelector->SelectionMode() == ActorSelection) + Selection_Mode aSelectionMode = mySelector->SelectionMode(); + + if(aSelectionMode == ActorSelection) Superclass::highlight(theIsHighlight); + else if(aSelectionMode != GaussPointSelection) + return; TColStd_IndexedMapOfInteger aMapIndex; mySelector->GetIndex( getIO(), aMapIndex ); diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 9e5841c5..8a4e36e2 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -1763,7 +1763,7 @@ VisuGUI:: OnSelectionInfo() { if (GetViewWindow(this)) - (new VisuGUI_SelectionDlg(GetDesktop(this)))->show(); + (new VisuGUI_SelectionDlg(this))->show(); else SUIT_MessageBox::warn1(GetDesktop(this), tr("WRN_VISU"), diff --git a/src/VISUGUI/VisuGUI_Selection.cxx b/src/VISUGUI/VisuGUI_Selection.cxx index 0948023b..760ff2f3 100644 --- a/src/VISUGUI/VisuGUI_Selection.cxx +++ b/src/VISUGUI/VisuGUI_Selection.cxx @@ -89,10 +89,13 @@ using namespace std; static VisuGUI_SelectionDlg* mySelectionDlg = NULL; -VisuGUI_SelectionDlg::VisuGUI_SelectionDlg (QWidget* parent) - : QDialog(parent, 0, false, WStyle_Customize | WStyle_NormalBorder | - WStyle_Title | WStyle_SysMenu | WDestructiveClose), - mySelectionMgr(NULL) +VisuGUI_SelectionDlg::VisuGUI_SelectionDlg (const SalomeApp_Module* theModule): + QDialog(VISU::GetDesktop(theModule), + 0, + false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose), + mySelectionMgr(NULL), + myModule(theModule) { if (mySelectionDlg) mySelectionDlg->close(true); @@ -259,10 +262,9 @@ VisuGUI_SelectionDlg::VisuGUI_SelectionDlg (QWidget* parent) myFl = false; // Activate Points pane - SVTK_ViewWindow* aSVTKVW = VISU::GetViewWindow(); myWidgetStack->raiseWidget(myPointsPane); - if (aSVTKVW) - aSVTKVW->SetSelectionMode(NodeSelection); + if(SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(myModule)) + aViewWindow->SetSelectionMode(NodeSelection); onSelectionEvent(); mySelectionDlg = this; @@ -274,23 +276,23 @@ VisuGUI_SelectionDlg::~VisuGUI_SelectionDlg() void VisuGUI_SelectionDlg::onSelectionChange (int theId) { - SVTK_ViewWindow* aSVTKVW = VISU::GetViewWindow(); - if (!aSVTKVW) return; + SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(myModule); + if (!aViewWindow) return; switch (theId) { case 0: // Points myWidgetStack->raiseWidget(myPointsPane); - aSVTKVW->SetSelectionMode(NodeSelection); + aViewWindow->SetSelectionMode(NodeSelection); onPointIdEdit(myIDValLbl->text()); break; case 1: // Cells myWidgetStack->raiseWidget(myCellsPane); - aSVTKVW->SetSelectionMode(CellSelection); + aViewWindow->SetSelectionMode(CellSelection); onCellIdEdit(myCellIDValLbl->text()); break; case 2: // Actor myWidgetStack->raiseWidget(myActorsPane); - aSVTKVW->SetSelectionMode(ActorSelection); + aViewWindow->SetSelectionMode(ActorSelection); onSelectionEvent(); } } @@ -298,11 +300,9 @@ void VisuGUI_SelectionDlg::onSelectionChange (int theId) void VisuGUI_SelectionDlg::closeEvent (QCloseEvent* theEvent) { - SVTK_ViewWindow* aSVTKVW = VISU::GetViewWindow(); - mySelectionDlg = NULL; - if (aSVTKVW) - aSVTKVW->SetSelectionMode(ActorSelection); + if(SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(myModule)) + aViewWindow->SetSelectionMode(ActorSelection); disconnect(mySelectionMgr,0,0,0); QDialog::closeEvent(theEvent); } @@ -328,8 +328,8 @@ template QString getVector(TData* theData, int theId){ #define ABS(a) (a>=0)?a:-a void VisuGUI_SelectionDlg::onSelectionEvent() { - SVTK_ViewWindow* aSVTKVW = VISU::GetViewWindow(); - if (!aSVTKVW) return; + SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(myModule); + if (!aViewWindow) return; if (myFl) return; myFl = true; @@ -339,14 +339,14 @@ void VisuGUI_SelectionDlg::onSelectionEvent() { SalomeApp_Application* anApp = dynamic_cast (SUIT_Session::session()->activeApplication()); - SVTK_Selector* aSelector = aSVTKVW->GetSelector(); + SVTK_Selector* aSelector = aViewWindow->GetSelector(); VISU::Prs3d_i* aPrs3d = NULL; _PTR(SObject) aSObject; Handle(SALOME_InteractiveObject) anIO; SALOME_ListIO aListIO; - mySelectionMgr->selectedObjects(aListIO, SVTK_Viewer::Type()); + mySelectionMgr->selectedObjects(aListIO); if (aListIO.Extent() == 1) { anIO = aListIO.First(); @@ -392,7 +392,7 @@ void VisuGUI_SelectionDlg::onSelectionEvent() { myFieldName->setText((aFieldName == "NULL") ? QString("No name") : aFieldName); VISU_Actor* anVISUActor = - VISU::FindActor(aSVTKVW, aSObject->GetID().c_str()); + VISU::FindActor(aViewWindow, aSObject->GetID().c_str()); if (anVISUActor) { float aCoord[6]; anVISUActor->GetBounds(aCoord); @@ -512,16 +512,16 @@ typedef vtkIdType (vtkDataSet::* TDataSetMethod)(); bool onIdEdit (const QString& theText, TDataSetMethod theMethod, bool theIsCell, + const SalomeApp_Module* theModule, SalomeApp_SelectionMgr* theSelectionMgr, QLabel* theMeshName, QString theValue, QLabel* theFieldName) { - SalomeApp_Application* anApp = dynamic_cast - (SUIT_Session::session()->activeApplication()); - SVTK_ViewWindow* aSVTKVW = VISU::GetViewWindow(); - if (!aSVTKVW) return false; - SVTK_Selector* aSelector = aSVTKVW->GetSelector(); + SalomeApp_Application* anApp = theModule->getApp(); + SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(theModule); + if (!aViewWindow) return false; + SVTK_Selector* aSelector = aViewWindow->GetSelector(); VISU::Prs3d_i* aPrs3d = NULL; Handle(SALOME_InteractiveObject) anIO; @@ -561,7 +561,7 @@ bool onIdEdit (const QString& theText, TColStd_MapOfInteger newIndices; newIndices.Add(anId); aSelector->AddOrRemoveIndex(anIO, newIndices, false); - aSVTKVW->highlight(anIO, true, true); + aViewWindow->highlight(anIO, true, true); return true; @@ -576,7 +576,7 @@ void VisuGUI_SelectionDlg::onPointIdEdit (const QString& theText) { if (myFl) return; TDataSetMethod aMethod = &vtkDataSet::GetNumberOfPoints; - bool anIsSelected = onIdEdit(theText,aMethod,false,mySelectionMgr, + bool anIsSelected = onIdEdit(theText,aMethod,false,myModule,mySelectionMgr, myMeshName,tr("WRN_NO_AVAILABLE_DATA"), myFieldName); if (anIsSelected) @@ -590,7 +590,7 @@ void VisuGUI_SelectionDlg::onCellIdEdit (const QString& theText) { if (myFl) return; TDataSetMethod aMethod = &vtkDataSet::GetNumberOfCells; - bool anIsSelected = onIdEdit(theText,aMethod,true,mySelectionMgr, + bool anIsSelected = onIdEdit(theText,aMethod,true,myModule,mySelectionMgr, myMeshName,tr("WRN_NO_AVAILABLE_DATA"), myFieldName); if (anIsSelected) diff --git a/src/VISUGUI/VisuGUI_Selection.h b/src/VISUGUI/VisuGUI_Selection.h index c1976404..9b3ac87b 100644 --- a/src/VISUGUI/VisuGUI_Selection.h +++ b/src/VISUGUI/VisuGUI_Selection.h @@ -38,12 +38,13 @@ class QLineEdit; class QTable; class SalomeApp_SelectionMgr; class SalomeApp_Application; +class SalomeApp_Module; class VisuGUI_SelectionDlg: public QDialog { Q_OBJECT public: - VisuGUI_SelectionDlg (QWidget*); + VisuGUI_SelectionDlg (const SalomeApp_Module* theModule); virtual ~VisuGUI_SelectionDlg (); protected: @@ -85,6 +86,7 @@ private slots: QLabel* myDYLbl; QLabel* myDZLbl; + const SalomeApp_Module* myModule; SalomeApp_SelectionMgr* mySelectionMgr; bool myFl; }; diff --git a/src/VVTK/VVTK_InteractorStyle.cxx b/src/VVTK/VVTK_InteractorStyle.cxx index 68367249..e95debe7 100644 --- a/src/VVTK/VVTK_InteractorStyle.cxx +++ b/src/VVTK/VVTK_InteractorStyle.cxx @@ -164,7 +164,7 @@ void VVTK_InteractorStyle ::OnKeyDown() { - if( GetSelector()->SelectionMode() != NodeSelection ) + if( GetSelector()->SelectionMode() != GaussPointSelection ) return; char key = Interactor->GetKeyCode(); @@ -176,8 +176,6 @@ VVTK_InteractorStyle FindPokedRenderer( x, y ); // calls SetCurrentRenderer myOtherPoint = myPoint = QPoint(x, y); - //printf ( "--- myPoint[ %d, %d ], myOtherPoint[ %d, %d ] ---\n", - //myPoint.x(), myPoint.y(), myOtherPoint.x(), myOtherPoint.y() ); startOperation(VTK_INTERACTOR_STYLE_CAMERA_SELECT); onFinishOperation(); diff --git a/src/VVTK/VVTK_MainWindow.cxx b/src/VVTK/VVTK_MainWindow.cxx index baba8608..ac1d5aa8 100644 --- a/src/VVTK/VVTK_MainWindow.cxx +++ b/src/VVTK/VVTK_MainWindow.cxx @@ -30,6 +30,7 @@ #include "VVTK_InteractorStyle.h" #include "VISU_ImplicitFunctionWidget.h" #include "VISU_GaussPtsAct.h" +#include "VISU_Event.h" #include "SVTK_RenderWindowInteractor.h" #include "VVTK_Renderer.h" @@ -85,7 +86,7 @@ void VVTK_MainWindow ::OnSelectionModeSwitch(bool theIsSelectionOn) { - SetSelectionMode(theIsSelectionOn? NodeSelection: ActorSelection); + SetSelectionMode(theIsSelectionOn? GaussPointSelection: ActorSelection); } //---------------------------------------------------------------------------- -- 2.39.2