From d097f4c8fffcdd5fd1477f9400a0627087426390 Mon Sep 17 00:00:00 2001 From: asl Date: Fri, 15 Jul 2005 11:48:41 +0000 Subject: [PATCH] *** empty log message *** --- src/SMESHGUI/Makefile.in | 8 +- src/SMESHGUI/SMESHGUI.cxx | 139 ++---- src/SMESHGUI/SMESHGUI_ExportMeshOp.cxx | 177 ++++++++ src/SMESHGUI/SMESHGUI_ExportMeshOp.h | 54 +++ src/SMESHGUI/SMESHGUI_Operation.cxx | 5 +- .../SMESHGUI_StandardMeshInfosDlg.cxx | 402 ++---------------- src/SMESHGUI/SMESHGUI_StandardMeshInfosDlg.h | 46 +- src/SMESHGUI/SMESHGUI_StandardMeshInfosOp.cxx | 333 +++++++++++++++ src/SMESHGUI/SMESHGUI_StandardMeshInfosOp.h | 59 +++ 9 files changed, 693 insertions(+), 530 deletions(-) create mode 100644 src/SMESHGUI/SMESHGUI_ExportMeshOp.cxx create mode 100644 src/SMESHGUI/SMESHGUI_ExportMeshOp.h create mode 100644 src/SMESHGUI/SMESHGUI_StandardMeshInfosOp.cxx create mode 100644 src/SMESHGUI/SMESHGUI_StandardMeshInfosOp.h diff --git a/src/SMESHGUI/Makefile.in b/src/SMESHGUI/Makefile.in index 436572e7c..365709f75 100644 --- a/src/SMESHGUI/Makefile.in +++ b/src/SMESHGUI/Makefile.in @@ -73,6 +73,7 @@ LIB_SRC = SMESHGUI.cxx \ SMESHGUI_RemoveOp.cxx \ SMESHGUI_MeshInfosDlg.cxx \ SMESHGUI_StandardMeshInfosDlg.cxx \ + SMESHGUI_StandardMeshInfosOp.cxx \ SMESHGUI_Preferences_ColorDlg.cxx \ SMESHGUI_Preferences_ScalarBarDlg.cxx \ SMESHGUI_Preferences_SelectionDlg.cxx \ @@ -119,7 +120,8 @@ LIB_SRC = SMESHGUI.cxx \ SMESHGUI_Dialog.cxx \ SMESHGUI_Operation.cxx \ SMESHGUI_SelectionOp.cxx \ - SMESHGUI_DeleteOp.cxx + SMESHGUI_DeleteOp.cxx \ + SMESHGUI_ExportMeshOp.cxx LIB_MOC = \ SMESHGUI.h \ @@ -142,6 +144,7 @@ LIB_MOC = \ SMESHGUI_RemoveOp.h \ SMESHGUI_MeshInfosDlg.h \ SMESHGUI_StandardMeshInfosDlg.h \ + SMESHGUI_StandardMeshInfosOp.h \ SMESHGUI_Preferences_ColorDlg.h \ SMESHGUI_Preferences_ScalarBarDlg.h \ SMESHGUI_Preferences_SelectionDlg.h \ @@ -175,7 +178,8 @@ LIB_MOC = \ SMESHGUI_CreatePolyhedralVolumeDlg.h \ SMESHGUI_Operation.h \ SMESHGUI_DeleteOp.h \ - SMESHGUI_SelectionOp.h + SMESHGUI_SelectionOp.h \ + SMESHGUI_ExportMeshOp.h LIB_CLIENT_IDL = SALOME_Exception.idl \ GEOM_Gen.idl \ diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 5ff303221..646a2815c 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -25,6 +25,7 @@ // $Header$ #include "SMESHGUI.h" +#include "SMESHGUI_ExportMeshOp.h" #include "SMESHGUI_InitMeshOp.h" #include "SMESHGUI_AddSubMeshOp.h" #include "SMESHGUI_NodesOp.h" @@ -34,7 +35,7 @@ #include "SMESHGUI_GroupDlg.h" #include "SMESHGUI_RemoveOp.h" #include "SMESHGUI_MeshInfosDlg.h" -#include "SMESHGUI_StandardMeshInfosDlg.h" +#include "SMESHGUI_StandardMeshInfosOp.h" #include "SMESHGUI_Preferences_ColorDlg.h" #include "SMESHGUI_Preferences_ScalarBarDlg.h" #include "SMESHGUI_Preferences_SelectionDlg.h" @@ -161,8 +162,6 @@ namespace{ void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh, int theCommandID); - void ExportMeshToFile(int theCommandID); - void SetDisplayMode(int theCommandID); void SetDisplayEntity(int theCommandID); @@ -255,111 +254,6 @@ namespace{ } } - - void ExportMeshToFile( int theCommandID ) - { - SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr(); - SALOME_ListIO selected; - if( aSel ) - aSel->selectedObjects( selected ); - - if(selected.Extent()){ - Handle(SALOME_InteractiveObject) anIObject = selected.First(); - SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface(anIObject); - if ( !aMesh->_is_nil() ) { - QString aFilter, aTitle = QObject::tr("Export mesh"); - QMap aFilterMap; - switch ( theCommandID ) { - case 125: - case 122: - aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 ); - aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 ); - break; - case 124: - case 121: - aFilter = QObject::tr("DAT files (*.dat)"); - break; - case 126: - case 123: { - if(aMesh->NbPyramids()){ - int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(), - QObject::tr("SMESH_WRN_WARNING"), - QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()), - QObject::tr("SMESH_BUT_YES"), - QObject::tr("SMESH_BUT_NO"), - 0,1,0); - if(aRet) - return; - } - aFilter = QObject::tr("IDEAS files (*.unv)"); - break; - default: - return; - }} - - QString aFilename; - SMESH::MED_VERSION aFormat; - - if ( theCommandID != 122 && theCommandID != 125 ) - aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(), "", aFilter, aTitle, false); - else - { - QStringList filters; - for ( QMap::const_iterator it = aFilterMap.begin(); it != aFilterMap.end(); ++it ) - filters.push_back( it.key() ); - - SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true ); - fd->setCaption( aTitle ); - fd->setFilters( filters ); - bool is_ok = false; - while(!is_ok){ - fd->exec(); - aFilename = fd->selectedFile(); - aFormat = aFilterMap[fd->selectedFilter()]; - is_ok = true; - if( !aFilename.isEmpty() - && (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0) - && aFormat==SMESH::MED_V2_1){ - int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(), - QObject::tr("SMESH_WRN_WARNING"), - QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()), - QObject::tr("SMESH_BUT_YES"), - QObject::tr("SMESH_BUT_NO"), - 0,1,0); - if(aRet){ - is_ok = false; - } - } - } - delete fd; - } - if ( !aFilename.isEmpty() ) { - // Check whether the file already exists and delete it if yes - QFile aFile( aFilename ); - if ( aFile.exists() ) - aFile.remove(); - SUIT_OverrideCursor wc; - switch ( theCommandID ) { - case 125: - case 122: - aMesh->ExportToMED( aFilename.latin1(), false, aFormat ); // currently, automatic groups are never created - break; - case 124: - case 121: - aMesh->ExportDAT( aFilename.latin1() ); - break; - case 126: - case 123: - aMesh->ExportUNV( aFilename.latin1() ); - break; - default: - break; - } - } - } - } - } - inline void InverseEntityMode(unsigned int& theOutputMode, unsigned int theMode) { @@ -1026,7 +920,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) case 125: case 126: { - ::ExportMeshToFile(theCommandID); + startOperation( theCommandID ); + //::ExportMeshToFile(theCommandID); break; } @@ -1631,12 +1526,13 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) } else new SMESHGUI_MeshInfosDlg(this, "", false); + startOperation( 900 ); break; } case 902: // STANDARD MESH INFOS { - EmitSignalDeactivateDialog(); +/* EmitSignalDeactivateDialog(); SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr(); SALOME_ListIO selected; if( aSel ) @@ -1655,7 +1551,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) aSel->setSelectedObjects( selected ); } else - new SMESHGUI_StandardMeshInfosDlg( this, "", false); + new SMESHGUI_StandardMeshInfosDlg( this, "", false);*/ + startOperation( 902 ); break; } @@ -3282,7 +3179,27 @@ SalomeApp_Operation* SMESHGUI::createOperation( const int id ) const case 413: op = new SMESHGUI_ExtrusionOp(); break; + +/* case 900: + op = new SMESHGUI_MeshInfosOp(); + break;*/ + + case 902: + op = new SMESHGUI_StandardMeshInfosOp(); + break; + + case 121: case 124: + op = new SMESHGUI_ExportMeshOp( SMESHGUI_ExportMeshOp::DAT ); + break; + case 122: case 125: + op = new SMESHGUI_ExportMeshOp( SMESHGUI_ExportMeshOp::MED ); + break; + + case 123: case 126: + op = new SMESHGUI_ExportMeshOp( SMESHGUI_ExportMeshOp::UNV ); + break; + default: op = SalomeApp_Module::createOperation( id ); break; diff --git a/src/SMESHGUI/SMESHGUI_ExportMeshOp.cxx b/src/SMESHGUI/SMESHGUI_ExportMeshOp.cxx new file mode 100644 index 000000000..5fa852b5c --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_ExportMeshOp.cxx @@ -0,0 +1,177 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_ExportMeshOp.cxx +// Author : Alexander SOLOVYOV +// Module : SMESH +// $Header$ + +#include "SMESHGUI_ExportMeshOp.h" +#include +#include + +#include +#include +#include +#include +#include + +#include + +//================================================================================= +// function : +// purpose : +//================================================================================= +SMESHGUI_ExportMeshOp::SMESHGUI_ExportMeshOp( const Type t ) +: SMESHGUI_Operation(), + myType( t ) +{ +} + +//================================================================================= +// function : +// purpose : +//================================================================================= +SMESHGUI_ExportMeshOp::~SMESHGUI_ExportMeshOp() +{ +} + +//================================================================================= +// function : +// purpose : +//================================================================================= +void SMESHGUI_ExportMeshOp::startOperation() +{ + SMESHGUI_Operation::startOperation(); + + SalomeApp_SelectionMgr *aSel = selectionMgr(); + SALOME_ListIO selected; + if( aSel ) + aSel->selectedObjects( selected ); + + if( selected.Extent()==0 ) + { + abort(); + return; + } + + Handle(SALOME_InteractiveObject) anIObject = selected.First(); + SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface(anIObject); + if( !aMesh->_is_nil() ) + { + QString aFilter, aTitle = QObject::tr("Export mesh"); + QMap aFilterMap; + switch( myType ) + { + case MED: + aFilterMap.insert( QObject::tr("MED 2.1 (*.med)"), SMESH::MED_V2_1 ); + aFilterMap.insert( QObject::tr("MED 2.2 (*.med)"), SMESH::MED_V2_2 ); + break; + + case DAT: + aFilter = QObject::tr("DAT files (*.dat)"); + break; + + case UNV: + if( aMesh->NbPyramids() ) + { + int aRet = SUIT_MessageBox::warn2( desktop(), tr("SMESH_WRN_WARNING"), + tr("SMESH_EXPORT_UNV").arg(anIObject->getName()), tr("SMESH_BUT_YES"), + tr("SMESH_BUT_NO"), 0,1,0 ); + if(aRet) + { + abort(); + return; + } + } + aFilter = QObject::tr("IDEAS files (*.unv)"); + break; + default: + abort(); + return; + } + + QString aFilename; + SMESH::MED_VERSION aFormat; + + if( myType!=MED ) + aFilename = SUIT_FileDlg::getFileName( desktop(), "", aFilter, aTitle, false ); + else + { + QStringList filters; + for( QMap::const_iterator it = aFilterMap.begin(); it != aFilterMap.end(); ++it ) + filters.push_back( it.key() ); + + SUIT_FileDlg* fd = new SUIT_FileDlg( desktop(), false, true, true ); + fd->setCaption( aTitle ); + fd->setFilters( filters ); + bool is_ok = false; + while( !is_ok ) + { + fd->exec(); + aFilename = fd->selectedFile(); + aFormat = aFilterMap[fd->selectedFilter()]; + is_ok = true; + if( !aFilename.isEmpty() && (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0 ) && aFormat==SMESH::MED_V2_1) + { + int aRet = SUIT_MessageBox::warn2( desktop(), tr("SMESH_WRN_WARNING"), + tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()), tr("SMESH_BUT_YES"), + tr("SMESH_BUT_NO"), 0,1,0 ); + if(aRet) + is_ok = false; + } + } + delete fd; + } + + if( !aFilename.isEmpty() ) + { + // Check whether the file already exists and delete it if yes + QFile aFile( aFilename ); + if( aFile.exists() ) + aFile.remove(); + SUIT_OverrideCursor wc; + switch( myType ) + { + case MED: + aMesh->ExportToMED( aFilename.latin1(), false, aFormat ); // currently, automatic groups are never created + break; + + case DAT: + aMesh->ExportDAT( aFilename.latin1() ); + break; + + case UNV: + aMesh->ExportUNV( aFilename.latin1() ); + break; + + default: + abort(); + return; + } + commit(); + return; + } + } + abort(); +} diff --git a/src/SMESHGUI/SMESHGUI_ExportMeshOp.h b/src/SMESHGUI/SMESHGUI_ExportMeshOp.h new file mode 100644 index 000000000..3ad92fbe4 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_ExportMeshOp.h @@ -0,0 +1,54 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_ExportMeshOp.h +// Author : Alexander SOLOVYOV +// Module : SMESH +// $Header$ + +#ifndef OPERATION_EXPORT_MESH_H +#define OPERATION_EXPORT_MESH_H + +#include + +class SMESHGUI_ExportMeshOp : public SMESHGUI_Operation +{ +public: + typedef enum + { + MED, DAT, UNV + + } Type; + +public: + SMESHGUI_ExportMeshOp( const Type ); + ~SMESHGUI_ExportMeshOp(); + +protected: + virtual void startOperation(); + +private: + Type myType; +}; + +#endif diff --git a/src/SMESHGUI/SMESHGUI_Operation.cxx b/src/SMESHGUI/SMESHGUI_Operation.cxx index e43e0a68b..29a406753 100755 --- a/src/SMESHGUI/SMESHGUI_Operation.cxx +++ b/src/SMESHGUI/SMESHGUI_Operation.cxx @@ -70,8 +70,9 @@ void SMESHGUI_Operation::startOperation() if( dlg()->testButtonFlags( QtxDialog::Cancel ) ) connect( dlg(), SIGNAL( dlgCancel() ), this, SLOT( onCancel() ) ); - if( dlg()->testButtonFlags( QtxDialog::Close ) ) - connect( dlg(), SIGNAL( dlgClose() ), this, SLOT( onCancel() ) ); + //if( dlg()->testButtonFlags( QtxDialog::Close ) ) + //if dialog hasn't close, cancel, no and etc buttons, dlgClose will be emitted when dialog is closed not by OK + connect( dlg(), SIGNAL( dlgClose() ), this, SLOT( onCancel() ) ); initDialog(); } diff --git a/src/SMESHGUI/SMESHGUI_StandardMeshInfosDlg.cxx b/src/SMESHGUI/SMESHGUI_StandardMeshInfosDlg.cxx index 8960524b3..39f78d08a 100644 --- a/src/SMESHGUI/SMESHGUI_StandardMeshInfosDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_StandardMeshInfosDlg.cxx @@ -26,44 +26,13 @@ // Module : SMESH // $Header$ -#include "SMESHGUI_StandardMeshInfosDlg.h" +#include -#include "SMESHGUI.h" -#include "SMESHGUI_Utils.h" -#include "SMESHGUI_MeshUtils.h" +#include -#include "SMESH.hxx" -#include "SMESH_TypeFilter.hxx" - -#include "SALOMEDSClient_Study.hxx" -#include "SALOMEDSClient_SObject.hxx" - -#include "SUIT_Desktop.h" -#include "SUIT_Session.h" -#include "SUIT_OverrideCursor.h" - -#include "SalomeApp_SelectionMgr.h" -#include "SALOME_ListIO.hxx" - -#include "utilities.h" - -// QT Includes -#include -#include #include -#include +#include #include -#include -#include - -// IDL Headers -#include "SALOMEconfig.h" -#include CORBA_SERVER_HEADER(SMESH_Mesh) -#include CORBA_SERVER_HEADER(SMESH_Group) -#include CORBA_SERVER_HEADER(GEOM_Gen) - -using namespace std; - //================================================================================= /*! @@ -72,107 +41,41 @@ using namespace std; * Constructor */ //================================================================================= -SMESHGUI_StandardMeshInfosDlg::SMESHGUI_StandardMeshInfosDlg( SMESHGUI* theModule, const char* name, - bool modal, WFlags fl) - : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | - WStyle_Title | WStyle_SysMenu | WDestructiveClose), - mySMESHGUI( theModule ), - mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ) +SMESHGUI_StandardMeshInfosDlg::SMESHGUI_StandardMeshInfosDlg() +: SMESHGUI_Dialog( false, false, OK ) { - if (!name) - setName("SMESHGUI_StandardMeshInfosDlg"); setCaption(tr("SMESH_STANDARD_MESHINFO_TITLE" )); - setSizeGripEnabled(TRUE); - - myStartSelection = true; - myIsActiveWindow = true; + resize( 300, 200 ); + // dialog layout - QGridLayout* aDlgLayout = new QGridLayout(this); - aDlgLayout->setSpacing(6); - aDlgLayout->setMargin(11); + QVBoxLayout* main = new QVBoxLayout( mainFrame(), 0, 5 ); // mesh group box - myMeshGroup = new QGroupBox(this, "myMeshGroup"); - myMeshGroup->setTitle(tr("SMESH_MESH")); - myMeshGroup->setColumnLayout(0, Qt::Vertical); - myMeshGroup->layout()->setSpacing(0); - myMeshGroup->layout()->setMargin(0); - QGridLayout* myMeshGroupLayout = new QGridLayout(myMeshGroup->layout()); - myMeshGroupLayout->setAlignment(Qt::AlignTop); - myMeshGroupLayout->setSpacing(6); - myMeshGroupLayout->setMargin(11); - - // select button, label and line edit with mesh name - myNameLab = new QLabel(myMeshGroup, "myNameLab"); - myNameLab->setText(tr("SMESH_NAME" )); - myMeshGroupLayout->addWidget(myNameLab, 0, 0); + QGroupBox* MeshGroup = new QGroupBox( mainFrame(), "myMeshGroup"); + MeshGroup->setTitle(tr("SMESH_MESH")); + MeshGroup->setColumnLayout(3, Qt::Horizontal); + MeshGroup->layout()->setSpacing(0); + MeshGroup->layout()->setMargin(5); - QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("SMESH",tr("ICON_SELECT"))); - mySelectBtn = new QPushButton(myMeshGroup, "mySelectBtn"); - mySelectBtn->setPixmap(image0); - mySelectBtn->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); - myMeshGroupLayout->addWidget(mySelectBtn, 0, 1); + createObject( tr("SMESH_NAME" ), MeshGroup, 0 ); + setNameIndication( 0, OneName ); + setObjectType( 0, prefix( "SMESH" ) + MESH, -1 ); - myMeshLine = new QLineEdit(myMeshGroup, "myMeshLine"); - myMeshGroupLayout->addWidget(myMeshLine, 0, 2); - - aDlgLayout->addWidget(myMeshGroup, 0, 0); + main->addWidget( MeshGroup ); // information group box - myInfoGroup = new QGroupBox(this, "myInfoGroup"); - myInfoGroup->setTitle(tr("SMESH_INFORMATION")); - myInfoGroup->setColumnLayout(0, Qt::Vertical); - myInfoGroup->layout()->setSpacing(0); - myInfoGroup->layout()->setMargin(0); - QGridLayout* myInfoGroupLayout = new QGridLayout(myInfoGroup->layout()); - myInfoGroupLayout->setAlignment(Qt::AlignTop); - myInfoGroupLayout->setSpacing(6); - myInfoGroupLayout->setMargin(11); + QGroupBox* InfoGroup = new QGroupBox( mainFrame(), "myInfoGroup"); + InfoGroup->setTitle(tr("SMESH_INFORMATION")); + InfoGroup->setColumnLayout(1, Qt::Vertical); + InfoGroup->layout()->setSpacing(0); + InfoGroup->layout()->setMargin(5); // information text browser - myInfo = new QTextBrowser(myInfoGroup, "myInfo"); - myInfoGroupLayout->addWidget(myInfo, 0, 0); - - aDlgLayout->addWidget(myInfoGroup, 1, 0); - - // buttons group - myButtonsGroup = new QGroupBox(this, "myButtonsGroup"); - myButtonsGroup->setColumnLayout(0, Qt::Vertical); - myButtonsGroup->layout()->setSpacing(0); myButtonsGroup->layout()->setMargin(0); - QHBoxLayout* myButtonsGroupLayout = new QHBoxLayout(myButtonsGroup->layout()); - myButtonsGroupLayout->setAlignment(Qt::AlignTop); - myButtonsGroupLayout->setSpacing(6); myButtonsGroupLayout->setMargin(11); - - // buttons --> OK button - myOkBtn = new QPushButton(tr("SMESH_BUT_OK" ), myButtonsGroup, "myOkBtn"); - myOkBtn->setAutoDefault(TRUE); myOkBtn->setDefault(TRUE); - myButtonsGroupLayout->addStretch(); - myButtonsGroupLayout->addWidget(myOkBtn); - myButtonsGroupLayout->addStretch(); + myInfo = new QTextBrowser( InfoGroup, "myInfo"); - aDlgLayout->addWidget(myButtonsGroup, 2, 0); + main->addWidget( InfoGroup ); - mySMESHGUI->SetActiveDialogBox(this); - - // connect signals - connect( myOkBtn, SIGNAL(clicked()), this, SLOT(close())); - connect( mySelectBtn, SIGNAL(clicked()), this, SLOT(onStartSelection())); - connect( mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(close())); - connect( mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); - connect( mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionChanged())); - - // resize and move dialog, then show - this->setMinimumSize(270, 428); - int x, y; - mySMESHGUI->DefineDlgPosition(this, x, y); - this->move(x, y); - this->show(); - - // init dialog with current selection - myMeshFilter = new SMESH_TypeFilter (MESH); - mySelectionMgr->installFilter(myMeshFilter); - onSelectionChanged(); } //================================================================================= @@ -188,259 +91,12 @@ SMESHGUI_StandardMeshInfosDlg::~SMESHGUI_StandardMeshInfosDlg() //================================================================================= /*! - * SMESHGUI_StandardMeshInfosDlg::DumpMeshInfos + * SMESHGUI_StandardMeshInfosDlg::setInfo + * + * Set text to text browser */ //================================================================================= -void SMESHGUI_StandardMeshInfosDlg::DumpMeshInfos() -{ - SUIT_OverrideCursor wc; - - SALOME_ListIO aList; - mySelectionMgr->selectedObjects(aList); - - int nbSel = aList.Extent(); - myInfo->clear(); - if (nbSel == 1) { - myStartSelection = false; - myMeshLine->setText(""); - SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(aList.First()); - - if (!aMesh->_is_nil()) { - QString aName, anInfo; - SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aName); - myMeshLine->setText(aName); - int aNbNodes = (int)aMesh->NbNodes(); - int aNbEdges = (int)aMesh->NbEdges(); - int aNbFaces = (int)aMesh->NbFaces(); - int aNbVolumes = (int)aMesh->NbVolumes(); - - int aDimension = 0; - double aNbDimElements = 0; - if (aNbVolumes > 0) { - aNbDimElements = aNbVolumes; - aDimension = 3; - } - else if(aNbFaces > 0) { - aNbDimElements = aNbFaces; - aDimension = 2; - } - else if(aNbEdges > 0) { - aNbDimElements = aNbEdges; - aDimension = 1; - } - else if(aNbNodes > 0) { - aNbDimElements = aNbNodes; - aDimension = 0; - } - - // information about the mesh - anInfo.append(QString("Nb of element of dimension %1: %2
").arg(aDimension).arg(aNbDimElements)); - anInfo.append(QString("Nb of nodes: %1

