]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
VISU 2008 - Unification of the VISU selection functionality (debug)
authorouv <ouv@opencascade.com>
Mon, 26 May 2008 10:14:10 +0000 (10:14 +0000)
committerouv <ouv@opencascade.com>
Mon, 26 May 2008 10:14:10 +0000 (10:14 +0000)
36 files changed:
resources/Makefile.am
resources/SalomeApp.xml
resources/Visu_actor_selection.png [new file with mode: 0644]
resources/Visu_apply.png [new file with mode: 0644]
resources/Visu_cell_selection.png [new file with mode: 0644]
resources/Visu_close.png [new file with mode: 0644]
resources/Visu_gauss_point_selection.png [new file with mode: 0644]
resources/Visu_help.png [new file with mode: 0644]
resources/Visu_ok.png [new file with mode: 0644]
resources/Visu_point_selection.png [new file with mode: 0644]
resources/Visu_selection_panel.png [new file with mode: 0644]
src/OBJECT/Makefile.am
src/OBJECT/VISU_Actor.cxx
src/OBJECT/VISU_Actor.h
src/OBJECT/VISU_GaussPtsAct.cxx
src/OBJECT/VISU_GaussPtsAct.h
src/OBJECT/VISU_GaussPtsDeviceActor.cxx
src/OBJECT/VISU_GaussPtsSettings.cxx
src/OBJECT/VISU_GaussPtsSettings.h
src/OBJECT/VISU_PickingSettings.cxx [new file with mode: 0644]
src/OBJECT/VISU_PickingSettings.h [new file with mode: 0644]
src/VISUGUI/VISU_images.ts
src/VISUGUI/VISU_msg_en.ts
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI.h
src/VISUGUI/VisuGUI_ActionsDef.h
src/VISUGUI/VisuGUI_BasePanel.cxx
src/VISUGUI/VisuGUI_BasePanel.h
src/VISUGUI/VisuGUI_GaussPointsSelectionPane.cxx
src/VISUGUI/VisuGUI_GaussPointsSelectionPane.h
src/VISUGUI/VisuGUI_InputPanel.cxx
src/VISUGUI/VisuGUI_InputPanel.h
src/VISUGUI/VisuGUI_SelectionPanel.cxx
src/VISUGUI/VisuGUI_SelectionPanel.h
src/VVTK/VVTK_PickingDlg.cxx
src/VVTK/VVTK_Renderer.cxx

index 148851d3139cb16220b60237cbcedb840617cf6d..1daf455b6e2ef0ba941c004b1998456cd8e0c0e5 100644 (file)
@@ -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 \
index dfd869d57f1c581e8002b5b50a95ecc7ff4881de..b7e6fed16cb84be23c509e8553b8a76a9a8d37cf 100644 (file)
     <parameter name="picking_pyramid_height"  value="1.0"/>
     <parameter name="picking_selection_color" value="255, 255, 0"/>
     <parameter name="picking_point_tolerance" value="0.01"/>
+    <parameter name="picking_info_window"  value="false" />
     <parameter name="picking_transparency" value="50" />
     <parameter name="picking_position"     value="0"  />
+    <parameter name="picking_camera_movement"  value="false" />
     <parameter name="picking_zoom_factor"  value="1.5"/>
     <parameter name="picking_step_number"  value="10" />
     <parameter name="picking_display_parent_mesh" value="false" />
diff --git a/resources/Visu_actor_selection.png b/resources/Visu_actor_selection.png
new file mode 100644 (file)
index 0000000..f94b29d
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 (file)
index 0000000..3a225a1
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 (file)
index 0000000..8e2dc4f
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 (file)
index 0000000..d5f353e
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 (file)
index 0000000..8129a9e
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 (file)
index 0000000..452b45f
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 (file)
index 0000000..8ce1457
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 (file)
index 0000000..bcc9203
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 (file)
index 0000000..4c95efe
Binary files /dev/null and b/resources/Visu_selection_panel.png differ
index 3dcac5f02b28ac65570744363a33760fbadafcd1..60acb9b0815c45af18b68fdd0c2a93482bb01a95 100644 (file)
@@ -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 \
index 8d448e7f542c76de17e8a406711f05e8fe2996b2..58c8409196dcf1616a7c053ac046229312f6fce9 100644 (file)
 //  $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"
 #include <vtkGeometryFilter.h>
 #include <vtkObjectFactory.h>
 
