+// Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
// File: SalomeApp_Application.h
// Created: 10/22/2004 3:37:25 PM
// Author: Sergey LITONIN
-// Copyright (C) CEA 2004
-
+//
#ifndef SALOMEAPP_APPLICATION_H
#define SALOMEAPP_APPLICATION_H
#endif // _MSC_VER > 1000
#include "SalomeApp.h"
-#include <CAM_Application.h>
+#include <LightApp_Application.h>
-#include <CORBA.h>
+#include <omniORB4/CORBA.h>
-#include <SALOMEconfig.h>
+//#include <SALOMEconfig.h>
//#include CORBA_CLIENT_HEADER(SALOMEDS)
#include <SALOME_NamingService.hxx>
#include "SALOMEDSClient.hxx"
-class QAction;
-class QComboBox;
-class QDockWindow;
+#include <QPointer>
-class LogWindow;
-class OB_Browser;
-class PythonConsole;
-class SalomeApp_Module;
-class SalomeApp_Preferences;
-class SalomeApp_SelectionMgr;
-class SalomeApp_WidgetContainer;
-class SUIT_Accel;
+#include <memory>
+class LightApp_Preferences;
+class SalomeApp_Study;
+#ifndef DISABLE_PYCONSOLE
+class SalomeApp_NoteBook;
+#endif
+class SUIT_Desktop;
class SALOME_LifeCycleCORBA;
+
#ifdef WIN32
#pragma warning( disable:4251 )
#endif
/*!
- Description : Application containing SalomeApp module
+ \class SalomeApp_Application
+ \brief Application containing SalomeApp module or LightApp module
*/
-class SALOMEAPP_EXPORT SalomeApp_Application : public CAM_Application
+class SALOMEAPPIMPL_EXPORT SalomeApp_Application : public LightApp_Application
{
Q_OBJECT
public:
- typedef enum { WT_ObjectBrowser, WT_PyConsole, WT_LogWindow, WT_User } WindowTypes;
+ enum { MenuToolsId = 5 };
+ enum { DumpStudyId = LightApp_Application::UserID, LoadScriptId, PropertiesId,
+ CatalogGenId, RegDisplayId, SaveGUIStateId, ConnectId, DisconnectId,
+ UserID };
- enum { ModulesListId = STD_Application::UserID, NewGLViewId,
- NewPlot2dId, NewOCCViewId, NewVTKViewId, DumpStudyId,
- LoadScriptId, PropertiesId, PreferencesId, MRUId,
- CatalogGenId, RegDisplayId, UserID };
+ typedef enum { WT_NoteBook = LightApp_Application::WT_User,
+ WT_User
+ } WindowTypes;
+
+protected:
+ enum { OpenRefresh = LightApp_Application::OpenReload + 1 };
+ enum { CloseDisconnectSave = LightApp_Application::CloseDiscard + 1, CloseDisconnect };
+ enum { LoadStudyId = LightApp_Application::OpenStudyId + 1, NewAndScriptId };
public:
- SalomeApp_Application();
+ SalomeApp_Application(SALOME_NamingService_Abstract *ns = nullptr);
virtual ~SalomeApp_Application();
-
- virtual QString applicationName() const;
- virtual QString applicationVersion() const;
-
- virtual CAM_Module* loadModule( const QString& );
- virtual bool activateModule( const QString& );
-
- virtual bool useStudy( const QString& );
-
- SalomeApp_SelectionMgr* selectionMgr() const;
-
- LogWindow* logWindow();
- OB_Browser* objectBrowser();
- PythonConsole* pythonConsole();
virtual void updateObjectBrowser( const bool = true );
- SalomeApp_Preferences* preferences() const;
-
- virtual QString getFileFilter() const;
- virtual QString getFileName( bool open, const QString& initial, const QString& filters,
- const QString& caption, QWidget* parent );
- virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent );
- virtual QStringList getOpenFileNames( const QString& initial, const QString& filters,
- const QString& caption, QWidget* parent );
-
- SUIT_ViewManager* getViewManager( const QString&, const bool );
-
- void updateActions();
+ virtual void start();
- QWidget* getWindow( const int, const int = -1 );
+ virtual void contextMenuPopup( const QString&, QMenu*, QString& );
- QWidget* window( const int, const int = -1 ) const;
- void addWindow( QWidget*, const int, const int = -1 );
- void removeWindow( const int, const int = -1 );
+ virtual bool checkDataObject(LightApp_DataObject* theObj);
- bool isWindowVisible( const int ) const;
- void setWindowShown( const int, const bool );
+ virtual bool checkExistingDoc();
- virtual void start();
+ static CORBA::ORB_var orb();
+ static _PTR(Study) getStudy();
+ static SALOME_NamingService_Abstract* namingService();
+ static SALOME_LifeCycleCORBA* lcc();
- virtual void contextMenuPopup( const QString&, QPopupMenu*, QString& );
+ SUIT_ViewManager* newViewManager(const QString&);
+ void updateSavePointDataObjects( SalomeApp_Study* );
- virtual void createEmptyStudy();
+ virtual bool isPossibleToClose( bool& );
- SUIT_Accel* accel() const;
+ virtual bool useStudy( const QString& );
+ virtual void updateDesktopTitle();
- static CORBA::ORB_var orb();
- static SALOMEDSClient_StudyManager* studyMgr();
- static SALOME_NamingService* namingService();
- static SALOME_LifeCycleCORBA* lcc();
- static QString defaultEngineIOR();
+#ifndef DISABLE_PYCONSOLE
+ virtual void setNoteBook(SalomeApp_NoteBook* theNoteBook);
+ virtual SalomeApp_NoteBook* getNoteBook() const;
+#endif
-signals:
- void studyOpened();
- void studySaved();
- void studyClosed();
+ virtual bool renameAllowed( const QString& ) const;
+ virtual bool renameObject( const QString&, const QString& );
public slots:
virtual void onNewDoc();
- virtual void onOpenDoc();
- virtual void onHelpAbout();
- virtual bool onOpenDoc( const QString& );
virtual void onLoadDoc();
+ virtual void onNewWithScript();
virtual bool onLoadDoc( const QString& );
+ virtual void onUnloadDoc( bool ask = true);
+ virtual void onCloseDoc( bool ask = true);
+ virtual void onOpenDoc();
+ virtual bool onOpenDoc( const QString& );
+ virtual bool onReopenDoc();
+
+ virtual void onExit();
virtual void onCopy();
- virtual void onPaste();
-
-private slots:
- void onSelection();
- void onRefresh();
- void onDeleteReferences();
+ virtual void onPaste();
+ void onSaveGUIState();// called from VISU
+#ifndef DISABLE_PYCONSOLE
+ void onUpdateStudy(); // called from NoteBook
+#endif
+ bool onRestoreStudy( const QString& theDumpScript,
+ const QString& theStudyName,
+ bool theIsStudySaved );
+
+ virtual void onDockWindowVisibilityChanged( bool );
+
+protected slots:
+ void onStudyCreated( SUIT_Study* );
+ void onStudyOpened( SUIT_Study* );
+ void onDesktopMessage( const QString& );
+
+ virtual void onModuleActivation( const QString& );
protected:
virtual void createActions();
virtual SUIT_Study* createNewStudy();
virtual QWidget* createWindow( const int );
- virtual void defaultWindows( QMap<int, int>& ) const;
- virtual void defaultViewManagers( QStringList& ) const;
-
- virtual void setActiveStudy( SUIT_Study* );
virtual void updateCommandsStatus();
-
virtual void onSelectionChanged();
- virtual void beforeCloseDoc( SUIT_Study* );
- virtual void afterCloseDoc();
+ virtual void createPreferences( LightApp_Preferences* );
- virtual void moduleAdded( CAM_Module* );
- virtual bool activateModule( CAM_Module* = 0 );
+ virtual bool closeAction( const int, bool& );
+ virtual int closeChoice( const QString& );
- SalomeApp_Preferences* preferences( const bool ) const;
+ virtual int openChoice( const QString& );
+ virtual bool openAction( const int, const QString& );
- virtual void createPreferences( SalomeApp_Preferences* );
- virtual void preferencesChanged( const QString&, const QString& );
- virtual void updateDesktopTitle();
+ virtual QMap<int, QString> activateModuleActions() const;
+ virtual void moduleActionSelected( const int );
-protected slots:
- virtual void onDesktopActivated();
+ void objectBrowserColumnsVisibility();
-private slots:
- void onNewWindow();
- void onModuleActivation( QAction* );
- void onCloseView( SUIT_ViewManager* );
+#ifndef DISABLE_PYCONSOLE
+ bool updateStudy();
+ virtual PyConsole_Interp* createPyInterp();
+#endif
- void onStudyCreated( SUIT_Study* );
- void onStudyOpened( SUIT_Study* );
- void onStudySaved( SUIT_Study* );
- void onStudyClosed( SUIT_Study* );
-
+ virtual bool canOpenDoc( const QString& );
+ virtual void afterCloseDoc();
+
+ virtual void addCatalogue( const QString&, const QString& );
+
+private slots:
+ void onDeleteInvalidReferences();
+ void onDblClick( SUIT_DataObject* );
void onProperties();
void onDumpStudy();
- void onLoadScript();
+ void onLoadScript();
- void onPreferences();
- void onMRUActivated( QString );
+ void onDeleteGUIState();
+ void onRestoreGUIState();
void onCatalogGen();
void onRegDisplay();
-
- void onPreferenceChanged( QString&, QString&, QString& );
void onOpenWith();
+ void onExtAction();
private:
- void updateWindows();
- void updateViewManagers();
- void updateModuleActions();
-
- void loadWindowsGeometry();
- void saveWindowsGeometry();
+ void createExtraActions();
+ void ensureShaperIsActivated();
- void updatePreference( const QString&, const QString&, const QString& );
-
- QString defaultModule() const;
- void currentWindows( QMap<int, int>& ) const;
- void currentViewManagers( QStringList& ) const;
- SUIT_ViewManager* createViewManager( const QString& vmType );
- void moduleIconNames( QMap<QString, QString>& ) const;
-
- void activateWindows();
-
-private:
- typedef QMap<QString, QAction*> ActionMap;
- typedef QMap<int, SalomeApp_WidgetContainer*> WindowMap;
+ QString getScriptFileName();
+ void execScript(bool isNewDoc);
private:
- SalomeApp_Preferences* myPrefs;
- SalomeApp_SelectionMgr* mySelMgr;
- ActionMap myActions;
- WindowMap myWindows;
+#ifndef DISABLE_PYCONSOLE
+ QPointer<SalomeApp_NoteBook> myNoteBook; // Notebook instance
+#endif
+ QMap<QString, QAction*> myExtActions; // Map <AttributeUserID, QAction>
+ bool myIsCloseFromExit; // "Close from Exit" flag
- SUIT_Accel* myAccel;
+ bool myToIgnoreMessages;// to ignore messages from SALOMEDS
- static SalomeApp_Preferences* _prefs_;
+signals:
+ void dumpedStudyClosed( const QString& theDumpScript,
+ const QString& theStudyName,
+ bool theIsStudySaved );
+ void notebookVarUpdated( QString theVarName );
+ void objectDoubleClicked( SUIT_DataObject* );
+protected:
+ static std::unique_ptr<SALOME_NamingService_Abstract> _ns;
};
#ifdef WIN32