").arg(aNbNodes)); - - // information about the groups of the mesh - _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); - _PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh); - _PTR(SObject) anObj; - - bool hasGroup = false; - - // info about groups on nodes - aMeshSO->FindSubObject(Tag_NodeGroups, anObj); - if (anObj) { - _PTR(ChildIterator) it = aStudy->NewChildIterator(anObj); - if (it->More()) { - anInfo.append(QString("Groups:

")); - hasGroup = true; - } - for (; it->More(); it->Next()) { - _PTR(SObject) subObj = it->Value(); - CORBA::Object_var anObject = SMESH::SObjectToObject(subObj); - SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(anObject); - if (!aGroup->_is_nil()) { - anInfo.append(QString("- %1
").arg(aGroup->GetName())); - anInfo.append(QString("%1
").arg("on nodes")); - anInfo.append(QString("%1
").arg(aGroup->Size())); - // check if the group based on geometry - SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow(aGroup); - if (!aGroupOnGeom->_is_nil()) { - GEOM::GEOM_Object_var aGroupMainShape = aGroupOnGeom->GetShape(); - QString aShapeName = ""; - _PTR(SObject) aGeomObj, aRef; - if (subObj->FindSubObject(1, aGeomObj) && aGeomObj->ReferencedObject(aRef)) - aShapeName = aRef->GetName().c_str(); - anInfo.append(QString("based on %1 geometry object

