Issue 0021055: EDF 1602 STUDY: Object browser reactualisation when creating an object

This commit is contained in:
ouv 2011-03-25 15:25:16 +00:00
parent cacc7209a0
commit 36afbbe8e3
22 changed files with 360 additions and 28 deletions

View File

@ -215,6 +215,7 @@
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
QStringList errors;
QStringList anEntryList;
bool isEmpty = false;
for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
QString filename = *it;
@ -276,6 +277,8 @@
if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
anEntryList.append( aMeshSO->GetID().c_str() );
#ifdef WITHGENERICOBJ
// obj has been published in study. Its refcount has been incremented.
// It is safe to decrement its refcount
@ -292,6 +295,11 @@
// update Object browser
SMESHGUI::GetSMESHGUI()->updateObjBrowser();
// browse to the published meshes
if( LightApp_Application* anApp =
dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
anApp->browseObjects( anEntryList );
// show Error message box if there were errors
if ( errors.count() > 0 ) {
SUIT_MessageBox::critical( SMESHGUI::desktop(),
@ -2372,24 +2380,33 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME);
// create group for each type o elements
QString aName = IObject->getName();
QStringList anEntryList;
if (aNodes->length() > 0) {
SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName + "_Nodes");
aGroup->Add(aNodes.inout());
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
anEntryList.append( aSObject->GetID().c_str() );
}
if (aEdges->length() > 0) {
SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName + "_Edges");
aGroup->Add(aEdges.inout());
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
anEntryList.append( aSObject->GetID().c_str() );
}
if (aFaces->length() > 0) {
SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName + "_Faces");
aGroup->Add(aFaces.inout());
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
anEntryList.append( aSObject->GetID().c_str() );
}
if (aVolumes->length() > 0) {
SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName + "_Volumes");
aGroup->Add(aVolumes.inout());
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aGroup ) )
anEntryList.append( aSObject->GetID().c_str() );
}
updateObjBrowser();
anApp->browseObjects( anEntryList );
}
catch(const SALOME::SALOME_Exception & S_ex){
SalomeApp_Tools::QtCatchCorbaException(S_ex);

View File

@ -77,7 +77,8 @@
SMESHGUI_BuildCompoundDlg::SMESHGUI_BuildCompoundDlg( SMESHGUI* theModule )
: QDialog(SMESH::GetDesktop(theModule)),
mySMESHGUI(theModule),
mySelectionMgr(SMESH::GetSelectionMgr(theModule))
mySelectionMgr(SMESH::GetSelectionMgr(theModule)),
myIsApplyAndClose( false )
{
setModal(false);
setAttribute(Qt::WA_DeleteOnClose, true);
@ -298,6 +299,7 @@ bool SMESHGUI_BuildCompoundDlg::ClickOnApply()
if (!myMesh->_is_nil()) {
QStringList aParameters;
aParameters << (CheckBoxMerge->isChecked() ? SpinBoxTol->text() : QString(" "));
QStringList anEntryList;
try {
SUIT_OverrideCursor aWaitCursor;
@ -316,7 +318,11 @@ bool SMESHGUI_BuildCompoundDlg::ClickOnApply()
aCompoundMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
SMESH::SetName( SMESH::FindSObject( aCompoundMesh ), LineEditName->text() );
_PTR(SObject) aSO = SMESH::FindSObject( aCompoundMesh );
if( aSO ) {
SMESH::SetName( aSO, LineEditName->text() );
anEntryList.append( aSO->GetID().c_str() );
}
mySMESHGUI->updateObjBrowser();
} catch(...) {
return false;
@ -334,6 +340,10 @@ bool SMESHGUI_BuildCompoundDlg::ClickOnApply()
SMESH::DisplayActor(SMESH::GetActiveWindow(), anActor);
}// end IPAL21468
if( LightApp_Application* anApp =
dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
anApp->browseObjects( anEntryList, isApplyAndClose() );
SMESHGUI::Modified();
#ifdef WITHGENERICOBJ
@ -355,6 +365,7 @@ bool SMESHGUI_BuildCompoundDlg::ClickOnApply()
//=================================================================================
void SMESHGUI_BuildCompoundDlg::ClickOnOk()
{
setIsApplyAndClose( true );
if (ClickOnApply())
ClickOnCancel();
}
@ -540,3 +551,23 @@ bool SMESHGUI_BuildCompoundDlg::isValid()
}
return true;
}
//================================================================
// function : setIsApplyAndClose
// Purpose : Set value of the flag indicating that the dialog is
// accepted by Apply & Close button
//================================================================
void SMESHGUI_BuildCompoundDlg::setIsApplyAndClose( const bool theFlag )
{
myIsApplyAndClose = theFlag;
}
//================================================================
// function : isApplyAndClose
// Purpose : Get value of the flag indicating that the dialog is
// accepted by Apply & Close button
//================================================================
bool SMESHGUI_BuildCompoundDlg::isApplyAndClose() const
{
return myIsApplyAndClose;
}

View File

@ -74,6 +74,9 @@ private:
void keyPressEvent( QKeyEvent* );
bool isValid();
void setIsApplyAndClose( const bool theFlag );
bool isApplyAndClose() const;
private:
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
@ -110,6 +113,8 @@ private:
QString myHelpFileName;
bool myIsApplyAndClose;
private slots:
void ClickOnOk();
void ClickOnCancel();

View File

@ -115,7 +115,8 @@ SMESHGUI_CopyMeshDlg::SMESHGUI_CopyMeshDlg( SMESHGUI* theModule )
mySMESHGUI( theModule ),
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
myFilterDlg(0),
mySelectedObject(SMESH::SMESH_IDSource::_nil())
mySelectedObject(SMESH::SMESH_IDSource::_nil()),
myIsApplyAndClose( false )
{
QPixmap image (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_COPY_MESH")));
@ -308,6 +309,7 @@ bool SMESHGUI_CopyMeshDlg::ClickOnApply()
if( !isValid() )
return false;
QStringList anEntryList;
try
{
SUIT_OverrideCursor aWaitCursor;
@ -334,6 +336,9 @@ bool SMESHGUI_CopyMeshDlg::ClickOnApply()
SMESH::SMESH_Gen_var gen = SMESHGUI::GetSMESHGen();
SMESH::SMESH_Mesh_var newMesh =
gen->CopyMesh(aPartToCopy, meshName.constData(), toCopyGroups, toKeepIDs);
if( !newMesh->_is_nil() )
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( newMesh ) )
anEntryList.append( aSObject->GetID().c_str() );
#ifdef WITHGENERICOBJ
// obj has been published in study. Its refcount has been incremented.
// It is safe to decrement its refcount
@ -346,6 +351,10 @@ bool SMESHGUI_CopyMeshDlg::ClickOnApply()
mySMESHGUI->updateObjBrowser(true);
SMESHGUI::Modified();
if( LightApp_Application* anApp =
dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
anApp->browseObjects( anEntryList, isApplyAndClose() );
Init(false);
mySelectedObject = SMESH::SMESH_IDSource::_nil();
SelectionIntoArgument();
@ -359,6 +368,7 @@ bool SMESHGUI_CopyMeshDlg::ClickOnApply()
//=================================================================================
void SMESHGUI_CopyMeshDlg::ClickOnOk()
{
setIsApplyAndClose( true );
if( ClickOnApply() )
ClickOnCancel();
}
@ -665,3 +675,23 @@ void SMESHGUI_CopyMeshDlg::setFilters()
myFilterDlg->show();
}
//================================================================
// function : setIsApplyAndClose
// Purpose : Set value of the flag indicating that the dialog is
// accepted by Apply & Close button
//================================================================
void SMESHGUI_CopyMeshDlg::setIsApplyAndClose( const bool theFlag )
{
myIsApplyAndClose = theFlag;
}
//================================================================
// function : isApplyAndClose
// Purpose : Get value of the flag indicating that the dialog is
// accepted by Apply & Close button
//================================================================
bool SMESHGUI_CopyMeshDlg::isApplyAndClose() const
{
return myIsApplyAndClose;
}

View File

@ -74,6 +74,9 @@ private:
bool isValid();
void setIsApplyAndClose( const bool theFlag );
bool isApplyAndClose() const;
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
SMESHGUI_IdValidator* myIdValidator;
LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */
@ -109,6 +112,8 @@ private:
QString myHelpFileName;
bool myIsApplyAndClose;
private slots:
void ClickOnOk();
void ClickOnCancel();

View File

@ -123,7 +123,8 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule,
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
mySelector( SMESH::GetViewWindow( theModule )->GetSelector() ),
myIsBusy( false ),
myNameChanged( false )
myNameChanged( false ),
myIsApplyAndClose( false )
{
initDialog( true );
if ( !theMesh->_is_nil() )
@ -773,6 +774,8 @@ bool SMESHGUI_GroupDlg::onApply()
if (myName->text().trimmed().isEmpty())
return false;
bool anIsOk = false;
QStringList anEntryList;
if (myGrpTypeId == 0) { // on mesh elements
if (!mySelectAll->isChecked() && !myElements->count())
return false;
@ -824,6 +827,8 @@ bool SMESHGUI_GroupDlg::onApply()
myGroup->SetColor(aColor);
_PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroup);
if( aMeshGroupSO )
anEntryList.append( aMeshGroupSO->GetID().c_str() );
//SMESH::setFileName ( aMeshGroupSO, QString::number(myColorSpinBox->value()) );
SMESH::setFileType ( aMeshGroupSO, "COULEURGROUP" );
@ -895,7 +900,7 @@ bool SMESHGUI_GroupDlg::onApply()
mySMESHGUI->updateObjBrowser(true);
SMESH::UpdateView(); // asv: fix of BUG PAL5515
mySelectionMgr->clearSelected();
return true;
anIsOk = true;
}
else if (myGrpTypeId == 1) { // on geom object
if (CORBA::is_nil(myGroupOnGeom)) { // creation
@ -971,6 +976,8 @@ bool SMESHGUI_GroupDlg::onApply()
myGroupOnGeom->SetColor(aColor);
_PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroupOnGeom);
if( aMeshGroupSO )
anEntryList.append( aMeshGroupSO->GetID().c_str() );
//SMESH::setFileName ( aMeshGroupSO, QString::number(myColorSpinBox->value()) );
SMESH::setFileType ( aMeshGroupSO,"COULEURGROUP" );
@ -1000,10 +1007,15 @@ bool SMESHGUI_GroupDlg::onApply()
SMESHGUI::Modified();
mySMESHGUI->updateObjBrowser(true);
mySelectionMgr->clearSelected();
return true;
anIsOk = true;
}
return false;
if( anIsOk )
if( LightApp_Application* anApp =
dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
myObjectToSelect = anApp->browseObjects( anEntryList, isApplyAndClose() );
return anIsOk;
}
//=================================================================================
@ -1012,8 +1024,10 @@ bool SMESHGUI_GroupDlg::onApply()
//=================================================================================
void SMESHGUI_GroupDlg::onOK()
{
setIsApplyAndClose( true );
if ( onApply() )
onClose();
setIsApplyAndClose( false );
}
//=================================================================================
@ -1963,7 +1977,13 @@ void SMESHGUI_GroupDlg::onClose()
restoreShowEntityMode();
}
mySelectionMgr->clearSelected();
if( isApplyAndClose() && !myObjectToSelect.isEmpty() ) {
SUIT_DataOwnerPtrList aList;
aList.append( new LightApp_DataOwner( myObjectToSelect ) );
mySelectionMgr->setSelected( aList );
}
else
mySelectionMgr->clearSelected();
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(ActorSelection);
mySelectionMgr->clearFilters();
@ -2395,3 +2415,23 @@ bool SMESHGUI_GroupDlg::IsActorVisible( SMESH_Actor* theActor )
return aViewWindow->isVisible(theActor->getIO());
return false;
}
//================================================================
//function : setIsApplyAndClose
//purpose : Set value of the flag indicating that the dialog is
// accepted by Apply & Close button
//================================================================
void SMESHGUI_GroupDlg::setIsApplyAndClose( const bool theFlag )
{
myIsApplyAndClose = theFlag;
}
//================================================================
//function : isApplyAndClose
//purpose : Get value of the flag indicating that the dialog is
// accepted by Apply & Close button
//================================================================
bool SMESHGUI_GroupDlg::isApplyAndClose() const
{
return myIsApplyAndClose;
}

View File

@ -141,6 +141,9 @@ private:
QColor getGroupQColor() const;
void setDefaultGroupColor();
void setIsApplyAndClose( const bool theFlag );
bool isApplyAndClose() const;
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */
@ -215,6 +218,9 @@ private:
QMap<QAction*, int> myActions;
bool myNameChanged; //added by skl for IPAL19574
QString myObjectToSelect;
bool myIsApplyAndClose;
};
#endif // SMESHGUI_GROUPDLG_H

View File

@ -36,6 +36,7 @@
#include <SUIT_Session.h>
#include <SUIT_OverrideCursor.h>
#include <LightApp_Application.h>
#include <LightApp_UpdateFlags.h>
#include <SUIT_ResourceMgr.h>
@ -318,6 +319,7 @@ bool SMESHGUI_GroupOnShapeOp::onApply()
// create groups
SMESH::SMESH_GroupOnGeom_var group;
QStringList anEntryList;
for ( int isNode = 0; isNode < 2; ++isNode ) // elems and then nodes
{
QStringList::iterator geomID = isNode ? myNodeGeoIDs.begin() : myElemGeoIDs.begin();
@ -346,6 +348,9 @@ bool SMESHGUI_GroupOnShapeOp::onApply()
//printf( "apply() %s %s\n", (*geomID).latin1(), name.latin1() );
group = mesh->CreateGroupFromGEOM( elemType, name.toLatin1().data(), geom );
if( !group->_is_nil() )
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( group ) )
anEntryList.append( aSObject->GetID().c_str() );
}
}
SMESHGUI::Modified();
@ -362,6 +367,10 @@ bool SMESHGUI_GroupOnShapeOp::onApply()
myDlg->myNodeGeomBtn->setChecked(false);
myDlg->updateButtons();
if( LightApp_Application* anApp =
dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
anApp->browseObjects( anEntryList, isApplyAndClose() );
return !group->_is_nil();
}

