]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Merging GUI_SRC module with the BR_HDF_dev_merged branch, which has been merged with...
authornds <nds@opencascade.com>
Tue, 7 Oct 2008 09:39:28 +0000 (09:39 +0000)
committernds <nds@opencascade.com>
Tue, 7 Oct 2008 09:39:28 +0000 (09:39 +0000)
src/SUITApp/resources/SUITApp_msg_en.ts [new file with mode: 0644]
src/SVTK/SVTK_Selector.cxx
src/SVTK/SVTK_Selector.h
src/SVTK/SVTK_SelectorDef.h
src/SVTK/SVTK_View.cxx
src/SVTK/SVTK_View.h
src/SVTK/SVTK_ViewModel.cxx
src/SVTK/SVTK_ViewModel.h
src/SVTK/SVTK_ViewWindow.cxx
src/SVTK/SVTK_ViewWindow.h
src/Style/Style.qrc [new file with mode: 0644]

diff --git a/src/SUITApp/resources/SUITApp_msg_en.ts b/src/SUITApp/resources/SUITApp_msg_en.ts
new file mode 100644 (file)
index 0000000..20b003e
--- /dev/null
@@ -0,0 +1,17 @@
+<!DOCTYPE TS><TS>
+<context>
+    <name>@default</name>
+    <message>
+        <source>APP_OK</source>
+        <translation>Ok</translation>
+    </message>
+    <message>
+        <source>APP_ERROR</source>
+        <translation>Error</translation>
+    </message>
+    <message>
+        <source>APP_UNK_EXCEPTION</source>
+        <translation>Unknown exception</translation>
+    </message>
+</context>
+</TS>
index 86e9bc3358f8ab569524895942353ce1bd75867f..906574ca788e04f654cf0562956b895ebc18d305 100644 (file)
 
 #include "SVTK_SelectorDef.h"
 
-#include "VTKViewer_Filter.h"
+#include <VTKViewer_Filter.h>
 
 #include "SALOME_Actor.h"
 
+#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
+
 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
 #include <TColStd_IndexedMapOfInteger.hxx>
 
 #include <vtkCallbackCommand.h>
+#include <vtkActorCollection.h>
+#include <vtkCellPicker.h>
+
+
+/*!
+  Find first SALOME_Actor from the end of actors collection
+*/
+inline
+SALOME_Actor* 
+GetLastSALOMEActor(vtkActorCollection* theCollection)
+{
+  if (theCollection) {
+    for (int i = theCollection->GetNumberOfItems() - 1; i >= 0; i--) {
+      if (SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>(theCollection->GetItemAsObject(i)))
+       if (anActor->hasIO())
+         return anActor;
+    }
+  }
+  return NULL;
+}
+
 
 /*!
   \return new SVTK_Selector
@@ -52,9 +76,14 @@ SVTK_Selector
   Default constructor
 */
 SVTK_SelectorDef