").arg(aShapeName)); - } else { - anInfo.append(QString("
")); - } - } - } - } - - // info about groups on edges - anObj.reset(); - aMeshSO->FindSubObject(Tag_EdgeGroups, anObj); - if (anObj) { - _PTR(ChildIterator) it = aStudy->NewChildIterator(anObj); - if (!hasGroup && it->More()) { - anInfo.append(QString("Groups:

")); - hasGroup = true; - } - for (; it->More(); it->Next()) { - _PTR(SObject) subObj = it->Value(); - CORBA::Object_var anObject = SMESH::SObjectToObject(subObj); - SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(anObject); - if (!aGroup->_is_nil()) { - anInfo.append(QString("- %1
").arg(aGroup->GetName())); - anInfo.append(QString("%1
").arg("on edges")); - anInfo.append(QString("%1
").arg(aGroup->Size())); - // check if the group based on geometry - SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow(aGroup); - if (!aGroupOnGeom->_is_nil()) { - GEOM::GEOM_Object_var aGroupMainShape = aGroupOnGeom->GetShape(); - QString aShapeName = ""; - _PTR(SObject) aGeomObj, aRef; - if (subObj->FindSubObject(1, aGeomObj) && aGeomObj->ReferencedObject(aRef)) - aShapeName = aRef->GetName().c_str(); - anInfo.append(QString("based on %1 geometry object

