#include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_MeshInfosBox.h"
+#include "SMESH_TypeFilter.hxx"
+#include "SMESH_LogicalFilter.hxx"
// SALOME GUI includes
#include <LightApp_SelectionMgr.h>
+#include <SalomeApp_Tools.h>
#include <SUIT_Desktop.h>
#include <SUIT_MessageBox.h>
#include <QLabel>
#include <QPixmap>
#include <QGroupBox>
+#include <QRadioButton>
#include <QPushButton>
+#include <QLineEdit>
+#include <QCheckBox>
#include <QVBoxLayout>
+#include <QGridLayout>
// MESH includes
#include "SMDSAbs_ElementType.hxx"
#include "SMDSAbs_ElementType.hxx"
-
#define SPACING 6
#define MARGIN 11
myFullInfo->SetMeshInfo( theInfo );
}
+// =========================================================================================
+/*!
+ * \brief Copy Mesh dialog box
+ */
+//=======================================================================
+
+SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( QWidget* parent )
+ : SMESHGUI_Dialog( parent, false, true, OK | Apply | Close | Help )
+{
+ setWindowTitle( tr("CAPTION") );
+
+ // mesh
+ setObjectPixmap( "SMESH", tr( "ICON_SELECT" ) );
+ createObject( tr( "MESH" ), mainFrame(), Mesh );
+
+ // mode
+ QGroupBox* aModeGrp = new QGroupBox( tr( "MODE" ), mainFrame() );
+ QHBoxLayout* aModeGrpLayout = new QHBoxLayout( aModeGrp );
+ aModeGrpLayout->setMargin( MARGIN );
+ aModeGrpLayout->setSpacing( SPACING );
+ QRadioButton* a2dFrom3dRB = new QRadioButton( tr( "2D_FROM_3D" ), aModeGrp );
+ QRadioButton* a1dFrom3dRB = new QRadioButton( tr( "1D_FROM_3D" ), aModeGrp );
+ QRadioButton* a1dFrom2dRB = new QRadioButton( tr( "1D_FROM_2D" ), aModeGrp );
+ aModeGrpLayout->addWidget( a2dFrom3dRB );
+ aModeGrpLayout->addWidget( a1dFrom3dRB );
+ aModeGrpLayout->addWidget( a1dFrom2dRB );
+
+ // target
+ QGroupBox* aTargetGrp = new QGroupBox( tr( "TARGET" ), mainFrame() );
+ QGridLayout* aTargetGrpLayout = new QGridLayout( aTargetGrp );
+ aTargetGrpLayout->setMargin( MARGIN );
+ aTargetGrpLayout->setSpacing( SPACING );
+ myThisMeshRB = new QRadioButton( tr( "THIS_MESH" ), aTargetGrp );
+ myNewMeshRB = new QRadioButton( tr( "NEW_MESH" ), aTargetGrp );
+ myMeshName = new QLineEdit( aTargetGrp );
+ myCopyCheck = new QCheckBox( tr( "COPY_SRC" ), aTargetGrp );
+ myMissingCheck = new QCheckBox( tr( "MISSING_ONLY" ), aTargetGrp );
+ aTargetGrpLayout->addWidget( myThisMeshRB, 0, 0 );
+ aTargetGrpLayout->addWidget( myNewMeshRB, 1, 0 );
+ aTargetGrpLayout->addWidget( myMeshName, 1, 1 );
+ aTargetGrpLayout->addWidget( myCopyCheck, 2, 0 );
+ aTargetGrpLayout->addWidget( myMissingCheck, 2, 1 );
+ myGroupCheck = new QCheckBox( tr( "CREATE_GROUP" ), mainFrame() );
+ myGroupName = new QLineEdit( mainFrame() );
+
+ // layout
+ QGridLayout* aDlgLay = new QGridLayout( mainFrame() );
+ aDlgLay->setMargin( 0 );
+ aDlgLay->setSpacing( SPACING );
+ aDlgLay->addWidget( objectWg( Mesh, Label ), 0, 0 );
+ aDlgLay->addWidget( objectWg( Mesh, Btn ), 0, 1 );
+ aDlgLay->addWidget( objectWg( Mesh, Control ), 0, 2 );
+ aDlgLay->addWidget( aModeGrp, 1, 0, 1, 3 );
+ aDlgLay->addWidget( aTargetGrp, 2, 0, 1, 3 );
+ aDlgLay->addWidget( myGroupCheck, 3, 0 );
+ aDlgLay->addWidget( myGroupName, 3, 1, 1, 2 );
+ //aDlgLay->setStretchFactor(aMainFrame, 1);
+
+ connect( myThisMeshRB, SIGNAL( clicked() ), this, SLOT( onTargetChanged() ) );
+ connect( myNewMeshRB, SIGNAL( clicked() ), this, SLOT( onTargetChanged() ) );
+ connect( myGroupCheck, SIGNAL( clicked() ), this, SLOT( onGroupChecked() ) );
+
+ a2dFrom3dRB->setChecked( true );
+ myThisMeshRB->setChecked( true );
+ onTargetChanged();
+ onGroupChecked();
+ enableControls( false );
+}
+
+SMESHGUI_CopyMeshDlg::~SMESHGUI_CopyMeshDlg()
+{
+}
+
+void SMESHGUI_CopyMeshDlg::enableControls( bool on )
+{
+ printf("SMESHGUI_CopyMeshDlg::enableControls:%d\n",on);
+ setButtonEnabled( on, QtxDialog::OK | QtxDialog::Apply );
+}
+
+void SMESHGUI_CopyMeshDlg::onTargetChanged()
+{
+ myMeshName->setEnabled( myNewMeshRB->isChecked() );
+ myCopyCheck->setEnabled( myNewMeshRB->isChecked() );
+ myMissingCheck->setEnabled( myNewMeshRB->isChecked() );
+}
+
+void SMESHGUI_CopyMeshDlg::onGroupChecked()
+{
+ myGroupName->setEnabled( myGroupCheck->isChecked() );
+}
+
//================================================================================
/*!
* \brief Constructor
//================================================================================
SMESHGUI_Make2DFrom3DOp::SMESHGUI_Make2DFrom3DOp()
- : SMESHGUI_Operation()
+ : SMESHGUI_SelectionOp()
{
- myDlg = new SMESHGUI_Make2DFrom3DDlg(desktop());
}
//================================================================================
SMESHGUI_Make2DFrom3DOp::~SMESHGUI_Make2DFrom3DOp()
{
+ if ( myDlg )
+ delete myDlg;
+}
+
+//================================================================================
+/*!
+ * \brief Gets dialog of this operation
+ * \retval LightApp_Dialog* - pointer to dialog of this operation
+*/
+//================================================================================
+LightApp_Dialog* SMESHGUI_Make2DFrom3DOp::dlg() const
+{
+ return myDlg;
}
//================================================================================
void SMESHGUI_Make2DFrom3DOp::startOperation()
{
- myMesh = SMESH::SMESH_Mesh::_nil();
-
- // check selection
- LightApp_SelectionMgr *Sel = selectionMgr();
- SALOME_ListIO selected; Sel->selectedObjects( selected );
+ if( !myDlg )
+ myDlg = new SMESHGUI_CopyMeshDlg( desktop() );
- int nbSel = selected.Extent();
- if (nbSel != 1) {
- SUIT_MessageBox::warning(desktop(),
- tr("SMESH_WRN_WARNING"),
- tr("SMESH_WRN_NO_AVAILABLE_DATA"));
- onCancel();
- return;
- }
-
- Handle(SALOME_InteractiveObject) anIO = selected.First();
- myMesh = SMESH::GetMeshByIO(anIO);
- if (myMesh->_is_nil()) {
- SUIT_MessageBox::warning(desktop(),
- tr("SMESH_WRN_WARNING"),
- tr("SMESH_WRN_NO_AVAILABLE_DATA"));
- onCancel();
- return;
- }
+ mySrc = SMESH::SMESH_IDSource::_nil();
+
+ myHelpFileName = "copy_mesh_page.html";
- SMESHGUI_Operation::startOperation();
+ SMESHGUI_SelectionOp::startOperation();
+ myDlg->activateObject( SMESHGUI_CopyMeshDlg::Mesh );
+ myDlg->show();
+ selectionDone();
+ /*
// backup mesh info before 2D mesh computation
SMESH::long_array_var anOldInfo = myMesh->GetMeshInfo();
- if (!compute2DMesh()) {
+ if (0){//!compute2DMesh()) {
SUIT_MessageBox::warning(desktop(),
tr("SMESH_WRN_WARNING"),
tr("SMESH_WRN_COMPUTE_FAILED"));
// show computated result
_PTR(SObject) aMeshSObj = SMESH::FindSObject(myMesh);
if ( aMeshSObj )
- myDlg->SetMeshName( aMeshSObj->GetName().c_str() );
- myDlg->SetMeshInfo( aNewInfo );
- myDlg->show(); /*exec();*/
- commit();
- SMESHGUI::Modified();
+ ;//myDlg->SetMeshName( aMeshSObj->GetName().c_str() );
+ //myDlg->SetMeshInfo( aNewInfo );
+ myDlg->show();
+ //commit();
+ //SMESHGUI::Modified();
+*/
+}
+
+//================================================================================
+/*!
+ * \brief Updates dialog's look and feel
+ *
+ * Virtual method redefined from the base class updates dialog's look and feel
+ */
+//================================================================================
+void SMESHGUI_Make2DFrom3DOp::selectionDone()
+{
+ bool on = false;
+ if ( dlg()->isVisible() ) {
+ SMESHGUI_SelectionOp::selectionDone();
+ try {
+ QString entry = myDlg->selectedObject( SMESHGUI_CopyMeshDlg::Mesh );
+ _PTR(SObject) sobj = studyDS()->FindObjectID( entry.toLatin1().constData() );
+ if ( sobj ) {
+ SMESH::SMESH_IDSource_var obj = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( sobj );
+ on = !obj->_is_nil();
+ }
+ }
+ catch ( const SALOME::SALOME_Exception& S_ex ) {
+ SalomeApp_Tools::QtCatchCorbaException( S_ex );
+ }
+ catch ( ... ) {
+ }
+ }
+ myDlg->enableControls( on );
+}
+
+//================================================================================
+/*!
+ * \brief Creates selection filter
+ * \param theId - identifier of current selection widget
+ * \retval SUIT_SelectionFilter* - pointer to the created filter or null
+ *
+ * Creates selection filter in accordance with identifier of current selection widget
+ */
+//================================================================================
+SUIT_SelectionFilter* SMESHGUI_Make2DFrom3DOp::createFilter( const int theId ) const
+{
+ SUIT_SelectionFilter* f = 0;
+ if ( theId == SMESHGUI_CopyMeshDlg::Mesh ) {
+ QList<SUIT_SelectionFilter*> filters;
+ filters.append( new SMESH_TypeFilter( MESHorSUBMESH ) );
+ filters.append( new SMESH_TypeFilter( GROUP ) );
+ f = new SMESH_LogicalFilter( filters, SMESH_LogicalFilter::LO_OR );
+ }
+ return f;
}
//================================================================================
bool SMESHGUI_Make2DFrom3DOp::compute2DMesh()
{
- SUIT_OverrideCursor wc;
- SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
- return aMeshEditor->Make2DMeshFrom3D();
+// SUIT_OverrideCursor wc;
+// SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
+// return aMeshEditor->Make2DMeshFrom3D();
+}
+
+bool SMESHGUI_Make2DFrom3DOp::onApply()
+{
+ return false;
}
#include "SMESH_SMESHGUI.hxx"
#include "SMESHGUI_Dialog.h"
-#include "SMESHGUI_Operation.h"
+#include "SMESHGUI_SelectionOp.h"
// IDL includes
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
class QFrame;
+class QCheckBox;
+class QLineEdit;
+class QRadioButton;
class SMESHGUI_MeshInfosBox;
/*!
{
Q_OBJECT
- public:
+public:
SMESHGUI_Make2DFrom3DDlg( QWidget* );
virtual ~SMESHGUI_Make2DFrom3DDlg();
void SetMeshName(const QString& theName);
void SetMeshInfo(const SMESH::long_array& theInfo);
- private:
+private:
QFrame* createMainFrame( QWidget* );
- private:
+private:
QLabel* myMeshName;
SMESHGUI_MeshInfosBox* myFullInfo;
};
+/*!
+ * \brief Dialog to show result mesh statistic
+ */
+
+class SMESHGUI_CopyMeshDlg : public SMESHGUI_Dialog
+{
+ Q_OBJECT
+
+public:
+ enum { Mesh };
+
+ SMESHGUI_CopyMeshDlg( QWidget* );
+ virtual ~SMESHGUI_CopyMeshDlg();
+
+ void enableControls( bool );
+
+private slots:
+ void onTargetChanged();
+ void onGroupChecked();
+
+private:
+ QRadioButton* myThisMeshRB;
+ QRadioButton* myNewMeshRB;
+ QLineEdit* myMeshName;
+ QCheckBox* myCopyCheck;
+ QCheckBox* myMissingCheck;
+ QCheckBox* myGroupCheck;
+ QLineEdit* myGroupName;
+};
/*!
* \brief Operation to compute 2D mesh on 3D
*/
-class SMESHGUI_Make2DFrom3DOp : public SMESHGUI_Operation
+class SMESHGUI_Make2DFrom3DOp : public SMESHGUI_SelectionOp
{
- public:
+ Q_OBJECT
+
+public:
SMESHGUI_Make2DFrom3DOp();
virtual ~SMESHGUI_Make2DFrom3DOp();
- protected:
+ virtual LightApp_Dialog* dlg() const;
+
+protected:
virtual void startOperation();
+ virtual void selectionDone();
+ virtual SUIT_SelectionFilter* createFilter( const int ) const;
+
+protected slots:
+ virtual bool onApply();
- private:
+private:
bool compute2DMesh();
- private:
- SMESH::SMESH_Mesh_var myMesh;
- QPointer<SMESHGUI_Make2DFrom3DDlg> myDlg;
+private:
+ SMESH::SMESH_IDSource_var mySrc;
+ QPointer<SMESHGUI_CopyMeshDlg> myDlg;
};
#endif // SMESHGUI_Make2DFrom3DOp_H
}
}
}
+ clear();
}
/*!
void SMESHGUI_MinDistance::firstEdited()
{
setTarget( FirstTgt );
- clear();
+ if ( sender() == myFirstTgt )
+ clear();
SVTK_Selector* selector = SMESH::GetViewWindow()->GetSelector();
if ( myFirstActor && selector ) {
Handle(SALOME_InteractiveObject) IO = myFirstActor->getIO();
void SMESHGUI_MinDistance::secondEdited()
{
setTarget( SecondTgt );
- clear();
+ if ( sender() == mySecondTgt )
+ clear();
SVTK_Selector* selector = SMESH::GetViewWindow()->GetSelector();
if ( mySecondActor && selector ) {
Handle(SALOME_InteractiveObject) IO = mySecondActor->getIO();
mySource->clear();
}
}
+ clear();
}
/*!
*/
void SMESHGUI_BoundingBox::sourceEdited()
{
- clear();
+ if ( sender() == mySource )
+ clear();
SVTK_Selector* selector = SMESH::GetViewWindow()->GetSelector();
if ( myActor && selector ) {
Handle(SALOME_InteractiveObject) IO = myActor->getIO();
TColStd_MapOfInteger ID;
if ( !mySource->isReadOnly() )
myIDs = mySource->text();
- QStringList ids = mySource->text().split( " ", QString::SkipEmptyParts );
+ QStringList ids = myIDs.split( " ", QString::SkipEmptyParts );
foreach ( QString id, ids )
ID.Add( id.trimmed().toLong() );
selector->AddOrRemoveIndex( IO, ID, false );
void SMESHGUI_BoundingBox::compute()
{
SUIT_OverrideCursor wc;
- if ( mySourceMode->checkedId() == NodesSrc ) {
+ SMESH::ListOfIDSources_var srcList = new SMESH::ListOfIDSources();
+ if ( mySourceMode->checkedId() == NodesSrc || mySourceMode->checkedId() == ElementsSrc ) {
+ if ( mySrc.count() > 0 && !CORBA::is_nil( mySrc[0] ) ) {
+ SMESH::SMESH_Mesh_var m = mySrc[0]->GetMesh();
+ QStringList ids = myIDs.split( " ", QString::SkipEmptyParts );
+ if ( !CORBA::is_nil( m ) && ids.count() > 0 ) {
+ SMESH::long_array_var ids_in = new SMESH::long_array();
+ ids_in->length( ids.count() );
+ for( int i = 0; i < ids.count(); i++ )
+ ids_in[i] = ids[i].trimmed().toLong();
+ SMESH::SMESH_MeshEditor_var me = m->GetMeshEditor();
+ SMESH::SMESH_IDSource_var s = me->MakeIDSource( ids_in.in(), mySourceMode->checkedId() == NodesSrc ? SMESH::NODE : SMESH::FACE );
+ srcList->length( 1 );
+ srcList[0] = s;
+ }
+ }
}
else {
+ srcList->length( mySrc.count() );
+ for( int i = 0; i < mySrc.count(); i++ )
+ srcList[i] = mySrc[i];
+ }
+ if ( srcList->length() > 0 ) {
+ int precision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "length_precision", 6 );
+ SMESH::Measurements_var measure = SMESHGUI::GetSMESHGen()->CreateMeasurements();
+ SMESH::Measure result = measure->BoundingBox( srcList.in() );
+ measure->Destroy();
+ myXmin->setText( QString::number( result.minX, precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
+ myXmax->setText( QString::number( result.maxX, precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
+ myDX->setText( QString::number( result.maxX-result.minX, precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
+ myYmin->setText( QString::number( result.minY, precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
+ myYmax->setText( QString::number( result.maxY, precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
+ myDY->setText( QString::number( result.maxY-result.minY, precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
+ myZmin->setText( QString::number( result.minZ, precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
+ myZmax->setText( QString::number( result.maxZ, precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
+ myDZ->setText( QString::number( result.maxZ-result.minZ, precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
+ }
+ else {
+ clear();
}
}