[571] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
---|
| 2 | <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> |
---|
| 3 | <title>G4UIQt.cc Source File</title> |
---|
| 4 | <link href="doxygen.css" rel="stylesheet" type="text/css"> |
---|
| 5 | </head><body> |
---|
| 6 | <!-- Generated by Doxygen 1.3.4 --> |
---|
| 7 | <div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a></div> |
---|
| 8 | <h1>G4UIQt.cc</h1><a href="G4UIQt_8cc.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">//</span> |
---|
| 9 | 00002 <span class="comment">// ********************************************************************</span> |
---|
| 10 | 00003 <span class="comment">// * License and Disclaimer *</span> |
---|
| 11 | 00004 <span class="comment">// * *</span> |
---|
| 12 | 00005 <span class="comment">// * The Geant4 software is copyright of the Copyright Holders of *</span> |
---|
| 13 | 00006 <span class="comment">// * the Geant4 Collaboration. It is provided under the terms and *</span> |
---|
| 14 | 00007 <span class="comment">// * conditions of the Geant4 Software License, included in the file *</span> |
---|
| 15 | 00008 <span class="comment">// * LICENSE and available at http://cern.ch/geant4/license . These *</span> |
---|
| 16 | 00009 <span class="comment">// * include a list of copyright holders. *</span> |
---|
| 17 | 00010 <span class="comment">// * *</span> |
---|
| 18 | 00011 <span class="comment">// * Neither the authors of this software system, nor their employing *</span> |
---|
| 19 | 00012 <span class="comment">// * institutes,nor the agencies providing financial support for this *</span> |
---|
| 20 | 00013 <span class="comment">// * work make any representation or warranty, express or implied, *</span> |
---|
| 21 | 00014 <span class="comment">// * regarding this software system or assume any liability for its *</span> |
---|
| 22 | 00015 <span class="comment">// * use. Please see the license in the file LICENSE and URL above *</span> |
---|
| 23 | 00016 <span class="comment">// * for the full disclaimer and the limitation of liability. *</span> |
---|
| 24 | 00017 <span class="comment">// * *</span> |
---|
| 25 | 00018 <span class="comment">// * This code implementation is the result of the scientific and *</span> |
---|
| 26 | 00019 <span class="comment">// * technical work of the GEANT4 collaboration. *</span> |
---|
| 27 | 00020 <span class="comment">// * By using, copying, modifying or distributing the software (or *</span> |
---|
| 28 | 00021 <span class="comment">// * any work based on the software) you agree to acknowledge its *</span> |
---|
| 29 | 00022 <span class="comment">// * use in resulting scientific publications, and indicate your *</span> |
---|
| 30 | 00023 <span class="comment">// * acceptance of all terms of the Geant4 Software license. *</span> |
---|
| 31 | 00024 <span class="comment">// ********************************************************************</span> |
---|
| 32 | 00025 <span class="comment">//</span> |
---|
| 33 | 00026 <span class="comment">//</span> |
---|
| 34 | 00027 <span class="comment">// $Id: G4UIQt.cc,v 1.14 2007/05/29 11:09:49 $</span> |
---|
| 35 | 00028 <span class="comment">// GEANT4 tag $Name: geant4-08-01 $</span> |
---|
| 36 | 00029 <span class="comment">//</span> |
---|
| 37 | 00030 <span class="comment">// L. Garnier</span> |
---|
| 38 | 00031 |
---|
| 39 | 00032 <span class="comment">//#define DEBUG</span> |
---|
| 40 | 00033 |
---|
| 41 | 00034 <span class="preprocessor">#ifdef G4UI_BUILD_QT_SESSION</span> |
---|
| 42 | 00035 <span class="preprocessor"></span> |
---|
| 43 | 00036 <span class="preprocessor">#include "G4Types.hh"</span> |
---|
| 44 | 00037 |
---|
| 45 | 00038 <span class="preprocessor">#include <string.h></span> |
---|
| 46 | 00039 |
---|
| 47 | 00040 <span class="preprocessor">#include "<a class="code" href="G4UIQt_8hh.html">G4UIQt.hh</a>"</span> |
---|
| 48 | 00041 <span class="preprocessor">#include "G4UImanager.hh"</span> |
---|
| 49 | 00042 <span class="preprocessor">#include "G4StateManager.hh"</span> |
---|
| 50 | 00043 <span class="preprocessor">#include "G4UIcommandTree.hh"</span> |
---|
| 51 | 00044 <span class="preprocessor">#include "G4UIcommandStatus.hh"</span> |
---|
| 52 | 00045 |
---|
| 53 | 00046 <span class="preprocessor">#include "<a class="code" href="G4Qt_8hh.html">G4Qt.hh</a>"</span> |
---|
| 54 | 00047 |
---|
| 55 | 00048 <span class="preprocessor">#include <QtGui/qapplication.h></span> |
---|
| 56 | 00049 <span class="preprocessor">#include <QtGui/qwidget.h></span> |
---|
| 57 | 00050 <span class="preprocessor">#include <QtGui/qmenu.h></span> |
---|
| 58 | 00051 <span class="preprocessor">#include <QtGui/qmenubar.h></span> |
---|
| 59 | 00052 <span class="preprocessor">#include <QtGui/qboxlayout.h></span> |
---|
| 60 | 00053 <span class="preprocessor">#include <QtGui/qpushbutton.h></span> |
---|
| 61 | 00054 <span class="preprocessor">#include <QtGui/qlabel.h></span> |
---|
| 62 | 00055 <span class="preprocessor">#include <QtGui/qsplitter.h></span> |
---|
| 63 | 00056 <span class="preprocessor">#include <QtGui/qscrollbar.h></span> |
---|
| 64 | 00057 <span class="preprocessor">#include <QtGui/qdialog.h></span> |
---|
| 65 | 00058 <span class="preprocessor">#include <QtGui/qevent.h></span> |
---|
| 66 | 00059 |
---|
| 67 | 00060 <span class="preprocessor">#include <stdlib.h></span> |
---|
| 68 | 00061 |
---|
| 69 | 00062 <span class="comment">// Pourquoi Static et non variables de classe ?</span> |
---|
| 70 | <a name="l00063"></a><a class="code" href="G4UIQt_8cc.html#a0">00063</a> <span class="keyword">static</span> G4bool <a class="code" href="G4UIQt_8cc.html#a0">exitSession</a> = <span class="keyword">true</span>; |
---|
| 71 | <a name="l00064"></a><a class="code" href="G4UIQt_8cc.html#a1">00064</a> <span class="keyword">static</span> G4bool <a class="code" href="G4UIQt_8cc.html#a1">exitPause</a> = <span class="keyword">true</span>; |
---|
| 72 | 00065 |
---|
| 73 | <a name="l00087"></a><a class="code" href="classG4UIQt.html#a0">00087</a> <a class="code" href="classG4UIQt.html#a0">G4UIQt::G4UIQt</a> ( |
---|
| 74 | 00088 <span class="keywordtype">int</span> argc, |
---|
| 75 | 00089 <span class="keywordtype">char</span>** argv |
---|
| 76 | 00090 ) |
---|
| 77 | 00091 :fHelpDialog(NULL) |
---|
| 78 | 00092 { |
---|
| 79 | 00093 <a class="code" href="classG4Qt.html">G4Qt</a>* interactorManager = <a class="code" href="classG4Qt.html#e0">G4Qt::getInstance</a> (); |
---|
| 80 | 00094 G4UImanager* UI = G4UImanager::GetUIpointer(); |
---|
| 81 | 00095 <span class="keywordflow">if</span>(UI!=NULL) UI->SetSession(<span class="keyword">this</span>); |
---|
| 82 | 00096 |
---|
| 83 | 00097 <a class="code" href="classG4UIQt.html#r0">fMainWindow</a> = <span class="keyword">new</span> QMainWindow(); |
---|
| 84 | 00098 <a class="code" href="classG4UIQt.html#r0">fMainWindow</a>->setWindowTitle( <span class="stringliteral">"G4UI Session"</span> ); |
---|
| 85 | 00099 <a class="code" href="classG4UIQt.html#r0">fMainWindow</a>->resize(800,600); |
---|
| 86 | 00100 <a class="code" href="classG4UIQt.html#r0">fMainWindow</a>->move(QPoint(200,100)); |
---|
| 87 | 00101 |
---|
| 88 | 00102 QSplitter *splitter = <span class="keyword">new</span> QSplitter(Qt::Vertical); |
---|
| 89 | 00103 <a class="code" href="classG4UIQt.html#r3">fTextArea</a> = <span class="keyword">new</span> QTextEdit(); |
---|
| 90 | 00104 QPushButton *clearButton = <span class="keyword">new</span> QPushButton(<span class="stringliteral">"clear"</span>); |
---|
| 91 | 00105 connect(clearButton, SIGNAL(clicked()), SLOT(<a class="code" href="classG4UIQt.html#k0">clearButtonCallback</a>())); |
---|
| 92 | 00106 |
---|
| 93 | 00107 <a class="code" href="classG4UIQt.html#r5">fCommandHistoryArea</a> = <span class="keyword">new</span> QListWidget(); |
---|
| 94 | 00108 <a class="code" href="classG4UIQt.html#r5">fCommandHistoryArea</a>->setSelectionMode(QAbstractItemView::SingleSelection); |
---|
| 95 | 00109 connect(<a class="code" href="classG4UIQt.html#r5">fCommandHistoryArea</a>, SIGNAL(itemSelectionChanged()), SLOT(<a class="code" href="classG4UIQt.html#k5">commandHistoryCallback</a>())); |
---|
| 96 | 00110 <a class="code" href="classG4UIQt.html#r5">fCommandHistoryArea</a>->installEventFilter(<span class="keyword">this</span>); |
---|
| 97 | 00111 <a class="code" href="classG4UIQt.html#r1">fCommandLabel</a> = <span class="keyword">new</span> QLabel(); |
---|
| 98 | 00112 |
---|
| 99 | 00113 <a class="code" href="classG4UIQt.html#r2">fCommandArea</a> = <span class="keyword">new</span> QLineEdit(); |
---|
| 100 | 00114 <a class="code" href="classG4UIQt.html#r2">fCommandArea</a>->installEventFilter(<span class="keyword">this</span>); |
---|
| 101 | 00115 <a class="code" href="classG4UIQt.html#r2">fCommandArea</a>->activateWindow(); |
---|
| 102 | 00116 connect(<a class="code" href="classG4UIQt.html#r2">fCommandArea</a>, SIGNAL(returnPressed()), SLOT(<a class="code" href="classG4UIQt.html#k1">commandEnteredCallback</a>())); |
---|
| 103 | 00117 <span class="comment">// fCommandArea->setFocusPolicy ( Qt::StrongFocus );</span> |
---|
| 104 | 00118 <span class="comment">// fCommandArea->setFocus(Qt::TabFocusReason);</span> |
---|
| 105 | 00119 <a class="code" href="classG4UIQt.html#r3">fTextArea</a>->setReadOnly(<span class="keyword">true</span>); |
---|
| 106 | 00120 |
---|
| 107 | 00121 |
---|
| 108 | 00122 <span class="comment">// Set layouts</span> |
---|
| 109 | 00123 |
---|
| 110 | 00124 QWidget* topWidget = <span class="keyword">new</span> QWidget(); |
---|
| 111 | 00125 QVBoxLayout *layoutTop = <span class="keyword">new</span> QVBoxLayout; |
---|
| 112 | 00126 |
---|
| 113 | 00127 QWidget* bottomWidget = <span class="keyword">new</span> QWidget(); |
---|
| 114 | 00128 QVBoxLayout *layoutBottom = <span class="keyword">new</span> QVBoxLayout; |
---|
| 115 | 00129 |
---|
| 116 | 00130 |
---|
| 117 | 00131 layoutTop->addWidget(<a class="code" href="classG4UIQt.html#r3">fTextArea</a>); |
---|
| 118 | 00132 layoutTop->addWidget(clearButton); |
---|
| 119 | 00133 topWidget->setLayout(layoutTop); |
---|
| 120 | 00134 |
---|
| 121 | 00135 layoutBottom->addWidget(<a class="code" href="classG4UIQt.html#r5">fCommandHistoryArea</a>); |
---|
| 122 | 00136 layoutBottom->addWidget(<a class="code" href="classG4UIQt.html#r1">fCommandLabel</a>); |
---|
| 123 | 00137 layoutBottom->addWidget(<a class="code" href="classG4UIQt.html#r2">fCommandArea</a>); |
---|
| 124 | 00138 bottomWidget->setLayout(layoutBottom); |
---|
| 125 | 00139 |
---|
| 126 | 00140 |
---|
| 127 | 00141 splitter->addWidget(topWidget); |
---|
| 128 | 00142 splitter->addWidget(bottomWidget); |
---|
| 129 | 00143 <a class="code" href="classG4UIQt.html#r0">fMainWindow</a>->setCentralWidget(splitter); |
---|
| 130 | 00144 |
---|
| 131 | 00145 <span class="comment">// Add a quit subMenu</span> |
---|
| 132 | 00146 QMenu *fileMenu = <a class="code" href="classG4UIQt.html#r0">fMainWindow</a>->menuBar()->addMenu(<span class="stringliteral">"File"</span>); |
---|
| 133 | 00147 fileMenu->addAction(<span class="stringliteral">"Quitter"</span>, <a class="code" href="classG4UIQt.html#r0">fMainWindow</a>, SLOT(close())); |
---|
| 134 | 00148 |
---|
| 135 | 00149 <span class="comment">// Add a Help menu</span> |
---|
| 136 | 00150 QMenu *helpMenu = <a class="code" href="classG4UIQt.html#r0">fMainWindow</a>->menuBar()->addMenu(<span class="stringliteral">"Help"</span>); |
---|
| 137 | 00151 helpMenu->addAction(<span class="stringliteral">"Show Help"</span>, <span class="keyword">this</span>, SLOT(<a class="code" href="classG4UIQt.html#k4">showHelpCallback</a>())); |
---|
| 138 | 00152 |
---|
| 139 | 00153 <span class="comment">// Set the splitter size. The fTextArea sould be 2/3 on the fMainWindow</span> |
---|
| 140 | 00154 QList<int> vals = splitter->sizes(); |
---|
| 141 | 00155 <span class="keywordflow">if</span>(vals.size()==2) { |
---|
| 142 | 00156 vals[0] = (splitter->orientation()==Qt::Vertical ? splitter->height() : splitter->width())*3/4; |
---|
| 143 | 00157 vals[1] = (splitter->orientation()==Qt::Vertical ? splitter->height() : splitter->width())*1/4; |
---|
| 144 | 00158 splitter->setSizes(vals); |
---|
| 145 | 00159 } |
---|
| 146 | 00160 |
---|
| 147 | 00161 |
---|
| 148 | 00162 <span class="keywordflow">if</span>(UI!=NULL) UI->SetCoutDestination(<span class="keyword">this</span>); <span class="comment">// TO KEEP</span> |
---|
| 149 | 00163 } |
---|
| 150 | 00164 |
---|
| 151 | 00165 |
---|
| 152 | 00166 |
---|
| 153 | <a name="l00167"></a><a class="code" href="classG4UIQt.html#a4">00167</a> <a class="code" href="classG4UIQt.html#a4">G4UIQt::~G4UIQt</a>( |
---|
| 154 | 00168 ) |
---|
| 155 | 00169 { |
---|
| 156 | 00170 G4UImanager* UI = G4UImanager::GetUIpointer(); <span class="comment">// TO KEEP</span> |
---|
| 157 | 00171 <span class="keywordflow">if</span>(UI!=NULL) { <span class="comment">// TO KEEP</span> |
---|
| 158 | 00172 UI->SetSession(NULL); <span class="comment">// TO KEEP</span> |
---|
| 159 | 00173 UI->SetCoutDestination(NULL); <span class="comment">// TO KEEP</span> |
---|
| 160 | 00174 } |
---|
| 161 | 00175 |
---|
| 162 | 00176 |
---|
| 163 | 00177 <span class="keywordflow">if</span> (<a class="code" href="classG4UIQt.html#r0">fMainWindow</a>!=NULL) |
---|
| 164 | 00178 <span class="keyword">delete</span> <a class="code" href="classG4UIQt.html#r0">fMainWindow</a>; |
---|
| 165 | 00179 } |
---|
| 166 | 00180 |
---|
| 167 | 00181 |
---|
| 168 | 00182 |
---|
| 169 | 00183 |
---|
| 170 | <a name="l00187"></a><a class="code" href="classG4UIQt.html#a1">00187</a> G4UIsession* <a class="code" href="classG4UIQt.html#a1">G4UIQt::SessionStart</a> ( |
---|
| 171 | 00188 ) |
---|
| 172 | 00189 { |
---|
| 173 | 00190 |
---|
| 174 | 00191 <a class="code" href="classG4Qt.html">G4Qt</a>* interactorManager = <a class="code" href="classG4Qt.html#e0">G4Qt::getInstance</a> (); |
---|
| 175 | 00192 <a class="code" href="classG4UIQt.html#r0">fMainWindow</a>->show(); |
---|
| 176 | 00193 <a class="code" href="classG4UIQt.html#a5">Prompt</a>(<span class="stringliteral">"session"</span>); |
---|
| 177 | 00194 <a class="code" href="G4UIQt_8cc.html#a0">exitSession</a> = <span class="keyword">false</span>; |
---|
| 178 | 00195 |
---|
| 179 | 00196 |
---|
| 180 | 00197 printf(<span class="stringliteral">"disable secondary loop\n"</span>); |
---|
| 181 | 00198 interactorManager-><a class="code" href="classG4VInteractorManager.html#a13">DisableSecondaryLoop</a> (); <span class="comment">// TO KEEP</span> |
---|
| 182 | 00199 ((QApplication*)interactorManager-><a class="code" href="classG4VInteractorManager.html#a5">GetMainInteractor</a>())->exec(); |
---|
| 183 | 00200 <span class="comment">// on ne passe pas le dessous ? FIXME ????</span> |
---|
| 184 | 00201 <span class="comment">// je ne pense pas 13/06</span> |
---|
| 185 | 00202 |
---|
| 186 | 00203 <span class="comment">// void* event; // TO KEEP</span> |
---|
| 187 | 00204 <span class="comment">// while((event = interactorManager->GetEvent())!=NULL) { // TO KEEP</span> |
---|
| 188 | 00205 <span class="comment">// interactorManager->DispatchEvent(event); // TO KEEP</span> |
---|
| 189 | 00206 <span class="comment">// if(exitSession==true) break; // TO KEEP</span> |
---|
| 190 | 00207 <span class="comment">// } // TO KEEP</span> |
---|
| 191 | 00208 |
---|
| 192 | 00209 interactorManager-><a class="code" href="classG4VInteractorManager.html#a12">EnableSecondaryLoop</a> (); |
---|
| 193 | 00210 printf(<span class="stringliteral">"enable secondary loop\n"</span>); |
---|
| 194 | 00211 <span class="keywordflow">return</span> <span class="keyword">this</span>; |
---|
| 195 | 00212 } |
---|
| 196 | 00213 |
---|
| 197 | 00214 |
---|
| 198 | <a name="l00221"></a><a class="code" href="classG4UIQt.html#a5">00221</a> <span class="keywordtype">void</span> <a class="code" href="classG4UIQt.html#a5">G4UIQt::Prompt</a> ( |
---|
| 199 | 00222 G4String aPrompt |
---|
| 200 | 00223 ) |
---|
| 201 | 00224 { |
---|
| 202 | 00225 <a class="code" href="classG4UIQt.html#r1">fCommandLabel</a>->setText((<span class="keywordtype">char</span>*)aPrompt.data()); |
---|
| 203 | 00226 } |
---|
| 204 | 00227 |
---|
| 205 | 00228 |
---|
| 206 | <a name="l00229"></a><a class="code" href="classG4UIQt.html#a6">00229</a> <span class="keywordtype">void</span> <a class="code" href="classG4UIQt.html#a6">G4UIQt::SessionTerminate</a> ( |
---|
| 207 | 00230 ) |
---|
| 208 | 00231 { |
---|
| 209 | 00232 <a class="code" href="classG4Qt.html">G4Qt</a>* interactorManager = <a class="code" href="classG4Qt.html#e0">G4Qt::getInstance</a> (); |
---|
| 210 | 00233 <a class="code" href="classG4UIQt.html#r0">fMainWindow</a>->close(); |
---|
| 211 | 00234 ((QApplication*)interactorManager-><a class="code" href="classG4VInteractorManager.html#a5">GetMainInteractor</a>())->exit(); |
---|
| 212 | 00235 } |
---|
| 213 | 00236 |
---|
| 214 | 00237 |
---|
| 215 | 00238 |
---|
| 216 | <a name="l00247"></a><a class="code" href="classG4UIQt.html#a7">00247</a> <span class="keywordtype">void</span> <a class="code" href="classG4UIQt.html#a7">G4UIQt::PauseSessionStart</a> ( |
---|
| 217 | 00248 G4String aState |
---|
| 218 | 00249 ) |
---|
| 219 | 00250 { |
---|
| 220 | 00251 printf(<span class="stringliteral">"G4UIQt::PauseSessionStart\n"</span>); |
---|
| 221 | 00252 <span class="keywordflow">if</span>(aState==<span class="stringliteral">"G4_pause> "</span>) { <span class="comment">// TO KEEP</span> |
---|
| 222 | 00253 <a class="code" href="classG4UIQt.html#d0">SecondaryLoop</a> (<span class="stringliteral">"Pause, type continue to exit this state"</span>); <span class="comment">// TO KEEP</span> |
---|
| 223 | 00254 } <span class="comment">// TO KEEP</span> |
---|
| 224 | 00255 |
---|
| 225 | 00256 <span class="keywordflow">if</span>(aState==<span class="stringliteral">"EndOfEvent"</span>) { <span class="comment">// TO KEEP</span> |
---|
| 226 | 00257 <span class="comment">// Picking with feed back in event data Done here !!!</span> |
---|
| 227 | 00258 <a class="code" href="classG4UIQt.html#d0">SecondaryLoop</a> (<span class="stringliteral">"End of event, type continue to exit this state"</span>); <span class="comment">// TO KEEP</span> |
---|
| 228 | 00259 } <span class="comment">// TO KEEP</span> |
---|
| 229 | 00260 } |
---|
| 230 | 00261 |
---|
| 231 | 00262 |
---|
| 232 | 00263 |
---|
| 233 | <a name="l00268"></a><a class="code" href="classG4UIQt.html#d0">00268</a> <span class="keywordtype">void</span> <a class="code" href="classG4UIQt.html#d0">G4UIQt::SecondaryLoop</a> ( |
---|
| 234 | 00269 G4String aPrompt |
---|
| 235 | 00270 ) |
---|
| 236 | 00271 { |
---|
| 237 | 00272 printf(<span class="stringliteral">"G4UIQt::SecondaryLoop\n"</span>); |
---|
| 238 | 00273 <a class="code" href="classG4Qt.html">G4Qt</a>* interactorManager = <a class="code" href="classG4Qt.html#e0">G4Qt::getInstance</a> (); <span class="comment">// TO KEEP ?</span> |
---|
| 239 | 00274 <a class="code" href="classG4UIQt.html#a5">Prompt</a>(aPrompt); <span class="comment">// TO KEEP</span> |
---|
| 240 | 00275 <a class="code" href="G4UIQt_8cc.html#a1">exitPause</a> = <span class="keyword">false</span>; <span class="comment">// TO KEEP</span> |
---|
| 241 | 00276 <span class="keywordtype">void</span>* event; <span class="comment">// TO KEEP</span> |
---|
| 242 | 00277 <span class="keywordflow">while</span>((event = interactorManager-><a class="code" href="classG4Qt.html#a1">GetEvent</a>())!=NULL) { <span class="comment">// TO KEEP</span> |
---|
| 243 | 00278 interactorManager-><a class="code" href="classG4VInteractorManager.html#a17">DispatchEvent</a>(event); <span class="comment">// TO KEEP</span> |
---|
| 244 | 00279 <span class="keywordflow">if</span>(<a class="code" href="G4UIQt_8cc.html#a1">exitPause</a>==<span class="keyword">true</span>) <span class="keywordflow">break</span>; <span class="comment">// TO KEEP</span> |
---|
| 245 | 00280 } <span class="comment">// TO KEEP</span> |
---|
| 246 | 00281 <a class="code" href="classG4UIQt.html#a5">Prompt</a>(<span class="stringliteral">"session"</span>); <span class="comment">// TO KEEP</span> |
---|
| 247 | 00282 } |
---|
| 248 | 00283 |
---|
| 249 | 00284 |
---|
| 250 | 00285 |
---|
| 251 | <a name="l00290"></a><a class="code" href="classG4UIQt.html#a8">00290</a> G4int <a class="code" href="classG4UIQt.html#a8">G4UIQt::ReceiveG4cout</a> ( |
---|
| 252 | 00291 G4String aString |
---|
| 253 | 00292 ) |
---|
| 254 | 00293 { |
---|
| 255 | 00294 <a class="code" href="classG4UIQt.html#r3">fTextArea</a>->append(QString((<span class="keywordtype">char</span>*)aString.data()).trimmed()); |
---|
| 256 | 00295 <a class="code" href="classG4UIQt.html#r3">fTextArea</a>->verticalScrollBar()->setSliderPosition(<a class="code" href="classG4UIQt.html#r3">fTextArea</a>->verticalScrollBar()->maximum()); |
---|
| 257 | 00296 <span class="keywordflow">return</span> 0; |
---|
| 258 | 00297 } |
---|
| 259 | 00298 |
---|
| 260 | 00299 |
---|
| 261 | <a name="l00304"></a><a class="code" href="classG4UIQt.html#a9">00304</a> G4int <a class="code" href="classG4UIQt.html#a9">G4UIQt::ReceiveG4cerr</a> ( |
---|
| 262 | 00305 G4String aString |
---|
| 263 | 00306 ) |
---|
| 264 | 00307 { |
---|
| 265 | 00308 QColor previousColor = <a class="code" href="classG4UIQt.html#r3">fTextArea</a>->textColor(); |
---|
| 266 | 00309 <a class="code" href="classG4UIQt.html#r3">fTextArea</a>->setTextColor(Qt::red); |
---|
| 267 | 00310 <a class="code" href="classG4UIQt.html#r3">fTextArea</a>->append(QString((<span class="keywordtype">char</span>*)aString.data()).trimmed()); |
---|
| 268 | 00311 <a class="code" href="classG4UIQt.html#r3">fTextArea</a>->setTextColor(previousColor); |
---|
| 269 | 00312 <a class="code" href="classG4UIQt.html#r3">fTextArea</a>->verticalScrollBar()->setSliderPosition(<a class="code" href="classG4UIQt.html#r3">fTextArea</a>->verticalScrollBar()->maximum()); |
---|
| 270 | 00313 <span class="keywordflow">return</span> 0; |
---|
| 271 | 00314 } |
---|
| 272 | 00315 |
---|
| 273 | 00316 |
---|
| 274 | 00317 |
---|
| 275 | <a name="l00323"></a><a class="code" href="classG4UIQt.html#a2">00323</a> <span class="keywordtype">void</span> <a class="code" href="classG4UIQt.html#a2">G4UIQt::AddMenu</a> ( |
---|
| 276 | 00324 <span class="keyword">const</span> <span class="keywordtype">char</span>* aName |
---|
| 277 | 00325 ,<span class="keyword">const</span> <span class="keywordtype">char</span>* aLabel |
---|
| 278 | 00326 ) |
---|
| 279 | 00327 { |
---|
| 280 | 00328 QMenu *fileMenu = <span class="keyword">new</span> QMenu(aLabel); |
---|
| 281 | 00329 <a class="code" href="classG4UIQt.html#r0">fMainWindow</a>->menuBar()->insertMenu(<a class="code" href="classG4UIQt.html#r0">fMainWindow</a>->menuBar()->actions().last(),fileMenu); |
---|
| 282 | 00330 <a class="code" href="classG4VInteractiveSession.html#a4">AddInteractor</a> (aName,(<a class="code" href="G4VInteractorManager_8hh.html#a0">G4Interactor</a>)fileMenu); |
---|
| 283 | 00331 } |
---|
| 284 | 00332 |
---|
| 285 | 00333 |
---|
| 286 | <a name="l00340"></a><a class="code" href="classG4UIQt.html#a3">00340</a> <span class="keywordtype">void</span> <a class="code" href="classG4UIQt.html#a3">G4UIQt::AddButton</a> ( |
---|
| 287 | 00341 <span class="keyword">const</span> <span class="keywordtype">char</span>* aMenu |
---|
| 288 | 00342 ,<span class="keyword">const</span> <span class="keywordtype">char</span>* aLabel |
---|
| 289 | 00343 ,<span class="keyword">const</span> <span class="keywordtype">char</span>* aCommand |
---|
| 290 | 00344 ) |
---|
| 291 | 00345 { |
---|
| 292 | 00346 <span class="keywordflow">if</span>(aMenu==NULL) <span class="keywordflow">return</span>; <span class="comment">// TO KEEP</span> |
---|
| 293 | 00347 <span class="keywordflow">if</span>(aLabel==NULL) <span class="keywordflow">return</span>; <span class="comment">// TO KEEP</span> |
---|
| 294 | 00348 <span class="keywordflow">if</span>(aCommand==NULL) <span class="keywordflow">return</span>; <span class="comment">// TO KEEP</span> |
---|
| 295 | 00349 QMenu *parent = (QMenu*)<a class="code" href="classG4VInteractiveSession.html#a5">GetInteractor</a>(aMenu); |
---|
| 296 | 00350 <span class="keywordflow">if</span>(parent==NULL) <span class="keywordflow">return</span>; |
---|
| 297 | 00351 |
---|
| 298 | 00352 <a class="code" href="classG4UIQt.html#r6">signalMapper</a> = <span class="keyword">new</span> QSignalMapper(<span class="keyword">this</span>); |
---|
| 299 | 00353 QAction *action = parent->addAction(aLabel, <a class="code" href="classG4UIQt.html#r6">signalMapper</a>, SLOT(map())); |
---|
| 300 | 00354 <a class="code" href="classG4UIQt.html#r6">signalMapper</a>->setMapping(action, QString(aCommand)); |
---|
| 301 | 00355 connect(<a class="code" href="classG4UIQt.html#r6">signalMapper</a>, SIGNAL(mapped(<span class="keyword">const</span> QString &)),<span class="keyword">this</span>, SLOT(<a class="code" href="classG4UIQt.html#k2">buttonCallback</a>(<span class="keyword">const</span> QString&))); |
---|
| 302 | 00356 } |
---|
| 303 | 00357 |
---|
| 304 | 00358 |
---|
| 305 | 00359 |
---|
| 306 | 00360 |
---|
| 307 | <a name="l00368"></a><a class="code" href="classG4UIQt.html#d1">00368</a> <span class="keywordtype">void</span> <a class="code" href="classG4UIQt.html#d1">G4UIQt::TerminalHelp</a>( |
---|
| 308 | 00369 G4String newCommand |
---|
| 309 | 00370 ) |
---|
| 310 | 00371 { |
---|
| 311 | 00372 <span class="keywordflow">if</span> (!<a class="code" href="classG4UIQt.html#r8">fHelpDialog</a>) { |
---|
| 312 | 00373 <a class="code" href="classG4UIQt.html#r8">fHelpDialog</a> = <span class="keyword">new</span> QDialog; |
---|
| 313 | 00374 |
---|
| 314 | 00375 QSplitter *splitter = <span class="keyword">new</span> QSplitter(Qt::Horizontal); |
---|
| 315 | 00376 <a class="code" href="classG4UIQt.html#r4">fHelpArea</a> = <span class="keyword">new</span> QTextEdit(); |
---|
| 316 | 00377 QPushButton *exitButton = <span class="keyword">new</span> QPushButton(<span class="stringliteral">"Exit"</span>); |
---|
| 317 | 00378 connect(exitButton, SIGNAL(clicked()), <a class="code" href="classG4UIQt.html#r8">fHelpDialog</a>,SLOT(close())); |
---|
| 318 | 00379 <a class="code" href="classG4UIQt.html#r4">fHelpArea</a>->setReadOnly(<span class="keyword">true</span>); |
---|
| 319 | 00380 |
---|
| 320 | 00381 <span class="comment">// the help tree</span> |
---|
| 321 | 00382 G4UImanager* UI = G4UImanager::GetUIpointer(); |
---|
| 322 | 00383 <span class="keywordflow">if</span>(UI==NULL) <span class="keywordflow">return</span>; |
---|
| 323 | 00384 G4UIcommandTree * treeTop = UI->GetTree(); |
---|
| 324 | 00385 |
---|
| 325 | 00386 <span class="comment">// build widget</span> |
---|
| 326 | 00387 <a class="code" href="classG4UIQt.html#r7">fHelpTreeWidget</a> = <span class="keyword">new</span> QTreeWidget(); |
---|
| 327 | 00388 <a class="code" href="classG4UIQt.html#r7">fHelpTreeWidget</a>->setSelectionMode(QAbstractItemView::SingleSelection); |
---|
| 328 | 00389 <a class="code" href="classG4UIQt.html#r7">fHelpTreeWidget</a>->setColumnCount(2); |
---|
| 329 | 00390 <a class="code" href="classG4UIQt.html#r7">fHelpTreeWidget</a>->setColumnHidden(1,<span class="keyword">true</span>); |
---|
| 330 | 00391 QStringList labels; |
---|
| 331 | 00392 labels << QString(<span class="stringliteral">"Command"</span>) << QString(<span class="stringliteral">"Description"</span>); |
---|
| 332 | 00393 <a class="code" href="classG4UIQt.html#r7">fHelpTreeWidget</a>->setHeaderLabels(labels); |
---|
| 333 | 00394 |
---|
| 334 | 00395 QList<QTreeWidgetItem *> items; |
---|
| 335 | 00396 G4int treeSize = treeTop->GetTreeEntry(); |
---|
| 336 | 00397 QTreeWidgetItem * newItem; |
---|
| 337 | 00398 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> a=0;a<treeSize;a++) { |
---|
| 338 | 00399 <span class="comment">// Creating new item</span> |
---|
| 339 | 00400 QStringList stringList; |
---|
| 340 | 00401 stringList << QString((<span class="keywordtype">char</span>*)(treeTop->GetTree(a+1)->GetPathName()).data()).trimmed() ; |
---|
| 341 | 00402 stringList << QString((<span class="keywordtype">char</span>*)(treeTop->GetTree(a+1)->GetTitle()).data()).trimmed() ; |
---|
| 342 | 00403 |
---|
| 343 | 00404 newItem = <span class="keyword">new</span> QTreeWidgetItem(stringList); |
---|
| 344 | 00405 |
---|
| 345 | 00406 <span class="comment">// look for childs</span> |
---|
| 346 | 00407 <a class="code" href="classG4UIQt.html#d2">CreateChildTree</a>(newItem,treeTop->GetTree(a+1)); |
---|
| 347 | 00408 items.append(newItem); |
---|
| 348 | 00409 } |
---|
| 349 | 00410 <a class="code" href="classG4UIQt.html#r7">fHelpTreeWidget</a>->insertTopLevelItems(0, items); |
---|
| 350 | 00411 |
---|
| 351 | 00412 <span class="comment">//connecting callback</span> |
---|
| 352 | 00413 <span class="comment">// QSignalMapper signalMapper = new QSignalMapper(this);</span> |
---|
| 353 | 00414 |
---|
| 354 | 00415 connect(<a class="code" href="classG4UIQt.html#r7">fHelpTreeWidget</a>, SIGNAL(itemSelectionChanged ()),<span class="keyword">this</span>, SLOT(<a class="code" href="classG4UIQt.html#k3">helpTreeCallback</a>())); |
---|
| 355 | 00416 |
---|
| 356 | 00417 <span class="comment">// Set layouts</span> |
---|
| 357 | 00418 |
---|
| 358 | 00419 QVBoxLayout *vLayout = <span class="keyword">new</span> QVBoxLayout; |
---|
| 359 | 00420 |
---|
| 360 | 00421 splitter->addWidget(<a class="code" href="classG4UIQt.html#r7">fHelpTreeWidget</a>); |
---|
| 361 | 00422 splitter->addWidget(<a class="code" href="classG4UIQt.html#r4">fHelpArea</a>); |
---|
| 362 | 00423 |
---|
| 363 | 00424 vLayout->addWidget(splitter); |
---|
| 364 | 00425 vLayout->addWidget(exitButton); |
---|
| 365 | 00426 <a class="code" href="classG4UIQt.html#r8">fHelpDialog</a>->setLayout(vLayout); |
---|
| 366 | 00427 |
---|
| 367 | 00428 } |
---|
| 368 | 00429 |
---|
| 369 | 00430 <span class="comment">// Look for the choosen command "newCommand"</span> |
---|
| 370 | 00431 size_t i = newCommand.index(<span class="stringliteral">" "</span>); |
---|
| 371 | 00432 G4String targetCom=<span class="stringliteral">""</span>; |
---|
| 372 | 00433 <span class="keywordflow">if</span>( i != std::string::npos ) |
---|
| 373 | 00434 { |
---|
| 374 | 00435 G4String newValue = newCommand(i+1,newCommand.length()-(i+1)); |
---|
| 375 | 00436 newValue.strip(G4String::both); |
---|
| 376 | 00437 targetCom = <a class="code" href="classG4VBasicShell.html#b0">ModifyToFullPathCommand</a>( newValue ); |
---|
| 377 | 00438 printf(<span class="stringliteral">"test : av:%s-- ap:%s--\n"</span>,((<span class="keywordtype">char</span>*)newValue.data()),((<span class="keywordtype">char</span>*)targetCom.data())); |
---|
| 378 | 00439 } |
---|
| 379 | 00440 <span class="keywordflow">if</span> (targetCom != <span class="stringliteral">""</span>) { |
---|
| 380 | 00441 QList<QTreeWidgetItem *> list = <a class="code" href="classG4UIQt.html#r7">fHelpTreeWidget</a>->findItems(QString(((<span class="keywordtype">char</span>*)targetCom.data())),Qt::MatchFixedString,0); |
---|
| 381 | 00442 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> a=0;a<13;a++) { |
---|
| 382 | 00443 printf(<span class="stringliteral">"verif.... =%s= +%s+\n"</span>,<a class="code" href="classG4UIQt.html#r7">fHelpTreeWidget</a>->topLevelItem(a)->text(0).toStdString().c_str(),((<span class="keywordtype">char</span>*)targetCom.data())); |
---|
| 383 | 00444 } |
---|
| 384 | 00445 |
---|
| 385 | 00446 <span class="keywordflow">if</span> (!list.isEmpty()) { |
---|
| 386 | 00447 <span class="keywordflow">if</span> (list.first()->childCount() >0) |
---|
| 387 | 00448 list.first()->setExpanded(<span class="keyword">true</span>); |
---|
| 388 | 00449 |
---|
| 389 | 00450 <span class="comment">//collapsed open item</span> |
---|
| 390 | 00451 QList<QTreeWidgetItem *> selected; |
---|
| 391 | 00452 selected = <a class="code" href="classG4UIQt.html#r7">fHelpTreeWidget</a>->selectedItems(); |
---|
| 392 | 00453 <span class="keywordflow">if</span> ( selected.count() != 0 ) { |
---|
| 393 | 00454 <a class="code" href="classG4UIQt.html#r7">fHelpTreeWidget</a>->collapseItem (selected.at( 0 ) ); |
---|
| 394 | 00455 } |
---|
| 395 | 00456 |
---|
| 396 | 00457 <span class="comment">// clear old selection</span> |
---|
| 397 | 00458 <a class="code" href="classG4UIQt.html#r7">fHelpTreeWidget</a>->clearSelection(); |
---|
| 398 | 00459 list.first()->setSelected(<span class="keyword">true</span>); |
---|
| 399 | 00460 |
---|
| 400 | 00461 <span class="comment">// Call the update of the right textArea</span> |
---|
| 401 | 00462 <a class="code" href="classG4UIQt.html#k3">helpTreeCallback</a>(); |
---|
| 402 | 00463 } |
---|
| 403 | 00464 } |
---|
| 404 | 00465 <a class="code" href="classG4UIQt.html#r8">fHelpDialog</a>->setWindowTitle(<span class="stringliteral">"Help on commands"</span>); |
---|
| 405 | 00466 <a class="code" href="classG4UIQt.html#r8">fHelpDialog</a>->resize(800,600); |
---|
| 406 | 00467 <a class="code" href="classG4UIQt.html#r8">fHelpDialog</a>->move(QPoint(400,150)); |
---|
| 407 | 00468 <a class="code" href="classG4UIQt.html#r8">fHelpDialog</a>->show(); |
---|
| 408 | 00469 <a class="code" href="classG4UIQt.html#r8">fHelpDialog</a>->raise(); |
---|
| 409 | 00470 <a class="code" href="classG4UIQt.html#r8">fHelpDialog</a>->activateWindow(); |
---|
| 410 | 00471 } |
---|
| 411 | 00472 |
---|
| 412 | 00473 |
---|
| 413 | 00474 |
---|
| 414 | <a name="l00480"></a><a class="code" href="classG4UIQt.html#d2">00480</a> <span class="keywordtype">void</span> <a class="code" href="classG4UIQt.html#d2">G4UIQt::CreateChildTree</a>( |
---|
| 415 | 00481 QTreeWidgetItem *aParent |
---|
| 416 | 00482 ,G4UIcommandTree *aCommandTree |
---|
| 417 | 00483 ) |
---|
| 418 | 00484 { |
---|
| 419 | 00485 |
---|
| 420 | 00486 <span class="comment">// Creating new item</span> |
---|
| 421 | 00487 QTreeWidgetItem * newItem; |
---|
| 422 | 00488 |
---|
| 423 | 00489 |
---|
| 424 | 00490 <span class="comment">// Get the Sub directories</span> |
---|
| 425 | 00491 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> a=0;a<aCommandTree->GetTreeEntry();a++) { |
---|
| 426 | 00492 |
---|
| 427 | 00493 QStringList stringList; |
---|
| 428 | 00494 stringList << QString((<span class="keywordtype">char</span>*)(aCommandTree->GetTree(a+1)->GetPathName()).data()).trimmed() ; |
---|
| 429 | 00495 stringList << QString((<span class="keywordtype">char</span>*)(aCommandTree->GetTree(a+1)->GetTitle()).data()).trimmed() ; |
---|
| 430 | 00496 newItem = <span class="keyword">new</span> QTreeWidgetItem(stringList); |
---|
| 431 | 00497 |
---|
| 432 | 00498 <a class="code" href="classG4UIQt.html#d2">CreateChildTree</a>(newItem,aCommandTree->GetTree(a+1)); |
---|
| 433 | 00499 aParent->addChild(newItem); |
---|
| 434 | 00500 } |
---|
| 435 | 00501 |
---|
| 436 | 00502 |
---|
| 437 | 00503 |
---|
| 438 | 00504 <span class="comment">// Get the Commands</span> |
---|
| 439 | 00505 |
---|
| 440 | 00506 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> a=0;a<aCommandTree->GetCommandEntry();a++) { |
---|
| 441 | 00507 |
---|
| 442 | 00508 QStringList stringList; |
---|
| 443 | 00509 stringList << QString((<span class="keywordtype">char</span>*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()).trimmed() ; |
---|
| 444 | 00510 stringList << QString((<span class="keywordtype">char</span>*)(aCommandTree->GetCommand(a+1)->GetCommandPath()).data()).trimmed() ; |
---|
| 445 | 00511 newItem = <span class="keyword">new</span> QTreeWidgetItem(stringList); |
---|
| 446 | 00512 |
---|
| 447 | 00513 aParent->addChild(newItem); |
---|
| 448 | 00514 newItem->setExpanded(<span class="keyword">false</span>); |
---|
| 449 | 00515 } |
---|
| 450 | 00516 } |
---|
| 451 | 00517 |
---|
| 452 | 00518 |
---|
| 453 | <a name="l00526"></a><a class="code" href="classG4UIQt.html#d3">00526</a> QString <a class="code" href="classG4UIQt.html#d3">G4UIQt::GetCommandList</a> ( |
---|
| 454 | 00527 G4UIcommand *aCommand |
---|
| 455 | 00528 ) |
---|
| 456 | 00529 { |
---|
| 457 | 00530 |
---|
| 458 | 00531 QString txt; |
---|
| 459 | 00532 G4String commandPath = aCommand->GetCommandPath(); |
---|
| 460 | 00533 G4String rangeString = aCommand->GetRange(); |
---|
| 461 | 00534 |
---|
| 462 | 00535 <span class="keywordflow">if</span>((commandPath.length()-1)!=<span class="charliteral">'/'</span>) |
---|
| 463 | 00536 { |
---|
| 464 | 00537 txt += <span class="stringliteral">"Command "</span> + QString((<span class="keywordtype">char</span>*)(commandPath).data()) + <span class="stringliteral">"\n"</span>; |
---|
| 465 | 00538 } |
---|
| 466 | 00539 txt += <span class="stringliteral">"Guidance :\n"</span>; |
---|
| 467 | 00540 G4int n_guidanceEntry = aCommand->GetGuidanceEntries(); |
---|
| 468 | 00541 |
---|
| 469 | 00542 <span class="keywordflow">for</span>( G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) |
---|
| 470 | 00543 { txt += QString((<span class="keywordtype">char</span>*)(aCommand->GetGuidanceLine(i_thGuidance)).data()) + <span class="stringliteral">"\n"</span>; } |
---|
| 471 | 00544 <span class="keywordflow">if</span>( ! rangeString.isNull() ) |
---|
| 472 | 00545 { txt += <span class="stringliteral">" Range of parameters : "</span> + QString((<span class="keywordtype">char</span>*)(rangeString).data()) + <span class="stringliteral">"\n"</span>; } |
---|
| 473 | 00546 G4int n_parameterEntry = aCommand->GetParameterEntries(); |
---|
| 474 | 00547 <span class="keywordflow">if</span>( n_parameterEntry > 0 ) |
---|
| 475 | 00548 { |
---|
| 476 | 00549 G4UIparameter *param; |
---|
| 477 | 00550 |
---|
| 478 | 00551 <span class="comment">// Re-implementation of G4UIparameter.cc</span> |
---|
| 479 | 00552 |
---|
| 480 | 00553 <span class="keywordflow">for</span>( G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) |
---|
| 481 | 00554 { param = aCommand->GetParameter(i_thParameter); |
---|
| 482 | 00555 txt += <span class="stringliteral">"\nParameter : "</span> + QString((<span class="keywordtype">char</span>*)(param->GetParameterName()).data()) + <span class="stringliteral">"\n"</span>; |
---|
| 483 | 00556 <span class="keywordflow">if</span>( ! param->GetParameterGuidance().isNull() ) |
---|
| 484 | 00557 txt += QString((<span class="keywordtype">char</span>*)(param->GetParameterGuidance()).data())+ <span class="stringliteral">"\n"</span> ; |
---|
| 485 | 00558 txt += <span class="stringliteral">" Parameter type : "</span> + QString(param->GetParameterType())+ <span class="stringliteral">"\n"</span>; |
---|
| 486 | 00559 <span class="keywordflow">if</span>(param->IsOmittable()) |
---|
| 487 | 00560 { txt += <span class="stringliteral">" Omittable : True\n"</span>; } |
---|
| 488 | 00561 <span class="keywordflow">else</span> |
---|
| 489 | 00562 { txt += <span class="stringliteral">" Omittable : False\n"</span>; } |
---|
| 490 | 00563 <span class="keywordflow">if</span>( param->GetCurrentAsDefault() ) |
---|
| 491 | 00564 { txt += <span class="stringliteral">" Default value : taken from the current value\n"</span>; } |
---|
| 492 | 00565 <span class="keywordflow">else</span> <span class="keywordflow">if</span>( ! param->GetDefaultValue().isNull() ) |
---|
| 493 | 00566 { txt += <span class="stringliteral">" Default value : "</span> + QString((<span class="keywordtype">char</span>*)(param->GetDefaultValue()).data())+ <span class="stringliteral">"\n"</span>; } |
---|
| 494 | 00567 <span class="keywordflow">if</span>( ! param->GetParameterRange().isNull() ) |
---|
| 495 | 00568 txt += <span class="stringliteral">" Parameter range : "</span> + QString((<span class="keywordtype">char</span>*)(param->GetParameterRange()).data())+ <span class="stringliteral">"\n"</span>; |
---|
| 496 | 00569 <span class="keywordflow">if</span>( ! param->GetParameterCandidates().isNull() ) |
---|
| 497 | 00570 txt += <span class="stringliteral">" Candidates : "</span> + QString((<span class="keywordtype">char</span>*)(param->GetParameterCandidates()).data())+ <span class="stringliteral">"\n"</span>; |
---|
| 498 | 00571 } |
---|
| 499 | 00572 } |
---|
| 500 | 00573 <span class="keywordflow">return</span> txt; |
---|
| 501 | 00574 } |
---|
| 502 | 00575 |
---|
| 503 | 00576 |
---|
| 504 | 00577 |
---|
| 505 | <a name="l00581"></a><a class="code" href="classG4UIQt.html#d4">00581</a> G4bool <a class="code" href="classG4UIQt.html#d4">G4UIQt::GetHelpChoice</a>( |
---|
| 506 | 00582 G4int& aInt |
---|
| 507 | 00583 ) |
---|
| 508 | 00584 { |
---|
| 509 | 00585 printf(<span class="stringliteral">"G4UIQt::GetHelpChoice SHOULD NEVER GO HERE"</span>); |
---|
| 510 | 00586 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
---|
| 511 | 00587 } |
---|
| 512 | 00588 |
---|
| 513 | 00589 |
---|
| 514 | <a name="l00593"></a><a class="code" href="classG4UIQt.html#d5">00593</a> <span class="keywordtype">void</span> <a class="code" href="classG4UIQt.html#d5">G4UIQt::ExitHelp</a>( |
---|
| 515 | 00594 ) |
---|
| 516 | 00595 { |
---|
| 517 | 00596 printf(<span class="stringliteral">"G4UIQt::ExitHelp SHOULD NEVER GO HERE"</span>); |
---|
| 518 | 00597 } |
---|
| 519 | 00598 |
---|
| 520 | 00599 |
---|
| 521 | <a name="l00608"></a><a class="code" href="classG4UIQt.html#d6">00608</a> <span class="keywordtype">bool</span> <a class="code" href="classG4UIQt.html#d6">G4UIQt::eventFilter</a>( |
---|
| 522 | 00609 QObject *obj |
---|
| 523 | 00610 ,QEvent *event |
---|
| 524 | 00611 ) |
---|
| 525 | 00612 { |
---|
| 526 | 00613 <span class="keywordflow">if</span> (obj == <a class="code" href="classG4UIQt.html#r5">fCommandHistoryArea</a>) { |
---|
| 527 | 00614 <span class="keywordflow">if</span> (event->type() == QEvent::KeyPress) { |
---|
| 528 | 00615 <a class="code" href="classG4UIQt.html#r2">fCommandArea</a>->setFocus(); |
---|
| 529 | 00616 } |
---|
| 530 | 00617 } |
---|
| 531 | 00618 <span class="keywordflow">if</span> (obj == <a class="code" href="classG4UIQt.html#r2">fCommandArea</a>) { |
---|
| 532 | 00619 <span class="keywordflow">if</span> (event->type() == QEvent::KeyPress) { |
---|
| 533 | 00620 QKeyEvent *e = static_cast<QKeyEvent*>(event); |
---|
| 534 | 00621 <span class="keywordflow">if</span> ((e->key() == (Qt::Key_Down)) || |
---|
| 535 | 00622 (e->key() == (Qt::Key_PageDown)) || |
---|
| 536 | 00623 (e->key() == (Qt::Key_Up)) || |
---|
| 537 | 00624 (e->key() == (Qt::Key_PageUp))) { |
---|
| 538 | 00625 <span class="keywordtype">int</span> selection = <a class="code" href="classG4UIQt.html#r5">fCommandHistoryArea</a>->currentRow(); |
---|
| 539 | 00626 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> a=0;a<<a class="code" href="classG4UIQt.html#r5">fCommandHistoryArea</a>->count();a++) { |
---|
| 540 | 00627 |
---|
| 541 | 00628 } |
---|
| 542 | 00629 <span class="keywordflow">if</span> (<a class="code" href="classG4UIQt.html#r5">fCommandHistoryArea</a>->count()) { |
---|
| 543 | 00630 <span class="keywordflow">if</span> (selection == -1) { |
---|
| 544 | 00631 selection = <a class="code" href="classG4UIQt.html#r5">fCommandHistoryArea</a>->count()-1; |
---|
| 545 | 00632 } |
---|
| 546 | 00633 <span class="keywordflow">if</span> (e->key() == (Qt::Key_Down)) { |
---|
| 547 | 00634 <span class="keywordflow">if</span> (selection <(<a class="code" href="classG4UIQt.html#r5">fCommandHistoryArea</a>->count()-1)) |
---|
| 548 | 00635 selection++; |
---|
| 549 | 00636 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (e->key() == (Qt::Key_PageDown)) { |
---|
| 550 | 00637 selection = <a class="code" href="classG4UIQt.html#r5">fCommandHistoryArea</a>->count()-1; |
---|
| 551 | 00638 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (e->key() == (Qt::Key_Up)) { |
---|
| 552 | 00639 <span class="keywordflow">if</span> (selection >0) |
---|
| 553 | 00640 selection --; |
---|
| 554 | 00641 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (e->key() == (Qt::Key_PageUp)) { |
---|
| 555 | 00642 selection = 0; |
---|
| 556 | 00643 } |
---|
| 557 | 00644 <a class="code" href="classG4UIQt.html#r5">fCommandHistoryArea</a>->clearSelection(); |
---|
| 558 | 00645 <a class="code" href="classG4UIQt.html#r5">fCommandHistoryArea</a>->item(selection)->setSelected(<span class="keyword">true</span>); |
---|
| 559 | 00646 <a class="code" href="classG4UIQt.html#r5">fCommandHistoryArea</a>->setCurrentItem(<a class="code" href="classG4UIQt.html#r5">fCommandHistoryArea</a>->item(selection)); |
---|
| 560 | 00647 } |
---|
| 561 | 00648 } |
---|
| 562 | 00649 } |
---|
| 563 | 00650 } |
---|
| 564 | 00651 <span class="comment">// pass the event on to the parent class</span> |
---|
| 565 | 00652 <span class="keywordflow">return</span> QObject::eventFilter(obj, event); |
---|
| 566 | 00653 } |
---|
| 567 | 00654 |
---|
| 568 | 00655 |
---|
| 569 | 00656 |
---|
| 570 | 00657 |
---|
| 571 | 00658 <span class="comment">/***************************************************************************/</span> |
---|
| 572 | 00659 <span class="comment">//</span> |
---|
| 573 | 00660 <span class="comment">// SLOTS DEFINITIONS</span> |
---|
| 574 | 00661 <span class="comment">//</span> |
---|
| 575 | 00662 <span class="comment">/***************************************************************************/</span> |
---|
| 576 | 00663 |
---|
| 577 | <a name="l00667"></a><a class="code" href="classG4UIQt.html#k4">00667</a> <span class="keywordtype">void</span> <a class="code" href="classG4UIQt.html#k4">G4UIQt::showHelpCallback</a> ( |
---|
| 578 | 00668 ) |
---|
| 579 | 00669 { |
---|
| 580 | 00670 <a class="code" href="classG4UIQt.html#d1">TerminalHelp</a>(<span class="stringliteral">""</span>); |
---|
| 581 | 00671 } |
---|
| 582 | 00672 |
---|
| 583 | 00673 |
---|
| 584 | <a name="l00677"></a><a class="code" href="classG4UIQt.html#k0">00677</a> <span class="keywordtype">void</span> <a class="code" href="classG4UIQt.html#k0">G4UIQt::clearButtonCallback</a> ( |
---|
| 585 | 00678 ) |
---|
| 586 | 00679 { |
---|
| 587 | 00680 <a class="code" href="classG4UIQt.html#r3">fTextArea</a>->clear(); |
---|
| 588 | 00681 } |
---|
| 589 | 00682 |
---|
| 590 | 00683 |
---|
| 591 | <a name="l00688"></a><a class="code" href="classG4UIQt.html#k1">00688</a> <span class="keywordtype">void</span> <a class="code" href="classG4UIQt.html#k1">G4UIQt::commandEnteredCallback</a> ( |
---|
| 592 | 00689 ) |
---|
| 593 | 00690 { |
---|
| 594 | 00691 G4String command (<a class="code" href="classG4UIQt.html#r2">fCommandArea</a>->text().toStdString().c_str()); |
---|
| 595 | 00692 <span class="keywordflow">if</span> (<a class="code" href="classG4UIQt.html#r2">fCommandArea</a>->text().trimmed() != <span class="stringliteral">""</span>) { |
---|
| 596 | 00693 <a class="code" href="classG4UIQt.html#r5">fCommandHistoryArea</a>->addItem(<a class="code" href="classG4UIQt.html#r2">fCommandArea</a>->text()); |
---|
| 597 | 00694 <a class="code" href="classG4UIQt.html#r5">fCommandHistoryArea</a>->clearSelection(); |
---|
| 598 | 00695 <a class="code" href="classG4UIQt.html#r5">fCommandHistoryArea</a>->item(<a class="code" href="classG4UIQt.html#r5">fCommandHistoryArea</a>->count()-1)->setSelected(<span class="keyword">true</span>); |
---|
| 599 | 00696 <a class="code" href="classG4UIQt.html#r5">fCommandHistoryArea</a>->setCurrentItem(<a class="code" href="classG4UIQt.html#r5">fCommandHistoryArea</a>->item(<a class="code" href="classG4UIQt.html#r5">fCommandHistoryArea</a>->count()-1)); |
---|
| 600 | 00697 |
---|
| 601 | 00698 <span class="keywordflow">if</span> (command(0,4) != <span class="stringliteral">"help"</span>) { |
---|
| 602 | 00699 <a class="code" href="classG4VBasicShell.html#b10">ApplyShellCommand</a> (command,<a class="code" href="G4UIQt_8cc.html#a0">exitSession</a>,<a class="code" href="G4UIQt_8cc.html#a1">exitPause</a>); |
---|
| 603 | 00700 } <span class="keywordflow">else</span> { |
---|
| 604 | 00701 <a class="code" href="classG4UIQt.html#d1">TerminalHelp</a>(command); |
---|
| 605 | 00702 } |
---|
| 606 | 00703 <span class="keywordflow">if</span>(<a class="code" href="G4UIQt_8cc.html#a0">exitSession</a>==<span class="keyword">true</span>) |
---|
| 607 | 00704 <a class="code" href="classG4UIQt.html#a6">SessionTerminate</a>(); |
---|
| 608 | 00705 } |
---|
| 609 | 00706 <a class="code" href="classG4UIQt.html#r2">fCommandArea</a>->setText(<span class="stringliteral">""</span>); |
---|
| 610 | 00707 } |
---|
| 611 | 00708 |
---|
| 612 | 00709 |
---|
| 613 | <a name="l00715"></a><a class="code" href="classG4UIQt.html#k2">00715</a> <span class="keywordtype">void</span> <a class="code" href="classG4UIQt.html#k2">G4UIQt::buttonCallback</a> ( |
---|
| 614 | 00716 <span class="keyword">const</span> QString& aCommand |
---|
| 615 | 00717 ) |
---|
| 616 | 00718 { |
---|
| 617 | 00719 G4String ss = G4String(aCommand.toStdString().c_str()); |
---|
| 618 | 00720 printf (<span class="stringliteral">"debug : execute:\n-%s- %d %d \n"</span>,ss.data(),<a class="code" href="G4UIQt_8cc.html#a0">exitSession</a>,<a class="code" href="G4UIQt_8cc.html#a1">exitPause</a>); |
---|
| 619 | 00721 <a class="code" href="classG4VBasicShell.html#b10">ApplyShellCommand</a>(ss,<a class="code" href="G4UIQt_8cc.html#a0">exitSession</a>,<a class="code" href="G4UIQt_8cc.html#a1">exitPause</a>); |
---|
| 620 | 00722 <span class="keywordflow">if</span>(<a class="code" href="G4UIQt_8cc.html#a0">exitSession</a>==<span class="keyword">true</span>) |
---|
| 621 | 00723 <a class="code" href="classG4UIQt.html#a6">SessionTerminate</a>(); |
---|
| 622 | 00724 } |
---|
| 623 | 00725 |
---|
| 624 | 00726 |
---|
| 625 | 00727 |
---|
| 626 | <a name="l00731"></a><a class="code" href="classG4UIQt.html#k3">00731</a> <span class="keywordtype">void</span> <a class="code" href="classG4UIQt.html#k3">G4UIQt::helpTreeCallback</a> ( |
---|
| 627 | 00732 ) |
---|
| 628 | 00733 { |
---|
| 629 | 00734 <span class="comment">// G4bool GetHelpChoice(G4int&);</span> |
---|
| 630 | 00735 QTreeWidgetItem* item = NULL; |
---|
| 631 | 00736 <span class="keywordflow">if</span> (!<a class="code" href="classG4UIQt.html#r7">fHelpTreeWidget</a>) |
---|
| 632 | 00737 <span class="keywordflow">return</span> ; |
---|
| 633 | 00738 |
---|
| 634 | 00739 <span class="keywordflow">if</span> (!<a class="code" href="classG4UIQt.html#r4">fHelpArea</a>) |
---|
| 635 | 00740 <span class="keywordflow">return</span>; |
---|
| 636 | 00741 |
---|
| 637 | 00742 QList<QTreeWidgetItem *> list =<a class="code" href="classG4UIQt.html#r7">fHelpTreeWidget</a>->selectedItems(); |
---|
| 638 | 00743 <span class="keywordflow">if</span> (list.isEmpty()) |
---|
| 639 | 00744 <span class="keywordflow">return</span>; |
---|
| 640 | 00745 item = list.first(); |
---|
| 641 | 00746 <span class="keywordflow">if</span> (!item) |
---|
| 642 | 00747 <span class="keywordflow">return</span>; |
---|
| 643 | 00748 |
---|
| 644 | 00749 G4UImanager* UI = G4UImanager::GetUIpointer(); |
---|
| 645 | 00750 <span class="keywordflow">if</span>(UI==NULL) <span class="keywordflow">return</span>; |
---|
| 646 | 00751 G4UIcommandTree * treeTop = UI->GetTree(); |
---|
| 647 | 00752 G4UIcommand* command = treeTop->FindPath(item->text (1).toStdString().c_str()); |
---|
| 648 | 00753 <span class="keywordflow">if</span> (command) { |
---|
| 649 | 00754 <a class="code" href="classG4UIQt.html#r4">fHelpArea</a>->setText(<a class="code" href="classG4UIQt.html#d3">GetCommandList</a>(command)); |
---|
| 650 | 00755 } <span class="keywordflow">else</span> { |
---|
| 651 | 00756 <span class="comment">// this is not a command, this is a sub directory</span> |
---|
| 652 | 00757 <span class="comment">// We display the Title</span> |
---|
| 653 | 00758 <a class="code" href="classG4UIQt.html#r4">fHelpArea</a>->setText(item->text (1).toStdString().c_str()); |
---|
| 654 | 00759 } |
---|
| 655 | 00760 } |
---|
| 656 | 00761 |
---|
| 657 | 00762 |
---|
| 658 | <a name="l00767"></a><a class="code" href="classG4UIQt.html#k5">00767</a> <span class="keywordtype">void</span> <a class="code" href="classG4UIQt.html#k5">G4UIQt::commandHistoryCallback</a>( |
---|
| 659 | 00768 ) |
---|
| 660 | 00769 { |
---|
| 661 | 00770 QListWidgetItem* item = NULL; |
---|
| 662 | 00771 <span class="keywordflow">if</span> (!<a class="code" href="classG4UIQt.html#r5">fCommandHistoryArea</a>) |
---|
| 663 | 00772 <span class="keywordflow">return</span> ; |
---|
| 664 | 00773 |
---|
| 665 | 00774 |
---|
| 666 | 00775 QList<QListWidgetItem *> list =<a class="code" href="classG4UIQt.html#r5">fCommandHistoryArea</a>->selectedItems(); |
---|
| 667 | 00776 <span class="keywordflow">if</span> (list.isEmpty()) |
---|
| 668 | 00777 <span class="keywordflow">return</span>; |
---|
| 669 | 00778 item = list.first(); |
---|
| 670 | 00779 <span class="keywordflow">if</span> (!item) |
---|
| 671 | 00780 <span class="keywordflow">return</span>; |
---|
| 672 | 00781 <a class="code" href="classG4UIQt.html#r2">fCommandArea</a>->setText(item->text()); |
---|
| 673 | 00782 |
---|
| 674 | 00783 } |
---|
| 675 | 00784 |
---|
| 676 | 00785 <span class="preprocessor">#endif</span> |
---|
| 677 | </pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri Jun 22 11:07:02 2007 by |
---|
| 678 | <a href="http://www.doxygen.org/index.html"> |
---|
| 679 | <img src="doxygen.png" alt="doxygen" align="middle" border=0 > |
---|
| 680 | </a>1.3.4 </small></address> |
---|
| 681 | </body> |
---|
| 682 | </html> |
---|