mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-11-11 16:19:17 +05:00
Rename and Delete functionalities added.
This commit is contained in:
parent
d323a0aa04
commit
1bf3bfc5d8
@ -40,17 +40,14 @@
|
|||||||
#include <SUIT_Tools.h>
|
#include <SUIT_Tools.h>
|
||||||
#include <SUIT_FileDlg.h>
|
#include <SUIT_FileDlg.h>
|
||||||
#include <SUIT_Desktop.h>
|
#include <SUIT_Desktop.h>
|
||||||
|
#include <SUIT_ViewModel.h>
|
||||||
|
|
||||||
#include <SalomeApp_Application.h>
|
#include <SalomeApp_Application.h>
|
||||||
#include <SalomeApp_Study.h>
|
#include <SalomeApp_Study.h>
|
||||||
|
#include <SalomeApp_SelectionMgr.h>
|
||||||
|
|
||||||
//#include "OCCViewer_Viewer3d.h"
|
#include <SALOME_ListIteratorOfListIO.hxx>
|
||||||
//#include "VTKViewer_ViewWindow.h"
|
#include <SALOME_Prs.h>
|
||||||
//#include "VTKViewer_RenderWindowInteractor.h"
|
|
||||||
|
|
||||||
#include "SALOME_ListIteratorOfListIO.hxx"
|
|
||||||
//#include "SALOMEGUI_ImportOperation.h"
|
|
||||||
//#include "SALOMEGUI_QtCatchCorbaException.hxx"
|
|
||||||
|
|
||||||
#include <qapplication.h>
|
#include <qapplication.h>
|
||||||
#include <qmap.h>
|
#include <qmap.h>
|
||||||
@ -61,9 +58,7 @@ using namespace std;
|
|||||||
|
|
||||||
typedef QMap<QString, QString> FilterMap;
|
typedef QMap<QString, QString> FilterMap;
|
||||||
|
|
||||||
#include "SALOMEDSClient.hxx"
|
#include <SALOMEDS_SObject.hxx>
|
||||||
#include "SALOMEDS_SObject.hxx"
|
|
||||||
#include "SALOMEDS_Study.hxx"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -229,138 +224,140 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//===============================================================================
|
//===============================================================================
|
||||||
// function : OnEditDelete()
|
// function : OnEditDelete()
|
||||||
// purpose :
|
// purpose :
|
||||||
//===============================================================================
|
//===============================================================================
|
||||||
void GEOMToolsGUI::OnEditDelete()
|
void GEOMToolsGUI::OnEditDelete()
|
||||||
{
|
{
|
||||||
/*
|
SALOME_ListIO selected;
|
||||||
SALOME_Selection* Sel = SALOME_Selection::Selection(
|
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
||||||
QAD_Application::getDesktop()->getActiveStudy()->getSelection() );
|
if ( app ) {
|
||||||
|
SalomeApp_SelectionMgr* aSelMgr = app->selectionMgr();
|
||||||
|
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
|
||||||
|
if ( aSelMgr && appStudy ) {
|
||||||
|
aSelMgr->selectedObjects( selected );
|
||||||
|
if ( !selected.IsEmpty() ) {
|
||||||
|
_PTR(Study) aStudy = appStudy->studyDS();
|
||||||
|
|
||||||
if ( Sel->IObjectCount() == 0 )
|
bool aLocked = (_PTR(AttributeStudyProperties)(aStudy->GetProperties()))->IsLocked();
|
||||||
return;
|
if ( aLocked ) {
|
||||||
|
SUIT_MessageBox::warn1 ( app->desktop(),
|
||||||
|
QObject::tr("WRN_WARNING"),
|
||||||
|
QObject::tr("WRN_STUDY_LOCKED"),
|
||||||
|
QObject::tr("BUT_OK") );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_PTR(Study) aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
|
// VSR 17/11/04: check if all objects selected belong to GEOM component --> start
|
||||||
|
// modifications of ASV 01.06.05
|
||||||
|
QString parentComp = getParentComponent( aStudy, selected );
|
||||||
|
const char* geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
|
||||||
|
QString geomComp = getParentComponent( aStudy->FindObjectIOR( geomIOR ) );
|
||||||
|
|
||||||
bool aLocked = (_PTR(AttributeStudyProperties)(aStudy->GetProperties()))->IsLocked();
|
if ( parentComp != geomComp ) {
|
||||||
if ( aLocked ) {
|
SUIT_MessageBox::warn1 ( app->desktop(),
|
||||||
QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
|
QObject::tr("ERR_ERROR"),
|
||||||
QObject::tr("WRN_WARNING"),
|
QObject::tr("NON_GEOM_OBJECTS_SELECTED").arg( getGeometryGUI()->moduleName() ),
|
||||||
QObject::tr("WRN_STUDY_LOCKED"),
|
QObject::tr("BUT_OK") );
|
||||||
QObject::tr("BUT_OK") );
|
return;
|
||||||
return;
|
}
|
||||||
}
|
// VSR 17/11/04: check if all objects selected belong to GEOM component <-- finish
|
||||||
|
|
||||||
// VSR 17/11/04: check if all objects selected belong to GEOM component --> start
|
if ( SUIT_MessageBox::warn2( app->desktop(),
|
||||||
QString aParentComponent = ((SALOMEGUI_Desktop*)QAD_Application::getDesktop())->getComponentFromSelection();
|
QObject::tr( "GEOM_WRN_WARNING" ),
|
||||||
if ( aParentComponent != QAD_Application::getDesktop()->getActiveComponent() ) {
|
QObject::tr( "GEOM_REALLY_DELETE" ),
|
||||||
QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
|
QObject::tr( "GEOM_BUT_YES" ),
|
||||||
QObject::tr("ERR_ERROR"),
|
QObject::tr( "GEOM_BUG_NO" ), 1, 0, 0 ) != 1 )
|
||||||
QObject::tr("NON_GEOM_OBJECTS_SELECTED").arg(QAD_Application::getDesktop()->getComponentUserName( "GEOM" )),
|
return;
|
||||||
QObject::tr("BUT_OK") );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// VSR 17/11/04: check if all objects selected belong to GEOM component <-- finish
|
|
||||||
|
|
||||||
if ( QAD_MessageBox::warn2( QAD_Application::getDesktop(),
|
// QAD_Operation* op = new SALOMEGUI_ImportOperation(.....);
|
||||||
tr( "GEOM_WRN_WARNING" ),
|
// op->start();
|
||||||
tr( "GEOM_REALLY_DELETE" ),
|
|
||||||
tr( "GEOM_BUT_YES" ),
|
|
||||||
tr( "GEOM_BUT_NO" ), 1, 0, 0 ) != 1 )
|
|
||||||
return;
|
|
||||||
|
|
||||||
int nbSf = QAD_Application::getDesktop()->getActiveStudy()->getStudyFramesCount();
|
// prepare list of SALOME_Views
|
||||||
|
QPtrList<SALOME_View> views;
|
||||||
|
SALOME_View* view;
|
||||||
|
// fill the list
|
||||||
|
ViewManagerList vmans = app->viewManagers();
|
||||||
|
SUIT_ViewManager* vman;
|
||||||
|
for ( vman = vmans.first(); vman; vman = vmans.next() ) {
|
||||||
|
SUIT_ViewModel* vmod = vman->getViewModel();
|
||||||
|
view = dynamic_cast<SALOME_View*> ( vmod ); // must work for OCC and VTK views
|
||||||
|
if ( view )
|
||||||
|
views.append( view );
|
||||||
|
}
|
||||||
|
|
||||||
Standard_Boolean found;
|
_PTR(StudyBuilder) aStudyBuilder (aStudy->NewBuilder());
|
||||||
_PTR(GenericAttribute) anAttr;
|
_PTR(GenericAttribute) anAttr;
|
||||||
|
GEOM_Displayer* disp = new GEOM_Displayer( appStudy );
|
||||||
|
|
||||||
SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
|
// MAIN LOOP OF SELECTED OBJECTS
|
||||||
|
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
|
||||||
|
|
||||||
QAD_Operation* op = new SALOMEGUI_ImportOperation( QAD_Application::getDesktop()->getActiveStudy() );
|
Handle(SALOME_InteractiveObject) io = It.Value();
|
||||||
|
if ( !io->hasEntry() )
|
||||||
|
continue;
|
||||||
|
|
||||||
op->start();
|
_PTR(SObject) obj ( aStudy->FindObjectID( io->getEntry() ) );
|
||||||
|
|
||||||
Standard_Boolean deleted = false;
|
// disable removal of "Geometry" component object
|
||||||
|
if ( !strcmp( obj->GetIOR().c_str(), geomIOR ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
for ( ;It.More();It.Next() )
|
// iterate through all childres of obj, find IOR attributes on children and remove shapes that
|
||||||
{
|
// correspond to these IORs
|
||||||
Handle( SALOME_InteractiveObject ) IObject = It.Value();
|
for ( _PTR(ChildIterator) it ( aStudy->NewChildIterator( obj ) ); it->More();it->Next() ) {
|
||||||
|
_PTR(SObject) child ( it->Value() );
|
||||||
|
if ( child->FindAttribute( anAttr, "AttributeIOR" ) ) {
|
||||||
|
_PTR(AttributeIOR) anIOR( anAttr );
|
||||||
|
|
||||||
if ( !IObject->hasEntry() )
|
// Delete child( s ) shape in Client :
|
||||||
continue;
|
const TCollection_AsciiString ASCior( (char*)anIOR->Value().c_str() ) ;
|
||||||
|
getGeometryGUI()->GetShapeReader().RemoveShapeFromBuffer( ASCior );
|
||||||
|
|
||||||
_PTR(SObject) SO ( aStudy->FindObjectID( IObject->getEntry() ) );
|
for ( view = views.first(); view; view = views.next() ) {
|
||||||
_PTR(AttributeIOR) anIOR;
|
CORBA::Object_var corbaObj = (dynamic_cast<SALOMEDS_SObject*>(child.get()))->GetObject();
|
||||||
|
GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
|
||||||
|
if ( !CORBA::is_nil( geomObj ) )
|
||||||
|
disp->Erase( geomObj, true, view );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // for ( childres of obj )
|
||||||
|
|
||||||
// Erase child graphical objects
|
// Erase main graphical object
|
||||||
|
for ( view = views.first(); view; view = views.next() )
|
||||||
|
disp->Erase( io, true, view );
|
||||||
|
|
||||||
_PTR(ChildIterator) it ( aStudy->NewChildIterator( SO ) );
|
// Delete main shape in Client :
|
||||||
for ( ; it->More();it->Next() )
|
if ( obj->FindAttribute( anAttr, "AttributeIOR" ) ) {
|
||||||
{
|
_PTR(AttributeIOR) anIOR( anAttr );
|
||||||
_PTR(SObject) CSO ( it->Value() );
|
const TCollection_AsciiString ASCIor( (char*)anIOR->Value().c_str() ) ;
|
||||||
|
getGeometryGUI()->GetShapeReader().RemoveShapeFromBuffer( ASCIor );
|
||||||
|
}
|
||||||
|
|
||||||
if ( CSO->FindAttribute( anAttr, "AttributeIOR" ) )
|
// Remove objects from Study
|
||||||
{
|
aStudyBuilder->RemoveObject( obj );
|
||||||
anIOR = anAttr;
|
|
||||||
|
|
||||||
// Delete child( s ) shape in Client :
|
CORBA::Object_var corbaObj = (dynamic_cast<SALOMEDS_SObject*>(obj.get()))->GetObject();
|
||||||
|
GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
|
||||||
|
if ( !CORBA::is_nil( geomObj ) )
|
||||||
|
GeometryGUI::GetGeomGen()->RemoveObject( geomObj );
|
||||||
|
|
||||||
const TCollection_AsciiString ASCior( (char*)anIOR->Value().c_str() ) ;
|
//deleted = true;
|
||||||
GeometryGUI::GetGeomGUI()->GetShapeReader().RemoveShapeFromBuffer( ASCior );
|
} // MAIN LOOP of selected
|
||||||
|
|
||||||
for ( int i = 0; i < nbSf; i++ )
|
selected.Clear();
|
||||||
{
|
aSelMgr->setSelectedObjects( selected );
|
||||||
GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow( dynamic_cast<SALOMEDS_SObject*>(CSO.get())->GetObject() );
|
getGeometryGUI()->updateObjBrowser();
|
||||||
if ( !aGeomObj->_is_nil() )
|
} // if ( selected not empty )
|
||||||
GEOM_Displayer().Erase( aGeomObj, true );
|
} // if ( selMgr && appStudy )
|
||||||
}
|
} // if ( app )
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Erase main graphical object
|
// if ( deleted )
|
||||||
|
// op->finish();
|
||||||
for ( int i = 0; i < nbSf; i++ )
|
// else
|
||||||
{
|
// op->abort();
|
||||||
QAD_StudyFrame* sf = QAD_Application::getDesktop()->getActiveStudy()->getStudyFrame( i );
|
|
||||||
GEOM_Displayer().Erase( IObject, true );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete main shape in Client :
|
|
||||||
|
|
||||||
if ( SO->FindAttribute( anAttr, "AttributeIOR" ) )
|
|
||||||
{
|
|
||||||
anIOR = anAttr;
|
|
||||||
const TCollection_AsciiString ASCIor( (char*)anIOR->Value().c_str() ) ;
|
|
||||||
GeometryGUI::GetGeomGUI()->GetShapeReader().RemoveShapeFromBuffer( ASCIor );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Erase objects in Study
|
|
||||||
|
|
||||||
_PTR(SObject) obj ( aStudy->FindObjectID( IObject->getEntry() ) );
|
|
||||||
if ( obj )
|
|
||||||
{
|
|
||||||
_PTR(StudyBuilder) aStudyBuilder (aStudy->NewBuilder());
|
|
||||||
aStudyBuilder->RemoveObject( obj );
|
|
||||||
|
|
||||||
GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(dynamic_cast<SALOMEDS_SObject*>(obj.get())->GetObject());
|
|
||||||
if ( !aGeomObj->_is_nil() )
|
|
||||||
GeometryGUI::GetGeomGUI()->GetGeomGen()->RemoveObject( aGeomObj );
|
|
||||||
|
|
||||||
deleted = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( deleted )
|
|
||||||
op->finish();
|
|
||||||
else
|
|
||||||
op->abort();
|
|
||||||
|
|
||||||
// Clear any previous selection
|
|
||||||
Sel->ClearIObjects();
|
|
||||||
QAD_Application::getDesktop()->getActiveStudy()->updateObjBrowser();
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -558,6 +555,43 @@ bool GEOMToolsGUI::Export()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString GEOMToolsGUI::getParentComponent( _PTR( Study ) study, const SALOME_ListIO& iobjs )
|
||||||
|
{
|
||||||
|
QString parentComp;
|
||||||
|
|
||||||
|
for ( SALOME_ListIteratorOfListIO it( iobjs ); it.More(); it.Next() ) {
|
||||||
|
|
||||||
|
Handle(SALOME_InteractiveObject) io = it.Value();
|
||||||
|
if ( !io->hasEntry() )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
QString compName = getParentComponent( study->FindObjectID( io->getEntry() ) );
|
||||||
|
|
||||||
|
if ( parentComp.isNull() )
|
||||||
|
parentComp = compName;
|
||||||
|
else if ( parentComp.compare( compName) != 0 ) { // objects belonging to different components are selected
|
||||||
|
parentComp = QString::null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return parentComp;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString GEOMToolsGUI::getParentComponent( _PTR( SObject ) obj )
|
||||||
|
{
|
||||||
|
if ( obj ) {
|
||||||
|
_PTR(SComponent) comp = obj->GetFatherComponent();
|
||||||
|
if ( comp ) {
|
||||||
|
_PTR(GenericAttribute) anAttr;
|
||||||
|
if ( comp->FindAttribute( anAttr, "AttributeName") ) {
|
||||||
|
_PTR(AttributeName) aName( anAttr );
|
||||||
|
return QString( aName->Value().c_str() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
//=====================================================================================
|
//=====================================================================================
|
||||||
// EXPORTED METHODS
|
// EXPORTED METHODS
|
||||||
|
@ -31,6 +31,11 @@
|
|||||||
|
|
||||||
#include "GEOMGUI.h"
|
#include "GEOMGUI.h"
|
||||||
|
|
||||||
|
#include <SALOMEDSClient.hxx>
|
||||||
|
#include <SALOMEDS_Study.hxx>
|
||||||
|
#include <SALOME_ListIO.hxx>
|
||||||
|
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// class : GEOMToolsGUI
|
// class : GEOMToolsGUI
|
||||||
// purpose :
|
// purpose :
|
||||||
@ -44,7 +49,7 @@ public :
|
|||||||
bool OnGUIEvent( int theCommandID, SUIT_Desktop* parent );
|
bool OnGUIEvent( int theCommandID, SUIT_Desktop* parent );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* Import and export topology methods */
|
// Import and export topology methods
|
||||||
bool Import();
|
bool Import();
|
||||||
bool Export();
|
bool Export();
|
||||||
|
|
||||||
@ -63,6 +68,11 @@ private:
|
|||||||
void OnTransparency();
|
void OnTransparency();
|
||||||
void OnNbIsos();
|
void OnNbIsos();
|
||||||
void OnOpen();
|
void OnOpen();
|
||||||
|
|
||||||
|
// returns name of Module (Component) of given objects (usually selected objects)
|
||||||
|
// if objects belong to different Components, a NULL string is returned.
|
||||||
|
QString getParentComponent( _PTR( Study ), const SALOME_ListIO& );
|
||||||
|
QString getParentComponent( _PTR(SObject) );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include "GEOMBase.h"
|
#include "GEOMBase.h"
|
||||||
#include "GEOMToolsGUI_TransparencyDlg.h"
|
#include "GEOMToolsGUI_TransparencyDlg.h"
|
||||||
#include "GEOMToolsGUI_NbIsosDlg.h" // Method ISOS adjustement
|
#include "GEOMToolsGUI_NbIsosDlg.h" // Method ISOS adjustement
|
||||||
|
#include "GEOMToolsGUI_NameDlg.h"
|
||||||
|
|
||||||
#include <SALOME_ListIO.hxx>
|
#include <SALOME_ListIO.hxx>
|
||||||
#include <SALOME_ListIteratorOfListIO.hxx>
|
#include <SALOME_ListIteratorOfListIO.hxx>
|
||||||
@ -49,9 +50,12 @@
|
|||||||
#include <SUIT_ResourceMgr.h>
|
#include <SUIT_ResourceMgr.h>
|
||||||
#include <SUIT_Session.h>
|
#include <SUIT_Session.h>
|
||||||
#include <SUIT_OverrideCursor.h>
|
#include <SUIT_OverrideCursor.h>
|
||||||
|
#include <SUIT_MessageBox.h>
|
||||||
|
|
||||||
#include <SalomeApp_Application.h>
|
#include <SalomeApp_Application.h>
|
||||||
#include <SalomeApp_SelectionMgr.h>
|
#include <SalomeApp_SelectionMgr.h>
|
||||||
|
#include <SalomeApp_Study.h>
|
||||||
|
#include <SalomeApp_Module.h>
|
||||||
|
|
||||||
#include <AIS_Drawer.hxx>
|
#include <AIS_Drawer.hxx>
|
||||||
#include <AIS_ListOfInteractive.hxx>
|
#include <AIS_ListOfInteractive.hxx>
|
||||||
@ -158,40 +162,46 @@ void GEOMToolsGUI::OnSettingsStep()
|
|||||||
|
|
||||||
void GEOMToolsGUI::OnRename()
|
void GEOMToolsGUI::OnRename()
|
||||||
{
|
{
|
||||||
/*
|
SALOME_ListIO selected;
|
||||||
SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
|
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
||||||
_PTR(Study) aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
|
if ( app ) {
|
||||||
|
SalomeApp_SelectionMgr* aSelMgr = app->selectionMgr();
|
||||||
|
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
|
||||||
|
if ( aSelMgr && appStudy ) {
|
||||||
|
aSelMgr->selectedObjects( selected );
|
||||||
|
if ( !selected.IsEmpty() ) {
|
||||||
|
_PTR(Study) aStudy = appStudy->studyDS();
|
||||||
|
|
||||||
bool aLocked = (_PTR(AttributeStudyProperties)(aStudy->GetProperties()))->IsLocked();
|
bool aLocked = (_PTR(AttributeStudyProperties)(aStudy->GetProperties()))->IsLocked();
|
||||||
if ( aLocked ) {
|
if ( aLocked ) {
|
||||||
QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
|
SUIT_MessageBox::warn1 ( app->desktop(),
|
||||||
QObject::tr("WRN_WARNING"),
|
QObject::tr("WRN_WARNING"),
|
||||||
QObject::tr("WRN_STUDY_LOCKED"),
|
QObject::tr("WRN_STUDY_LOCKED"),
|
||||||
QObject::tr("BUT_OK") );
|
QObject::tr("BUT_OK") );
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
|
|
||||||
for(; It.More(); It.Next()) {
|
|
||||||
Handle(SALOME_InteractiveObject) IObject = It.Value();
|
|
||||||
|
|
||||||
_PTR(SObject) obj ( aStudy->FindObjectID(IObject->getEntry()) );
|
|
||||||
_PTR(GenericAttribute) anAttr;
|
|
||||||
if(obj) {
|
|
||||||
if(obj->FindAttribute(anAttr, "AttributeName")) {
|
|
||||||
_PTR(AttributeName) aName (anAttr);
|
|
||||||
|
|
||||||
QString nm = QString(aName->Value().c_str());
|
|
||||||
nm = SALOMEGUI_NameDlg::getName(QAD_Application::getDesktop(), nm);
|
|
||||||
if(!nm.isEmpty()) {
|
|
||||||
QApplication::setOverrideCursor(Qt::waitCursor);
|
|
||||||
QAD_Application::getDesktop()->getActiveStudy()->renameIObject(IObject, nm);
|
|
||||||
QApplication::restoreOverrideCursor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
|
||||||
|
Handle(SALOME_InteractiveObject) IObject = It.Value();
|
||||||
|
|
||||||
|
_PTR(SObject) obj ( aStudy->FindObjectID(IObject->getEntry()) );
|
||||||
|
_PTR(GenericAttribute) anAttr;
|
||||||
|
if ( obj ) {
|
||||||
|
if( obj->FindAttribute(anAttr, "AttributeName") ) {
|
||||||
|
_PTR(AttributeName) aName (anAttr);
|
||||||
|
|
||||||
|
QString newName = GEOMToolsGUI_NameDlg::getName( app->desktop(), aName->Value().c_str() );
|
||||||
|
if ( !newName.isEmpty() ) {
|
||||||
|
aName->SetValue( newName.latin1() ); // rename the SObject
|
||||||
|
IObject->setName( newName.latin1() );// rename the InteractiveObject
|
||||||
|
(dynamic_cast<SalomeApp_Module*>(app->activeModule()))->updateObjBrowser( false );
|
||||||
|
}
|
||||||
|
} // if ( name attribute )
|
||||||
|
} // if ( obj )
|
||||||
|
} // iterator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GEOMToolsGUI::OnCheckGeometry()
|
void GEOMToolsGUI::OnCheckGeometry()
|
||||||
|
134
src/GEOMToolsGUI/GEOMToolsGUI_NameDlg.cxx
Normal file
134
src/GEOMToolsGUI/GEOMToolsGUI_NameDlg.cxx
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
// SALOME GEOMToolsGUI : implementation of desktop and GUI kernel
|
||||||
|
//
|
||||||
|
// Copyright (C) 2003 CEA/DEN, EDF R&D
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// File : GEOMToolsGUI_NameDlg.cxx
|
||||||
|
// Author : Vadim SANDLER
|
||||||
|
// Module : SALOME
|
||||||
|
// $Header$
|
||||||
|
|
||||||
|
#include "GEOMToolsGUI_NameDlg.h"
|
||||||
|
|
||||||
|
#include <SUIT_Session.h>
|
||||||
|
#include <SUIT_Application.h>
|
||||||
|
#include <SUIT_Desktop.h>
|
||||||
|
#include <SUIT_Tools.h>
|
||||||
|
|
||||||
|
#include <qgroupbox.h>
|
||||||
|
#include <qlabel.h>
|
||||||
|
#include <qlineedit.h>
|
||||||
|
#include <qpushbutton.h>
|
||||||
|
#include <qlayout.h>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Constructor
|
||||||
|
*/
|
||||||
|
GEOMToolsGUI_NameDlg::GEOMToolsGUI_NameDlg( QWidget* parent )
|
||||||
|
: QDialog( parent ? parent : SUIT_Session::session()->activeApplication()->desktop(),
|
||||||
|
"GEOMToolsGUI_NameDlg",
|
||||||
|
true,
|
||||||
|
WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
|
||||||
|
{
|
||||||
|
setCaption( tr("TLT_RENAME") );
|
||||||
|
setSizeGripEnabled( TRUE );
|
||||||
|
|
||||||
|
QVBoxLayout* topLayout = new QVBoxLayout( this );
|
||||||
|
topLayout->setMargin( 11 ); topLayout->setSpacing( 6 );
|
||||||
|
|
||||||
|
/***************************************************************/
|
||||||
|
QGroupBox* GroupC1 = new QGroupBox( this, "GroupC1" );
|
||||||
|
GroupC1->setColumnLayout(0, Qt::Vertical );
|
||||||
|
GroupC1->layout()->setMargin( 0 ); GroupC1->layout()->setSpacing( 0 );
|
||||||
|
QHBoxLayout* GroupC1Layout = new QHBoxLayout( GroupC1->layout() );
|
||||||
|
GroupC1Layout->setAlignment( Qt::AlignTop );
|
||||||
|
GroupC1Layout->setMargin( 11 ); GroupC1Layout->setSpacing( 6 );
|
||||||
|
|
||||||
|
QLabel* TextLabel = new QLabel( GroupC1, "TextLabel1" );
|
||||||
|
TextLabel->setText( tr( "NAME_LBL" ) );
|
||||||
|
GroupC1Layout->addWidget( TextLabel );
|
||||||
|
|
||||||
|
myLineEdit = new QLineEdit( GroupC1, "LineEdit1" );
|
||||||
|
myLineEdit->setMinimumSize( 250, 0 );
|
||||||
|
GroupC1Layout->addWidget( myLineEdit );
|
||||||
|
|
||||||
|
/***************************************************************/
|
||||||
|
QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
|
||||||
|
GroupButtons->setColumnLayout(0, Qt::Vertical );
|
||||||
|
GroupButtons->layout()->setMargin( 0 ); GroupButtons->layout()->setSpacing( 0 );
|
||||||
|
QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons->layout() );
|
||||||
|
GroupButtonsLayout->setAlignment( Qt::AlignTop );
|
||||||
|
GroupButtonsLayout->setMargin( 11 ); GroupButtonsLayout->setSpacing( 6 );
|
||||||
|
|
||||||
|
myButtonOk = new QPushButton( GroupButtons, "buttonOk" );
|
||||||
|
myButtonOk->setText( tr( "BUT_OK" ) );
|
||||||
|
myButtonOk->setAutoDefault( TRUE ); myButtonOk->setDefault( TRUE );
|
||||||
|
GroupButtonsLayout->addWidget( myButtonOk );
|
||||||
|
|
||||||
|
GroupButtonsLayout->addStretch();
|
||||||
|
|
||||||
|
myButtonCancel = new QPushButton( GroupButtons, "buttonCancel" );
|
||||||
|
myButtonCancel->setText( tr( "BUT_CANCEL" ) );
|
||||||
|
myButtonCancel->setAutoDefault( TRUE );
|
||||||
|
GroupButtonsLayout->addWidget( myButtonCancel );
|
||||||
|
/***************************************************************/
|
||||||
|
|
||||||
|
topLayout->addWidget( GroupC1 );
|
||||||
|
topLayout->addWidget( GroupButtons );
|
||||||
|
|
||||||
|
// signals and slots connections
|
||||||
|
connect( myButtonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
|
||||||
|
connect( myButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
|
||||||
|
|
||||||
|
/* Move widget on the botton right corner of main widget */
|
||||||
|
SUIT_Tools::centerWidget( this, parent );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Destructor
|
||||||
|
*/
|
||||||
|
GEOMToolsGUI_NameDlg::~GEOMToolsGUI_NameDlg()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Sets name
|
||||||
|
*/
|
||||||
|
void GEOMToolsGUI_NameDlg::setName( const QString& name )
|
||||||
|
{
|
||||||
|
myLineEdit->setText( name );
|
||||||
|
myLineEdit->end(false);
|
||||||
|
myLineEdit->home(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns name entered by user
|
||||||
|
*/
|
||||||
|
QString GEOMToolsGUI_NameDlg::name()
|
||||||
|
{
|
||||||
|
return myLineEdit->text();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GEOMToolsGUI_NameDlg::accept()
|
||||||
|
{
|
||||||
|
if ( name().stripWhiteSpace().isEmpty() )
|
||||||
|
return;
|
||||||
|
QDialog::accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Creates modal <Rename> dialog and returns name entered [ static ]
|
||||||
|
*/
|
||||||
|
QString GEOMToolsGUI_NameDlg::getName( QWidget* parent, const QString& oldName )
|
||||||
|
{
|
||||||
|
QString n;
|
||||||
|
GEOMToolsGUI_NameDlg* dlg = new GEOMToolsGUI_NameDlg( parent );
|
||||||
|
if ( !oldName.isNull() )
|
||||||
|
dlg->setName( oldName );
|
||||||
|
if ( dlg->exec() == QDialog::Accepted )
|
||||||
|
n = dlg->name();
|
||||||
|
delete dlg;
|
||||||
|
return n;
|
||||||
|
}
|
46
src/GEOMToolsGUI/GEOMToolsGUI_NameDlg.h
Normal file
46
src/GEOMToolsGUI/GEOMToolsGUI_NameDlg.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
// SALOME GEOMToolsGUI : implementation of desktop and GUI kernel
|
||||||
|
//
|
||||||
|
// Copyright (C) 2003 CEA/DEN, EDF R&D
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// File : GEOMToolsGUI_NameDlg.h
|
||||||
|
// Author : Vadim SANDLER
|
||||||
|
// Module : SALOME
|
||||||
|
// $Header$
|
||||||
|
|
||||||
|
#ifndef GEOMToolsGUI_NAMEDLG_H
|
||||||
|
#define GEOMToolsGUI_NAMEDLG_H
|
||||||
|
|
||||||
|
#include <qdialog.h>
|
||||||
|
|
||||||
|
class QLineEdit;
|
||||||
|
class QPushButton;
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// class : GEOMToolsGUI_NameDlg
|
||||||
|
// purpose : Common <Rename> dialog box class
|
||||||
|
//=================================================================================
|
||||||
|
class GEOMToolsGUI_NameDlg : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
GEOMToolsGUI_NameDlg( QWidget* parent = 0 );
|
||||||
|
~GEOMToolsGUI_NameDlg();
|
||||||
|
|
||||||
|
void setName( const QString& name );
|
||||||
|
QString name();
|
||||||
|
|
||||||
|
static QString getName( QWidget* parent = 0, const QString& oldName = QString::null );
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void accept();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPushButton* myButtonOk;
|
||||||
|
QPushButton* myButtonCancel;
|
||||||
|
QLineEdit* myLineEdit;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GEOMToolsGUI_NAMEDLG_H
|
@ -43,11 +43,12 @@ EXPORT_HEADERS=
|
|||||||
LIB_SRC = GEOMToolsGUI.cxx \
|
LIB_SRC = GEOMToolsGUI.cxx \
|
||||||
GEOMToolsGUI_1.cxx \
|
GEOMToolsGUI_1.cxx \
|
||||||
GEOMToolsGUI_TransparencyDlg.cxx \
|
GEOMToolsGUI_TransparencyDlg.cxx \
|
||||||
GEOMToolsGUI_NbIsosDlg.cxx
|
GEOMToolsGUI_NbIsosDlg.cxx \
|
||||||
|
GEOMToolsGUI_NameDlg.cxx
|
||||||
|
|
||||||
LIB_MOC = GEOMToolsGUI.h \
|
LIB_MOC = GEOMToolsGUI_TransparencyDlg.h \
|
||||||
GEOMToolsGUI_TransparencyDlg.h \
|
GEOMToolsGUI_NbIsosDlg.h \
|
||||||
GEOMToolsGUI_NbIsosDlg.h
|
GEOMToolsGUI_NameDlg.h
|
||||||
|
|
||||||
LIB_CLIENT_IDL = SALOMEDS_Attributes.idl \
|
LIB_CLIENT_IDL = SALOMEDS_Attributes.idl \
|
||||||
SALOME_GenericObj.idl \
|
SALOME_GenericObj.idl \
|
||||||
|
Loading…
Reference in New Issue
Block a user