").arg(aShapeName)); - } else { - anInfo.append(QString("
")); - } - } - } - } - - // info about groups on faces - anObj.reset(); - aMeshSO->FindSubObject(Tag_FaceGroups , anObj); - if (anObj) { - _PTR(ChildIterator) it = aStudy->NewChildIterator(anObj); - if (!hasGroup && it->More()) { - anInfo.append(QString("Groups:

")); - hasGroup = true; - } - for (; it->More(); it->Next()) { - _PTR(SObject) subObj = it->Value(); - CORBA::Object_var anObject = SMESH::SObjectToObject(subObj); - SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(anObject); - if (!aGroup->_is_nil()) { - anInfo.append(QString("- %1
").arg(aGroup->GetName())); - anInfo.append(QString("%1
").arg("on faces")); - anInfo.append(QString("%1
").arg(aGroup->Size())); - // check if the group based on geometry - SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow(aGroup); - if (!aGroupOnGeom->_is_nil()) { - GEOM::GEOM_Object_var aGroupMainShape = aGroupOnGeom->GetShape(); - QString aShapeName = ""; - _PTR(SObject) aGeomObj, aRef; - if (subObj->FindSubObject(1, aGeomObj) && aGeomObj->ReferencedObject(aRef)) - aShapeName = aRef->GetName().c_str(); - anInfo.append(QString("based on %1 geometry object