View File

@ -45,6 +45,9 @@
#include <SVTK_ViewWindow.h>
#include <SALOME_ListIO.hxx>
// SALOME KERNEL includes
#include <SALOMEDSClient_SObject.hxx>
// Qt includes
#include <QHBoxLayout>
#include <QVBoxLayout>
@ -75,7 +78,8 @@
SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg( SMESHGUI* theModule )
: QDialog( SMESH::GetDesktop( theModule ) ),
mySMESHGUI( theModule ),
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
myIsApplyAndClose( false )
{
setModal(false);
@ -309,8 +313,10 @@ bool SMESHGUI_GroupOpDlg::isValid( const QList<SMESH::SMESH_GroupBase_var>& theL
*/
void SMESHGUI_GroupOpDlg::onOk()
{
setIsApplyAndClose( true );
if ( onApply() )
onClose();
setIsApplyAndClose( false );
}
/*!
@ -525,6 +531,28 @@ bool SMESHGUI_GroupOpDlg::onApply()
return false;
}
/*!
\brief Set value of the flag indicating that the dialog is
accepted by Apply & Close button
\param theFlag value of the flag
\sa isApplyAndClose()
*/
void SMESHGUI_GroupOpDlg::setIsApplyAndClose( const bool theFlag )
{
myIsApplyAndClose = theFlag;
}
/*!
\brief Get value of the flag indicating that the dialog is
accepted by Apply & Close button
\return value of the flag
\sa setApplyAndClose()
*/
bool SMESHGUI_GroupOpDlg::isApplyAndClose() const
{
return myIsApplyAndClose;
}
// === === === === === === === === === === === === === === === === === === === === ===
/*!
@ -586,6 +614,7 @@ bool SMESHGUI_UnionGroupsDlg::onApply()
QString aName = getName();
bool aRes = false;
QStringList anEntryList;
try
{
SMESH::ListOfGroups_var aList = convert( myGroups );
@ -594,6 +623,8 @@ bool SMESHGUI_UnionGroupsDlg::onApply()
if ( !CORBA::is_nil( aNewGrp ) )
{
aNewGrp->SetColor( getColor() );
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aNewGrp ) )
anEntryList.append( aSObject->GetID().c_str() );
aRes = true;
}
}
@ -607,6 +638,9 @@ bool SMESHGUI_UnionGroupsDlg::onApply()
SMESHGUI::Modified();
getSMESHGUI()->updateObjBrowser(true);
reset();
if( LightApp_Application* anApp =
dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
anApp->browseObjects( anEntryList, isApplyAndClose() );
return true;
}
else
@ -689,6 +723,7 @@ bool SMESHGUI_IntersectGroupsDlg::onApply()
QString aName = getName();
bool aRes = false;
QStringList anEntryList;
try
{
SMESH::ListOfGroups_var aList = convert( myGroups );
@ -697,6 +732,8 @@ bool SMESHGUI_IntersectGroupsDlg::onApply()
if ( !CORBA::is_nil( aNewGrp ) )
{
aNewGrp->SetColor( getColor() );
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aNewGrp ) )
anEntryList.append( aSObject->GetID().c_str() );
aRes = true;
}
}
@ -710,6 +747,9 @@ bool SMESHGUI_IntersectGroupsDlg::onApply()
SMESHGUI::Modified();
getSMESHGUI()->updateObjBrowser(true);
reset();
if( LightApp_Application* anApp =
dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
anApp->browseObjects( anEntryList, isApplyAndClose() );
return true;
}
else
@ -855,6 +895,7 @@ bool SMESHGUI_CutGroupsDlg::onApply()
QString aName = getName();
bool aRes = false;
QStringList anEntryList;
try
{
SMESH::ListOfGroups_var aList1 = convert( myGroups1 );
@ -864,6 +905,8 @@ bool SMESHGUI_CutGroupsDlg::onApply()
if ( !CORBA::is_nil( aNewGrp ) )
{
aNewGrp->SetColor( getColor() );
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aNewGrp ) )
anEntryList.append( aSObject->GetID().c_str() );
aRes = true;
}
}
@ -877,6 +920,9 @@ bool SMESHGUI_CutGroupsDlg::onApply()
SMESHGUI::Modified();
getSMESHGUI()->updateObjBrowser(true);
reset();
if( LightApp_Application* anApp =
dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
anApp->browseObjects( anEntryList, isApplyAndClose() );
return true;
}
else
@ -1007,6 +1053,7 @@ bool SMESHGUI_DimGroupDlg::onApply()
QString aName = getName();
bool aRes = false;
QStringList anEntryList;
try
{
SMESH::ListOfGroups_var aList = convert( myGroups );
@ -1016,6 +1063,8 @@ bool SMESHGUI_DimGroupDlg::onApply()
if ( !CORBA::is_nil( aNewGrp ) )
{
aNewGrp->SetColor( getColor() );
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aNewGrp ) )
anEntryList.append( aSObject->GetID().c_str() );
aRes = true;
}
}
@ -1029,6 +1078,9 @@ bool SMESHGUI_DimGroupDlg::onApply()
SMESHGUI::Modified();
getSMESHGUI()->updateObjBrowser(true);
reset();
if( LightApp_Application* anApp =
dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
anApp->browseObjects( anEntryList, isApplyAndClose() );
return true;
}
else

View File

@ -88,6 +88,9 @@ protected:
SALOMEDS::Color getColor() const;
void setIsApplyAndClose( const bool theFlag );
bool isApplyAndClose() const;
private:
void closeEvent( QCloseEvent* );
void enterEvent( QEvent* );
@ -119,6 +122,8 @@ private:
SVTK_Selector* mySelector;
QString myHelpFileName;
bool myIsApplyAndClose;
};
/*

View File

@ -28,12 +28,14 @@
#include "SMESH_LogicalFilter.hxx"
// SALOME GUI includes
#include <LightApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <LightApp_UpdateFlags.h>
#include <SALOME_ListIO.hxx>
#include <SUIT_Desktop.h>
#include <SUIT_MessageBox.h>
#include <SUIT_OverrideCursor.h>
#include <SUIT_Session.h>
#include <SVTK_ViewModel.h>
#include <SalomeApp_Study.h>
#include <SalomeApp_Tools.h>
@ -337,7 +339,7 @@ bool SMESHGUI_Make2DFrom3DOp::isValid( QString& msg ) const
return true;
}
bool SMESHGUI_Make2DFrom3DOp::compute2DMesh()
bool SMESHGUI_Make2DFrom3DOp::compute2DMesh( QStringList& theEntryList )
{
SUIT_OverrideCursor wc;
@ -373,6 +375,8 @@ bool SMESHGUI_Make2DFrom3DOp::compute2DMesh()
tr("SMESH_INFORMATION"),
tr("NB_ADDED").arg( nbAdded ));
if ( !newMesh->_is_nil() ) {
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( newMesh ) )
theEntryList.append( aSObject->GetID().c_str() );
#ifdef WITHGENERICOBJ
newMesh->UnRegister();
#endif
@ -403,9 +407,10 @@ bool SMESHGUI_Make2DFrom3DOp::onApply()
return false;
}
QStringList anEntryList;
bool res = false;
try {
res = compute2DMesh();
res = compute2DMesh( anEntryList );
}
catch ( const SALOME::SALOME_Exception& S_ex ) {
SalomeApp_Tools::QtCatchCorbaException( S_ex );
@ -416,6 +421,9 @@ bool SMESHGUI_Make2DFrom3DOp::onApply()
if ( res ) {
SMESHGUI::Modified();
update( UF_ObjBrowser | UF_Model );
if( LightApp_Application* anApp =
dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
anApp->browseObjects( anEntryList, isApplyAndClose() );
myDlg->setNewMeshName( SMESH::UniqueName( "Mesh_1" ) );
myDlg->setGroupName( SMESH::UniqueName( "Group" ) );
}

View File

@ -105,7 +105,7 @@ protected slots:
void onModeChanged();
private:
bool compute2DMesh();
bool compute2DMesh( QStringList& );
private:
SMESH::SMESH_Mesh_var mySrcMesh;

View File

@ -45,10 +45,12 @@
// SALOME GUI includes
#include <SalomeApp_Tools.h>
#include <SalomeApp_Application.h>
#include <LightApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <LightApp_UpdateFlags.h>
#include <SUIT_MessageBox.h>
#include <SUIT_OverrideCursor.h>
#include <SUIT_Session.h>
#include <SALOME_InteractiveObject.hxx>
#include <SALOME_ListIO.hxx>
@ -146,16 +148,20 @@ bool SMESHGUI_MeshOp::onApply()
aMess = "";
try
{
QStringList anEntryList;
if ( myToCreate && myIsMesh )
aResult = createMesh( aMess );
aResult = createMesh( aMess, anEntryList );
if ( myToCreate && !myIsMesh )
aResult = createSubMesh( aMess );
aResult = createSubMesh( aMess, anEntryList );
else if ( !myToCreate )
aResult = editMeshOrSubMesh( aMess );
if ( aResult )
{
SMESHGUI::Modified();
update( UF_ObjBrowser | UF_Model );
if( LightApp_Application* anApp =
dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
myObjectToSelect = anApp->browseObjects( anEntryList, isApplyAndClose() );
}
}
catch ( const SALOME::SALOME_Exception& S_ex )
@ -246,6 +252,30 @@ void SMESHGUI_MeshOp::startOperation()
selectionDone();
myIgnoreAlgoSelection = false;
myObjectToSelect.clear();
}
//=================================================================================
/*!
* \brief Selects a recently created mesh or sub-mesh if necessary
*
* Virtual method redefined from base class called when operation is commited
* selects a recently created mesh or sub-mesh if necessary. Allows to perform
* selection when the custom selection filters are removed.
*/
//=================================================================================
void SMESHGUI_MeshOp::commitOperation()
{
SMESHGUI_SelectionOp::commitOperation();
if ( !myObjectToSelect.isEmpty() ) {
if ( LightApp_SelectionMgr* aSelectionMgr = selectionMgr() ) {
SUIT_DataOwnerPtrList aList;
aList.append( new LightApp_DataOwner( myObjectToSelect ) );
aSelectionMgr->setSelected( aList );
}
}
}
//================================================================================
@ -1558,12 +1588,13 @@ void SMESHGUI_MeshOp::processSet()
/*!
* \brief Creates mesh
* \param theMess - Output parameter intended for returning error message
* \param theEntryList - List of entries of published objects
* \retval bool - TRUE if mesh is created, FALSE otherwise
*
* Creates mesh
*/
//================================================================================
bool SMESHGUI_MeshOp::createMesh( QString& theMess )
bool SMESHGUI_MeshOp::createMesh( QString& theMess, QStringList& theEntryList )
{
theMess = "";
@ -1591,8 +1622,10 @@ bool SMESHGUI_MeshOp::createMesh( QString& theMess )
if ( aMeshVar->_is_nil() )
return false;
_PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshVar.in() );
if ( aMeshSO )
if ( aMeshSO ) {
SMESH::SetName( aMeshSO, myDlg->objectText( SMESHGUI_MeshDlg::Obj ) );
theEntryList.append( aMeshSO->GetID().c_str() );
}
for ( int aDim = SMESH::DIM_0D; aDim <= SMESH::DIM_3D; aDim++ ) {
if ( !isAccessibleDim( aDim )) continue;
@ -1626,12 +1659,13 @@ bool SMESHGUI_MeshOp::createMesh( QString& theMess )
/*!
* \brief Creates sub-mesh
* \param theMess - Output parameter intended for returning error message
* \param theEntryList - List of entries of published objects
* \retval bool - TRUE if sub-mesh is created, FALSE otherwise
*
* Creates sub-mesh
*/
//================================================================================
bool SMESHGUI_MeshOp::createSubMesh( QString& theMess )
bool SMESHGUI_MeshOp::createSubMesh( QString& theMess, QStringList& theEntryList )
{
theMess = "";
@ -1721,8 +1755,10 @@ bool SMESHGUI_MeshOp::createSubMesh( QString& theMess )
// create sub-mesh
SMESH::SMESH_subMesh_var aSubMeshVar = aMeshVar->GetSubMesh( aGeomVar, aName.toLatin1().data() );
_PTR(SObject) aSubMeshSO = SMESH::FindSObject( aSubMeshVar.in() );
if ( aSubMeshSO )
if ( aSubMeshSO ) {
SMESH::SetName( aSubMeshSO, aName.toLatin1().data() );
theEntryList.append( aSubMeshSO->GetID().c_str() );
}
for ( int aDim = SMESH::DIM_0D; aDim <= SMESH::DIM_3D; aDim++ )
{

View File

@ -66,6 +66,7 @@ public:
protected:
virtual void startOperation();
virtual void commitOperation();
virtual void selectionDone();
virtual SUIT_SelectionFilter* createFilter( const int ) const;
virtual bool isValid( SUIT_Operation* ) const;
@ -105,8 +106,8 @@ private:
void createHypothesis( const int, const int,
const QString& );
bool createMesh( QString& );
bool createSubMesh( QString& );
bool createMesh( QString&, QStringList& );
bool createSubMesh( QString&, QStringList& );
bool editMeshOrSubMesh( QString& );
int currentHyp( const int, const int ) const;
@ -142,6 +143,8 @@ private:
bool myIgnoreAlgoSelection;
HypothesesSet* myHypoSet;
int myDim, myType;
QString myObjectToSelect;
};
#endif // SMESHGUI_MESHOP_H

View File

@ -50,7 +50,8 @@
// Purpose : Constructor
//=======================================================================
SMESHGUI_Operation::SMESHGUI_Operation()
: LightApp_Operation()
: LightApp_Operation(),
myIsApplyAndClose( false )
{
myHelpFileName = "";
}
@ -158,8 +159,10 @@ _PTR(Study) SMESHGUI_Operation::studyDS() const
//=======================================================================
void SMESHGUI_Operation::onOk()
{
setIsApplyAndClose( true );
if( onApply() )
commit();
setIsApplyAndClose( false );
//else
// abort();
}
@ -214,6 +217,26 @@ void SMESHGUI_Operation::initDialog()
{
}
//================================================================
// name : setIsApplyAndClose
// Purpose : Set value of the flag indicating that the dialog is
// accepted by Apply & Close button
//================================================================
void SMESHGUI_Operation::setIsApplyAndClose( const bool theFlag )
{
myIsApplyAndClose = theFlag;
}
//================================================================
// name : isApplyAndClose
// Purpose : Get value of the flag indicating that the dialog is
// accepted by Apply & Close button
//================================================================
bool SMESHGUI_Operation::isApplyAndClose() const
{
return myIsApplyAndClose;
}
/*!
* \brief Verifies whether study of operation is locked
* \param theMess - specifies whether message box must be shown if study is locked

View File

@ -58,6 +58,9 @@ protected:
virtual void startOperation();
virtual bool isReadyToStart() const;
virtual void setIsApplyAndClose( const bool theFlag );
virtual bool isApplyAndClose() const;
//! Set according dialog active or inactive
virtual void setDialogActive( const bool );
@ -69,6 +72,7 @@ protected:
virtual bool isValid( SUIT_Operation* ) const;
QString myHelpFileName;
bool myIsApplyAndClose;
protected slots:
virtual void onOk();

View File

@ -46,7 +46,9 @@
//=================================================================================
SMESHGUI_PreviewDlg::SMESHGUI_PreviewDlg(SMESHGUI* theModule) :
mySMESHGUI(theModule),
QDialog(SMESH::GetDesktop( theModule )) {
QDialog(SMESH::GetDesktop( theModule )),
myIsApplyAndClose( false )
{
mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ));
}
@ -101,3 +103,23 @@ void SMESHGUI_PreviewDlg::toDisplaySimulation() {
void SMESHGUI_PreviewDlg::onDisplaySimulation(bool toDisplayPreview) {
//Empty implementation here
}
//================================================================
// Function : setIsApplyAndClose
// Purpose : Set value of the flag indicating that the dialog is
// accepted by Apply & Close button
//================================================================
void SMESHGUI_PreviewDlg::setIsApplyAndClose( const bool theFlag )
{
myIsApplyAndClose = theFlag;
}
//================================================================
// Function : isApplyAndClose
// Purpose : Get value of the flag indicating that the dialog is
// accepted by Apply & Close button
//================================================================
bool SMESHGUI_PreviewDlg::isApplyAndClose() const
{
return myIsApplyAndClose;
}

View File

@ -49,6 +49,9 @@ public:
protected:
void connectPreviewControl();
virtual void setIsApplyAndClose( const bool theFlag );
virtual bool isApplyAndClose() const;
protected slots:
void toDisplaySimulation();
virtual void onDisplaySimulation( bool );
@ -58,6 +61,7 @@ protected:
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
SMESHGUI_MeshEditPreview* mySimulation;
QCheckBox* myPreviewCheckBox;
bool myIsApplyAndClose;
};
#endif

View File

@ -430,6 +430,7 @@ bool SMESHGUI_RotationDlg::ClickOnApply()
int actionButton = ActionGroup->checkedId();
bool makeGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() );
QStringList anEntryList;
try {
SUIT_OverrideCursor aWaitCursor;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
@ -469,6 +470,8 @@ bool SMESHGUI_RotationDlg::ClickOnApply()
LineEditNewMesh->text().toLatin1().data());
if (!mesh->_is_nil()) {
mesh->SetParameters(aParameters.join(":").toLatin1().constData());
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) )
anEntryList.append( aSObject->GetID().c_str() );
#ifdef WITHGENERICOBJ
// obj has been published in study. Its refcount has been incremented.
// It is safe to decrement its refcount
@ -484,8 +487,12 @@ bool SMESHGUI_RotationDlg::ClickOnApply()
SMESH::UpdateView();
if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ||
actionButton == MAKE_MESH_BUTTON )
actionButton == MAKE_MESH_BUTTON ) {
mySMESHGUI->updateObjBrowser(true); // new groups may appear
if( LightApp_Application* anApp =
dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
anApp->browseObjects( anEntryList, isApplyAndClose() );
}
Init(false);
mySelectedObject = SMESH::SMESH_IDSource::_nil();
SelectionIntoArgument();
@ -502,6 +509,7 @@ bool SMESHGUI_RotationDlg::ClickOnApply()
//=================================================================================
void SMESHGUI_RotationDlg::ClickOnOk()
{
setIsApplyAndClose( true );
if( ClickOnApply() )
ClickOnCancel();
}

View File

@ -472,6 +472,7 @@ bool SMESHGUI_ScaleDlg::ClickOnApply()
int actionButton = ActionGroup->checkedId();
bool makeGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() );
QStringList anEntryList;
try {
SUIT_OverrideCursor aWaitCursor;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
@ -505,6 +506,8 @@ bool SMESHGUI_ScaleDlg::ClickOnApply()
LineEditNewMesh->text().toLatin1().data());
if (!mesh->_is_nil()) {
mesh->SetParameters(aParameters.join(":").toLatin1().constData());
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) )
anEntryList.append( aSObject->GetID().c_str() );
#ifdef WITHGENERICOBJ
// obj has been published in study. Its refcount has been incremented.
// It is safe to decrement its refcount
@ -520,8 +523,12 @@ bool SMESHGUI_ScaleDlg::ClickOnApply()
SMESH::UpdateView();
if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ||
actionButton == MAKE_MESH_BUTTON )
actionButton == MAKE_MESH_BUTTON ) {
mySMESHGUI->updateObjBrowser(true); // new groups may appear
if( LightApp_Application* anApp =
dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
anApp->browseObjects( anEntryList, isApplyAndClose() );
}
Init(false);
ConstructorsClicked(GetConstructorId());
mySelectedObject = SMESH::SMESH_IDSource::_nil();
@ -539,6 +546,7 @@ bool SMESHGUI_ScaleDlg::ClickOnApply()
//=================================================================================
void SMESHGUI_ScaleDlg::ClickOnOk()
{
setIsApplyAndClose( true );
if( ClickOnApply() )
ClickOnCancel();
}

View File

@ -494,7 +494,7 @@ bool SMESHGUI_SymmetryDlg::ClickOnApply()
int actionButton = ActionGroup->checkedId();
bool makeGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() );
QStringList anEntryList;
try {
SUIT_OverrideCursor aWaitCursor;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
@ -538,6 +538,8 @@ bool SMESHGUI_SymmetryDlg::ClickOnApply()
LineEditNewMesh->text().toLatin1().data());
if (!mesh->_is_nil()) {
mesh->SetParameters(aParameters.join(":").toLatin1().constData());
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) )
anEntryList.append( aSObject->GetID().c_str() );
#ifdef WITHGENERICOBJ
// obj has been published in study. Its refcount has been incremented.
// It is safe to decrement its refcount
@ -553,8 +555,12 @@ bool SMESHGUI_SymmetryDlg::ClickOnApply()
SMESH::UpdateView();
if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ||
actionButton == MAKE_MESH_BUTTON )
actionButton == MAKE_MESH_BUTTON ) {
mySMESHGUI->updateObjBrowser(true); // new groups may appear
if( LightApp_Application* anApp =
dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
anApp->browseObjects( anEntryList, isApplyAndClose() );
}
Init(false);
ConstructorsClicked(GetConstructorId());
mySelectedObject = SMESH::SMESH_IDSource::_nil();
@ -571,6 +577,7 @@ bool SMESHGUI_SymmetryDlg::ClickOnApply()
//=================================================================================
void SMESHGUI_SymmetryDlg::ClickOnOk()
{
setIsApplyAndClose( true );
if( ClickOnApply() )
ClickOnCancel();
}

View File

@ -504,6 +504,7 @@ bool SMESHGUI_TranslationDlg::ClickOnApply()
int actionButton = ActionGroup->checkedId();
bool makeGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() );
QStringList anEntryList;
try {
SUIT_OverrideCursor aWaitCursor;
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
@ -543,6 +544,8 @@ bool SMESHGUI_TranslationDlg::ClickOnApply()
LineEditNewMesh->text().toLatin1().data());
if (!mesh->_is_nil()) {
mesh->SetParameters(aParameters.join(":").toLatin1().constData());
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) )
anEntryList.append( aSObject->GetID().c_str() );
#ifdef WITHGENERICOBJ
// obj has been published in study. Its refcount has been incremented.
// It is safe to decrement its refcount
@ -556,8 +559,13 @@ bool SMESHGUI_TranslationDlg::ClickOnApply()
SMESH::UpdateView();
if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ||
actionButton == MAKE_MESH_BUTTON )
actionButton == MAKE_MESH_BUTTON ) {
mySMESHGUI->updateObjBrowser(true); // new groups may appear
if( LightApp_Application* anApp =
dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
anApp->browseObjects( anEntryList, isApplyAndClose() );
}
Init(false);
ConstructorsClicked(GetConstructorId());
mySelectedObject = SMESH::SMESH_IDSource::_nil();
@ -575,6 +583,7 @@ bool SMESHGUI_TranslationDlg::ClickOnApply()
//=================================================================================
void SMESHGUI_TranslationDlg::ClickOnOk()
{
setIsApplyAndClose( true );
if( ClickOnApply() )
ClickOnCancel();
}