31 #ifdef G4UI_BUILD_WT_SESSION 
   44 #include <Wt/WLineEdit> 
   45 #include <Wt/WTextArea> 
   46 #include <Wt/WMessageBox> 
   48 #include <Wt/WRadioButton> 
   49 #include <Wt/WButtonGroup> 
   50 #include <Wt/WComboBox> 
   51 #include <Wt/WVBoxLayout> 
   52 #include <Wt/WHBoxLayout> 
   53 #include <Wt/WGridLayout> 
   55 #include <Wt/WSelectionBox> 
   58 #define G4DEBUG_INTERFACES_BASIC 1 
   61 static G4bool exitSession = 
true;
 
   62 static G4bool exitPause = 
true;
 
   91 ,fCoutTBTextArea(NULL)
 
   96 ,fHistoryTBTableList(NULL)
 
   97 ,fHelpTreeWidget(NULL)
 
   99 ,fHistoryTBWidget(NULL)
 
  101 ,fSceneTreeComponentsTBWidget(NULL)
 
  103 ,fViewerTabWidget(NULL)
 
  105 ,fEmptyViewerTabLabel(NULL)
 
  106 ,fMainSplitterWidget(NULL)
 
  107 ,fRightSplitterWidget(NULL)
 
  108 ,fHelpVSplitter(NULL)
 
  111 ,fStringSeparator(
"__$$$@%%###__")
 
  113 ,fMoveSelected(false)
 
  114 ,fRotateSelected(true)
 
  115 ,fPickSelected(false)
 
  116 ,fZoomInSelected(false)
 
  117 ,fZoomOutSelected(false)
 
  123   G4Wt* interactorManager = G4Wt::getInstance (argc,argv,(
char*)
"Wt");
 
  124   if (!(Wt::WApplication*)interactorManager->GetMainInteractor()) {
 
  129       G4cout        << 
"G4UIWt : Unable to init Wt. Aborted" << 
G4endl;
 
  137   fMainWindow = 
new Wt::WContainerWidget(wApp->root());
 
  140   Wt::WVBoxLayout* mainWindowVLayout = 
new Wt::WVBoxLayout();
 
  141   fMainWindow->setLayout(mainWindowVLayout);
 
  144 #ifdef G4DEBUG_INTERFACES_BASIC 
  145   printf(
"G4UIWt::Initialise after main window creation +++++++++++\n");
 
  150   fMainSplitterWidget = 
new Wt::WContainerWidget();
 
  151   Wt::WGridLayout* fMainSplitterWidgetLayout = 
new Wt::WGridLayout();
 
  154   fMainSplitterWidgetLayout->addWidget(CreateLeftSplitterWidget(),1,1);
 
  155   fMainSplitterWidgetLayout->addWidget(CreateRightSplitterWidget(),1,2);
 
  156   fMainSplitterWidgetLayout->setColumnResizable (1,
true,Wt::WLength(30,Wt::WLength::Percentage));
 
  162   fMainSplitterWidget->setLayout(fMainSplitterWidgetLayout);
 
  163   mainWindowVLayout->addWidget(fMainSplitterWidget);
 
  167 #ifdef G4DEBUG_INTERFACES_BASIC 
  168   printf(
"G4UIWt::G4UIWt :: 5\n");
 
  174   wApp->setTitle(
"Wt application");
 
  185 #ifdef G4DEBUG_INTERFACES_BASIC 
  186   printf(
"G4UIWt::~G4UIWt Delete\n");
 
  195   if (fMainWindow!=NULL) {
 
  196 #ifdef G4DEBUG_INTERFACES_BASIC 
  197   printf(
"G4UIWt::~G4UIWt DELETE fMainWindow\n");
 
  205 Wt::WWidget* G4UIWt::CreateHistoryTBWidget(
 
  208   fHistoryTBWidget = 
new Wt::WPanel();
 
  209   fHistoryTBWidget->setCollapsed(
true);
 
  210   fHistoryTBWidget->setCollapsible(
true);
 
  212   fHistoryTBTableList = 
new Wt::WSelectionBox();
 
  213   fHistoryTBTableList->setSelectionMode(Wt::SingleSelection);
 
  214   fHistoryTBTableList->changed().connect(
this,&G4UIWt::CommandHistoryCallback);
 
  216   fHistoryTBWidget->setCentralWidget(fHistoryTBTableList);
 
  217   return fHistoryTBWidget;
 
  223 Wt::WWidget* G4UIWt::CreateHelpTBWidget(
 
  226   fHelpTBWidget = 
new Wt::WPanel();
 
  227   fHelpTBWidget->setCollapsible(
true);
 
  229   Wt::WContainerWidget *helpWidget = 
new Wt::WContainerWidget();
 
  230   Wt::WHBoxLayout *helpLayout = 
new Wt::WHBoxLayout();
 
  231   Wt::WVBoxLayout *vLayout = 
new Wt::WVBoxLayout();
 
  233   fHelpVSplitter = 
new Wt::WContainerWidget();
 
  234   fHelpVSplitter->setLayout(
new Wt::WHBoxLayout());
 
  236   Wt::WVBoxLayout* VHelpSplitterVLayout = 
new Wt::WVBoxLayout();
 
  237   fHelpVSplitter->setLayout(VHelpSplitterVLayout);
 
  240   fHelpLine = 
new Wt::WLineEdit();
 
  241   fHelpTBWidget->setCentralWidget(helpWidget);
 
  242   helpWidget->setLayout(helpLayout);
 
  243   helpWidget->layout()->addWidget(
new Wt::WLabel(Wt::WString(
"Search :")));
 
  244   helpWidget->layout()->addWidget(fHelpLine);
 
  245   printf(
"*** G4UIWt::CreateHelpTBWidget, missing EnterPress connection\n");
 
  251   fHelpArea = 
new Wt::WTextArea(fHelpVSplitter);
 
  252   fHelpArea->setReadOnly(
true);
 
  256   if (fHelpTreeWidget) {
 
  257     fHelpVSplitter->addWidget(fHelpTreeWidget);
 
  259   fHelpVSplitter->addWidget(fHelpArea);
 
  261   vLayout->addWidget(helpWidget);
 
  262   vLayout->addWidget(fHelpVSplitter,1);
 
  272   return fHelpTBWidget;
 
  278 Wt::WWidget* G4UIWt::CreateCoutTBWidget(
 
  281   fCoutTBWidget = 
new Wt::WPanel();
 
  282   fCoutTBWidget->setCollapsible(
true);
 
  283   fCoutTBWidget->setTitle(
"Output");
 
  284   fCoutTBWidget->setCollapsed(
false);
 
  286   Wt::WContainerWidget* myContainer = 
new Wt::WContainerWidget();
 
  287   Wt::WVBoxLayout *myContainerVLayout = 
new Wt::WVBoxLayout();
 
  288   myContainer->setLayout(myContainerVLayout);
 
  291   if (!fCoutTBTextArea) {
 
  292     fCoutTBTextArea = 
new Wt::WTextArea(myContainer);
 
  294   fCoutFilter = 
new Wt::WLineEdit();
 
  295   Wt::WLabel* coutFilterLabel = 
new Wt::WLabel(
"Filter : ");
 
  296   myContainerVLayout->addWidget(fCoutTBTextArea);
 
  297   myContainerVLayout->addWidget(fCoutFilter);
 
  298   myContainerVLayout->addWidget(coutFilterLabel);
 
  300   Wt::WPushButton *coutTBClearButton = 
new Wt::WPushButton (
"clear",myContainer);
 
  307   fCoutTBTextArea->setReadOnly(
true);
 
  309   Wt::WContainerWidget* coutButtonWidget = 
new Wt::WContainerWidget(myContainer);
 
  310   Wt::WHBoxLayout* layoutCoutTBButtons = 
new Wt::WHBoxLayout(coutButtonWidget);
 
  311   layoutCoutTBButtons->addWidget(coutTBClearButton);
 
  312   layoutCoutTBButtons->addWidget(coutFilterLabel);
 
  313   layoutCoutTBButtons->addWidget(fCoutFilter);
 
  315   myContainerVLayout->addWidget(coutButtonWidget);
 
  317   fCoutTBWidget->setCentralWidget(myContainer);
 
  319   return fCoutTBWidget;
 
  325 Wt::WContainerWidget* G4UIWt::CreateVisParametersTBWidget(
 
  334 Wt::WWidget* G4UIWt::CreateUITabWidget(
 
  337   fUITabWidget = 
new Wt::WTabWidget();
 
  340   fUITabWidget->addTab(CreateSceneTreeComponentsTBWidget(),
"Scene tree");
 
  341   fUITabWidget->addTab(CreateHelpTBWidget(),
"Help");
 
  342   fUITabWidget->addTab(CreateHistoryTBWidget(),
"History");
 
  353 Wt::WWidget* G4UIWt::CreateSceneTreeComponentsTBWidget(){
 
  355   fSceneTreeComponentsTBWidget = 
new Wt::WTabWidget();
 
  357   fSceneTreeComponentsTBWidget->hide();
 
  359   return fSceneTreeComponentsTBWidget;
 
  363 Wt::WContainerWidget* G4UIWt::CreateLeftSplitterWidget(){
 
  365   fLeftSplitterWidget = 
new Wt::WContainerWidget();
 
  366   Wt::WVBoxLayout * layoutLeftSplitterWidget = 
new Wt::WVBoxLayout();
 
  367   fLeftSplitterWidget->setLayout(layoutLeftSplitterWidget);
 
  369   layoutLeftSplitterWidget->addWidget(CreateUITabWidget());
 
  371   return fLeftSplitterWidget;
 
  375 Wt::WContainerWidget* G4UIWt::CreateRightSplitterWidget(){
 
  377   fRightSplitterWidget = 
new Wt::WContainerWidget();
 
  380   Wt::WVBoxLayout* VSplitterVLayout = 
new Wt::WVBoxLayout();
 
  381   fRightSplitterWidget->setLayout(VSplitterVLayout);
 
  382   Wt::WContainerWidget* commandLineWidget = 
new Wt::WContainerWidget();
 
  384   Wt::WHBoxLayout *layoutCommandLine = 
new Wt::WHBoxLayout();
 
  385   commandLineWidget->setLayout(layoutCommandLine);
 
  389   fCommandLabel = 
new Wt::WLabel(
"",commandLineWidget);
 
  390   fCommandArea = 
new Wt::WLineEdit(commandLineWidget);
 
  391   fCommandArea->setToolTip(
"Apply command");
 
  394   layoutCommandLine->addWidget(fCommandLabel);
 
  395   layoutCommandLine->addWidget(fCommandArea);
 
  398   fViewerTabWidget = 
new G4WTabWidget(fRightSplitterWidget);
 
  400   fViewerTabWidget->tabClosed().connect(
this, &G4UIWt::TabCloseCallback);
 
  402   fViewerTabWidget->currentChanged().connect(
this,&G4UIWt::CurrentChangedTabWidgetCallback);
 
  405   fEmptyViewerTabLabel = 
new Wt::WLabel(
"         If you want to have a Viewer, please use /vis/open commands. ");
 
  408   fRightSplitterWidget->layout()->addWidget(fViewerTabWidget);
 
  409   fRightSplitterWidget->layout()->addWidget(fEmptyViewerTabLabel);
 
  410   fRightSplitterWidget->layout()->addWidget(CreateCoutTBWidget());
 
  411   fRightSplitterWidget->layout()->addWidget(commandLineWidget);
 
  413   commandLineWidget->setMinimumSize(50,50);
 
  416   fCommandArea->enterPressed().connect(
this,&G4UIWt::CommandEnteredCallback);
 
  418   return fRightSplitterWidget;
 
  424 Wt::WTabWidget* G4UIWt::GetSceneTreeComponentsTBWidget(
 
  427   return fSceneTreeComponentsTBWidget;
 
  434 bool G4UIWt::AddTabWidget(
 
  457   if (!fViewerTabWidget->isVisible() ) {
 
  458     if ( fRightSplitterWidget->isVisible()) {
 
  459       fRightSplitterWidget->setHidden(
true);
 
  460       fEmptyViewerTabLabel->setHidden(
true);
 
  462 #ifdef G4DEBUG_INTERFACES_BASIC 
  463     printf(
"G4UIWt::AddTabWidget +++++\n");
 
  465     fViewerTabWidget->show();
 
  466     fViewerTabWidget = 
new G4WTabWidget(fRightSplitterWidget);
 
  468     fViewerTabWidget->tabClosed().connect(
this, &G4UIWt::TabCloseCallback);
 
  470     fViewerTabWidget->currentChanged().connect(
this,&G4UIWt::CurrentChangedTabWidgetCallback);
 
  471     fRightSplitterWidget->layout()->addWidget(fViewerTabWidget);
 
  493   fViewerTabWidget->addTab(
new Wt::WLabel(
"test"),
"test1");
 
  494   fViewerTabWidget->addTab(aWidget,name);
 
  495   fViewerTabWidget->addTab(
new Wt::WLabel(
"test"),
"test2");
 
  498   aWidget->decorationStyle().setBackgroundColor (Wt::WColor(245,245,245));
 
  500   fViewerTabWidget->setCurrentIndex(fViewerTabWidget->count()-1);
 
  503   fViewerTabWidget->setLastTabCreated(fViewerTabWidget->currentIndex());
 
  510 void G4UIWt::CurrentChangedTabWidgetCallback(
int tabNumber) {
 
  511 #ifdef G4DEBUG_INTERFACES_BASIC 
  512   printf(
"G4UIWt::CurrentChangedTabWidget %d\n",tabNumber);
 
  514   if ( fViewerTabWidget == NULL) {
 
  515     fViewerTabWidget = 
new G4WTabWidget;
 
  518 #ifdef G4DEBUG_INTERFACES_BASIC 
  519   printf(
"G4UIWt::CurrentChangedTabWidget CALL REPAINT tabGL\n");
 
  522   fViewerTabWidget->setCurrentIndex(tabNumber);
 
  525   fViewerTabWidget->setTabSelected(
false);
 
  527   fViewerTabWidget->show();
 
  530   fViewerTabWidget->setTabSelected(
true);
 
  533   Wt::WString text = fViewerTabWidget->tabText (tabNumber);
 
  535   Wt::WString paramSelect = Wt::WString(
"/vis/viewer/select ")+text;
 
  548 #ifdef G4DEBUG_INTERFACES_BASIC 
  549   printf(
"G4UIWt::G4UIWt SessionStart 1\n");
 
  552   G4Wt* interactorManager = G4Wt::getInstance ();
 
  559 #ifdef G4DEBUG_INTERFACES_BASIC 
  560   printf(
"G4UIWt::G4UIWt SessionStart2\n");
 
  562   interactorManager->DisableSecondaryLoop (); 
 
  575   interactorManager->EnableSecondaryLoop ();
 
  586 void G4UIWt::Prompt (
 
  590   if (!aPrompt) 
return;
 
  591   if (!fCommandLabel) 
return;
 
  593   fCommandLabel->setText((
char*)aPrompt.
data());
 
  598 void G4UIWt::SessionTerminate (
 
  601   G4Wt* interactorManager = G4Wt::getInstance ();
 
  603   if ((Wt::WApplication*)interactorManager->GetMainInteractor()) {
 
  614 void G4UIWt::SecondaryLoop (
 
  618   if (!aPrompt) 
return;
 
  620   G4Wt* interactorManager = G4Wt::getInstance (); 
 
  624   while((eventTmp = interactorManager->GetEvent())!=NULL) {  
 
  625     interactorManager->DispatchEvent(eventTmp); 
 
  626     if(fExitPause==
true) 
break; 
 
  635 void G4UIWt::CommandEnteredCallback (
 
  638 #ifdef G4DEBUG_INTERFACES_BASIC 
  639   printf(
"G4UIWt::CommandEnteredCallback\n");
 
  641 #ifdef G4DEBUG_INTERFACES_BASIC 
  642   printf(
"G4UIWt::CommandEnteredCallback 1\n");
 
  644   G4String command (fCommandArea->text().toUTF8());
 
  645  if (fCommandArea->text() != 
"") {
 
  647    printf(
"*** G4UIWt::CommandEnteredCallback, missing update on history \n");
 
  653    fCommandArea->setText(
"");
 
  654 #ifdef G4DEBUG_INTERFACES_BASIC 
  655     printf(
"G4UIWt::CommandEnteredCallback 2\n");
 
  658     G4Wt* interactorManager = G4Wt::getInstance ();
 
  659 #ifdef G4DEBUG_INTERFACES_BASIC 
  660     printf(
"G4UIWt::CommandEnteredCallback 3\n");
 
  662     if (interactorManager) {
 
  663       interactorManager->FlushAndWaitExecution();
 
  665 #ifdef G4DEBUG_INTERFACES_BASIC 
  666     printf(
"G4UIWt::CommandEnteredCallback 4\n");
 
  668     if (command(0,4) != 
"help") {
 
  669       ApplyShellCommand (command,exitSession,exitPause);
 
  671       ActivateCommand(command);
 
  673 #ifdef G4DEBUG_INTERFACES_BASIC 
  674     printf(
"G4UIWt::CommandEnteredCallback 5\n");
 
  679 #ifdef G4DEBUG_INTERFACES_BASIC 
  680     printf(
"G4UIWt::CommandEnteredCallback 6\n");
 
  682     if(exitSession==
true)
 
  685 #ifdef G4DEBUG_INTERFACES_BASIC 
  686   printf(
"G4UIWt::CommandEnteredCallback END\n");
 
  698 void G4UIWt::AddButton (
 
  701                         ,
const char* aCommand
 
  704   if(aMenu==NULL) 
return; 
 
  705   if(aLabel==NULL) 
return; 
 
  706   if(aCommand==NULL) 
return; 
 
  708   Wt::WMenu *parentTmp = (Wt::WMenu*)GetInteractor(aMenu);
 
  710   if(parentTmp==NULL) {
 
  715       G4cout << 
"Menu name " << aMenu<< 
" does not exist, please define it before using it."<< 
G4endl;
 
  726   G4int cmdEndPos = cmd.find_first_of(
" \t");
 
  727   if(cmdEndPos!=
G4int(std::string::npos)) {
 
  728     cmd.erase(cmdEndPos);
 
  731   if(treeTop->
FindPath(aCommand) == NULL) {
 
  736       G4cout << 
"Warning: command '"<< aCommand <<
"' does not exist, please define it before using it."<< 
G4endl;
 
  740   printf(
"*** G4UIWt::AddButton, missing connection on menu callback \n");
 
  754 void G4UIWt::AddIcon(
const char* aLabel, 
const char* aIconFile, 
const char* aCommand, 
const char*  ){
 
  755   if(aLabel==NULL) 
return; 
 
  757   if (aCommand==NULL) {
 
  758     if (std::string(aIconFile) == 
"user_icon") {
 
  762   printf(
"*** G4UIWt::AddIcon, missing icon creation \n");
 
 1646 bool G4UIWt::CreateCommandWidget(
G4UIcommand* aCommand, Wt::WContainerWidget* aParent, 
bool isDialog) {
 
 1648   if (aCommand == NULL) {
 
 1655   if( n_parameterEntry > 0 ) {
 
 1659     Wt::WContainerWidget* paramWidget = 
new Wt::WContainerWidget();
 
 1660     Wt::WGridLayout* gridLayout = 
new Wt::WGridLayout(paramWidget);
 
 1663     unsigned int nbColorParameter = 0;
 
 1664     bool isStillColorParameter = 
false;
 
 1665     bool isColorDialogAdded = 
false;
 
 1666     Wt::WLabel* redLabel = NULL;
 
 1667     Wt::WLabel* greenLabel = NULL;
 
 1668     Wt::WString redDefaultStr = 
"";
 
 1669     Wt::WString greenDefaultStr = 
"";
 
 1670     Wt::WString blueDefaultStr = 
"";
 
 1671     Wt::WWidget* redInput = NULL;
 
 1672     Wt::WWidget* greenInput = NULL;
 
 1674     for( 
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
 
 1677       Wt::WLabel* label = 
new Wt::WLabel(Wt::WString((
char*)(param->
GetParameterName()).data()));
 
 1679       if ((label->text() == 
"red") || (label->text() == 
"red_or_string")){
 
 1680         nbColorParameter ++;
 
 1681         isStillColorParameter = 
true;
 
 1682       } 
else if ((label->text() == 
"green") && isStillColorParameter) {
 
 1683         nbColorParameter ++;
 
 1684       } 
else if ((label->text() == 
"blue") && isStillColorParameter) {
 
 1685         nbColorParameter ++;
 
 1686       } 
else if (!isColorDialogAdded) {
 
 1689         if (nbColorParameter == 1) {
 
 1690           gridLayout->addWidget(redLabel,i_thParameter-1,0);
 
 1691           gridLayout->addWidget(redInput,i_thParameter-1,1);
 
 1692         } 
else if (nbColorParameter == 2) {
 
 1693           gridLayout->addWidget(redLabel,i_thParameter-2,0);
 
 1694           gridLayout->addWidget(redInput,i_thParameter-2,1);
 
 1695           gridLayout->addWidget(greenLabel,i_thParameter-1,0);
 
 1696           gridLayout->addWidget(greenInput,i_thParameter-1,1);
 
 1698         nbColorParameter = 0;
 
 1701       Wt::WWidget* input = NULL;
 
 1703       if ((paramType == 
'd') || (paramType == 
'i')) {
 
 1704         input = 
new Wt::WLineEdit();
 
 1706         dynamic_cast<Wt::WLineEdit*
>(input)->setText(Wt::WString((
char*)(param->
GetDefaultValue()).data()));
 
 1708         if (((label->text() == 
"red") || (label->text() == 
"red_or_string")) && isStillColorParameter) {
 
 1709           redDefaultStr = Wt::WString((
char*)(param->
GetDefaultValue()).data());
 
 1710         } 
else if ((label->text() == 
"green") && isStillColorParameter) {
 
 1711           greenDefaultStr = Wt::WString((
char*)(param->
GetDefaultValue()).data());
 
 1712         } 
else if ((label->text() == 
"green") && isStillColorParameter) {
 
 1713           blueDefaultStr = Wt::WString((
char*)(param->
GetDefaultValue()).data());
 
 1716       } 
else if (paramType == 
'b') {
 
 1717         input = 
new Wt::WContainerWidget();
 
 1718         Wt::WHBoxLayout* layout = 
new Wt::WHBoxLayout(input);
 
 1720         Wt::WButtonGroup* buttons = 
new Wt::WButtonGroup();
 
 1721         Wt::WRadioButton* radioOff = 
new Wt::WRadioButton(
"0");
 
 1722         Wt::WRadioButton* radioOn = 
new Wt::WRadioButton(
"1");
 
 1723         buttons->addButton(radioOn);
 
 1724         buttons->addButton(radioOff);
 
 1725         layout->addWidget(radioOn);
 
 1726         layout->addWidget(radioOff);
 
 1729         Wt::WString defaultValue = Wt::WString((
char*)(param->
GetDefaultValue()).data());
 
 1730         if (defaultValue == 
"0") {
 
 1731           radioOff->setChecked(
true);
 
 1732         } 
else if (defaultValue == 
"1") {
 
 1733           radioOn->setChecked(
true);
 
 1736         input = 
new Wt::WComboBox();
 
 1738         printf(
"*** G4UIWt::CreateCommandWidget, missing parameter management for 's'\n");
 
 1750       } 
else if (paramType == 
's') {  
 
 1751         input = 
new Wt::WLineEdit();
 
 1753         dynamic_cast<Wt::WLineEdit*
>(input)->setText(Wt::WString((
char*)(param->
GetDefaultValue()).data()));
 
 1755       } 
else if (paramType == 
'c') {  
 
 1756         input = 
new Wt::WContainerWidget();
 
 1757         Wt::WHBoxLayout* layout = 
new Wt::WHBoxLayout(input);
 
 1759         Wt::WButtonGroup* buttons = 
new Wt::WButtonGroup();
 
 1760         Wt::WRadioButton* radioOff = 
new Wt::WRadioButton(
"off");
 
 1761         Wt::WRadioButton* radioOn = 
new Wt::WRadioButton(
"on");
 
 1762         buttons->addButton(radioOn);
 
 1763         buttons->addButton(radioOff);
 
 1764         layout->addWidget(radioOn);
 
 1765         layout->addWidget(radioOff);
 
 1768         Wt::WString defaultValue = Wt::WString((
char*)(param->
GetDefaultValue()).data());
 
 1769         if (defaultValue == 
"off") {
 
 1770           radioOff->setChecked(
true);
 
 1771         } 
else if (defaultValue == 
"on") {
 
 1772           radioOn->setChecked(
true);
 
 1776         input = 
new Wt::WLineEdit();
 
 1777         dynamic_cast<Wt::WLineEdit*
>(input)->setText(Wt::WString((
char*)(param->
GetDefaultValue()).data()));
 
 1780       txt += 
"\nParameter : " + Wt::WString((
char*)(param->
GetParameterName()).data()) + 
"\n";
 
 1785       txt += Wt::WString(
" Parameter type  : ") + std::string(¶mType).c_str() + 
"\n";
 
 1787         txt += 
" Omittable       : True\n";
 
 1789         txt += 
" Omittable       : False\n";
 
 1792         txt += 
" Default value   : taken from the current value\n";
 
 1794         txt += 
" Default value   : " + Wt::WString((
char*)(param->
GetDefaultValue()).data())+ 
"\n";
 
 1797         txt += 
" Parameter range : " + Wt::WString((
char*)(param->
GetParameterRange()).data())+ 
"\n";
 
 1803       if (isStillColorParameter && (nbColorParameter != 0)) {
 
 1804         if ((label->text() == 
"red") || (label->text() == 
"red_or_string")) {
 
 1807         } 
else if (label->text() == 
"green") {
 
 1810         } 
else if (label->text() == 
"blue") {
 
 1816           if ((redDefaultStr != 
"") && (redDefaultStr != 
"") && (redDefaultStr != 
"")) {
 
 1818             wc.setRgb(atof(redDefaultStr.toUTF8().c_str())*256,
 
 1819                        atof(greenDefaultStr.toUTF8().c_str())*256,
 
 1820                        atof(blueDefaultStr.toUTF8().c_str())*256);
 
 1822           printf(
"*** G4UIWt::CreateCommandWidget, missing icon on command widget\n");
 
 1848           isColorDialogAdded = 
true;
 
 1849           isStillColorParameter = 
false;
 
 1852         gridLayout->addWidget(label,i_thParameter-nbColorParameter,0);
 
 1853         input->setToolTip(txt);
 
 1854         gridLayout->addWidget(input,i_thParameter-nbColorParameter,1);
 
 1858     Wt::WLabel* name = 
new Wt::WLabel(Wt::WString((
char*)(aCommand->
GetCommandPath().
data())));
 
 1860     gridLayout->addWidget(name,n_parameterEntry-nbColorParameter,0);
 
 1862     Wt::WPushButton* applyButton = 
new Wt::WPushButton(
"Apply");
 
 1865       gridLayout->addWidget(applyButton,n_parameterEntry-nbColorParameter,1);
 
 1867       printf(
"*** G4UIWt::CreateCommandWidget, missing connection on ApplyButton\n");
 
 1877       printf(
"*** G4UIWt::CreateCommandWidget, missing connection on Apply/Cancel Button\n");
 
 1909     if (!aParent->layout()) {
 
 1910       aParent->setLayout(
new Wt::WVBoxLayout());
 
 1912     aParent->layout()->addWidget(paramWidget);
 
 1926 bool G4UIWt::eventFilter( 
 
 1932   printf(
"*** G4UIWt::eventFilter, missing eventFilter on everything\n");
 
 2007 void G4UIWt::HelpTreeClicCallback (
 
 2010   Wt::WTreeNode* item =  NULL;
 
 2011   if (!fHelpTreeWidget)
 
 2017   const Wt::WTree::WTreeNodeSet& list = fHelpTreeWidget->selectedNodes();
 
 2020   item = *list.begin();
 
 2025   if(UI==NULL) 
return;
 
 2028   std::string itemText = GetLongCommandPath(item).toUTF8();
 
 2033     fHelpArea->setText(GetCommandList(command));
 
 2046 void G4UIWt::HelpTreeDoubleClicCallback (
 
 2049   HelpTreeClicCallback();
 
 2051   Wt::WTreeNode* item =  NULL;
 
 2052   if (!fHelpTreeWidget)
 
 2058   const Wt::WTree::WTreeNodeSet& list = fHelpTreeWidget->selectedNodes();
 
 2061   item = *list.begin();
 
 2065   fCommandArea->setText(
"");
 
 2066   fCommandArea->setText(GetLongCommandPath(item));
 
 2075 G4int G4UIWt::ReceiveG4cout (
 
 2079   if (!aString) 
return 0;
 
 2081   Wt::WStringListModel newStr;
 
 2084   std::string whiteSpaces( 
" \f\n\r\t\v" );
 
 2085   std::string path = (
char*)aString.
data();
 
 2087   std::string::size_type posR = path.find_last_not_of( whiteSpaces );
 
 2088   path.erase( posR + 1 );
 
 2090   std::string::size_type posL = path.find_first_not_of( whiteSpaces );
 
 2091   path.erase( 0, posL );
 
 2093   printf(
"*** G4UIWt::ReceiveG4cout, missing filtering\n");
 
 2103   if (!fCoutTBTextArea) {
 
 2104     printf(
"*** G4UIWt::ReceiveG4cout, create a new fCoutTBTextArea \n");
 
 2105     fCoutTBTextArea = 
new Wt::WTextArea();
 
 2106     fCoutTBTextArea->setText(
"");
 
 2108   fCoutTBTextArea->setText(fCoutTBTextArea->text()+
"\n"+path);
 
 2109   fCoutTBTextArea->refresh();
 
 2120 G4int G4UIWt::ReceiveG4cerr (
 
 2124   if (!aString) 
return 0;
 
 2126   Wt::WStringListModel newStr;
 
 2129   std::string whiteSpaces( 
" \f\n\r\t\v" );
 
 2130   std::string path = (
char*)aString.
data();
 
 2132   std::string::size_type posR = path.find_last_not_of( whiteSpaces );
 
 2133   path.erase( posR + 1 );
 
 2135   std::string::size_type posL = path.find_first_not_of( whiteSpaces );
 
 2136   path.erase( 0, posL );
 
 2138   printf(
"*** G4UIWt::ReceiveG4cerr, missing filtering\n");
 
 2150       Wt::WMessageBox::show(
"Error", Wt::WString(fLastErrMessage.data())+
"\n"+aString.
data(), Wt::Ok );
 
 2154   printf(
"****ERR****: %s\n",path.c_str());
 
 2155   if (!fCoutTBTextArea) {
 
 2156     fCoutTBTextArea = 
new Wt::WTextArea();
 
 2158   fCoutTBTextArea->setText(fCoutTBTextArea->text()+
"\n<font color='red'>"+path+
"</font>");
 
 2159   fCoutTBTextArea->refresh();
 
 2163     fLastErrMessage = aString;
 
 2173 void G4UIWt::CommandEditedCallback(
const Wt::WString &)
 
 2175   printf(
"*** G4UIWt::CommandEditedCallback, missing callback on command line edit\n");
 
 2193 void G4UIWt::CoutFilterCallback(
 
 2194                                 const Wt::WString & ) {
 
 2195   printf(
"*** G4UIWt::CoutFilterCallbackt, missing filtering\n");
 
 2215 void G4UIWt::AddMenu (
 
 2220   if (aName == NULL) 
return;
 
 2221   if (aLabel == NULL) 
return;
 
 2223   printf(
"*** G4UIWt::AddMenu, missing \n");
 
 2237 bool G4UIWt::CreateVisCommandGroupAndToolBox(
 
 2244   printf(
"*** G4UIWt::CreateVisCommandGroupAndToolBox, missing \n");
 
 2384 void G4UIWt::VisParameterCallback(Wt::WContainerWidget* widget){
 
 2385   if (widget == NULL) {
 
 2388   printf(
"*** G4UIWt::VisParameterCallback, missing \n");
 
 2448 void G4UIWt::CommandHistoryCallback(
 
 2451   if (!fHistoryTBTableList)
 
 2453   fCommandArea->setText(fHistoryTBTableList->currentText ());
 
 2454 #ifdef G4DEBUG_INTERFACES_BASIC 
 2455   printf(
"G4UIWt::CommandHistoryCallback change text\n");
 
 2460 void G4UIWt::OpenHelpTreeOnCommand(
 
 2464   printf(
"*** G4UIWt::OpenHelpTreeOnCommand, missing \n");
 
 2597 void G4UIWt::ChangeColorCallback(Wt::WContainerWidget* widget) {
 
 2598   if (widget == NULL) {
 
 2601   printf(
"*** G4UIWt::ChangeColorCallback, missing \n");
 
 2638 void G4UIWt::ChangeCursorStyle(
const Wt::WString& ) {
 
 2642   fMoveSelected = 
true;
 
 2643   fPickSelected = 
true;
 
 2644   fRotateSelected = 
true;
 
 2645   fZoomInSelected = 
true;
 
 2646   fZoomOutSelected = 
true;
 
 2648   printf(
"*** G4UIWt::ChangeCursorStyle, missing \n");
 
 2683 void G4UIWt::ChangeSurfaceStyle(
const Wt::WString& ) {
 
 2687   printf(
"*** G4UIWt::ChangeSurfaceStyle, missing \n");
 
 2724 void G4UIWt::OpenIconCallback(
const Wt::WString& ) {
 
 2726   printf(
"*** G4UIWt::OpenIconCallback, missing \n");
 
 2741 void G4UIWt::SaveIconCallback(
const Wt::WString& ) {
 
 2743   printf(
"*** G4UIWt::SaveIconCallback, missing \n");
 
 2759 void G4UIWt::ChangePerspectiveOrthoCallback(
const Wt::WString& ) {
 
 2763   printf(
"*** G4UIWt::ChangePerspectiveOrthoCallback, missing \n");
 
 3032 void G4UIWt::FillHelpTree()
 
 3034   if (! fHelpTreeWidget ) {
 
 3035     InitHelpTreeAndVisParametersWidget();
 
 3038   Wt::WString searchText = fHelpLine->text();
 
 3040   if (searchText ==
"") {
 
 3048     fHelpArea->setText(
"");
 
 3052     fHelpLine->setText(
"");
 
 3056   if(UI==NULL) 
return;
 
 3060   Wt::WTreeNode * newItem = NULL;
 
 3061   Wt::WString commandText = 
"";
 
 3063   for (
int a=0;
a<treeSize;
a++) {
 
 3068     std::string whiteSpaces( 
" \f\n\r\t\v" );
 
 3071     std::string::size_type posR = path.find_last_not_of( whiteSpaces );
 
 3072     path.erase( posR + 1 );
 
 3074     std::string::size_type posL = path.find_first_not_of( whiteSpaces );
 
 3075     path.erase( 0, posL );
 
 3077     commandText = Wt::WString(path.c_str());
 
 3080     if (fHelpTreeWidget->treeRoot()) {
 
 3081       for (
int b=0;b<fHelpTreeWidget->treeRoot()->displayedChildCount();b++) {
 
 3083           newItem = FindTreeItem(fHelpTreeWidget->treeRoot()->childNodes()[b],path.c_str());
 
 3086     if (newItem == NULL) {
 
 3087       newItem = 
new Wt::WTreeNode(GetShortCommandPath(path), 0);
 
 3088       fHelpTreeWidget->setTreeRoot(newItem);
 
 3092     CreateHelpTree(newItem,treeTop->
GetTree(
a+1));
 
 3107 void G4UIWt::PauseSessionStart (
 
 3111   if (!aState) 
return;
 
 3113   if(aState==
"G4_pause> ") {  
 
 3114     SecondaryLoop (
"Pause, type continue to exit this state"); 
 
 3117   if(aState==
"EndOfEvent") { 
 
 3119     SecondaryLoop (
"End of event, type continue to exit this state"); 
 
 3130 void G4UIWt::ActivateCommand(
 
 3134   if (!fHelpTreeWidget) {
 
 3138   size_t i = newCommand.
index(
" ");
 
 3140   if( i != std::string::npos )
 
 3142     G4String newValue = newCommand(i+1,newCommand.length()-(i+1));
 
 3144     targetCom = ModifyToFullPathCommand( newValue );
 
 3146 #ifdef G4DEBUG_INTERFACES_BASIC 
 3147   printf(
"G4UIWt::ActivateCommand found : %s \n",targetCom.
data());
 
 3149   if (targetCom != 
"") {
 
 3150     OpenHelpTreeOnCommand(targetCom.
data());
 
 3153   fUITabWidget->setCurrentWidget(fHelpTBWidget);
 
 3164 void G4UIWt::InitHelpTreeAndVisParametersWidget()
 
 3167   if (! fHelpTreeWidget ) {
 
 3168     fHelpTreeWidget = 
new Wt::WTree();
 
 3172   fHelpTreeWidget->setSelectionMode(Wt::SingleSelection);
 
 3174   fHelpTreeWidget->itemSelectionChanged ().connect(
this,&G4UIWt::HelpTreeClicCallback);
 
 3182 void G4UIWt::CreateHelpTree(
 
 3183                                  Wt::WTreeNode *aParent
 
 3187   if (aParent == NULL) 
return;
 
 3188   if (aCommandTree == NULL) 
return;
 
 3192   Wt::WTreeNode * newItem;
 
 3194   Wt::WString commandText = 
"";
 
 3199     std::string whiteSpaces( 
" \f\n\r\t\v" );
 
 3202     std::string::size_type posR = path.find_last_not_of( whiteSpaces );
 
 3203     path.erase( posR + 1 );
 
 3205     std::string::size_type posL = path.find_first_not_of( whiteSpaces );
 
 3206     path.erase( 0, posL );
 
 3208     commandText = Wt::WString(path.c_str());
 
 3211     newItem = FindTreeItem(aParent,path.c_str());
 
 3212     if (newItem == NULL) {
 
 3213       newItem = 
new Wt::WTreeNode(GetShortCommandPath(path), 0,aParent);
 
 3215     CreateHelpTree(newItem,aCommandTree->
GetTree(
a+1));
 
 3223     std::string whiteSpaces( 
" \f\n\r\t\v" );
 
 3226     std::string::size_type posR = path.find_last_not_of( whiteSpaces );
 
 3227     path.erase( posR + 1 );
 
 3229     std::string::size_type posL = path.find_first_not_of( whiteSpaces );
 
 3230     path.erase( 0, posL );
 
 3232     commandText = Wt::WString(path.c_str());
 
 3235     newItem = FindTreeItem(aParent,path.c_str());
 
 3236     if (newItem == NULL) {
 
 3238       newItem = 
new Wt::WTreeNode(GetShortCommandPath(path), 0,aParent);
 
 3240       newItem->collapse();
 
 3255 Wt::WTreeNode* G4UIWt::FindTreeItem(
 
 3256                                                        Wt::WTreeNode *aParent
 
 3257                                                        ,
const std::string& aCommand
 
 3260   if (aParent == NULL) 
return NULL;
 
 3263   std::string myCommand = aCommand;
 
 3266   if (myCommand.rfind(
"/") == (myCommand.size()-1)) {
 
 3267     myCommand = myCommand.substr(0,myCommand.size()-1);
 
 3270   if (GetLongCommandPath(aParent) == Wt::WString(myCommand.c_str()))
 
 3273   Wt::WTreeNode * tmp = NULL;
 
 3274   for (
unsigned int a=0;
a<aParent->childNodes().size();
a++) {
 
 3276       tmp = FindTreeItem(aParent->childNodes().at(
a),myCommand);
 
 3290 Wt::WString G4UIWt::GetCommandList (
 
 3295   Wt::WString txt =
"";
 
 3296   if (aCommand == NULL)
 
 3304   if ((commandPath == 
"") &&
 
 3305       (rangeString == 
"") &&
 
 3306       (n_guidanceEntry == 0) &&
 
 3307       (n_parameterEntry == 0)) {
 
 3311   if((commandPath.length()-1)!=
'/') {
 
 3312     txt += 
"Command " + Wt::WString((
char*)(commandPath).data()) + 
"\n";
 
 3314   txt += 
"Guidance :\n";
 
 3316   for( 
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ ) {
 
 3317     txt += Wt::WString((
char*)(aCommand->
GetGuidanceLine(i_thGuidance)).data()) + 
"\n";
 
 3319   if( ! rangeString.
isNull() ) {
 
 3320     txt += 
" Range of parameters : " + Wt::WString((
char*)(rangeString).data()) + 
"\n";
 
 3322   if( n_parameterEntry > 0 ) {
 
 3327     for( 
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
 
 3329       txt += 
"\nParameter : " + Wt::WString((
char*)(param->
GetParameterName()).data()) + 
"\n";
 
 3333       txt += 
" Parameter type  : " + Wt::WString(&myChar) + 
"\n";
 
 3335         txt += 
" Omittable       : True\n";
 
 3337         txt += 
" Omittable       : False\n";
 
 3340         txt += 
" Default value   : taken from the current value\n";
 
 3342         txt += 
" Default value   : " + Wt::WString((
char*)(param->
GetDefaultValue()).data())+ 
"\n";
 
 3345         txt += 
" Parameter range : " + Wt::WString((
char*)(param->
GetParameterRange()).data())+ 
"\n";
 
 3361 G4bool G4UIWt::IsGUICommand(
 
 3365   if (aCommand == NULL)
 
 3370   if( n_parameterEntry > 0 ) {
 
 3375     for( 
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ ) {
 
 3378       if (myChar == 
'd') {
 
 3381       if (myChar == 
'b') {
 
 3384       if (myChar == 
'i') {
 
 3399 G4bool G4UIWt::GetHelpChoice(
 
 3403 #ifdef G4DEBUG_INTERFACES_BASIC 
 3404   printf(
"G4UIWt::GetHelpChoice SHOULD NEVER GO HERE");
 
 3421 void G4UIWt::ShowHelpCallback (
 
 3430 void G4UIWt::ClearButtonCallback (
 
 3433   fCoutTBTextArea->setText(
"");
 
 3434   fG4cout.removeRows(0,fG4cout.rowCount());
 
 3439 void G4UIWt::ExitSession (
 
 3445 void G4UIWt::ExitHelp(
 
 3458 void G4UIWt::ButtonCallback (
 
 3459                                   const char* aCommand
 
 3466   if(UI==NULL) 
return;
 
 3473     if (IsGUICommand(command)) {
 
 3474       Wt::WDialog* menuParameterDialog = 
new Wt::WDialog();
 
 3476       if (CreateVisCommandGroupAndToolBox(command,menuParameterDialog,1,
true)) {
 
 3477         menuParameterDialog->setWindowTitle (aCommand);
 
 3480         menuParameterDialog->exec();
 
 3486   ApplyShellCommand(ss,fExitSession,fExitPause);
 
 3491   if(fExitSession==
true)
 
 3503 void G4UIWt::LookForHelpStringCallback(
 
 3506   Wt::WString searchText = fHelpLine->text();
 
 3508   fHelpArea->setText(
"");
 
 3509   if (searchText ==
"") {
 
 3511     fHelpTreeWidget = 
new Wt::WTree();
 
 3517     OpenHelpTreeOnCommand(searchText);
 
 3524 Wt::WString G4UIWt::GetShortCommandPath(
 
 3525                                                      const std::string& aTxt
 
 3528   std::string commandPath;
 
 3529   if (aTxt.find(
"/", 0) != std::string::npos) {
 
 3531     commandPath = aTxt.substr(aTxt.size()-1);
 
 3535   commandPath = commandPath.substr(commandPath.size()-commandPath.rfind(
"/",-2)-1);
 
 3538   if (commandPath.rfind(
"/") == (commandPath.size()-1)) {
 
 3540     commandPath = commandPath.substr(0,commandPath.size()-1);
 
 3543   return commandPath.c_str();
 
 3547 Wt::WString G4UIWt::GetLongCommandPath(
 
 3551   if (item == NULL) 
return "";
 
 3554   Wt::WString itemText = 
"";
 
 3555   itemText = item->label()->text();
 
 3557   while (item->parentNode() != NULL) {
 
 3558     itemText = item->parentNode()->label()->text()+
"/"+itemText;
 
 3559     item = item->parentNode();
 
 3561   itemText = 
"/"+itemText;
 
 3577 G4WTabWidget::G4WTabWidget(
 
 3578  Wt::WContainerWidget*& 
 
 3586 G4WTabWidget::G4WTabWidget(
 
 3595 void G4UIWt::TabCloseCallback(
int a){
 
 3596   Wt::WWidget* temp =  fViewerTabWidget->widget(a);
 
 3597   fViewerTabWidget->removeTab (temp);
 
 3601   if (fViewerTabWidget->count() == 0) {
 
 3602     fEmptyViewerTabLabel->show();
 
 3608 void G4UIWt::ToolBoxActivated(
int a){
 
 3610   if (fUITabWidget->widget(a) == fHelpTBWidget) {
 
 3613   } 
else if (fUITabWidget->widget(a) == fSceneTreeComponentsTBWidget) {
 
 3614     fSceneTreeComponentsTBWidget->hide();
 
G4UIcommandTree * FindCommandTree(const char *commandPath)
Try to match a command or a path with the one given. 
 
G4String GetParameterCandidates() const 
 
const G4String & GetRange() const 
 
G4UIcommand * FindPath(const char *commandPath) const 
 
G4String strip(G4int strip_Type=trailing, char c=' ')
 
G4int GetCommandEntry() const 
 
G4String GetParameterName() const 
 
G4UIcommand * GetCommand(G4int i)
 
G4int GetTreeEntry() const 
 
G4int GetVerboseLevel() const 
 
void SetSession(G4UIsession *const value)
 
const G4String & GetGuidanceLine(G4int i) const 
 
void SetG4UIWindow(G4UIsession *const value)
 
static G4UImanager * GetUIpointer()
 
G4bool IsOmittable() const 
 
static G4StateManager * GetStateManager()
 
G4GLOB_DLL std::ostream G4cout
 
str_size index(const char *, G4int pos=0) const 
 
G4UIcommandTree * GetTree(G4int i)
 
G4UIparameter * GetParameter(G4int i) const 
 
const G4String & GetCommandPath() const 
 
const G4String GetPathName() const 
 
const char * data() const 
 
const G4String GetTitle() const 
 
G4UIcommandTree * GetTree() const 
 
G4String GetDefaultValue() const 
 
void SetCoutDestination(G4UIsession *const value)
 
char GetParameterType() const 
 
const G4String GetParameterGuidance() const 
 
G4String GetParameterRange() const 
 
G4int GetGuidanceEntries() const 
 
G4int GetParameterEntries() const 
 
G4bool GetCurrentAsDefault() const 
 
G4int ApplyCommand(const char *aCommand)