From 1ca056a9d9f9caefc174c88c2280537715652f97 Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 15 Sep 2005 13:43:53 +0000 Subject: [PATCH] *** empty log message *** --- src/LightApp/LightApp_Application.cxx | 56 +- src/LightApp/LightApp_Application.h | 2 + src/LightApp/LightApp_DataModel.h | 3 +- src/LightApp/LightApp_Dialog.cxx | 860 ++++++++++++++++++++++ src/LightApp/LightApp_Dialog.h | 266 +++++++ src/LightApp/LightApp_Module.cxx | 150 +++- src/LightApp/LightApp_Module.h | 30 +- src/LightApp/LightApp_Operation.cxx | 290 ++++++++ src/LightApp/LightApp_Operation.h | 90 +++ src/LightApp/LightApp_Study.h | 4 +- src/LightApp/LightApp_SwitchOp.cxx | 164 +++++ src/LightApp/LightApp_SwitchOp.h | 71 ++ src/LightApp/LightApp_UpdateFlags.h | 37 + src/LightApp/Makefile.in | 11 + src/LightApp/resources/LightApp_images.po | 3 + src/LightApp/resources/icon_select.png | Bin 0 -> 976 bytes src/Makefile.in | 2 +- src/OBJECT/Makefile.in | 2 +- src/Plot2d/Makefile.in | 4 +- src/Plot2d/Plot2d_ViewFrame.cxx | 10 - src/Prs/Makefile.in | 2 +- src/PyInterp/Makefile.in | 2 +- src/PyInterp/PyInterp_base.cxx | 44 +- src/PyInterp/PyInterp_base.h | 5 +- src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx | 10 +- src/SALOME_PYQT/SalomePyQt/SalomePyQt.h | 4 +- src/SALOME_SWIG/SALOMEGUI_Swig.cxx | 24 +- src/SOCC/Makefile.in | 11 +- src/SOCC/SOCC_ViewModel.cxx | 141 ++-- src/SUIT/SUIT_DataObject.cxx | 3 + src/SUIT/SUIT_Study.cxx | 4 + 31 files changed, 2138 insertions(+), 167 deletions(-) create mode 100644 src/LightApp/LightApp_Dialog.cxx create mode 100644 src/LightApp/LightApp_Dialog.h create mode 100755 src/LightApp/LightApp_Operation.cxx create mode 100755 src/LightApp/LightApp_Operation.h create mode 100755 src/LightApp/LightApp_SwitchOp.cxx create mode 100755 src/LightApp/LightApp_SwitchOp.h create mode 100755 src/LightApp/LightApp_UpdateFlags.h create mode 100644 src/LightApp/resources/icon_select.png diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 317f8d1c3..153abd3e9 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -120,11 +120,6 @@ myPrefs( 0 ) desktop()->setDockableMenuBar( true ); desktop()->setDockableStatusBar( false ); - // base logo (salome itself) - desktop()->addLogo( "_app_base", aResMgr->loadPixmap( "SalomeApp", tr( "APP_BASE_LOGO" ), false ) ); - // extra logo (salome-based application) - desktop()->addLogo( "_app_extra", aResMgr->loadPixmap( "SalomeApp", tr( "APP_EXTRA_LOGO" ), false ) ); - clearViewManagers(); mySelMgr = new LightApp_SelectionMgr( this ); @@ -209,37 +204,30 @@ QString LightApp_Application::applicationVersion() const if ( _app_version.isEmpty() ) { - QString resVersion = tr( "APP_VERSION" ); - if ( resVersion != "APP_VERSION" ) - { - _app_version = resVersion; - } - else + QString path( ::getenv( "GUI_ROOT_DIR" ) ); + if ( !path.isEmpty() ) + path += QDir::separator(); + path += QString( "bin/salome/VERSION" ); + + QFile vf( path ); + if ( vf.open( IO_ReadOnly ) ) { - QString path( ::getenv( "GUI_ROOT_DIR" ) ); - if ( !path.isEmpty() ) - path += QDir::separator(); - path += QString( "bin/salome/VERSION" ); + QString line; + vf.readLine( line, 1024 ); + vf.close(); - QFile vf( path ); - if ( vf.open( IO_ReadOnly ) ) + if ( !line.isEmpty() ) { - QString line; - vf.readLine( line, 1024 ); - vf.close(); - - if ( !line.isEmpty() ) - { - while ( !line.isEmpty() && line.at( line.length() - 1 ) == QChar( '\n' ) ) - line.remove( line.length() - 1, 1 ); - - int idx = line.findRev( ":" ); - if ( idx != -1 ) - _app_version = line.mid( idx + 1 ).stripWhiteSpace(); - } + while ( !line.isEmpty() && line.at( line.length() - 1 ) == QChar( '\n' ) ) + line.remove( line.length() - 1, 1 ); + + int idx = line.findRev( ":" ); + if ( idx != -1 ) + _app_version = line.mid( idx + 1 ).stripWhiteSpace(); } } } + return _app_version; } @@ -948,6 +936,14 @@ void LightApp_Application::onDesktopActivated() aModule->studyActivated(); } +/*!Gets file filter. + *\retval QString "(*.hdf)" + */ +QString LightApp_Application::getFileFilter() const +{ + return "(*.hdf)"; +} + /*!*/ QString LightApp_Application::getFileName( bool open, const QString& initial, const QString& filters, const QString& caption, QWidget* parent ) diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index 51e95b554..d93b51cc4 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -68,6 +68,8 @@ public: LightApp_Preferences* preferences() const; + virtual QString getFileFilter() const; + virtual QString getFileName( bool open, const QString& initial, const QString& filters, const QString& caption, QWidget* parent ); virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent ); diff --git a/src/LightApp/LightApp_DataModel.h b/src/LightApp/LightApp_DataModel.h index 4a914bb17..f39350dc6 100644 --- a/src/LightApp/LightApp_DataModel.h +++ b/src/LightApp/LightApp_DataModel.h @@ -37,13 +37,14 @@ public: virtual bool isModified() const; virtual bool isSaved() const; + LightApp_Module* getModule() const; + signals: void opened(); void saved(); void closed(); protected: - LightApp_Module* getModule() const; LightApp_Study* getStudy() const; }; diff --git a/src/LightApp/LightApp_Dialog.cxx b/src/LightApp/LightApp_Dialog.cxx new file mode 100644 index 000000000..5599c4983 --- /dev/null +++ b/src/LightApp/LightApp_Dialog.cxx @@ -0,0 +1,860 @@ +// File: LightApp_Dialog.cxx +// Author: Alexander SOLOVYOV + +#include +#include + +#include +#include +#include + +/* + Class : LightApp_Dialog + Description : Base class for all SALOME dialogs +*/ + +//======================================================================= +// name : LightApp_Dialog +// Purpose : Constructor +//======================================================================= +LightApp_Dialog::LightApp_Dialog( QWidget* parent, const char* name, bool modal, + bool allowResize, const int f, WFlags wf ) +: QtxDialog( parent, name, modal, allowResize, f, wf ), + myIsExclusive( true ), + myIsBusy( false ) +{ + setObjectPixmap( "LightApp", tr( "ICON_SELECT" ) ); +} + +//======================================================================= +// name : ~LightApp_Dialog +// Purpose : Destructor +//======================================================================= +LightApp_Dialog::~LightApp_Dialog() +{ +} + +//======================================================================= +// name : show +// Purpose : +//======================================================================= +void LightApp_Dialog::show() +{ + QtxDialog::show(); +} + +//======================================================================= +// name : isExclusive +// Purpose : +//======================================================================= +bool LightApp_Dialog::isExclusive() const +{ + return myIsExclusive; +} + +//======================================================================= +// name : updateButtons +// Purpose : +//======================================================================= +void LightApp_Dialog::updateButtons( const int _id ) +{ + if( !myIsExclusive ) + return; + + int id = _id; + + ObjectMap::const_iterator anIt = myObjects.begin(), + aLast = myObjects.end(); + for( ; anIt!=aLast; anIt++ ) + { + QToolButton* but = (QToolButton*)anIt.data().myBtn; + if( but && but->isOn() ) + { + if( id==-1 ) + id = anIt.key(); + + if( anIt.key()!=id ) + but->setOn( false ); + } + } +} + +//======================================================================= +// name : setExclusive +// Purpose : +//======================================================================= +void LightApp_Dialog::setExclusive( const bool ex ) +{ + myIsExclusive = ex; + updateButtons(); +} + +//======================================================================= +// name : showObject +// Purpose : +//======================================================================= +void LightApp_Dialog::showObject( const int id ) +{ + setObjectShown( id, true ); +} + +//======================================================================= +// name : hideObject +// Purpose : +//======================================================================= +void LightApp_Dialog::hideObject( const int id ) +{ + setObjectShown( id, false ); +} + +//======================================================================= +// name : setObjectShown +// Purpose : +//======================================================================= +void LightApp_Dialog::setObjectShown( const int id, const bool shown ) +{ + if( myObjects.contains( id ) && isObjectShown( id )!=shown ) + { + Object& obj = myObjects[ id ]; + obj.myEdit->setShown( shown ); + obj.myBtn->setShown( shown ); + obj.myLabel->setShown( shown ); + if( !shown ) + ( ( QToolButton* )obj.myBtn )->setOn( false ); + } +} + +//======================================================================= +// name : isObjectShown +// Purpose : +//======================================================================= +bool LightApp_Dialog::isObjectShown( const int id ) const +{ + return myObjects.contains( id ) && myObjects[ id ].myEdit->isShown(); +} + +//======================================================================= +// name : setObjectEnabled +// Purpose : +//======================================================================= +void LightApp_Dialog::setObjectEnabled( const int id, const bool en ) +{ + if( myObjects.contains( id ) && isObjectEnabled( id )!=en ) + { + Object& obj = myObjects[ id ]; + obj.myEdit->setEnabled( en ); + obj.myBtn->setEnabled( en ); +// obj.myLabel->setEnabled( en ); + if( !en ) + ( ( QToolButton* )obj.myBtn )->setOn( false ); + } +} + +//======================================================================= +// name : isObjectEnabled +// Purpose : +//======================================================================= +bool LightApp_Dialog::isObjectEnabled( const int id ) const +{ + return myObjects.contains( id ) && myObjects[ id ].myEdit->isEnabled(); +} + +//======================================================================= +// name : selectObject +// Purpose : +//======================================================================= +void LightApp_Dialog::selectObject( const QString& name, const int type, const QString& id, const bool update ) +{ + QStringList names; names.append( name ); + TypesList types; types.append( type ); + QStringList ids; ids.append( id ); + selectObject( names, types, ids, update ); +} + +//======================================================================= +// name : selectObject +// Purpose : +//======================================================================= +void LightApp_Dialog::selectObject( const QStringList& _names, + const TypesList& _types, + const QStringList& _ids, + const bool update ) +{ + ObjectMap::iterator anIt = myObjects.begin(), + aLast = myObjects.end(); + for( ; anIt!=aLast; anIt++ ) + if( anIt.data().myBtn->isOn() ) + selectObject( anIt.key(), _names, _types, _ids, update ); +} + +//======================================================================= +// name : hasSelection +// Purpose : +//======================================================================= +bool LightApp_Dialog::hasSelection( const int id ) const +{ + return myObjects.contains( id ) && !myObjects[ id ].myIds.isEmpty(); +} + +//======================================================================= +// name : clearSelection +// Purpose : +//======================================================================= +void LightApp_Dialog::clearSelection( const int id ) +{ + if( id==-1 ) + { + ObjectMap::const_iterator anIt = myObjects.begin(), + aLast = myObjects.end(); + for( ; anIt!=aLast; anIt++ ) + clearSelection( anIt.key() ); + } + + else if( myObjects.contains( id ) ) + { + myObjects[ id ].myIds.clear(); + myObjects[ id ].myTypes.clear(); + myObjects[ id ].myNames.clear(); + + myObjects[ id ].myEdit->setText( QString::null ); + emit selectionChanged( id ); + } +} + +//======================================================================= +// name : objectWg +// Purpose : +//======================================================================= +QWidget* LightApp_Dialog::objectWg( const int theId, const int theWgId ) const +{ + QWidget* aResWg = 0; + if( myObjects.contains( theId ) ) + { + if ( theWgId == Label ) + aResWg = myObjects[ theId ].myLabel; + else if ( theWgId == Btn ) + aResWg = myObjects[ theId ].myBtn; + else if ( theWgId == Control ) + aResWg = myObjects[ theId ].myEdit; + } + return aResWg; +} + +//======================================================================= +// name : objectText +// Purpose : +//======================================================================= +QString LightApp_Dialog::objectText( const int theId ) const +{ + return myObjects.contains( theId ) ? myObjects[ theId ].myEdit->text() : ""; +} + +//======================================================================= +// name : setObjectText +// Purpose : +//======================================================================= +void LightApp_Dialog::setObjectText( const int theId, const QString& theText ) +{ + if ( myObjects.contains( theId ) ) + myObjects[ theId ].myEdit->setText( theText ); +} + +//======================================================================= +// name : selectedObject +// Purpose : +//======================================================================= +void LightApp_Dialog::selectedObject( const int id, QStringList& list ) const +{ + if( myObjects.contains( id ) ) + list = myObjects[ id ].myIds; +} + +//======================================================================= +// name : selectedObject +// Purpose : +//======================================================================= +QString LightApp_Dialog::selectedObject( const int id ) const +{ + if ( myObjects.contains( id ) && myObjects[ id ].myIds.count() > 0 ) + return myObjects[ id ].myIds.first(); + else + return ""; +} + +//======================================================================= +// name : objectSelection +// Purpose : +//======================================================================= +void LightApp_Dialog::objectSelection( SelectedObjects& objs ) const +{ + //objs.clear(); + ObjectMap::const_iterator anIt = myObjects.begin(), + aLast = myObjects.end(); + for( ; anIt!=aLast; anIt++ ) + { + QStringList ids; + selectedObject( anIt.key(), ids ); + if( !ids.isEmpty() ) + objs.insert( anIt.key(), ids ); + } +} + +//======================================================================= +// name : createObject +// Purpose : +//======================================================================= +int LightApp_Dialog::createObject( const QString& label, QWidget* parent, const int id ) +{ + int nid = id; + if( nid<0 ) + for( nid=0; myObjects.contains( nid ); nid++ ); + + if( !myObjects.contains( nid ) ) + { + QLabel* lab = new QLabel( label, parent ); + myObjects[ nid ].myLabel = lab; + + QToolButton* but = new QToolButton( parent ); + but->setIconSet( QIconSet( myPixmap ) ); + but->setToggleButton( true ); + but->setMaximumWidth( but->height() ); + but->setMinimumWidth( but->height() ); + connect( but, SIGNAL( toggled( bool ) ), this, SLOT( onToggled( bool ) ) ); + myObjects[ nid ].myBtn = but; + + QLineEdit* ne = new QLineEdit( parent ); + ne->setReadOnly( true ); + ne->setMinimumWidth( 150 ); + connect( ne, SIGNAL( textChanged( const QString& ) ), this, SLOT( onTextChanged( const QString& ) ) ); + myObjects[ nid ].myEdit = ne; + + myObjects[ nid ].myNI = OneNameOrCount; + } + return nid; +} + +//======================================================================= +// name : renameObject +// Purpose : +//======================================================================= +void LightApp_Dialog::renameObject( const int id, const QString& label ) +{ + if( myObjects.contains( id ) ) + myObjects[ id ].myLabel->setText( label ); +} + +//======================================================================= +// name : setObjectType +// Purpose : +//======================================================================= +void LightApp_Dialog::setObjectType( const int id, const int type1, ... ) +{ + TypesList types; + + const int* tt = &type1; + while( *tt>=0 ) + { + types.append( *tt ); + tt++; + } + + setObjectType( id, types ); +} + +//======================================================================= +// name : setObjectType +// Purpose : +//======================================================================= +void LightApp_Dialog::setObjectType( const int id, const TypesList& list ) +{ + if( !myObjects.contains( id ) ) + return; + + TypesList& internal = myObjects[ id ].myPossibleTypes; + + QMap types; + TypesList::const_iterator anIt = list.begin(), + aLast = list.end(); + for( ; anIt!=aLast; anIt++ ) + types.insert( *anIt, 0 ); + + + internal.clear(); + QMap::const_iterator aMIt = types.begin(), + aMLast = types.end(); + for( ; aMIt!=aMLast; aMIt++ ) + internal.append( aMIt.key() ); + + updateObject( id ); +} + +//======================================================================= +// name : addObjectType +// Purpose : +//======================================================================= +void LightApp_Dialog::addObjectType( const int id, const int type1, const int, ... ) +{ + TypesList types; objectTypes( id, types ); + + const int* tt = &type1; + while( *tt>=0 ) + { + types.append( *tt ); + tt++; + } + + setObjectType( id, types ); +} + +//======================================================================= +// name : addObjectType +// Purpose : +//======================================================================= +void LightApp_Dialog::addObjectType( const int id, const TypesList& list ) +{ + TypesList types = list; objectTypes( id, types ); + setObjectType( id, types ); +} + +//======================================================================= +// name : addObjectType +// Purpose : +//======================================================================= +void LightApp_Dialog::addObjectType( const int id, const int type ) +{ + TypesList types; objectTypes( id, types ); + types.append( type ); + setObjectType( id, types ); +} + +//======================================================================= +// name : removeObjectType +// Purpose : +//======================================================================= +void LightApp_Dialog::removeObjectType( const int id ) +{ + TypesList types; + setObjectType( id, types ); +} + +//======================================================================= +// name : removeObjectType +// Purpose : +//======================================================================= +void LightApp_Dialog::removeObjectType( const int id, const TypesList& list ) +{ + if( !myObjects.contains( id ) ) + return; + + TypesList& internal = myObjects[ id ].myPossibleTypes; + + QMap types; + TypesList::const_iterator anIt = internal.begin(), + aLast = internal.end(); + for( ; anIt!=aLast; anIt++ ) + types.insert( *anIt, 0 ); + anIt = list.begin(); aLast = list.end(); + for( ; anIt!=aLast; anIt++ ) + types.remove( *anIt ); + + + internal.clear(); + QMap::const_iterator aMIt = types.begin(), + aMLast = types.end(); + for( ; aMIt!=aMLast; aMIt++ ) + internal.append( aMIt.key() ); + + updateObject( id ); +} + +//======================================================================= +// name : removeObjectType +// Purpose : +//======================================================================= +void LightApp_Dialog::removeObjectType( const int id, const int type ) +{ + TypesList list; list.append( type ); + removeObjectType( id, list ); +} + +//======================================================================= +// name : hasObjectType +// Purpose : +//======================================================================= +bool LightApp_Dialog::hasObjectType( const int id, const int type ) const +{ + if( myObjects.contains( id ) ) + return myObjects[ id ].myPossibleTypes.contains( type ); + else + return false; +} + +//======================================================================= +// name : objectTypes +// Purpose : +//======================================================================= +void LightApp_Dialog::objectTypes( const int id, TypesList& list ) const +{ + if( myObjects.contains( id ) ) + { + TypesList::const_iterator anIt = myObjects[ id ].myPossibleTypes.begin(), + aLast = myObjects[ id ].myPossibleTypes.end(); + for( ; anIt!=aLast; anIt++ ) + list.append( *anIt ); + } +} + +//======================================================================= +// name : onToggled +// Purpose : +//======================================================================= +void LightApp_Dialog::onToggled( bool on ) +{ + QButton* but = ( QButton* )sender(); + int id = -1; + + if( !but ) + return; + + ObjectMap::const_iterator anIt = myObjects.begin(), + aLast = myObjects.end(); + for( ; anIt!=aLast && id==-1; anIt++ ) + if( anIt.data().myBtn==but ) + id = anIt.key(); + + if( id!=-1 ) + if( on ) + { + emit objectActivated( id ); + updateButtons( id ); + } + else + emit objectDeactivated( id ); +} + +//======================================================================= +// name : updateObject +// Purpose : +//======================================================================= +void LightApp_Dialog::updateObject( const int id, bool emit_signal ) +{ + if( hasSelection( id ) ) + { + Object& obj = myObjects[ id ]; + filterTypes( id, obj.myNames, obj.myTypes, obj.myIds ); + obj.myEdit->setText( selectionDescription( obj.myNames, obj.myTypes, obj.myNI ) ); + if( emit_signal ) + emit selectionChanged( id ); + } +} + +//======================================================================= +// name : filterTypes +// Purpose : +//======================================================================= +void LightApp_Dialog::filterTypes( const int id, QStringList& names, TypesList& types, QStringList& ids ) const +{ + if( !myObjects.contains( id ) ) + return; + + const Object& obj = myObjects[ id ]; + if( obj.myPossibleTypes.isEmpty() ) + return; + + QStringList new_names, new_ids; + TypesList new_types; + + TypesList::const_iterator anIt1 = types.begin(), + aLast = types.end(); + QStringList::const_iterator anIt2 = names.begin(), + anIt3 = ids.begin(); + for( ; anIt1!=aLast; anIt1++, anIt2++, anIt3++ ) + if( obj.myPossibleTypes.contains( *anIt1 ) ) + { + if( new_types.count()==1 && !multipleSelection( id ) ) + break; + + new_names.append( *anIt2 ); + new_types.append( *anIt1 ); + new_ids.append( *anIt3 ); + } + names = new_names; + types = new_types; + ids = new_ids; +} + +//======================================================================= +// name : resMgr +// Purpose : +//======================================================================= +SUIT_ResourceMgr* LightApp_Dialog::resMgr() const +{ + return SUIT_Session::session()->resourceMgr(); +} + +//======================================================================= +// name : setObjectPixmap +// Purpose : +//======================================================================= +void LightApp_Dialog::setObjectPixmap( const QPixmap& p ) +{ + myPixmap = p; + ObjectMap::const_iterator anIt = myObjects.begin(), + aLast = myObjects.end(); + for( ; anIt!=aLast; anIt++ ) + ( ( QToolButton* )anIt.data().myBtn )->setIconSet( p ); +} + +//======================================================================= +// name : setObjectPixmap +// Purpose : +//======================================================================= +void LightApp_Dialog::setObjectPixmap( const QString& section, const QString& file ) +{ + SUIT_ResourceMgr* mgr = resMgr(); + if( mgr ) + setObjectPixmap( mgr->loadPixmap( section, file ) ); +} + +//======================================================================= +// name : multipleSelection +// Purpose : +//======================================================================= +bool LightApp_Dialog::multipleSelection( const int id ) const +{ + return nameIndication( id )!=OneName; +} + +//======================================================================= +// name : nameIndication +// Purpose : +//======================================================================= +LightApp_Dialog::NameIndication LightApp_Dialog::nameIndication( const int id ) const +{ + if( myObjects.contains( id ) ) + return myObjects[ id ].myNI; + else + return OneNameOrCount; +} + +//======================================================================= +// name : setNameIndication +// Purpose : +//======================================================================= +void LightApp_Dialog::setNameIndication( const int id, const NameIndication ni ) +{ + if( id==-1 ) + { + ObjectMap::iterator anIt = myObjects.begin(), + aNext, + aLast = myObjects.end(); + for( ; anIt!=aLast; anIt++ ) + { + anIt.data().myNI = ni; + setReadOnly( anIt.key(), isReadOnly( anIt.key() ) ); + aNext = anIt; aNext++; + updateObject( anIt.key(), aNext==aLast ); + } + } + else if( myObjects.contains( id ) ) + { + myObjects[ id ].myNI = ni; + setReadOnly( id, isReadOnly( id ) ); + updateObject( id, true ); + } +} + +//======================================================================= +// name : selectionDescription +// Purpose : +//======================================================================= +QString LightApp_Dialog::selectionDescription( const QStringList& names, const TypesList& types, const NameIndication ni ) const +{ + if( names.count()!=types.count() ) + return "LightApp_Dialog::selectionDescription(): Error!!!"; + + if( names.isEmpty() ) + return QString::null; + + switch( ni ) + { + case OneName: + return names.first(); + break; + + case OneNameOrCount: + if( names.count()==1 ) + return names.first(); + else + return countOfTypes( types ); + break; + + case ListOfNames: + return names.join( " " ); + break; + + case Count: + return countOfTypes( types ); + break; + }; + return QString::null; +} + +//======================================================================= +// name : countOfTypes +// Purpose : +//======================================================================= +QString LightApp_Dialog::countOfTypes( const TypesList& types ) const +{ + QMap typesCount; + QStringList typeCount; + + TypesList::const_iterator anIt = types.begin(), + aLast = types.end(); + for( ; anIt!=aLast; anIt++ ) + if( typesCount.contains( *anIt ) ) + typesCount[ *anIt ]++; + else + typesCount[ *anIt ] = 1; + + QMap::const_iterator aMIt = typesCount.begin(), + aMLast = typesCount.end(); + for( ; aMIt!=aMLast; aMIt++ ) + typeCount.append( QString( "%1 %2" ).arg( aMIt.data() ).arg( typeName( aMIt.key() ) ) ); + + return typeCount.join( ", " ); +} + +//======================================================================= +// name : typeName +// Purpose : +//======================================================================= +QString& LightApp_Dialog::typeName( const int type ) +{ + return myTypeNames[ type ]; +} + +//======================================================================= +// name : typeName +// Purpose : +//======================================================================= +const QString& LightApp_Dialog::typeName( const int type ) const +{ + return myTypeNames[ type ]; +} + + +//======================================================================= +// name : activateObject +// Purpose : +//======================================================================= +void LightApp_Dialog::activateObject( const int theId ) +{ + if ( myObjects.contains( theId ) && !myObjects[ theId ].myBtn->isOn() ) + myObjects[ theId ].myBtn->toggle(); +} + +//======================================================================= +// name : deactivateAll +// Purpose : +//======================================================================= +void LightApp_Dialog::deactivateAll() +{ + ObjectMap::iterator anIt = myObjects.begin(), + aLast = myObjects.end(); + for( ; anIt!=aLast; anIt++ ) + { + QToolButton* btn = ( QToolButton* )anIt.data().myBtn; + btn->setOn( false ); + } +} + +//======================================================================= +// name : selectObject +// Purpose : +//======================================================================= +void LightApp_Dialog::selectObject( const int id, const QString& name, const int type, const QString& selid, const bool update ) +{ + QStringList names; names.append( name ); + TypesList types; types.append( type ); + QStringList ids; ids.append( selid ); + selectObject( id, names, types, ids, update ); +} + +//======================================================================= +// name : selectObject +// Purpose : +//======================================================================= +void LightApp_Dialog::selectObject( const int id, const QStringList& _names, const TypesList& _types, + const QStringList& _ids, const bool update ) +{ + if( !myObjects.contains( id ) ) + return; + + QStringList names = _names, ids = _ids; + TypesList types = _types; + + filterTypes( id, names, types, ids ); + + Object& obj = myObjects[ id ]; + if( update ) + obj.myEdit->setText( selectionDescription( names, types, obj.myNI ) ); + obj.myTypes = types; + obj.myIds = ids; + obj.myNames = names; + + emit selectionChanged( id ); +} + +//======================================================================= +// name : setReadOnly +// Purpose : +//======================================================================= +void LightApp_Dialog::setReadOnly( const int id, const bool ro ) +{ + if( myObjects.contains( id ) ) + myObjects[ id ].myEdit->setReadOnly( nameIndication( id )==ListOfNames || nameIndication( id )==OneName ? ro : true ); +} + +//======================================================================= +// name : isReadOnly +// Purpose : +//======================================================================= +bool LightApp_Dialog::isReadOnly( const int id ) const +{ + if( myObjects.contains( id ) ) + return myObjects[ id ].myEdit->isReadOnly(); + else + return true; +} + +//======================================================================= +// name : onTextChanged +// Purpose : +//======================================================================= +void LightApp_Dialog::onTextChanged( const QString& text ) +{ + if( myIsBusy ) + return; + + myIsBusy = true; + + if( sender() && sender()->inherits( "QLineEdit" ) ) + { + QLineEdit* edit = ( QLineEdit* )sender(); + int id = -1; + ObjectMap::const_iterator anIt = myObjects.begin(), + aLast = myObjects.end(); + for( ; anIt!=aLast; anIt++ ) + if( anIt.data().myEdit == edit ) + id = anIt.key(); + + if( id>=0 && !isReadOnly( id ) ) + { + QStringList list = QStringList::split( " ", text ); + emit objectChanged( id, list ); + } + } + + myIsBusy = false; +} diff --git a/src/LightApp/LightApp_Dialog.h b/src/LightApp/LightApp_Dialog.h new file mode 100644 index 000000000..5e36c4394 --- /dev/null +++ b/src/LightApp/LightApp_Dialog.h @@ -0,0 +1,266 @@ +// File: LightApp_Dialog.h +// Author: Alexander SOLOVYOV + +#ifndef LIGHTAPP_DIALOG_H +#define LIGHTAPP_DIALOG_H + +#include + +#include +#include +#include + +class QLineEdit; +class QButton; +class QLabel; + +class SUIT_ResourceMgr; + +/* + Class : LightApp_Dialog + Description : Base class for all SALOME dialogs +*/ +class LightApp_Dialog : public QtxDialog +{ + Q_OBJECT + +public: + typedef QValueList TypesList; + typedef QMap SelectedObjects; + + enum ObjectWg + { + Label = 0x00000001, + Btn = 0x00000002, + Control = 0x00000004 + }; + + typedef enum + { + OneName, // " is shown + ListOfNames, //! list of all names is shown + Count //! In every case " " is shown + + } NameIndication; + //! The enumeration describing how names of selected objects will be shown in line edit + //! For more details see above + +public: + LightApp_Dialog( QWidget* = 0, const char* = 0, bool = false, + bool = false, const int = Standard, WFlags = 0 ); + virtual ~LightApp_Dialog(); + + virtual void show(); + + //! Check if buttons is exclusive (as radiobuttons) + bool isExclusive() const; + + //! Set exclusive state + void setExclusive( const bool ); + + //! Check if operation according to dialog will be resumed automatically when mouse enter the dialog + bool isAutoResumed() const; + + //! Set auto resumed state + void setAutoResumed( const bool ); + + //! Show widgets corresponding to id + void showObject( const int ); + + //! Hide widgets corresponding to id + void hideObject( const int ); + + //! Change the shown state of widgets corresponding to id + void setObjectShown( const int, const bool ); + + //! Check the shown state + bool isObjectShown( const int ) const; + + //! Change the enabled state of widgets corresponding to id + void setObjectEnabled( const int, const bool ); + + //! Check the enabled state + bool isObjectEnabled( const int ) const; + + //! Get widget of object (see ObjectWg enumeration) + QWidget* objectWg( const int theId, const int theWgId ) const; + + //! Pass to all active widgets name, type and id of selected object + void selectObject( const QString&, const int, const QString&, const bool = true ); + + /*! + Pass to all active widgets list of names, types and ids of selected objects + Every active widget filters list and accept only objects with possible types + */ + void selectObject( const QStringList&, const TypesList&, const QStringList&, const bool = true ); + + //! Get text of object's control + QString objectText( const int ) const; + + //! Set text of object's control + void setObjectText( const int, const QString& ); + + //! Select in certain widget avoiding check if there is active widget + void selectObject( const int, const QString&, const int, const QString&, const bool = true ); + void selectObject( const int, const QStringList&, const TypesList&, const QStringList&, const bool = true ); + + //! Check if certain widget has selection + bool hasSelection( const int ) const; + + //! Clear selection in widgets. If parameter is -1, then selection in all widgets will be cleared + void clearSelection( const int = -1 ); + + //! Get ids list of object selected in certain widget + void selectedObject( const int, QStringList& ) const; + + //! Get ids list of object selected in certain widget + QString selectedObject( const int ) const; + + //! Get map "widget id -> ids list" + void objectSelection( SelectedObjects& ) const; + + //! Activate object selection button + void activateObject( const int ); + + //! Set all object selection buttons to inactive state + void deactivateAll(); + +signals: + //! selection in certain widget is changed + void selectionChanged ( int ); + + //! selection in certain widget is on + void objectActivated ( int ); + + //! selection in certain widget is off + void objectDeactivated( int ); + + /* + text representation of selection is changed + it is emitted only if "read only" state of line edit is false + */ + void objectChanged( int, const QStringList& ); + +protected: + //! Finds and returns resource manager + SUIT_ResourceMgr* resMgr() const; + + /*! Create label, button and line edit for object selection + * If passed id is negative, then id will be calculated automatically (first free id) + * Returns the same id (if id>=0) or calculated + */ + int createObject ( const QString&, QWidget*, const int = -1 ); + + //! Set pixmap as icon for all selection buttons + void setObjectPixmap ( const QPixmap& ); + + //! Load pixmap with section, name using resource manager and set as icon for all selection buttons + void setObjectPixmap ( const QString&, const QString& ); + + //! Change label + void renameObject ( const int, const QString& ); + + //! Set possible types for certain id. The list of arguments must be finished by negative integer + void setObjectType ( const int, const int, ... ); + + //! Set list as possible types for object selection + void setObjectType ( const int, const TypesList& ); + + /*! + Add types to list of possible types + The list of arguments must be finished by negative integer + */ + void addObjectType ( const int, const int, const int, ... ); + + //! Add types to list of possible types + void addObjectType ( const int, const TypesList& ); + + //! Add type to list of possible types + void addObjectType ( const int, const int ); + + //! Clear list of possible types (it means, that all types are welcome) + void removeObjectType( const int ); + + //! Remove types in list from list of possible types + void removeObjectType( const int, const TypesList& ); + + //! Remove a type from list of possible types + void removeObjectType( const int, const int ); + + //! Check if list of possible types contains this one + bool hasObjectType ( const int, const int ) const; + + //! Return list of possible types + void objectTypes ( const int, TypesList& ) const; + + //!Change and get type name for indicating in selection widget + QString& typeName( const int ); + const QString& typeName( const int ) const; + + //! Create string contains selection list by list of names, list of types and current name indication state + virtual QString selectionDescription( const QStringList&, const TypesList&, const NameIndication ) const; + + //! Create string by pattern " " for current list of types + virtual QString countOfTypes( const TypesList& ) const; + + //! Get and set name indication for certain widget + NameIndication nameIndication( const int ) const; + void setNameIndication( const int, const NameIndication ); + + //! Check using name indication if multiple selection in possible + bool multipleSelection( const int ) const; + + //! Set the "read only" state of object selection line edit + //! The "read only" will be false only if name indication is ListOfNames + void setReadOnly( const int, const bool ); + + //! Check the "read only" state of object selection line edit + bool isReadOnly( const int ) const; + +private slots: + //! emits if the object selection button changes state + void onToggled( bool ); + + //! text in some line edit is changed + void onTextChanged( const QString& ); + +private: + /*! + If buttons are exclusive, set to "off" all buttons except one with id + If id=-1, then all buttons, except first with "on" state, will be set to "off" + */ + void updateButtons( const int = -1 ); + + /*! + Filter types and update selection string in line edit + If bool is true, then signal is emitted + */ + void updateObject( const int, bool = true ); + + //! Remove from list not possible types and remove from names and ids lists the corresponding items + void filterTypes( const int, QStringList&, TypesList&, QStringList& ) const; + +private: + typedef struct + { + QLineEdit* myEdit; + QButton* myBtn; + QLabel* myLabel; + QStringList myNames, myIds; + TypesList myTypes, myPossibleTypes; + NameIndication myNI; + + } Object; + + typedef QMap ObjectMap; + +private: + ObjectMap myObjects; + QMap myTypeNames; + bool myIsExclusive, myIsBusy; + QPixmap myPixmap; +}; + +#endif diff --git a/src/LightApp/LightApp_Module.cxx b/src/LightApp/LightApp_Module.cxx index a3eca473f..649ccfefe 100644 --- a/src/LightApp/LightApp_Module.cxx +++ b/src/LightApp/LightApp_Module.cxx @@ -12,11 +12,22 @@ #include "LightApp_Study.h" #include "LightApp_Preferences.h" #include "LightApp_Selection.h" +#include "LightApp_Operation.h" +#include "LightApp_SwitchOp.h" +#include "LightApp_UpdateFlags.h" +#include "SUIT_Operation.h" #include #include #include +#include +#include +#include +#include +#include +#include + #include #include @@ -28,13 +39,16 @@ /*!Constructor.*/ LightApp_Module::LightApp_Module( const QString& name ) : CAM_Module( name ), -myPopupMgr( 0 ) + myPopupMgr( 0 ), + mySwitchOp( 0 ) { } /*!Destructor.*/ LightApp_Module::~LightApp_Module() { + if ( mySwitchOp ) + delete mySwitchOp; } /*!Initialize module.*/ @@ -89,12 +103,18 @@ bool LightApp_Module::activateModule( SUIT_Study* study ) if ( res && application() && application()->resourceMgr() ) application()->resourceMgr()->raiseTranslators( name() ); + if ( mySwitchOp == 0 ) + mySwitchOp = new LightApp_SwitchOp( this ); + return res; } /*!Deactivate module.*/ bool LightApp_Module::deactivateModule( SUIT_Study* ) { + delete mySwitchOp; + mySwitchOp = 0; + return true; } @@ -119,6 +139,55 @@ LightApp_Application* LightApp_Module::getApp() const return (LightApp_Application*)application(); } +/*! + * \brief Update something in accordance with update flags + * \param theFlags - update flags +* +* Update viewer or/and object browser etc. in accordance with update flags ( see +* LightApp_UpdateFlags enumeration ). Derived modules can redefine this method for their +* own purposes +*/ +void LightApp_Module::update( const int theFlags ) +{ + if ( theFlags & UF_Model ) + { + if( CAM_DataModel* aDataModel = dataModel() ) + if( LightApp_DataModel* aModel = dynamic_cast( aDataModel ) ) { + LightApp_Study* aStudy = dynamic_cast( getApp()->activeStudy() ); + if (aStudy) + aModel->update( 0, aStudy ); + } + } + if ( theFlags & UF_ObjBrowser ) + getApp()->objectBrowser()->updateTree( 0 ); + if ( theFlags & UF_Controls ) + updateControls(); + if ( theFlags & UF_Viewer ) + { + if ( SUIT_ViewManager* viewMgr = getApp()->activeViewManager() ) + if ( SUIT_ViewWindow* viewWnd = viewMgr->getActiveView() ) + { + if ( viewWnd->inherits( "SVTK_ViewWindow" ) ) + ( (SVTK_ViewWindow*)viewWnd )->Repaint(); + else if ( viewWnd->inherits( "OCCViewer_ViewWindow" ) ) + ( (OCCViewer_ViewWindow*)viewWnd )->getViewPort()->onUpdate(); + else if ( viewWnd->inherits( "Plot2d_ViewWindow" ) ) + ( (Plot2d_ViewWindow*)viewWnd )->getViewFrame()->Repaint(); + else if ( viewWnd->inherits( "GLViewer_ViewFrame" ) ) + ( (GLViewer_ViewFrame*)viewWnd )->getViewPort()->onUpdate(); + } + } +} +/*! + * \brief Updates controls +* +* Updates (i.e. disable/enable) controls states (menus, tool bars etc.). This method is +* called from update( UF_Controls ). You may redefine it in concrete module. +*/ +void LightApp_Module::updateControls() +{ +} + /*!Create new instance of data model and return it.*/ CAM_DataModel* LightApp_Module::createDataModel() { @@ -204,3 +273,82 @@ void LightApp_Module::setPreferenceProperty( const int id, const QString& prop, if ( pref ) pref->setItemProperty( id, prop, var ); } + +/*! + * \brief Starts operation with given identifier + * \param id - identifier of operation to be started +* +* Module stores operations in map. This method starts operation by id. +* If operation isn't in map, then it will be created by createOperation method +* and will be inserted to map +*/ +void LightApp_Module::startOperation( const int id ) +{ + LightApp_Operation* op = 0; + if( myOperations.contains( id ) ) + op = myOperations[ id ]; + else + { + op = createOperation( id ); + if( op ) + { + myOperations.insert( id, op ); + op->setModule( this ); + connect( op, SIGNAL( stopped( SUIT_Operation* ) ), this, SLOT( onOperationStopped( SUIT_Operation* ) ) ); + connect( op, SIGNAL( destroyed() ), this, SLOT( onOperationDestroyed() ) ); + } + } + + if( op ) + op->start(); +} + +/*! + * \brief Creates operation with given identifier + * \param id - identifier of operation to be started + * \return Pointer on created operation or NULL if operation is not created +* +* Creates operation with given id. You should not call this method, it will be called +* automatically from startOperation. You may redefine this method in concrete module to +* create operations. +*/ +LightApp_Operation* LightApp_Module::createOperation( const int /*id*/ ) const +{ + return 0; +} + +/*! + * \brief Virtual protected slot called when operation stopped + * \param theOp - stopped operation +* +* Virtual protected slot called when operation stopped. Redefine this slot if you want to +* perform actions after stopping operation +*/ +void LightApp_Module::onOperationStopped( SUIT_Operation* /*theOp*/ ) +{ +} + +/*! + * \brief Virtual protected slot called when operation destroyed + * \param theOp - destroyed operation +* +* Virtual protected slot called when operation destroyed. Redefine this slot if you want to +* perform actions after destroying operation. Base implementation removes pointer on +* destroyed operation from the map of operations +*/ +void LightApp_Module::onOperationDestroyed() +{ + const QObject* s = sender(); + if( s && s->inherits( "LightApp_Operation" ) ) + { + const LightApp_Operation* op = ( LightApp_Operation* )s; + MapOfOperation::const_iterator anIt = myOperations.begin(), + aLast = myOperations.end(); + for( ; anIt!=aLast; anIt++ ) + if( anIt.data()==op ) + { + myOperations.remove( anIt.key() ); + break; + } + } +} diff --git a/src/LightApp/LightApp_Module.h b/src/LightApp/LightApp_Module.h index cebb5e493..1367d4500 100644 --- a/src/LightApp/LightApp_Module.h +++ b/src/LightApp/LightApp_Module.h @@ -12,9 +12,12 @@ class LightApp_Application; class LightApp_Preferences; class LightApp_Selection; +class LightApp_Operation; +class LightApp_SwitchOp; class SUIT_Study; class SUIT_DataObject; +class SUIT_Operation; class CAM_Application; class QtxPopupMgr; @@ -45,6 +48,11 @@ public: LightApp_Application* getApp() const; + virtual void update( const int ); + // Update viewer or/and object browser etc. in accordance with update flags + // ( see LightApp_UpdateFlags enumeration ). Derived modules can redefine this method + // for their own purposes + virtual void updateObjBrowser( bool = true, SUIT_DataObject* = 0 ); // Update object bropwser ( for updating model or whole object browser use update() method // can be used ) @@ -64,6 +72,9 @@ protected slots: virtual void onModelOpened(); virtual void onModelClosed(); + virtual void onOperationStopped( SUIT_Operation* ); + virtual void onOperationDestroyed(); + protected: QtxPopupMgr* popupMgr(); LightApp_Preferences* preferences() const; @@ -77,9 +88,26 @@ protected: const QString& param = QString::null ); QVariant preferenceProperty( const int, const QString& ) const; void setPreferenceProperty( const int, const QString&, const QVariant& ); + /*! Module stores operations in map. This method starts operation by id. + * If operation isn't in map, then it will be created by createOperation method + * and will be inserted to map + */ + void startOperation( const int ); + + /*! Create operation by its id. You must not call this method, it will be called automatically + * by startOperation. Please redefine this method in current module + */ + virtual LightApp_Operation* createOperation( const int ) const; + + virtual void updateControls(); + +private: + typedef QMap MapOfOperation; private: - QtxPopupMgr* myPopupMgr; + QtxPopupMgr* myPopupMgr; + MapOfOperation myOperations; + LightApp_SwitchOp* mySwitchOp; }; #endif diff --git a/src/LightApp/LightApp_Operation.cxx b/src/LightApp/LightApp_Operation.cxx new file mode 100755 index 000000000..0d5a24d5a --- /dev/null +++ b/src/LightApp/LightApp_Operation.cxx @@ -0,0 +1,290 @@ +// SALOME LightApp +// +// Copyright (C) 2005 CEA/DEN, EDF R&D +// +// +// +// File : LightApp_Operation.h +// Author : Sergey LITONIN +// Module : SALOME + +#include +#include +#include +#include +#include +#include + +#include + +#include + + +/*! + * \brief Constructor +* +* Constructor sets myModule in NULL and myIsAutoResumed in TRUE +*/ +LightApp_Operation::LightApp_Operation() +: SUIT_Operation( 0 ), + myModule( 0 ), + myIsAutoResumed( true ) +{ +} + +/*! + * \brief Destructor +* +* Destructor does nothing +*/ +LightApp_Operation::~LightApp_Operation() +{ + +} + +/*! + * \brief Gets module of operation + * \return Pointer to the module +* +* Gets pointer to the module or NULL if module was not set. It is strongly recomended to +* set valid pointer on the module before start of operation +*/ +LightApp_Module* LightApp_Operation::module() const +{ + return myModule; +} + + +/*! + * \brief Sets module of operation + * \param theModule - module to be set +* +* Sets pointer to the module. It is strongly recomended to set valid pointer on the +* module before start of operation +*/ +void LightApp_Operation::setModule( LightApp_Module* theModule ) +{ + myModule = theModule; + setApplication( myModule ? myModule->application() : 0 ); + setStudy( application() ? application()->activeStudy() : 0 ); +} + +/*! + * \brief Gets desktop of operation + * \return Pointer to the desktop +* +* Gets pointer to the desktop or NULL if application was not set. It is strongly recomended +* to set valid pointer on the application before start of operation +*/ +SUIT_Desktop* LightApp_Operation::desktop() const +{ + return application() != 0 ? application()->desktop() : 0; +} + +/*! + * \brief Enable dialog of operation +* +* Virtual method redefined from the base class. Enable dialog if it was desabled (in +* suspend method) and activate selection +*/ +void LightApp_Operation::resumeOperation() +{ + SUIT_Operation::resumeOperation(); + setDialogActive( true ); +} + +/*! + * \brief Performs actions needed for starting operation +* +* Virtual method redefined from the base class. Connect signal of selection manager to +* onSelectionDone() slot +*/ +void LightApp_Operation::startOperation() +{ + if( selectionMgr() ) + connect( selectionMgr(), SIGNAL( selectionChanged() ), SLOT( onSelectionDone() ) ); + + //If suspended operation was stopped during starting other operation, + //the dialog is inactive now, We must activate it + setDialogActive( true ); +} + +/*! + * \brief Performs actions needed for suspending operation +* +* Virtual method redefined from the base class. This implementation calls corresponding +* method of base class and cals setDialogActive( false ) +*/ +void LightApp_Operation::suspendOperation() +{ + SUIT_Operation::suspendOperation(); + setDialogActive( false ); +} + +//======================================================================= +// name : abortOperation +// Purpose : Hide dialog box (if it is exists) +//======================================================================= +/*! + * \brief Performs actions needed for aborting operation +* +* Virtual method redefined from the base class calls corresponding method of base class +* and hides dialog box (if it is exists), disconnect slots from selection manager +*/ +void LightApp_Operation::abortOperation() +{ + SUIT_Operation::abortOperation(); + setDialogActive( true ); + if ( dlg() ) + dlg()->hide(); + + if( selectionMgr() ) + disconnect( selectionMgr(), SIGNAL( selectionChanged() ), this, SLOT( onSelectionDone() ) ); +} + +/*! + * \brief Performs actions needed for committing operation +* +* Virtual method redefined from the base class calls corresponding method of base class +* and hides dialog box (if it is exists), disconnect slots from selection manager +*/ +void LightApp_Operation::commitOperation() +{ + SUIT_Operation::commitOperation(); + setDialogActive( true ); + if ( dlg() ) + dlg()->hide(); + + if( selectionMgr() ) + disconnect( selectionMgr(), SIGNAL( selectionChanged() ), this, SLOT( onSelectionDone() ) ); +} + +/*! + * \brief Gets dialog + * \return Pointer to the dialog of this operation or NULL if it does not exist +* +* This method should be redefined in derived classes if they use dialogs. If this +* function returns pointer to dialog then dialog will be correctly +* -# deactivated in suspendOperation method +* -# activated in resumeOperation method +* -# hidden in abortOperation and commitOperation methods +*/ +LightApp_Dialog* LightApp_Operation::dlg() const +{ + return 0; +} + +/*! + * \brief Activates selection +* +* Virtual method should be redefined in derived classes if they use own selection modes +* (different from default) +*/ +void LightApp_Operation::activateSelection() +{ +} + +/*! + * \brief Virtual method called when selection is changed +* +* Virtual method should be redefined in derived classes if they works with selection +* to provide reaction on the change of selection +*/ +void LightApp_Operation::selectionDone() +{ +} + +/*! + * \brief Gets active operation +* +* This method provided for convinience calls SUIT_Study::activeOperation() one +*/ +SUIT_Operation* LightApp_Operation::activeOperation() const +{ + return study() != 0 ? study()->activeOperation() : 0; +} + +/*! + * \brief Gets selection manager +* +* This method provided for convinience calls LightApp_Application::selectionMgr() one +*/ +LightApp_SelectionMgr* LightApp_Operation::selectionMgr() const +{ + SUIT_Application* app = application(); + if ( app != 0 && app->inherits( "LightApp_Application" ) ) + return ( (LightApp_Application*)app )->selectionMgr(); + else + return 0; +} + +/*! + * \brief Call selectionDone() method +* +* Call selectionDone() method if operator is an active one (see selectionDone() for more +* description ) +*/ +void LightApp_Operation::onSelectionDone() +{ + if ( isActive() ) + selectionDone(); +} + +/*! + * \brief Update object browser or/and viewer etc. + * \param flags - update flags +* +* This method provided for convinience calls LightApp_Module::update() one (see +* LightApp_Module::update() for more description) +*/ +void LightApp_Operation::update( const int flags ) +{ + if ( myModule != 0 ) + myModule->update( flags ); +} + +/*! + * \brief Activate/Deactivate dialog of operation + * \param active - State of the dialog to be set +* +* Activate/Deactivate dialog of operation. This method called from startOperation(), +* suspendOperation() ones and so on +*/ +void LightApp_Operation::setDialogActive( const bool active ) +{ + if( dlg() ) + { + if( active ) + { + activateSelection(); + dlg()->setActiveWindow(); + } + } +} + +/*! + * \brief Gets autoresume property + * \return Autoresume property. +* +* Autoresume property is used during automatic resuming operation. If operation is +* suspended and cursor is moved above dialog of the operation then operation is resumed +* automatically (if possible). It can be resumed only program call otherwise (see +* LightApp_SwitchOp for more description). This property is TRUE by default and may be +* changed with setAutoResumed() method call. +*/ +bool LightApp_Operation::isAutoResumed() const +{ + return myIsAutoResumed; +} + +/*! + * \brief Sets autoresume property + * \param on - Value to be set + * \return Autoresume property. +* +* Sets autoresume property (see isAutoResumed() for more description) +*/ +void LightApp_Operation::setAutoResumed( const bool on ) +{ + myIsAutoResumed = on; +} diff --git a/src/LightApp/LightApp_Operation.h b/src/LightApp/LightApp_Operation.h new file mode 100755 index 000000000..0ab698ffa --- /dev/null +++ b/src/LightApp/LightApp_Operation.h @@ -0,0 +1,90 @@ +// SALOME LightApp +// +// Copyright (C) 2005 CEA/DEN, EDF R&D +// +// +// +// File : LightApp_Operation.h +// Author : Sergey LITONIN +// Module : SALOME + + +#ifndef LightApp_Operation_H +#define LightApp_Operation_H + +#include + +class LightApp_Module; +class LightApp_Application; +class LightApp_Operation; +class LightApp_SelectionMgr; +class LightApp_Dialog; +class SUIT_Desktop; + +/* + Class : LightApp_Operation + Description : Base class for all operations +*/ + +/*! + * \brief Base class for all salome operations + * + * Base class for all salome operations (see SUIT_Operation for more description) +*/ +class LightApp_Operation : public SUIT_Operation +{ + Q_OBJECT + +public: + LightApp_Operation(); + virtual ~LightApp_Operation(); + + virtual void setModule( LightApp_Module* ); + LightApp_Module* module() const; + + bool isAutoResumed() const; + + virtual LightApp_Dialog* dlg() const; + +protected: + + // Methods redefined from base class + + virtual void startOperation(); + virtual void suspendOperation(); + virtual void resumeOperation(); + virtual void abortOperation(); + virtual void commitOperation(); + + // Additional virtual methods may be redefined by derived classes + + virtual void setDialogActive( const bool ); + virtual void activateSelection(); + virtual void selectionDone(); + + + // Axiluary methods + + SUIT_Desktop* desktop() const; + SUIT_Operation* activeOperation() const; + LightApp_SelectionMgr* selectionMgr() const; + void update( const int ); + void setAutoResumed( const bool ); + +private slots: + + virtual void onSelectionDone(); + +private: + + LightApp_Module* myModule; + bool myIsAutoResumed; +}; + +#endif + + + + + + diff --git a/src/LightApp/LightApp_Study.h b/src/LightApp/LightApp_Study.h index f107a4fb4..f60a763cc 100644 --- a/src/LightApp/LightApp_Study.h +++ b/src/LightApp/LightApp_Study.h @@ -39,10 +39,10 @@ public: /** @name methods to be used by modules*/ //@{ virtual std::vector GetListOfFiles () const; - virtual void SetListOfFiles (const std::vector theListOfFiles); + virtual void SetListOfFiles (const std::vector theListOfFiles); virtual std::string GetTmpDir (const char* theURL, - const bool isMultiFile); + const bool isMultiFile); virtual void RemoveTemporaryFiles (const bool isMultiFile) const; //@} diff --git a/src/LightApp/LightApp_SwitchOp.cxx b/src/LightApp/LightApp_SwitchOp.cxx new file mode 100755 index 000000000..305d186a1 --- /dev/null +++ b/src/LightApp/LightApp_SwitchOp.cxx @@ -0,0 +1,164 @@ +/** +* SALOME LightApp +* +* Copyright (C) 2005 CEA/DEN, EDF R&D +* +* +* +* File : LightApp_SwitchOp.h +* Author : Sergey LITONIN +* Module : SALOME +*/ + +#include "LightApp_SwitchOp.h" +#include "LightApp_Module.h" +#include "LightApp_Operation.h" +#include "LightApp_Dialog.h" +#include +#include +#include +#include +#include +#include +#include + +/*! + * \brief Constructor + * \param theParent - parent of object +* +* Creates instance of the object. Connects signals and slots. Install eveny filter +* on application +*/ +LightApp_SwitchOp::LightApp_SwitchOp( LightApp_Module* theModule ) +: QObject( 0 ), + myModule( theModule ) +{ + qApp->installEventFilter( this ); +} + +/*! + * \brief Destructor +*/ +LightApp_SwitchOp::~LightApp_SwitchOp() +{ + +} + +/*! + * \brief Get module +* +* Get module. Module is a parent of this class +*/ +LightApp_Module* LightApp_SwitchOp::module() const +{ + return myModule; +} + +/*! + * \brief Get study + * \return Active study of application (in current realisation) +* +* Get study +*/ +SUIT_Study* LightApp_SwitchOp::study() const +{ + return module()->application()->activeStudy(); +} + +/*! + * \brief Get operation by widget + * \param theWg - key widget to find operation + * \return Pointer to the operations if it is found or zero +* +* Find operation containing dialog with given widget +*/ +LightApp_Operation* LightApp_SwitchOp::operation( QWidget* theWg ) const +{ + // get dialog from widget + LightApp_Dialog* aDlg = 0; + QWidget* aParent = theWg; + while( aParent && !aParent->inherits( "LightApp_Dialog" ) ) + aParent = aParent->parentWidget(); + + if ( aParent && aParent->inherits( "LightApp_Dialog" ) ) + aDlg = (LightApp_Dialog*)aParent; + + // try to find operation corresponding to the dialog + if ( aDlg != 0 && study() != 0 ) + { + QPtrListIterator anIter( study()->operations() ); + while( SUIT_Operation* anOp = anIter.current() ) + { + if ( anOp->inherits( "LightApp_Operation" ) && + ((LightApp_Operation*)anOp)->dlg() == aDlg ) + return ((LightApp_Operation*)anOp); + ++anIter; + } + } + + return 0; +} + +/*! + * \brief Event filter + * \param theObj - object + * \param theEv - event +* +* Event filter. Catched signals off application. If event concerns to dialog then +* corresponding operation is found and activated. +*/ +bool LightApp_SwitchOp::eventFilter( QObject* theObj, QEvent* theEv ) +{ + if ( theObj->inherits( "QWidget" ) && ( theEv->type() == QEvent::Enter ) ) + { + QEvent::Type aType = theEv->type(); + LightApp_Operation* anOp = operation( (QWidget*)theObj ); + if ( anOp ) + { + switch ( aType ) + { + case QEvent::Enter: + { + if ( !anOp->isActive() && anOp->isAutoResumed() && + study() && !study()->blockingOperation( anOp ) ) + study()->resume( anOp ); + } + break; + + case QEvent::MouseButtonRelease: + case QEvent::MouseButtonPress: + case QEvent::MouseButtonDblClick: + case QEvent::MouseMove: + case QEvent::KeyPress: + case QEvent::KeyRelease: + { + if ( !anOp->isActive() ) + return true; + } + break; + + } + } + } + + return QObject::eventFilter( theObj, theEv ); +} + + + + + + + + + + + + + + + + + + + diff --git a/src/LightApp/LightApp_SwitchOp.h b/src/LightApp/LightApp_SwitchOp.h new file mode 100755 index 000000000..d635f81b5 --- /dev/null +++ b/src/LightApp/LightApp_SwitchOp.h @@ -0,0 +1,71 @@ +/** +* SALOME SalomeApp +* +* Copyright (C) 2005 CEA/DEN, EDF R&D +* +* +* +* File : LightApp_SwitchOp.h +* Author : Sergey LITONIN +* Module : SALOME +*/ + + + +#ifndef LightApp_SwitchOp_H +#define LightApp_SwitchOp_H + +#include + +class LightApp_Module; +class LightApp_Operation; +class QEvent; +class SUIT_Study; + +/*! + * \brief This class is intended for controling switching between operation + * + * Several operation may be launched simultaneously. This class is intended for + * controlling switching between such operations. This class works with operations having + * dialogs (activation of other operations is performed by SUIT_Study). When several + * operations is launched simultaneously corresponding dialogs are shown on the screen. + * Only one operation from the launched ones can be active (active operation). Other + * operations are suspended. As result only one dialog from shown ones can be active too. + * Other dialogs are disabled. This class installs event filter on application. When mouse + * cursor is moved above disabled dialog corresponding event is catched by this class. + * It finds corresponding operation and verify whether operation can be resumed (see + * SUIT_Study::isDenied( SUIT_Operation* ) method). If yes then current active + * operation is suspended and new operation activated. Module contains this class as a + * field. Then module is created instance of this class created too. + */ +class LightApp_SwitchOp : public QObject +{ + Q_OBJECT + +public: + + LightApp_SwitchOp( LightApp_Module* ); + virtual ~LightApp_SwitchOp(); + + // Redefined from base class + bool eventFilter( QObject*, QEvent* ); + +private: + + LightApp_Module* module() const; + LightApp_Operation* operation( QWidget* ) const; + SUIT_Study* study() const; + +private: + + LightApp_Module* myModule; + +}; + +#endif + + + + + + diff --git a/src/LightApp/LightApp_UpdateFlags.h b/src/LightApp/LightApp_UpdateFlags.h new file mode 100755 index 000000000..f7a0f9d06 --- /dev/null +++ b/src/LightApp/LightApp_UpdateFlags.h @@ -0,0 +1,37 @@ +// SALOME LightApp +// +// Copyright (C) 2005 CEA/DEN, EDF R&D +// +// +// +// File : LightApp_UpdateFlags.h +// Author : Sergey LITONIN +// Module : SALOME + + +#ifndef LightApp_UpdateFlags_H +#define LightApp_UpdateFlags_H + +/* + Enum : UpdateFlags + Description : Enumeration for update flags. First byte is reserved for LightApp_Module. + Modules derived from this model must use other 3 bytes to define their + own update flags +*/ + +typedef enum +{ + UF_Forced = 0x00000001, + UF_Model = 0x00000002, + UF_Viewer = 0x00000004, + UF_ObjBrowser = 0x00000008, + UF_Controls = 0x00000010, +} UpdateFlags; + +#endif + + + + + + diff --git a/src/LightApp/Makefile.in b/src/LightApp/Makefile.in index a1593ba7f..d2669e99b 100755 --- a/src/LightApp/Makefile.in +++ b/src/LightApp/Makefile.in @@ -19,6 +19,7 @@ EXPORT_HEADERS= LightApp.h \ LightApp_DataObject.h \ LightApp_DataOwner.h \ LightApp_DataSubOwner.h \ + LightApp_Dialog.h \ LightApp_GLSelector.h \ LightApp_Module.h \ LightApp_ModuleDlg.h \ @@ -26,12 +27,15 @@ EXPORT_HEADERS= LightApp.h \ LightApp_OBFilter.h \ LightApp_OBSelector.h \ LightApp_OCCSelector.h \ + LightApp_Operation.h \ LightApp_Selection.h \ LightApp_SelectionMgr.h \ LightApp_Study.h \ + LightApp_SwitchOp.h \ LightApp_Preferences.h \ LightApp_PreferencesDlg.h \ LightApp_RootObject.h \ + LightApp_UpdateFlags.h \ LightApp_VTKSelector.h \ LightApp_WidgetContainer.h @@ -48,6 +52,7 @@ LIB_SRC= LightApp_AboutDlg.cxx \ LightApp_DataObject.cxx \ LightApp_DataOwner.cxx \ LightApp_DataSubOwner.cxx \ + LightApp_Dialog.cxx \ LightApp_GLSelector.cxx \ LightApp_Module.cxx \ LightApp_ModuleDlg.cxx \ @@ -55,9 +60,11 @@ LIB_SRC= LightApp_AboutDlg.cxx \ LightApp_OBFilter.cxx \ LightApp_OBSelector.cxx \ LightApp_OCCSelector.cxx \ + LightApp_Operation.cxx \ LightApp_Selection.cxx \ LightApp_SelectionMgr.cxx \ LightApp_Study.cxx \ + LightApp_SwitchOp.cxx \ LightApp_Preferences.cxx \ LightApp_PreferencesDlg.cxx \ LightApp_VTKSelector.cxx \ @@ -66,14 +73,17 @@ LIB_SRC= LightApp_AboutDlg.cxx \ LIB_MOC = LightApp_AboutDlg.h \ LightApp_Application.h \ LightApp_DataModel.h \ + LightApp_Dialog.h \ LightApp_GLSelector.h \ LightApp_OBSelector.h \ LightApp_OCCSelector.h \ + LightApp_Operation.h \ LightApp_Module.h \ LightApp_ModuleDlg.h \ LightApp_NameDlg.h \ LightApp_SelectionMgr.h \ LightApp_Study.h \ + LightApp_SwitchOp.h \ LightApp_Preferences.h \ LightApp_PreferencesDlg.h \ LightApp_VTKSelector.h \ @@ -84,6 +94,7 @@ RESOURCES_FILES = icon_about.png \ icon_default.png \ icon_module.png \ icon_module_big.png \ + icon_select.png \ LightApp.ini CPPFLAGS+=$(PYTHON_INCLUDES) $(QT_INCLUDES) $(QWT_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) diff --git a/src/LightApp/resources/LightApp_images.po b/src/LightApp/resources/LightApp_images.po index bca041e60..8ae1d02cd 100644 --- a/src/LightApp/resources/LightApp_images.po +++ b/src/LightApp/resources/LightApp_images.po @@ -23,5 +23,8 @@ msgstr "icon_about.png" msgid "APP_DEFAULT_ICO" msgstr "icon_default.png" +msgid "ICON_SELECT" +msgstr "icon_select.png" + msgid "APP_LOGO_ICO" msgstr "icon_applogo.png" diff --git a/src/LightApp/resources/icon_select.png b/src/LightApp/resources/icon_select.png new file mode 100644 index 0000000000000000000000000000000000000000..99ebde65e86ffe25badbb1507f0286abbabd99ec GIT binary patch literal 976 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc3?z4jzqMyzU}gyL32{Ag(ZBjoa^c8=d#Wzp$P!dS9t;e literal 0 HcmV?d00001 diff --git a/src/Makefile.in b/src/Makefile.in index e1899da8d..9d6a17933 100755 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -34,6 +34,6 @@ VPATH=.:@srcdir@ SUBDIRS = Qtx SUIT STD CAF CAM SUITApp VTKViewer OCCViewer GLViewer \ LogWindow Event OBJECT Prs PyInterp PythonConsole ObjBrowser \ - RegistryDisplay Plot2d TOOLSGUI SOCC SVTK SPlot2d Session SalomeApp SALOME_SWIG SALOME_PY SUPERVGraph SALOME_PYQT Style ResExporter + RegistryDisplay Plot2d TOOLSGUI SOCC SVTK SPlot2d LightApp Session SalomeApp SALOME_SWIG SALOME_PY SUPERVGraph SALOME_PYQT Style ResExporter @MODULE@ diff --git a/src/OBJECT/Makefile.in b/src/OBJECT/Makefile.in index b6dfae0e1..9bcbc4cec 100755 --- a/src/OBJECT/Makefile.in +++ b/src/OBJECT/Makefile.in @@ -52,7 +52,7 @@ LIB_CLIENT_IDL = BIN = BIN_SRC = -CPPFLAGS+=$(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(QT_INCLUDES) $(OGL_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome +CPPFLAGS+=$(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(QT_INCLUDES) $(OGL_INCLUDES) LDFLAGS+= $(PYTHON_LIBS) $(VTK_LIBS) $(QT_LIBS) $(OGL_LIBS) $(CAS_LDPATH) -lTKV3d -lVTKViewer -lsuit diff --git a/src/Plot2d/Makefile.in b/src/Plot2d/Makefile.in index 65ccacd41..ef3d4742b 100755 --- a/src/Plot2d/Makefile.in +++ b/src/Plot2d/Makefile.in @@ -66,9 +66,9 @@ plot2d_settings.png \ plot2d_splines.png \ plot2d_zoom.png -CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(QWT_INCLUDES) -I$(KERNEL_ROOT_DIR)/include/salome +CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(QWT_INCLUDES) -LDFLAGS+=$(QWT_LIBS) $(QT_MT_LIBS) -L$(KERNEL_ROOT_DIR)/lib/salome -lsuit +LDFLAGS+=$(QWT_LIBS) $(QT_MT_LIBS) -lsuit @CONCLUDE@ diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index 03540eabd..7b1da6225 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -12,8 +12,6 @@ #include "SUIT_ResourceMgr.h" #include "SUIT_Application.h" -//#include "utilities.h" - #include "qapplication.h" #include #include @@ -381,7 +379,6 @@ QString Plot2d_ViewFrame::getInfo( const QPoint& pnt ) if ( xmark-2 == pnt.x() ) { xCoord = majXmark; xFound = true; -// MESSAGE("Plot2d_ViewFrame::getInfo : close maj X mark("< color.blue() ) cols[ "blue-min" ] = color.blue(); } - for (IList::Iterator it = mars.begin(); it != mars.end(); ++it) - MESSAGE("markers( " << it.key() << ") = " << it.data() ); - for (IList::Iterator it = lins.begin(); it != lins.end(); ++it) - MESSAGE("lines( " << it.key() << ") = " << it.data() ); - for (SList::Iterator it = cols.begin(); it != cols.end(); ++it) - MESSAGE("colors( " << it.key() << ") = " << it.data() ); #endif Plot2d_SetupViewDlg* dlg = new Plot2d_SetupViewDlg( this, true, mySecondY ); diff --git a/src/Prs/Makefile.in b/src/Prs/Makefile.in index 2ca3c38c5..73133a3e6 100755 --- a/src/Prs/Makefile.in +++ b/src/Prs/Makefile.in @@ -20,7 +20,7 @@ LIB_CLIENT_IDL = BIN = BIN_SRC = -CPPFLAGS+= -I${KERNEL_ROOT_DIR}/include/salome +CPPFLAGS+= LDFLAGS+= diff --git a/src/PyInterp/Makefile.in b/src/PyInterp/Makefile.in index 15e6ba005..1672f5ada 100755 --- a/src/PyInterp/Makefile.in +++ b/src/PyInterp/Makefile.in @@ -44,7 +44,7 @@ LIB_SRC= PyInterp_base.cxx \ LIB_MOC = PyInterp_Watcher.h -CPPFLAGS+= $(PYTHON_INCLUDES) $(QT_INCLUDES) -I$(KERNEL_ROOT_DIR)/include/salome +CPPFLAGS+= $(PYTHON_INCLUDES) $(QT_INCLUDES) LDFLAGS+= $(PYTHON_LIBS) $(QT_MT_LIBS) diff --git a/src/PyInterp/PyInterp_base.cxx b/src/PyInterp/PyInterp_base.cxx index 4c427d7ef..e9fdcb259 100644 --- a/src/PyInterp/PyInterp_base.cxx +++ b/src/PyInterp/PyInterp_base.cxx @@ -14,46 +14,29 @@ #include #include "PyInterp_base.h" // this include must be first (see PyInterp_base.h)! -#include #include -#include - - using namespace std; - -//#ifdef _DEBUG_ -//static int MYDEBUG = 1; -//static int MYPYDEBUG = 1; -//#else -//static int MYDEBUG = 0; -//static int MYPYDEBUG = 0; -//#endif - - PyLockWrapper::PyLockWrapper(PyThreadState* theThreadState): myThreadState(theThreadState), - mySaveThreadState(KERNEL_PYTHON::_gtstate) + mySaveThreadState(0) { PyEval_AcquireLock(); mySaveThreadState = PyThreadState_Swap(myThreadState); // store previous current in save, // set local in current -// if(MYDEBUG) MESSAGE(" PyLockWrapper "< #include -class SalomeApp_SelectionMgr; +class LightApp_SelectionMgr; class SalomeApp_Application; class QMenuBar; class QPopupMenu; @@ -40,7 +40,7 @@ private slots: void onSelMgrDestroyed(); private: - SalomeApp_SelectionMgr* mySelMgr; + LightApp_SelectionMgr* mySelMgr; SALOME_Selection( QObject* ); }; diff --git a/src/SALOME_SWIG/SALOMEGUI_Swig.cxx b/src/SALOME_SWIG/SALOMEGUI_Swig.cxx index 088c576eb..c4c2382c4 100644 --- a/src/SALOME_SWIG/SALOMEGUI_Swig.cxx +++ b/src/SALOME_SWIG/SALOMEGUI_Swig.cxx @@ -36,7 +36,7 @@ #include "SalomeApp_Study.h" #include "SalomeApp_Module.h" #include "SalomeApp_DataObject.h" -#include "SalomeApp_SelectionMgr.h" +#include "LightApp_SelectionMgr.h" #include "SALOME_Prs.h" #include "SOCC_ViewModel.h" #include "SVTK_ViewModel.h" @@ -241,8 +241,8 @@ public: TSelectedCountEvent() : myResult( 0 ) {} virtual void Execute() { if ( SalomeApp_Application* anApp = getApplication() ) { - SalomeApp_Study* aStudy = dynamic_cast( anApp->activeStudy() ); // for sure! - SalomeApp_SelectionMgr* aSelMgr = anApp->selectionMgr(); + SalomeApp_Study* aStudy = dynamic_cast( anApp->activeStudy() ); // for sure! + LightApp_SelectionMgr* aSelMgr = anApp->selectionMgr(); if ( aStudy && aSelMgr ) { SALOME_ListIO anIOList; aSelMgr->selectedObjects( anIOList ); @@ -268,8 +268,8 @@ public: TGetSelectedEvent( int theIndex ) : myIndex( theIndex ) {} virtual void Execute() { if ( SalomeApp_Application* anApp = getApplication() ) { - SalomeApp_Study* aStudy = dynamic_cast( anApp->activeStudy() ); // for sure! - SalomeApp_SelectionMgr* aSelMgr = anApp->selectionMgr(); + SalomeApp_Study* aStudy = dynamic_cast( anApp->activeStudy() ); // for sure! + LightApp_SelectionMgr* aSelMgr = anApp->selectionMgr(); if ( aStudy && aSelMgr ) { SALOME_ListIO anIOList; aSelMgr->selectedObjects( anIOList ); @@ -305,8 +305,8 @@ void SALOMEGUI_Swig::AddIObject( const char* theEntry ) TEvent( const char* theEntry ) : myEntry( theEntry ) {} virtual void Execute() { if ( SalomeApp_Application* anApp = getApplication() ) { - SalomeApp_Study* aStudy = dynamic_cast( anApp->activeStudy() ); // for sure! - SalomeApp_SelectionMgr* aSelMgr = anApp->selectionMgr(); + SalomeApp_Study* aStudy = dynamic_cast( anApp->activeStudy() ); // for sure! + LightApp_SelectionMgr* aSelMgr = anApp->selectionMgr(); if ( aStudy && aSelMgr ) { SALOME_ListIO anIOList; anIOList.Append( new SALOME_InteractiveObject( myEntry, "", "" ) ); @@ -329,11 +329,11 @@ void SALOMEGUI_Swig::RemoveIObject( const char* theEntry ) TEvent( const char* theEntry ) : myEntry( theEntry ) {} virtual void Execute() { if ( SalomeApp_Application* anApp = getApplication() ) { - SalomeApp_Study* aStudy = dynamic_cast( anApp->activeStudy() ); // for sure! - SalomeApp_SelectionMgr* aSelMgr = anApp->selectionMgr(); + SalomeApp_Study* aStudy = dynamic_cast( anApp->activeStudy() ); // for sure! + LightApp_SelectionMgr* aSelMgr = anApp->selectionMgr(); if ( aStudy && aSelMgr ) { SALOME_ListIO anIOList; - // VSR: temporary solution, until SalomeApp_SelectionMgr::unsetSelectedObjects() method appears + // VSR: temporary solution, until LightApp_SelectionMgr::unsetSelectedObjects() method appears // Lately this should be replaced by the following: // anIOList.Append( new SALOME_InteractiveObject( myEntry, "", "" ) ); // aSelMgr->unsetSelectedObjects( anIOList ); @@ -364,8 +364,8 @@ void SALOMEGUI_Swig::ClearIObjects() TEvent() {} virtual void Execute() { if ( SalomeApp_Application* anApp = getApplication() ) { - SalomeApp_Study* aStudy = dynamic_cast( anApp->activeStudy() ); // for sure! - SalomeApp_SelectionMgr* aSelMgr = anApp->selectionMgr(); + SalomeApp_Study* aStudy = dynamic_cast( anApp->activeStudy() ); // for sure! + LightApp_SelectionMgr* aSelMgr = anApp->selectionMgr(); if ( aStudy && aSelMgr ) aSelMgr->clearSelected(); } diff --git a/src/SOCC/Makefile.in b/src/SOCC/Makefile.in index 9ae919a0a..36b2aa697 100755 --- a/src/SOCC/Makefile.in +++ b/src/SOCC/Makefile.in @@ -27,14 +27,9 @@ LIB_SRC= SOCC_ViewModel.cxx \ LIB_MOC = SOCC_ViewModel.h \ SOCC_ViewWindow.h -LIB_CLIENT_IDL = SALOMEDS.idl \ - SALOME_Exception.idl \ - SALOME_ModuleCatalog.idl \ - SALOME_GenericObj.idl +CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) $(BOOST_CPPFLAGS) -CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) $(BOOST_CPPFLAGS) -I$(KERNEL_ROOT_DIR)/include/salome - -LDFLAGS+=$(QT_MT_LIBS) -L$(KERNEL_ROOT_DIR)/lib/salome -LIBS+= -lsuit -lSalomeObject -lSalomePrs -lOCCViewer -lOpUtil +LDFLAGS+=$(QT_MT_LIBS) +LIBS+= -lsuit -lSalomeObject -lSalomePrs -lOCCViewer @CONCLUDE@ diff --git a/src/SOCC/SOCC_ViewModel.cxx b/src/SOCC/SOCC_ViewModel.cxx index b78328d7f..dd9ebd70f 100755 --- a/src/SOCC/SOCC_ViewModel.cxx +++ b/src/SOCC/SOCC_ViewModel.cxx @@ -8,8 +8,11 @@ #include "ToolsGUI.h" -#include -#include CORBA_CLIENT_HEADER(SALOMEDS) +// Temporarily commented to avoid awful dependecy on SALOMEDS +// TODO: better mechanism of storing display/erse status in a study +// should be provided... +//#include +//#include CORBA_CLIENT_HEADER(SALOMEDS) #include #include @@ -17,13 +20,16 @@ #include #include -#include -#include -#include -#include +// Temporarily commented to avoid awful dependecy on SALOMEDS +// TODO: better mechanism of storing display/erse status in a study +// should be provided... +//#include +//#include +//#include +//#include -#include "SALOMEDSClient.hxx" -#include "SALOMEDS_StudyManager.hxx" +//#include "SALOMEDSClient.hxx" +//#include "SALOMEDS_StudyManager.hxx" #include @@ -31,21 +37,24 @@ // SalomeApp_Study::studyDS() does it as well, but -- here it is retrieved from // SALOMEDS::StudyManager - no linkage with SalomeApp. -static _PTR(Study) getStudyDS() -{ - SALOMEDSClient_Study* aStudy = NULL; - _PTR(StudyManager) aMgr( new SALOMEDS_StudyManager() ); +// Temporarily commented to avoid awful dependecy on SALOMEDS +// TODO: better mechanism of storing display/erse status in a study +// should be provided... +//static _PTR(Study) getStudyDS() +//{ +// SALOMEDSClient_Study* aStudy = NULL; +// _PTR(StudyManager) aMgr( new SALOMEDS_StudyManager() ); // get id of SUIT_Study, if it's a SalomeApp_Study, it will return // id of its underlying SALOMEDS::Study - SUIT_Application* app = SUIT_Session::session()->activeApplication(); - if ( !app ) return _PTR(Study)(aStudy); - SUIT_Study* stud = app->activeStudy(); - if ( !stud ) return _PTR(Study)(aStudy); - const int id = stud->id(); // virtual method, must return SALOMEDS_Study id +// SUIT_Application* app = SUIT_Session::session()->activeApplication(); +// if ( !app ) return _PTR(Study)(aStudy); +// SUIT_Study* stud = app->activeStudy(); +// if ( !stud ) return _PTR(Study)(aStudy); +// const int id = stud->id(); // virtual method, must return SALOMEDS_Study id // get SALOMEDS_Study with this id from StudyMgr - return aMgr->GetStudyByID( id ); -} +// return aMgr->GetStudyByID( id ); +//} SOCC_Viewer::SOCC_Viewer( bool DisplayTrihedron ) : OCCViewer_Viewer( DisplayTrihedron ) @@ -244,7 +253,10 @@ void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) return; // get SALOMEDS Study - _PTR(Study) study(getStudyDS()); + // Temporarily commented to avoid awful dependecy on SALOMEDS + // TODO: better mechanism of storing display/erse status in a study + // should be provided... + // _PTR(Study) study(getStudyDS()); // get context Handle (AIS_InteractiveContext) ic = getAISContext(); @@ -303,14 +315,16 @@ void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) bDisplayed = true; // Set visibility flag - Handle(SALOME_InteractiveObject) anObj = - Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() ); - if ( !anObj.IsNull() && anObj->hasEntry() ) - { - if ( study ) - ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); - } - + // Temporarily commented to avoid awful dependecy on SALOMEDS + // TODO: better mechanism of storing display/erse status in a study + // should be provided... + //Handle(SALOME_InteractiveObject) anObj = + // Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() ); + //if ( !anObj.IsNull() && anObj->hasEntry() ) + //{ + // if ( study ) + // ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); + //} break; } } @@ -329,13 +343,16 @@ void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) ic->Display( anAIS, false ); // Set visibility flag - Handle(SALOME_InteractiveObject) anObj = - Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() ); - if ( !anObj.IsNull() && anObj->hasEntry() ) - { - if ( study ) - ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); - } + // Temporarily commented to avoid awful dependecy on SALOMEDS + // TODO: better mechanism of storing display/erse status in a study + // should be provided... + //Handle(SALOME_InteractiveObject) anObj = + // Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() ); + //if ( !anObj.IsNull() && anObj->hasEntry() ) + //{ + // if ( study ) + // ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); + //} // Deactivate object if necessary if ( !anOCCPrs->ToActivate() ) @@ -356,7 +373,10 @@ void SOCC_Viewer::Erase( const SALOME_OCCPrs* prs, const bool forced ) return; // get SALOMEDS Study - _PTR(Study) study(getStudyDS()); + // Temporarily commented to avoid awful dependecy on SALOMEDS + // TODO: better mechanism of storing display/erse status in a study + // should be provided... + // _PTR(Study) study(getStudyDS()); // get context Handle(AIS_InteractiveContext) ic = getAISContext(); @@ -373,16 +393,19 @@ void SOCC_Viewer::Erase( const SALOME_OCCPrs* prs, const bool forced ) ic->Erase( anAIS, false, forced ? false : true ); // Set visibility flag if necessary - if ( !forced ) - { - Handle(SALOME_InteractiveObject) anObj = - Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() ); - if ( !anObj.IsNull() && anObj->hasEntry() ) - { - if ( study ) - ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); - } - } + // Temporarily commented to avoid awful dependecy on SALOMEDS + // TODO: better mechanism of storing display/erse status in a study + // should be provided... + //if ( !forced ) + //{ + // Handle(SALOME_InteractiveObject) anObj = + // Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() ); + // if ( !anObj.IsNull() && anObj->hasEntry() ) + // { + // if ( study ) + // ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); + // } + //} } } } @@ -394,7 +417,10 @@ void SOCC_Viewer::Erase( const SALOME_OCCPrs* prs, const bool forced ) void SOCC_Viewer::EraseAll( const bool forced ) { // get SALOMEDS Study - _PTR(Study) study(getStudyDS()); + // Temporarily commented to avoid awful dependecy on SALOMEDS + // TODO: better mechanism of storing display/erse status in a study + // should be provided... + // _PTR(Study) study(getStudyDS()); // get context Handle(AIS_InteractiveContext) ic = getAISContext(); @@ -415,15 +441,18 @@ void SOCC_Viewer::EraseAll( const bool forced ) ic->Erase( anIO, false, forced ? false : true ); // Set visibility flag if necessary - if ( !forced ) { - Handle(SALOME_InteractiveObject) anObj = - Handle(SALOME_InteractiveObject)::DownCast( anIO->GetOwner() ); - - if ( !anObj.IsNull() && anObj->hasEntry() ) { - if ( study ) - ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); - } - } + // Temporarily commented to avoid awful dependecy on SALOMEDS + // TODO: better mechanism of storing display/erse status in a study + // should be provided... + //if ( !forced ) { + // Handle(SALOME_InteractiveObject) anObj = + // Handle(SALOME_InteractiveObject)::DownCast( anIO->GetOwner() ); + + // if ( !anObj.IsNull() && anObj->hasEntry() ) { + // if ( study ) + // ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); + // } + //} } // display trihedron if necessary diff --git a/src/SUIT/SUIT_DataObject.cxx b/src/SUIT/SUIT_DataObject.cxx index 7fdc04631..1987bbd27 100755 --- a/src/SUIT/SUIT_DataObject.cxx +++ b/src/SUIT/SUIT_DataObject.cxx @@ -276,6 +276,9 @@ bool SUIT_DataObject::replaceChild( SUIT_DataObject* src, SUIT_DataObject* trg, void SUIT_DataObject::reparentChildren( const SUIT_DataObject* obj ) { + if ( !obj ) + return; + DataObjectList lst; obj->children( lst ); for ( DataObjectListIterator it( lst ); it.current(); ++it ) diff --git a/src/SUIT/SUIT_Study.cxx b/src/SUIT/SUIT_Study.cxx index 9c2af0282..799641f16 100755 --- a/src/SUIT/SUIT_Study.cxx +++ b/src/SUIT/SUIT_Study.cxx @@ -192,6 +192,10 @@ void SUIT_Study::setRoot( SUIT_DataObject* obj ) if ( myRoot == obj ) return; + // This is necessary in order not to destroy the complete tree of objects + if ( obj ) + obj->reparentChildren( myRoot ); + delete myRoot; myRoot = obj; } -- 2.39.2