+#include <vtkCallbackCommand.h>
+#include <vtkCamera.h>
+#include <vtkRenderWindowInteractor.h>
+
 #include <boost/bind.hpp>
 
 #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 = "<<this);
 
@@ -104,6 +120,19 @@ VISU_Actor
 
   myAnnotationActor->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<class TData> 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<class TData> 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<vtkObject*>(theClientData))
+    if(VISU_Actor* self = dynamic_cast<VISU_Actor*>(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();
+}
index 962894177d025500559c6ae95d681a30b414ce18..8377ec9498085abce324f49d8fd61353cd41a583 100644 (file)
@@ -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<vtkCallbackCommand> 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<VISU_PipeLine> myPipeLine;
@@ -264,6 +312,11 @@ class VTKOCC_EXPORT VISU_Actor :
 
   vtkSmartPointer<vtkTextMapper> myAnnotationMapper;
   vtkSmartPointer<vtkTextActor>  myAnnotationActor;
+
+  vtkSmartPointer<VISU_FramedTextActor> myTextActor;
+
+  Selection_Mode myLastSelectionMode;
+  bool myIsSubElementsHighlighted;
 };
 
 #endif //VISU_ACTOR_H
index 8d30e2450e9707cc1091f25b62e8f1466edd519f..e5eadc859b286ad4e54532b727fd5789f1900408 100644 (file)
@@ -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 = "<<this);
   SetWidgetCtrl(NULL);
   SetInteractor(NULL);
-  SetPickingSettings(NULL);
   SetInsideCursorSettings(NULL);
 }
 
@@ -291,14 +290,11 @@ VISU_GaussPtsAct
 
   myDeviceActor->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());
 
index 5cf5086f746597e2c12b61ffc52f4d49f35ed857..b4105a2b8d88d5024fa544e60fdcfb09c9e3192b 100644 (file)
@@ -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<VISU_FramedTextActor> myTextActor;
-
   vtkSmartPointer<VISU_CursorPyramid> myCursorPyramid;
   vtkSmartPointer<VISU_CursorPyramid> myCursorPyramidSelected;
   
@@ -330,7 +324,6 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_Actor
   vtkSmartPointer<VISU_ScalarBarCtrl> myScalarBarCtrl;
 
   VISU_InsideCursorSettings* myInsideCursorSettings;
-  VISU_PickingSettings* myPickingSettings;
 };
 
 
index c4b084daa489a8343fc7853a13d6a0f97bfddc14..925865164d03b8e32b069ae9408c7f4e786ba849 100644 (file)
@@ -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);
index 196e5c6c91720fa11df5a90509549d78d00deeed..1518c8ee41044037479aaed1224b22b524feb362 100644 (file)
@@ -28,6 +28,9 @@
 
 #include "VISU_GaussPtsSettings.h"
 
+#include "SUIT_ResourceMgr.h"
+#include "SUIT_Session.h"
+
 #include <vtkObjectFactory.h>
 #include <vtkImageData.h>
 
@@ -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()
-{
-}
index 3d7389523f5fbccaed754c6ab5dc9db24867d421..11435aebee5317196c40578c1c2860e9bcc7f556 100644 (file)
@@ -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 (file)
index 0000000..ae29565
--- /dev/null
@@ -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 <vtkObjectFactory.h>
+
+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 (file)
index 0000000..c5f30b3
--- /dev/null
@@ -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 <vtkObject.h>
+#include <vtkCommand.h>
+
+#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
index 46aac25d2b6f93adb6600902f10e112f8d77216f..12a5e8282097b0cfc3d60c6797f299b409c6f42b 100644 (file)
@@ -2,10 +2,26 @@
 <TS version="1.1" >
     <context>
         <name>@default</name>
+        <message>
+            <source>ICON_ACTOR_SELECTION</source>
+            <translation>Visu_actor_selection.png</translation>
+        </message>
         <message>
             <source>ICON_ADD</source>
             <translation>Visu_add.png</translation>
         </message>
+        <message>
+            <source>ICON_APPLY</source>
+            <translation>Visu_apply.png</translation>
+        </message>
+        <message>
+            <source>ICON_CELL_SELECTION</source>
+            <translation>Visu_cell_selection.png</translation>
+        </message>
+        <message>
+            <source>ICON_CLOSE</source>
+            <translation>Visu_close.png</translation>
+        </message>
         <message>
             <source>ICON_CUBE_AXES</source>
             <translation>Visu_graduated_axes.png</translation>
             <source>ICON_GAUSS_NEW_VIEWER</source>
             <translation>Visu_points.png</translation>
         </message>