").arg(aShapeName)); - } else { - anInfo.append(QString("
")); - } - } - } - } - - // info about groups on volumes - anObj.reset(); - aMeshSO->FindSubObject(Tag_VolumeGroups, anObj); - if (anObj) { - _PTR(ChildIterator) it = aStudy->NewChildIterator(anObj); - if (!hasGroup && it->More()) - anInfo.append(QString("Groups:
")); - for (; it->More(); it->Next()) { - _PTR(SObject) subObj = it->Value(); - CORBA::Object_var anObject = SMESH::SObjectToObject(subObj); - SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(anObject); - if (!aGroup->_is_nil()) { - anInfo.append(QString("- %1
").arg(aGroup->GetName())); - anInfo.append(QString("%1
").arg("on volumes")); - anInfo.append(QString("%1
").arg(aGroup->Size())); - // check if the group based on geometry - SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow(aGroup); - if (!aGroupOnGeom->_is_nil()) { - GEOM::GEOM_Object_var aGroupMainShape = aGroupOnGeom->GetShape(); - QString aShapeName = ""; - _PTR(SObject) aGeomObj, aRef; - if (subObj->FindSubObject(1, aGeomObj) && aGeomObj->ReferencedObject(aRef)) - aShapeName = aRef->GetName().c_str(); - anInfo.append(QString("based on %1 geometry object