-::SVTK_SelectorDef()
+::SVTK_SelectorDef():
+  myPicker(vtkPicker::New()),
+  myCellPicker(vtkCellPicker::New())
 {
   mySelectionMode = ActorSelection;
+
+  myPicker->Delete();
+  myCellPicker->Delete();
 }
 
 /*!
@@ -517,3 +546,43 @@ SVTK_SelectorDef
   return Handle(VTKViewer_Filter)();
 }
 
+SALOME_Actor*
+SVTK_SelectorDef
+::Pick(const SVTK_SelectionEvent* theEvent, vtkRenderer* theRenderer) const
+{
+  bool anAdvancedSelectionAlgorithm = true;
+  SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
+  if ( aResourceMgr )
+    anAdvancedSelectionAlgorithm = aResourceMgr->booleanValue( "VTKViewer", "use_advanced_selection_algorithm", true );
+
+  SALOME_Actor* anActor = NULL;
+  vtkActorCollection* aListActors = NULL;
+  if ( anAdvancedSelectionAlgorithm ) {
+    myCellPicker->Pick(theEvent->myX,
+                      theEvent->myY, 
+                      0.0,
+                      theRenderer);
+  
+    aListActors = myCellPicker->GetActors();
+    anActor = GetLastSALOMEActor(aListActors);
+  }
+
+  if ( !anActor ) {
+    myPicker->Pick(theEvent->myX,
+                  theEvent->myY, 
+                  0.0,
+                  theRenderer);
+    aListActors = myPicker->GetActors();
+    anActor = GetLastSALOMEActor(aListActors);
+  }
+  
+  return anActor;
+}
+
+void
+SVTK_SelectorDef
+::SetTolerance(const double& theTolerance) 
+{
+  myPicker->SetTolerance(theTolerance);        
+  myCellPicker->SetTolerance(theTolerance);
+}
index 17ab9be70df9d1a1c501ebdaea5169e5a5a25cab..0d65de7e3fcacd3e70feee2ed72e2424735de2f4 100644 (file)
@@ -41,6 +41,8 @@
 class Handle(VTKViewer_Filter);
 
 class SALOME_Actor;
+class SVTK_SelectionEvent;
+class vtkRenderer;
 class Handle(SALOME_InteractiveObject);
 
 //! Define an abstract interface for selection in SVTK package
@@ -206,6 +208,15 @@ public:
   virtual
   void 
   EndPickCallback() = 0;
+
+  //----------------------------------------------------------------------------
+  virtual
+  SALOME_Actor*
+  Pick(const SVTK_SelectionEvent* theEvent, vtkRenderer* theRenderer) const = 0;
+
+  virtual
+  void
+  SetTolerance(const double& theTolerance) = 0;
 };
 
 
index 6515a187b73b116b224a813e7e0b51afc74a80f7..70b95775636d3ed84719326f6c99c57347dd8390 100644 (file)
@@ -44,6 +44,8 @@ class SALOME_Actor;
 
 class SVTK_Viewer;
 class SVTK_ViewWindow;
+class vtkPicker;
+class vtkCellPicker;
 
 class SVTK_SelectorDef: public SVTK_Selector
 {
@@ -167,6 +169,15 @@ public:
   void 
   EndPickCallback();
 
+  //----------------------------------------------------------------------------
+  virtual
+  SALOME_Actor*
+  Pick(const SVTK_SelectionEvent* theEvent, vtkRenderer* theRenderer) const;
+
+  virtual
+  void
+  SetTolerance(const double& theTolerance);
+
 private:
   int mySelectionMode;
 
@@ -208,6 +219,9 @@ private:
 
   typedef std::map<TFilterID,Handle(VTKViewer_Filter)> TFilters;
   TFilters myFilters;
+
+  vtkSmartPointer<vtkPicker> myPicker;
+  vtkSmartPointer<vtkCellPicker> myCellPicker;
 };
 
 #endif
index e056d6d7783ed4122331dcdbb727bfc3054eb193..57e6e49eb3dd27fc82f03e32c86860f0e35209ea 100644 (file)
@@ -259,9 +259,10 @@ SVTK_View
 void
 SVTK_View
 ::SetSelectionTolerance(const double& theTolNodes, 
-                       const double& theTolCell)
+                       const double& theTolCell,
+                       const double& theTolObjects)
 {
-  GetRenderer()->SetSelectionTolerance(theTolNodes,theTolCell);
+  GetRenderer()->SetSelectionTolerance(theTolNodes, theTolCell, theTolObjects);
 }
 
 /*!
index af25bf5ea1944f5cfbe569f9349f8836d2398016..ff463ab5e8b7897ec2102a5bf29776d4639fed79 100644 (file)
@@ -258,7 +258,8 @@ public:
   //! Redirect the request to #SVTK_Renderer::SetPreselectionProp
   void
   SetSelectionTolerance(const double& theTolNodes = 0.025, 
-                       const double& theTolCell = 0.001);
+                       const double& theTolCell = 0.001,
+                       const double& theTolObjects = 0.025);
 
  protected:  
   int myDisplayMode;
index 990a96ee9ea0713d82f2e88de836fa0a40efcc10..b8edb171c6a705b1030d7668bc7481c2f98b2441 100644 (file)
@@ -196,9 +196,11 @@ SVTK_Viewer
   thePopup->addSeparator();
 
   if(TViewWindow* aView = dynamic_cast<TViewWindow*>(myViewManager->getActiveView())){
-    if ( !aView->getMainWindow()->getToolBar()->isVisible() ){
-      thePopup->addAction( VTKViewer_Viewer::tr( "MEN_SHOW_TOOLBAR" ), this, SLOT( onShowToolbar() ) );
-    }
+    //Support of several toolbars in the popup menu
+    QList<QToolBar*> lst = qFindChildren<QToolBar*>( aView );
+    QList<QToolBar*>::const_iterator it = lst.begin(), last = lst.end();
+    for( ; it!=last; it++ )
+      thePopup->addAction( (*it)->toggleViewAction() );
     aView->RefreshDumpImage();
   }
 }
@@ -275,21 +277,6 @@ SVTK_Viewer
   }
 }
 
-/*!
-  SLOT: called when popup item "Show toolbar" is activated, shows toolbar of active view window
-*/
-void
-SVTK_Viewer
-::onShowToolbar() 
-{
-  QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
-  for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
-    if(TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at(i))){
-      aView->getMainWindow()->getToolBar()->show();
-    }
-  }
-}
-
 /*!
   Display presentation
   \param prs - presentation
index db6c4d79dda63d5b72ad96b6ba0e0ac4e8fb9b03..a76da1dbc0d64e357e7eaf16732b2661f65ab959 100644 (file)
@@ -113,7 +113,6 @@ protected slots:
   void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
 
   void onDumpView();
-  void onShowToolbar();
   void onChangeBgColor();
 
 private:
index 12d296388ab4589eb51553deee935450409b04fd..be2e4468ffa250d7b2ff1823bbb085dc39e5fc86 100755 (executable)
@@ -799,9 +799,10 @@ SVTK_ViewWindow
 void
 SVTK_ViewWindow
 ::SetSelectionTolerance(const double& theTolNodes, 
-                       const double& theTolItems)
+                       const double& theTolItems,
+                       const double& theTolObjects)
 {
-  myView->SetSelectionTolerance(theTolNodes,theTolItems);
+  myView->SetSelectionTolerance(theTolNodes, theTolItems, theTolObjects);
 }
 
 /*!
@@ -827,9 +828,7 @@ SVTK_ViewWindow
 // 76 values for graduated axes, so both numbers are processed.
 const int nNormalParams = 13;   // number of view windows parameters excluding graduated axes params
 const int nGradAxisParams = 25; // number of parameters of ONE graduated axis (X, Y, or Z)
-const int nNormalGradAxisParams = nNormalParams + 3*nGradAxisParams + 1; // number of visual parameters with graduated axes
-const int nBgColorParams = 4; // number of parameters of BgColor ("BgColor",Red,Gree,Blue)
-const int nNormalBgColorParams = nNormalGradAxisParams + nBgColorParams; // number of visual parameters with background color
+const int nAllParams = nNormalParams + 3*nGradAxisParams + 1; // number of all visual parameters
 
 /*! The method returns visual parameters of a graduated axis actor (x,y,z axis of graduated axes)
  */
