+// Copyright (C) 2005 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
+//
/**
* SMESH SMESHGUI
*
#include <qcombobox.h>
#include <qpopupmenu.h>
#include <qcursor.h>
+#include <qpushbutton.h>
/*!
* \brief Tab for tab widget containing controls for definition of
connect( myEditHyp[ i ], SIGNAL( clicked() ), SLOT( onEditHyp() ) );
connect( myHyp[ i ], SIGNAL( activated( int ) ), SLOT( onHyp( int ) ) );
}
+ connect( myHyp[ Algo ], SIGNAL( activated( int ) ), SLOT( onHyp( int ) ) );
// Initialize controls
void SMESHGUI_MeshTab::setAvailableHyps( const int theId, const QStringList& theHyps )
{
myAvailableHyps[ theId ] = theHyps;
+
+ bool enable = ! theHyps.isEmpty();
if ( theId == Algo )
{
myHyp[ Algo ]->clear();
myHyp[ Algo ]->insertStringList( theHyps );
myHyp[ Algo ]->setCurrentItem( 0 );
}
+ else {
+ myCreateHyp[ theId ]->setEnabled( enable );
+ myEditHyp[ theId ]->setEnabled( false );
+ }
+ myHyp[ theId ]->setEnabled( enable );
}
//================================================================================
myHyp[ theId ]->insertItem( tr( "NONE" ) );
myHyp[ theId ]->insertStringList( theHyps );
myHyp[ theId ]->setCurrentItem( 0 );
+ myHyp[ theId ]->setEnabled( !theHyps.isEmpty() );
myEditHyp[ theId ]->setEnabled( false );
}
}
myHyp[ theId ]->insertItem( theHyp );
myHyp[ theId ]->setCurrentItem( myHyp[ theId ]->count() - 1 );
myEditHyp[ theId ]->setEnabled( true );
+ myHyp[ theId ]->setEnabled( true );
}
//================================================================================
{
const QObject* aSender = sender();
int aHypType = aSender == myEditHyp[ MainHyp ] ? MainHyp : AddHyp;
- emit editHyp( aHypType, myHyp[ aHypType ]->currentItem() );
+ emit editHyp( aHypType, myHyp[ aHypType ]->currentItem() - 1 ); // - 1 because there is NONE on the top
}
//================================================================================
/*!
* \brief Updates "Edit hypothesis" button state
*
- * SLOT called when current hypothesis changed disables "Edit hypothesis" button
- * if current hypothesis is <None>, enables otherwise
+ * SLOT called when current hypothesis changed. Disables "Edit hypothesis" button
+ * if current hypothesis is <None>, enables otherwise.
+ * If an algorithm changed, emits selectAlgo( theIndex ) signal
*/
//================================================================================
void SMESHGUI_MeshTab::onHyp( int theIndex )
{
const QObject* aSender = sender();
- int anIndex = aSender == myHyp[ MainHyp ] ? MainHyp : AddHyp;
- myEditHyp[ anIndex ]->setEnabled( theIndex > 0 );
+ if ( aSender == myHyp[ Algo ] )
+ emit selectAlgo( theIndex - 1 ); // - 1 because there is NONE on the top
+ else {
+ int anIndex = aSender == myHyp[ MainHyp ] ? MainHyp : AddHyp;
+ myEditHyp[ anIndex ]->setEnabled( theIndex > 0 );
+ }
}
//================================================================================
createObject( tr( "MESH" ), aGrp, Mesh );
// geometry
createObject( tr( "GEOMETRY" ), aGrp, Geom );
+ myGeomPopup = 0;
// Create tab widget
myTabWg = new QTabWidget( mainFrame() );
+ myTabs[ Dim0D ] = new SMESHGUI_MeshTab( myTabWg );
myTabs[ Dim1D ] = new SMESHGUI_MeshTab( myTabWg );
myTabs[ Dim2D ] = new SMESHGUI_MeshTab( myTabWg );
myTabs[ Dim3D ] = new SMESHGUI_MeshTab( myTabWg );
- myTabWg->addTab( myTabs[ Dim1D ], tr( "DIM_1D" ) );
- myTabWg->addTab( myTabs[ Dim2D ], tr( "DIM_2D" ) );
myTabWg->addTab( myTabs[ Dim3D ], tr( "DIM_3D" ) );
+ myTabWg->addTab( myTabs[ Dim2D ], tr( "DIM_2D" ) );
+ myTabWg->addTab( myTabs[ Dim1D ], tr( "DIM_1D" ) );
+ myTabWg->addTab( myTabs[ Dim0D ], tr( "DIM_0D" ) );
+
+ // Hypotheses Sets
+ myHypoSetPopup = new QPopupMenu();
+ QButton* aHypoSetButton = new QPushButton( mainFrame(), "aHypoSetButton");
+ aHypoSetButton->setText( tr( "HYPOTHESES_SETS" ) );
// Fill layout
-
QVBoxLayout* aLay = new QVBoxLayout( mainFrame(), 0, 5 );
aLay->addWidget( aGrp );
aLay->addItem( new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum) );
aLay->addWidget( myTabWg );
-
+ aLay->addWidget( aHypoSetButton );
+
// Disable controls if necessary
setObjectShown( Mesh, false );
if ( theToCreate )
objectWg( Mesh, Btn )->hide();
objectWg( Geom, Btn )->hide();
}
+
+ // Connect signals and slots
+ connect( aHypoSetButton, SIGNAL( clicked() ), SLOT( onHypoSetButton() ) );
+ connect( myHypoSetPopup, SIGNAL( activated( int ) ), SLOT( onHypoSetPopup( int ) ) );
}
SMESHGUI_MeshDlg::~SMESHGUI_MeshDlg()
{
+ if ( myHypoSetPopup )
+ delete myHypoSetPopup;
}
//================================================================================
//================================================================================
SMESHGUI_MeshTab* SMESHGUI_MeshDlg::tab( const int theId ) const
{
- return ( theId >= Dim1D && theId <= Dim3D ? myTabs[ theId ] : 0 );
+ return ( theId >= Dim0D && theId <= Dim3D ? myTabs[ theId ] : 0 );
}
//================================================================================
void SMESHGUI_MeshDlg::reset()
{
clearSelection();
+ myTabs[ Dim0D ]->reset();
myTabs[ Dim1D ]->reset();
myTabs[ Dim2D ]->reset();
myTabs[ Dim3D ]->reset();
//================================================================================
void SMESHGUI_MeshDlg::setCurrentTab( const int theId )
{
- myTabWg->setCurrentPage( theId );
+ myTabWg->setCurrentPage( Dim3D - theId );
}
-
+//================================================================================
+/*!
+ * \brief Enable/disable tabs
+ * \param int - maximum possible dimention
+ */
+//================================================================================
+void SMESHGUI_MeshDlg::setMaxHypoDim( const int maxDim )
+{
+ const int DIM = maxDim;
+ for ( int dim = Dim0D; dim <= Dim3D; ++dim ) {
+ bool enable = ( dim <= DIM );
+ if ( !enable )
+ myTabs[ dim ]->reset();
+ myTabWg->setTabEnabled( myTabs[ dim ], enable );
+ }
+ // deselect desabled tab
+ if ( !myTabWg->isTabEnabled( myTabWg->currentPage() ))
+ setCurrentTab( DIM - 1 );
+}
+//================================================================================
+/*!
+ * \brief Sets list of available Sets of Hypotheses
+ */
+//================================================================================
+void SMESHGUI_MeshDlg::setHypoSets( const QStringList& theSets )
+{
+ myHypoSetPopup->clear();
+ for ( int i = 0, n = theSets.count(); i < n; i++ ) {
+ myHypoSetPopup->insertItem( theSets[ i ], i );
+ }
+}
+//================================================================================
+/*!
+ * \brief Emits hypoSet signal
+ *
+ * SLOT is called when a hypotheses set is selected. Emits hypoSet
+ * signal to notify operation about this event
+ */
+//================================================================================
+void SMESHGUI_MeshDlg::onHypoSetPopup( int theIndex )
+{
+ emit hypoSet( myHypoSetPopup->text( theIndex ));
+}
+
+//================================================================================
+/*!
+ * \brief Shows myHypoSetPopup
+ */
+//================================================================================
+
+void SMESHGUI_MeshDlg::onHypoSetButton()
+{
+ myHypoSetPopup->exec( QCursor::pos() );
+}
+//================================================================================
+/*!
+ * \brief Enable showing of the popup when Geometry selection btn is clicked
+ * \param enable - true to enable
+ */
+//================================================================================
+
+enum { DIRECT_GEOM_INDEX = 0, GEOM_BY_MESH_INDEX };
+
+void SMESHGUI_MeshDlg::setGeomPopupEnabled( const bool enable )
+{
+ if ( QButton* selBtn = dynamic_cast<QButton*>( objectWg( Geom, Btn )))
+ {
+ disconnect( selBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) ));
+ if ( enable ) {
+ if ( ! myGeomPopup ) {
+ myGeomPopup = new QPopupMenu();
+ myGeomPopup->insertItem( tr("DIRECT_GEOM_SELECTION"), DIRECT_GEOM_INDEX );
+ myGeomPopup->insertItem( tr("GEOM_BY_MESH_ELEM_SELECTION"), GEOM_BY_MESH_INDEX );
+ connect( myGeomPopup, SIGNAL( activated( int ) ), SLOT( onGeomPopup( int ) ) );
+ }
+ connect( selBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) ));
+ }
+ }
+}
+//================================================================================
+/*!
+ * \brief Disable tab
+ * \param int - tab ID
+ */
+//================================================================================
+void SMESHGUI_MeshDlg::disableTab(const int theTabId) {
+ myTabWg->setTabEnabled( myTabs[ theTabId ], false );
+}
+//================================================================================
+/*!
+ * \brief Enable tabs
+ * \param int - tab ID
+ */
+//================================================================================
+void SMESHGUI_MeshDlg::enableTab(const int theTabId) {
+ myTabWg->setTabEnabled( myTabs[ theTabId ], true );
+}
+void SMESHGUI_MeshDlg::onGeomSelectionButton(bool isBtnOn)
+{
+ if ( myGeomPopup && isBtnOn )
+ myGeomPopup->exec( QCursor::pos() );
+}
+void SMESHGUI_MeshDlg::onGeomPopup( int index )
+{
+ emit geomSelectionByMesh( index == GEOM_BY_MESH_INDEX );
+}