Salome HOME
PR: mergefrom_PAL_OCC_21Oct04
[modules/kernel.git] / src / SALOMEGUI / QAD_Desktop.h
index 0d25d2243a411152a629badeb80c75d074ea261e..83bc083c972ceb6c8f30bb1c09f3831fae75a4d8 100644 (file)
@@ -1,12 +1,29 @@
-//  File      : QAD_Desktop.h
-//  Created   : UI team, 02.10.00
-//  Descr     : Main desktop of QAD-based application
-
-//  Modified  : Mon Dec 03 13:40:28 2001
-//  Author    : Nicolas REJNERI
-//  Project   : SALOME
-//  Module    : SALOMEGUI
-//  Copyright : Open CASCADE 2001
+//  SALOME SALOMEGUI : implementation of desktop and GUI kernel
+//
+//  Copyright (C) 2003  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. 
+// 
+//  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//
+//
+//
+//  File   : QAD_Desktop.h
+//  Author : Nicolas REJNERI
+//  Module : SALOME
 //  $Header$
 
 #ifndef QAD_DESKTOP_H
 #include "QAD_Application.h"
 #include "QAD_OperatorMenus.h"
 #include "QAD_Menus.h"
-#include "QAD_HelpWindow.h"
+//NRI#include "QAD_HelpWindow.h"
+#include "QAD_Action.h"
 
 #include "SALOME_NamingService.hxx"
 #include "SALOME_LifeCycleCORBA.hxx"
+#include "SALOME_Selection.h"
 
 // IDL Headers 
 #include <SALOMEconfig.h>
@@ -30,7 +49,6 @@
 
 // QT Includes
 #include <qlist.h>
-#include <qaction.h>
 #include <qmap.h>
 #include <qmenubar.h>
 #include <qtoolbar.h>
 #include <qfiledialog.h>
 #include <qtoolbutton.h>
 
-// Open CASCADE Includes
-#include <OSD_SharedLibrary.hxx>
-
-class ActionMap {
- public:
-     ActionMap() {}
-     ~ActionMap() 
-     { 
-       QMapIterator<unsigned int, QAction*> it;
-       for ( it = myMap.begin(); it != myMap.end(); it++ ) delete (QAction*)it.data();
-       myMap.clear();
-     }
-     bool isEmpty()                                           { return myMap.isEmpty(); }
-     void insert( const unsigned int id, QAction* action )    { myMap[id] = action;     }
-     QAction* at( const unsigned int id )                     { return myMap[id];       }
-     void clear()                                             { myMap.clear();          }
-     QAction*& operator[] (const unsigned int id)             { return myMap[id];       }
-
- private:
-     QMap<unsigned int, QAction*> myMap;
-
-};
-
-class ToggleAction : public QAction {
-  Q_OBJECT
- public:
-  ToggleAction( const QString& text,     const QString& menuText, 
-               QKeySequence   accel,    QObject*       parent, 
-               const char*    name = 0, bool           toggle = FALSE)
-    : QAction( text, menuText, accel, parent, name, toggle ) 
-      {
-       connect( this, SIGNAL(toggled(bool)), this, SLOT(onToggled(bool)));
-      }
- private slots:
-  void onToggled( bool on)
-    {
-      on ? emit( toggledOn() ) : emit( toggledOff() );
-    }
-  
- signals:
-  void toggledOn();
-  void toggledOff();
-};
-
 class QAD_XmlHandler;
