From 9b90197d4313ed2f2ac58f731e8bcb8a0b8698fc Mon Sep 17 00:00:00 2001 From: jfa Date: Wed, 28 Dec 2005 08:38:00 +0000 Subject: [PATCH] Join modifications from branch BR_3_1_0deb --- INSTALL | 4 +- Makefile.in | 3 +- bin/VERSION | 2 +- bin/runLightSalome.sh | 14 + build_configure | 2 +- doc/salome/GUI_index.html | 95 ++ doc/salome/tui/SUIT/doxyfile | 2 +- src/LightApp/LightApp_Application.cxx | 108 +- src/LightApp/LightApp_Module.cxx | 10 +- src/LightApp/LightApp_PreferencesDlg.cxx | 4 +- src/LightApp/LightApp_PreferencesDlg.h | 4 + src/LightApp/LightApp_ShowHideOp.cxx | 12 +- src/LightApp/resources/LightApp.xml | 3 + src/LightApp/resources/LightApp_msg_en.po | 32 +- src/OCCViewer/OCCViewer_ViewWindow.cxx | 22 +- src/ObjBrowser/OB_Browser.cxx | 26 +- src/ObjBrowser/OB_Browser.h | 2 +- src/ObjBrowser/OB_ListItem.cxx | 11 + src/ObjBrowser/OB_ListItem.h | 1 + src/ObjBrowser/OB_ListView.cxx | 36 + src/ObjBrowser/OB_ListView.h | 7 + src/Plot2d/Plot2d_ViewFrame.cxx | 25 +- src/Plot2d/Plot2d_ViewWindow.cxx | 27 +- src/PyInterp/PyInterp_Dispatcher.cxx | 9 +- src/PyInterp/PyInterp_base.cxx | 77 +- src/PyInterp/PyInterp_base.h | 17 +- src/PythonConsole/PythonConsole_PyEditor.cxx | 6 +- src/PythonConsole/PythonConsole_PyInterp.cxx | 1 + src/Qtx/QtxListResourceEdit.cxx | 10 +- src/Qtx/QtxListResourceEdit.h | 1 + .../SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx | 174 ++-- .../SALOME_PYQT_GUI/SALOME_PYQT_PyInterp.cxx | 15 +- src/SALOME_PYQT/SalomePyQt/SalomePyQt_v4.sip | 2 +- src/STD/STD_Application.cxx | 6 +- src/STD/STD_TabDesktop.cxx | 2 +- src/STD/resources/STD_msg_en.po | 2 +- src/SUIT/SUIT_MessageBox.cxx | 397 +++++--- src/SUIT/SUIT_MessageBox.h | 9 + src/SVTK/SVTK_ViewModel.cxx | 919 +++++++++--------- src/SalomeApp/SalomeApp_Application.cxx | 160 ++- src/SalomeApp/SalomeApp_Application.h | 2 +- src/SalomeApp/SalomeApp_PyInterp.cxx | 26 +- src/SalomeApp/resources/SalomeApp.xml | 50 +- src/SalomeApp/resources/SalomeApp_msg_en.po | 19 +- src/Session/SALOME_Session_Server.cxx | 6 +- src/Session/Session_ServerThread.cxx | 1 + 46 files changed, 1375 insertions(+), 988 deletions(-) create mode 100755 bin/runLightSalome.sh create mode 100755 doc/salome/GUI_index.html diff --git a/INSTALL b/INSTALL index dab02b3a0..dcef3b788 100644 --- a/INSTALL +++ b/INSTALL @@ -1,3 +1,3 @@ -This is the version 3.1.0b1 of SALOMEGUI +This is the version 3.1.0 of SALOMEGUI Compatible with : - - KERNEL 3.1.0b1 + - KERNEL 3.1.0 diff --git a/Makefile.in b/Makefile.in index 41e9d3c71..989c6a476 100644 --- a/Makefile.in +++ b/Makefile.in @@ -75,7 +75,8 @@ uc_clear.png \ channel.cfg \ BIN_SCRIPT= VERSION \ -runLightSalome.csh +runLightSalome.csh \ +runLightSalome.sh # copy header files in common directory OWN_CONFIG_H=@OWN_CONFIG_H@ diff --git a/bin/VERSION b/bin/VERSION index adc8613cc..fe6986e15 100755 --- a/bin/VERSION +++ b/bin/VERSION @@ -1 +1 @@ -THIS IS SALOME - SALOMEGUI VERSION: 3.1.0b1 +THIS IS SALOME - SALOMEGUI VERSION: 3.1.0 diff --git a/bin/runLightSalome.sh b/bin/runLightSalome.sh new file mode 100755 index 000000000..f99a8125f --- /dev/null +++ b/bin/runLightSalome.sh @@ -0,0 +1,14 @@ +#!/bin/bash -f + +if [ -z "$SUITRoot" ] ; then + export SUITRoot=${GUI_ROOT_DIR}/share/salome +fi +# this variable necessary for loading .ini or .xml file +if [ -z "$LightAppConfig" ] ; then + export LightAppConfig=${GUI_ROOT_DIR}/share/salome/resources +fi +if [ -z "$LightAppResources" ] ; then + export LightAppResources=${GUI_ROOT_DIR}/share/salome/resources +fi + +SUITApp LightApp -style salome $* & diff --git a/build_configure b/build_configure index 873825f0b..ec5cce644 100755 --- a/build_configure +++ b/build_configure @@ -109,7 +109,7 @@ fi # make a link allowing AC_OUTPUT to find the salome_adm/.../*.in files echo "" >> configure.in_tmp1 -echo 'ln -fs ${KERNEL_ROOT_DIR}/salome_adm ${ROOT_SRCDIR}/salome_adm' >> configure.in_tmp1 +echo 'ln -fs ${KERNEL_ROOT_DIR}/salome_adm ${ROOT_SRCDIR}/.' >> configure.in_tmp1 echo "" >> configure.in_tmp1 echo "AC_OUTPUT([ \\" >> configure.in_tmp1 diff --git a/doc/salome/GUI_index.html b/doc/salome/GUI_index.html new file mode 100755 index 000000000..465e3ea9d --- /dev/null +++ b/doc/salome/GUI_index.html @@ -0,0 +1,95 @@ + + + + + + + + Gui Module Documentation + + + +
  +
+
                   +   
+ + + + + + + + + +
+ + + +
+ +
+
+
+

GUI MODULE Documentation

+
+
+ + + + + +
+
+ +
+

Application-About.png +     

+
+ +
+ + + + +
+
+
+
+
+ +
+ +
GUI Documentation
+ +
+ +
+ +

+
+ +
+ +
TUI Documentation
+ +
+ +
+ +

