mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-02-06 00:04:18 +05:00
SMESHGUI_DeleteOp operation added
This commit is contained in:
parent
27542bbe52
commit
2439f9a459
@ -116,7 +116,8 @@ LIB_SRC = SMESHGUI.cxx \
|
|||||||
SMESHGUI_CreatePolyhedralVolumeDlg.cxx \
|
SMESHGUI_CreatePolyhedralVolumeDlg.cxx \
|
||||||
SMESHGUI_Dialog.cxx \
|
SMESHGUI_Dialog.cxx \
|
||||||
SMESHGUI_Operation.cxx \
|
SMESHGUI_Operation.cxx \
|
||||||
SMESHGUI_SelectionOp.cxx
|
SMESHGUI_SelectionOp.cxx \
|
||||||
|
SMESHGUI_DeleteOp.cxx
|
||||||
|
|
||||||
LIB_MOC = \
|
LIB_MOC = \
|
||||||
SMESHGUI.h \
|
SMESHGUI.h \
|
||||||
@ -169,6 +170,7 @@ LIB_MOC = \
|
|||||||
SMESHGUI_Dialog.h \
|
SMESHGUI_Dialog.h \
|
||||||
SMESHGUI_CreatePolyhedralVolumeDlg.h \
|
SMESHGUI_CreatePolyhedralVolumeDlg.h \
|
||||||
SMESHGUI_Operation.h \
|
SMESHGUI_Operation.h \
|
||||||
|
SMESHGUI_DeleteOp.h \
|
||||||
SMESHGUI_SelectionOp.h
|
SMESHGUI_SelectionOp.h
|
||||||
|
|
||||||
LIB_CLIENT_IDL = SALOME_Exception.idl \
|
LIB_CLIENT_IDL = SALOME_Exception.idl \
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "SMESHGUI_InitMeshOp.h"
|
#include "SMESHGUI_InitMeshOp.h"
|
||||||
#include "SMESHGUI_AddSubMeshOp.h"
|
#include "SMESHGUI_AddSubMeshOp.h"
|
||||||
#include "SMESHGUI_NodesOp.h"
|
#include "SMESHGUI_NodesOp.h"
|
||||||
|
#include "SMESHGUI_DeleteOp.h"
|
||||||
#include "SMESHGUI_TransparencyDlg.h"
|
#include "SMESHGUI_TransparencyDlg.h"
|
||||||
#include "SMESHGUI_ClippingDlg.h"
|
#include "SMESHGUI_ClippingDlg.h"
|
||||||
#include "SMESHGUI_GroupDlg.h"
|
#include "SMESHGUI_GroupDlg.h"
|
||||||
@ -714,115 +715,6 @@ namespace{
|
|||||||
|
|
||||||
return RefType;
|
return RefType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnEditDelete()
|
|
||||||
{
|
|
||||||
// VSR 17/11/04: check if all objects selected belong to SMESH component --> start
|
|
||||||
SalomeApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
|
|
||||||
SALOME_ListIO selected; aSel->selectedObjects( selected );
|
|
||||||
|
|
||||||
QString aParentComponent = QString::null;
|
|
||||||
for( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
|
|
||||||
{
|
|
||||||
QString cur = anIt.Value()->getComponentDataType();
|
|
||||||
if( aParentComponent.isNull() )
|
|
||||||
aParentComponent = cur;
|
|
||||||
else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
|
|
||||||
aParentComponent = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( aParentComponent != SMESHGUI::GetSMESHGUI()->name() ) {
|
|
||||||
SUIT_MessageBox::warn1 ( SMESHGUI::desktop(),
|
|
||||||
QObject::tr("ERR_ERROR"),
|
|
||||||
QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg( SMESHGUI::GetSMESHGUI()->moduleName() ),
|
|
||||||
QObject::tr("BUT_OK") );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
|
|
||||||
if (SUIT_MessageBox::warn2
|
|
||||||
(SMESHGUI::desktop(),
|
|
||||||
QObject::tr("SMESH_WRN_WARNING"),
|
|
||||||
QObject::tr("SMESH_REALLY_DELETE"),
|
|
||||||
QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
|
|
||||||
SUIT_ViewManager* vm = anApp->activeViewManager();
|
|
||||||
int nbSf = vm->getViewsCount();
|
|
||||||
|
|
||||||
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
|
|
||||||
_PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
|
|
||||||
_PTR(GenericAttribute) anAttr;
|
|
||||||
_PTR(AttributeIOR) anIOR;
|
|
||||||
|
|
||||||
SALOME_ListIteratorOfListIO It(selected);
|
|
||||||
|
|
||||||
aStudyBuilder->NewCommand(); // There is a transaction
|
|
||||||
for(; It.More(); It.Next()){
|
|
||||||
Handle(SALOME_InteractiveObject) IObject = It.Value();
|
|
||||||
if(IObject->hasEntry()){
|
|
||||||
_PTR(SObject) SO = aStudy->FindObjectID(IObject->getEntry());
|
|
||||||
|
|
||||||
/* Erase child graphical objects */
|
|
||||||
_PTR(ChildIterator) it = aStudy->NewChildIterator(SO);
|
|
||||||
for(it->InitEx(true); it->More(); it->Next()){
|
|
||||||
_PTR(SObject) CSO = it->Value();
|
|
||||||
if(CSO->FindAttribute(anAttr, "AttributeIOR")){
|
|
||||||
anIOR = anAttr;
|
|
||||||
|
|
||||||
QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
|
|
||||||
for(int i = 0; i < nbSf; i++){
|
|
||||||
SUIT_ViewWindow *sf = aViews[i];
|
|
||||||
CORBA::String_var anEntry = CSO->GetID().c_str();
|
|
||||||
if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){
|
|
||||||
SMESH::RemoveActor(sf,anActor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Erase main graphical object */
|
|
||||||
QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
|
|
||||||
for(int i = 0; i < nbSf; i++){
|
|
||||||
SUIT_ViewWindow *sf = aViews[i];
|
|
||||||
if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){
|
|
||||||
SMESH::RemoveActor(sf,anActor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove object(s) from data structures
|
|
||||||
_PTR(SObject) obj = aStudy->FindObjectID(IObject->getEntry());
|
|
||||||
if(obj){
|
|
||||||
SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( obj ) );
|
|
||||||
SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( obj ) );
|
|
||||||
|
|
||||||
if ( !aGroup->_is_nil() ) { // DELETE GROUP
|
|
||||||
SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
|
|
||||||
aMesh->RemoveGroup( aGroup );
|
|
||||||
}
|
|
||||||
else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH
|
|
||||||
SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
|
|
||||||
aMesh->RemoveSubMesh( aSubMesh );
|
|
||||||
}
|
|
||||||
else {// default action: remove SObject from the study
|
|
||||||
// san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
|
|
||||||
//SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
|
|
||||||
//op->start();
|
|
||||||
aStudyBuilder->RemoveObjectWithChildren( obj );
|
|
||||||
//op->finish();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} /* IObject->hasEntry() */
|
|
||||||
} /* more/next */
|
|
||||||
aStudyBuilder->CommitCommand();
|
|
||||||
|
|
||||||
/* Clear any previous selection */
|
|
||||||
SALOME_ListIO l1;
|
|
||||||
aSel->setSelectedObjects( l1 );
|
|
||||||
|
|
||||||
SMESHGUI::GetSMESHGUI()->updateObjBrowser();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -1116,8 +1008,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
|
|||||||
|
|
||||||
switch (theCommandID) {
|
switch (theCommandID) {
|
||||||
case 33: // DELETE
|
case 33: // DELETE
|
||||||
if(checkLock(aStudy)) break;
|
startOperation( 33 );
|
||||||
::OnEditDelete();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 113: // IMPORT
|
case 113: // IMPORT
|
||||||
@ -3293,6 +3184,10 @@ SalomeApp_Operation* SMESHGUI::createOperation( const int id ) const
|
|||||||
SalomeApp_Operation* op = 0;
|
SalomeApp_Operation* op = 0;
|
||||||
switch( id )
|
switch( id )
|
||||||
{
|
{
|
||||||
|
case 33:
|
||||||
|
op = new SMESHGUI_DeleteOp();
|
||||||
|
break;
|
||||||
|
|
||||||
case 400:
|
case 400:
|
||||||
op = new SMESHGUI_NodesOp();
|
op = new SMESHGUI_NodesOp();
|
||||||
break;
|
break;
|
||||||
|
206
src/SMESHGUI/SMESHGUI_DeleteOp.cxx
Executable file
206
src/SMESHGUI/SMESHGUI_DeleteOp.cxx
Executable file
@ -0,0 +1,206 @@
|
|||||||
|
// SALOME SMESHGUI
|
||||||
|
//
|
||||||
|
// Copyright (C) 2005 CEA/DEN, EDF R&D
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// File : SMESHGUI_DeleteOp.cxx
|
||||||
|
// Author : Sergey LITONIN
|
||||||
|
// Module : SALOME
|
||||||
|
|
||||||
|
|
||||||
|
#include "SMESHGUI_DeleteOp.h"
|
||||||
|
#include "SMESHGUI_Utils.h"
|
||||||
|
#include "SMESHGUI.h"
|
||||||
|
#include "SMESHGUI_VTKUtils.h"
|
||||||
|
#include <SMESH_Actor.h>
|
||||||
|
#include <SalomeApp_UpdateFlags.h>
|
||||||
|
#include <SalomeApp_Tools.h>
|
||||||
|
#include <SALOME_ListIteratorOfListIO.hxx>
|
||||||
|
#include <SALOME_ListIO.hxx>
|
||||||
|
#include <SalomeApp_SelectionMgr.h>
|
||||||
|
#include <SalomeApp_Application.h>
|
||||||
|
#include <SUIT_MessageBox.h>
|
||||||
|
#include <SUIT_ViewManager.h>
|
||||||
|
#include <SUIT_ViewWindow.h>
|
||||||
|
#include <SUIT_Desktop.h>
|
||||||
|
#include <qapplication.h>
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Constructor
|
||||||
|
*/
|
||||||
|
SMESHGUI_DeleteOp::SMESHGUI_DeleteOp()
|
||||||
|
: SMESHGUI_Operation()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Destructor
|
||||||
|
*/
|
||||||
|
SMESHGUI_DeleteOp::~SMESHGUI_DeleteOp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Verifies whether operation is ready to start
|
||||||
|
* \return TRUE if operation is ready to start, FALSE otherwise
|
||||||
|
*
|
||||||
|
* Virtual method redefined from the base class verifies whether operation is ready to start
|
||||||
|
*/
|
||||||
|
bool SMESHGUI_DeleteOp::isReadyToStart() const
|
||||||
|
{
|
||||||
|
if ( !SMESHGUI_Operation::isReadyToStart() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// VSR 17/11/04: check if all objects selected belong to SMESH component --> start
|
||||||
|
SALOME_ListIO selected;
|
||||||
|
selectionMgr()->selectedObjects( selected );
|
||||||
|
|
||||||
|
QString aParentComponent = QString::null;
|
||||||
|
for ( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
|
||||||
|
{
|
||||||
|
QString cur = anIt.Value()->getComponentDataType();
|
||||||
|
if ( aParentComponent.isNull() )
|
||||||
|
aParentComponent = cur;
|
||||||
|
else if( !aParentComponent.isEmpty() && aParentComponent!=cur )
|
||||||
|
aParentComponent = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( aParentComponent != getSMESHGUI()->name() )
|
||||||
|
{
|
||||||
|
QString aMess = QObject::tr("NON_SMESH_OBJECTS_SELECTED").arg(
|
||||||
|
getSMESHGUI()->moduleName() );
|
||||||
|
SUIT_MessageBox::warn1 ( desktop(), QObject::tr( "ERR_ERROR" ), aMess, tr( "BUT_OK" ) );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// VSR 17/11/04: check if all objects selected belong to SMESH component <-- finish
|
||||||
|
if ( SUIT_MessageBox::warn2 ( desktop(), QObject::tr( "SMESH_WRN_WARNING" ),
|
||||||
|
QObject::tr( "SMESH_REALLY_DELETE" ), tr( "SMESH_BUT_YES"),
|
||||||
|
QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1 )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if ( isStudyLocked() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Deletes selected objects
|
||||||
|
* \return TRUE if operation is ready to start, FALSE otherwise
|
||||||
|
*
|
||||||
|
* Virtual method redefined from the base deletes selected objects
|
||||||
|
*/
|
||||||
|
void SMESHGUI_DeleteOp::startOperation()
|
||||||
|
{
|
||||||
|
QApplication::setOverrideCursor( Qt::waitCursor );
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SUIT_ViewManager* vm =
|
||||||
|
( (SalomeApp_Application*) application() )->activeViewManager();
|
||||||
|
int nbSf = vm->getViewsCount();
|
||||||
|
|
||||||
|
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
|
||||||
|
_PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
|
||||||
|
_PTR(GenericAttribute) anAttr;
|
||||||
|
_PTR(AttributeIOR) anIOR;
|
||||||
|
|
||||||
|
SALOME_ListIO selected;
|
||||||
|
selectionMgr()->selectedObjects( selected );
|
||||||
|
SALOME_ListIteratorOfListIO It( selected );
|
||||||
|
|
||||||
|
aStudyBuilder->NewCommand(); // There is a transaction
|
||||||
|
for ( ; It.More(); It.Next() )
|
||||||
|
{
|
||||||
|
Handle(SALOME_InteractiveObject) IObject = It.Value();
|
||||||
|
if ( IObject->hasEntry())
|
||||||
|
{
|
||||||
|
_PTR(SObject) SO = aStudy->FindObjectID(IObject->getEntry());
|
||||||
|
|
||||||
|
/* Erase child graphical objects */
|
||||||
|
_PTR(ChildIterator) it = aStudy->NewChildIterator(SO);
|
||||||
|
for ( it->InitEx(true); it->More(); it->Next())
|
||||||
|
{
|
||||||
|
_PTR(SObject) CSO = it->Value();
|
||||||
|
if ( CSO->FindAttribute( anAttr, "AttributeIOR" ) )
|
||||||
|
{
|
||||||
|
anIOR = anAttr;
|
||||||
|
QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
|
||||||
|
for ( int i = 0; i < nbSf; i++ )
|
||||||
|
{
|
||||||
|
SUIT_ViewWindow *sf = aViews[ i ];
|
||||||
|
CORBA::String_var anEntry = CSO->GetID().c_str();
|
||||||
|
if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( sf,anEntry.in() ) )
|
||||||
|
SMESH::RemoveActor(sf,anActor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Erase main graphical object */
|
||||||
|
QPtrVector<SUIT_ViewWindow> aViews = vm->getViews();
|
||||||
|
for ( int i = 0; i < nbSf; i++ )
|
||||||
|
{
|
||||||
|
SUIT_ViewWindow *sf = aViews[ i ];
|
||||||
|
if ( SMESH_Actor* anActor = SMESH::FindActorByEntry( sf,IObject->getEntry() ) )
|
||||||
|
SMESH::RemoveActor(sf,anActor);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove object(s) from data structures
|
||||||
|
_PTR(SObject) obj = aStudy->FindObjectID(IObject->getEntry());
|
||||||
|
if ( obj )
|
||||||
|
{
|
||||||
|
SMESH::SMESH_GroupBase_var aGroup =
|
||||||
|
SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( obj ) );
|
||||||
|
SMESH::SMESH_subMesh_var aSubMesh =
|
||||||
|
SMESH::SMESH_subMesh::_narrow( SMESH::SObjectToObject( obj ) );
|
||||||
|
|
||||||
|
if ( !aGroup->_is_nil() ) // DELETE GROUP
|
||||||
|
{
|
||||||
|
SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh();
|
||||||
|
aMesh->RemoveGroup( aGroup );
|
||||||
|
}
|
||||||
|
else if ( !aSubMesh->_is_nil() ) // DELETE SUBMESH
|
||||||
|
{
|
||||||
|
SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
|
||||||
|
aMesh->RemoveSubMesh( aSubMesh );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// default action: remove SObject from the study
|
||||||
|
// san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH
|
||||||
|
//SUIT_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy);
|
||||||
|
//op->start();
|
||||||
|
aStudyBuilder->RemoveObjectWithChildren( obj );
|
||||||
|
//op->finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} /* IObject->hasEntry() */
|
||||||
|
} /* more/next */
|
||||||
|
|
||||||
|
aStudyBuilder->CommitCommand();
|
||||||
|
|
||||||
|
/* Clear any previous selection */
|
||||||
|
SALOME_ListIO l1;
|
||||||
|
selectionMgr()->setSelectedObjects( l1 );
|
||||||
|
|
||||||
|
update( UF_Model | UF_ObjBrowser );
|
||||||
|
}
|
||||||
|
catch ( const SALOME::SALOME_Exception& S_ex )
|
||||||
|
{
|
||||||
|
SalomeApp_Tools::QtCatchCorbaException(S_ex);
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QApplication::restoreOverrideCursor();
|
||||||
|
commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
44
src/SMESHGUI/SMESHGUI_DeleteOp.h
Executable file
44
src/SMESHGUI/SMESHGUI_DeleteOp.h
Executable file
@ -0,0 +1,44 @@
|
|||||||
|
// SALOME SMESHGUI
|
||||||
|
//
|
||||||
|
// Copyright (C) 2005 CEA/DEN, EDF R&D
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// File : SMESHGUI_DeleteOp.h
|
||||||
|
// Author : Sergey LITONIN
|
||||||
|
// Module : SALOME
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef SMESHGUI_DeleteOp_H
|
||||||
|
#define SMESHGUI_DeleteOp_H
|
||||||
|
|
||||||
|
#include "SMESHGUI_Operation.h"
|
||||||
|
|
||||||
|
#include <SALOMEconfig.h>
|
||||||
|
#include CORBA_SERVER_HEADER(SMESH_Group)
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Operation for deleting objects
|
||||||
|
*/
|
||||||
|
|
||||||
|
class SMESHGUI_DeleteOp : public SMESHGUI_Operation
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
SMESHGUI_DeleteOp();
|
||||||
|
virtual ~SMESHGUI_DeleteOp();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
virtual bool isReadyToStart() const;
|
||||||
|
virtual void startOperation();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -2813,3 +2813,4 @@ msgstr "Hypothesises"
|
|||||||
|
|
||||||
msgid "SMESHGUI_Dialog::DLG_ALGO"
|
msgid "SMESHGUI_Dialog::DLG_ALGO"
|
||||||
msgstr "Algorithms"
|
msgstr "Algorithms"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user