").arg(aShapeName)); - } else { - anInfo.append(QString("
")); - } - } - } - } - - myInfo->setText(anInfo); - return; - } - } -} - -//================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection has changed -//================================================================================= -void SMESHGUI_StandardMeshInfosDlg::onSelectionChanged() -{ - if (myStartSelection) - DumpMeshInfos(); -} - -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void SMESHGUI_StandardMeshInfosDlg::closeEvent (QCloseEvent* e) -{ - mySelectionMgr->clearFilters(); - mySMESHGUI->ResetState(); - QDialog::closeEvent(e); -} - -//================================================================================= -// function : windowActivationChange() -// purpose : called when window is activated/deactivated -//================================================================================= -void SMESHGUI_StandardMeshInfosDlg::windowActivationChange (bool oldActive) -{ - QDialog::windowActivationChange(oldActive); - if (isActiveWindow() && myIsActiveWindow != isActiveWindow()) - ActivateThisDialog(); - myIsActiveWindow = isActiveWindow(); -} - -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void SMESHGUI_StandardMeshInfosDlg::DeactivateActiveDialog() -{ - disconnect(mySelectionMgr, 0, this, 0); -} - -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void SMESHGUI_StandardMeshInfosDlg::ActivateThisDialog() -{ - /* Emit a signal to deactivate any active dialog */ - mySMESHGUI->EmitSignalDeactivateDialog(); - connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionChanged())); -} - -//================================================================================= -// function : onStartSelection() -// purpose : starts selection -//================================================================================= -void SMESHGUI_StandardMeshInfosDlg::onStartSelection() +void SMESHGUI_StandardMeshInfosDlg::setInfo( const QString& text ) { - myStartSelection = true; - mySelectionMgr->installFilter(myMeshFilter); - myMeshLine->setText(tr("Select a mesh")); - onSelectionChanged(); - myStartSelection = true; + myInfo->setText( text ); } diff --git a/src/SMESHGUI/SMESHGUI_StandardMeshInfosDlg.h b/src/SMESHGUI/SMESHGUI_StandardMeshInfosDlg.h index 7fcbdc239..720eb47c6 100644 --- a/src/SMESHGUI/SMESHGUI_StandardMeshInfosDlg.h +++ b/src/SMESHGUI/SMESHGUI_StandardMeshInfosDlg.h @@ -29,60 +29,22 @@ #ifndef SMESHGUI_STANDARDMESHINFOSDLG_H #define SMESHGUI_STANDARDMESHINFOSDLG_H -//#include "SMESH_TypeFilter.hxx" -#include "SUIT_SelectionFilter.h" +#include -// QT Includes -#include - -class QGroupBox; -class QLabel; -class QPushButton; -class QLineEdit; class QTextBrowser; -class SalomeApp_SelectionMgr; -class SMESHGUI; - -class SMESHGUI_StandardMeshInfosDlg : public QDialog +class SMESHGUI_StandardMeshInfosDlg : public SMESHGUI_Dialog { Q_OBJECT public: - SMESHGUI_StandardMeshInfosDlg( SMESHGUI*, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + SMESHGUI_StandardMeshInfosDlg(); ~SMESHGUI_StandardMeshInfosDlg(); -protected: - void closeEvent( QCloseEvent* e ); - void windowActivationChange( bool oldActive ); - void DumpMeshInfos(); - -private slots: - void onSelectionChanged(); - void DeactivateActiveDialog() ; - void ActivateThisDialog(); - void onStartSelection(); + void setInfo( const QString& ); private: - SMESHGUI* mySMESHGUI; - SalomeApp_SelectionMgr* mySelectionMgr; - bool myStartSelection; - bool myIsActiveWindow; - - //Handle(SMESH_TypeFilter) myMeshFilter; - SUIT_SelectionFilter* myMeshFilter; - - QLabel* myNameLab; - QPushButton* mySelectBtn; - QLineEdit* myMeshLine; - QTextBrowser* myInfo; - - QGroupBox* myMeshGroup; - QGroupBox* myInfoGroup; - - QGroupBox* myButtonsGroup; - QPushButton* myOkBtn; }; #endif // SMESHGUI_STANDARDMESHINFOSDLG_H diff --git a/src/SMESHGUI/SMESHGUI_StandardMeshInfosOp.cxx b/src/SMESHGUI/SMESHGUI_StandardMeshInfosOp.cxx new file mode 100644 index 000000000..39fc0c77a --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_StandardMeshInfosOp.cxx @@ -0,0 +1,333 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_StandardMeshInfosOp.cxx +// Author : Alexander SOLOVYOV +// Module : SMESH +// $Header$ + +#include "SMESHGUI_StandardMeshInfosOp.h" +#include +#include + +#include +#include + +#include + +#include CORBA_SERVER_HEADER(SMESH_Gen) +#include CORBA_SERVER_HEADER(SMESH_Group) + +#include + +//================================================================================= +// function : SMESHGUI_StandardMeshInfosOp() +// purpose : constructor +//================================================================================= +SMESHGUI_StandardMeshInfosOp::SMESHGUI_StandardMeshInfosOp() +: SMESHGUI_SelectionOp(), + myDlg( 0 ) +{ +} + +//================================================================================= +// function : ~SMESHGUI_StandardMeshInfosOp() +// purpose : destructor +//================================================================================= +SMESHGUI_StandardMeshInfosOp::~SMESHGUI_StandardMeshInfosOp() +{ + if( myDlg ) + delete myDlg; +} + +//================================================================================= +// function : dlg +// purpose : +//================================================================================= +SalomeApp_Dialog* SMESHGUI_StandardMeshInfosOp::dlg() const +{ + return myDlg; +} + +//================================================================================= +// function : startOperation +// purpose : +//================================================================================= +void SMESHGUI_StandardMeshInfosOp::startOperation() +{ + if( !myDlg ) + myDlg = new SMESHGUI_StandardMeshInfosDlg(); + + SMESHGUI_SelectionOp::startOperation(); + + myDlg->show(); +} + +//================================================================================= +// function : createFilter +// purpose : +//================================================================================= +SUIT_SelectionFilter* SMESHGUI_StandardMeshInfosOp::createFilter( const int ) const +{ + return new SMESH_TypeFilter( MESH ); +} + +//================================================================================= +// function : fillMeshInfos +// purpose : +//================================================================================= +void SMESHGUI_StandardMeshInfosOp::fillMeshInfos() +{ + if( !myDlg ) + return; + + SUIT_OverrideCursor wc; + + QStringList ids; myDlg->selectedObject( 0, ids ); + if( ids.count()==0 ) + { + myDlg->setInfo( "" ); + return; + } + + _PTR(SObject) SO = studyDS()->FindObjectID( ids.first() ), anObj; + if( !SO ) + { + myDlg->setInfo( "" ); + return; + } + + SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( _CAST(SObject,SO)->GetObject() ); + + if( aMesh->_is_nil() ) + { + myDlg->setInfo( "" ); + return; + } + + + QString anInfo; + int aNbNodes = (int)aMesh->NbNodes(); + int aNbEdges = (int)aMesh->NbEdges(); + int aNbFaces = (int)aMesh->NbFaces(); + int aNbVolumes = (int)aMesh->NbVolumes(); + + int aDimension = 0; + double aNbDimElements = 0; + if( aNbVolumes > 0 ) + { + aNbDimElements = aNbVolumes; + aDimension = 3; + } + else if( aNbFaces > 0 ) + { + aNbDimElements = aNbFaces; + aDimension = 2; + } + else if( aNbEdges > 0 ) + { + aNbDimElements = aNbEdges; + aDimension = 1; + } + else if( aNbNodes > 0 ) + { + aNbDimElements = aNbNodes; + aDimension = 0; + } + + // information about the mesh + anInfo.append(QString("Nb of element of dimension %1: %2
").arg(aDimension).arg(aNbDimElements)); + anInfo.append(QString("Nb of nodes: %1

