#include "SMESHGUI_SpinBox.h"
#include "SMESHGUI_Utils.h"
#include "SMESHGUI_VTKUtils.h"
+#include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_IdValidator.h"
#include "SMESH_Actor.h"
+#include "SMESH_TypeFilter.hxx"
#include "SMDS_Mesh.hxx"
-#include <TopoDS.hxx>
-#include <gp_Lin.hxx>
-#include <gp_Vec.hxx>
-#include <BRepAdaptor_Curve.hxx>
-
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_MessageBox.h"
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
+#include <qcheckbox.h>
#include <qlayout.h>
#include <qspinbox.h>
#include <qvalidator.h>
// Controls for elements selection
TextLabelElements = new QLabel( GroupArguments, "TextLabelElements" );
TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
+ TextLabelElements->setFixedWidth(74);
GroupArgumentsLayout->addWidget( TextLabelElements, 0, 0 );
SelectElementsButton = new QPushButton( GroupArguments, "SelectElementsButton" );
LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" ));
GroupArgumentsLayout->addMultiCellWidget( LineEditElements, 0, 0, 2, 7 );
+ // Control for the whole mesh selection
+ CheckBoxMesh = new QCheckBox( GroupArguments, "CheckBoxMesh" );
+ CheckBoxMesh->setText( tr( "SMESH_SELECT_WHOLE_MESH" ) );
+ GroupArgumentsLayout->addMultiCellWidget( CheckBoxMesh, 1, 1, 0, 7 );
+
// Controls for vector selection
TextLabelVector = new QLabel( GroupArguments, "TextLabelVector" );
TextLabelVector->setText( tr( "SMESH_VECTOR" ) );
- GroupArgumentsLayout->addWidget( TextLabelVector, 1, 0 );
+ GroupArgumentsLayout->addWidget( TextLabelVector, 2, 0 );
TextLabelDx = new QLabel( GroupArguments, "TextLabelDx" );
TextLabelDx->setText( tr( "SMESH_DX" ) );
- GroupArgumentsLayout->addWidget( TextLabelDx, 1, 2 );
+ GroupArgumentsLayout->addWidget( TextLabelDx, 2, 2 );
SpinBox_Dx = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Dx");
- GroupArgumentsLayout->addWidget( SpinBox_Dx, 1, 3 );
+ GroupArgumentsLayout->addWidget( SpinBox_Dx, 2, 3 );
TextLabelDy = new QLabel( GroupArguments, "TextLabelDy" );
TextLabelDy->setText( tr( "SMESH_DY" ) );
- GroupArgumentsLayout->addWidget( TextLabelDy, 1, 4 );
+ GroupArgumentsLayout->addWidget( TextLabelDy, 2, 4 );
SpinBox_Dy = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Dy");
- GroupArgumentsLayout->addWidget( SpinBox_Dy, 1, 5 );
+ GroupArgumentsLayout->addWidget( SpinBox_Dy, 2, 5 );
TextLabelDz = new QLabel( GroupArguments, "TextLabelDz" );
TextLabelDz->setText( tr( "SMESH_DZ" ) );
- GroupArgumentsLayout->addWidget( TextLabelDz, 1, 6 );
+ GroupArgumentsLayout->addWidget( TextLabelDz, 2, 6 );
SpinBox_Dz = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Dz");
- GroupArgumentsLayout->addWidget( SpinBox_Dz, 1, 7 );
+ GroupArgumentsLayout->addWidget( SpinBox_Dz, 2, 7 );
// Controls for nb. steps defining
TextLabelNbSteps = new QLabel( GroupArguments, "TextLabelNbSteps" );
TextLabelNbSteps->setText( tr( "SMESH_NUMBEROFSTEPS" ) );
- GroupArgumentsLayout->addMultiCellWidget( TextLabelNbSteps, 2, 2, 0, 1 );
+ GroupArgumentsLayout->addMultiCellWidget( TextLabelNbSteps, 3, 3, 0, 1 );
SpinBox_NbSteps = new QSpinBox(GroupArguments, "SpinBox_NbSteps");
- GroupArgumentsLayout->addMultiCellWidget( SpinBox_NbSteps, 2, 2, 2, 7 );
+ GroupArgumentsLayout->addMultiCellWidget( SpinBox_NbSteps, 3, 3, 2, 7 );
SMESHGUI_ExtrusionDlgLayout->addWidget( GroupArguments, 1, 0 );
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
+ // Costruction of the logical filter
+ SMESH_ListOfFilter aListOfFilters;
+ Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
+ if ( !aMeshOrSubMeshFilter.IsNull() )
+ aListOfFilters.Append( aMeshOrSubMeshFilter );
+ Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP );
+ if ( !aSmeshGroupFilter.IsNull() )
+ aListOfFilters.Append( aSmeshGroupFilter );
+
+ myMeshOrSubMeshOrGroupFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR );
+
Init();
/* signals and slots connections */
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
connect( LineEditElements, SIGNAL( textChanged( const QString& )),
SLOT( onTextChange( const QString& )));
-
+ connect( CheckBoxMesh, SIGNAL( toggled( bool )),
+ SLOT( onSelectMesh( bool )));
+
/* Move widget on the botton right corner of main widget */
int x, y ;
mySMESHGUI->DefineDlgPosition( this, x, y ) ;
// function : Init()
// purpose :
//=================================================================================
-void SMESHGUI_ExtrusionDlg::Init()
+void SMESHGUI_ExtrusionDlg::Init( bool ResetControls )
{
myBusy = false;
-
- SpinBox_NbSteps->setValue(1);
- myEditCurrentArgument = LineEditElements;
- LineEditElements->setFocus();
+ LineEditElements->clear();
+ myElementsId = "";
myNbOkElements = 0 ;
+
+ buttonOk->setEnabled( false );
+ buttonApply->setEnabled( false );
+
myActor = 0;
myMesh = SMESH::SMESH_Mesh::_nil();
- SpinBox_Dx->SetValue(0);
- SpinBox_Dy->SetValue(0);
- SpinBox_Dz->SetValue(0);
-
- SelectionIntoArgument();
+ if( ResetControls )
+ {
+ SpinBox_NbSteps->setValue(1);
+ SpinBox_Dx->SetValue(0);
+ SpinBox_Dy->SetValue(0);
+ SpinBox_Dz->SetValue(0);
+
+ CheckBoxMesh->setChecked(false);
+ onSelectMesh( false );
+ }
}
void SMESHGUI_ExtrusionDlg::ConstructorsClicked(int constructorId)
{
disconnect(mySelection, 0, this, 0);
- mySelection->ClearIObjects();
- mySelection->ClearFilters();
- myNbOkElements = 0 ;
- myEditCurrentArgument = LineEditElements;
- LineEditElements->setText("");
- LineEditElements->setFocus();
switch(constructorId)
{
case 0 :
{
GroupArguments->setTitle( tr( "EXTRUSION_1D" ) );
- QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true );
+ if ( !CheckBoxMesh->isChecked() )
+ QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true );
break;
}
case 1 :
{
GroupArguments->setTitle( tr( "EXTRUSION_2D" ) );
- QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true );
+ if ( !CheckBoxMesh->isChecked() )
+ QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true );
break;
}
}
+
+ myEditCurrentArgument = LineEditElements;
+ LineEditElements->setFocus();
+
+ if (CheckBoxMesh->isChecked())
+ onSelectMesh(true);
+
connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
}
if ( myNbOkElements)
{
- QStringList aListElementsId = QStringList::split( " ", LineEditElements->text(), false);
+ QStringList aListElementsId = QStringList::split( " ", myElementsId, false);
SMESH::long_array_var anElementsId = new SMESH::long_array;
mySelection->ClearIObjects();
SMESH::UpdateView();
- Init();
+ Init( false);
+ ConstructorsClicked( GetConstructorId() );
}
}
//=================================================================================
void SMESHGUI_ExtrusionDlg::ClickOnOk()
{
- this->ClickOnApply() ;
- this->ClickOnCancel() ;
+ ClickOnApply();
+ ClickOnCancel();
}
void SMESHGUI_ExtrusionDlg::onTextChange(const QString& theNewText)
{
QLineEdit* send = (QLineEdit*)sender();
-
+
if ( myBusy ) return;
myBusy = true;
aMesh = myActor->GetObject()->GetMesh();
if ( aMesh ) {
-
mySelection->ClearIObjects();
mySelection->AddIObject( myActor->getIO() );
myNbOkElements++;
}
}
+ myElementsId = theNewText;
}
}
if ( myBusy ) return;
// clear
-
myActor = 0;
QString aString = "";
myBusy = true;
myEditCurrentArgument->setText( aString );
+ myNbOkElements = 0;
+ buttonOk->setEnabled( false );
+ buttonApply->setEnabled( false );
myBusy = false;
if ( !GroupButtons->isEnabled() ) // inactive
return;
Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
+ myMesh = SMESH::GetMeshByIO(IO);
+ if(myMesh->_is_nil())
+ return;
+ myActor = SMESH::FindActorByObject(myMesh);
+ if (!myActor)
+ return;
if (myEditCurrentArgument == LineEditElements)
{
- myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO) ;
-
- myActor = SMESH::FindActorByEntry( mySelection->firstIObject()->getEntry() );
-
- // get selected elements
int aNbElements = 0;
+ myElementsId = "";
- aNbElements = SMESH::GetNameOfSelectedElements(mySelection, aString) ;
+ if (CheckBoxMesh->isChecked())
+ {
+ SMESH::GetNameOfSelectedIObjects(mySelection, aString);
+
+ int aConstructorId = GetConstructorId();
+
+ if(!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) //MESH
+ {
+ // get IDs from mesh
+ SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
+ if (!aSMDSMesh)
+ return;
+
+ if (aConstructorId == 0)
+ {
+ SMDS_EdgeIteratorPtr anIter = aSMDSMesh->edgesIterator();
+
+ while ( anIter->more() )
+ {
+ const SMDS_MeshEdge * edge = anIter->next();
+ if ( edge ) {
+ myElementsId += QString(" %1").arg(edge->GetID());
+ aNbElements++;
+ }
+ }
+ }
+ else if (aConstructorId == 1)
+ {
+ SMDS_FaceIteratorPtr anIter = aSMDSMesh->facesIterator();
+ while ( anIter->more() )
+ {
+ const SMDS_MeshFace * face = anIter->next();
+ if ( face ) {
+ myElementsId += QString(" %1").arg(face->GetID());
+ aNbElements++;
+ }
+ }
+ }
+ }
+ else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) //SUBMESH
+ {
+ // get submesh
+ SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO) ;
+
+ // get IDs from submesh
+ SMESH::long_array_var anElementsIds = new SMESH::long_array;
+ if (aConstructorId == 0)
+ anElementsIds = aSubMesh->GetElementsByType(SMESH::EDGE);
+ else if (aConstructorId == 1)
+ anElementsIds = aSubMesh->GetElementsByType(SMESH::FACE);
+
+ for ( int i = 0; i < anElementsIds->length(); i++ )
+ myElementsId += QString(" %1").arg(anElementsIds[i]);
+ aNbElements = anElementsIds->length();
+ }
+ else // GROUP
+ {
+ // get smesh group
+ SMESH::SMESH_GroupBase_var aGroup =
+ SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
+ if (aGroup->_is_nil())
+ return;
+
+ if ( (aConstructorId == 0 && aGroup->GetType()!= SMESH::EDGE) ||
+ (aConstructorId == 1 && aGroup->GetType()!= SMESH::FACE) )
+ return;
+
+ // get IDs from smesh group
+ SMESH::long_array_var anElementsIds = new SMESH::long_array;
+ anElementsIds = aGroup->GetListOfID();
+ for ( int i = 0; i < anElementsIds->length(); i++ )
+ myElementsId += QString(" %1").arg(anElementsIds[i]);
+ aNbElements = anElementsIds->length();
+ }
+ }
+ else
+ {
+ aNbElements = SMESH::GetNameOfSelectedElements(mySelection, aString) ;
+ myElementsId = aString;
+ }
if(aNbElements < 1)
return ;
+
+ myNbOkElements = true;
}
myBusy = true;
// OK
- if (myEditCurrentArgument == LineEditElements )
- myNbOkElements = true;
-
if(myNbOkElements)
{
buttonOk->setEnabled( true );
void SMESHGUI_ExtrusionDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
+
disconnect( mySelection, 0, this, 0 );
mySelection->ClearIObjects();
mySelection->ClearFilters();
if(send == SelectElementsButton) {
myEditCurrentArgument = LineEditElements;
- int aConstructorId = GetConstructorId();
- if (aConstructorId == 0)
- QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true );
- else if (aConstructorId == 1)
- QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true );
+ if (CheckBoxMesh->isChecked())
+ {
+ QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
+ mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter);
+ }
+ else
+ {
+ int aConstructorId = GetConstructorId();
+ if (aConstructorId == 0)
+ QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true );
+ else if (aConstructorId == 1)
+ QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true );
+ }
}
myEditCurrentArgument->setFocus();
mySMESHGUI->ResetState() ;
mySMESHGUI->SetActiveDialogBox(0) ;
}
- return ;
}
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
- return ;
}
}
+//=======================================================================
+//function : onSelectMesh
+//purpose :
+//=======================================================================
+void SMESHGUI_ExtrusionDlg::onSelectMesh ( bool toSelectMesh )
+{
+ if (toSelectMesh)
+ TextLabelElements->setText( tr( "SMESH_NAME" ) );
+ else
+ TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) );
+
+ if (myEditCurrentArgument != LineEditElements)
+ {
+ LineEditElements->clear();
+ return;
+ }
+
+ mySelection->ClearFilters() ;
+
+ if (toSelectMesh)
+ {
+ QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
+ mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter);
+ LineEditElements->setReadOnly(true);
+ }
+ else
+ {
+ int aConstructorId = GetConstructorId();
+ if (aConstructorId == 0)
+ QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true );
+ else if (aConstructorId == 0)
+ QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true );
+
+ LineEditElements->setReadOnly(false);
+ onTextChange(LineEditElements->text());
+ }
+
+ SelectionIntoArgument();
+}
+
+
//=================================================================================
// function : GetConstructorId()
// purpose :