Salome HOME
Merge V8_3_BR branch.
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshDlg.cxx
index 09218ef3d1bfb9cf9f4a9e3a52da09ce6c99739b..b99c8a4f6a59a4931f56fb51f5ae63a5c8513650 100644 (file)
@@ -31,6 +31,7 @@
 #include <SUIT_Session.h>
 #include <SUIT_ResourceMgr.h>
 #include <QtxMenu.h>
+#include <QtxToolButton.h>
 
 // Qt includes
 #include <QComboBox>
@@ -74,11 +75,11 @@ SMESHGUI_MeshTab::SMESHGUI_MeshTab( QWidget* theParent )
   
   // Algorifm
   QLabel* anAlgoLbl = new QLabel( tr( "ALGORITHM" ), this );
-  myHypCombo[ Algo ] = new QComboBox( this );
+  myHypCombo[ Algo ] = new QtxToolButton( this );
   
   // Hypothesis
   QLabel* aHypLbl = new QLabel( tr( "HYPOTHESIS" ), this );
-  myHypCombo[ MainHyp ] = new QComboBox( this );
+  myHypCombo[ MainHyp ] = new QtxToolButton( this );
   myHypCombo[ MainHyp ]->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
   myCreateHypBtn[ MainHyp ] = new QToolButton( this );
   myCreateHypBtn[ MainHyp ]->setIcon( aCreateIcon );
@@ -91,7 +92,7 @@ SMESHGUI_MeshTab::SMESHGUI_MeshTab( QWidget* theParent )
 
   // Add. hypothesis
   QLabel* anAddHypLbl = new QLabel( tr( "ADD_HYPOTHESIS" ), this );
-  myHypCombo[ AddHyp ] = new QComboBox( this );
+  myHypCombo[ AddHyp ] = new QtxToolButton( this );
   myHypCombo[ AddHyp ]->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
   myCreateHypBtn[ AddHyp ] = new QToolButton( this );
   myCreateHypBtn[ AddHyp ]->setIcon( aCreateIcon );
@@ -126,6 +127,7 @@ SMESHGUI_MeshTab::SMESHGUI_MeshTab( QWidget* theParent )
   aLay->addWidget( myMoreAddHypBtn, 4, 2 );
   aLay->addWidget( myEditHypBtn[ MoreAddHyp ], 4, 3 );
   aLay->addWidget( myLessAddHypBtn, 5, 2 );
+
   aLay->addItem( new QSpacerItem( 0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding ), 6, 0 );
 
   // Connect signals and slots
@@ -167,30 +169,26 @@ SMESHGUI_MeshTab::~SMESHGUI_MeshTab()
  *  \param [in] isGroup - is the item a group title
  */
 //================================================================================
-
 void SMESHGUI_MeshTab::addItem( const QString& txt,
                                 const int      type,
                                 const int      index,
                                 const bool     isGroup )
 {
-  const char* prefix = "  ";
   if ( type <= AddHyp )
   {
     if ( isGroup )
     {
-      int idx = myHypCombo[ type ]->count();
-      myHypCombo[ type ]->addItem( txt.mid( 6 ), QVariant( index ));
-      myHypCombo[ type ]->setItemData( idx, "separator", Qt::AccessibleDescriptionRole );
+      myHypCombo[ type ]->addSeparator( txt.mid( 6 ) );
     }
     else
     {
-      myHypCombo[ type ]->addItem( prefix + txt, QVariant( index ));
+      myHypCombo[ type ]->addItem( txt, QVariant( index ));
     }
     //myHypCombo[ type ]->setMaxVisibleItems( qMax( 10, myHypCombo[ type ]->count() ) );
   }
   else
   {
-    QListWidgetItem* item = new QListWidgetItem( prefix + txt, myAddHypList );
+    QListWidgetItem* item = new QListWidgetItem( txt, myAddHypList );
     item->setData( Qt::UserRole, QVariant( index ));
   }
 }