").arg(aNbNodes)); + + bool hasGroup = false; + + // info about groups on nodes + SO->FindSubObject( Tag_NodeGroups, anObj ); + if( anObj ) + { + _PTR(ChildIterator) it = studyDS()->NewChildIterator(anObj); + if( it->More() ) + { + anInfo.append(QString("Groups:

")); + hasGroup = true; + + for( ; it->More(); it->Next() ) + { + _PTR(SObject) subObj = it->Value(); + CORBA::Object_var anObject = SMESH::SObjectToObject(subObj); + SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(anObject); + if( !aGroup->_is_nil() ) + { + anInfo.append(QString("- %1
").arg(aGroup->GetName())); + anInfo.append(QString("%1
").arg("on nodes")); + anInfo.append(QString("%1
").arg(aGroup->Size())); + // check if the group based on geometry + SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow(aGroup); + if (!aGroupOnGeom->_is_nil()) + { + GEOM::GEOM_Object_var aGroupMainShape = aGroupOnGeom->GetShape(); + QString aShapeName = ""; + _PTR(SObject) aGeomObj, aRef; + if (subObj->FindSubObject(1, aGeomObj) && aGeomObj->ReferencedObject(aRef)) + aShapeName = aRef->GetName().c_str(); + anInfo.append(QString("based on %1 geometry object

").arg(aShapeName)); + } + else + anInfo.append(QString("
")); + } + } + } + + // info about groups on edges + anObj.reset(); + SO->FindSubObject(Tag_EdgeGroups, anObj); + if( anObj ) + { + _PTR(ChildIterator) it = studyDS()->NewChildIterator(anObj); + if( !hasGroup && it->More() ) + { + anInfo.append(QString("Groups:

