From 0c6715aedcbba0d5ff37669f99e7c7a325c582cc Mon Sep 17 00:00:00 2001 From: san Date: Fri, 30 Jun 2006 13:04:15 +0000 Subject: [PATCH] Debug by NEPTUNE pre-processor team --- src/LightApp/LightApp_DataModel.cxx | 15 +++++++++++++- src/LightApp/LightApp_Module.cxx | 2 +- src/LightApp/LightApp_Module.h | 2 +- src/LightApp/LightApp_OBSelector.cxx | 2 +- src/LightApp/LightApp_Selection.cxx | 10 +++++++++- src/LightApp/LightApp_Selection.h | 9 ++------- src/LightApp/LightApp_ShowHideOp.cxx | 18 +++++++++++++---- src/Plot2d/Plot2d_ViewWindow.cxx | 1 + src/PythonConsole/PythonConsole.h | 4 ++-- src/PythonConsole/PythonConsole_PyConsole.cxx | 12 +++++++++++ src/PythonConsole/PythonConsole_PyConsole.h | 2 +- src/PythonConsole/PythonConsole_PyEditor.cxx | 20 ++++++++++++++++++- src/PythonConsole/PythonConsole_PyEditor.h | 3 ++- src/SUIT/SUIT_DataOwner.cxx | 2 +- src/SUIT/SUIT_DataOwner.h | 1 + src/SalomeApp/SalomeApp_Module.h | 2 +- 16 files changed, 82 insertions(+), 23 deletions(-) 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..4c289cb8a 100644 --- a/src/LightApp/LightApp_Selection.h +++ b/src/LightApp/LightApp_Selection.h @@ -37,13 +37,7 @@ class LightApp_DataOwner; class LightApp_Study; class SUIT_ViewWindow; -/*! - \class LightApp_Selection - Custom selection class, allowing to build popup with rules on the base - of owners selected in all selectors (popup client has more priority). - It is able to return values of standard object properties - (isVisible,isComponent,canBeDisplayed,isReference, etc) -*/ + class LIGHTAPP_EXPORT LightApp_Selection : public QtxPopupMgr::Selection { public: @@ -65,6 +59,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/Plot2d/Plot2d_ViewWindow.cxx b/src/Plot2d/Plot2d_ViewWindow.cxx index e562e30dc..b786b0e2a 100755 --- a/src/Plot2d/Plot2d_ViewWindow.cxx +++ b/src/Plot2d/Plot2d_ViewWindow.cxx @@ -491,6 +491,7 @@ void Plot2d_ViewWindow::onDumpView() */ QImage Plot2d_ViewWindow::dumpView() { + myViewFrame->repaint( true ); QPixmap px = QPixmap::grabWindow( myViewFrame->winId() ); return px.convertToImage(); } 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 3093b89de..d2f608082 100755 --- a/src/PythonConsole/PythonConsole_PyEditor.cxx +++ b/src/PythonConsole/PythonConsole_PyEditor.cxx @@ -101,7 +101,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 ); @@ -157,6 +158,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 */ @@ -659,6 +671,8 @@ void PythonConsole_PyEditor::customEvent(QCustomEvent* e) _currentPrompt = READY_PROMPT; setText(_currentPrompt); viewport()->unsetCursor(); + if( myIsInLoop ) + qApp->exit_loop(); break; } case PyInterp_Event::INCOMPLETE: @@ -667,6 +681,8 @@ void PythonConsole_PyEditor::customEvent(QCustomEvent* e) _currentPrompt = DOTS_PROMPT; setText(_currentPrompt); viewport()->unsetCursor(); + if( myIsInLoop ) + qApp->exit_loop(); break; } default: @@ -694,6 +710,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 004b40021..f86bd0825 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; }; -- 2.39.2