From: vsr Date: Mon, 10 Nov 2014 08:20:45 +0000 (+0300) Subject: Merge remote branch 'origin/Doc_update_ver741' into V7_5_BR X-Git-Tag: V7_5_0rc1~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1c1e0526d452336651ccecf48deb5d8227ecdd47;hp=a33f77713a1da174842dff2adc14e28d3fb838c6;p=modules%2Fgui.git Merge remote branch 'origin/Doc_update_ver741' into V7_5_BR --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 274140c44..2ce226a17 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,11 +30,11 @@ CMAKE_POLICY(SET CMP0003 NEW) STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC) SET(${PROJECT_NAME_UC}_MAJOR_VERSION 7) -SET(${PROJECT_NAME_UC}_MINOR_VERSION 4) -SET(${PROJECT_NAME_UC}_PATCH_VERSION 1) +SET(${PROJECT_NAME_UC}_MINOR_VERSION 5) +SET(${PROJECT_NAME_UC}_PATCH_VERSION 0) SET(${PROJECT_NAME_UC}_VERSION ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION}) -SET(${PROJECT_NAME_UC}_VERSION_DEV 1) +SET(${PROJECT_NAME_UC}_VERSION_DEV 0) # Find KERNEL # =========== diff --git a/src/CAF/CAF_Study.cxx b/src/CAF/CAF_Study.cxx index 0b60a95fd..3b69c88eb 100755 --- a/src/CAF/CAF_Study.cxx +++ b/src/CAF/CAF_Study.cxx @@ -25,8 +25,6 @@ #include "CAF_Tools.h" #include "CAF_Application.h" -#include - #include #include #include diff --git a/src/DDS/DDS_Dictionary.cxx b/src/DDS/DDS_Dictionary.cxx index 823bfe1a8..d22fdb0ba 100644 --- a/src/DDS/DDS_Dictionary.cxx +++ b/src/DDS/DDS_Dictionary.cxx @@ -24,8 +24,6 @@ #include "DDS_KeyWords.h" -#include - #include #include diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 3017896cf..56b3f8852 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -58,9 +58,7 @@ #include "LightApp_WgViewModel.h" #include "LightApp_FullScreenHelper.h" - #include -#include #include @@ -223,7 +221,6 @@ static const char* imageEmptyIcon[] = { int LightApp_Application::lastStudyId = 0; - // Markers used to parse array with dockable windows and toolbars state. // For more details please see the qdockarealayout.cpp && qtoolbararealayout.cpp // in the Qt source code. @@ -1618,7 +1615,7 @@ void LightApp_Application::onStudyCreated( SUIT_Study* theStudy ) #ifndef DISABLE_PYCONSOLE if( pythonConsole() ) - pythonConsole()->getInterp()->initStudy(); + getPyInterp()->initStudy(); #endif } @@ -1649,7 +1646,7 @@ void LightApp_Application::onStudyOpened( SUIT_Study* theStudy ) #ifndef DISABLE_PYCONSOLE if( pythonConsole() ) - pythonConsole()->getInterp()->initStudy(); + getPyInterp()->initStudy(); #endif emit studyOpened(); @@ -1918,7 +1915,7 @@ QWidget* LightApp_Application::createWindow( const int flag ) #ifndef DISABLE_PYCONSOLE else if ( flag == WT_PyConsole ) { - PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(),new LightApp_PyInterp()); + PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(), getPyInterp() ); pyCons->setObjectName( "pythonConsole" ); pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) ); pyCons->setFont(resourceMgr()->fontValue( "PyConsole", "font" )); @@ -4156,6 +4153,11 @@ void LightApp_Application::onDesktopMessage( const QString& message ) // update object browser updateObjectBrowser(); } + else if ( message.toLower().startsWith( "activate_viewer" ) ) { + QString vtype = message.split( sectionSeparator ).last(); + if ( !vtype.isEmpty() ) + getViewManager( vtype, true ); + } else { QStringList data = message.split( sectionSeparator ); if ( data.count() > 1 ) { @@ -4453,3 +4455,19 @@ bool LightApp_Application::checkExistingDoc() return result; } +#ifndef DISABLE_PYCONSOLE + +PyConsole_Interp* LightApp_Application::getPyInterp() +{ + static PyConsole_Interp* myInterp = 0; + if ( !myInterp ) + myInterp = createPyInterp(); + return myInterp; +} + +PyConsole_Interp* LightApp_Application::createPyInterp() +{ + return new LightApp_PyInterp(); +} + +#endif // DISABLE_PYCONSOLE diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index 3ea6cb1dd..54be0df78 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -42,6 +42,7 @@ class LogWindow; #ifndef DISABLE_PYCONSOLE class PyConsole_Console; +class PyConsole_Interp; #endif class LightApp_WidgetContainer; class LightApp_Preferences; @@ -182,6 +183,10 @@ public: virtual bool checkExistingDoc(); +#ifndef DISABLE_PYCONSOLE + PyConsole_Interp* getPyInterp(); +#endif + signals: void studyOpened(); void studySaved(); @@ -231,6 +236,10 @@ protected: virtual QMap activateModuleActions() const; virtual void moduleActionSelected( const int ); +#ifndef DISABLE_PYCONSOLE + virtual PyConsole_Interp* createPyInterp(); +#endif + protected slots: virtual void onDesktopActivated(); virtual void onViewManagerRemoved( SUIT_ViewManager* ); diff --git a/src/LightApp/LightApp_PyInterp.h b/src/LightApp/LightApp_PyInterp.h index de8c26636..7f35fbb25 100644 --- a/src/LightApp/LightApp_PyInterp.h +++ b/src/LightApp/LightApp_PyInterp.h @@ -27,11 +27,13 @@ class LightApp_PyInterp : public PyConsole_EnhInterp { + friend class LightApp_Application; + public: - LightApp_PyInterp(); virtual ~LightApp_PyInterp(); protected: + LightApp_PyInterp(); virtual void initPython(); }; diff --git a/src/OBJECT/SALOME_InteractiveObject.hxx b/src/OBJECT/SALOME_InteractiveObject.hxx index 17c29310a..df63cd8cc 100755 --- a/src/OBJECT/SALOME_InteractiveObject.hxx +++ b/src/OBJECT/SALOME_InteractiveObject.hxx @@ -59,7 +59,7 @@ public: Standard_EXPORT Standard_Boolean isComponentType(const char* ComponentDataType); // Must be defined for using by NCollection for ceratin of data map - friend Standard_Boolean IsEqual(const Handle(SALOME_InteractiveObject)& anIO1, + Standard_EXPORT friend Standard_Boolean IsEqual(const Handle(SALOME_InteractiveObject)& anIO1, const Handle(SALOME_InteractiveObject)& anIO2); protected: diff --git a/src/OCCViewer/OCCViewer_ClippingDlg.cxx b/src/OCCViewer/OCCViewer_ClippingDlg.cxx index ec75a1052..2c993287b 100644 --- a/src/OCCViewer/OCCViewer_ClippingDlg.cxx +++ b/src/OCCViewer/OCCViewer_ClippingDlg.cxx @@ -37,6 +37,8 @@ #include "OCCViewer_ViewManager.h" #include "OCCViewer_ClipPlaneInteractor.h" +#include + #include #include #include @@ -92,7 +94,17 @@ void getMinMaxFromContext( Handle(AIS_InteractiveContext) ic, if ( !aPrs->IsEmpty() && !aPrs->IsInfinite() ) { isFound = true; double xmin, ymin, zmin, xmax, ymax, zmax; +#if OCC_VERSION_LARGE > 0x06070100 + Bnd_Box aBox = aPrs->MinMaxValues(); + xmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().X(); + ymin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().Y(); + zmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().Z(); + xmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().X(); + ymax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().Y(); + zmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().Z(); +#else aPrs->MinMaxValues( xmin, ymin, zmin, xmax, ymax, zmax ); +#endif aXMin = qMin( aXMin, xmin ); aXMax = qMax( aXMax, xmax ); aYMin = qMin( aYMin, ymin ); aYMax = qMax( aYMax, ymax ); aZMin = qMin( aZMin, zmin ); aZMax = qMax( aZMax, zmax ); diff --git a/src/OCCViewer/OCCViewer_CubeAxesDlg.cxx b/src/OCCViewer/OCCViewer_CubeAxesDlg.cxx index 31561c3a5..c62789d55 100644 --- a/src/OCCViewer/OCCViewer_CubeAxesDlg.cxx +++ b/src/OCCViewer/OCCViewer_CubeAxesDlg.cxx @@ -29,8 +29,6 @@ #include "QtxAction.h" #include "QtxIntSpinBox.h" -#include - #include #include #include diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx index 64e558564..ae9e8639f 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -36,6 +36,8 @@ #include "ViewerData_AISShape.hxx" +#include + #include "QtxActionToolMgr.h" #include "QtxBackgroundTool.h" @@ -956,7 +958,17 @@ double OCCViewer_Viewer::computeSceneSize(const Handle(V3d_View)& view3d) const double aMaxSide = 0; double Xmin = 0, Ymin = 0, Zmin = 0, Xmax = 0, Ymax = 0, Zmax = 0; +#if OCC_VERSION_LARGE > 0x06070100 + Bnd_Box aBox = view3d->View()->MinMaxValues(); + Xmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().X(); + Ymin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().Y(); + Zmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().Z(); + Xmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().X(); + Ymax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().Y(); + Zmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().Z(); +#else view3d->View()->MinMaxValues( Xmin, Ymin, Zmin, Xmax, Ymax, Zmax ); +#endif if ( Xmin != RealFirst() && Ymin != RealFirst() && Zmin != RealFirst() && Xmax != RealLast() && Ymax != RealLast() && Zmax != RealLast() ) diff --git a/src/OCCViewer/OCCViewer_ViewModel.h b/src/OCCViewer/OCCViewer_ViewModel.h index 5ca95ef26..685e362b0 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.h +++ b/src/OCCViewer/OCCViewer_ViewModel.h @@ -36,7 +36,6 @@ #include #include #include -#include #include class QKeyEvent; diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 4f38b4110..2fa68a577 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -651,7 +651,17 @@ bool OCCViewer_ViewWindow::computeGravityCenter( double& theX, double& theY, dou continue; } +#if OCC_VERSION_LARGE > 0x06070100 + Bnd_Box aBox = aStructure->MinMaxValues(); + aXmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().X(); + aYmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().Y(); + aZmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().Z(); + aXmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().X(); + aYmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().Y(); + aZmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().Z(); +#else aStructure->MinMaxValues( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax ); +#endif // Infinite structures are skipped Standard_Real aLIM = ShortRealLast() - 1.0; diff --git a/src/OCCViewer/resources/OCCViewer_msg_en.ts b/src/OCCViewer/resources/OCCViewer_msg_en.ts index 09bd1217e..710c6907d 100644 --- a/src/OCCViewer/resources/OCCViewer_msg_en.ts +++ b/src/OCCViewer/resources/OCCViewer_msg_en.ts @@ -425,7 +425,7 @@ OCCViewer_AxialScaleDlg DLG_SCALING - Axes scaling + Scaling LBL_X diff --git a/src/OCCViewer/resources/OCCViewer_msg_fr.ts b/src/OCCViewer/resources/OCCViewer_msg_fr.ts index 1ffde87ee..547a90d8b 100755 --- a/src/OCCViewer/resources/OCCViewer_msg_fr.ts +++ b/src/OCCViewer/resources/OCCViewer_msg_fr.ts @@ -190,7 +190,7 @@ MNU_SCALING - Changer l'échelle + Mise à l'échelle DSC_SCALING @@ -425,7 +425,7 @@ OCCViewer_AxialScaleDlg DLG_SCALING - Changer l'échelle des axes + Mise à l'échelle LBL_X diff --git a/src/OCCViewer/resources/OCCViewer_msg_ja.ts b/src/OCCViewer/resources/OCCViewer_msg_ja.ts index dc12be6dd..c9a97890a 100644 --- a/src/OCCViewer/resources/OCCViewer_msg_ja.ts +++ b/src/OCCViewer/resources/OCCViewer_msg_ja.ts @@ -190,7 +190,7 @@ MNU_SCALING - 軸のスケーリング + スケーリング DSC_SCALING @@ -425,7 +425,7 @@ OCCViewer_AxialScaleDlg DLG_SCALING - スケールの変更 + スケーリング LBL_X diff --git a/src/PVViewer/PVViewer_GUIElements.cxx b/src/PVViewer/PVViewer_GUIElements.cxx index ff139e682..b68bc1ead 100644 --- a/src/PVViewer/PVViewer_GUIElements.cxx +++ b/src/PVViewer/PVViewer_GUIElements.cxx @@ -40,14 +40,12 @@ PVViewer_GUIElements::PVViewer_GUIElements(SUIT_Desktop* desk) : pipelineBrowserWidget = new pqPipelineBrowserWidget(desk); pipelineBrowserWidget->hide(); - sourcesMenu = new QMenu(desk); - pqParaViewMenuBuilders::buildSourcesMenu(*sourcesMenu, desk); - - filtersMenu = new QMenu(desk); - pqParaViewMenuBuilders::buildFiltersMenu(*filtersMenu, desk); - - macrosMenu = new QMenu(desk); - pqParaViewMenuBuilders::buildMacrosMenu(*macrosMenu); +// sourcesMenu = new QMenu(desk); +// pqParaViewMenuBuilders::buildSourcesMenu(*sourcesMenu, desk); +// filtersMenu = new QPVMenu(desk); +// pqParaViewMenuBuilders::buildFiltersMenu(*filtersMenu, desk); +// macrosMenu = new QMenu(desk); +// pqParaViewMenuBuilders::buildMacrosMenu(*macrosMenu); } PVViewer_GUIElements * PVViewer_GUIElements::GetInstance(SUIT_Desktop* desk) @@ -57,44 +55,45 @@ PVViewer_GUIElements * PVViewer_GUIElements::GetInstance(SUIT_Desktop* desk) return theInstance; } -void PVViewer_GUIElements::updateSourcesMenu(QMenu *menu) -{ - if (menu) - { - menu->clear(); - QList act_list = sourcesMenu->actions(); - foreach(QAction * a, act_list) - { - menu->addAction(a); - } - } -} - -void PVViewer_GUIElements::updateFiltersMenu(QMenu *menu) -{ - if (menu) - { - menu->clear(); - QList act_list = filtersMenu->actions(); - foreach(QAction * a, act_list) - { - menu->addAction(a); - } - } -} - -void PVViewer_GUIElements::updateMacrosMenu(QMenu *menu) -{ - if (menu) - { - menu->clear(); - QList act_list = macrosMenu->actions(); - foreach(QAction * a, act_list) - { - menu->addAction(a); - } - } -} +//void PVViewer_GUIElements::updateSourcesMenu(QMenu *menu) +//{ +// if (menu) +// { +// menu->clear(); +// QList act_list = sourcesMenu->actions(); +// foreach(QAction * a, act_list) +// { +// menu->addAction(a); +// } +// } +//} +// +//void PVViewer_GUIElements::updateFiltersMenu(QMenu *menu) +//{ +// if (menu) +// { +// filtersMenu->linkToMenu(menu); +// menu->clear(); +// QList act_list = filtersMenu->actions(); +// foreach(QAction * a, act_list) +// { +// menu->addAction(a); +// } +// } +//} +// +//void PVViewer_GUIElements::updateMacrosMenu(QMenu *menu) +//{ +// if (menu) +// { +// menu->clear(); +// QList act_list = macrosMenu->actions(); +// foreach(QAction * a, act_list) +// { +// menu->addAction(a); +// } +// } +//} void PVViewer_GUIElements::onEmulateApply() diff --git a/src/PVViewer/PVViewer_GUIElements.h b/src/PVViewer/PVViewer_GUIElements.h index aa22f4b2d..1615efc48 100644 --- a/src/PVViewer/PVViewer_GUIElements.h +++ b/src/PVViewer/PVViewer_GUIElements.h @@ -33,8 +33,6 @@ class QMenu; /*! * Some GUI elements of ParaView need to be instanciated in a proper order. This class * holds all of them for the sake of clarity. - * For example sources menu should be built *before* loading ParaView's configuration, so that the - * list of sources gets properly populated. */ class PVVIEWER_EXPORT PVViewer_GUIElements: public QObject { @@ -47,9 +45,9 @@ public: pqPipelineBrowserWidget * getPipelineBrowserWidget() { return pipelineBrowserWidget; } // Update the sources menu from what was built in private member 'sourcesMenu' - void updateSourcesMenu(QMenu *); - void updateFiltersMenu(QMenu *); - void updateMacrosMenu(QMenu *); +// void updateSourcesMenu(QMenu *); +// void updateFiltersMenu(QMenu *); +// void updateMacrosMenu(QMenu *); public slots: void onEmulateApply(); // better use the slot from PVViewer_ViewManager if you want to trigger "Apply" diff --git a/src/PVViewer/PVViewer_ViewManager.cxx b/src/PVViewer/PVViewer_ViewManager.cxx index 74baf63fa..0d4b2ec4f 100644 --- a/src/PVViewer/PVViewer_ViewManager.cxx +++ b/src/PVViewer/PVViewer_ViewManager.cxx @@ -135,9 +135,9 @@ void PVViewer_ViewManager::ParaviewInitBehaviors(bool fullSetup, SUIT_Desktop* a ParaviewBehaviors->instanciateMinimalBehaviors(aDesktop); } -void PVViewer_ViewManager::ParaviewLoadConfigurations() +void PVViewer_ViewManager::ParaviewLoadConfigurations(bool force) { - if (!ConfigLoaded) + if (!ConfigLoaded || force) { SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); QString aPath = resMgr->stringValue("resources", "PVViewer", QString()); diff --git a/src/PVViewer/PVViewer_ViewManager.h b/src/PVViewer/PVViewer_ViewManager.h index fad78159f..9061eb65a 100644 --- a/src/PVViewer/PVViewer_ViewManager.h +++ b/src/PVViewer/PVViewer_ViewManager.h @@ -48,7 +48,7 @@ public: //! Initialize ParaView if not yet done (once per session) static bool ParaviewInitApp(SUIT_Desktop* aDesktop, LogWindow * w); static void ParaviewInitBehaviors(bool fullSetup=false, SUIT_Desktop* aDesktop=0); - static void ParaviewLoadConfigurations(); + static void ParaviewLoadConfigurations(bool force=false); static void ParaviewCleanup(); //! Connect to the external PVServer, using the PARAVIS engine to launch it if it is not diff --git a/src/PVViewer/PVViewer_ViewWindow.cxx b/src/PVViewer/PVViewer_ViewWindow.cxx index c7fff08a2..bdb1edfa0 100644 --- a/src/PVViewer/PVViewer_ViewWindow.cxx +++ b/src/PVViewer/PVViewer_ViewWindow.cxx @@ -22,6 +22,7 @@ #include "PVViewer_ViewWindow.h" #include "PVViewer_ViewManager.h" +#include "PVViewer_ViewModel.h" #include "PVViewer_GUIElements.h" #include @@ -46,6 +47,7 @@ PVViewer_ViewWindow::PVViewer_ViewWindow( SUIT_Desktop* theDesktop, PVViewer_Vie : SUIT_ViewWindow( theDesktop ), myPVMgr( 0 ) { myModel = theModel; + setViewManager(myModel->getViewManager()); myPVMgr = qobject_cast(pqApplicationCore::instance()->manager("MULTIVIEW_WIDGET")); if (myPVMgr) { myPVMgr->setParent( this ); diff --git a/src/PyConsole/PyConsole_Console.cxx b/src/PyConsole/PyConsole_Console.cxx index a3991bf88..5ec6eb57e 100644 --- a/src/PyConsole/PyConsole_Console.cxx +++ b/src/PyConsole/PyConsole_Console.cxx @@ -52,18 +52,15 @@ PyConsole_Console::PyConsole_Console( QWidget* parent, PyConsole_Interp* interp ) : QWidget( parent ) { - // create python interpreter - myInterp = interp; - if ( !myInterp ) - myInterp = new PyConsole_Interp(); + PyConsole_Interp* anInterp = interp ? interp : new PyConsole_Interp(); // initialize Python interpretator - myInterp->initialize(); + anInterp->initialize(); // create editor console QVBoxLayout* lay = new QVBoxLayout( this ); lay->setMargin( 0 ); - myEditor = new PyConsole_Editor( myInterp, this ); + myEditor = new PyConsole_Editor( anInterp, this ); char* synchronous = getenv("PYTHON_CONSOLE_SYNC"); if (synchronous && atoi(synchronous)) { @@ -78,8 +75,8 @@ PyConsole_Console::PyConsole_Console( QWidget* parent, PyConsole_Interp* interp /** * Protected constructor. */ -PyConsole_Console::PyConsole_Console( QWidget* parent, PyConsole_Interp* i, PyConsole_Editor* e) - : QWidget (parent), myEditor(e), myInterp(i) +PyConsole_Console::PyConsole_Console( QWidget* parent, PyConsole_Interp* /*i*/, PyConsole_Editor* e ) + : QWidget (parent), myEditor(e) {} /*! @@ -91,6 +88,11 @@ PyConsole_Console::~PyConsole_Console() { } +PyConsole_Interp* PyConsole_Console::getInterp() const +{ + return myEditor ? myEditor->getInterp() : 0; +} + /*! \brief Execute python command in the interpreter. \param command string with command and arguments @@ -373,21 +375,18 @@ void PyConsole_Console::stopLog() * @param parent * @param interp */ -PyConsole_EnhConsole::PyConsole_EnhConsole( QWidget* parent, PyConsole_EnhInterp* interp) - : PyConsole_Console(parent, interp, 0) +PyConsole_EnhConsole::PyConsole_EnhConsole( QWidget* parent, PyConsole_Interp* interp ) + : PyConsole_Console( parent, interp, 0 ) { - // create python interpreter - myInterp = interp; - if ( !myInterp ) - myInterp = new PyConsole_EnhInterp(); + PyConsole_Interp* anInterp = interp ? interp : new PyConsole_EnhInterp(); // initialize Python interpretator - myInterp->initialize(); + anInterp->initialize(); // create editor console QVBoxLayout* lay = new QVBoxLayout( this ); lay->setMargin( 0 ); - myEditor = new PyConsole_EnhEditor( static_cast(myInterp), this ); + myEditor = new PyConsole_EnhEditor( anInterp, this ); char* synchronous = getenv("PYTHON_CONSOLE_SYNC"); if (synchronous && atoi(synchronous)) { diff --git a/src/PyConsole/PyConsole_Console.h b/src/PyConsole/PyConsole_Console.h index 54442c2cd..b32b078e4 100644 --- a/src/PyConsole/PyConsole_Console.h +++ b/src/PyConsole/PyConsole_Console.h @@ -34,7 +34,6 @@ class PyConsole_Interp; class PyConsole_Editor; -class PyConsole_EnhInterp; class PYCONSOLE_EXPORT PyConsole_Console : public QWidget, public SUIT_PopupClient { @@ -59,7 +58,7 @@ public: virtual ~PyConsole_Console(); //! \brief Get python interperter - PyConsole_Interp* getInterp() { return myInterp; } + PyConsole_Interp* getInterp() const; QFont font() const; virtual void setFont( const QFont& ); @@ -93,8 +92,6 @@ protected: PyConsole_Console( QWidget* parent, PyConsole_Interp*, PyConsole_Editor*); - - PyConsole_Interp* myInterp; //!< python interpreter PyConsole_Editor* myEditor; //!< python console editor widget QMap myActions; //!< menu actions list }; @@ -109,7 +106,7 @@ class PYCONSOLE_EXPORT PyConsole_EnhConsole: public PyConsole_Console Q_OBJECT public: - PyConsole_EnhConsole( QWidget* parent, PyConsole_EnhInterp* interp = 0); + PyConsole_EnhConsole( QWidget* parent, PyConsole_Interp* interp = 0 ); virtual ~PyConsole_EnhConsole() {} }; diff --git a/src/PyConsole/PyConsole_Editor.cxx b/src/PyConsole/PyConsole_Editor.cxx index 42ea63e4f..aeb61f965 100644 --- a/src/PyConsole/PyConsole_Editor.cxx +++ b/src/PyConsole/PyConsole_Editor.cxx @@ -191,16 +191,20 @@ PyConsole_Editor::PyConsole_Editor( PyConsole_Interp* theInterp, /*! \brief Destructor. - - Does nothing for the moment. */ PyConsole_Editor::~PyConsole_Editor() { - myInterp->destroy(); - delete myInterp; myInterp = 0; } +/*! + \brief Get Python interpreter +*/ +PyConsole_Interp* PyConsole_Editor::getInterp() const +{ + return myInterp; +} + /*! \brief Get synchronous mode flag value. diff --git a/src/PyConsole/PyConsole_Editor.h b/src/PyConsole/PyConsole_Editor.h index c939ef1b7..5094f8687 100644 --- a/src/PyConsole/PyConsole_Editor.h +++ b/src/PyConsole/PyConsole_Editor.h @@ -42,6 +42,8 @@ class PYCONSOLE_EXPORT PyConsole_Editor : public QTextEdit public: PyConsole_Editor( PyConsole_Interp* theInterp, QWidget *theParent = 0 ); ~PyConsole_Editor(); + + PyConsole_Interp* getInterp() const; virtual void addText( const QString& str, const bool newBlock = false, const bool isError = false ); bool isCommand( const QString& str ) const; diff --git a/src/PyConsole/PyConsole_EnhEditor.cxx b/src/PyConsole/PyConsole_EnhEditor.cxx index 20a5ef1c5..aa73ac04b 100644 --- a/src/PyConsole/PyConsole_EnhEditor.cxx +++ b/src/PyConsole/PyConsole_EnhEditor.cxx @@ -43,7 +43,7 @@ const std::vector PyConsole_EnhEditor::SEPARATORS = \ * @param interp the interpreter linked to the editor * @param parent parent widget */ -PyConsole_EnhEditor::PyConsole_EnhEditor(PyConsole_EnhInterp * interp, QWidget * parent) : +PyConsole_EnhEditor::PyConsole_EnhEditor(PyConsole_Interp* interp, QWidget* parent) : PyConsole_Editor(interp, parent), _tab_mode(false), _cursor_pos(-1), @@ -117,7 +117,8 @@ void PyConsole_EnhEditor::clearCompletion() setTextCursor(tc); textCursor().deletePreviousChar(); // TODO: before wait for any TAB event to be completed - static_cast(myInterp)->clearCompletion(); + if ( myInterp ) + myInterp->clearCompletion(); } _tab_mode = false; } @@ -222,8 +223,8 @@ PyInterp_Request* PyConsole_EnhEditor::createTabRequest( const QString& input ) _compl_before_point = QString(""); } - return new CompletionCommand( static_cast(myInterp), _compl_before_point, - _compl_after_point, this, isSync() ); + return new CompletionCommand( myInterp, _compl_before_point, + _compl_after_point, this, isSync() ); } /** @@ -231,7 +232,7 @@ PyInterp_Request* PyConsole_EnhEditor::createTabRequest( const QString& input ) * @param matches list of possible completions * @param result return value */ -void PyConsole_EnhEditor::formatCompletion(const std::vector & matches, QString & result) const +void PyConsole_EnhEditor::formatCompletion(const QStringList& matches, QString& result) const { int sz = matches.size(); @@ -255,90 +256,97 @@ void PyConsole_EnhEditor::formatCompletion(const std::vector & matches, */ void PyConsole_EnhEditor::customEvent( QEvent* event ) { - std::vector matches; + QStringList matches; QString first_match, comple_text, doc, base; QTextCursor cursor(textCursor()); QTextBlockFormat bf; QTextCharFormat cf; - PyConsole_EnhInterp * interp = static_cast(myInterp); int cursorPos; switch( event->type() ) { case PyInterp_Event::ES_TAB_COMPLETE_OK: + { // Extract corresponding matches from the interpreter - matches = interp->getLastMatches(); + matches = getInterp()->getLastMatches(); + doc = getInterp()->getDocStr(); if (matches.size() == 0) - { - // Completion successful but nothing returned. - _tab_mode = false; - _cursor_pos = -1; - return; - } - + { + // Completion successful but nothing returned. + _tab_mode = false; + _cursor_pos = -1; + return; + } + // Only one match - complete directly and update doc string window - doc = interp->getDocStr(); if (matches.size() == 1) - { - first_match = matches[0].mid(_compl_after_point.size()); - cursor.insertText(first_match); - _tab_mode = false; - if (doc == QString("")) - emit updateDoc(formatDocHTML("(no documentation available)\n")); - else - emit updateDoc(formatDocHTML(doc)); - } + { + first_match = matches[0].mid(_compl_after_point.size()); + cursor.insertText(first_match); + _tab_mode = false; + if (doc.isEmpty()) + emit updateDoc(formatDocHTML("(no documentation available)\n")); + else + emit updateDoc(formatDocHTML(doc)); + } else - { - // Detect if there is a common base to all available completion - // In this case append this base to the text already - extractCommon(matches, base); - first_match = base.mid(_compl_after_point.size()); - cursor.insertText(first_match); - - // If this happens to match exaclty the first completion - // also provide doc - if (base == matches[0]) - { - doc = formatDocHTML(doc); - emit updateDoc(doc); - } - - // Print all matching completion in a "undo-able" block - cursorPos = cursor.position(); - cursor.insertBlock(); - cursor.beginEditBlock(); - - // Insert all matches - QTextCharFormat cf; - cf.setForeground(QBrush(Qt::darkGreen)); - cursor.setCharFormat(cf); - formatCompletion(matches, comple_text); - cursor.insertText(comple_text); - cursor.endEditBlock(); - - // Position cursor where it was before inserting the completion list: - cursor.setPosition(cursorPos); - setTextCursor(cursor); - } + { + // Detect if there is a common base to all available completion + // In this case append this base to the text already + extractCommon(matches, base); + first_match = base.mid(_compl_after_point.size()); + cursor.insertText(first_match); + + // If this happens to match exaclty the first completion + // also provide doc + if (base == matches[0]) + { + doc = formatDocHTML(doc); + emit updateDoc(doc); + } + + // Print all matching completion in a "undo-able" block + cursorPos = cursor.position(); + cursor.insertBlock(); + cursor.beginEditBlock(); + + // Insert all matches + QTextCharFormat cf; + cf.setForeground(QBrush(Qt::darkGreen)); + cursor.setCharFormat(cf); + formatCompletion(matches, comple_text); + cursor.insertText(comple_text); + cursor.endEditBlock(); + + // Position cursor where it was before inserting the completion list: + cursor.setPosition(cursorPos); + setTextCursor(cursor); + } break; + } case PyInterp_Event::ES_TAB_COMPLETE_ERR: + { // Tab completion was unsuccessful, switch off mode: _tab_mode = false; _cursor_pos = -1; break; + } case PyInterp_Event::ES_OK: case PyInterp_Event::ES_ERROR: case PyInterp_Event::ES_INCOMPLETE: + { // Before everything else, call super() PyConsole_Editor::customEvent(event); // If we are in multi_paste_mode, process the next item: multiLineProcessNextLine(); break; + } default: + { PyConsole_Editor::customEvent( event ); break; + } } } @@ -347,7 +355,7 @@ void PyConsole_EnhEditor::customEvent( QEvent* event ) * @param matches * @param result */ -void PyConsole_EnhEditor::extractCommon(const std::vector & matches, QString & result) const +void PyConsole_EnhEditor::extractCommon(const QStringList& matches, QString& result) const { result = ""; int charIdx = 0; diff --git a/src/PyConsole/PyConsole_EnhEditor.h b/src/PyConsole/PyConsole_EnhEditor.h index c18738f29..546ea98fc 100644 --- a/src/PyConsole/PyConsole_EnhEditor.h +++ b/src/PyConsole/PyConsole_EnhEditor.h @@ -23,13 +23,11 @@ #define PYCONSOLE_ENHEDITOR_H_ #include "PyConsole.h" - #include "PyConsole_Editor.h" + #include #include -class PyConsole_EnhInterp; - /** * Enhanced Python editor handling tab completion. */ @@ -38,7 +36,7 @@ class PYCONSOLE_EXPORT PyConsole_EnhEditor: public PyConsole_Editor Q_OBJECT; public: - PyConsole_EnhEditor(PyConsole_EnhInterp * interp, QWidget * parent=0); + PyConsole_EnhEditor(PyConsole_Interp* interp, QWidget* parent = 0); virtual ~PyConsole_EnhEditor() {} signals: @@ -83,14 +81,14 @@ protected: virtual void handleTab(); virtual void handleBackTab(); virtual void clearCompletion(); - virtual void formatCompletion(const std::vector & matches, QString & result) const; + virtual void formatCompletion(const QStringList& matches, QString& result) const; virtual QString formatDocHTML(const QString & doc) const; virtual void multilinePaste(const QString & s); virtual void multiLineProcessNextLine(); private: - void extractCommon(const std::vector & matches, QString & result) const; + void extractCommon(const QStringList& matches, QString& result) const; }; diff --git a/src/PyConsole/PyConsole_EnhInterp.cxx b/src/PyConsole/PyConsole_EnhInterp.cxx index 1f5defe07..eb5cb2705 100644 --- a/src/PyConsole/PyConsole_EnhInterp.cxx +++ b/src/PyConsole/PyConsole_EnhInterp.cxx @@ -37,6 +37,31 @@ static const char * tmp_k[] = {"and", "as", "assert", "break", "class", const std::vector PyConsole_EnhInterp::PYTHON_KEYWORDS = \ std::vector(tmp_k, tmp_k+sizeof(tmp_k)/sizeof(tmp_k[0])); +/*! + \brief Constructor +*/ +PyConsole_EnhInterp::PyConsole_EnhInterp() + : PyConsole_Interp() +{ +} + +/*! + \brief Destructor +*/ +PyConsole_EnhInterp::~PyConsole_EnhInterp() +{ +} + +QStringList PyConsole_EnhInterp::getLastMatches() const +{ + return _last_matches; +} + +QString PyConsole_EnhInterp::getDocStr() const +{ + return _doc_str; +} + /*! \brief Run Python dir() command and saves the result internally in _lastPy \param dirArgument Python expression to pass to the dir command. The parsing of what the @@ -45,7 +70,7 @@ const std::vector PyConsole_EnhInterp::PYTHON_KEYWORDS = \ the user types "a_string_variable.rsp ", this is "rsp". \return command exit status - 0 = success */ -int PyConsole_EnhInterp::runDirCommand(const QString & dirArgument, const QString & startMatch) +int PyConsole_EnhInterp::runDirCommand(const QString& dirArgument, const QString& startMatch) { int ret; std::vector v; @@ -99,8 +124,9 @@ int PyConsole_EnhInterp::runDirCommand(const QString & dirArgument, const QStrin * @return -1 if the call to dir() or the parsing of the result failed, 0 otherwise. */ int PyConsole_EnhInterp::runDirAndExtract(const QString& dirArgument, - const QString & startMatch, std::vector & result, - bool discardSwig) const + const QString& startMatch, + QStringList& result, + bool discardSwig) const { QRegExp re("^[A-Z].+_[A-Z]+[a-z]+.+$"); // discard SWIG static method, e.g. MEDCouplingUMesh_Blabla QString command("dir(" + dirArgument + ")"); @@ -146,9 +172,6 @@ int PyConsole_EnhInterp::runDirAndExtract(const QString& dirArgument, */ void PyConsole_EnhInterp::clearCompletion() { - _last_matches.resize(0); - _doc_str = QString(""); + _last_matches.clear(); + _doc_str = ""; } - - - diff --git a/src/PyConsole/PyConsole_EnhInterp.h b/src/PyConsole/PyConsole_EnhInterp.h index 4b16aa369..42c0ab35d 100644 --- a/src/PyConsole/PyConsole_EnhInterp.h +++ b/src/PyConsole/PyConsole_EnhInterp.h @@ -38,14 +38,11 @@ class PYCONSOLE_EXPORT PyConsole_EnhInterp: public PyConsole_Interp { public: - PyConsole_EnhInterp() - : PyConsole_Interp(), _last_matches(0), _doc_str("") - {} + PyConsole_EnhInterp(); + virtual ~PyConsole_EnhInterp(); - virtual ~PyConsole_EnhInterp() {} - - const std::vector& getLastMatches() const { return _last_matches; } - const QString & getDocStr() const { return _doc_str; } + virtual QStringList getLastMatches() const; + virtual QString getDocStr() const; virtual int runDirCommand(const QString& dirArgument, const QString& startMatch); virtual void clearCompletion(); @@ -55,13 +52,12 @@ protected: static const std::vector PYTHON_KEYWORDS; /** Last computed matches */ - std::vector _last_matches; + QStringList _last_matches; /** Doc string of the first match - when only one match it will be displayed by the Editor*/ QString _doc_str; - virtual int runDirAndExtract(const QString& dirArgument, const QString & startMatch, - std::vector & result, bool discardSwig=true) const; - + virtual int runDirAndExtract(const QString& dirArgument, const QString& startMatch, + QStringList& result, bool discardSwig=true) const; }; #endif /* PYCONSOLE_ENHINTERP_H_ */ diff --git a/src/PyConsole/PyConsole_Interp.cxx b/src/PyConsole/PyConsole_Interp.cxx index 01c94fe20..e1365760a 100644 --- a/src/PyConsole/PyConsole_Interp.cxx +++ b/src/PyConsole/PyConsole_Interp.cxx @@ -19,12 +19,9 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // - -// SALOME SALOMEGUI : implementation of desktop and GUI kernel // File : PyConsole_Interp.cxx // Author : Nicolas REJNERI, Adrien BRUNETON -// Module : SALOME -// + #include "PyConsole_Interp.h" /*! @@ -48,14 +45,17 @@ Creates new python interpreter. */ PyConsole_Interp::PyConsole_Interp(): PyInterp_Interp() -{} +{ +} /*! \brief Destructor. Does nothing for the moment. */ -PyConsole_Interp::~PyConsole_Interp() { } +PyConsole_Interp::~PyConsole_Interp() +{ +} /*! Sets the variable "__IN_SALOME_GUI_CONSOLE" to True. * This is not attached to a module (like salome_iapp.IN_SALOME_GUI_CONSOLE) @@ -72,3 +72,22 @@ int PyConsole_Interp::afterRun() { return PyRun_SimpleString("__builtins__.__IN_SALOME_GUI_CONSOLE=False"); } + +QStringList PyConsole_Interp::getLastMatches() const +{ + return QStringList(); +} + +QString PyConsole_Interp::getDocStr() const +{ + return QString(); +} + +int PyConsole_Interp::runDirCommand(const QString&, const QString& ) +{ + return 0; +} + +void PyConsole_Interp::clearCompletion() +{ +} diff --git a/src/PyConsole/PyConsole_Interp.h b/src/PyConsole/PyConsole_Interp.h index 5434e4813..31e8f7e97 100644 --- a/src/PyConsole/PyConsole_Interp.h +++ b/src/PyConsole/PyConsole_Interp.h @@ -19,18 +19,16 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // - -// SALOME SALOMEGUI : implementation of desktop and GUI kernel // File : PyConsole_Interp.h // Author : Nicolas REJNERI, Adrien BRUNETON -// Module : SALOME -// + #ifndef PYCONSOLE_INTERP_H #define PYCONSOLE_INTERP_H #include "PyConsole.h" +#include "PyInterp_Interp.h" /// !!! WARNING !!! THIS INCLUDE MUST BE VERY FIRST !!! -#include /// !!! WARNING !!! THIS INCLUDE MUST BE VERY FIRST !!! +#include class PYCONSOLE_EXPORT PyConsole_Interp : public PyInterp_Interp { @@ -40,6 +38,12 @@ public: virtual int afterRun(); virtual int beforeRun(); + + virtual QStringList getLastMatches() const; + virtual QString getDocStr() const; + + virtual int runDirCommand(const QString&, const QString&); + virtual void clearCompletion(); }; #endif // PYCONSOLE_INTERP_H diff --git a/src/PyConsole/PyConsole_Request.cxx b/src/PyConsole/PyConsole_Request.cxx index 97bf7f2df..12a5e612d 100644 --- a/src/PyConsole/PyConsole_Request.cxx +++ b/src/PyConsole/PyConsole_Request.cxx @@ -20,11 +20,9 @@ // Created on: 3 avr. 2013 #include "PyConsole_Request.h" - -#include "PyInterp_Event.h" +#include "PyConsole_Interp.h" #include "PyConsole_Event.h" -#include "PyConsole_EnhInterp.h" -#include "PyConsole_EnhEditor.h" +#include "PyInterp_Event.h" #include @@ -37,12 +35,12 @@ * @param sync */ ExecCommand::ExecCommand( PyInterp_Interp* theInterp, - const QString& theCommand, - PyConsole_Editor* theListener, - bool sync ) - : PyInterp_LockRequest( theInterp, theListener, sync ), - myCommand( theCommand ), myState( PyInterp_Event::ES_OK ) - {} + const QString& theCommand, + QObject* theListener, + bool theSync ) + : PyInterp_LockRequest( theInterp, theListener, theSync ), + myCommand( theCommand ), myState( PyInterp_Event::ES_OK ) +{} /** * Execute the command by calling the run() method of the embedded interpreter. @@ -50,13 +48,13 @@ ExecCommand::ExecCommand( PyInterp_Interp* theInterp, void ExecCommand::execute() { if ( myCommand != "" ) - { - int ret = getInterp()->run( myCommand.toUtf8().data() ); - if ( ret < 0 ) - myState = PyInterp_Event::ES_ERROR; - else if ( ret > 0 ) - myState = PyInterp_Event::ES_INCOMPLETE; - } + { + int ret = getInterp()->run( myCommand.toUtf8().data() ); + if ( ret < 0 ) + myState = PyInterp_Event::ES_ERROR; + else if ( ret > 0 ) + myState = PyInterp_Event::ES_INCOMPLETE; + } } /** @@ -80,13 +78,13 @@ QEvent* ExecCommand::createEvent() \param theListener widget to get the notification messages \param sync if True the request is processed synchronously */ -CompletionCommand::CompletionCommand( PyConsole_EnhInterp* theInterp, - const QString& input, - const QString& startMatch, - PyConsole_EnhEditor* theListener, - bool sync) - : PyInterp_LockRequest( theInterp, theListener, sync ), - _tabSuccess(false), _dirArg(input), _startMatch(startMatch) +CompletionCommand::CompletionCommand( PyInterp_Interp* theInterp, + const QString& theInput, + const QString& theStartMatch, + QObject* theListener, + bool theSync ) + : PyInterp_LockRequest( theInterp, theListener, theSync ), + _tabSuccess(false), _dirArg(theInput), _startMatch(theStartMatch) {} /** @@ -95,12 +93,8 @@ CompletionCommand::CompletionCommand( PyConsole_EnhInterp* theInterp, */ void CompletionCommand::execute() { - PyConsole_EnhInterp * interp = static_cast(getInterp()); - int ret = interp->runDirCommand( _dirArg, _startMatch); - if (ret == 0) - _tabSuccess = true; - else - _tabSuccess = false; + int ret = static_cast(getInterp())->runDirCommand( _dirArg, _startMatch ); + _tabSuccess = ret == 0; } /** @@ -110,9 +104,5 @@ void CompletionCommand::execute() QEvent* CompletionCommand::createEvent() { int typ = _tabSuccess ? PyInterp_Event::ES_TAB_COMPLETE_OK : PyInterp_Event::ES_TAB_COMPLETE_ERR; - return new PyInterp_Event( typ, this); } - - - diff --git a/src/PyConsole/PyConsole_Request.h b/src/PyConsole/PyConsole_Request.h index c2f22ff43..5605cc7fa 100644 --- a/src/PyConsole/PyConsole_Request.h +++ b/src/PyConsole/PyConsole_Request.h @@ -23,7 +23,6 @@ #ifndef PYCONSOLE_REQUEST_H_ #define PYCONSOLE_REQUEST_H_ -#include "PyConsole.h" #include "PyInterp_Request.h" #include @@ -31,7 +30,6 @@ #include class PyInterp_Interp; -class PyConsole_Editor; /*! \class ExecCommand @@ -52,8 +50,8 @@ public: */ ExecCommand( PyInterp_Interp* theInterp, const QString& theCommand, - PyConsole_Editor* theListener, - bool sync = false ); + QObject* theListener, + bool theSync = false ); protected: /*! @@ -73,17 +71,14 @@ private: int myState; //!< Python command execution status }; -class PyConsole_EnhInterp; -class PyConsole_EnhEditor; - class CompletionCommand : public PyInterp_LockRequest { public: - CompletionCommand( PyConsole_EnhInterp* theInterp, - const QString& input, - const QString& startMatch, - PyConsole_EnhEditor* theListener, - bool sync = false ); + CompletionCommand( PyInterp_Interp* theInterp, + const QString& theInput, + const QString& theStartMatch, + QObject* theListener, + bool theSync = false ); protected: @@ -99,7 +94,6 @@ protected: virtual void execute(); virtual QEvent* createEvent(); - }; #endif /* PYCONSOLE_REQUEST_H_ */ diff --git a/src/Qtx/QtxRubberBand.cxx b/src/Qtx/QtxRubberBand.cxx index 16dca8b96..9a72c5846 100755 --- a/src/Qtx/QtxRubberBand.cxx +++ b/src/Qtx/QtxRubberBand.cxx @@ -205,8 +205,8 @@ void QtxAbstractRubberBand::updateMask() if ( isClosed() ) r += createRegion( myPoints.last(), myPoints.first() ); - setMask( r ); - + if ( !r.isEmpty() ) + setMask( r ); } diff --git a/src/SOCC/SOCC_ViewModel.cxx b/src/SOCC/SOCC_ViewModel.cxx index 3def58d2c..69f17119d 100755 --- a/src/SOCC/SOCC_ViewModel.cxx +++ b/src/SOCC/SOCC_ViewModel.cxx @@ -57,7 +57,6 @@ //#include "SALOMEDSClient.hxx" //#include "SALOMEDS_StudyManager.hxx" -#include #include #include diff --git a/src/SVTK/resources/SVTK_msg_en.ts b/src/SVTK/resources/SVTK_msg_en.ts index a21b2d92d..e7f237aae 100644 --- a/src/SVTK/resources/SVTK_msg_en.ts +++ b/src/SVTK/resources/SVTK_msg_en.ts @@ -263,7 +263,7 @@ DSC_SVTK_SCALING - Scaling + Change scale of axes MNU_SVTK_SCALING @@ -341,10 +341,6 @@ Please, refer to the documentation. LBL_Z Z: - - MEN_SCALING - Scaling - DLG_TITLE Scaling diff --git a/src/SVTK/resources/SVTK_msg_fr.ts b/src/SVTK/resources/SVTK_msg_fr.ts index 15f55eca9..01ae93dac 100755 --- a/src/SVTK/resources/SVTK_msg_fr.ts +++ b/src/SVTK/resources/SVTK_msg_fr.ts @@ -263,7 +263,7 @@ DSC_SVTK_SCALING - Mise à l'échelle + Changer l'échelle des axes de coordonnées MNU_SVTK_SCALING @@ -341,10 +341,6 @@ Veuillez consulter la documentation. LBL_Z Z: - - MEN_SCALING - Echelle - DLG_TITLE Mise à l'échelle diff --git a/src/SVTK/resources/SVTK_msg_ja.ts b/src/SVTK/resources/SVTK_msg_ja.ts index 11d36a3ef..983fa07a1 100644 --- a/src/SVTK/resources/SVTK_msg_ja.ts +++ b/src/SVTK/resources/SVTK_msg_ja.ts @@ -263,7 +263,7 @@ DSC_SVTK_SCALING - スケーリング + 座標のスケールの軸を変更します。 MNU_SVTK_SCALING @@ -340,10 +340,6 @@ LBL_Z Z: - - MEN_SCALING - スケール - DLG_TITLE スケーリング diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 12ff6b9a3..c142eca0b 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -588,6 +588,9 @@ void SalomeApp_Application::onDesktopMessage( const QString& message ) if ( a ) a->setEnabled( false ); } + else if ( message.toLower() == "connect_to_study" ) { + onLoadDoc(); + } LightApp_Application::onDesktopMessage( message ); } @@ -1109,7 +1112,7 @@ QWidget* SalomeApp_Application::createWindow( const int flag ) #ifndef DISABLE_PYCONSOLE else if ( flag == WT_PyConsole ) { - PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(), new SalomeApp_PyInterp() ); + PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(), getPyInterp() ); pyCons->setObjectName( "pythonConsole" ); pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) ); pyCons->setFont(resourceMgr()->fontValue( "PyConsole", "font" )); @@ -2121,3 +2124,13 @@ bool SalomeApp_Application::checkExistingDoc() } return result; } + + +#ifndef DISABLE_PYCONSOLE + +PyConsole_Interp* SalomeApp_Application::createPyInterp() +{ + return new SalomeApp_PyInterp(); +} + +#endif // DISABLE_PYCONSOLE diff --git a/src/SalomeApp/SalomeApp_Application.h b/src/SalomeApp/SalomeApp_Application.h index b9833a1dc..aeee6dcb2 100644 --- a/src/SalomeApp/SalomeApp_Application.h +++ b/src/SalomeApp/SalomeApp_Application.h @@ -168,6 +168,7 @@ protected: #ifndef DISABLE_PYCONSOLE bool updateStudy(); + virtual PyConsole_Interp* createPyInterp(); #endif virtual void afterCloseDoc(); diff --git a/src/SalomeApp/SalomeApp_DoubleSpinBox.cxx b/src/SalomeApp/SalomeApp_DoubleSpinBox.cxx index 527449499..9611f2ff4 100644 --- a/src/SalomeApp/SalomeApp_DoubleSpinBox.cxx +++ b/src/SalomeApp/SalomeApp_DoubleSpinBox.cxx @@ -23,7 +23,6 @@ #ifndef DISABLE_PYCONSOLE #include // this include must be first (see PyInterp_base.h)! - #include #endif #include "SalomeApp_DoubleSpinBox.h" @@ -438,8 +437,7 @@ SalomeApp_DoubleSpinBox::SearchState SalomeApp_DoubleSpinBox::findVariable( cons if( studyDS->IsString( aName ) ) { #ifndef DISABLE_PYCONSOLE - PyConsole_Console* pyConsole = app->pythonConsole(); - PyConsole_Interp* pyInterp = pyConsole->getInterp(); + PyConsole_Interp* pyInterp = app->getPyInterp(); PyLockWrapper aLock; // Acquire GIL std::string command; command = "import salome_notebook ; "; diff --git a/src/SalomeApp/SalomeApp_ExceptionHandler.cxx b/src/SalomeApp/SalomeApp_ExceptionHandler.cxx index 6c2184022..a4360c60e 100644 --- a/src/SalomeApp/SalomeApp_ExceptionHandler.cxx +++ b/src/SalomeApp/SalomeApp_ExceptionHandler.cxx @@ -24,7 +24,6 @@ #include "Utils_CorbaException.hxx" #include "CASCatch.hxx" -#include "Basics_OCCTVersion.hxx" #include diff --git a/src/SalomeApp/SalomeApp_IntSpinBox.cxx b/src/SalomeApp/SalomeApp_IntSpinBox.cxx index 2e8bcc78d..b5cc01765 100644 --- a/src/SalomeApp/SalomeApp_IntSpinBox.cxx +++ b/src/SalomeApp/SalomeApp_IntSpinBox.cxx @@ -23,7 +23,6 @@ #ifndef DISABLE_PYCONSOLE #include //this include must be first (see PyInterp_base.h)! - #include #endif #include "SalomeApp_IntSpinBox.h" @@ -386,8 +385,7 @@ SalomeApp_IntSpinBox::SearchState SalomeApp_IntSpinBox::findVariable( const QStr if( studyDS->IsString( aName ) ) { #ifndef DISABLE_PYCONSOLE - PyConsole_Console* pyConsole = app->pythonConsole(); - PyConsole_Interp* pyInterp = pyConsole->getInterp(); + PyConsole_Interp* pyInterp = app->getPyInterp(); PyLockWrapper aLock; // Acquire GIL std::string command; command = "import salome_notebook ; "; diff --git a/src/SalomeApp/SalomeApp_NoteBook.cxx b/src/SalomeApp/SalomeApp_NoteBook.cxx index b5ecb767a..242aae2ca 100644 --- a/src/SalomeApp/SalomeApp_NoteBook.cxx +++ b/src/SalomeApp/SalomeApp_NoteBook.cxx @@ -285,7 +285,7 @@ bool NoteBook_TableRow::IsValidStringValue(const QString theValue) SalomeApp_Application* app = dynamic_cast( SUIT_Session::session()->activeApplication() ); PyConsole_Console* pyConsole = app->pythonConsole(); - PyConsole_Interp* pyInterp = pyConsole->getInterp(); + PyConsole_Interp* pyInterp = app->getPyInterp(); PyLockWrapper aLock; // Acquire GIL std::string command = "import salome_notebook ; "; command += "salome_notebook.checkThisNoteBook("; @@ -459,7 +459,7 @@ bool NoteBook_Table::IsValid() const SalomeApp_Application* app = dynamic_cast( SUIT_Session::session()->activeApplication() ); PyConsole_Console* pyConsole = app->pythonConsole(); - PyConsole_Interp* pyInterp = pyConsole->getInterp(); + PyConsole_Interp* pyInterp = app->getPyInterp(); PyLockWrapper aLock; // Acquire GIL std::string command = "import salome_notebook ; "; command += "salome_notebook.checkThisNoteBook("; diff --git a/src/SalomeApp/SalomeApp_PyInterp.h b/src/SalomeApp/SalomeApp_PyInterp.h index bf7bd8d50..a0b6a3ec2 100755 --- a/src/SalomeApp/SalomeApp_PyInterp.h +++ b/src/SalomeApp/SalomeApp_PyInterp.h @@ -31,8 +31,9 @@ class SalomeApp_PyInterp : public PyConsole_EnhInterp { + friend class SalomeApp_Application; + public: - SalomeApp_PyInterp(); virtual ~SalomeApp_PyInterp(); virtual void initPython(); @@ -40,6 +41,7 @@ public: virtual void closeContext(); protected: + SalomeApp_PyInterp(); virtual int beforeRun(); private: diff --git a/src/SalomeApp/SalomeApp_Study.cxx b/src/SalomeApp/SalomeApp_Study.cxx index 293488936..ab6166997 100644 --- a/src/SalomeApp/SalomeApp_Study.cxx +++ b/src/SalomeApp/SalomeApp_Study.cxx @@ -49,7 +49,6 @@ #ifndef DISABLE_PYCONSOLE #include "SalomeApp_PyInterp.h" // WARNING! This include must be the first! - #include #endif #include "utilities.h" @@ -741,8 +740,7 @@ void SalomeApp_Study::closeDocument(bool permanently) desk->blockSignals( isBlocked ); #ifndef DISABLE_PYCONSOLE SalomeApp_Application* app = dynamic_cast( application() ); - if( app->pythonConsole() ) - app->pythonConsole()->getInterp()->destroy(); + app->getPyInterp()->destroy(); #endif } SALOMEDSClient_Study* aStudy = 0; diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index ee57a9cd1..30d208e83 100755 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -30,8 +30,6 @@ #include #include -#include - #include #include #include diff --git a/src/TreeData/TreeItem.cxx b/src/TreeData/TreeItem.cxx index 8e6dbce63..9a0e66b47 100644 --- a/src/TreeData/TreeItem.cxx +++ b/src/TreeData/TreeItem.cxx @@ -47,7 +47,7 @@ void TreeItem::initialize(const QString &nameId, //when creating the root item). if ( parent != NULL ) { this->associateToModel(parent->associatedModel()); - } + } } TreeItem::~TreeItem() @@ -128,13 +128,13 @@ void TreeItem::appendChild(const QString &nameId, folder = new TreeItem(folderNameId, folderColumnValues, this); this->appendChild(folder); } - + // We create the relative path of the next iteration (delete the // first folder path). QStringList nextRelativePath; for (int i = 1; i < relativePath.size(); ++i) nextRelativePath << relativePath[i]; - + folder->appendChild(nameId, columnValues, nextRelativePath); } @@ -154,6 +154,49 @@ void TreeItem::appendChild(TreeItem *item) model->endInsertRows(); } +/*! + * This removes the specified child to this item. This item is the + * direct parent of the specified child. + */ +void TreeItem::removeChild(TreeItem *item) +{ + TreeModel * model = this->associatedModel(); + + int position = this->childCount(); + model->beginRemoveRows(this->modelIndex(), position, position); + _childItems.removeOne(item); + _childItemsMapById.remove(item->nameId()); + _childItemsMapByLabel.remove(item->data(0).toString()); + model->endRemoveRows(); +} + +void TreeItem::removeChild(DataObject * dataObject, const QStringList &relativePath) { + if ( relativePath.isEmpty() ) { + // It is a direct child => just remove it. + QString nameId = QString(dataObject->getNameId().c_str()); + TreeItem * child = this->childById(nameId); + if (child != NULL) + this->removeChild(child); + return; + } + + // The child is embedded in a sub-folder. + // We first check if the sub-folder already exist: + TreeItem * folder = this->childByLabel(relativePath[0]); + if ( folder == NULL ) + return; + + // Go down into subfolder, if any. + QStringList nextRelativePath; + for (int i = 1; i < relativePath.size(); ++i) + nextRelativePath << relativePath[i]; + + folder->removeChild(dataObject, nextRelativePath); + + if (folder->childCount() == 0) + this->removeChild(folder); +} + /*! * The child() function returns the child that corresponds to the * specified row number in the item's list of child items. diff --git a/src/TreeData/TreeItem.hxx b/src/TreeData/TreeItem.hxx index d60e560fe..c0a7d4077 100644 --- a/src/TreeData/TreeItem.hxx +++ b/src/TreeData/TreeItem.hxx @@ -51,8 +51,10 @@ class TREEDATA_EXPORT TreeItem const QVector &columnValues, const QStringList &relativePath=QStringList()); - - + void removeChild(TreeItem * child); + void removeChild(DataObject * dataObject, + const QStringList &relativePath=QStringList()); + TreeItem *child(int row); TreeItem *childById(const QString &nameId); TreeItem *childByLabel(const QString &label); @@ -62,7 +64,6 @@ class TREEDATA_EXPORT TreeItem QVariant data(int column) const; bool setData(int column, const QVariant &value); - private: void initialize(const QString &nameId, const QVector &columnValues, diff --git a/src/TreeData/TreeModel.cxx b/src/TreeData/TreeModel.cxx index 12510fd40..0c5e6422b 100644 --- a/src/TreeData/TreeModel.cxx +++ b/src/TreeData/TreeModel.cxx @@ -186,7 +186,7 @@ bool TreeModel::setHeaderData(int section, Qt::Orientation orientation, // This part is a specific behavior to get a TreeModel that can // organize itself the tree hierarchy using data provided in a // filesystem-like format: -// +// // data="a/b/c" ==> creation/filling of the hierarchy a->b->c // The "folder" categories are unique whereas the leaves may exists // in multiple instances. @@ -208,3 +208,10 @@ bool TreeModel::addData(DataObject * dataObject, const QStringList &path) { rootItem->appendChild(dataObject, path); return true; } + +bool TreeModel::removeData(DataObject * dataObject) { + QStringList path = QString(dataObject->getPath().c_str()).split(DataObject::pathsep.c_str()); + TreeItem * rootItem = this->getItem(); + rootItem->removeChild(dataObject, path); + return true; +} diff --git a/src/TreeData/TreeModel.hxx b/src/TreeData/TreeModel.hxx index 9cb262e08..65bafb687 100644 --- a/src/TreeData/TreeModel.hxx +++ b/src/TreeData/TreeModel.hxx @@ -83,7 +83,7 @@ public: // This part is a specific behavior to get a TreeModel that can // organize itself the tree hierarchy using data provided in a // filesystem-like format: - // + // // data="a/b/c" ==> creation/filling of the hierarchy a->b->c // The "folder" categories are unique whereas the leaves may exists // in multiple instances. @@ -93,6 +93,7 @@ public: bool addData(DataObject * dataObject, const QStringList &path); // TODO: We should implement the delete and the update fucntions + bool removeData(DataObject * dataObject); // This part contains helper functions for general purposes TreeItem * getRootItem();