+        <message>
+            <source>ICON_GAUSS_POINT_SELECTION</source>
+            <translation>Visu_gauss_point_selection.png</translation>
+        </message>
         <message>
             <source>ICON_GAUSS_POINTS</source>
             <translation>Visu_gauss_points.png</translation>
             <source>ICON_GLOBAL_SELECTION</source>
             <translation>Visu_selectall.png</translation>
         </message>
+        <message>
+            <source>ICON_HELP</source>
+            <translation>Visu_help.png</translation>
+        </message>
         <message>
             <source>ICON_HOLO_RENDER</source>
             <translation>Visu_holo_render.png</translation>
             <source>ICON_OBJBROWSER_Visu</source>
             <translation>Visu_tree_visu.png</translation>
         </message>
+        <message>
+            <source>ICON_OK</source>
+            <translation>Visu_ok.png</translation>
+        </message>
         <message>
             <source>ICON_PARTIAL_SELECTION</source>
             <translation>Visu_selectonly.png</translation>
             <source>ICON_PLOT_3D</source>
             <translation>Visu_plot3d.png</translation>
         </message>
+        <message>
+            <source>ICON_POINT_SELECTION</source>
+            <translation>Visu_point_selection.png</translation>
+        </message>
         <message>
             <source>ICON_POINTS</source>
             <translation>Visu_points.png</translation>
             <source>ICON_SCALING</source>
             <translation>Visu_scaling.png</translation>
         </message>
+        <message>
+            <source>ICON_SELECTION_PANEL</source>
+            <translation>Visu_selection_panel.png</translation>
+        </message>
         <message>
             <source>ICON_SLIDER_AVI</source>
             <translation>Visu_slider_avi.png</translation>
index ceacca2e80f7365aeeba9678efed93436e25f596..46313199a46bff5d211bc5536a135e6ddbf89a39 100644 (file)
@@ -864,6 +864,10 @@ Please, refer to the documentation.</translation>
             <source>IMPORT_FROM_FILE</source>
             <translation>Import from File</translation>
         </message>
+        <message>
+            <source>MEN_ACTOR_SELECTION</source>
+            <translation>Actor Selection</translation>
+        </message>
         <message>
             <source>MEN_ARRANGE_ACTORS</source>
             <translation>Arrange Actors</translation>
@@ -876,6 +880,10 @@ Please, refer to the documentation.</translation>
             <source>MEN_CELL_COLOR</source>
             <translation>Cell color</translation>
         </message>
+        <message>
+            <source>MEN_CELL_SELECTION</source>
+            <translation>Cell Selection</translation>
+        </message>
         <message>
             <source>MEN_CLEAR_CONTAINER</source>
             <translation>Clear</translation>
@@ -980,6 +988,10 @@ Please, refer to the documentation.</translation>
             <source>MEN_FREE_SCALAR_BARS</source>
             <translation>Use Field Range</translation>
         </message>
+        <message>
+            <source>MEN_GAUSS_POINT_SELECTION</source>
+            <translation>Gauss Point Selection</translation>
+        </message>
         <message>
             <source>MEN_GLOBAL_SELECTION</source>
             <translation>Global Selection</translation>
@@ -1068,6 +1080,10 @@ Please, refer to the documentation.</translation>
             <source>MEN_PLOT_3D</source>
             <translation>Plot3D</translation>
         </message>
+        <message>
+            <source>MEN_POINT_SELECTION</source>
+            <translation>Point Selection</translation>
+        </message>
         <message>
             <source>MEN_POINTS</source>
             <translation>Points</translation>
@@ -1184,6 +1200,10 @@ Please, refer to the documentation.</translation>
             <source>TOOL_REPRESENTATION</source>
             <translation>Representation Toolbar</translation>
         </message>
+        <message>
+            <source>TOOL_SELECTION</source>
+            <translation>Selection Toolbar</translation>
+        </message>
         <message>
             <source>TOOL_VISUALISATION</source>
             <translation>Visualization Toolbar</translation>