@@ -200,7 +198,6 @@ void SMESHGUI_MeshTab::addItem( const QString& txt,
  * \brief Returns index of hyp of a given type
  */
 //================================================================================
-
 int SMESHGUI_MeshTab::getCurrentIndex( const int type, const bool curByType ) const
 {
   if ( type <= AddHyp )
@@ -311,24 +308,6 @@ void SMESHGUI_MeshTab::addHyp( const int theId, const QString& theHyp )
     myMoreAddHypBtn->setEnabled( true );
 }
 
-//================================================================================
-/*!
- * \brief Renames hypothesis
- * \param theId - identifier of hypothesis (main or additional, see HypType enumeration)
- * \param theIndex - index of hypothesis to be renamed
- * \param theNewName - new name of hypothesis to be renamed
- *
- * Renames hypothesis
- */
-//================================================================================
-// void SMESHGUI_MeshTab::renameHyp( const int theId,
-//                                   const int theIndex,
-//                                   const QString& theNewName )
-// {
-//   if ( theIndex > 0 && theIndex < myHypCombo[ theId ]->count() )
-//     myHypCombo[ theId ]->setItemText( theIndex, theNewName );
-// }
-
 //================================================================================
 /*!
  * \brief Sets current hypothesis
@@ -397,7 +376,6 @@ int SMESHGUI_MeshTab::currentHyp( const int theId ) const
  * range 0 <= i < this->nbAddHypTypes()
  */
 //================================================================================
-
 int SMESHGUI_MeshTab::nbAddHypTypes() const
 {
   return myAddHypList->count();
@@ -426,7 +404,7 @@ void SMESHGUI_MeshTab::onCreateHyp()
     QAction* a = 0;
     if ( aHypNames[ i ].startsWith( "GROUP:" ))
     {
-      aPopup.appendGroupTitle( aHypNames[ i ].mid( 6 ));
+      aPopup.addGroup( aHypNames[ i ].mid( 6 ));
     }
     else
     {
@@ -507,7 +485,6 @@ void SMESHGUI_MeshTab::onHyp( int theIndex )
  * SLOT called when myMoreAddHypBtn ("plus") clicked
  */
 //================================================================================
-
 void SMESHGUI_MeshTab::onMoreAddHyp()
 {
   int hypIndex = currentHyp( AddHyp );
@@ -532,7 +509,6 @@ void SMESHGUI_MeshTab::onMoreAddHyp()
  * SLOT called when myLessAddHypBtn ("minus") clicked
  */
 //================================================================================
-
 void SMESHGUI_MeshTab::onLessAddHyp()
 {
   if ( QListWidgetItem * item = myAddHypList->currentItem() )
@@ -672,7 +648,6 @@ SMESHGUI_MeshDlg::~SMESHGUI_MeshDlg()
  * \brief Set dialog title
  */
 //================================================================================
-
 void SMESHGUI_MeshDlg::setTitile( const bool theToCreate, const bool theIsMesh )
 {
   if ( theToCreate )
@@ -728,10 +703,9 @@ void SMESHGUI_MeshDlg::setCurrentTab( const int theId  )
 //================================================================================
 /*!
  * \brief Enable/disable tabs
-  * \param int - maximum possible dimention
+  * \param int - maximum possible dimension
  */
 //================================================================================
-
 void SMESHGUI_MeshDlg::setMaxHypoDim( const int maxDim )
 {
   const int DIM = maxDim;
@@ -755,7 +729,6 @@ void SMESHGUI_MeshDlg::setMaxHypoDim( const int maxDim )
  * \brief Sets list of available Sets of Hypotheses
  */
 //================================================================================
-
 void SMESHGUI_MeshDlg::setHypoSets( const QStringList& theSets )
 {
   QMenu* aHypoSetPopup = myHypoSetButton->menu();
@@ -780,7 +753,6 @@ void SMESHGUI_MeshDlg::setHypoSets( const QStringList& theSets )
  * signal to notify operation about this event
  */
 //================================================================================
-
 void SMESHGUI_MeshDlg::onHypoSetPopup( QAction* a )
 {
   emit hypoSet( a->text() );
@@ -825,9 +797,9 @@ void SMESHGUI_MeshDlg::setGeomPopupEnabled( const bool enable )
  * \param int - tab ID
  */
 //================================================================================
-void SMESHGUI_MeshDlg::disableTab(const int theTabId) {
+void SMESHGUI_MeshDlg::disableTab(const int theTabId)
+{
   myTabWg->setTabEnabled( myTabWg->indexOf( myTabs[ theTabId ] ), false );
-  if ( theTabId == Dim3D ) myHypoSetButton->setEnabled( false );
 }
 
 //================================================================================
@@ -836,7 +808,8 @@ void SMESHGUI_MeshDlg::disableTab(const int theTabId) {
  * \param int - tab ID
  */
 //================================================================================
-void SMESHGUI_MeshDlg::enableTab(const int theTabId) {
+void SMESHGUI_MeshDlg::enableTab(const int theTabId)
+{
   myTabWg->setTabEnabled( myTabWg->indexOf( myTabs[ theTabId ] ), true );
   if ( theTabId == Dim3D ) {
     QMenu* aHypoSetPopup = myHypoSetButton->menu();
@@ -850,21 +823,37 @@ void SMESHGUI_MeshDlg::enableTab(const int theTabId) {
  * \param int - tab ID
  */
 //================================================================================
-bool SMESHGUI_MeshDlg::isTabEnabled(const int theTabId) const {
+bool SMESHGUI_MeshDlg::isTabEnabled(const int theTabId) const
+{
   return myTabWg->isTabEnabled( myTabWg->indexOf( myTabs[ theTabId ] ) );
 }
 
+//================================================================================
+/*!
+ * \brief SLOT called when a Geom selection button is clicked
+ */
+//================================================================================
 void SMESHGUI_MeshDlg::onGeomSelectionButton(bool isBtnOn)
 {
   if ( myGeomPopup && isBtnOn )
     myGeomPopup->exec( QCursor::pos() );
 }
 
+//================================================================================
+/*!
+ * \brief SLOT called when a item of Geom selection popup is chosen
+ */
+//================================================================================
 void SMESHGUI_MeshDlg::onGeomPopup( QAction* a )
 {
   emit geomSelectionByMesh( a->data().toInt() == GEOM_BY_MESH_INDEX );
 }
 
+//================================================================================
+/*!
+ * \brief Return ID of an active selection button
+ */
+//================================================================================
 int SMESHGUI_MeshDlg::getActiveObject()
 {
   for (int i = 0; i < 3; ++i )