@@ -989,13 +988,6 @@ SVTK_ViewWindow
     retStr += ::getGradAxisVisualParams( gradAxesActor->GetZAxisActor2D() );
   }
 
-  QColor bgColor=backgroundColor();
-
-  retStr += QString("* BgColor ");
-  retStr += QString( "*%1" ).arg(bgColor.red());
-  retStr += QString( "*%1" ).arg(bgColor.green());
-  retStr += QString( "*%1" ).arg(bgColor.blue());
-
   return retStr;
 }
 
@@ -1051,7 +1043,7 @@ SVTK_ViewWindow
 
     // apply graduated axes parameters
     SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes();
-    if ( gradAxesActor && paramsLst.size() >= nNormalGradAxisParams ) {
+    if ( gradAxesActor && paramsLst.size() == nAllParams ) {
       
       int i = nNormalParams+1, j = i + nGradAxisParams - 1;
       ::setGradAxisVisualParams( gradAxesActor->GetXAxisActor2D(), parameters.section( '*', i, j ) ); 
@@ -1065,13 +1057,6 @@ SVTK_ViewWindow
       else
        gradAxesActor->VisibilityOff();
     }
-    if(paramsLst.size() >= nNormalBgColorParams) {
-       QColor bgColor(paramsLst[nNormalBgColorParams-3].toInt(),
-                     paramsLst[nNormalBgColorParams-2].toInt(),
-                     paramsLst[nNormalBgColorParams-1].toInt()
-                     );
-      setBackgroundColor(bgColor);
-    }
   }
 }
 
index f0c756ae5178d22c82dece1137c0e84dbccc352f..811752c972fcd231f6268aee7948f9a228ebe2b0 100755 (executable)
@@ -248,7 +248,8 @@ class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow
   virtual
   void
   SetSelectionTolerance(const double& theTolNodes = 0.025, 
-                       const double& theTolCell = 0.001);
+                       const double& theTolCell = 0.001,
+                       const double& theTolObjects = 0.025);
 
   //! Methods to save/restore visual parameters of a view (pan, zoom, etc.)
   virtual 
diff --git a/src/Style/Style.qrc b/src/Style/Style.qrc
new file mode 100644 (file)
index 0000000..7c529c5
--- /dev/null
@@ -0,0 +1,8 @@
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource>
+     <file>images/critical.png</file>
+     <file>images/information.png</file>
+     <file>images/question.png</file>
+     <file>images/warning.png</file>
+ </qresource>
+ </RCC>