+class SALOMEGUI;
+class SALOME_Event;
 
 class QAD_EXPORT QAD_Desktop : public QMainWindow
 {
@@ -95,7 +71,7 @@ class QAD_EXPORT QAD_Desktop : public QMainWindow
 protected:
   //NRI - unused - :  enum ComponentType {GEOM, MESH, SOLVER, DATA, VISU, OTHER} ;
 
-  enum {  FileNewId = 0, FileOpenId, FileLoadId, FileCloseId, FileSaveId, FileSaveAsId, FilePropsId, FileExitId,
+  enum {  FileNewId = -1000, FileOpenId, FileLoadId, FileCloseId, FileSaveId, FileSaveAsId, FilePropsId, FileExitId,
          ViewStatusBarId,
          SelectionPointId, SelectionEdgeId, SelectionCellId, SelectionActorId,
          PrefViewerOCCId, PrefViewerVTKId, PrefGraphSupervisorId, PrefViewerPlot2dId,
@@ -103,13 +79,15 @@ protected:
          DefaultViewerOCCId, DefaultViewerVTKId, DefaultGraphSupervisorId, DefaultPlot2dId,
          //VRV: T2.5 - add default viewer
          PrefViewerTrihedronId, PrefConsoleFontId, PrefObjectBrowserEntryId, 
-         PrefObjectBrowserIAPPId, PrefObjectBrowserValueId, PrefObjectBrowserCHRONO_SORTId, 
-         PrefDirsId, PrefMultiFileSave, PrefSaveId,
+         PrefObjectBrowserIAPPId, PrefObjectBrowserValueId, PrefObjectBrowserCHRONO_SORTId,PrefObjectBrowserShowUseCaseId, 
+         PrefObjectBrowserNoAutoSizeColumnsId,  
+         PrefDirsId, PrefMultiFileSave, PrefASCIISave, PrefUndoLevelId, PrefExternalBrowserId, PrefSaveId,
          //NRI : SAL2214
          WindowNew3dId, ViewOCCId, ViewVTKId, ViewPlot2dId,
          //NRI : SAL2214
          WindowCascadeId, WindowTileId, 
-         HelpContentsId, HelpSearchId, HelpWhatsThisId, HelpAboutId };
+         HelpContentsId, HelpContentsModuleId,
+         HelpSearchId, HelpWhatsThisId, HelpAboutId };
   enum UpdateCommand { ActivateApp, DeactivateApp };
 
     /* Desktop can be created only by application */
@@ -137,16 +115,13 @@ public:
     void     definePopup(QString & theContext,
                         QString & theParent, 
                         QString & theObject );
-
-    void     createPopup(QPopupMenu* popupFather, QPopupMenu* popup,
-                        QString text, int popupID, bool separator = false);
     void     createPopup(QPopupMenu* popup, const QString & theContext,
                         const QString & theParent, const QString & theObject );
     void     customPopup(QPopupMenu* popup, const QString & theContext,
                         const QString & theParent, const QString & theObject);
 
     /* selection mode */
-    void SetSelectionMode(int mode, bool activeCompOnly = false);
+    void SetSelectionMode(Selection_Mode mode, bool activeCompOnly = false);
 
     /* desktop */
     void             showDesktop();
@@ -168,15 +143,18 @@ public:
     QWorkspaceP*      getMainFrame() const;
     QString          getNewStudyName();
     QAD_Study*        findStudy( SALOMEDS::Study_ptr theStudy );
-
+    static int        getUndoLevel();
     /* help actions */
     virtual void      helpAbout();    
-    virtual void      helpSearch();
+/*    virtual void      helpSearch();
     virtual void      helpContents();
     virtual void      helpContext(const QString& path, const QString& dir = QString::null);
-
+*/
     bool             loadComponent(QString);
+    bool              loadComponentData( const QString& );
+    QString           changeXmlInputSourceData(QString theData, QString theComponent);
     void             activateComponent(const QString& theName, bool isLoadData = true);
+    void              deactivateComponent();
     void              createStudy();
 
     void              setSettings();
@@ -185,8 +163,10 @@ public:
 
     QAD_Menus*           getActiveMenus()      {return myActiveMenus;}
     QAD_OperatorMenus*   getOperatorMenus()    {return myOperatorMenus;}
-    const OSD_SharedLibrary&  getHandle() const {return mySharedLibrary;}// never return sych objects "by value"
     const QString&       getActiveComponent() const;
+    SALOMEGUI*            getActiveGUI();
+    SALOMEGUI*            getComponentGUI( const QString& );  // accepts component`s user name
+    QString               getComponentDataType() const;
     SALOME_NamingService* getNameService()      {return myNameService;}
 
     Engines::Component_var getEngine(const char *containerName,
@@ -195,12 +175,14 @@ public:
     QString getComponentName(const char *componentUserName);
     QString getComponentUserName(const char *componentName);
     
-    QAD_HelpWindow*   getHelpWindow();
+    //NRI    QAD_HelpWindow*   getHelpWindow();
 
     void             onMouseMove(QMouseEvent*);
     bool             onMousePress(QMouseEvent*);
     void             onKeyPress(QKeyEvent*);
 
+    virtual QAD_Study* loadStudy(QString theStudyName);
+
 protected:
     bool             closeAllStudies( QAD_Application* );
     void             closeEvent( QCloseEvent* );
@@ -214,8 +196,6 @@ protected:
     virtual   void    updateCaption( UpdateCommand );
     virtual   void    updateMenu( UpdateCommand );
 
-    bool              loadComponentData( const QString& );
-
 protected slots:
     virtual void      onNewStudy();
     virtual void      onNewStudy(QAD_Application* app);
@@ -240,6 +220,11 @@ protected slots:
     virtual void      onWindowPopupAboutToShow();
     void             onWindowsPopupActivated( int id );
     void             onWindowsPopupStatusText( int id );
+    void              onHelpModulePopupStatusText(int id);
+    
+    void              onFilePopupStatusText( int id );
+    void              onEditPopupStatusText( int id );
+    void              onViewPopupStatusText( int id );
 
     void             onSelectionMode();
 
@@ -251,18 +236,23 @@ protected slots:
     void              onPlot2d();
     void              onConsoleFontAction();
   //VRV: T2.5 - add default viewer
-    void             onDefaultViewer( QAction * theAction);
+    void             onDefaultViewer( QActionP * theAction);
   //VRV: T2.5 - add default viewer
 
     void             onViewerTrihedron();
     void             onObjectBrowser();
     void              onMultiFileSave();
+    void              onASCIISave();
+    void              onUndoLevel();
+    void             onExternalBrowser();      
 
     void             onActivateApp(QAD_Application* app);
     void             onDeactivateApp(QAD_Application* app);
 
     void             onHelpContents();
-    void             onHelpSearch();
+    void             onHelpContentsModule();
+    /*    void       onHelpContentsTUI(); */
+/*    void           onHelpSearch(); */
     void             onHelpAbout();
 
     void             onNewWindow3d();
@@ -278,7 +268,7 @@ protected slots:
     void             onComboActiveComponent( const QString & , bool isLoadData);
     void              onCascade(); 
 
-    void              onHelpWindowClosed();
+/* NRI   void              onHelpWindowClosed(); */
 
 protected:
     QMenuBar*        myMainMenu;           /* the main menu bar */
@@ -300,11 +290,13 @@ protected:
   //NRI : SAL2214
     QPopupMenu       myNewViewPopup;
   //NRI : SAL2214
+    QPopupMenu       myHelpContentsModulePopup;
+
     QPopupMenu       myToolsPopup;
     QPopupMenu       myPrefPopup;
     QPopupMenu       mySelectionModePopup;
     QPopupMenu       myWindowPopup;        /* not customized by an application */
-
+    
     ActionMap         myStdActions;        /* default actions */
     QToolBar*        myStdToolBar;         /* standard toolbar */
     QStatusBar*              myStatusBar;          /* the only status bar */
@@ -326,18 +318,23 @@ protected:
     QList<QAD_Menus>   myMenusList;
     QAD_Menus*        myActiveMenus;
 
-    QAD_HelpWindow*    myHelpWindow;
+    //NRI QAD_HelpWindow*    myHelpWindow;
 
     QList<QToolButton> myComponentButton;
 
     QMap<QString,QString> mapComponentName;
 
+private:
+    void processEvent( SALOME_Event* );
+
+private:
+    typedef QMap<QString, SALOMEGUI*> ComponentMap;
+
 private:
     static QAD_ResourceMgr*                resourceMgr;
     static QPalette*                       palette;
     void                                   createActions();
     void                                   updateActions();
-    OSD_SharedLibrary                      mySharedLibrary;
     QAD_XmlHandler*                        myXmlHandler;
     QString                                myActiveComp;
     SALOME_NamingService*                  myNameService;
@@ -345,6 +342,10 @@ private:
     SALOME_LifeCycleCORBA *                myEnginesLifeCycle;
     QComboBox *                                    myCombo;
     bool                                    myQueryClose;
+    bool                                    myAboutToClose;
+    bool                                    _islibso;
+
+    ComponentMap                            myComponents;
 };
 
 /********************************************************************