From: skl Date: Thu, 30 Nov 2006 07:55:02 +0000 (+0000) Subject: Some corrections for NEPTUNE. X-Git-Tag: V3_2_4pre1~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=483db41037c810374159a3443c66056981d2dcdf;p=modules%2Fgui.git Some corrections for NEPTUNE. --- diff --git a/src/LightApp/LightApp_DataModel.cxx b/src/LightApp/LightApp_DataModel.cxx index 9fe3b086a..702ef7b33 100644 --- a/src/LightApp/LightApp_DataModel.cxx +++ b/src/LightApp/LightApp_DataModel.cxx @@ -110,16 +110,29 @@ void LightApp_DataModel::update( LightApp_DataObject*, LightApp_Study* ) { LightApp_ModuleObject* modelRoot = dynamic_cast( root() ); DataObjectList ch; + QMap aMap; if( modelRoot ) { ch = modelRoot->children(); for ( DataObjectListIterator it( ch ); it.current(); ++it ) it.current()->setParent( 0 ); } + build(); + + modelRoot = dynamic_cast( root() ); + if( modelRoot ) + { + DataObjectList new_ch = modelRoot->children(); + for ( DataObjectListIterator it1( new_ch ); it1.current(); ++it1 ) + aMap.insert( it1.current(), 0 ); + } + updateWidgets(); + for( DataObjectListIterator it( ch ); it.current(); ++it ) - delete it.current(); + if( !aMap.contains( it.current() ) ) + delete it.current(); } /*! diff --git a/src/LightApp/LightApp_Module.cxx b/src/LightApp/LightApp_Module.cxx index 9c1a71335..da2a555c7 100644 --- a/src/LightApp/LightApp_Module.cxx +++ b/src/LightApp/LightApp_Module.cxx @@ -340,7 +340,7 @@ QtxPopupMgr* LightApp_Module::popupMgr() myPopupMgr->insert( eraseAll, -1, 0 ); myPopupMgr->insert( separator(), -1, 0 ); - QString oneAndNotActive = "( count( $component ) = 1 ) and ( component != activeModule )"; + QString oneAndNotActive = "( count( $component ) = 1 ) and ( not( activeModule in $component ) )"; QString uniform = "true in $canBeDisplayed and %1 and ( activeModule = '%2' )"; uniform = uniform.arg( oneAndNotActive ).arg( name() ); myPopupMgr->setRule( disp, /*QString( "( not isVisible ) and " ) + */ uniform, true ); diff --git a/src/LightApp/LightApp_Module.h b/src/LightApp/LightApp_Module.h index 17a95366f..de4e6600f 100644 --- a/src/LightApp/LightApp_Module.h +++ b/src/LightApp/LightApp_Module.h @@ -84,6 +84,7 @@ public: virtual void studyActivated() {}; virtual LightApp_Displayer* displayer(); + virtual LightApp_Selection* createSelection() const; public slots: virtual bool activateModule( SUIT_Study* ); @@ -107,7 +108,6 @@ protected: LightApp_Preferences* preferences() const; virtual CAM_DataModel* createDataModel(); - virtual LightApp_Selection* createSelection() const; int addPreference( const QString& label ); int addPreference( const QString& label, const int pId, const int = -1, diff --git a/src/LightApp/LightApp_OBSelector.cxx b/src/LightApp/LightApp_OBSelector.cxx index 3db252685..dd2e65f05 100644 --- a/src/LightApp/LightApp_OBSelector.cxx +++ b/src/LightApp/LightApp_OBSelector.cxx @@ -69,7 +69,7 @@ void LightApp_OBSelector::getSelection( SUIT_DataOwnerPtrList& theList ) const for ( DataObjectListIterator it( objlist ); it.current(); ++it ) { LightApp_DataObject* obj = dynamic_cast( it.current() ); - if ( obj ) + if ( obj && !obj->entry().isEmpty() && !obj->componentDataType().isEmpty() && !obj->name().isEmpty() ) { #ifndef DISABLE_SALOMEOBJECT Handle(SALOME_InteractiveObject) aSObj = new SALOME_InteractiveObject diff --git a/src/LightApp/LightApp_Selection.cxx b/src/LightApp/LightApp_Selection.cxx index 5620c41d3..fe0a15207 100644 --- a/src/LightApp/LightApp_Selection.cxx +++ b/src/LightApp/LightApp_Selection.cxx @@ -86,7 +86,7 @@ void LightApp_Selection::init( const QString& client, LightApp_SelectionMgr* mgr LightApp_DataOwner* sowner = dynamic_cast( (*anIt ).get() ); if( sowner ) { - entry = myStudy->referencedToEntry( sowner->entry() ); + entry = referencedToEntry( sowner->entry() ); if( entries.contains( entry ) ) continue; @@ -100,6 +100,11 @@ void LightApp_Selection::init( const QString& client, LightApp_SelectionMgr* mgr } } +QString LightApp_Selection::referencedToEntry( const QString& entry ) const +{ + return myStudy->referencedToEntry( entry ); +} + /*! Gets count of entries. */ @@ -147,6 +152,9 @@ QtxValue LightApp_Selection::param( const int ind, const QString& p ) const else if( p=="isReference" ) return QtxValue( isReference( ind ), false ); + else if( p=="displayer" ) + return param( ind, "component" ); + else if( p=="canBeDisplayed" ) { QString mod_name = app->moduleTitle( param( ind, "component" ).toString() ); diff --git a/src/LightApp/LightApp_Selection.h b/src/LightApp/LightApp_Selection.h index 846699f3b..7756a767d 100644 --- a/src/LightApp/LightApp_Selection.h +++ b/src/LightApp/LightApp_Selection.h @@ -65,6 +65,7 @@ protected: LightApp_Study* study() const { return myStudy; } QString activeViewType() const; SUIT_ViewWindow* activeVW() const; + virtual QString referencedToEntry( const QString& ) const; private: QString myPopupClient; diff --git a/src/LightApp/LightApp_ShowHideOp.cxx b/src/LightApp/LightApp_ShowHideOp.cxx index a329cf889..657e30d9d 100644 --- a/src/LightApp/LightApp_ShowHideOp.cxx +++ b/src/LightApp/LightApp_ShowHideOp.cxx @@ -63,17 +63,25 @@ void LightApp_ShowHideOp::startOperation() } LightApp_SelectionMgr* mgr = app->selectionMgr(); - LightApp_Selection sel; sel.init( "", mgr ); - if( sel.count()==0 && myActionType!=ERASE_ALL ) + LightApp_Module* mod = dynamic_cast( app->activeModule() ); + if( !mod ) + return; + + LightApp_Selection* sel = mod->createSelection(); + if( !sel ) + return; + + sel->init( "", mgr ); + if( sel->count()==0 && myActionType!=ERASE_ALL ) { abort(); return; } QString mod_name; - if( sel.count()>0 ) + if( sel->count()>0 ) { - QString aStr = sel.param( 0, "component" ).toString(); + QString aStr = sel->param( 0, "displayer" ).toString(); mod_name = app->moduleTitle( aStr ); } else if( app->activeModule() ) @@ -144,4 +152,6 @@ void LightApp_ShowHideOp::startOperation() } d->UpdateViewer(); commit(); + + delete sel; } diff --git a/src/PythonConsole/PythonConsole.h b/src/PythonConsole/PythonConsole.h index 98fa563c4..d9bbf65a2 100755 --- a/src/PythonConsole/PythonConsole.h +++ b/src/PythonConsole/PythonConsole.h @@ -40,12 +40,12 @@ #ifdef _DEBUG #undef _DEBUG -#include +//#include #define _DEBUG #else // _DEBUG -#include +//#include #endif // _DEBUG diff --git a/src/PythonConsole/PythonConsole_PyConsole.cxx b/src/PythonConsole/PythonConsole_PyConsole.cxx index 9eecd0f15..9c8f85237 100755 --- a/src/PythonConsole/PythonConsole_PyConsole.cxx +++ b/src/PythonConsole/PythonConsole_PyConsole.cxx @@ -16,6 +16,8 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + +#include #include "PythonConsole_PyConsole.h" #include "PythonConsole_PyEditor.h" #include "PyInterp_base.h" @@ -63,6 +65,16 @@ void PythonConsole::exec( const QString& command ) myEditor->exec( command ); } +/*! + Blocks execution of main application until command is executed + \param command - string with command and arguments +*/ +void PythonConsole::execAndWait( const QString& command ) +{ + if ( myEditor ) + myEditor->execAndWait( command ); +} + /*! Changes font of python console \param f - new font diff --git a/src/PythonConsole/PythonConsole_PyConsole.h b/src/PythonConsole/PythonConsole_PyConsole.h index 4978214fb..b3364e597 100755 --- a/src/PythonConsole/PythonConsole_PyConsole.h +++ b/src/PythonConsole/PythonConsole_PyConsole.h @@ -39,7 +39,7 @@ public: virtual void setFont( const QFont& ); void exec( const QString& command ); - + void execAndWait( const QString& command ); protected: PyInterp_base* myInterp; PythonConsole_PyEditor* myEditor; diff --git a/src/PythonConsole/PythonConsole_PyEditor.cxx b/src/PythonConsole/PythonConsole_PyEditor.cxx index e32bf03ee..c48c534fd 100755 --- a/src/PythonConsole/PythonConsole_PyEditor.cxx +++ b/src/PythonConsole/PythonConsole_PyEditor.cxx @@ -104,7 +104,8 @@ private: */ PythonConsole_PyEditor::PythonConsole_PyEditor(PyInterp_base* theInterp, QWidget *theParent, const char* theName): QTextEdit(theParent,theName), - myInterp( 0 ) + myInterp( 0 ), + myIsInLoop( false ) { QString fntSet( "" ); QFont aFont = SUIT_Tools::stringToFont( fntSet ); @@ -162,6 +163,17 @@ void PythonConsole_PyEditor::exec( const QString& command ) handleReturn(); } +void PythonConsole_PyEditor::execAndWait( const QString& command ) +{ + if( myIsInLoop ) + return; + + myIsInLoop = true; + exec( command ); + qApp->enter_loop(); + myIsInLoop = false; +} + /*! Called when an handleReturn */ @@ -666,6 +678,8 @@ void PythonConsole_PyEditor::customEvent(QCustomEvent* e) _currentPrompt = READY_PROMPT; setText(_currentPrompt); viewport()->unsetCursor(); + if( myIsInLoop ) + qApp->exit_loop(); break; } case PyInterp_Event::INCOMPLETE: @@ -674,6 +688,8 @@ void PythonConsole_PyEditor::customEvent(QCustomEvent* e) _currentPrompt = DOTS_PROMPT; setText(_currentPrompt); viewport()->unsetCursor(); + if( myIsInLoop ) + qApp->exit_loop(); break; } default: @@ -707,6 +723,8 @@ void PythonConsole_PyEditor::onPyInterpChanged( PyInterp_base* interp ) _isInHistory = false; setText(_currentPrompt); viewport()->unsetCursor(); + if( myIsInLoop ) + qApp->exit_loop(); } else { clear(); diff --git a/src/PythonConsole/PythonConsole_PyEditor.h b/src/PythonConsole/PythonConsole_PyEditor.h index d362b1f8c..b353ee4da 100755 --- a/src/PythonConsole/PythonConsole_PyEditor.h +++ b/src/PythonConsole/PythonConsole_PyEditor.h @@ -47,6 +47,7 @@ public: bool isCommand(const QString& str) const; virtual void exec( const QString& command ); + void execAndWait( const QString& command ); protected: virtual void contentsDropEvent( QDropEvent* event ); @@ -65,7 +66,7 @@ private: QString _buf; QString _currentCommand; QString _currentPrompt; - bool _isInHistory; + bool _isInHistory, myIsInLoop; PyInterp_base* myInterp; diff --git a/src/SUIT/SUIT_DataOwner.cxx b/src/SUIT/SUIT_DataOwner.cxx index 826bd89bf..d97a249d3 100755 --- a/src/SUIT/SUIT_DataOwner.cxx +++ b/src/SUIT/SUIT_DataOwner.cxx @@ -162,5 +162,5 @@ uint SUIT_DataOwnerPtrList::remove(const SUIT_DataOwnerPtr& x ) */ bool operator<( const SUIT_DataOwnerPtr& p1, const SUIT_DataOwnerPtr& p2 ) { - return p1.get()operator<( *p2 ); } diff --git a/src/SUIT/SUIT_DataOwner.h b/src/SUIT/SUIT_DataOwner.h index bc2ef2615..81fe710b8 100755 --- a/src/SUIT/SUIT_DataOwner.h +++ b/src/SUIT/SUIT_DataOwner.h @@ -42,6 +42,7 @@ public: virtual ~SUIT_DataOwner();//!< destructor //! compare function virtual bool isEqual( const SUIT_DataOwner& ) const = 0; + virtual bool operator<( const SUIT_DataOwner& ) const = 0; }; /*! \typedef SUIT_DataOwnerPtr diff --git a/src/SalomeApp/SalomeApp_Module.h b/src/SalomeApp/SalomeApp_Module.h index 07f4c0620..87ca5aad7 100644 --- a/src/SalomeApp/SalomeApp_Module.h +++ b/src/SalomeApp/SalomeApp_Module.h @@ -59,10 +59,10 @@ public: virtual void storeVisualParameters(int savePoint); virtual void restoreVisualParameters(int savePoint); + virtual LightApp_Selection* createSelection() const; protected: virtual CAM_DataModel* createDataModel(); - virtual LightApp_Selection* createSelection() const; virtual void extractContainers( const SALOME_ListIO&, SALOME_ListIO& ) const; };