G4UIQt.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 #ifndef G4UIQt_h
00030 #define G4UIQt_h 
00031 
00032 #if defined(G4UI_BUILD_QT_SESSION) || defined(G4UI_USE_QT)
00033 
00034 #include <map>
00035 
00036 #include "G4VBasicShell.hh"
00037 #include "G4VInteractiveSession.hh"
00038 
00039 #include <qobject.h>
00040 #include <qmap.h>
00041 #include <qstringlist.h>
00042 #include <qtabwidget.h>
00043 
00044 class QMainWindow;
00045 class QLineEdit;
00046 class G4UIsession;
00047 class QListWidget;
00048 class QTreeWidget;
00049 class QTreeWidgetItem;
00050 class QTextEdit;
00051 class QLabel;
00052 class QResizeEvent;
00053 class QTabWidget;
00054 class QStringList;
00055 class QSplitter;
00056 class QToolBar;
00057 
00058 // Class description :
00059 //
00060 //  G4UIQt : class to handle a Qt interactive session.
00061 // G4UIQt is the Qt version of G4UIterminal.
00062 //
00063 //  A command box is at disposal for entering/recalling Geant4 commands.
00064 //  A menubar could be customized through the AddMenu, AddButton, AddIcon methods.
00065 //  Note that there are corresponding Geant4 commands to add a 
00066 // menus in the menubar and add buttons in a menu.
00067 //  Ex : 
00068 //    /gui/addMenu   test Test
00069 //    /gui/addButton test Init /run/initialize
00070 //    /gui/addButton test "Set gun" "/control/execute gun.g4m"
00071 //    /gui/addButton test "Run one event" "/run/beamOn 1"
00072 //
00073 //  Command completion, by typing "tab" key, is available on the 
00074 // command line.
00075 //
00076 // Class description - end :
00077 
00078 class G4QTabWidget : public QTabWidget {
00079 public :
00080   G4QTabWidget();
00081   G4QTabWidget(QSplitter*&);
00082   void paintEvent  ( QPaintEvent * event );
00083   inline void setTabSelected(bool a) { tabSelected = a; };
00084   inline void setLastTabCreated(int a) { lastCreated = a; };
00085   inline bool isTabSelected() { return tabSelected; };
00086   bool tabSelected;
00087   int lastCreated;
00088 };
00089 
00090 class G4UIQt : public QObject, public G4VBasicShell, public G4VInteractiveSession {
00091   Q_OBJECT
00092 
00093 public: // With description
00094   G4UIQt(int,char**);
00095   // (argv, argc) or (0, NULL) had to be given.
00096   G4UIsession* SessionStart();
00097   // To enter interactive X loop ; waiting/executing command,...
00098   void AddMenu(const char*,const char*);
00099   // To add a pulldown menu in the menu bar. 
00100   // First argument is the name of the menu.
00101   // Second argument is the label of the cascade button.
00102   // Ex : AddMenu("my_menu","My menu")
00103   void AddButton(const char*,const char*,const char*);
00104   // To add a push button in a pulldown menu.
00105   // First argument is the name of the menu.
00106   // Second argument is the label of the button.
00107   // Third argument is the Geant4 command executed when the button is fired.
00108   // Ex : AddButton("my_menu","Run","/run/beamOn 1"); 
00109   void AddIcon(const char* userLabel, const char* iconFile, const char* command, const char* file_name="");
00110   // To add a icon in the toolbar
00111   // First argument is the label of the icon.
00112   // Second argument is the icon file.
00113   // Third argument is the Geant4 command executed when the button is fired.
00114   // Ex : AddButton("change background color","../background.xpm"," /vis/viewer/set/background"); 
00115 
00116   bool AddTabWidget(QWidget*,QString,int,int);
00117   // To add a tab for vis openGL Qt driver
00118   
00119   QTabWidget* GetSceneTreeComponentsTBWidget();
00120   // Get the viewComponent
00121 
00122   bool IsSplitterReleased();
00123 
00124   inline bool IsIconMoveSelected() {
00125     return fMoveSelected;
00126   };
00127   inline bool IsIconRotateSelected() {
00128     return fRotateSelected;
00129   };
00130   inline bool IsIconPickSelected() {
00131     return fPickSelected;
00132   };
00133   inline bool IsIconZoomInSelected() {
00134     return fZoomInSelected;
00135   };
00136   inline bool IsIconZoomOutSelected() {
00137     return fZoomOutSelected;
00138   };
00139 
00140   void SetIconMoveSelected();
00141   void SetIconRotateSelected();
00142   void SetIconPickSelected();
00143   void SetIconZoomInSelected();
00144   void SetIconZoomOutSelected();
00145   void SetIconHLHSRSelected();
00146   void SetIconHLRSelected();
00147   void SetIconSolidSelected();
00148   void SetIconWireframeSelected();
00149   void SetIconPerspectiveSelected();
00150   void SetIconOrthoSelected();
00151 
00152 public:
00153   ~G4UIQt();
00154   void Prompt(G4String);
00155   void SessionTerminate();
00156   virtual void PauseSessionStart(const G4String&);
00157   virtual G4int ReceiveG4cout(const G4String&);
00158   virtual G4int ReceiveG4cerr(const G4String&);
00159   //   G4String GetCommand(Widget);
00160 
00161 private:
00162   void SecondaryLoop(G4String); // a VIRER
00163   void CreateHelpWidget();
00164   void InitHelpTreeAndVisParametersWidget();
00165   void FillHelpTree();
00166   virtual void ExitHelp() const;
00167 
00168   void CreateHelpTree(QTreeWidgetItem*,G4UIcommandTree*);
00169   QTreeWidgetItem* FindTreeItem(QTreeWidgetItem *,const QString&);
00170 
00171   QString GetCommandList(const G4UIcommand*);
00172 
00173   virtual G4bool GetHelpChoice(G4int&);// have to be implemeted because we heritate from G4VBasicShell
00174   bool eventFilter(QObject*,QEvent*);
00175   void ActivateCommand(G4String);
00176   QMap<int,QString> LookForHelpStringInChildTree(G4UIcommandTree *,const QString&);
00177 
00178   void CreateVisParametersTBWidget();
00179   void CreateHelpTBWidget();
00180   void CreateCoutTBWidget();
00181   void CreateHistoryTBWidget();
00182   void OpenHelpTreeOnCommand(const QString &);
00183   QString GetShortCommandPath(QString);
00184   QString GetLongCommandPath(QTreeWidgetItem*);
00185   G4bool IsGUICommand(const G4UIcommand*);
00186   bool CreateVisCommandGroupAndToolBox(G4UIcommand*, QWidget*, int, bool isDialog);
00187   bool CreateCommandWidget(G4UIcommand* command, QWidget* parent, bool isDialog);
00188 
00189 private:
00190 
00191   QMainWindow * fMainWindow;
00192   QLabel *fCommandLabel;
00193   QLineEdit * fCommandArea;
00194   QTextEdit *fCoutTBTextArea;
00195   QTextEdit *fHelpArea;
00196   QTabWidget* fUITabWidget;
00197   QStringList fG4cout;
00198   QLineEdit * fCoutFilter;
00199 
00200   QListWidget *fHistoryTBTableList;
00201   QTreeWidget *fHelpTreeWidget;
00202   QWidget* fHelpTBWidget;
00203   QWidget* fHistoryTBWidget;
00204   QWidget* fCoutTBWidget;
00205   QTabWidget* fSceneTreeComponentsTBWidget;
00206   QLineEdit* fHelpLine;
00207   G4QTabWidget* fViewerTabWidget;
00208   QString fCoutText;
00209   QLabel *fEmptyViewerTabLabel;
00210   QSplitter * fMainSplitterWidget;
00211   QSplitter* fRightSplitterWidget;
00212   QSplitter * fHelpVSplitter;
00213   int fLastQTabSizeX;
00214   int fLastQTabSizeY;
00215 
00216   QToolBar *fToolbarApp;
00217   QToolBar *fToolbarUser;
00218 
00219   bool fMoveSelected;
00220   bool fRotateSelected;
00221   bool fPickSelected;
00222   bool fZoomInSelected;
00223   bool fZoomOutSelected;
00224 
00225 private Q_SLOTS :
00226   void ExitSession();
00227   void ClearButtonCallback();
00228   void CommandEnteredCallback();
00229   void ButtonCallback(const QString&);
00230   void HelpTreeClicCallback();
00231   void HelpTreeDoubleClicCallback();
00232   void ShowHelpCallback();
00233   void CommandHistoryCallback();
00234   void LookForHelpStringCallback();
00235   void UpdateTabWidget(int);
00236   void ResizeTabWidget( QResizeEvent* );
00237   void CoutFilterCallback(const QString&);
00238   void TabCloseCallback(int);
00239   void ToolBoxActivated(int);
00240   void VisParameterCallback(QWidget*);
00241   void ChangeColorCallback(QWidget*);
00242   void ChangeCursorStyle(const QString&);
00243   void ChangeSurfaceStyle(const QString&);
00244   void OpenIconCallback(const QString&);
00245   void SaveIconCallback(const QString&);
00246   void ChangePerspectiveOrtho(const QString&);
00247 };
00248 
00249 #endif
00250 
00251 #endif
00252 

Generated on Mon May 27 17:50:06 2013 for Geant4 by  doxygen 1.4.7