@@ -1900,7 +1920,7 @@ Please, provide non-empty resulting presentation.</translation>
         <name>VisuGUI_GaussPointsSelectionPane</name>
         <message>
             <source>BELOW_POINT</source>
-            <translation>Centered below the point</translation>
+            <translation>Centered</translation>
         </message>
         <message>
             <source>CAMERA_TITLE</source>
@@ -1947,8 +1967,12 @@ Please, provide non-empty resulting presentation.</translation>
             <translation>Selection cursor color :</translation>
         </message>
         <message>
-            <source>STEP_NUMBER</source>
-            <translation>Number of steps between two positions :</translation>
+            <source>STEP_NUMBER_DSC</source>
+            <translation>Number of steps :</translation>
+        </message>
+        <message>
+            <source>STEP_NUMBER_TIP</source>
+            <translation>Number of steps between two positions</translation>
         </message>
         <message>
             <source>TOLERANCE_TITLE</source>
@@ -1956,15 +1980,19 @@ Please, provide non-empty resulting presentation.</translation>
         </message>
         <message>
             <source>TOP_LEFT_CORNER</source>
-            <translation>Top-left corner of the 3D view</translation>
+            <translation>Top-left corner</translation>
         </message>
         <message>
             <source>TRANSPARENCY</source>
             <translation>Transparency :</translation>
         </message>
         <message>
-            <source>ZOOM_FACTOR</source>
-            <translation>Zoom at first selected point (ratio) :</translation>
+            <source>ZOOM_FACTOR_DSC</source>
+            <translation>Zoom factor :</translation>
+        </message>
+        <message>
+            <source>ZOOM_FACTOR_TIP</source>
+            <translation>Zoom at first selected point (ratio)</translation>
         </message>
         <message>
             <source>DATA_POSITION</source>
@@ -3158,7 +3186,7 @@ Please, refer to the documentation.</translation>
         <name>VisuGUI_SelectionPanel</name>
         <message>
             <source>WINDOW_TITLE</source>
-            <translation>Data on elements</translation>
+            <translation>Selection info</translation>
         </message>
         <message>
             <source>MODE_TITLE</source>
@@ -3232,6 +3260,46 @@ Please, refer to the documentation.</translation>
            <source>ACTOR_DATA_SIZE_TITLE</source>
             <translation>Size</translation>
         </message>
+        <message>
+            <source>BELOW_POINT</source>
+            <translation>Centered</translation>
+        </message>
+        <message>
+            <source>CAMERA_TITLE</source>
+            <translation>Movement of the camera</translation>
+        </message>
+        <message>
+            <source>INFO_WINDOW_TITLE</source>
+            <translation>Information window</translation>
+        </message>
+        <message>
+            <source>POSITION</source>
+            <translation>Position :</translation>
+        </message>
+        <message>
+            <source>STEP_NUMBER_DSC</source>
+            <translation>Number of steps :</translation>
+        </message>
+        <message>
+            <source>STEP_NUMBER_TIP</source>
+            <translation>Number of steps between two positions</translation>
+        </message>
+        <message>
+            <source>TOP_LEFT_CORNER</source>
+            <translation>Top-left corner</translation>
+        </message>
+        <message>
+            <source>TRANSPARENCY</source>
+            <translation>Transparency :</translation>
+        </message>
+        <message>
+            <source>ZOOM_FACTOR_DSC</source>
+            <translation>Zoom factor :</translation>
+        </message>
+        <message>
+            <source>ZOOM_FACTOR_TIP</source>
+            <translation>Zoom at first selected point (ratio)</translation>
+        </message>
     </context>
     <context>
         <name>VisuGUI_BarPrefDlg</name>
