]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix for Bug GVIEW10539
authorapo <apo@opencascade.com>
Thu, 17 Nov 2005 12:24:58 +0000 (12:24 +0000)
committerapo <apo@opencascade.com>
Thu, 17 Nov 2005 12:24:58 +0000 (12:24 +0000)
   selction info dialog

src/OBJECT/VISU_Event.h
src/OBJECT/VISU_GaussPtsAct.cxx
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI_Selection.cxx
src/VISUGUI/VisuGUI_Selection.h
src/VVTK/VVTK_InteractorStyle.cxx
src/VVTK/VVTK_MainWindow.cxx

index e9850df950174a97c37b5ae5c3455a1886c7cb4f..7c613cf209e2a1d6091efdeacec937a8e08cc902 100644 (file)
@@ -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
index 97f3c6f087bfbcfcb29e334d1992deefb26450c9..99b2585ad06141c400b64e115c06f238d356532b 100644 (file)
@@ -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 );
index 9e5841c5f7caafa6b568f2903dfe1d97ac631e23..8a4e36e25b166dc97f96c4958bacc99b87ba7829 100644 (file)
@@ -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"),
index 0948023b459d92bb790f3b14a6d4b53536123988..760ff2f3861d07e53ca0f8fc7f28e77c3bbff0a0 100644 (file)
@@ -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<class TData> 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<SalomeApp_Application*>
     (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<SalomeApp_Application*>
-    (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)
index c1976404996449c2e7bc899a31adb688d0d1cbe6..9b3ac87b07d4091e135951bebd9a019cceee91f8 100644 (file)
@@ -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;
 };
index 68367249431f43ba91bf1cc6cb0752775edec241..e95debe766d5bc7e42ea71237ca64428ac6e9fc8 100644 (file)
@@ -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();
index baba86082ffddc552f9cb995ebaac87ca09c0e7c..ac1d5aa8f0c7527c4eeb8d24744008d00a568507 100644 (file)
@@ -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);
 }
 
 //----------------------------------------------------------------------------