")); + hasGroup = true; + } + for( ; it->More(); it->Next() ) + { + _PTR(SObject) subObj = it->Value(); + CORBA::Object_var anObject = SMESH::SObjectToObject(subObj); + SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(anObject); + if( !aGroup->_is_nil() ) + { + anInfo.append(QString("- %1
").arg(aGroup->GetName())); + anInfo.append(QString("%1
").arg("on edges")); + anInfo.append(QString("%1
").arg(aGroup->Size())); + // check if the group based on geometry + SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow(aGroup); + if( !aGroupOnGeom->_is_nil() ) + { + GEOM::GEOM_Object_var aGroupMainShape = aGroupOnGeom->GetShape(); + QString aShapeName = ""; + _PTR(SObject) aGeomObj, aRef; + if( subObj->FindSubObject( 1, aGeomObj ) && aGeomObj->ReferencedObject( aRef ) ) + aShapeName = aRef->GetName().c_str(); + anInfo.append(QString("based on %1 geometry object

").arg(aShapeName)); + } + else + anInfo.append(QString("
")); + } + } + } + + // info about groups on faces + anObj.reset(); + SO->FindSubObject( Tag_FaceGroups, anObj ); + if (anObj) + { + _PTR(ChildIterator) it = studyDS()->NewChildIterator(anObj); + if( !hasGroup && it->More() ) + { + anInfo.append(QString("Groups:

")); + hasGroup = true; + } + for( ; it->More(); it->Next() ) + { + _PTR(SObject) subObj = it->Value(); + CORBA::Object_var anObject = SMESH::SObjectToObject(subObj); + SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(anObject); + if( !aGroup->_is_nil() ) + { + anInfo.append(QString("- %1
").arg(aGroup->GetName())); + anInfo.append(QString("%1
").arg("on faces")); + anInfo.append(QString("%1
").arg(aGroup->Size())); + // check if the group based on geometry + SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow(aGroup); + if( !aGroupOnGeom->_is_nil() ) + { + GEOM::GEOM_Object_var aGroupMainShape = aGroupOnGeom->GetShape(); + QString aShapeName = ""; + _PTR(SObject) aGeomObj, aRef; + if (subObj->FindSubObject(1, aGeomObj) && aGeomObj->ReferencedObject(aRef)) + aShapeName = aRef->GetName().c_str(); + anInfo.append(QString("based on %1 geometry object

").arg(aShapeName)); + } + else + anInfo.append(QString("
")); + } + } + } + + // info about groups on volumes + anObj.reset(); + SO->FindSubObject( Tag_VolumeGroups, anObj ); + if( anObj ) + { + _PTR(ChildIterator) it = studyDS()->NewChildIterator(anObj); + if( !hasGroup && it->More() ) + anInfo.append(QString("Groups:
")); + for( ; it->More(); it->Next() ) + { + _PTR(SObject) subObj = it->Value(); + CORBA::Object_var anObject = SMESH::SObjectToObject(subObj); + SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(anObject); + if( !aGroup->_is_nil() ) + { + anInfo.append(QString("- %1
").arg(aGroup->GetName())); + anInfo.append(QString("%1
").arg("on volumes")); + anInfo.append(QString("%1
").arg(aGroup->Size())); + // check if the group based on geometry + SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow(aGroup); + if( !aGroupOnGeom->_is_nil() ) + { + GEOM::GEOM_Object_var aGroupMainShape = aGroupOnGeom->GetShape(); + QString aShapeName = ""; + _PTR(SObject) aGeomObj, aRef; + if (subObj->FindSubObject(1, aGeomObj) && aGeomObj->ReferencedObject(aRef)) + aShapeName = aRef->GetName().c_str(); + anInfo.append(QString("based on %1 geometry object

").arg(aShapeName)); + } + else + anInfo.append(QString("
")); + } + } + } + } + myDlg->setInfo(anInfo); +} + +//================================================================================= +// function : onOk +// purpose : +//================================================================================= +void SMESHGUI_StandardMeshInfosOp::onOk() +{ + commit(); +} + +//================================================================================= +// function : onSelectionChanged +// purpose : +//================================================================================= +void SMESHGUI_StandardMeshInfosOp::onSelectionChanged( int ) +{ + fillMeshInfos(); +} + + diff --git a/src/SMESHGUI/SMESHGUI_StandardMeshInfosOp.h b/src/SMESHGUI/SMESHGUI_StandardMeshInfosOp.h new file mode 100644 index 000000000..0d46cd524 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_StandardMeshInfosOp.h @@ -0,0 +1,59 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_StandardMeshInfos.h +// Author : Alexander SOLOVYOV +// Module : SMESH +// $Header: + +#ifndef SMESHGUI_STANDARDMESHINFOSOP_H +#define SMESHGUI_STANDARDMESHINFOSOP_H + +#include + +class SMESHGUI_StandardMeshInfosDlg; + +class SMESHGUI_StandardMeshInfosOp : public SMESHGUI_SelectionOp +{ + Q_OBJECT + +public: + SMESHGUI_StandardMeshInfosOp(); + ~SMESHGUI_StandardMeshInfosOp(); + + virtual SalomeApp_Dialog* dlg() const; + +protected: + virtual void startOperation(); + virtual SUIT_SelectionFilter* createFilter( const int ) const; + void fillMeshInfos(); + +protected slots: + virtual void onOk(); + virtual void onSelectionChanged( int ); + +private: + SMESHGUI_StandardMeshInfosDlg* myDlg; +}; + +#endif // SMESHGUI_STANDARDMESHINFOSOP_H -- 2.39.2