From 4d061d8c0318c85875fe23fc9b28477fcdc4e16b Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 7 Oct 2008 09:39:28 +0000 Subject: [PATCH] Merging GUI_SRC module with the BR_HDF_dev_merged branch, which has been merged with the BR_V5_DEV branch. --- src/SUITApp/resources/SUITApp_msg_en.ts | 17 ++++++ src/SVTK/SVTK_Selector.cxx | 73 ++++++++++++++++++++++++- src/SVTK/SVTK_Selector.h | 11 ++++ src/SVTK/SVTK_SelectorDef.h | 14 +++++ src/SVTK/SVTK_View.cxx | 5 +- src/SVTK/SVTK_View.h | 3 +- src/SVTK/SVTK_ViewModel.cxx | 23 ++------ src/SVTK/SVTK_ViewModel.h | 1 - src/SVTK/SVTK_ViewWindow.cxx | 25 ++------- src/SVTK/SVTK_ViewWindow.h | 3 +- src/Style/Style.qrc | 8 +++ 11 files changed, 138 insertions(+), 45 deletions(-) create mode 100644 src/SUITApp/resources/SUITApp_msg_en.ts create mode 100644 src/Style/Style.qrc diff --git a/src/SUITApp/resources/SUITApp_msg_en.ts b/src/SUITApp/resources/SUITApp_msg_en.ts new file mode 100644 index 000000000..20b003ece --- /dev/null +++ b/src/SUITApp/resources/SUITApp_msg_en.ts @@ -0,0 +1,17 @@ + + + @default + + APP_OK + Ok + + + APP_ERROR + Error + + + APP_UNK_EXCEPTION + Unknown exception + + + diff --git a/src/SVTK/SVTK_Selector.cxx b/src/SVTK/SVTK_Selector.cxx index 86e9bc335..906574ca7 100644 --- a/src/SVTK/SVTK_Selector.cxx +++ b/src/SVTK/SVTK_Selector.cxx @@ -29,14 +29,38 @@ #include "SVTK_SelectorDef.h" -#include "VTKViewer_Filter.h" +#include #include "SALOME_Actor.h" +#include +#include + #include #include #include +#include +#include + + +/*! + 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(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); +} diff --git a/src/SVTK/SVTK_Selector.h b/src/SVTK/SVTK_Selector.h index 17ab9be70..0d65de7e3 100644 --- a/src/SVTK/SVTK_Selector.h +++ b/src/SVTK/SVTK_Selector.h @@ -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; }; diff --git a/src/SVTK/SVTK_SelectorDef.h b/src/SVTK/SVTK_SelectorDef.h index 6515a187b..70b957756 100644 --- a/src/SVTK/SVTK_SelectorDef.h +++ b/src/SVTK/SVTK_SelectorDef.h @@ -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 TFilters; TFilters myFilters; + + vtkSmartPointer myPicker; + vtkSmartPointer myCellPicker; }; #endif diff --git a/src/SVTK/SVTK_View.cxx b/src/SVTK/SVTK_View.cxx index e056d6d77..57e6e49eb 100644 --- a/src/SVTK/SVTK_View.cxx +++ b/src/SVTK/SVTK_View.cxx @@ -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); } /*! diff --git a/src/SVTK/SVTK_View.h b/src/SVTK/SVTK_View.h index af25bf5ea..ff463ab5e 100644 --- a/src/SVTK/SVTK_View.h +++ b/src/SVTK/SVTK_View.h @@ -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; diff --git a/src/SVTK/SVTK_ViewModel.cxx b/src/SVTK/SVTK_ViewModel.cxx index 990a96ee9..b8edb171c 100644 --- a/src/SVTK/SVTK_ViewModel.cxx +++ b/src/SVTK/SVTK_ViewModel.cxx @@ -196,9 +196,11 @@ SVTK_Viewer thePopup->addSeparator(); if(TViewWindow* aView = dynamic_cast(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 lst = qFindChildren( aView ); + QList::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 aViews = myViewManager->getViews(); - for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ - if(TViewWindow* aView = dynamic_cast(aViews.at(i))){ - aView->getMainWindow()->getToolBar()->show(); - } - } -} - /*! Display presentation \param prs - presentation diff --git a/src/SVTK/SVTK_ViewModel.h b/src/SVTK/SVTK_ViewModel.h index db6c4d79d..a76da1dbc 100644 --- a/src/SVTK/SVTK_ViewModel.h +++ b/src/SVTK/SVTK_ViewModel.h @@ -113,7 +113,6 @@ protected slots: void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*); void onDumpView(); - void onShowToolbar(); void onChangeBgColor(); private: diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index 12d296388..be2e4468f 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -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); - } } } diff --git a/src/SVTK/SVTK_ViewWindow.h b/src/SVTK/SVTK_ViewWindow.h index f0c756ae5..811752c97 100755 --- a/src/SVTK/SVTK_ViewWindow.h +++ b/src/SVTK/SVTK_ViewWindow.h @@ -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 index 000000000..7c529c541 --- /dev/null +++ b/src/Style/Style.qrc @@ -0,0 +1,8 @@ + + + images/critical.png + images/information.png + images/question.png + images/warning.png + + -- 2.39.2