index 3ce326cdedef73bcabbc1afd355ed40e30d977c5..242de2787f5130fe547e7d0ff248738a3a071ffc 100644 (file)
@@ -1787,8 +1787,6 @@ VisuGUI
 {
   if (GetActiveViewWindow<SVTK_ViewWindow>(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<SVTK_ViewWindow>(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<QAction*>( 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 )
 {
index 8dc56b136c1a13add0bc1e4091f2e7568ac395a4..560f7c2edd3f747ef0fdea309ef327d8c5e7570a 100644 (file)
@@ -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;
index 40ef7783f5a01bda867e60353c0be85ef7fa5026..7ea0936e286a7f35ce74103977900ab6c99e6914 100644 (file)
 #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
index 4c6dcf7062b044141bce034c8ffed02d2227e3e0..4d131cf202fa937f5f9f33e19ffe55af92aef748 100755 (executable)
 //  Author : Oleg Uvarov
 //  Module : VISU
 
-#include <VisuGUI_BasePanel.h>
+#include "VisuGUI_BasePanel.h"
+#include "VisuGUI_Tools.h"
+
+#include "SUIT_ResourceMgr.h"
 
 #include <QScrollArea>
-#include <QPushButton>
 #include <QHBoxLayout>
 #include <QVBoxLayout>
 #include <QApplication>
+#include <QPushButton>
+//#include <QToolButton>
 
 /*!
   \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 );
 }
 
index 822e85d4629e0bdc0d2bf4bda1e638c061640cd6..775a9426b03549e0dbd8db4b701f24af2ffa2c3b 100755 (executable)
@@ -69,7 +69,7 @@ protected:
   QFrame*                   mainFrame();
 
 protected:
-  //QScrollArea*              myView;
+  QScrollArea*              myView;
   QFrame*                   myMainFrame;
 
   QPushButton*              myOK;
index 2d8ddef97f57316c417fc1d78c3e92010453bd27..98ed64ed103d550e37ff01e06dba6b274f974815 100644 (file)
@@ -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()
 {
index c70f37dfd0046a5e3719ce2ba6d48132aa4a91de..a00f47f20de4cebd093b28e2b742787bf154d450 100644 (file)
@@ -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<VISU_PickingSettings> myPickingSettings;
 
   VisuGUI_ValidatedLineEdit*            myParentElementLineEdit;
   VisuGUI_ValidatedLineEdit*            myLocalPointLineEdit;
index 246d2997e3f4b546f4faea5cd0c4d00bf5923f7f..e634ac8fb9e3f89da174eae19a41d3c78486aff9 100755 (executable)
 
 #include "VisuGUI_InputPanel.h"
 #include "VisuGUI_BasePanel.h"
-#include "VisuGUI_Module.h"
-
-#include <SalomeApp_Application.h>
 
 #include <QVBoxLayout>
 
-#include <SUIT_ResourceMgr.h>
-#include <SUIT_Session.h>
-
 /*!
  * \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<VisuGUI_BasePanel*, bool>::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().
 */
index 2e5764768f1d6d6d0374597bd48ed51a8545ce3d..b295b0b1324366145a6d7dba33ae1c65d8eda5b1 100755 (executable)
@@ -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<VisuGUI_BasePanel*, bool> myPanels;
   VisuGUI_BasePanel* myCurrentPanel;
 };
 
index 43d8984d0379d9557b30d94ec3f7891721cbec1f..9a7b6711cdc225f897ad83369cd12ff8b9faaec0 100644 (file)
@@ -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 <QRadioButton>
 #include <QValidator>
 #include <QPushButton>
+#include <QToolButton>
 #include <QGroupBox>
 #include <QLineEdit>
 #include <QValidator>
@@ -84,6 +91,8 @@
 #include <QKeyEvent>
 #include <QHeaderView>
 #include <QTabWidget>
+#include <QScrollArea>
+#include <QComboBox>
 
 // VTK Includes
 #include <vtkDataSetMapper.h>
 
 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<SalomeApp_Application*>
     (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<SVTK_ViewWindow>(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<class TData> QString getVector(TData* theData, int theId){
   }
 }
 
-#define ABS(a) (a>=0)?a:-a
-
 void VisuGUI_SelectionPanel::onSelectionEvent() {
   SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>(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<vtkFloatingPointType> 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<VISU_GaussPointsPL*>( 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<VISU_Actor>(anInteractor->getRenderer()->GetActors(),
+                                                  SVTK::TIsSameIObject<VISU_Actor>( 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();
 }
 
index 01c4f77ae27784fc65c274a50eebf6bd2fb067a5..17aad529544525e38a52b768692419deee889374 100644 (file)
 
 #include <VisuGUI_BasePanel.h>
 
+#include <vtkSmartPointer.h>
+
+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;
index 75670122be675f69950d0fa04f6bd852d668edbe..06b7f26eb7db3edf23a6d190c352100950be03c7 100644 (file)
@@ -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() );
index 8b56aede642ec584fe51d9d2a33c85076d9ad651..d0e3d6a1a0b77ee1e7dc5d2800ea4ac829b2b6d0 100644 (file)
@@ -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);
   }
 }