+
+
+
+
+
+
+ + diff --git a/doc/salome/tui/SUIT/doxyfile b/doc/salome/tui/SUIT/doxyfile index 02d73d5e5..7d82b803d 100755 --- a/doc/salome/tui/SUIT/doxyfile +++ b/doc/salome/tui/SUIT/doxyfile @@ -3,7 +3,7 @@ #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- -PROJECT_NAME = "SALOME v.3.1.0a" +PROJECT_NAME = "SALOME v.3.1.0" PROJECT_NUMBER = id#1.1 OUTPUT_DIRECTORY = ../ CREATE_SUBDIRS = NO diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 3aa523b1c..50f5fe543 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -41,6 +41,7 @@ #include #include +#include #include #include @@ -76,15 +77,7 @@ #include #include #include - -#define OBJECT_BROWSER_WIDTH 300 -#define OBJECT_COLUMN_WIDTH 150 - -#ifdef WIN32 -#define DEFAULT_BROWSER "start iexplore.exe" -#else -#define DEFAULT_BROWSER "mozilla" -#endif +#include #define FIRST_HELP_ID 1000000 @@ -338,7 +331,7 @@ void LightApp_Application::createActions() //! Preferences createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIconSet(), tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ), - CTRL+Key_P, desk, false, this, SLOT( onPreferences() ) ); + CTRL+Key_F, desk, false, this, SLOT( onPreferences() ) ); //! Help for modules int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 ); @@ -485,8 +478,8 @@ void LightApp_Application::createActions() createMenu( a, newWinMenu, -1 ); } - createAction( RenameId, tr( "TOT_RENAME" ), QIconSet(), tr( "MEN_RENAME" ), tr( "PRP_RENAME" ), - 0, desk, false, this, SLOT( onRenameWindow() ) ); + createAction( RenameId, tr( "TOT_RENAME" ), QIconSet(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ), + SHIFT+Key_R, desk, false, this, SLOT( onRenameWindow() ) ); createMenu( RenameId, windowMenu, -1 ); connect( modGroup, SIGNAL( selected( QAction* ) ), this, SLOT( onModuleActivation( QAction* ) ) ); @@ -780,17 +773,13 @@ public: postEvent (qApp, ce2000); } } - - if( myStatus != 0 || myApp.isEmpty()) + if( myStatus != 0) { - myParams = ""; - aCommand.sprintf("%s %s %s", QString(DEFAULT_BROWSER).latin1(),myParams.latin1(), myHelpFile.latin1()); - myStatus = system(aCommand); - if(myStatus != 0) - { - QCustomEvent* ce2001 = new QCustomEvent (2001); - postEvent (qApp, ce2001); - } + qApp->lock(); + SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"), + QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").arg(myApp).arg(myHelpFile), + QObject::tr("BUT_OK")); + qApp->unlock(); } } @@ -821,8 +810,15 @@ void LightApp_Application::onHelpContentsModule() QString anApp = resMgr->stringValue("ExternalBrowser", "application"); QString aParams = resMgr->stringValue("ExternalBrowser", "parameters"); - RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile); - rs->start(); + if (!anApp.isEmpty()) { + RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile); + rs->start(); + } + else { + SUIT_MessageBox::warn1(desktop(), tr("WRN_WARNING"), + tr("DEFINE_EXTERNAL_BROWSER"), + tr("BUT_OK")); + } } /*!Sets enable or disable some actions on selection changed.*/ @@ -888,11 +884,21 @@ void LightApp_Application::addWindow( QWidget* wid, const int flag, const int st myWindows[flag]->setResizeEnabled( true ); myWindows[flag]->setCloseMode( QDockWindow::Always ); myWindows[flag]->setName( QString( "dock_window_%1" ).arg( flag ) ); + myWindows[flag]->setFixedExtentWidth( wid->width() ); + myWindows[flag]->setFixedExtentHeight( wid->height() ); } QFont f; if( wid->inherits( "PythonConsole" ) ) - f = ( ( PythonConsole* )wid )->font(); + { + if( resourceMgr()->hasValue( "PyConsole", "font" ) ) + f = resourceMgr()->fontValue( "PyConsole", "font" ); + else + { + f = ( ( PythonConsole* )wid )->font(); + resourceMgr()->setValue( "PyConsole", "font", f ); + } + } else f = wid->font(); @@ -1018,7 +1024,7 @@ void LightApp_Application::updateObjectBrowser( const bool updateModels ) if ( objectBrowser() ) { objectBrowser()->updateGeometry(); - objectBrowser()->updateTree(); + objectBrowser()->updateTree( 0, false ); } } @@ -1252,7 +1258,11 @@ void LightApp_Application::onPreferences() if ( !prefDlg ) return; - prefDlg->exec(); + if ( ( prefDlg->exec() == QDialog::Accepted || prefDlg->isSaved() ) && resourceMgr() ) { + if ( desktop() ) + desktop()->saveGeometry( resourceMgr(), "desktop" ); + resourceMgr()->save(); + } delete prefDlg; } @@ -1319,10 +1329,12 @@ QWidget* LightApp_Application::createWindow( const int flag ) ob->setAutoUpdate( true ); ob->setAutoOpenLevel( 1 ); ob->setCaption( tr( "OBJECT_BROWSER" ) ); - ob->listView()->setColumnWidth( 0, OBJECT_COLUMN_WIDTH ); - ob->resize( OBJECT_BROWSER_WIDTH, ob->height() ); - ob->setFilter( new LightApp_OBFilter( selectionMgr() ) ); + OB_ListView* ob_list = dynamic_cast( const_cast( ob->listView() ) ); + if( ob_list ) + ob_list->setColumnMaxWidth( 0, desktop()->width()/4 ); + + ob->setFilter( new LightApp_OBFilter( selectionMgr() ) ); ob->setNameTitle( tr( "OBJ_BROWSER_NAME" ) ); // Create OBSelector @@ -1375,7 +1387,8 @@ LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const LightApp_Application* that = (LightApp_Application*)this; - if ( !_prefs_ && crt ) + bool toCreate = !_prefs_ && crt; + if( toCreate ) { _prefs_ = new LightApp_Preferences( resourceMgr() ); that->createPreferences( _prefs_ ); @@ -1411,7 +1424,8 @@ LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const { int modCat = _prefs_->addPreference( mod->moduleName() ); _prefs_->setItemProperty( modCat, "info", QString::null ); - mod->createPreferences(); + if( toCreate ) + mod->createPreferences(); } } } @@ -1456,12 +1470,14 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) int undoPref = pref->addPreference( tr( "PREF_UNDO_LEVEL" ), studyGroup, LightApp_Preferences::IntSpin, "Study", "undo_level" ); pref->setItemProperty( undoPref, "min", 1 ); pref->setItemProperty( undoPref, "max", 100 ); + pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" ); int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab ); pref->setItemProperty( extgroup, "columns", 1 ); int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", "application" ); pref->setItemProperty( apppref, "existing", true ); pref->setItemProperty( apppref, "flags", QFileInfo::ExeUser ); + pref->setItemProperty( apppref, "readOnly", false ); pref->addPreference( tr( "PREF_PARAM" ), extgroup, LightApp_Preferences::String, "ExternalBrowser", "parameters" ); @@ -1587,6 +1603,13 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) LightApp_Preferences::Color, "SUPERVGraph", "Title" ); // pref->addPreference( tr( "PREF_SUPERV_CTRL_COLOR" ), supervGroup, // LightApp_Preferences::Color, "SUPERVGraph", "Ctrl" ); + + int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat ); + int objSetGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SETTINGS" ), obTab ); + pref->addPreference( tr( "PREF_AUTO_SIZE_FIRST" ), objSetGroup, LightApp_Preferences::Bool, + "ObjectBrowser", "auto_size_first" ); + pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool, + "ObjectBrowser", "auto_size" ); } /*!Changed preferences */ @@ -1649,19 +1672,26 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString if( sec=="ObjectBrowser" ) { - if( param=="auto_size" ) + if( param=="auto_size" || param=="auto_size_first" ) { OB_Browser* ob = objectBrowser(); if( !ob ) return; - bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false ); + bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false ), + autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true ); ob->setWidthMode( autoSize ? QListView::Maximum : QListView::Manual ); - + ob->listView()->setColumnWidthMode( 0, autoSizeFirst ? QListView::Maximum : QListView::Manual ); updateObjectBrowser( false ); } } + if( sec=="Study" ) + { + if( param=="store_positions" ) + updateWindows(); + } + if( sec=="PyConsole" ) { if( param=="font" ) @@ -1757,6 +1787,10 @@ void LightApp_Application::updateViewManagers() /*!Load windows geometry.*/ void LightApp_Application::loadWindowsGeometry() { + bool store = resourceMgr()->booleanValue( "Study", "store_positions", true ); + if( !store ) + return; + QtxDockAction* dockMgr = 0; QAction* a = action( ViewWindowsId ); @@ -1781,6 +1815,10 @@ void LightApp_Application::loadWindowsGeometry() /*!Save windows geometry.*/ void LightApp_Application::saveWindowsGeometry() { + bool store = resourceMgr()->booleanValue( "Study", "store_positions", true ); + if( !store ) + return; + QtxDockAction* dockMgr = 0; QAction* a = action( ViewWindowsId ); diff --git a/src/LightApp/LightApp_Module.cxx b/src/LightApp/LightApp_Module.cxx index 46d3f82af..283c49c89 100644 --- a/src/LightApp/LightApp_Module.cxx +++ b/src/LightApp/LightApp_Module.cxx @@ -121,12 +121,18 @@ bool LightApp_Module::activateModule( SUIT_Study* study ) } /*!Deactivate module.*/ -bool LightApp_Module::deactivateModule( SUIT_Study* ) +bool LightApp_Module::deactivateModule( SUIT_Study* study ) { delete mySwitchOp; mySwitchOp = 0; - return true; + // abort all operations + MapOfOperation::const_iterator anIt; + for( anIt = myOperations.begin(); anIt != myOperations.end(); anIt++ ) { + anIt.data()->abort(); + } + + return CAM_Module::activateModule( study ); } /*!NOT IMPLEMENTED*/ diff --git a/src/LightApp/LightApp_PreferencesDlg.cxx b/src/LightApp/LightApp_PreferencesDlg.cxx index d44586445..5d0f1ead4 100644 --- a/src/LightApp/LightApp_PreferencesDlg.cxx +++ b/src/LightApp/LightApp_PreferencesDlg.cxx @@ -31,7 +31,7 @@ */ LightApp_PreferencesDlg::LightApp_PreferencesDlg( LightApp_Preferences* prefs, QWidget* parent ) : QtxDialog( parent, 0, true, false, OK | Close | Apply ), -myPrefs( prefs ) +myPrefs( prefs ), mySaved ( false ) { setCaption( tr( "CAPTION" ) ); @@ -79,6 +79,7 @@ void LightApp_PreferencesDlg::accept() QtxDialog::accept(); myPrefs->store(); + mySaved = true; } /*!Reject. Restore preferences from backup.*/ @@ -99,4 +100,5 @@ void LightApp_PreferencesDlg::onApply() { myPrefs->store(); myPrefs->toBackup(); + mySaved = true; } diff --git a/src/LightApp/LightApp_PreferencesDlg.h b/src/LightApp/LightApp_PreferencesDlg.h index 95ffb79b6..ea7bf55fe 100644 --- a/src/LightApp/LightApp_PreferencesDlg.h +++ b/src/LightApp/LightApp_PreferencesDlg.h @@ -40,12 +40,16 @@ public: virtual void accept(); virtual void reject(); + bool isSaved() { return mySaved; } + void setSaved( bool saved ) { mySaved = saved; } + private slots: void onHelp(); void onApply(); private: LightApp_Preferences* myPrefs; + bool mySaved; }; #endif diff --git a/src/LightApp/LightApp_ShowHideOp.cxx b/src/LightApp/LightApp_ShowHideOp.cxx index 4cf18982d..52f16266f 100644 --- a/src/LightApp/LightApp_ShowHideOp.cxx +++ b/src/LightApp/LightApp_ShowHideOp.cxx @@ -58,8 +58,16 @@ void LightApp_ShowHideOp::startOperation() abort(); return; } - QString aStr = sel.param( 0, "component" ).toString(); - QString mod_name = app->moduleTitle( aStr );//sel.param( 0, "component" ).toString() ); + + QString mod_name; + if( sel.count()>0 ) + { + QString aStr = sel.param( 0, "component" ).toString(); + mod_name = app->moduleTitle( aStr ); + } + else if( app->activeModule() ) + mod_name = app->moduleTitle( app->activeModule()->name() ); + LightApp_Displayer* d = LightApp_Displayer::FindDisplayer( mod_name, true ); if( !d ) { diff --git a/src/LightApp/resources/LightApp.xml b/src/LightApp/resources/LightApp.xml index beb65b8aa..2a4932e04 100644 --- a/src/LightApp/resources/LightApp.xml +++ b/src/LightApp/resources/LightApp.xml @@ -44,6 +44,9 @@ +
+ +
diff --git a/src/LightApp/resources/LightApp_msg_en.po b/src/LightApp/resources/LightApp_msg_en.po index b59f4a2fd..5c3215335 100644 --- a/src/LightApp/resources/LightApp_msg_en.po +++ b/src/LightApp/resources/LightApp_msg_en.po @@ -35,8 +35,8 @@ msgstr "Trying to activate module \"%1\"" msgid "LightApp_Application::TOT_RENAME" msgstr "Rename" -msgid "LightApp_Application::MEN_RENAME" -msgstr "Rename" +msgid "LightApp_Application::MEN_DESK_RENAME" +msgstr "&Rename" msgid "LightApp_Application::PRP_RENAME" msgstr "Rename active window" @@ -45,7 +45,7 @@ msgid "LightApp_Application::TOT_DESK_PREFERENCES" msgstr "Preferences" msgid "LightApp_Application::MEN_DESK_PREFERENCES" -msgstr "Preferences..." +msgstr "Pre&ferences..." msgid "LightApp_Application::TOT_DESK_MRU" msgstr "Most recently used" @@ -66,20 +66,26 @@ msgid "LightApp_Application::PRP_MODULE" msgstr "Switch to the module \"%1\"" msgid "LightApp_Application::NEW_WINDOW_0" -msgstr "GL view" +msgstr "&GL view" msgid "LightApp_Application::NEW_WINDOW_1" -msgstr "Plot2d view" +msgstr "&Plot2d view" msgid "LightApp_Application::NEW_WINDOW_2" -msgstr "OCC view" +msgstr "&OCC view" msgid "LightApp_Application::NEW_WINDOW_3" -msgstr "VTK view" +msgstr "VT&K view" msgid "LightApp_Application::INF_CANCELLED" msgstr "Module activation cancelled" +msgid "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" +msgstr "External browser \"%1\" can not show help page \"%2\"" + +msgid "LightApp_Application::DEFINE_EXTERNAL_BROWSER" +msgstr "Define external browser in preferences" + msgid "LightApp_Application::DATA_MODELS" msgstr "Data models" @@ -120,6 +126,9 @@ msgstr "ASCII save" msgid "LightApp_Application::PREF_UNDO_LEVEL" msgstr "Undo level" +msgid "LightApp_Application::PREF_STORE_POS" +msgstr "Store positions of windows" + msgid "LightApp_Application::PREF_GROUP_EXT_BROWSER" msgstr "External browser" @@ -138,6 +147,9 @@ msgstr "Font" msgid "LightApp_Application::PREF_TAB_OBJBROWSER" msgstr "Object browser" +msgid "LightApp_Application::PREF_OBJ_BROWSER_SETTINGS" +msgstr "Object browser settings" + msgid "LightApp_Application::PREF_GROUP_DEF_COLUMNS" msgstr "Default columns" @@ -233,6 +245,12 @@ msgstr "Title color" msgid "LightApp_Application::PREF_SUPERV_CTRL_COLOR" msgstr "Ctrl color" +msgid "LightApp_Application::PREF_AUTO_SIZE" +msgstr "Auto size for other columns" + +msgid "LightApp_Application::PREF_AUTO_SIZE_FIRST" +msgstr "Auto size for first column" + //======================================================================================= msgid "LightApp_PreferencesDlg::CAPTION" diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 1a020f497..4900fd9de 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -160,19 +160,6 @@ const char* imageCrossCursor[] = { "................................", "................................", "................................"}; - - -QPixmap zoomPixmap(imageZoomCursor); -QPixmap rotatePixmap(imageRotateCursor); -QPixmap globalPanPixmap(imageCrossCursor); - -QCursor defCursor(Qt::ArrowCursor); -QCursor handCursor(Qt::PointingHandCursor); -QCursor panCursor(Qt::SizeAllCursor); -QCursor zoomCursor(zoomPixmap); -QCursor rotCursor(rotatePixmap); -QCursor glPanCursor(globalPanPixmap); - ////////////////////////////////////////////////////////////////////// @@ -344,6 +331,8 @@ void OCCViewer_ViewWindow::activateZoom() myCursor = cursor(); /* save old cursor */ if ( myOperation != ZOOMVIEW ) { + QPixmap zoomPixmap (imageZoomCursor); + QCursor zoomCursor (zoomPixmap); setTransformRequested ( ZOOMVIEW ); setCursor( zoomCursor ); } @@ -360,6 +349,7 @@ void OCCViewer_ViewWindow::activatePanning() myCursor = cursor(); // save old cursor if ( myOperation != PANVIEW ) { + QCursor panCursor (Qt::SizeAllCursor); setTransformRequested ( PANVIEW ); setCursor( panCursor ); } @@ -375,6 +365,8 @@ void OCCViewer_ViewWindow::activateRotation() myCursor = cursor(); // save old cursor if ( myOperation != ROTATE ) { + QPixmap rotatePixmap (imageRotateCursor); + QCursor rotCursor (rotatePixmap); setTransformRequested ( ROTATE ); setCursor( rotCursor ); } @@ -385,6 +377,8 @@ void OCCViewer_ViewWindow::activateGlobalPanning() { Handle(V3d_View) aView3d = myViewPort->getView(); if ( !aView3d.IsNull() ) { + QPixmap globalPanPixmap (imageCrossCursor); + QCursor glPanCursor (globalPanPixmap); myCurScale = aView3d->Scale(); aView3d->FitAll(0.01, false); myCursor = cursor(); // save old cursor @@ -404,6 +398,7 @@ void OCCViewer_ViewWindow::activateWindowFit() myCursor = cursor(); /* save old cursor */ if ( myOperation != WINDOWFIT ) { + QCursor handCursor (Qt::PointingHandCursor); setTransformRequested ( WINDOWFIT ); setCursor ( handCursor ); myCursorIsHand = true; @@ -460,6 +455,7 @@ void OCCViewer_ViewWindow::vpMouseMoveEvent(QMouseEvent* theEvent) if ( myDrawRect ) { drawRect(); if ( !myCursorIsHand ) { // we are going to sketch a rectangle + QCursor handCursor (Qt::PointingHandCursor); myCursorIsHand = true; myCursor = cursor(); setCursor( handCursor ); diff --git a/src/ObjBrowser/OB_Browser.cxx b/src/ObjBrowser/OB_Browser.cxx index 81ee7a6bf..fff6ab535 100755 --- a/src/ObjBrowser/OB_Browser.cxx +++ b/src/ObjBrowser/OB_Browser.cxx @@ -134,7 +134,7 @@ void OB_Browser::setRootIsDecorated( const bool decor ) return; myRootDecorated = decor; - updateTree(); + updateTree( 0, false ); } int OB_Browser::autoOpenLevel() const @@ -506,7 +506,7 @@ void OB_Browser::setAppropriateColumn( const int id, const bool on ) myView->setAppropriate( myColumnIds[id], on ); } -void OB_Browser::updateTree( SUIT_DataObject* obj ) +void OB_Browser::updateTree( SUIT_DataObject* obj, const bool autoOpen ) { if ( !obj && !(obj = getRootObject()) ) return; @@ -523,7 +523,8 @@ void OB_Browser::updateTree( SUIT_DataObject* obj ) restoreState( selObjs, openObjs, curObj, selKeys, openKeys, curKey ); - autoOpenBranches(); + if( autoOpen ) + autoOpenBranches(); if ( selNum != numberOfSelected() ) emit selectionChanged(); @@ -860,11 +861,22 @@ void OB_Browser::restoreState( const DataObjectMap& selObjs, const DataObjectMap if ( openObjs.contains( obj ) ) { - if ( openObjs[obj] ) + bool parentOpen = true; + if( item && item->parent() ) + parentOpen = item->parent()->isOpen(); + + if ( openObjs[obj] && parentOpen ) lv->setOpen( item, true ); } else if ( !key.isNull() && openKeys.contains( key ) ) - lv->setOpen( item, true ); + { + bool parentOpen = true; + if( item && item->parent() ) + parentOpen = item->parent()->isOpen(); + + if( parentOpen ) + lv->setOpen( item, true ); + } if ( !curItem && ( curObj == obj || ( !curKey.isNull() && curKey == key )) ) curItem = item; @@ -892,7 +904,7 @@ OB_Browser::DataObjectKey OB_Browser::objectKey( SUIT_DataObject* obj ) const void OB_Browser::keyPressEvent( QKeyEvent* e ) { if ( e->key() == Qt::Key_F5 ) - updateTree(); + updateTree( 0, false ); QFrame::keyPressEvent( e ); } @@ -1083,7 +1095,7 @@ void OB_Browser::removeObject( SUIT_DataObject* obj, const bool autoUpd ) if ( isAutoUpdate() ) { SUIT_DataObject* pObj = item && item->parent() ? dataObject( item->parent() ) : 0; - updateTree( pObj ); + updateTree( pObj, false ); } else delete item; diff --git a/src/ObjBrowser/OB_Browser.h b/src/ObjBrowser/OB_Browser.h index 5d7575b47..cd0b48889 100755 --- a/src/ObjBrowser/OB_Browser.h +++ b/src/ObjBrowser/OB_Browser.h @@ -70,7 +70,7 @@ public: bool isAutoDeleteObjects() const; virtual void setAutoDeleteObjects( const bool ); - virtual void updateTree( SUIT_DataObject* = 0 ); + virtual void updateTree( SUIT_DataObject* = 0, const bool autoOpen = true ); virtual void replaceTree( SUIT_DataObject*, SUIT_DataObject* ); bool isShowToolTips(); diff --git a/src/ObjBrowser/OB_ListItem.cxx b/src/ObjBrowser/OB_ListItem.cxx index fb821308f..b2ced5c7b 100755 --- a/src/ObjBrowser/OB_ListItem.cxx +++ b/src/ObjBrowser/OB_ListItem.cxx @@ -192,6 +192,17 @@ int OB_ListItem::rtti() const return RTTI(); } +void OB_ListItem::setText( int column, const QString& text ) +{ + QListViewItem::setText( column, text ); + QFontMetrics fm = listView()->fontMetrics(); + int necessary = width( fm, listView(), column ), + current = listView()->columnWidth( column ); + + if( listView()->columnWidthMode( column )==QListView::Maximum && necessary>current ) + listView()->setColumnWidth( column, necessary ); +} + /*! Class: OB_CheckListItem Descr: Check list view item for OB_Browser. diff --git a/src/ObjBrowser/OB_ListItem.h b/src/ObjBrowser/OB_ListItem.h index 071ec308a..6b06cd842 100755 --- a/src/ObjBrowser/OB_ListItem.h +++ b/src/ObjBrowser/OB_ListItem.h @@ -75,6 +75,7 @@ public: virtual void paintFocus( QPainter* p, const QColorGroup& cg, const QRect& r ); virtual void paintCell( QPainter* p, const QColorGroup& cg, int c, int w, int align ); + virtual void setText ( int column, const QString & text ); virtual int rtti() const; diff --git a/src/ObjBrowser/OB_ListView.cxx b/src/ObjBrowser/OB_ListView.cxx index 70a9ca635..53d62602f 100755 --- a/src/ObjBrowser/OB_ListView.cxx +++ b/src/ObjBrowser/OB_ListView.cxx @@ -162,3 +162,39 @@ bool OB_ListView::isDropAccepted( QListViewItem* drag, QListViewItem* drop ) con return dropObj->isDropAccepted( dragObj ); } + +void OB_ListView::setColumnWidth( int col, int width ) +{ + int max = columnMaxWidth( col ); + if( max>0 && width>max ) + width = max; + QListView::setColumnWidth( col, width ); +} + +int OB_ListView::columnMaxWidth( const int col ) const +{ + int res = -1; + if( myMaxColWidth.contains( col ) ) + res = myMaxColWidth[col]; + else if( myMaxColRatio.contains( col ) ) + res = int( myMaxColRatio[col]*height() ); + return res; +} + +void OB_ListView::setColumnMaxWidth( const int col, const int w ) +{ + myMaxColWidth.insert( col, w ); +} + +double OB_ListView::columnMaxRatio( const int col ) const +{ + double res = 0.0; + if( myMaxColRatio.contains( col ) ) + res = myMaxColRatio[col]; + return res; +} + +void OB_ListView::setColumnMaxRatio( const int col, const double r ) +{ + myMaxColRatio.insert( col, r ); +} diff --git a/src/ObjBrowser/OB_ListView.h b/src/ObjBrowser/OB_ListView.h index 5c9feb5d1..03a394c21 100755 --- a/src/ObjBrowser/OB_ListView.h +++ b/src/ObjBrowser/OB_ListView.h @@ -47,6 +47,11 @@ public: void setFilter( OB_Filter* ); bool isOk( QListViewItem* ) const; + virtual void setColumnWidth( int, int ); + int columnMaxWidth( const int ) const; + void setColumnMaxWidth( const int, const int ); + double columnMaxRatio( const int ) const; + void setColumnMaxRatio( const int, const double ); signals: void dropped( QPtrList, QListViewItem*, int ); @@ -69,6 +74,8 @@ private: protected: QPtrList myItems; OB_Filter* myFilter; + QMap myMaxColWidth; + QMap myMaxColRatio; }; #ifdef WIN32 diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index e43e40cee..67933dbae 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -130,13 +130,6 @@ const char* imageCrossCursor[] = { "................................"}; -QPixmap zoomPixmap(imageZoomCursor); -QPixmap globalPanPixmap(imageCrossCursor); - -QCursor panCursor(Qt::SizeAllCursor); -QCursor zoomCursor(zoomPixmap); -QCursor glPanCursor(globalPanPixmap); - //================================================================================= // Plot2d_ViewFrame implementation //================================================================================= @@ -306,8 +299,8 @@ void Plot2d_ViewFrame::readPreferences() SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); myCurveType = resMgr->integerValue( "Plot2d", "CurveType", myCurveType ); - if ( myCurveType < 1 || myCurveType > 2 ) - myCurveType = 1; + setCurveType( resMgr->integerValue( "Plot2d", "CurveType", myCurveType ) ); + myShowLegend = resMgr->booleanValue( "Plot2d", "ShowLegend", myShowLegend ); myLegendPos = resMgr->integerValue( "Plot2d", "LegendPos", myLegendPos ); myMarkerSize = resMgr->integerValue( "Plot2d", "MarkerSize", myMarkerSize ); @@ -683,6 +676,7 @@ void Plot2d_ViewFrame::eraseCurve( Plot2d_Curve* curve, bool update ) if ( curveKey ) { myPlot->removeCurve( curveKey ); myCurves.remove( curveKey ); + updateTitles(); if ( update ) myPlot->replot(); } @@ -905,8 +899,12 @@ int Plot2d_ViewFrame::testOperation( const QMouseEvent& me ) switch (btn) { case zoomBtn: - myPlot->canvas()->setCursor( zoomCursor ); - return ZoomId; + { + QPixmap zoomPixmap (imageZoomCursor); + QCursor zoomCursor (zoomPixmap); + myPlot->canvas()->setCursor( zoomCursor ); + return ZoomId; + } case panBtn: myPlot->canvas()->setCursor( QCursor( Qt::SizeAllCursor ) ); return PanId; @@ -1533,6 +1531,7 @@ void Plot2d_ViewFrame::wheelEvent(QWheelEvent* event) */ void Plot2d_ViewFrame::onViewPan() { + QCursor panCursor (Qt::SizeAllCursor); myPlot->canvas()->setCursor( panCursor ); myOperation = PanId; qApp->installEventFilter( this ); @@ -1542,6 +1541,8 @@ void Plot2d_ViewFrame::onViewPan() */ void Plot2d_ViewFrame::onViewZoom() { + QPixmap zoomPixmap (imageZoomCursor); + QCursor zoomCursor (zoomPixmap); myPlot->canvas()->setCursor( zoomCursor ); myOperation = ZoomId; qApp->installEventFilter( this ); @@ -1567,6 +1568,8 @@ void Plot2d_ViewFrame::onViewFitArea() */ void Plot2d_ViewFrame::onViewGlobalPan() { + QPixmap globalPanPixmap (imageCrossCursor); + QCursor glPanCursor (globalPanPixmap); myPlot->canvas()->setCursor( glPanCursor ); myPlot->changeAxisOptions( QwtPlot::xBottom, QwtAutoScale::Logarithmic, false ); myPlot->changeAxisOptions( QwtPlot::yLeft, QwtAutoScale::Logarithmic, false ); diff --git a/src/Plot2d/Plot2d_ViewWindow.cxx b/src/Plot2d/Plot2d_ViewWindow.cxx index 447ec7dad..5c558ea0f 100755 --- a/src/Plot2d/Plot2d_ViewWindow.cxx +++ b/src/Plot2d/Plot2d_ViewWindow.cxx @@ -357,7 +357,12 @@ void Plot2d_ViewWindow::onChangeVerMode() //**************************************************************** void Plot2d_ViewWindow::onChangeCurveMode() { - myCurveBtn->SetItem(myViewFrame->getCurveType()); + int aCurveType = myViewFrame->getCurveType(); + myCurveBtn->SetItem(aCurveType); + + myActionsMap[CurvPointsId]->setOn(aCurveType == 0); + myActionsMap[CurvLinesId]->setOn(aCurveType == 1); + myActionsMap[CurvSplinesId]->setOn(aCurveType == 2); } //**************************************************************** @@ -425,26 +430,14 @@ void Plot2d_ViewWindow::onLegend() void Plot2d_ViewWindow::onCurves() { QtxAction* aSender = (QtxAction*) sender(); - if(aSender == myActionsMap[CurvPointsId]) { - myActionsMap[CurvPointsId]->setOn(true); - myActionsMap[CurvLinesId]->setOn(false); - myActionsMap[CurvSplinesId]->setOn(false); + if(aSender == myActionsMap[CurvPointsId]) myViewFrame->setCurveType(0); - } - else if(aSender == myActionsMap[CurvLinesId]) { - myActionsMap[CurvLinesId]->setOn(true); - myActionsMap[CurvPointsId]->setOn(false); - myActionsMap[CurvSplinesId]->setOn(false); + else if(aSender == myActionsMap[CurvLinesId]) myViewFrame->setCurveType(1); - } - else if(aSender == myActionsMap[CurvSplinesId]) { - myActionsMap[CurvSplinesId]->setOn( true ); - myActionsMap[CurvPointsId]->setOn( false ); - myActionsMap[CurvLinesId]->setOn( false ); + else if(aSender == myActionsMap[CurvSplinesId]) myViewFrame->setCurveType(2); - } } - + //**************************************************************** void Plot2d_ViewWindow::onDumpView() { diff --git a/src/PyInterp/PyInterp_Dispatcher.cxx b/src/PyInterp/PyInterp_Dispatcher.cxx index 3312e527c..3d5067dba 100755 --- a/src/PyInterp/PyInterp_Dispatcher.cxx +++ b/src/PyInterp/PyInterp_Dispatcher.cxx @@ -31,7 +31,8 @@ void PyInterp_Request::process() safeExecute(); myMutex.lock(); - if ( !IsSync() && getListener() && getEvent() ) + //if ( !IsSync() && getListener() && getEvent() ) + if ( getListener() && getEvent() ) postEvent(); myMutex.unlock(); } @@ -56,7 +57,8 @@ QEvent* PyInterp_Request::createEvent() const QEvent* PyInterp_Request::getEvent() { - if ( !myEvent && !IsSync() ) + //if ( !myEvent && !IsSync() ) + if ( !myEvent ) myEvent = createEvent(); return myEvent; } @@ -142,7 +144,8 @@ void PyInterp_Dispatcher::Exec( PyInterp_Request* theRequest ) if ( !theRequest ) return; - if ( theRequest->IsSync() && !IsBusy() ) // synchronous processing - nothing is done if dispatcher is busy! + //if ( theRequest->IsSync() && !IsBusy() ) // synchronous processing - nothing is done if dispatcher is busy! + if ( theRequest->IsSync() ) // synchronous processing - nothing is done if dispatcher is busy! processRequest( theRequest ); else { // asynchronous processing myQueueMutex.lock(); diff --git a/src/PyInterp/PyInterp_base.cxx b/src/PyInterp/PyInterp_base.cxx index a75c39bdd..69ccefc9d 100644 --- a/src/PyInterp/PyInterp_base.cxx +++ b/src/PyInterp/PyInterp_base.cxx @@ -22,18 +22,30 @@ PyLockWrapper::PyLockWrapper(PyThreadState* theThreadState): myThreadState(theThreadState), mySaveThreadState(0) { - PyEval_AcquireLock(); - mySaveThreadState = PyThreadState_Swap(myThreadState); // store previous current in save, - // set local in current +#if defined(USE_GILSTATE) + if (myThreadState->interp == PyInterp_base::_interp) { + _savestate = PyGILState_Ensure(); + } else { + PyEval_AcquireThread(myThreadState); + } +#else + PyEval_AcquireThread(myThreadState); +#endif } - -PyLockWrapper::~PyLockWrapper(){ - PyThreadState_Swap(mySaveThreadState); // restore previous current (no need to get local, - PyEval_ReleaseLock(); // local thread state* already in _tstate +PyLockWrapper::~PyLockWrapper() +{ +#if defined(USE_GILSTATE) + if (myThreadState->interp == PyInterp_base::_interp) { + PyGILState_Release(_savestate); + } else { + PyEval_ReleaseThread(myThreadState); + } +#else + PyEval_ReleaseThread(myThreadState); +#endif } - class PyReleaseLock{ public: ~PyReleaseLock(){ @@ -47,14 +59,16 @@ PyLockWrapper PyInterp_base::GetLockWrapper(){ } -// main python interpreter +// main python interpreter (static attributes) -//PyThreadState *PyInterp_base::_gtstate = 0; // force 0 before execution int PyInterp_base::_argc = 1; char* PyInterp_base::_argv[] = {""}; PyObject *PyInterp_base::builtinmodule = NULL; +PyThreadState *PyInterp_base::_gtstate = NULL; +PyInterpreterState *PyInterp_base::_interp = NULL; + /*! * basic constructor here : herited classes constructors must call initalize() method @@ -66,8 +80,6 @@ PyInterp_base::PyInterp_base(): _tstate(0), _vout(0), _verr(0), _g(0), _atFirst( PyInterp_base::~PyInterp_base() { - PyLockWrapper aLock(_tstate); - //Py_EndInterpreter(_tstate); } @@ -85,10 +97,10 @@ void PyInterp_base::initialize() init_python(); // Here the global lock is released - // The lock will be acquired in initState. Make provision to release it on exit - PyReleaseLock aReleaseLock; - initState(); + + PyLockWrapper aLock= GetLockWrapper(); + initContext(); // used to interpret & compile commands @@ -96,45 +108,40 @@ void PyInterp_base::initialize() if(!m){ PyErr_Print(); return; - } - + } + // Create cStringIO to capture stdout and stderr PycString_IMPORT; - //PycStringIO = (PycStringIO_CAPI *)xxxPyCObject_Import("cStringIO", "cStringIO_CAPI"); _vout = PycStringIO->NewOutput(128); _verr = PycStringIO->NewOutput(128); - + // All the initRun outputs are redirected to the standard output (console) initRun(); } void PyInterp_base::init_python() { - static PyThreadState *_gtstate = 0; - _atFirst = false; if (Py_IsInitialized()) return; + // Python is not initialized Py_SetProgramName(_argv[0]); Py_Initialize(); // Initialize the interpreter PySys_SetArgv(_argc, _argv); PyEval_InitThreads(); // Create (and acquire) the interpreter lock + _interp = PyThreadState_Get()->interp; _gtstate = PyEval_SaveThread(); // Release global thread state -// if(!_gtstate){ -// PyReleaseLock aReleaseLock; -// Py_Initialize(); // Initialize the interpreter -// PyEval_InitThreads(); // Initialize and acquire the global interpreter lock -// PySys_SetArgv(_argc,_argv); // initialize sys.argv -// _gtstate = PyThreadState_Get(); -// } } string PyInterp_base::getbanner() { + // Should we take the lock ? + // PyEval_RestoreThread(_tstate); string aBanner("Python "); aBanner = aBanner + Py_GetVersion() + " on " + Py_GetPlatform() ; aBanner = aBanner + "\ntype help to get general information on environment\n"; + //PyEval_SaveThread(); return aBanner; } @@ -185,11 +192,11 @@ int compile_command(const char *command,PyObject *context) return 1; }else{ // Complete and correct text. We evaluate it. -#if PY_VERSION_HEX < 0x02040000 // python version earlier than 2.4.0 - PyObjWrapper r(PyEval_EvalCode(v,context,context)); -#else + //#if PY_VERSION_HEX < 0x02040000 // python version earlier than 2.4.0 + // PyObjWrapper r(PyEval_EvalCode(v,context,context)); + //#else PyObjWrapper r(PyEval_EvalCode((PyCodeObject *)(void *)v,context,context)); -#endif + //#endif if(!r){ // Execution error. We return -1 PyErr_Print(); @@ -240,15 +247,16 @@ int PyInterp_base::simpleRun(const char *command) // Reset redirected outputs before treatment PySys_SetObject("stderr",_verr); PySys_SetObject("stdout",_vout); - + PyObjWrapper verr(PyObject_CallMethod(_verr,"reset","")); PyObjWrapper vout(PyObject_CallMethod(_vout,"reset","")); - + int ier = compile_command(command,_g); // Outputs are redirected on standards outputs (console) PySys_SetObject("stdout",PySys_GetObject("__stdout__")); PySys_SetObject("stderr",PySys_GetObject("__stderr__")); + return ier; } @@ -290,4 +298,3 @@ string PyInterp_base::getvout(){ string aRet(PyString_AsString(v)); return aRet; } - diff --git a/src/PyInterp/PyInterp_base.h b/src/PyInterp/PyInterp_base.h index b2e0a0b26..66847770d 100644 --- a/src/PyInterp/PyInterp_base.h +++ b/src/PyInterp/PyInterp_base.h @@ -23,9 +23,16 @@ //#include // must be before Python.h ! #include // must be before qt includes ... +#include // Python include needed for versions before 2.4. Included in Python.h now. +#include // Python include needed for versions before 2.4. Included in Python.h now. -#if PY_VERSION_HEX < 0x02040000 // python version earlier than 2.4.0 -extern "C" PyObject * PyEval_EvalCode(PyObject *co, PyObject *g, PyObject *l); +//#if PY_VERSION_HEX < 0x02040000 // python version earlier than 2.4.0 +//extern "C" PyObject * PyEval_EvalCode(PyObject *co, PyObject *g, PyObject *l); +//#endif + +/* For 2.3, use the PyGILState_ calls */ +#if (PY_VERSION_HEX >= 0x02030000) +#define USE_GILSTATE #endif #define TOP_HISTORY_PY "--- top of history ---" @@ -35,17 +42,21 @@ class PYINTERP_EXPORT PyLockWrapper { PyThreadState* myThreadState; PyThreadState* mySaveThreadState; +#if defined(USE_GILSTATE) + PyGILState_STATE _savestate ; +#endif public: PyLockWrapper(PyThreadState* theThreadState); ~PyLockWrapper(); }; - class PYINTERP_EXPORT PyInterp_base{ public: static int _argc; static char* _argv[]; static PyObject *builtinmodule; + static PyThreadState *_gtstate; + static PyInterpreterState *_interp; PyInterp_base(); ~PyInterp_base(); diff --git a/src/PythonConsole/PythonConsole_PyEditor.cxx b/src/PythonConsole/PythonConsole_PyEditor.cxx index 0a5a4f0da..5bb4aed68 100755 --- a/src/PythonConsole/PythonConsole_PyEditor.cxx +++ b/src/PythonConsole/PythonConsole_PyEditor.cxx @@ -56,8 +56,10 @@ static QString DOTS_PROMPT = "... "; class ExecCommand : public PyInterp_LockRequest { public: - ExecCommand(PyInterp_base* theInterp, const char* theCommand, PythonConsole_PyEditor* theListener) -: PyInterp_LockRequest( theInterp, theListener ), myCommand(theCommand), myState( PyInterp_Event::OK ) + ExecCommand(PyInterp_base* theInterp, const char* theCommand, + PythonConsole_PyEditor* theListener, bool sync = false) + : PyInterp_LockRequest( theInterp, theListener, sync ), + myCommand( theCommand ), myState( PyInterp_Event::OK ) {} protected: diff --git a/src/PythonConsole/PythonConsole_PyInterp.cxx b/src/PythonConsole/PythonConsole_PyInterp.cxx index 62b483905..5b7d3e579 100755 --- a/src/PythonConsole/PythonConsole_PyInterp.cxx +++ b/src/PythonConsole/PythonConsole_PyInterp.cxx @@ -92,6 +92,7 @@ bool PythonConsole_PyInterp::initState() _tstate->interp->builtins = PyModule_GetDict(builtinmodule); Py_INCREF(_tstate->interp->builtins); } + PyEval_ReleaseThread(_tstate); return true; } diff --git a/src/Qtx/QtxListResourceEdit.cxx b/src/Qtx/QtxListResourceEdit.cxx index 93acf8409..75e74e998 100644 --- a/src/Qtx/QtxListResourceEdit.cxx +++ b/src/Qtx/QtxListResourceEdit.cxx @@ -1303,12 +1303,13 @@ QtxListResourceEdit::FileItem::FileItem( const QString& title, QtxResourceEdit* : PrefItem( Font, edit, pItem, parent ), myFlags( QFileInfo::ReadUser ), myIsExisting( true ), + myIsReadOnly ( true ), myFileDlg( 0 ) { new QLabel( title, this ); myFile = new QLineEdit( this ); myFile->setValidator( new FileValidator( this, myFile ) ); - myFile->setReadOnly( true ); + myFile->setReadOnly( myIsReadOnly ); myOpenFile = new QToolButton( this ); myOpenFile->setText( "..." ); connect( myOpenFile, SIGNAL( clicked() ), this, SLOT( onOpenFile() ) ); @@ -1338,6 +1339,8 @@ QVariant QtxListResourceEdit::FileItem::property( const QString& name ) const return myIsExisting; else if( name=="flags" ) return myFlags; + else if( name=="readOnly") + return myIsReadOnly; return QVariant(); } @@ -1359,6 +1362,11 @@ void QtxListResourceEdit::FileItem::setProperty( const QString& name, const QVar else if( name=="flags" && value.canCast( QVariant::UInt ) ) myFlags = value.toUInt(); + + else if( name=="readOnly" && value.canCast( QVariant::Bool) ) { + myIsReadOnly = value.toBool(); + myFile->setReadOnly( myIsReadOnly ); + } } void QtxListResourceEdit::FileItem::onOpenFile() diff --git a/src/Qtx/QtxListResourceEdit.h b/src/Qtx/QtxListResourceEdit.h index 86bc32f1b..19713ca08 100644 --- a/src/Qtx/QtxListResourceEdit.h +++ b/src/Qtx/QtxListResourceEdit.h @@ -518,6 +518,7 @@ private slots: private: uint myFlags; + bool myIsReadOnly; QStringList myFilter; bool myIsExisting; QLineEdit* myFile; diff --git a/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx b/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx index 055df7904..3cb6cbbda 100644 --- a/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx +++ b/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx @@ -503,11 +503,11 @@ void SALOME_PYQT_Module::init( CAM_Application* app ) PyLockWrapper aLock = myInterp->GetLockWrapper(); // ... (the Python module is already imported) // ... finally call Python module's initialize() method - PyObjWrapper res( PyObject_CallMethod( myModule, "initialize", "" ) ); - if( !res ) { - // VSR: this method may not be implemented in Python module - // PyErr_Print(); - PyErr_Clear(); + if(PyObject_HasAttrString(myModule , "initialize")){ + PyObjWrapper res( PyObject_CallMethod( myModule, "initialize", "" ) ); + if( !res ) { + PyErr_Print(); + } } // get the windows list from the Python module by calling windows() method @@ -517,51 +517,51 @@ void SALOME_PYQT_Module::init( CAM_Application* app ) // VSR: LogWindow is not yet implemented // myWindowsMap.insert( SalomeApp_Application::WT_LogWindow, Qt::DockBottom ); - PyObjWrapper res1( PyObject_CallMethod( myModule, "windows", "" ) ); - if( !res1 ) { - // VSR: this method may not be implemented in Python module - // PyErr_Print(); - PyErr_Clear(); - } - else { - myWindowsMap.clear(); - if ( PyDict_Check( res1 ) ) { - PyObject* key; - PyObject* value; - int pos = 0; - while ( PyDict_Next( res1, &pos, &key, &value ) ) { - // parse the return value - // it should be a map: {integer:integer} - int aKey, aValue; - if( key && PyInt_Check( key ) && value && PyInt_Check( value ) ) { - aKey = PyInt_AsLong( key ); - aValue = PyInt_AsLong( value ); - myWindowsMap[ aKey ] = aValue; - } + if(PyObject_HasAttrString(myModule , "windows")){ + PyObjWrapper res1( PyObject_CallMethod( myModule, "windows", "" ) ); + if( !res1 ) { + PyErr_Print(); + } + else { + myWindowsMap.clear(); + if ( PyDict_Check( res1 ) ) { + PyObject* key; + PyObject* value; + int pos = 0; + while ( PyDict_Next( res1, &pos, &key, &value ) ) { + // parse the return value + // it should be a map: {integer:integer} + int aKey, aValue; + if( key && PyInt_Check( key ) && value && PyInt_Check( value ) ) { + aKey = PyInt_AsLong( key ); + aValue = PyInt_AsLong( value ); + myWindowsMap[ aKey ] = aValue; + } + } } } } // get the windows list from the Python module by calling views() method - PyObjWrapper res2( PyObject_CallMethod( myModule, "views", "" ) ); - if( !res2 ) { - // VSR: this method may not be implemented in Python module - // PyErr_Print(); - PyErr_Clear(); - } - else { - // parse the return value - // result can be one string... - if ( PyString_Check( res2 ) ) { - myViewMgrList.append( PyString_AsString( res2 ) ); + if(PyObject_HasAttrString(myModule , "views")){ + PyObjWrapper res2( PyObject_CallMethod( myModule, "views", "" ) ); + if( !res2 ) { + PyErr_Print(); } - // ... or list of strings - else if ( PyList_Check( res2 ) ) { - int size = PyList_Size( res2 ); - for ( int i = 0; i < size; i++ ) { - PyObject* value = PyList_GetItem( res2, i ); - if( value && PyString_Check( value ) ) { - myViewMgrList.append( PyString_AsString( value ) ); - } + else { + // parse the return value + // result can be one string... + if ( PyString_Check( res2 ) ) { + myViewMgrList.append( PyString_AsString( res2 ) ); + } + // ... or list of strings + else if ( PyList_Check( res2 ) ) { + int size = PyList_Size( res2 ); + for ( int i = 0; i < size; i++ ) { + PyObject* value = PyList_GetItem( res2, i ); + if( value && PyString_Check( value ) ) { + myViewMgrList.append( PyString_AsString( value ) ); + } + } } } } @@ -596,20 +596,20 @@ void SALOME_PYQT_Module::activate( SUIT_Study* theStudy ) if ( IsCallOldMethods ) { //__CALL_OLD_METHODS__ // call Python module's setSettings() method (obsolete) - PyObjWrapper res( PyObject_CallMethod( myModule, "setSettings", "" ) ); - if( !res ) { - // VSR: this method may not be implemented in Python module - // PyErr_Print(); - PyErr_Clear(); + if(PyObject_HasAttrString(myModule , "setSettings")){ + PyObjWrapper res( PyObject_CallMethod( myModule, "setSettings", "" ) ); + if( !res ) { + PyErr_Print(); + } } } //__CALL_OLD_METHODS__ // call Python module's activate() method (for the new modules) - PyObjWrapper res1( PyObject_CallMethod( myModule, "activate", "" ) ); - if( !res1 ) { - // VSR: this method may not be implemented in Python module - // PyErr_Print(); - PyErr_Clear(); + if(PyObject_HasAttrString(myModule , "activate")){ + PyObjWrapper res1( PyObject_CallMethod( myModule, "activate", "" ) ); + if( !res1 ) { + PyErr_Print(); + } } } @@ -625,11 +625,11 @@ void SALOME_PYQT_Module::deactivate( SUIT_Study* theStudy ) return; } // then call Python module's deactivate() method - PyObjWrapper res( PyObject_CallMethod( myModule, "deactivate", "" ) ); - if( !res ) { - // VSR: this method may not be implemented in Python module - // PyErr_Print(); - PyErr_Clear(); + if(PyObject_HasAttrString(myModule , "deactivate")){ + PyObjWrapper res( PyObject_CallMethod( myModule, "deactivate", "" ) ); + if( !res ) { + PyErr_Print(); + } } } @@ -659,11 +659,11 @@ void SALOME_PYQT_Module::studyChanged( SUIT_Study* theStudy ) PyLockWrapper aLock = myInterp->GetLockWrapper(); // call Python module's activeStudyChanged() method - PyObjWrapper res( PyObject_CallMethod( myModule, "activeStudyChanged", "i", aStudyId ) ); - if( !res ) { - // VSR: this method may not be implemented in Python module - // PyErr_Print(); - PyErr_Clear(); + if(PyObject_HasAttrString(myModule , "activeStudyChanged")){ + PyObjWrapper res( PyObject_CallMethod( myModule, "activeStudyChanged", "i", aStudyId ) ); + if( !res ) { + PyErr_Print(); + } } } @@ -741,8 +741,8 @@ void SALOME_PYQT_Module::contextMenu( const QString& theContext, QPopupMenu* the return; QString aContext( theContext ), aObject( "" ), aParent( "" ); - - if ( IsCallOldMethods ) { //__CALL_OLD_METHODS__ + + if ( IsCallOldMethods && PyObject_HasAttrString(myModule , "definePopup") ) { //__CALL_OLD_METHODS__ // call definePopup() Python module's function // this is obsolete function, used only for compatibility reasons PyObjWrapper res(PyObject_CallMethod( myModule, @@ -752,9 +752,7 @@ void SALOME_PYQT_Module::contextMenu( const QString& theContext, QPopupMenu* the aObject.latin1(), aParent.latin1() ) ); if( !res ) { - // VSR: this method may not be implemented in Python module - // PyErr_Print(); - PyErr_Clear(); + PyErr_Print(); } else { // parse return value @@ -775,18 +773,18 @@ void SALOME_PYQT_Module::contextMenu( const QString& theContext, QPopupMenu* the PyObjWrapper sipPopup( sipBuildResult( 0, "M", thePopupMenu, sipClass_QPopupMenu ) ); // then call Python module's createPopupMenu() method (for new modules) - PyObjWrapper res1( PyObject_CallMethod( myModule, + if ( PyObject_HasAttrString(myModule , "createPopupMenu") ) { + PyObjWrapper res1( PyObject_CallMethod( myModule, "createPopupMenu", "Os", sipPopup.get(), aContext.latin1() ) ); - if( !res1 ) { - // VSR: this method may not be implemented in Python module - // PyErr_Print(); - PyErr_Clear(); + if( !res1 ) { + PyErr_Print(); + } } - if ( IsCallOldMethods ) { //__CALL_OLD_METHODS__ + if ( IsCallOldMethods && PyObject_HasAttrString(myModule , "customPopup") ) { //__CALL_OLD_METHODS__ // call customPopup() Python module's function // this is obsolete function, used only for compatibility reasons PyObjWrapper res2( PyObject_CallMethod( myModule, @@ -797,9 +795,7 @@ void SALOME_PYQT_Module::contextMenu( const QString& theContext, QPopupMenu* the aObject.latin1(), aParent.latin1() ) ); if( !res2 ) { - // VSR: this method may not be implemented in Python module - // PyErr_Print(); - PyErr_Clear(); + PyErr_Print(); } } //__CALL_OLD_METHODS__ } @@ -815,11 +811,11 @@ void SALOME_PYQT_Module::guiEvent( const int theId ) if ( !myInterp || !myModule ) return; - PyObjWrapper res( PyObject_CallMethod( myModule, "OnGUIEvent", "i", theId ) ); - if( !res ) { - // VSR: this method may not be implemented in Python module - // PyErr_Print(); - PyErr_Clear(); + if ( PyObject_HasAttrString(myModule , "OnGUIEvent") ) { + PyObjWrapper res( PyObject_CallMethod( myModule, "OnGUIEvent", "i", theId ) ); + if( !res ) { + PyErr_Print(); + } } } @@ -934,11 +930,11 @@ void SALOME_PYQT_Module::setWorkSpace() } PyObjWrapper pyws( sipBuildResult( 0, "M", aWorkspace, sipClass_QWidget ) ); // ... and finally call Python module's setWorkspace() method (obsolete) - PyObjWrapper res( PyObject_CallMethod( myModule, "setWorkSpace", "O", pyws.get() ) ); - if( !res ) { - // VSR: this method may not be implemented in Python module - // PyErr_Print(); - PyErr_Clear(); + if ( PyObject_HasAttrString(myModule , "setWorkSpace") ) { + PyObjWrapper res( PyObject_CallMethod( myModule, "setWorkSpace", "O", pyws.get() ) ); + if( !res ) { + PyErr_Print(); + } } } //__CALL_OLD_METHODS__ } diff --git a/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_PyInterp.cxx b/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_PyInterp.cxx index dbde7b1d3..1956ec3af 100644 --- a/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_PyInterp.cxx +++ b/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_PyInterp.cxx @@ -38,9 +38,9 @@ bool SALOME_PYQT_PyInterp::initState() */ SCRUTE(KERNEL_PYTHON::_gtstate); _tstate = KERNEL_PYTHON::_gtstate; - PyEval_AcquireLock(); - PyThreadState_Swap(_tstate); + PyEval_AcquireThread(_tstate); SCRUTE(_tstate); + PyEval_ReleaseThread(_tstate); return true; } @@ -67,11 +67,11 @@ int SALOME_PYQT_PyInterp::run(const char *command) PyErr_Print(); return -1; } -#if PY_VERSION_HEX < 0x02040000 // python version earlier than 2.4.0 - PyObject *r = PyEval_EvalCode(code,_g,_g); -#else - PyObject *r = PyEval_EvalCode((PyCodeObject*)code,_g,_g); -#endif + //#if PY_VERSION_HEX < 0x02040000 // python version earlier than 2.4.0 + // PyObject *r = PyEval_EvalCode(code,_g,_g); + //#else + PyObject *r = PyEval_EvalCode((PyCodeObject *)code,_g,_g); + //#endif Py_DECREF(code); if(!r){ // Une erreur s est produite a l execution @@ -81,4 +81,3 @@ int SALOME_PYQT_PyInterp::run(const char *command) Py_DECREF(r); return 0; } - diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt_v4.sip b/src/SALOME_PYQT/SalomePyQt/SalomePyQt_v4.sip index eee54b26c..f306399b1 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt_v4.sip +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt_v4.sip @@ -73,7 +73,7 @@ public: static const QString getActiveComponent(); static void updateObjBrowser( const int = 0, bool = true ); - static QString getFileName ( QWidget*, const QString&, const QStringList&, const QString&, bool ); + static QString getFileName ( QWidget*, const QString&, const QStringList&, const QString&, bool ) /ReleaseGIL/ ; static QStringList getOpenFileNames ( QWidget*, const QString&, const QStringList&, const QString& ); static QString getExistingDirectory( QWidget*, const QString&, const QString& ); diff --git a/src/STD/STD_Application.cxx b/src/STD/STD_Application.cxx index 49d5cfcfc..3e955e6c9 100755 --- a/src/STD/STD_Application.cxx +++ b/src/STD/STD_Application.cxx @@ -163,7 +163,7 @@ void STD_Application::createActions() createAction( FileSaveAsId, tr( "TOT_DESK_FILE_SAVEAS" ), QIconSet(), tr( "MEN_DESK_FILE_SAVEAS" ), tr( "PRP_DESK_FILE_SAVEAS" ), - 0, desk, false, this, SLOT( onSaveAsDoc() ) ); + CTRL+Key_A, desk, false, this, SLOT( onSaveAsDoc() ) ); createAction( EditCopyId, tr( "TOT_DESK_EDIT_COPY" ), resMgr->loadPixmap( "STD", tr( "ICON_EDIT_COPY" ) ), @@ -177,7 +177,7 @@ void STD_Application::createActions() QAction* a = createAction( ViewStatusBarId, tr( "TOT_DESK_VIEW_STATUSBAR" ), QIconSet(), tr( "MEN_DESK_VIEW_STATUSBAR" ), - tr( "PRP_DESK_VIEW_STATUSBAR" ), 0, desk, true ); + tr( "PRP_DESK_VIEW_STATUSBAR" ), SHIFT+Key_S, desk, true ); a->setOn( desk->statusBar()->isVisibleTo( desk ) ); connect( a, SIGNAL( toggled( bool ) ), this, SLOT( onViewStatusBar( bool ) ) ); @@ -186,7 +186,7 @@ void STD_Application::createActions() createAction( HelpAboutId, tr( "TOT_DESK_HELP_ABOUT" ), QIconSet(), tr( "MEN_DESK_HELP_ABOUT" ), tr( "PRP_DESK_HELP_ABOUT" ), - 0, desk, false, this, SLOT( onHelpAbout() ) ); + SHIFT+Key_A, desk, false, this, SLOT( onHelpAbout() ) ); //SRN: BugID IPAL9021, add an action "Load" createAction( FileLoadId, tr( "TOT_DESK_FILE_LOAD" ), diff --git a/src/STD/STD_TabDesktop.cxx b/src/STD/STD_TabDesktop.cxx index 935b36dcb..24dfd5ccf 100644 --- a/src/STD/STD_TabDesktop.cxx +++ b/src/STD/STD_TabDesktop.cxx @@ -47,7 +47,7 @@ myWorkstackAction( 0 ) myWorkstack = new QtxWorkstack( base ); // setting Expanding size policy for central workstack. If there are several widgets - // in central area of Desktop, other widgets will be added below the workstack (CATHARE, TIRPOLI modules). + // in central area of Desktop, other widgets will be added below the workstack (CATHARE, TRIPOLI modules). // But the workstack must occupy as much space as possible -- set Expanding for it. myWorkstack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); diff --git a/src/STD/resources/STD_msg_en.po b/src/STD/resources/STD_msg_en.po index a88cd6ece..2c5d9fd37 100755 --- a/src/STD/resources/STD_msg_en.po +++ b/src/STD/resources/STD_msg_en.po @@ -123,7 +123,7 @@ msgid "MEN_DESK_VIEW_TOOLBARS" msgstr "T&oolbars" msgid "MEN_DESK_VIEW_STATUSBAR" -msgstr "Stat&us Bar" +msgstr "&Status Bar" msgid "MEN_DESK_VIEW_STDTOOLBAR" msgstr "&Standard" diff --git a/src/SUIT/SUIT_MessageBox.cxx b/src/SUIT/SUIT_MessageBox.cxx index 9d38c0519..1d4d03cad 100755 --- a/src/SUIT/SUIT_MessageBox.cxx +++ b/src/SUIT/SUIT_MessageBox.cxx @@ -32,211 +32,318 @@ /*! Shows info message box with one button [ static ] */ -int SUIT_MessageBox::info1( QWidget* parent, const QString& caption, const QString& text, - const QString& textButton0 ) +int SUIT_MessageBox::info1( QWidget* parent, + const QString& caption, + const QString& text, + const QString& textButton0 ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); - int ret = QMessageBox::information( parent, caption, text, textButton0, - QString::null, QString::null, 0, 0 ); - qApp->processEvents(); - return ret; + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + int ret = QMessageBox::information( parent, caption, text, textButton0, + QString::null, QString::null, 0, 0 ); + qApp->processEvents(); + return ret; } /*! Shows warning message box with one button [ static ] */ -int SUIT_MessageBox::warn1( QWidget* parent, const QString& caption, const QString& text, - const QString& textButton0 ) +int SUIT_MessageBox::warn1( QWidget* parent, + const QString& caption, + const QString& text, + const QString& textButton0 ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); - int ret = QMessageBox::warning( parent, caption, text, textButton0, - QString::null, QString::null, 0, 0 ); - qApp->processEvents(); - return ret; + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + int ret = QMessageBox::warning( parent, caption, text, textButton0, + QString::null, QString::null, 0, 0 ); + qApp->processEvents(); + return ret; } /*! Shows error message box with one button [ static ] */ -int SUIT_MessageBox::error1( QWidget* parent, const QString& caption, - const QString& text, const QString& textButton0 ) +int SUIT_MessageBox::error1( QWidget* parent, + const QString& caption, + const QString& text, + const QString& textButton0 ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); - int ret = QMessageBox::critical( parent, caption, text, textButton0, - QString::null, QString::null, 0, 0 ); - qApp->processEvents(); - return ret; + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + int ret = QMessageBox::critical( parent, caption, text, textButton0, + QString::null, QString::null, 0, 0 ); + qApp->processEvents(); + return ret; +} + +/*! + Shows question message box with one button [ static ] +*/ +int SUIT_MessageBox::question1( QWidget* parent, + const QString& caption, + const QString& text, + const QString& textButton0 ) +{ + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + int ret = QMessageBox::question( parent, caption, text, textButton0, + QString::null, QString::null, 0, 0 ); + qApp->processEvents(); + return ret; } /*! Shows info message box with two buttons. Returns id of the pressed button or -1 if escaped [ static ] */ -int SUIT_MessageBox::info2( QWidget* parent, const QString& caption, - const QString& text, const QString& textButton0, - const QString& textButton1, int idButton0, int idButton1, int idDefault ) +int SUIT_MessageBox::info2( QWidget* parent, + const QString& caption, + const QString& text, + const QString& textButton0, + const QString& textButton1, + int idButton0, int idButton1, int idDefault ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); - if ( idDefault == idButton0 ) - idDefault = 0; - else if ( idDefault == idButton1 ) - idDefault = 1; - else - idDefault = 0; - - int ret = QMessageBox::information( parent, caption, text, textButton0, - textButton1, QString::null, idDefault ); - qApp->processEvents(); - return ( ret == 0 ? idButton0 : idButton1 ); + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + if ( idDefault == idButton0 ) + idDefault = 0; + else if ( idDefault == idButton1 ) + idDefault = 1; + else + idDefault = 0; + + int ret = QMessageBox::information( parent, caption, text, textButton0, + textButton1, QString::null, idDefault ); + qApp->processEvents(); + return ( ret == 0 ? idButton0 : idButton1 ); } /*! - Shows warning message box with two buttons. + Shows warning message box with two buttons. Returns id of the pressed button or -1 if escaped [ static ] */ -int SUIT_MessageBox::warn2( QWidget* parent, const QString& caption, const QString& text, - const QString& textButton0, const QString& textButton1, - int idButton0, int idButton1, int idDefault ) +int SUIT_MessageBox::warn2( QWidget* parent, + const QString& caption, + const QString& text, + const QString& textButton0, + const QString& textButton1, + int idButton0, int idButton1, int idDefault ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); - - if ( idDefault == idButton0 ) - idDefault = 0; - else if ( idDefault == idButton1 ) - idDefault = 1; - else - idDefault = 0; - - int ret = QMessageBox::warning( parent, caption, text, textButton0, - textButton1, QString::null, idDefault ); - qApp->processEvents(); - return ( ret == 0 ? idButton0 : idButton1 ); + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + + if ( idDefault == idButton0 ) + idDefault = 0; + else if ( idDefault == idButton1 ) + idDefault = 1; + else + idDefault = 0; + + int ret = QMessageBox::warning( parent, caption, text, textButton0, + textButton1, QString::null, idDefault ); + qApp->processEvents(); + return ( ret == 0 ? idButton0 : idButton1 ); } /*! Shows error message box with two buttons Returns id of the pressed button or -1 if escaped [ static ] */ -int SUIT_MessageBox::error2( QWidget* parent, const QString& caption, const QString& text, - const QString& textButton0, const QString& textButton1, - int idButton0, int idButton1, int idDefault ) +int SUIT_MessageBox::error2( QWidget* parent, + const QString& caption, + const QString& text, + const QString& textButton0, + const QString& textButton1, + int idButton0, int idButton1, int idDefault ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); - - if ( idDefault == idButton0 ) - idDefault = 0; - else if ( idDefault == idButton1 ) - idDefault = 1; - else - idDefault = 0; + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + + if ( idDefault == idButton0 ) + idDefault = 0; + else if ( idDefault == idButton1 ) + idDefault = 1; + else + idDefault = 0; + + int ret = QMessageBox::critical( parent, caption, text, textButton0, + textButton1, QString::null, idDefault ); + qApp->processEvents(); + return ( ret == 0 ? idButton0 : idButton1 ); +} - int ret = QMessageBox::critical( parent, caption, text, textButton0, - textButton1, QString::null, idDefault ); - qApp->processEvents(); - return ( ret == 0 ? idButton0 : idButton1 ); +/*! + Shows question message box with two buttons + Returns id of the pressed button or -1 if escaped [ static ] +*/ +int SUIT_MessageBox::question2( QWidget* parent, + const QString& caption, + const QString& text, + const QString& textButton0, + const QString& textButton1, + int idButton0, int idButton1, int idDefault ) +{ + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + + if ( idDefault == idButton0 ) + idDefault = 0; + else if ( idDefault == idButton1 ) + idDefault = 1; + else + idDefault = 0; + + int ret = QMessageBox::question( parent, caption, text, textButton0, + textButton1, QString::null, idDefault ); + qApp->processEvents(); + return ( ret == 0 ? idButton0 : idButton1 ); } /*! Shows info message box with three buttons. Returns id of the pressed button or -1 if escaped [ static ] */ -int SUIT_MessageBox::info3( QWidget* parent, const QString& caption, const QString& text, - const QString& textButton0, const QString& textButton1, - const QString& textButton2, int idButton0, int idButton1, - int idButton2, int idDefault ) +int SUIT_MessageBox::info3( QWidget* parent, + const QString& caption, + const QString& text, + const QString& textButton0, + const QString& textButton1, + const QString& textButton2, + int idButton0, int idButton1, + int idButton2, int idDefault ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); - - if ( idDefault == idButton0 ) - idDefault = 0; - else if ( idDefault == idButton1 ) - idDefault = 1; - else if ( idDefault == idButton2 ) - idDefault = 2; - else - idDefault = 0; - - int ret = QMessageBox::information( parent, caption, text, textButton0, - textButton1, textButton2, idDefault ); - qApp->processEvents(); - switch ( ret ) + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + + if ( idDefault == idButton0 ) + idDefault = 0; + else if ( idDefault == idButton1 ) + idDefault = 1; + else if ( idDefault == idButton2 ) + idDefault = 2; + else + idDefault = 0; + + int ret = QMessageBox::information( parent, caption, text, textButton0, + textButton1, textButton2, idDefault ); + qApp->processEvents(); + switch ( ret ) { - case 0: - return idButton0; - case 1: - return idButton1; - case 2: - return idButton2; + case 0: + return idButton0; + case 1: + return idButton1; + case 2: + return idButton2; } - return -1; + return -1; } /*! Shows warning message box with three buttons. Returns id of the pressed button or -1 if escaped [ static ] */ -int SUIT_MessageBox::warn3( QWidget* parent, const QString& caption, const QString& text, - const QString& textButton0, const QString& textButton1, - const QString& textButton2, int idButton0, int idButton1, - int idButton2, int idDefault ) +int SUIT_MessageBox::warn3( QWidget* parent, + const QString& caption, + const QString& text, + const QString& textButton0, + const QString& textButton1, + const QString& textButton2, + int idButton0, int idButton1, + int idButton2, int idDefault ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); - - if ( idDefault == idButton0 ) - idDefault = 0; - else if ( idDefault == idButton1 ) - idDefault = 1; - else if ( idDefault == idButton2 ) - idDefault = 2; - else - idDefault = 0; - - int ret = QMessageBox::warning( parent, caption, text, textButton0, - textButton1, textButton2, idDefault ); - qApp->processEvents(); - switch ( ret ) + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + + if ( idDefault == idButton0 ) + idDefault = 0; + else if ( idDefault == idButton1 ) + idDefault = 1; + else if ( idDefault == idButton2 ) + idDefault = 2; + else + idDefault = 0; + + int ret = QMessageBox::warning( parent, caption, text, textButton0, + textButton1, textButton2, idDefault ); + qApp->processEvents(); + switch ( ret ) { - case 0: - return idButton0; - case 1: - return idButton1; - case 2: - return idButton2; + case 0: + return idButton0; + case 1: + return idButton1; + case 2: + return idButton2; } - return -1; + return -1; } /*! Shows error message box with three buttons. Returns id of the pressed button or -1 if escaped [ static ] */ -int SUIT_MessageBox::error3( QWidget* parent, const QString& caption, const QString& text, - const QString& textButton0, const QString& textButton1, - const QString& textButton2, int idButton0, int idButton1, - int idButton2, int idDefault ) +int SUIT_MessageBox::error3( QWidget* parent, + const QString& caption, + const QString& text, + const QString& textButton0, + const QString& textButton1, + const QString& textButton2, + int idButton0, int idButton1, + int idButton2, int idDefault ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); - - if ( idDefault == idButton0 ) - idDefault = 0; - else if ( idDefault == idButton1 ) - idDefault = 1; - else if ( idDefault == idButton2 ) - idDefault = 2; - else - idDefault = 0; + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + + if ( idDefault == idButton0 ) + idDefault = 0; + else if ( idDefault == idButton1 ) + idDefault = 1; + else if ( idDefault == idButton2 ) + idDefault = 2; + else + idDefault = 0; + + int ret = QMessageBox::critical( parent, caption, text, textButton0, + textButton1, textButton2, idDefault ); + qApp->processEvents(); + switch ( ret ) + { + case 0: + return idButton0; + case 1: + return idButton1; + case 2: + return idButton2; + } + return -1; +} - int ret = QMessageBox::critical( parent, caption, text, textButton0, - textButton1, textButton2, idDefault ); - qApp->processEvents(); - switch ( ret ) +/*! + Shows question message box with three buttons. + Returns id of the pressed button or -1 if escaped [ static ] +*/ +int SUIT_MessageBox::question3( QWidget* parent, + const QString& caption, + const QString& text, + const QString& textButton0, + const QString& textButton1, + const QString& textButton2, + int idButton0, int idButton1, + int idButton2, int idDefault ) +{ + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::arrowCursor ); + + if ( idDefault == idButton0 ) + idDefault = 0; + else if ( idDefault == idButton1 ) + idDefault = 1; + else if ( idDefault == idButton2 ) + idDefault = 2; + else + idDefault = 0; + + int ret = QMessageBox::question( parent, caption, text, textButton0, + textButton1, textButton2, idDefault ); + qApp->processEvents(); + switch ( ret ) { - case 0: - return idButton0; - case 1: - return idButton1; - case 2: - return idButton2; + case 0: + return idButton0; + case 1: + return idButton1; + case 2: + return idButton2; } - return -1; + return -1; } diff --git a/src/SUIT/SUIT_MessageBox.h b/src/SUIT/SUIT_MessageBox.h index dd8dccd53..f8cf626be 100755 --- a/src/SUIT/SUIT_MessageBox.h +++ b/src/SUIT/SUIT_MessageBox.h @@ -48,6 +48,8 @@ public: const QString& textButton0 ); static int error1 ( QWidget* parent, const QString& caption, const QString& text, const QString& textButton0 ); + static int question1 ( QWidget* parent, const QString& caption, const QString& text, + const QString& textButton0 ); //@} /** @name Two buttons message boxes.*/ @@ -61,6 +63,9 @@ public: static int error2 ( QWidget* parent, const QString& caption, const QString& text, const QString& textButton0, const QString& textButton1, int idButton0, int idButton1, int idDefault ); + static int question2 ( QWidget* parent, const QString& caption, const QString& text, + const QString& textButton0, const QString& textButton1, + int idButton0, int idButton1, int idDefault ); //@} /** @name Three buttons message boxes.*/ @@ -77,6 +82,10 @@ public: const QString& textButton0, const QString& textButton1, const QString& textButton2, int idButton0, int idButton1, int idButton2, int idDefault ); + static int question3 ( QWidget* parent, const QString& caption, const QString& text, + const QString& textButton0, const QString& textButton1, + const QString& textButton2, int idButton0, int idButton1, + int idButton2, int idDefault ); //@} }; diff --git a/src/SVTK/SVTK_ViewModel.cxx b/src/SVTK/SVTK_ViewModel.cxx index 60942b844..a8a11fbd2 100644 --- a/src/SVTK/SVTK_ViewModel.cxx +++ b/src/SVTK/SVTK_ViewModel.cxx @@ -16,462 +16,463 @@ // // See http://www.salome-platform.org/ // -#include -#include - -#include -#include -#include - -#include "SUIT_Session.h" - -#include "SVTK_Selection.h" -#include "SVTK_ViewModel.h" -#include "SVTK_ViewWindow.h" -#include "SVTK_Prs.h" - -#include "VTKViewer_ViewModel.h" - -#include "SVTK_RenderWindowInteractor.h" -#include "SVTK_RenderWindow.h" - -//#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 "Utils_ORB_INIT.hxx" -//#include "Utils_SINGLETON.hxx" -//#include "SALOME_ModuleCatalog_impl.hxx" -//#include "SALOME_NamingService.hxx" - -//#include "SALOMEDSClient.hxx" -//#include "SALOMEDS_StudyManager.hxx" - -// in order NOT TO link with SalomeApp, here the code returns SALOMEDS_Study. -// SalomeApp_Study::studyDS() does it as well, but -- here it is retrieved from -// SALOMEDS::StudyManager - no linkage with SalomeApp. - -// 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 - // get SALOMEDS_Study with this id from StudyMgr -// return aMgr->GetStudyByID( id ); -//} - -//========================================================== -SVTK_Viewer::SVTK_Viewer() -{ - myTrihedronSize = 100; -} - -//========================================================== -SVTK_Viewer::~SVTK_Viewer() -{ -} - -QColor SVTK_Viewer::backgroundColor() const -{ - return myBgColor; -} - -void SVTK_Viewer::setBackgroundColor( const QColor& c ) -{ - if ( c.isValid() ) - myBgColor = c; -} - -//========================================================== -SUIT_ViewWindow* SVTK_Viewer::createView( SUIT_Desktop* theDesktop ) -{ - SVTK_ViewWindow* vw = new SVTK_ViewWindow( theDesktop, this ); - vw->setBackgroundColor( backgroundColor() ); - vw->SetTrihedronSize( trihedronSize() ); - return vw; -} - -int SVTK_Viewer::trihedronSize() const -{ - return myTrihedronSize; -} - -void SVTK_Viewer::setTrihedronSize( const int sz ) -{ - myTrihedronSize = sz; - - SUIT_ViewManager* vm = getViewManager(); - if ( !vm ) - return; - - QPtrVector vec = vm->getViews(); - for ( int i = 0; i < vec.count(); i++ ) - { - SUIT_ViewWindow* win = vec.at( i ); - if ( !win || !win->inherits( "SVTK_ViewWindow" ) ) - continue; - - SVTK_ViewWindow* vw = (SVTK_ViewWindow*)win; - vw->SetTrihedronSize( sz ); - } -} - -//========================================================== -void SVTK_Viewer::setViewManager(SUIT_ViewManager* theViewManager) -{ - SUIT_ViewModel::setViewManager(theViewManager); - - if ( !theViewManager ) - return; - - connect(theViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), - this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*))); - - connect(theViewManager, SIGNAL(mouseMove(SUIT_ViewWindow*, QMouseEvent*)), - this, SLOT(onMouseMove(SUIT_ViewWindow*, QMouseEvent*))); - - connect(theViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)), - this, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*))); -} - -//========================================================== -void SVTK_Viewer::contextMenuPopup( QPopupMenu* thePopup ) -{ - thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) ); - thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_CHANGE_BACKGROUD" ), this, SLOT( onChangeBgColor() ) ); - - thePopup->insertSeparator(); - - SVTK_ViewWindow* aView = (SVTK_ViewWindow*)(myViewManager->getActiveView()); - if ( aView && !aView->getToolBar()->isVisible() ) - thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_SHOW_TOOLBAR" ), this, SLOT( onShowToolbar() ) ); -} - -//========================================================== -void SVTK_Viewer::onMousePress(SUIT_ViewWindow* vw, QMouseEvent* event) -{ - if(SVTK_ViewWindow* aVW = dynamic_cast(vw)){ - if(SVTK_RenderWindowInteractor* aRWI = aVW->getRWInteractor()){ - switch(event->button()) { - case LeftButton: - aRWI->LeftButtonPressed(event) ; - break ; - case MidButton: - aRWI->MiddleButtonPressed(event) ; - break ; - case RightButton: - aRWI->RightButtonPressed(event) ; - break; - default: - break ; - } - } - } -} - -//========================================================== -void -SVTK_Viewer -::onMouseMove(SUIT_ViewWindow* vw, QMouseEvent* event) -{ - if(SVTK_ViewWindow* aVW = dynamic_cast(vw)){ - if(SVTK_RenderWindowInteractor* aRWI = aVW->getRWInteractor()){ - aRWI->MouseMove( event ); - } - } -} - -//========================================================== -void -SVTK_Viewer -::onMouseRelease(SUIT_ViewWindow* vw, QMouseEvent* event) -{ - if(SVTK_ViewWindow* aVW = dynamic_cast(vw)){ - if(SVTK_RenderWindowInteractor* aRWI = aVW->getRWInteractor()){ - switch(event->button()) { - case LeftButton: - aRWI->LeftButtonReleased(event) ; - break ; - case MidButton: - aRWI->MiddleButtonReleased(event) ; - break ; - case RightButton: - aRWI->RightButtonReleased(event) ; - break; - default: - break ; - } - } - } -} - -//========================================================== -void -SVTK_Viewer -::enableSelection(bool isEnabled) -{ - mySelectionEnabled = isEnabled; - //!! To be done for view windows -} - -//========================================================== -void -SVTK_Viewer -::enableMultiselection(bool isEnable) -{ - myMultiSelectionEnabled = isEnable; - //!! To be done for view windows -} - -void SVTK_Viewer::onDumpView() -{ - SVTK_ViewWindow* aView = (SVTK_ViewWindow*)(myViewManager->getActiveView()); - if ( aView ) - aView->onDumpView(); -} - -//========================================================== -void SVTK_Viewer::onChangeBgColor() -{ - QPtrVector aViews = myViewManager->getViews(); - for(int i = 0, iEnd = aViews.size(); i < iEnd; i++) - if(SUIT_ViewWindow* aViewWindow = aViews.at(i)) - if(SVTK_ViewWindow* aView = dynamic_cast(aViewWindow)){ - QColor aColor = QColorDialog::getColor( aView->backgroundColor(), aView); - if ( aColor.isValid() ) - aView->setBackgroundColor(aColor); - } -} - -//========================================================== -void -SVTK_Viewer -::onShowToolbar() -{ - QPtrVector aViews = myViewManager->getViews(); - for(int i = 0, iEnd = aViews.size(); i < iEnd; i++) - if(SUIT_ViewWindow* aViewWindow = aViews.at(i)) - if(SVTK_ViewWindow* aView = dynamic_cast(aViewWindow)) - aView->getToolBar()->show(); -} - -//========================================================== -void -SVTK_Viewer -::Display( const SALOME_VTKPrs* prs ) -{ - // try do downcast object - if(const SVTK_Prs* aPrs = dynamic_cast( prs )){ - if(aPrs->IsNull()) - return; - if(vtkActorCollection* anActorCollection = aPrs->GetObjects()){ - // get SALOMEDS Study - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - // _PTR(Study) aStudy(getStudyDS()); - anActorCollection->InitTraversal(); - while(vtkActor* anActor = anActorCollection->GetNextActor()){ - if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){ - // Set visibility flag - // 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 = anAct->getIO(); - //if(!anObj.IsNull() && anObj->hasEntry() && aStudy){ - // ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),true,this); - //} - // just display the object - QPtrVector aViews = myViewManager->getViews(); - for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ - if(SUIT_ViewWindow* aViewWindow = aViews.at(i)){ - if(SVTK_ViewWindow* aView = dynamic_cast(aViewWindow)){ - if(SVTK_RenderWindowInteractor* aRWI = aView->getRWInteractor()){ - aRWI->Display(anAct,false); - if(anAct->IsSetCamera()){ - vtkRenderer* aRenderer = aView->getRenderer(); - anAct->SetCamera( aRenderer->GetActiveCamera() ); - } - } - } - } - } - } - } - } - } -} - -//========================================================== -void -SVTK_Viewer -::Erase( const SALOME_VTKPrs* prs, const bool forced ) -{ - // try do downcast object - if(const SVTK_Prs* aPrs = dynamic_cast( prs )){ - if(aPrs->IsNull()) - return; - if(vtkActorCollection* anActorCollection = aPrs->GetObjects()){ - // get SALOMEDS Study - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - //_PTR(Study) aStudy(getStudyDS()); - anActorCollection->InitTraversal(); - while(vtkActor* anActor = anActorCollection->GetNextActor()) - if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){ - // Set visibility flag - // 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 = anAct->getIO(); - //if(!anObj.IsNull() && anObj->hasEntry() && aStudy){ - // ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this); - //} - // just display the object - QPtrVector aViews = myViewManager->getViews(); - for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ - if(SUIT_ViewWindow* aViewWindow = aViews.at(i)) - if(SVTK_ViewWindow* aView = dynamic_cast(aViewWindow)) - if(SVTK_RenderWindowInteractor* aRWI = aView->getRWInteractor()) - if ( forced ) - aRWI->Remove(anAct,false); - else - aRWI->Erase(anAct,forced); - } - } - } - } -} - -//========================================================== -void -SVTK_Viewer -::EraseAll( const bool forced ) -{ - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - //_PTR(Study) aStudy(getStudyDS()); - QPtrVector aViews = myViewManager->getViews(); - for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ - if(SUIT_ViewWindow* aViewWindow = aViews.at(i)){ - if(SVTK_ViewWindow* aView = dynamic_cast(aViewWindow)){ - vtkRenderer* aRenderer = aView->getRenderer(); - vtkActorCollection* anActorCollection = aRenderer->GetActors(); - anActorCollection->InitTraversal(); - while(vtkActor* anActor = anActorCollection->GetNextActor()){ - if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){ - // Set visibility flag - // 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 = anAct->getIO(); - //if(!anObj.IsNull() && anObj->hasEntry() && aStudy) - // ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this); - if(forced) - aRenderer->RemoveActor(anAct); - else{ - // just erase actor - anAct->SetVisibility( false ); - // erase dependent actors - vtkActorCollection* aCollection = vtkActorCollection::New(); - anAct->GetChildActors( aCollection ); - aCollection->InitTraversal(); - while(vtkActor* aSubAct = aCollection->GetNextActor()) - aSubAct->SetVisibility( false ); - aCollection->Delete(); - } - } - } - } - } - } - Repaint(); -} - -//========================================================== -SALOME_Prs* -SVTK_Viewer -::CreatePrs( const char* entry ) -{ - SVTK_Prs* prs = new SVTK_Prs(); - if ( entry ) { - vtkRenderer* rnr = ( (SVTK_ViewWindow*) getViewManager()->getActiveView() )->getRenderer(); - vtkActorCollection* theActors = rnr->GetActors(); - theActors->InitTraversal(); - vtkActor* ac; - while( ( ac = theActors->GetNextActor() ) ) { - SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ); - if ( anActor && anActor->hasIO() && !strcmp( anActor->getIO()->getEntry(), entry ) ) { - prs->AddObject( ac ); - } - } - } - return prs; -} - -//========================================================== -void -SVTK_Viewer -::BeforeDisplay( SALOME_Displayer* d ) -{ - d->BeforeDisplay( this, SALOME_VTKViewType() ); -} - -//========================================================== -void -SVTK_Viewer::AfterDisplay( SALOME_Displayer* d ) -{ - d->AfterDisplay( this, SALOME_VTKViewType() ); -} - -//========================================================== -bool -SVTK_Viewer -::isVisible( const Handle(SALOME_InteractiveObject)& io ) -{ - QPtrVector aViews = myViewManager->getViews(); - for(int i = 0, iEnd = aViews.size(); i < iEnd; i++) - if(SUIT_ViewWindow* aViewWindow = aViews.at(i)) - if(SVTK_ViewWindow* aView = dynamic_cast(aViewWindow)) - if(SVTK_RenderWindowInteractor* aRWI = aView->getRWInteractor()) - if(!aRWI->isVisible( io )) - return false; - return true; -} - -//========================================================== -void -SVTK_Viewer -::Repaint() -{ -// if (theUpdateTrihedron) onAdjustTrihedron(); - QPtrVector aViews = myViewManager->getViews(); - for(int i = 0, iEnd = aViews.size(); i < iEnd; i++) - if(SUIT_ViewWindow* aViewWindow = aViews.at(i)) - if(SVTK_ViewWindow* aView = dynamic_cast(aViewWindow)) - if(SVTK_RenderWindow* aRW = aView->getRenderWindow()) - aRW->update(); -} - -void -SVTK_Viewer -::onSelectionChanged() -{ - emit selectionChanged(); -} - +#include +#include + +#include +#include +#include + +#include "SUIT_Session.h" + +#include "SVTK_Selection.h" +#include "SVTK_ViewModel.h" +#include "SVTK_ViewWindow.h" +#include "SVTK_Prs.h" + +#include "VTKViewer_ViewModel.h" + +#include "SVTK_RenderWindowInteractor.h" +#include "SVTK_RenderWindow.h" + +//#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 "Utils_ORB_INIT.hxx" +//#include "Utils_SINGLETON.hxx" +//#include "SALOME_ModuleCatalog_impl.hxx" +//#include "SALOME_NamingService.hxx" + +//#include "SALOMEDSClient.hxx" +//#include "SALOMEDS_StudyManager.hxx" + +// in order NOT TO link with SalomeApp, here the code returns SALOMEDS_Study. +// SalomeApp_Study::studyDS() does it as well, but -- here it is retrieved from +// SALOMEDS::StudyManager - no linkage with SalomeApp. + +// 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 + // get SALOMEDS_Study with this id from StudyMgr +// return aMgr->GetStudyByID( id ); +//} + +//========================================================== +SVTK_Viewer::SVTK_Viewer() +{ + myTrihedronSize = 100; +} + +//========================================================== +SVTK_Viewer::~SVTK_Viewer() +{ +} + +QColor SVTK_Viewer::backgroundColor() const +{ + return myBgColor; +} + +void SVTK_Viewer::setBackgroundColor( const QColor& c ) +{ + if ( c.isValid() ) + myBgColor = c; +} + +//========================================================== +SUIT_ViewWindow* SVTK_Viewer::createView( SUIT_Desktop* theDesktop ) +{ + SVTK_ViewWindow* vw = new SVTK_ViewWindow( theDesktop, this ); + vw->setBackgroundColor( backgroundColor() ); + vw->SetTrihedronSize( trihedronSize() ); + return vw; +} + +int SVTK_Viewer::trihedronSize() const +{ + return myTrihedronSize; +} + +void SVTK_Viewer::setTrihedronSize( const int sz ) +{ + myTrihedronSize = sz; + + SUIT_ViewManager* vm = getViewManager(); + if ( !vm ) + return; + + QPtrVector vec = vm->getViews(); + for ( int i = 0; i < vec.count(); i++ ) + { + SUIT_ViewWindow* win = vec.at( i ); + if ( !win || !win->inherits( "SVTK_ViewWindow" ) ) + continue; + + SVTK_ViewWindow* vw = (SVTK_ViewWindow*)win; + vw->SetTrihedronSize( sz ); + } +} + +//========================================================== +void SVTK_Viewer::setViewManager(SUIT_ViewManager* theViewManager) +{ + SUIT_ViewModel::setViewManager(theViewManager); + + if ( !theViewManager ) + return; + + connect(theViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), + this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*))); + + connect(theViewManager, SIGNAL(mouseMove(SUIT_ViewWindow*, QMouseEvent*)), + this, SLOT(onMouseMove(SUIT_ViewWindow*, QMouseEvent*))); + + connect(theViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)), + this, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*))); +} + +//========================================================== +void SVTK_Viewer::contextMenuPopup( QPopupMenu* thePopup ) +{ + thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) ); + thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_CHANGE_BACKGROUD" ), this, SLOT( onChangeBgColor() ) ); + + thePopup->insertSeparator(); + + SVTK_ViewWindow* aView = (SVTK_ViewWindow*)(myViewManager->getActiveView()); + if ( aView && !aView->getToolBar()->isVisible() ) + thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_SHOW_TOOLBAR" ), this, SLOT( onShowToolbar() ) ); +} + +//========================================================== +void SVTK_Viewer::onMousePress(SUIT_ViewWindow* vw, QMouseEvent* event) +{ + if(SVTK_ViewWindow* aVW = dynamic_cast(vw)){ + if(SVTK_RenderWindowInteractor* aRWI = aVW->getRWInteractor()){ + switch(event->button()) { + case LeftButton: + aRWI->LeftButtonPressed(event) ; + break ; + case MidButton: + aRWI->MiddleButtonPressed(event) ; + break ; + case RightButton: + aRWI->RightButtonPressed(event) ; + break; + default: + break ; + } + } + } +} + +//========================================================== +void +SVTK_Viewer +::onMouseMove(SUIT_ViewWindow* vw, QMouseEvent* event) +{ + if(SVTK_ViewWindow* aVW = dynamic_cast(vw)){ + if(SVTK_RenderWindowInteractor* aRWI = aVW->getRWInteractor()){ + aRWI->MouseMove( event ); + } + } +} + +//========================================================== +void +SVTK_Viewer +::onMouseRelease(SUIT_ViewWindow* vw, QMouseEvent* event) +{ + if(SVTK_ViewWindow* aVW = dynamic_cast(vw)){ + if(SVTK_RenderWindowInteractor* aRWI = aVW->getRWInteractor()){ + switch(event->button()) { + case LeftButton: + aRWI->LeftButtonReleased(event) ; + break ; + case MidButton: + aRWI->MiddleButtonReleased(event) ; + break ; + case RightButton: + aRWI->RightButtonReleased(event) ; + break; + default: + break ; + } + } + } +} + +//========================================================== +void +SVTK_Viewer +::enableSelection(bool isEnabled) +{ + mySelectionEnabled = isEnabled; + //!! To be done for view windows +} + +//========================================================== +void +SVTK_Viewer +::enableMultiselection(bool isEnable) +{ + myMultiSelectionEnabled = isEnable; + //!! To be done for view windows +} + +void SVTK_Viewer::onDumpView() +{ + SVTK_ViewWindow* aView = dynamic_cast(myViewManager->getActiveView()); + if ( aView ) + aView->onDumpView(); +} + +//========================================================== +void SVTK_Viewer::onChangeBgColor() +{ + SVTK_ViewWindow* aView = dynamic_cast(myViewManager->getActiveView()); + if ( aView ) { + QColor aColor = QColorDialog::getColor( aView->backgroundColor(), aView ); + if ( aColor.isValid() ) + aView->setBackgroundColor( aColor ); + } +} + +//========================================================== +void +SVTK_Viewer +::onShowToolbar() +{ + QPtrVector aViews = myViewManager->getViews(); + for(int i = 0, iEnd = aViews.size(); i < iEnd; i++) + if(SUIT_ViewWindow* aViewWindow = aViews.at(i)) + if(SVTK_ViewWindow* aView = dynamic_cast(aViewWindow)) + aView->getToolBar()->show(); +} + +//========================================================== +void +SVTK_Viewer +::Display( const SALOME_VTKPrs* prs ) +{ + // try do downcast object + if(const SVTK_Prs* aPrs = dynamic_cast( prs )){ + if(aPrs->IsNull()) + return; + if(vtkActorCollection* anActorCollection = aPrs->GetObjects()){ + // get SALOMEDS Study + // Temporarily commented to avoid awful dependecy on SALOMEDS + // TODO: better mechanism of storing display/erse status in a study + // should be provided... + // _PTR(Study) aStudy(getStudyDS()); + anActorCollection->InitTraversal(); + while(vtkActor* anActor = anActorCollection->GetNextActor()){ + if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){ + // Set visibility flag + // 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 = anAct->getIO(); + //if(!anObj.IsNull() && anObj->hasEntry() && aStudy){ + // ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),true,this); + //} + // just display the object + QPtrVector aViews = myViewManager->getViews(); + for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ + if(SUIT_ViewWindow* aViewWindow = aViews.at(i)){ + if(SVTK_ViewWindow* aView = dynamic_cast(aViewWindow)){ + if(SVTK_RenderWindowInteractor* aRWI = aView->getRWInteractor()){ + aRWI->Display(anAct,false); + if(anAct->IsSetCamera()){ + vtkRenderer* aRenderer = aView->getRenderer(); + anAct->SetCamera( aRenderer->GetActiveCamera() ); + } + } + } + } + } + } + } + } + } +} + +//========================================================== +void +SVTK_Viewer +::Erase( const SALOME_VTKPrs* prs, const bool forced ) +{ + // try do downcast object + if(const SVTK_Prs* aPrs = dynamic_cast( prs )){ + if(aPrs->IsNull()) + return; + if(vtkActorCollection* anActorCollection = aPrs->GetObjects()){ + // get SALOMEDS Study + // Temporarily commented to avoid awful dependecy on SALOMEDS + // TODO: better mechanism of storing display/erse status in a study + // should be provided... + //_PTR(Study) aStudy(getStudyDS()); + anActorCollection->InitTraversal(); + while(vtkActor* anActor = anActorCollection->GetNextActor()) + if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){ + // Set visibility flag + // 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 = anAct->getIO(); + //if(!anObj.IsNull() && anObj->hasEntry() && aStudy){ + // ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this); + //} + // just display the object + QPtrVector aViews = myViewManager->getViews(); + for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ + if(SUIT_ViewWindow* aViewWindow = aViews.at(i)) + if(SVTK_ViewWindow* aView = dynamic_cast(aViewWindow)) + if(SVTK_RenderWindowInteractor* aRWI = aView->getRWInteractor()) + if ( forced ) + aRWI->Remove(anAct,false); + else + aRWI->Erase(anAct,forced); + } + } + } + } +} + +//========================================================== +void +SVTK_Viewer +::EraseAll( const bool forced ) +{ + // Temporarily commented to avoid awful dependecy on SALOMEDS + // TODO: better mechanism of storing display/erse status in a study + // should be provided... + //_PTR(Study) aStudy(getStudyDS()); + QPtrVector aViews = myViewManager->getViews(); + for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ + if(SUIT_ViewWindow* aViewWindow = aViews.at(i)){ + if(SVTK_ViewWindow* aView = dynamic_cast(aViewWindow)){ + + aView->unHighlightAll(); + + vtkRenderer* aRenderer = aView->getRenderer(); + vtkActorCollection* anActorCollection = aRenderer->GetActors(); + anActorCollection->InitTraversal(); + while(vtkActor* anActor = anActorCollection->GetNextActor()){ + if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){ + // Set visibility flag + // 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 = anAct->getIO(); + //if(!anObj.IsNull() && anObj->hasEntry() && aStudy) + // ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this); + if(forced) + aRenderer->RemoveActor(anAct); + else{ + // just erase actor + anAct->SetVisibility( false ); + // erase dependent actors + vtkActorCollection* aCollection = vtkActorCollection::New(); + anAct->GetChildActors( aCollection ); + aCollection->InitTraversal(); + while(vtkActor* aSubAct = aCollection->GetNextActor()) + aSubAct->SetVisibility( false ); + aCollection->Delete(); + } + } + } + } + } + } + Repaint(); +} + +//========================================================== +SALOME_Prs* +SVTK_Viewer +::CreatePrs( const char* entry ) +{ + SVTK_Prs* prs = new SVTK_Prs(); + if ( entry ) { + vtkRenderer* rnr = ( (SVTK_ViewWindow*) getViewManager()->getActiveView() )->getRenderer(); + vtkActorCollection* theActors = rnr->GetActors(); + theActors->InitTraversal(); + vtkActor* ac; + while( ( ac = theActors->GetNextActor() ) ) { + SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ); + if ( anActor && anActor->hasIO() && !strcmp( anActor->getIO()->getEntry(), entry ) ) { + prs->AddObject( ac ); + } + } + } + return prs; +} + +//========================================================== +void +SVTK_Viewer +::BeforeDisplay( SALOME_Displayer* d ) +{ + d->BeforeDisplay( this, SALOME_VTKViewType() ); +} + +//========================================================== +void +SVTK_Viewer::AfterDisplay( SALOME_Displayer* d ) +{ + d->AfterDisplay( this, SALOME_VTKViewType() ); +} + +//========================================================== +bool +SVTK_Viewer +::isVisible( const Handle(SALOME_InteractiveObject)& io ) +{ + QPtrVector aViews = myViewManager->getViews(); + for(int i = 0, iEnd = aViews.size(); i < iEnd; i++) + if(SUIT_ViewWindow* aViewWindow = aViews.at(i)) + if(SVTK_ViewWindow* aView = dynamic_cast(aViewWindow)) + if(SVTK_RenderWindowInteractor* aRWI = aView->getRWInteractor()) + if(!aRWI->isVisible( io )) + return false; + return true; +} + +//========================================================== +void +SVTK_Viewer +::Repaint() +{ +// if (theUpdateTrihedron) onAdjustTrihedron(); + QPtrVector aViews = myViewManager->getViews(); + for(int i = 0, iEnd = aViews.size(); i < iEnd; i++) + if(SUIT_ViewWindow* aViewWindow = aViews.at(i)) + if(SVTK_ViewWindow* aView = dynamic_cast(aViewWindow)) + if(SVTK_RenderWindow* aRW = aView->getRenderWindow()) + aRW->update(); +} + +void +SVTK_Viewer +::onSelectionChanged() +{ + emit selectionChanged(); +} + diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 26df49c6c..690b13b52 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -80,7 +80,8 @@ SalomeApp_Application::SalomeApp_Application() */ SalomeApp_Application::~SalomeApp_Application() { - SalomeApp_EventFilter::Destroy(); + // Do not destroy. It's a singleton ! + //SalomeApp_EventFilter::Destroy(); } /*!Start application.*/ @@ -101,27 +102,27 @@ void SalomeApp_Application::createActions() //! Dump study createAction( DumpStudyId, tr( "TOT_DESK_FILE_DUMP_STUDY" ), QIconSet(), tr( "MEN_DESK_FILE_DUMP_STUDY" ), tr( "PRP_DESK_FILE_DUMP_STUDY" ), - 0, desk, false, this, SLOT( onDumpStudy() ) ); + CTRL+Key_D, desk, false, this, SLOT( onDumpStudy() ) ); //! Load script createAction( LoadScriptId, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), QIconSet(), tr( "MEN_DESK_FILE_LOAD_SCRIPT" ), tr( "PRP_DESK_FILE_LOAD_SCRIPT" ), - 0, desk, false, this, SLOT( onLoadScript() ) ); + CTRL+Key_T, desk, false, this, SLOT( onLoadScript() ) ); //! Properties createAction( PropertiesId, tr( "TOT_DESK_PROPERTIES" ), QIconSet(), tr( "MEN_DESK_PROPERTIES" ), tr( "PRP_DESK_PROPERTIES" ), - 0, desk, false, this, SLOT( onProperties() ) ); + CTRL+Key_P, desk, false, this, SLOT( onProperties() ) ); //! Catalog Generator createAction( CatalogGenId, tr( "TOT_DESK_CATALOG_GENERATOR" ), QIconSet(), tr( "MEN_DESK_CATALOG_GENERATOR" ), tr( "PRP_DESK_CATALOG_GENERATOR" ), - 0, desk, false, this, SLOT( onCatalogGen() ) ); + SHIFT+Key_G, desk, false, this, SLOT( onCatalogGen() ) ); //! Registry Display createAction( RegDisplayId, tr( "TOT_DESK_REGISTRY_DISPLAY" ), QIconSet(), tr( "MEN_DESK_REGISTRY_DISPLAY" ), tr( "PRP_DESK_REGISTRY_DISPLAY" ), - 0, desk, false, this, SLOT( onRegDisplay() ) ); + SHIFT+Key_D, desk, false, this, SLOT( onRegDisplay() ) ); int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 ); @@ -347,67 +348,60 @@ void SalomeApp_Application::onSelectionChanged() LightApp_SelectionMgr* mgr = selectionMgr(); mgr->selectedObjects(list); - SalomeApp_Study* study = dynamic_cast(activeStudy()); - if(study == NULL) return; + bool canCopy = false; + bool canPaste = false; - _PTR(Study) stdDS = study->studyDS(); - if(!stdDS) return; + SalomeApp_Study* study = dynamic_cast(activeStudy()); + if (study != NULL) { + _PTR(Study) stdDS = study->studyDS(); - QAction* qaction; + if (stdDS) { + SALOME_ListIteratorOfListIO it ( list ); - SALOME_ListIteratorOfListIO it( list ); - if(it.More() && list.Extent() == 1) - { - _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry()); + if (it.More() && list.Extent() == 1) { + _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry()); - qaction = action(EditCopyId); - if( so ) { - SALOMEDS_SObject* aSO = dynamic_cast(so.get()); - if ( aSO && studyMgr()->CanCopy(so) ) qaction->setEnabled(true); - else qaction->setEnabled(false); - } - else qaction->setEnabled(false); + if ( so ) { + SALOMEDS_SObject* aSO = dynamic_cast(so.get()); - qaction = action(EditPasteId); - if( so ) { - SALOMEDS_SObject* aSO = dynamic_cast(so.get()); - if( aSO && studyMgr()->CanPaste(so) ) qaction->setEnabled(true); - qaction->setEnabled(false); - } - else qaction->setEnabled(false); - } - else { - qaction = action(EditCopyId); - qaction->setEnabled(false); - qaction = action(EditPasteId); - qaction->setEnabled(false); + if ( aSO ) { + canCopy = studyMgr()->CanCopy(so); + canPaste = studyMgr()->CanPaste(so); + } + } + } + } } + + action(EditCopyId)->setEnabled(canCopy); + action(EditPasteId)->setEnabled(canPaste); } /*!Delete references.*/ -void SalomeApp_Application::onDeleteReferences() +void SalomeApp_Application::onDeleteInvalidReferences() { SALOME_ListIO aList; LightApp_SelectionMgr* mgr = selectionMgr(); - mgr->selectedObjects(aList); + mgr->selectedObjects( aList, QString::null, false ); - if (aList.Extent() < 1) return; + if( aList.IsEmpty() ) + return; SalomeApp_Study* aStudy = dynamic_cast(activeStudy()); _PTR(Study) aStudyDS = aStudy->studyDS(); _PTR(StudyBuilder) aStudyBuilder = aStudyDS->NewBuilder(); _PTR(SObject) anObj; - for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) + for( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) + if ( it.Value()->hasEntry() ) { - if ( it.Value()->hasEntry() ) - { - _PTR(SObject) aSObject = aStudyDS->FindObjectID( it.Value()->getEntry() ); - if ( aSObject->ReferencedObject(anObj) ) - aStudyBuilder->RemoveReference(aSObject); - } - } + _PTR(SObject) aSObject = aStudyDS->FindObjectID( it.Value()->getEntry() ), aRefObj = aSObject; + while( aRefObj && aRefObj->ReferencedObject( anObj ) ) + aRefObj = anObj; + if( aRefObj && aRefObj!=aSObject && QString( aRefObj->GetName().c_str() ).isEmpty() ) + aStudyBuilder->RemoveReference( aSObject ); + } updateObjectBrowser(); } @@ -469,10 +463,8 @@ void SalomeApp_Application::updateCommandsStatus() if( a ) a->setEnabled( activeStudy() ); - a = action(EditCopyId); - a->setEnabled(false); - a = action(EditPasteId); - a->setEnabled(false); + // update state of Copy/Paste menu items + onSelectionChanged(); } /*!Private SLOT. On dump study.*/ @@ -548,7 +540,8 @@ QString SalomeApp_Application::getFileFilter() const /*!Create window.*/ QWidget* SalomeApp_Application::createWindow( const int flag ) { - QWidget* wid = LightApp_Application::createWindow(flag); + QWidget* wid = 0; + if ( flag != WT_PyConsole ) wid = LightApp_Application::createWindow(flag); SUIT_ResourceMgr* resMgr = resourceMgr(); @@ -556,7 +549,8 @@ QWidget* SalomeApp_Application::createWindow( const int flag ) { OB_Browser* ob = (OB_Browser*)wid; connect( ob->listView(), SIGNAL( doubleClicked( QListViewItem* ) ), this, SLOT( onDblClick( QListViewItem* ) ) ); - bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false ); + bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false ), + autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true ); for ( int i = SalomeApp_DataObject::CT_Value; i <= SalomeApp_DataObject::CT_RefEntry; i++ ) { ob->addColumn( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ) ), i ); @@ -564,15 +558,16 @@ QWidget* SalomeApp_Application::createWindow( const int flag ) QString().sprintf( "visibility_column_%d", i ), true ) ); } ob->setWidthMode( autoSize ? QListView::Maximum : QListView::Manual ); + ob->listView()->setColumnWidthMode( 0, autoSizeFirst ? QListView::Maximum : QListView::Manual ); + ob->resize( desktop()->width()/3, ob->height() ); } else if ( flag == WT_PyConsole ) { - delete wid; - wid = 0; PythonConsole* pyCons = new PythonConsole( desktop(), new SalomeApp_PyInterp() ); pyCons->setCaption( tr( "PYTHON_CONSOLE" ) ); wid = pyCons; - // pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) ); + pyCons->resize( pyCons->width(), desktop()->height()/4 ); + //pyCons->connectPopupRequest(this, SLOT(onConnectPopupRequest(SUIT_PopupClient*, QContextMenuEvent*))); } return wid; } @@ -594,9 +589,6 @@ void SalomeApp_Application::createPreferences( LightApp_Preferences* pref ) LightApp_Preferences::Bool, "ObjectBrowser", QString().sprintf( "visibility_column_%d", i ) ); } pref->setItemProperty( defCols, "columns", 1 ); - - int objSetGroup = pref->addPreference( tr( "PREF_OBJ_BROWSER_SETTINGS" ), obTab ); - pref->addPreference( tr( "PREF_AUTO_SIZE" ), objSetGroup, LightApp_Preferences::Bool, "ObjectBrowser", "auto_size" ); } /*!Update desktop title.*/ @@ -701,42 +693,37 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* t // Get selected objects SALOME_ListIO aList; LightApp_SelectionMgr* mgr = selectionMgr(); - mgr->selectedObjects(aList); + mgr->selectedObjects( aList, QString::null, false ); // "Delete reference" item should appear only for invalid references - // Check if selected objects is invalid references - bool isInvalidRefs = true; - - if ( aList.Extent() < 1 ) - isInvalidRefs = false; + // isInvalidRefs will be true, if at least one of selected objects is invalid reference + bool isInvalidRefs = false; + SalomeApp_Study* aStudy = dynamic_cast(activeStudy()); + _PTR(Study) aStudyDS = aStudy->studyDS(); + _PTR(SObject) anObj; - if ( isInvalidRefs ) + for( SALOME_ListIteratorOfListIO it( aList ); it.More() && !isInvalidRefs; it.Next() ) + if( it.Value()->hasEntry() ) { - SalomeApp_Study* aStudy = dynamic_cast(activeStudy()); - _PTR(Study) aStudyDS = aStudy->studyDS(); - _PTR(SObject) anObj; + _PTR(SObject) aSObject = aStudyDS->FindObjectID( it.Value()->getEntry() ), aRefObj = aSObject; + while( aRefObj && aRefObj->ReferencedObject( anObj ) ) + aRefObj = anObj; - for ( SALOME_ListIteratorOfListIO it( aList ); it.More() && isInvalidRefs; it.Next() ) - { - if ( it.Value()->hasEntry() ) - { - _PTR(SObject) aSObject = aStudyDS->FindObjectID( it.Value()->getEntry() ); - SALOMEDS_SObject* aSO = dynamic_cast(aSObject.get()); - if( aSO ) - if ( aSObject->ReferencedObject(anObj) == false || !QString(anObj->GetName().c_str()).isEmpty() ) - isInvalidRefs = false; - } - } + if( aRefObj && aRefObj!=aSObject && QString( aRefObj->GetName().c_str() ).isEmpty() ) + isInvalidRefs = true; } - // Add "Delete refrence" item to popup + // Add "Delete reference" item to popup if ( isInvalidRefs ) - { - thePopup->insertSeparator(); - thePopup->insertItem( tr( "MEN_DELETE_REFERENCE" ), this, SLOT( onDeleteReferences() ) ); - return; - } + { + thePopup->insertSeparator(); + thePopup->insertItem( tr( "MEN_DELETE_INVALID_REFERENCE" ), this, SLOT( onDeleteInvalidReferences() ) ); + return; + } + + aList.Clear(); + mgr->selectedObjects( aList ); // "Activate module" item should appear only if it's necessary if (aList.Extent() != 1) @@ -748,7 +735,6 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* t if (currentModule && currentModule->moduleName() == aModuleTitle) return; thePopup->insertItem( tr( "MEN_OPENWITH" ), this, SLOT( onOpenWith() ) ); - } /*!Update obect browser: @@ -782,7 +768,7 @@ void SalomeApp_Application::updateObjectBrowser( const bool updateModels ) if ( objectBrowser() ) { objectBrowser()->updateGeometry(); - objectBrowser()->updateTree(); + objectBrowser()->updateTree( 0, false ); } } diff --git a/src/SalomeApp/SalomeApp_Application.h b/src/SalomeApp/SalomeApp_Application.h index 865fd2bd0..2462e557b 100644 --- a/src/SalomeApp/SalomeApp_Application.h +++ b/src/SalomeApp/SalomeApp_Application.h @@ -85,7 +85,7 @@ protected: virtual void updateDesktopTitle(); private slots: - void onDeleteReferences(); + void onDeleteInvalidReferences(); void onDblClick( QListViewItem* ); void onProperties(); void onDumpStudy(); diff --git a/src/SalomeApp/SalomeApp_PyInterp.cxx b/src/SalomeApp/SalomeApp_PyInterp.cxx index a6549f646..19bc57559 100755 --- a/src/SalomeApp/SalomeApp_PyInterp.cxx +++ b/src/SalomeApp/SalomeApp_PyInterp.cxx @@ -37,6 +37,7 @@ #include "PyInterp_base.h" // this include must be first (see PyInterp_base.h)! #include +using namespace std; /*! * constructor : multi Python interpreter, one per SALOME study. @@ -56,7 +57,7 @@ SalomeApp_PyInterp::~SalomeApp_PyInterp() /*!\class SalomeApp_PyInterp * EDF-CCAR - * Wasashen SALOME uses multi Python interpreter feature, + * When SALOME uses multi Python interpreter feature, * Every study has its own interpreter and thread state (_tstate = Py_NewInterpreter()) * This is fine because every study has its own modules (sys.modules) stdout and stderr * BUT some Python modules must be imported only once. In multi interpreter context Python @@ -83,14 +84,12 @@ bool SalomeApp_PyInterp::initContext() if ( !PythonConsole_PyInterp::initContext() ) return false; - // Debut modif CCAR // Import special module to change the import mechanism PyObjWrapper m1( PyImport_ImportModule( "import_hook" ) ); if ( !m1 ) { MESSAGE( "initContext: problem with import_hook import" ); PyErr_Print(); - PyErr_Clear(); ASSERT( 0 ); return false; } @@ -100,10 +99,9 @@ bool SalomeApp_PyInterp::initContext() PyObjWrapper m2( PyObject_CallMethod( m1, "init_shared_modules", "O", KERNEL_PYTHON::salome_shared_modules_module ) ); if ( !m2 ) { - MESSAGE( "initContext: problem with init_shared_modules call" ); - PyErr_Print(); - PyErr_Clear(); - ASSERT( 0 ); + MESSAGE( "initContext: problem with init_shared_modules call" ); + PyErr_Print(); + ASSERT( 0 ); return false; } @@ -113,19 +111,13 @@ bool SalomeApp_PyInterp::initContext() void SalomeApp_PyInterp::init_python() { /* - * Initialize the main state (_gtstate) if not already done - * The lock is released on init_python output - * It is the caller responsability to acquire it if needed + * Do nothing + * The initialization has been done in main */ MESSAGE("PyInterp_base::init_python"); ASSERT(KERNEL_PYTHON::_gtstate); // initialisation in main SCRUTE(KERNEL_PYTHON::_gtstate); -// if(!_gtstate){ -// PyReleaseLock aReleaseLock; -// Py_Initialize(); // Initialize the interpreter -// PyEval_InitThreads(); // Initialize and acquire the global interpreter lock -// PySys_SetArgv(_argc,_argv); // initialize sys.argv -// _gtstate = PyThreadState_Get(); -// } + _gtstate=KERNEL_PYTHON::_gtstate; + _interp=KERNEL_PYTHON::_interp; } diff --git a/src/SalomeApp/resources/SalomeApp.xml b/src/SalomeApp/resources/SalomeApp.xml index b32780274..ffdee1fd9 100644 --- a/src/SalomeApp/resources/SalomeApp.xml +++ b/src/SalomeApp/resources/SalomeApp.xml @@ -16,10 +16,11 @@ + - - + +
@@ -47,11 +48,18 @@ - + +
+
+ +
+
+ +
@@ -80,6 +88,11 @@
+
+ + + +
@@ -88,7 +101,8 @@
- + + @@ -104,6 +118,9 @@
+
+ +
@@ -140,9 +157,9 @@ - - - + + + @@ -151,10 +168,10 @@ - - + + - + @@ -162,9 +179,10 @@
- - - + + + + @@ -175,10 +193,10 @@ - - + + - + diff --git a/src/SalomeApp/resources/SalomeApp_msg_en.po b/src/SalomeApp/resources/SalomeApp_msg_en.po index ef835c709..a739779d2 100644 --- a/src/SalomeApp/resources/SalomeApp_msg_en.po +++ b/src/SalomeApp/resources/SalomeApp_msg_en.po @@ -37,7 +37,7 @@ msgid "SalomeApp_Application::TOT_DESK_FILE_DUMP_STUDY" msgstr "Dump study" msgid "SalomeApp_Application::MEN_DESK_FILE_DUMP_STUDY" -msgstr "Dump study..." +msgstr "&Dump study..." msgid "SalomeApp_Application::PRP_DESK_FILE_DUMP_STUDY" msgstr "Dumps study to the python script" @@ -46,7 +46,7 @@ msgid "SalomeApp_Application::TOT_DESK_FILE_LOAD_SCRIPT" msgstr "Load python script" msgid "SalomeApp_Application::MEN_DESK_FILE_LOAD_SCRIPT" -msgstr "Load script..." +msgstr "Load scrip&t..." msgid "SalomeApp_Application::PRP_DESK_FILE_LOAD_SCRIPT" msgstr "Loads python script from file" @@ -55,13 +55,13 @@ msgid "SalomeApp_Application::TOT_FILE_DESK_PREFERENCES" msgstr "Preferences" msgid "SalomeApp_Application::MEN_DESK_TOOLS" -msgstr "Tools" +msgstr "&Tools" msgid "SalomeApp_Application::TOT_DESK_CATALOG_GENERATOR" msgstr "Catalog generator" msgid "SalomeApp_Application::MEN_DESK_CATALOG_GENERATOR" -msgstr "Catalog generator" +msgstr "Catalog &generator" msgid "SalomeApp_Application::PRP_DESK_CATALOG_GENERATOR" msgstr "Generates XML catalog of a component's interface" @@ -70,7 +70,7 @@ msgid "SalomeApp_Application::TOT_DESK_REGISTRY_DISPLAY" msgstr "Registry display" msgid "SalomeApp_Application::MEN_DESK_REGISTRY_DISPLAY" -msgstr "Registry display" +msgstr "Registry &display" msgid "SalomeApp_Application::PRP_DESK_REGISTRY_DISPLAY" msgstr "Displays content of the Registry CORBA server" @@ -85,7 +85,7 @@ msgid "SalomeApp_Application::TOT_DESK_PROPERTIES" msgstr "Study properties" msgid "SalomeApp_Application::MEN_DESK_PROPERTIES" -msgstr "Properties..." +msgstr "Pro&perties..." msgid "SalomeApp_Application::PRP_DESK_PROPERTIES" msgstr "Edits study properties" @@ -99,8 +99,8 @@ msgstr "Object browser" msgid "SalomeApp_Application::MEN_OPENWITH" msgstr "Activate Module" -msgid "SalomeApp_Application::MEN_DELETE_REFERENCE" -msgstr "Delete Reference" +msgid "SalomeApp_Application::MEN_DELETE_INVALID_REFERENCE" +msgstr "Delete Invalid Reference" //======================================================================================= @@ -118,9 +118,6 @@ msgstr "Default columns" msgid "SalomeApp_Application::PREF_OBJ_BROWSER_SETTINGS" msgstr "Settings" -msgid "SalomeApp_Application::PREF_AUTO_SIZE" -msgstr "Auto size columns" - //======================================================================================= msgid "SalomeApp_Application::OBJ_BROWSER_NAME" diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index 84c7f7a81..ac7738582 100755 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -295,7 +295,6 @@ int main( int argc, char **argv ) { INFOS( "salome_shared_modules_module == NULL" ); PyErr_Print(); - PyErr_Clear(); } PyEval_ReleaseThread( KERNEL_PYTHON::_gtstate ); @@ -413,8 +412,9 @@ int main( int argc, char **argv ) SUIT_Application* aGUIApp = aGUISession->startApplication( "SalomeApp", 0, 0 ); if ( aGUIApp ) { - _qappl.setHandler( aGUISession->handler() ); // after loading SalomeApp application - // aGUISession contains SalomeApp_ExceptionHandler + if ( !isFound( "noexcepthandler", argc, argv ) ) + _qappl.setHandler( aGUISession->handler() ); // after loading SalomeApp application + // aGUISession contains SalomeApp_ExceptionHandler // Run GUI loop MESSAGE( "run(): starting the main event loop" ); result = _qappl.exec(); diff --git a/src/Session/Session_ServerThread.cxx b/src/Session/Session_ServerThread.cxx index 47f8bff0f..7e3714518 100755 --- a/src/Session/Session_ServerThread.cxx +++ b/src/Session/Session_ServerThread.cxx @@ -168,6 +168,7 @@ void Session_ServerThread::Init() { NamingService_WaitForServerReadiness(_NS,"/myStudyManager"); ActivateEngine(_argc, _argv); + break; } case 6: // Container Manager { -- 2.39.2