xbrabo.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           xbrabo.cpp  -  description
00003                              -------------------
00004     begin                : Fri Jul 19 2002
00005     copyright            : (C) 2002-2006 by Ben Swerts
00006     email                : bswerts@users.sourceforge.net
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00019 
00027 
00028 
00029 
00031 
00032 // Qt header files
00033 #include <qaccel.h>
00034 #include <qaction.h>
00035 #include <qapp.h>
00036 #include <qbitmap.h>
00037 #include <qdir.h>
00038 #include <qdockarea.h>
00039 #include <qdom.h>
00040 #include <qfiledialog.h>
00041 #include <qmainwindow.h>
00042 #include <qmenubar.h>
00043 #include <qmsgbox.h>
00044 #include <qnamespace.h>
00045 #include <qpainter.h>
00046 #include <qpixmap.h>
00047 #include <qpopupmenu.h>
00048 #include <qsettings.h>
00049 #include <qstatusbar.h>
00050 #include <qstring.h>
00051 #include <qtimer.h>
00052 #include <qtoolbar.h>
00053 #include <qtoolbutton.h>
00054 #include <qwhatsthis.h>
00055 
00056 // Xbrabo header files
00057 #include "aboutbox.h"
00058 #include "brabobase.h"
00059 #include "iconsets.h"
00060 #include "glmoleculeview.h"
00061 #include "globalbase.h"
00062 #include "orbitalviewerbase.h"
00063 #include "plotmapbase.h"
00064 #include "preferencesbase.h"
00065 #include "statustext.h"
00066 #include "textviewwidget.h"
00067 #include "version.h"
00068 #include "xbrabo.h"
00069 #include "xbraboview.h"
00070 
00071 #if defined(USE_KMDI) || defined(USE_KMDI_DLL)
00072 #  define QextMdiMainFrm KMdiMainFrm
00073 #  define QextMdiViewCloseEvent KMdiViewCloseEvent
00074 #  define QextMdi KMdi
00075 #  define m_pWinList m_pDocumentViews
00076 #endif
00077 
00081 
00083 Xbrabo::Xbrabo() : QextMdiMainFrm(0)
00085 {
00086   loadGeometry(); // basic settings for initial showing of the mainwindow
00087 }
00088 
00090 Xbrabo::~Xbrabo()
00092 {
00093 
00094 }
00095 
00097 void Xbrabo::init()
00103 {  
00104   setDefaultChildFrmSize(QSize(400, 400));
00105   
00106   editPreferences = new PreferencesBase(this, 0, true, 0);  // this loads the rest of the settings
00107 
00109   initActions();
00110   initMenuBar();
00111   initToolBars();
00112   //initStatusBar();
00113 
00114   updateActions();
00115 
00117   connect(this, SIGNAL(lastChildViewClosed()),this, SLOT(updateActions()));
00118 
00119   updatePreferences(); // update the static variables of XbraboView
00120   editPreferences->updateVisuals(); // update the visuals
00121   restoreToolbars(); // was being called in showevent
00122 }
00123 
00125 void Xbrabo::fileOpen(const QString filename)
00127 {  
00128   QFile file(filename);
00129   if(!file.open(IO_ReadOnly))
00130   {
00131     QMessageBox::warning(this, Version::appName, tr("The selected file could not be opened"), QMessageBox::Ok, QMessageBox::NoButton);
00132     statusBar()->message(tr("Opening aborted"), 2000);
00133     return;
00134   }
00135   QDomDocument* doc = new QDomDocument(filename);
00136   QString errorMessage;
00137   int errorLine, errorColumn;
00138   if(!doc->setContent(&file, false, &errorMessage, &errorLine, &errorColumn))
00139   {
00140     QString message =          tr("An error occured while parsing")
00141                       + "\n" + tr("Error Message: ") + errorMessage
00142                       + "\n" + tr("Line number: ") + QString::number(errorLine)
00143                       + "\n" + tr("Column number: ") + QString::number(errorColumn);
00144     QMessageBox::warning(this, Version::appName, message, QMessageBox::Ok, QMessageBox::NoButton);
00145     file.close();
00146     delete doc;
00147     statusBar()->message(tr("Opening aborted"), 2000);
00148     return;
00149   }
00150   file.close();
00151 
00152   /*
00156   QDomElement root = doc->documentElement();
00157   if(root.tagName() == "molecule")
00158   {
00159     QMessageBox::warning(this, appName, tr("The selected file is a regular CML file"), QMessageBox::Ok, QMessageBox::NoButton);
00160     delete doc;
00161     statusBar()->message(tr("Opening aborted"), 2000);
00162     return;
00163   }
00164   else if(root.tagName() == "cml")
00165   {
00167     QDomNodeList list = doc->elementsByTagName("brabosphere");
00168     if(list.count() == 0)
00169     {
00170       QMessageBox::warning(this, appName, tr("The selected file is a regular CML file"), QMessageBox::Ok, QMessageBox::NoButton);
00171       delete doc;
00172       statusBar()->message(tr("Opening aborted"), 2000);
00173       return;
00174     }
00175     if(list.item(0).toElement().text() != "1.0")
00176     {
00177       QMessageBox::warning(this, appName, tr("This CML file has been written with a more recent version of ") + appName, QMessageBox::Ok, QMessageBox::NoButton);
00178       delete doc;
00179       statusBar()->message(tr("Opening aborted"), 2000);
00180      return;
00181     }
00182   }
00183   else
00184   {
00185     QMessageBox::warning(this, appName, tr("The selected file is a regular XML file"), QMessageBox::Ok, QMessageBox::NoButton);
00186     delete doc;
00187     statusBar()->message(tr("Opening aborted"), 2000);
00188     return;
00189   } 
00190   */
00191 
00193   if(mdiMode() == QextMdi::ToplevelMode)
00194     view = new XbraboView(this); // no parent
00195   else
00196     view = new XbraboView(this, this);
00197   if(!view->loadCML(doc))
00198   {
00199     // An error occured during the loading of the CML file. 
00200     // The user has already been informed of the problem.
00201     delete view;
00202     delete doc;
00203     statusBar()->message(tr("Opening aborted"), 2000);
00204     return;
00205   }
00206 
00207   delete doc;
00208   view->setFileName(filename);
00209   connect(editPreferences, SIGNAL(newPVMHosts(const QStringList&)), view, SLOT(updatePVMHosts(const QStringList&)));
00210   view->updatePVMHosts(editPreferences->getPVMHosts());
00211   connect(view, SIGNAL(changed()), this, SLOT(updateActions()));
00212   addWindow(view);
00213   updateActions();
00214 
00215   statusBar()->message(tr("Loaded document: ") + filename, 2000);
00216 }
00217 
00221 
00223 bool Xbrabo::event (QEvent* e)
00225 {
00227   if(e->type() == QEvent::User)
00228   {
00229     XbraboView* tempview = (XbraboView*)((QextMdiViewCloseEvent*)e)->data();
00230     if(tempview != 0)
00231     {
00232       fileClose();
00233       return true;
00234     }
00235   }
00236   
00237   return QextMdiMainFrm::event(e);
00238 }
00239 
00241 void Xbrabo::resizeEvent (QResizeEvent* e)
00243 {  
00244    QextMdiMainFrm::resizeEvent(e);
00245    setSysButtonsAtMenuPosition();
00246 }
00247 
00249 void Xbrabo::closeEvent (QCloseEvent* e)
00251 {
00252   statusBar()->message(tr("Exiting application..."));
00253 
00254   /*if(QMessageBox::information(this, tr("Quit"), tr("Do your really want to quit?"), QMessageBox::Yes, QMessageBox::No) != QMessageBox::Yes)
00255   {
00256     statusBar()->message(IDS_STATUS_DEFAULT);
00257     return;
00258   }*/
00259 
00261   XbraboView* localview = dynamic_cast<XbraboView*>(activeWindow()); // view is used by fileClose()
00262   while(localview != 0)
00263   {
00264     fileClose();
00266     qApp->processEvents(); // needed so activeWindow() points to next window
00267     XbraboView* tempview = dynamic_cast<XbraboView*>(activeWindow());
00268     if(localview == tempview) // activeWindow is still the same, so not closed
00269     {
00270       statusBar()->clear();
00271       return;
00272     }
00273     localview = tempview;
00274   }
00275 
00276   updateToolbarsInfo();
00277   e->accept();
00278 }
00279 
00283 
00285 void Xbrabo::fileNew()
00287 {  
00288   statusBar()->message(tr("Creating new calculation..."));
00289  
00290   if(mdiMode() == QextMdi::ToplevelMode)
00291     view = new XbraboView(this);
00292   else
00293     view = new XbraboView(this, this);
00294   connect(editPreferences, SIGNAL(newPVMHosts(const QStringList&)), view, SLOT(updatePVMHosts(const QStringList&)));
00295     view->updatePVMHosts(editPreferences->getPVMHosts());
00296   connect(view, SIGNAL(changed()), this, SLOT(updateActions()));
00297   if(mdiMode() == QextMdi::ToplevelMode)
00298   {
00299     // from detachWindow (doesn't work as the size is larger than (1,1) because of the added layout)
00300     // this should be called before addWindow(), otherwise it references itself
00301     // position it outside of the screen so it doesn't flicker briefly when moving after addWindow
00302     // (which does a show, and using QextMdi::Hide with addWindow crashes at the next show())
00303     if(m_pCurrentWindow)
00304       view->setInternalGeometry(QRect(QPoint(0,-m_pCurrentWindow->size().height()-100), m_pCurrentWindow->size()));
00305     else
00306       view->setInternalGeometry(QRect(QPoint(0,-defaultChildFrmSize().height()-100), defaultChildFrmSize()));
00307   }
00308   addWindow(view);
00309   if(mdiMode() == QextMdi::ToplevelMode)
00310   {
00311     // also from detachWindow 
00312     // this should be called after addWindow otherwise the first 2 windows overlap
00313     view->move(QPoint(x() + 10, y() + frameGeometry().height()) + m_pMdi->getCascadePoint(m_pWinList->count()-1));
00314   }
00315   updateActions(); 
00316   statusBar()->clear();
00317 }
00318 
00320 void Xbrabo::fileOpen()
00322 {  
00323   statusBar()->message(tr("Opening file..."));
00324 
00325   QString fileName = QFileDialog::getOpenFileName(QString::null, "*.cml", this, 0, tr("Choose a") + " " + Version::appName + " " + tr("file to open"));
00326   if (fileName.isEmpty())
00327   {
00328     statusBar()->message(tr("Opening aborted"), 2000);
00329     return;
00330   }
00331 
00332   fileOpen(fileName);
00333 }
00334 
00336 void Xbrabo::fileSave()
00338 {  
00339   view = dynamic_cast<XbraboView*>(activeWindow());
00340   if(view == 0)
00341     return;
00342 
00343   if(view->fileName().contains("cml", false) == 0)
00344   {
00345     fileSaveAs();
00346     return;
00347   }
00348 
00349   statusBar()->message(tr("Saving file..."));
00350 
00351   QFile file(view->fileName());
00352   if(!file.open(IO_WriteOnly))
00353   {
00354     QMessageBox::warning(this, Version::appName, tr("The file could not be overwritten"), QMessageBox::Ok, QMessageBox::NoButton);
00355     statusBar()->message(tr("Saving aborted"), 2000);   
00356     return;
00357   }
00358 
00359   QTextStream stream(&file);
00360   stream.setEncoding(QTextStream::UnicodeUTF8);
00361   QDomDocument* doc = view->saveCML();
00362   stream << doc->toString(2) << endl;
00363   delete doc;
00364   view->setModified(false); // emits changed() which calls updateActions
00365 
00366   statusBar()->clear();
00367 }
00368 
00370 void Xbrabo::fileSaveAs()
00372 {  
00373   view = dynamic_cast<XbraboView*>(activeWindow());
00374   if(view == 0)
00375     return;  
00376 
00377   statusBar()->message(tr("Saving file under new filename..."));
00378 
00379   QString startName;
00380   if(view->fileName().contains("cml", false) == 0)
00381     startName = QDir::homeDirPath();
00382   else
00383     startName = view->fileName();
00384   QString fileName = QFileDialog::getSaveFileName(startName,"*.cml",this,0,"Choose a filename to save under");
00385   if (fileName.isEmpty())
00386   {
00387     statusBar()->message(tr("Saving aborted"), 2000);
00388     return;
00389   }
00390   if(fileName.right(4) != ".cml")
00391     fileName += ".cml";
00392   QFile file(fileName);
00393   if(file.exists())
00394   {
00395     if(QMessageBox::warning(this, Version::appName, tr("The selected file already exists. Do you want to overwrite it?"), QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
00396     {
00397       statusBar()->message(tr("Saving aborted"), 2000);
00398       return;
00399     }
00400   }
00401   if(!file.open(IO_WriteOnly))
00402   {
00403     QMessageBox::warning(this, Version::appName, tr("The selected file could not be created"), QMessageBox::Ok, QMessageBox::NoButton);
00404     statusBar()->message(tr("Saving aborted"), 2000);
00405     return;
00406   }   
00407 
00408   QDomDocument* doc = view->saveCML();  
00409   QString cml = doc->toString();
00410   delete doc;
00411     
00412   QTextStream stream(&file);
00413   stream.setEncoding(QTextStream::UnicodeUTF8);
00414   stream << cml << endl;
00415 
00416   view->setFileName(fileName);
00417   view->setModified(false);
00418   statusBar()->clear();
00419 }
00420 
00422 void Xbrabo::fileClose()
00424 {  
00425   view = dynamic_cast<XbraboView*>(activeWindow());
00426   if(view == 0)
00427     return;
00428 
00429   statusBar()->message(tr("Closing file..."));
00430 
00431   if(view->isRunning() && !view->isPaused())
00432   {
00433     if(QMessageBox::information(this, Version::appName, tr("The current calculation is running."), tr("Close anyway"), tr("Cancel"), 0, 1) == 1)
00434     {
00435       statusBar()->message(tr("Closing aborted"), 2000);
00436       return;
00437     }
00438   }
00439   if(view->isModified())
00440   {
00441     int result = QMessageBox::information(this, Version::appName, tr("Calculation ") + view->name() + tr(" has been modified since the last save."), tr("Save"), tr("Discard changes"), tr("Cancel"), 0, 2);
00442     if(result == 2)
00443       return;    
00444     else if(result == 0)
00445     {        
00446       fileSave();
00447       if(view->isModified())
00448       {
00449         statusBar()->message(tr("Closing aborted"), 2000);
00450         return; // cancellation of save occured
00451       }
00452     }
00453   }
00457   closeWindow(view); // closeActiveView loops because of the overridden event()
00458   statusBar()->clear();
00459 }
00460 
00462 void Xbrabo::editCut()
00464 {  
00465   statusBar()->message(tr("Cutting selection..."), 1000);
00466 
00467   view = dynamic_cast<XbraboView*>(activeWindow());
00468   if(view != 0)
00469     view->cut();  
00470 }
00471 
00473 void Xbrabo::editCopy()
00475 {  
00476   statusBar()->message(tr("Copying selection to clipboard..."), 1000);
00477 
00478   view = dynamic_cast<XbraboView*>(activeWindow());
00479   if(view != 0)
00480     view->copy();  
00481 }
00482 
00484 void Xbrabo::editPaste()
00486 {  
00487   statusBar()->message(tr("Inserting clipboard contents..."), 1000);
00488 
00489   view = dynamic_cast<XbraboView*>(activeWindow());
00490   if(view != 0)
00491     view->paste();  
00492 }
00493 
00495 void Xbrabo::editPrefs()
00497 {  
00498   statusBar()->message(tr("Changing program preferences..."));
00499 
00500   if(editPreferences->exec() == QDialog::Accepted)
00501   {
00502     updatePreferences();
00503     editPreferences->updateVisuals();
00504   }
00505 
00506   statusBar()->clear();
00507 }
00508 
00510 void Xbrabo::viewToolBarStandard()
00512 {  
00513   statusBar()->message(tr("Toggling Standard toolbar..."), 1000);
00514 
00515   // turn toolbar on or off
00516   if (ToolBarStandard->isVisible())
00517     ToolBarStandard->hide();
00518   else
00519     ToolBarStandard->show();
00520 }
00521 
00523 void Xbrabo::viewToolBarCalculation()
00525 {
00526   statusBar()->message(tr("Toggling Calculation toolbar..."), 1000);
00527 
00528   // turn toolbar on or off
00529   if (ToolBarCalculation->isVisible())
00530     ToolBarCalculation->hide();
00531   else
00532     ToolBarCalculation->show();
00533 }
00534 
00536 void Xbrabo::viewToolBarCoordinates()
00538 {
00539   statusBar()->message(tr("Toggling Coordinates toolbar..."), 1000);
00540 
00541   // turn toolbar on or off
00542   if (ToolBarCoordinates->isVisible())
00543     ToolBarCoordinates->hide();
00544   else
00545     ToolBarCoordinates->show();
00546 }
00547 
00549 void Xbrabo::viewStatusBar()
00551 {  
00552   statusBar()->message(tr("Toggling statusbar..."), 1000);
00553 
00554   //turn statusbar on or off
00555   if (statusBar()->isVisible())
00556     statusBar()->hide();
00557   else
00558     statusBar()->show();
00559   fixToplevelModeHeight();
00560 }
00561 
00563 void Xbrabo::viewTaskBar()
00565 {  
00566   statusBar()->message(tr("Toggling taskbar..."), 1000);
00567 
00568   //turn taskbar on or off
00569   if (m_pTaskBar->isVisible())
00570     hideViewTaskBar();
00571   else
00572     showViewTaskBar();
00573   actionViewTaskBar->setOn(m_pTaskBar->isVisible());
00574 }
00575 
00577 void Xbrabo::moleculeReadCoordinates()
00579 {
00580   statusBar()->message(tr("Reading Coordinates..."));
00581 
00582   view = dynamic_cast<XbraboView*>(activeWindow());
00583   if(view != 0)
00584     view->moleculeReadCoordinates();  
00585 
00586   statusBar()->clear();
00587 }
00588 
00590 void Xbrabo::moleculeCenterView()
00592 {
00593   statusBar()->message(tr("Centering view..."), 1000);
00594 
00595   view = dynamic_cast<XbraboView*>(activeWindow());
00596   if(view != 0)
00597     view->moleculeView()->centerView();
00598 }
00599 
00601 void Xbrabo::moleculeResetOrientation()
00603 {
00604   statusBar()->message(tr("Resetting orientation..."), 1000);
00605 
00606   view = dynamic_cast<XbraboView*>(activeWindow());
00607   if(view != 0)
00608     view->moleculeView()->resetOrientation();
00609 }
00610 
00612 void Xbrabo::moleculeZoomFit()
00614 {
00615   statusBar()->message(tr("Resetting zoom..."), 1000);
00616 
00617   view = dynamic_cast<XbraboView*>(activeWindow());
00618   if(view != 0)
00619     view->moleculeView()->zoomFit();
00620 }
00621 
00623 void Xbrabo::moleculeResetView()
00625 {
00626   statusBar()->message(tr("Resetting view..."), 1000);
00627 
00628   view = dynamic_cast<XbraboView*>(activeWindow());
00629   if(view != 0)
00630     view->moleculeView()->resetView();
00631 }
00632 
00634 void Xbrabo::moleculeAnimate()
00636 {
00637   statusBar()->message(tr("Toggling animation..."), 1000);
00638 
00639   view = dynamic_cast<XbraboView*>(activeWindow());
00640   if(view != 0)
00641   {
00642     view->moleculeView()->toggleAnimation();
00643     updateActions(); // toggling animation doesn't fire a XbraboView::changed signal
00644   }
00645 }
00646 
00648 void Xbrabo::moleculeFPS()
00650 {
00651   statusBar()->message(tr("Calculating FPS..."));
00652 
00653   view = dynamic_cast<XbraboView*>(activeWindow());
00654   if(view != 0)
00655     view->moleculeFPS();
00656 
00657   statusBar()->clear();
00658 }
00659 
00661 void Xbrabo::moleculeImage()
00663 {
00664   statusBar()->message(tr("Saving to an image..."));
00665 
00666   view = dynamic_cast<XbraboView*>(activeWindow());
00667   if(view != 0)
00668     view->moleculeView()->saveImage();
00669 
00670   statusBar()->clear();
00671 }
00672 
00674 void Xbrabo::moleculeAddAtoms()
00676 {
00677   statusBar()->message(tr("Adding atoms..."), 1000);
00678 
00679   view = dynamic_cast<XbraboView*>(activeWindow());
00680   if(view != 0)
00681     view->moleculeView()->addAtoms();
00682 }
00683 
00685 void Xbrabo::moleculeDeleteSelection()
00687 {
00688   statusBar()->message(tr("Deleting selection..."), 1000);
00689 
00690   view = dynamic_cast<XbraboView*>(activeWindow());
00691   if(view != 0)
00692     view->moleculeView()->deleteSelectedAtoms();
00693 }
00694 
00696 void Xbrabo::moleculeDensity()
00698 {
00699   statusBar()->message(tr("Changing density isosurfaces..."), 1000);
00700 
00701   view = dynamic_cast<XbraboView*>(activeWindow());
00702   if(view != 0)
00703     view->moleculeView()->showDensity();
00704 }
00705 
00707 void Xbrabo::moleculeDisplayMode()
00709 {
00710   statusBar()->message(tr("Changing molecular display mode..."), 1000);
00711 
00712   view = dynamic_cast<XbraboView*>(activeWindow());
00713   if(view != 0)
00714     view->showProperties();
00715 }
00716 
00718 void Xbrabo::moleculeAlterCartesian()
00720 {
00721   statusBar()->message(tr("Altering cartesian coordinates..."), 1000);
00722 
00723   view = dynamic_cast<XbraboView*>(activeWindow());
00724   if(view != 0)
00725     view->moleculeView()->alterCartesian();
00726 }
00727 
00729 void Xbrabo::moleculeAlterInternal()
00731 {
00732   statusBar()->message(tr("Altering selected internal coordinate..."), 1000);
00733 
00734   view = dynamic_cast<XbraboView*>(activeWindow());
00735   if(view != 0)
00736     view->moleculeView()->alterInternal();
00737 }
00738 
00740 void Xbrabo::moleculeSelectAll()
00742 {
00743   statusBar()->message(tr("Selecting all atoms..."), 1000);
00744 
00745   view = dynamic_cast<XbraboView*>(activeWindow());
00746   if(view != 0)
00747     view->moleculeView()->selectAll();
00748 }
00749 
00751 void Xbrabo::moleculeSelectNone()
00753 {
00754   statusBar()->message(tr("Deselecting all atoms..."), 1000);
00755 
00756   view = dynamic_cast<XbraboView*>(activeWindow());
00757   if(view != 0)
00758     view->moleculeView()->unselectAll();
00759 }
00760 
00762 void Xbrabo::moleculeSaveCoordinates()
00764 {
00765   statusBar()->message(tr("Saving coordinates..."), 1000);
00766 
00767   view = dynamic_cast<XbraboView*>(activeWindow());
00768   if(view != 0)
00769     view->moleculeSaveCoordinates();
00770 }
00771 
00773 void Xbrabo::moleculeSelection()
00775 {
00776   statusBar()->message(tr("Toggling manipulation target..."), 1000);
00777 
00778   view = dynamic_cast<XbraboView*>(activeWindow());
00779   if(view != 0)
00780     view->moleculeView()->toggleSelection();
00781 }
00782 
00784 void Xbrabo::setupGlobal()
00786 {  
00787   statusBar()->message(tr("Setup Global..."));
00788 
00789   view = dynamic_cast<XbraboView*>(activeWindow());
00790   if(view != 0)
00791     view->setupGlobal();
00792 
00793   statusBar()->clear();
00794 }
00795 
00797 void Xbrabo::setupBrabo()
00799 {  
00800   statusBar()->message(tr("Setup Energy & Forces..."));
00801 
00802   view = dynamic_cast<XbraboView*>(activeWindow());
00803   if(view != 0)
00804     view->setupBrabo();
00805 
00806   statusBar()->clear();
00807 }
00808 
00810 void Xbrabo::setupRelax()
00812 {  
00813   statusBar()->message(tr("Setup Geometry Optimization..."));
00814 
00815   view = dynamic_cast<XbraboView*>(activeWindow());
00816   if(view != 0)
00817     view->setupRelax();
00818 
00819   statusBar()->clear();
00820 }
00821 
00823 void Xbrabo::setupFreq()
00825 {  
00826   statusBar()->message(tr("Setup Frequencies..."));
00827 
00828   view = dynamic_cast<XbraboView*>(activeWindow());
00829   if(view != 0)
00830     view->setupFreq();
00831 
00832   statusBar()->clear();
00833 }
00834 
00836 void Xbrabo::setupBuur()
00838 {  
00839   statusBar()->message(tr("Setup Crystal..."));
00840 
00841   view = dynamic_cast<XbraboView*>(activeWindow());
00842   if(view != 0)
00843     view->setupBuur();
00844 
00845   statusBar()->clear();
00846 }
00847 
00849 void Xbrabo::runStart()
00851 {  
00852   statusBar()->message(tr("Starting Calculation..."), 1000);
00853 
00854   view = dynamic_cast<XbraboView*>(activeWindow());
00855   if(view != 0)
00856     view->start();
00857 }
00858 
00860 void Xbrabo::runPause()
00862 {  
00863   statusBar()->message(tr("Pausing Calculation..."), 1000);
00864 
00865   view = dynamic_cast<XbraboView*>(activeWindow());
00866   if(view != 0)
00867     view->pause();
00868 }
00869 
00871 void Xbrabo::runStop()
00873 {  
00874   statusBar()->message(tr("Stopping Calculation..."), 1000);
00875 
00876   view = dynamic_cast<XbraboView*>(activeWindow());
00877   if(view != 0)
00878     view->stop();
00879 }
00880 
00882 void Xbrabo::runWrite()
00884 {  
00885   statusBar()->message(tr("Writing Input Files..."), 1000);
00886 
00887   view = dynamic_cast<XbraboView*>(activeWindow());
00888   if(view != 0)
00889     view->writeInput();
00890 }
00891 
00893 void Xbrabo::runClean()
00895 {  
00896   statusBar()->message(tr("Cleaning the calculation directory..."), 1000);
00897 
00898   view = dynamic_cast<XbraboView*>(activeWindow());
00899   if(view != 0)
00900     view->cleanCalculation();
00901 }
00902 
00904 void Xbrabo::resultsViewOutput()
00906 {  
00907   statusBar()->message(tr("Viewing Output Files..."));
00908 
00909   view = dynamic_cast<XbraboView*>(activeWindow());
00910   if(view != 0)
00911     view->viewOutput();
00912 
00913   statusBar()->clear();
00914 }
00915 
00917 void Xbrabo::toolsPlotMap()
00919 {
00920   statusBar()->message(tr("Generating a 2D density map..."));
00921 
00922   PlotMapBase* plotmap = new PlotMapBase(this, 0, false, Qt::WDestructiveClose);
00923   
00924   /*
00925   view = dynamic_cast<XbraboView*>(activeWindow());
00926   if(view != 0)
00927   {
00929     if(plotmap->loadMapFile(view->directory() + QDir::separator() + view->name() + ".map.1"), true)
00930       plotmap->show();
00931     else if(plotmap->loadMapFile())
00932       plotmap->show();
00933     else
00934       plotmap->close();
00935   }
00936   else*/
00937   {
00939     if(plotmap->loadMapFile())
00940       plotmap->show();
00941     else
00942       plotmap->close();
00943   }
00944 
00945   statusBar()->clear();
00946 }
00947 
00949 void Xbrabo::toolsOrbitals()
00951 {
00952   statusBar()->message(tr("Showing orbitals..."), 1000);
00953 
00954   OrbitalViewerBase* orbitalView = new OrbitalViewerBase(this, 0, false, Qt::WDestructiveClose);
00955   orbitalView->show();
00956 }
00957 
00959 void Xbrabo::helpHelp()
00961 {  
00962   statusBar()->message(tr("Showing general help..."));
00963 
00964   TextViewWidget* context = new TextViewWidget(this, 0, true, 0);
00965   context->TextEdit->setText(tr(
00966     "<p>As usual, the help pages are worked on at the last moment, so you will not find a "
00967     "complete help system here. The aim was to make the functionality of the programs as self-evident as possible. "
00968     "There are, however, a few ways to get some limited help.</p>"
00969     "<ul><li>All elements of both <em><b>Brabosphere</b></em> and <em><b>CrdView</b></em> have context sensitive help "
00970     "associated with them. These can be invoked by making the programs enter the appropriate state. "
00971     "This can be done with the corresponding icon: <img source=\"WhatsThisNormal\" size=16>, by using "
00972     "Shift+F1 or clicking the question mark in the title bar of most dialogs. At that point the mouse "
00973     "cursor changes into a question mark. When clicking an element context sensitive help for that "
00974     "element will be shown (if any help is associated with it, of course). This normally only works "
00975     "for elements that can be changed (so not regular text).</li>"
00976     "<li>When hovering over the entries in the programs' menu, 1 line of help will appear in the "
00977     "statusbar. The visibility of this statusbar can be changed using the menu (View->Status Bar)</li></ul>"
00978     "<p>Now for some general information not explainable with context sensitive help:</p>"
00979     "<ul><li>The central entity of <em><b>Brabosphere</b></em> is a calculation, which can be created, opened, saved, "
00980     "and closed. The visual representation of a calculation shows a 3D window on the top and status "
00981     "messages at the bottom. The 3D window shows the molecule and possibly some of its properties.</li>"
00982     "<li>As soon as coordinates are present, a calculation can be started with the default settings. "
00983     "The type of calculation and all details can be changed in the appropriate dialogs. Most things "
00984     "can even be changed while the calculation is running (for example the SCF method, the basisset, "
00985     "whether or not to calculate stockholder charges at the next step, etc.).</li>"
00986     "<li>Coordinates can not only be read in, but also manipulated using cartesian or internal coordinates. "
00987     "Additionally, a limited molecular builder is available.</li><ul>"));
00988 
00989   context->TextEdit->setWordWrap(QTextEdit::WidgetWidth);
00990   QWhatsThis::add(context->TextEdit, "Yes, you found out how to use the context sensitive help!");
00991   context->TextEdit->setFont(QApplication::font());
00992   context->setCaption(tr("Contents"));
00993   context->exec();
00994   delete context;
00995 
00996   statusBar()->clear();
00997 }
00998 
01000 void Xbrabo::helpWhatsThis()
01002 {  
01003   statusBar()->message(tr("Entering What's This mode..."), 1000);
01004  
01005   QWhatsThis::enterWhatsThisMode();
01006 }
01007 
01009 void Xbrabo::helpCredits()
01011 {  
01012   statusBar()->message(tr("Showing credits..."));
01013 
01014   TextViewWidget* credits = new TextViewWidget(this, 0, true, 0);
01015   credits->TextEdit->setText(tr(
01016     "<p>Although the code of <em><b>Brabosphere</b></em> and <em><b>CrdView</b></em> is only written by one person at the moment, "
01017     "these programs would not exist without the help of a number of very useful libraries."
01018     "This is the ideal place to give some credit to those.</p>"
01019     "<ul><li> Trolltech's <b>Qt</b> (<font color=blue>http://www.trolltech.com</font>): provides all the visuals you can see. "
01020     "It is an excellent multiplatform toolkit with excellent documentation. It is also the sole "
01021     "reason I learnt to program in <nobr>C++.</nobr></li>"
01022     "<li> Falk Brettschneider's <b>QextMDI</b> (<font color=blue>http://www.geocities.com/gigafalk/qextmdi.htm</font>): provides "
01023     "the choice between the Childframe, Toplevel, and Tabpage modes of operation. This code has been "
01024     "included into KDE, so the Qt-only version is not maintained anymore.</li>"
01025     "<li><b>OpenBabel</b> (<font color=blue>http://openbabel.sourceforge.net</font>): without this library, you could only read "
01026     "and write a limited number of coordinate files (only BRABO .crd, Xmol .xyz, and Gaussian .fchk).</li>"
01027     "<li>The <b>Marching Cubes</b> algorithm coded by Raghavendra Chandrashekara "
01028     "(<font color=blue>http://astronomy.swin.edu.au/~pbourke/modelling/polygonise/</font>): this made the visualisation "
01029     "of density isosurfaces possible.</li>"
01030     "<li>The <b>quaternion</b> class of Sobiet Void (<font color=blue>http://www.gamedev.net/reference/articles/article1095.asp</font>): "
01031     "quaternion's are practically essential when you want to be able to control a molecule in 3D.</li>"
01032     "<li>Nullsoft's <b>NSIS</b> (<font color=blue>http://nsis.sourceforge.net</font>), responsible for the "
01033     "easy installation on Windows.</li>"
01034     "</ul>"));
01035 
01036   credits->TextEdit->setWordWrap(QTextEdit::WidgetWidth);
01037   credits->TextEdit->setFont(QApplication::font());
01038   credits->setCaption(tr("Credits"));
01039   credits->exec();
01040   delete credits;
01041 
01042   statusBar()->clear();
01043 }
01044 
01046 void Xbrabo::helpAbout()
01048 {  
01049   statusBar()->message(tr("Showing info about") + " " + Version::appName + " " + Version::appVersion + " (build " + Version::appBuild + ")...");
01050 
01051   AboutBox about(this); 
01052   about.exec();
01053 
01054   statusBar()->clear();
01055 }
01056 
01058 void Xbrabo::switchToToplevelMode()
01060 {  
01061   statusBar()->message(tr("Switching to Toplevel mode..."), 1000);
01062   QextMdiMainFrm::switchToToplevelMode();
01063   fixToplevelModeHeight();
01064 }
01065 
01067 void Xbrabo::switchToChildframeMode()
01069 {  
01070   statusBar()->message(tr("Switching to Childframe mode..."), 1000);
01071   //qDebug("before min and max heights: %d, %d", minimumHeight(), maximumHeight());
01072   //qDebug("before stored min and max heights: %d, %d", m_oldMainFrmMinHeight, m_oldMainFrmMaxHeight);
01073   //qDebug("before stored height = %d", m_oldMainFrmHeight);
01074   int keepHeight = m_oldMainFrmHeight;
01075   QextMdiMainFrm::switchToChildframeMode();
01076   qApp->processEvents();
01077   setMinimumHeight(0);
01078   setMaximumHeight(m_oldMainFrmMaxHeight > maximumHeight() ? m_oldMainFrmMaxHeight : maximumHeight());
01079   if(keepHeight > 0)
01080     resize(width(), keepHeight);
01081   //qDebug("after min and max heights: %d, %d", minimumHeight(), maximumHeight());
01082   //qDebug("after stored min and max heights: %d, %d", m_oldMainFrmMinHeight, m_oldMainFrmMaxHeight); 
01083   //qDebug("after stored height = %d", m_oldMainFrmHeight);
01084   // enable all dockareas
01085   setDockEnabled(Qt::DockLeft, true);
01086   setDockEnabled(Qt::DockRight, true);
01087 }
01088 
01090 void Xbrabo::switchToTabPageMode()
01092 {  
01093   statusBar()->message(tr("Switching to TabPage mode..."), 1000);
01094   int keepHeight = m_oldMainFrmHeight;
01095   QextMdiMainFrm::switchToTabPageMode();
01096   qApp->processEvents();
01097   setMinimumHeight(0);
01098   setMaximumHeight(m_oldMainFrmMaxHeight > maximumHeight() ? m_oldMainFrmMaxHeight : maximumHeight());
01099   if(keepHeight > 0)
01100     resize(width(), keepHeight);
01101   // enable all dockareas
01102   setDockEnabled(Qt::DockLeft, true);
01103   setDockEnabled(Qt::DockRight, true);
01104 }
01105 
01107 void Xbrabo::updateActions()
01112 {
01114   view = dynamic_cast<XbraboView*>(activeWindow());
01115   
01117   actionFileSave->setEnabled(view != 0);
01118   actionFileSaveAs->setEnabled(view != 0);
01119   actionFileClose->setEnabled(view != 0);
01121   actionMoleculeReadCoordinates->setEnabled(view != 0 && !view->isRunning());
01122   actionMoleculeSaveCoordinates->setEnabled(view != 0);
01123   actionMoleculeCenterView->setEnabled(view != 0);
01124   actionMoleculeResetOrientation->setEnabled(view != 0);
01125   actionMoleculeZoomFit->setEnabled(view != 0);
01126   actionMoleculeResetView->setEnabled(view != 0);
01127   actionMoleculeAnimate->setEnabled(view != 0);
01128   actionMoleculeAnimate->setOn(view != 0 && view->moleculeView()->isAnimating());
01129   //actionMoleculeFPS->setEnabled(view != 0);
01130   actionMoleculeImage->setEnabled(view != 0);
01131   actionMoleculeAddAtom->setEnabled(view != 0 && !view->isRunning());
01132   actionMoleculeDeleteSelection->setEnabled(view != 0 && view->moleculeView()->selectedAtoms() > 0);
01133   actionMoleculeAlterCartesian->setEnabled(view != 0 && !view->isRunning() && view->moleculeView()->selectedAtoms() > 0);
01134   actionMoleculeAlterInternal->setEnabled(view !=0 && !view->isRunning() && view->moleculeView()->selectedAtoms() > 1 && view->moleculeView()->selectedAtoms() < 5);
01135   actionMoleculeSelectAll->setEnabled(view != 0);
01136   actionMoleculeSelectNone->setEnabled(view != 0 && view->moleculeView()->selectedAtoms() > 0);
01137   actionMoleculeDensity->setEnabled(view != 0);
01138   actionMoleculeDisplayMode->setEnabled(view != 0);
01139   actionMoleculeSelection->setEnabled(view != 0 && view->moleculeView()->selectedAtoms() > 0);
01141   actionSetupGlobal->setEnabled(view != 0);
01142   actionSetupBrabo->setEnabled(view != 0);
01143   actionSetupRelax->setEnabled(view != 0 && view->calculationType() == GlobalBase::GeometryOptimization);
01144   actionSetupFreq->setEnabled(view != 0 && view->calculationType() == GlobalBase::Frequencies);
01145   actionSetupBuur->setEnabled(view != 0 && view->buurType() != GlobalBase::NoBuur);
01147   actionRunStart->setEnabled(view != 0 && (!view->isRunning() || view->isPaused()));
01148   actionRunStart->setOn(view != 0 && view->isRunning() && !view->isPaused());
01149   actionRunPause->setEnabled(view != 0 && view->isRunning() && !view->isPaused());
01150   actionRunPause->setOn(view != 0 && view->isPaused());
01151   actionRunStop->setEnabled(view != 0 && view->isRunning());
01152   actionRunWrite->setEnabled(view != 0);
01153   actionRunClean->setEnabled(view != 0 && !view->isRunning());
01154   actionResultsViewOutput->setEnabled(view != 0);
01155 
01157   if(view != 0)
01158     setCaption(Version::appName + " - " + view->caption());
01159   else
01160     setCaption(Version::appName);
01161 }
01162 
01164 void Xbrabo::fixToplevelModeHeight()
01169 {
01170   if(mdiMode() != QextMdi::ToplevelMode)
01171     return;
01172 
01173   QTimer::singleShot(0,this,SLOT(fixToplevelModeHeight2()));
01174   return;
01175 }
01176 
01178 void Xbrabo::fixToplevelModeHeight2()
01180 {
01181   // make sure all toolbars are in a horizontal orientation in the top (or bottom) dock.
01182   //*
01183   disconnect(ToolBarStandard, SIGNAL(placeChanged(QDockWindow::Place)), this, SLOT(fixToplevelModeHeight()));
01184   disconnect(ToolBarStandard, SIGNAL(visibilityChanged(bool)), this, SLOT(fixToplevelModeHeight()));
01185   disconnect(ToolBarCalculation, SIGNAL(placeChanged(QDockWindow::Place)), this, SLOT(fixToplevelModeHeight()));
01186   disconnect(ToolBarCalculation, SIGNAL(visibilityChanged(bool)), this, SLOT(fixToplevelModeHeight()));
01187   disconnect(ToolBarCoordinates, SIGNAL(placeChanged(QDockWindow::Place)), this, SLOT(fixToplevelModeHeight()));
01188   disconnect(ToolBarCoordinates, SIGNAL(visibilityChanged(bool)), this, SLOT(fixToplevelModeHeight()));
01189   disconnect(m_pTaskBar, SIGNAL(placeChanged(QDockWindow::Place)), this, SLOT(fixToplevelModeHeight()));
01190   disconnect(m_pTaskBar, SIGNAL(visibilityChanged(bool)), this, SLOT(fixToplevelModeHeight()));
01191   if(m_pTaskBar->orientation() == Qt::Vertical && m_pTaskBar->isVisible())
01192     moveDockWindow(m_pTaskBar);//, Qt::DockTop, true, 3);
01193   if(ToolBarStandard->orientation() == Qt::Vertical && ToolBarStandard->isVisible())
01194     moveDockWindow(ToolBarStandard);//, Qt::DockTop, true, 0);
01195   if(ToolBarCalculation->orientation() == Qt::Vertical && ToolBarCalculation->isVisible())
01196     moveDockWindow(ToolBarCalculation);//, Qt::DockTop, true, 1);
01197   if(ToolBarCoordinates->orientation() == Qt::Vertical && ToolBarCoordinates->isVisible())
01198     moveDockWindow(ToolBarCoordinates);//, Qt::DockTop, true, 2);
01199   connect(ToolBarStandard, SIGNAL(placeChanged(QDockWindow::Place)), this, SLOT(fixToplevelModeHeight()));
01200   connect(ToolBarStandard, SIGNAL(visibilityChanged(bool)), this, SLOT(fixToplevelModeHeight()));
01201   connect(ToolBarCalculation, SIGNAL(placeChanged(QDockWindow::Place)), this, SLOT(fixToplevelModeHeight()));
01202   connect(ToolBarCalculation, SIGNAL(visibilityChanged(bool)), this, SLOT(fixToplevelModeHeight()));
01203   connect(ToolBarCoordinates, SIGNAL(placeChanged(QDockWindow::Place)), this, SLOT(fixToplevelModeHeight()));
01204   connect(ToolBarCoordinates, SIGNAL(visibilityChanged(bool)), this, SLOT(fixToplevelModeHeight()));
01205   connect(m_pTaskBar, SIGNAL(placeChanged(QDockWindow::Place)), this, SLOT(fixToplevelModeHeight()));
01206   connect(m_pTaskBar, SIGNAL(visibilityChanged(bool)), this, SLOT(fixToplevelModeHeight()));
01207   // disable the vertical dockareas
01208   setDockEnabled(Qt::DockLeft, false);
01209   setDockEnabled(Qt::DockRight, false);
01210   //*/
01211   // calculate the height needed to fully show all dockwidgets
01212   // the menubar
01213   int newHeight = menuBar()->height();
01214   // the statusbar
01215   if(statusBar()->isVisible())
01216     newHeight += statusBar()->height();
01217   // the vertical QDockArea's (leftDock and rightDock) were emptied above
01218   if(!topDock()->isEmpty())
01219     newHeight += topDock()->height();
01220   if(!bottomDock()->isEmpty())
01221     newHeight += bottomDock()->height();
01222 
01223   // apply the new height and resize to the maximum allowed height
01224   setFixedHeight(newHeight);
01225   resize(width(), newHeight);
01226 }
01227 
01231 
01233 void Xbrabo::loadGeometry()
01237 {
01239   QSettings settings;
01240   settings.setPath(Version::appCompany, Version::appName.lower(), QSettings::User);
01241 #ifdef Q_OS_WIN32
01242   const QString unixPrefix = "/";
01243 #else
01244   const QString unixPrefix = "/" + Version::appName.lower() + "/";
01245 #endif
01246   const QString prefix = unixPrefix + "geometry/";
01247 
01249   int x      = settings.readNumEntry(prefix + "x", -1);
01250   int y      = settings.readNumEntry(prefix + "y", -1);
01251   int width  = settings.readNumEntry(prefix + "width", -1);
01252   int height = settings.readNumEntry(prefix + "height", -1);
01253   bool maxed = settings.readBoolEntry(prefix + "maximized", false);
01254   
01256 #ifdef Q_OS_WIN32
01257   int mdiMode = settings.readNumEntry(unixPrefix + "mdi_mode", QextMdi::ChildframeMode);
01258 #else
01259   int mdiMode = settings.readNumEntry(unixPrefix + "mdi_mode", QextMdi::ToplevelMode);
01260 #endif
01261 // */
01262 
01265   QRect screenRect = QApplication::desktop()->availableGeometry(QApplication::desktop()->primaryScreen());
01267   if((x == -1) || (y == -1) || (width == -1) || (height == -1))
01268   {
01269     width = screenRect.width()/2;
01270     height = screenRect.height()/2;
01271     x = width/2;
01272     y = height/2;
01273   }
01275   if(x < 0) x = 0;
01276   if(y < 0) y = 0;
01277   if(width > screenRect.width())
01278   {
01279     x = 0;
01280     width = screenRect.width();
01281   }
01282   if(height > screenRect.height())
01283   {
01284     y = 0;
01285     height = screenRect.height();
01286   }
01287   if((x + width) > screenRect.width())
01288     x = (screenRect.width() - width)/2; // centered
01289   if((y + height) > screenRect.height())
01290     y = (screenRect.height() - height)/2; // centered   
01292   QPoint position = QPoint(x, y);
01293   QSize size = QSize(width, height);
01294   resize(size);
01295   move(position);
01296   if(maxed)
01297     showMaximized();
01298 
01300   switch(mdiMode)
01301   {
01302     case QextMdi::ToplevelMode:   QextMdiMainFrm::switchToToplevelMode();
01303                                   break;
01304     case QextMdi::TabPageMode:    QextMdiMainFrm::switchToTabPageMode();
01305                                   break;
01306     case QextMdi::ChildframeMode:
01307     default:                      QextMdiMainFrm::switchToChildframeMode();
01308   }
01309 }
01310 
01312 void Xbrabo::initActions()
01314 {
01316   actionFileNew = new QAction(IconSets::getIconSet(IconSets::New), tr("&New"), CTRL+Key_N, this);
01317   actionFileNew->setToolTip(tr("Create a new calculation")); // also sets StatusTip
01318   actionFileNew->setWhatsThis(actionText(tr("New File"), tr("Creates a new calculation."),
01319                               tr("All calculation settings are at their default values "
01320                                  "which means a Single Point Energy calculation using RHF/MIA will be performed when "
01321                                  "starting it. Before that is possible, coordinates will have to be read in."),
01322                               IconSets::New));
01323   connect(actionFileNew, SIGNAL(activated()), this, SLOT(fileNew()));
01324 
01326   actionFileOpen = new QAction(IconSets::getIconSet(IconSets::Open), tr("&Open..."), CTRL+Key_O, this);
01327   actionFileOpen->setToolTip(tr("Open an existing calculation"));
01328   actionFileOpen->setWhatsThis(actionText(tr("Open File"), tr("Opens an existing calculation."),
01329                                tr("Any calculation saved using Brabosphere in CML-format can be opened again "
01330                                   "for further manipulation. General CML-files without the Brabosphere-specific "
01331                                   "enhancements will be rejected."),
01332                                IconSets::Open));
01333   connect(actionFileOpen, SIGNAL(activated()), this, SLOT(fileOpen()));
01334 
01336   actionFileSave = new QAction(IconSets::getIconSet(IconSets::Save), tr("&Save"), CTRL+Key_S, this);
01337   actionFileSave->setToolTip(tr("Save the calculation"));
01338   actionFileSave->setWhatsThis(actionText(tr("Save File"), tr("Saves the active calculation."),
01339                                tr("The calculation that is currently active will be saved in the Brabosphere "
01340                                   "CML format. This Chemical Markup Language format can be read by all "
01341                                   "application that support the format (e.g. CrdView). Only the cartesian "
01342                                   "coordinates will then be read, however.<br>"
01343                                   "If the calculation has not been saved yet, a new filename will be asked for."),
01344                                IconSets::Save));
01345   connect(actionFileSave, SIGNAL(activated()), this, SLOT(fileSave()));
01346 
01348   actionFileSaveAs = new QAction(QIconSet(), tr("Save &as..."), 0, this);
01349   actionFileSaveAs->setToolTip(tr("Saves the calculation under a different name..."));
01350   actionFileSaveAs->setWhatsThis(actionText(tr("Save File As"), tr("Saves the active calculation under a new name."),
01351                                  tr("The calculation that is currently active will be saved with a filename that has to be chosen.")));
01352   connect(actionFileSaveAs, SIGNAL(activated()), this, SLOT(fileSaveAs()));
01353 
01355   actionFileClose = new QAction(QIconSet(), tr("&Close"), CTRL+Key_W, this);
01356   actionFileClose->setToolTip(tr("Close the calculation"));
01357   actionFileClose->setWhatsThis(actionText(tr("Close File"), tr("Closes the active calculation."),
01358                                 tr("The calculation that is currently active will be closed. If any changes were made "
01359                                    "since the last save, the opportunity will be presented to save the calculation.")));
01360   connect(actionFileClose, SIGNAL(activated()), this, SLOT(fileClose()));
01361 
01363   actionFileQuit = new QAction(QIconSet(), tr("E&xit"), CTRL+Key_Q, this); 
01364   actionFileQuit->setToolTip(tr("Exit the application"));
01365   actionFileQuit->setWhatsThis(actionText(tr("Exit"), tr("Exits Brabosphere."),
01366                                tr("All opened calculations that have unsaved changes will be given the opportunity "
01367                                   "to be saved before exiting the application.")));
01368   connect(actionFileQuit, SIGNAL(activated()), this, SLOT(close()));
01369 
01371   actionEditCut = new QAction(IconSets::getIconSet(IconSets::Cut), tr("Cu&t"), CTRL+Key_X, this);
01372   actionEditCut->setToolTip(tr("Cut the selected text"));
01373   actionEditCut->setWhatsThis(actionText(tr("Cut"), tr("Cuts the selected text."),
01374                               tr("When invoking this command from the menu or the toolbar, only the "
01375                                  "selected text in the statuswindow of the active calculation will be "
01376                                  "copied to the clipboard. No text will be actually removed. The shortcut, "
01377                                  "however, can be used in all places were text can be given as input "
01378                                  "(e.g. Global Setup, Energy & Forces Setup, etc.).<br>"
01379                                  "This command cannot be used yet to cut selected atoms from the 3D view."),
01380                               IconSets::Cut));
01381   connect(actionEditCut, SIGNAL(activated()), this, SLOT(editCut()));
01382 
01384   actionEditCopy = new QAction(IconSets::getIconSet(IconSets::Copy), tr("&Copy"), CTRL+Key_C, this);
01385   actionEditCopy->setToolTip(tr("Copy the selected text to the clipboard"));
01386   actionEditCopy->setWhatsThis(actionText(tr("Copy"), tr("Copies the selected text."),
01387                                tr("When invoking this command from the menu or the toolbar, only the "
01388                                   "selected text in the statuswindow of the active calculation will be "
01389                                   "copied to the clipboard. It will have no effect on selected atoms in "
01390                                   "the 3D view (although this behaviour is subject to change). "
01391                                   "The shortcut can be used in all places were text can be given as input "
01392                                   "(e.g. Global Setup, Energy & Forces Setup, etc.).<br>"),
01393                                IconSets::Copy));
01394   connect(actionEditCopy, SIGNAL(activated()), this, SLOT(editCopy()));
01395 
01397   actionEditPaste = new QAction(IconSets::getIconSet(IconSets::Paste), tr("&Paste"), CTRL+Key_V, this);
01398   actionEditPaste->setToolTip(tr("Paste the contents of the clipboard"));
01399   actionEditPaste->setWhatsThis(actionText(tr("Paste"), tr("Pastes the contents of the clipboard."),
01400                                 tr("When invoking this command from the menu or the toolbar, nothing will "
01401                                    "happen at the moment as it has no influence on the 3D view yet. "
01402                                    "The shortcut can, however, be used in all places were text can be given as input "
01403                                    "(e.g. Global Setup, Energy & Forces Setup, etc.).<br>"),
01404                                 IconSets::Paste));
01405   connect(actionEditPaste, SIGNAL(activated()), this, SLOT(editPaste()));
01406 
01408   actionEditPrefs = new QAction(IconSets::getIconSet(IconSets::Prefs), tr("P&references..."), 0, this);  
01409   actionEditPrefs->setToolTip(tr("Configure your preferences"));
01410   actionEditPrefs->setWhatsThis(actionText(tr("Edit Preferences"), tr("Allows editing of the program's preferences."),
01411                                 tr("This command opens up a new window where the behaviour and visuals "
01412                                    "of Brabosphere can be adapted to your liking."),
01413                                 IconSets::Prefs));
01414   connect(actionEditPrefs, SIGNAL(activated()), this, SLOT(editPrefs()));
01415 
01417   actionViewToolBarStandard = new QAction(QIconSet(), tr("&Standard"), 0, this);
01418   actionViewToolBarStandard->setToolTip(tr("Toggle the visibility of the Standard toolbar"));
01419   actionViewToolBarStandard->setToggleAction(true);
01420   actionViewToolBarStandard->setWhatsThis(actionText(tr("View Standard Toolbar"), tr("Toggles the visibility of the Standard toolbar."),
01421                                           tr("This is the toolbar containing shortcuts to selected entries in "
01422                                              "the File, Edit and Help menus.")));
01423   connect(actionViewToolBarStandard, SIGNAL(activated()), this, SLOT(viewToolBarStandard()));
01424 
01426   actionViewToolBarCalculation = new QAction(QIconSet(), tr("&Calculation"), 0, this);
01427   actionViewToolBarCalculation->setToolTip(tr("Toggle the visibility of the Calculation toolbar"));
01428   actionViewToolBarCalculation->setToggleAction(true);
01429   actionViewToolBarCalculation->setWhatsThis(actionText(tr("View Calculation Toolbar"), tr("Toggles the visibility of the Calculation toolbar."),
01430                                              tr("This is the toolbar containing shortcuts to selected entries in "
01431                                                 "the Setup and Run menus.")));
01432   connect(actionViewToolBarCalculation, SIGNAL(activated()), this, SLOT(viewToolBarCalculation()));
01433 
01435   actionViewToolBarCoordinates = new QAction(QIconSet(), tr("&Molecule"), 0, this);
01436   actionViewToolBarCoordinates->setToolTip(tr("Toggle the visibility of the Molecule toolbar"));
01437   actionViewToolBarCoordinates->setToggleAction(true);
01438   actionViewToolBarCoordinates->setWhatsThis(actionText(tr("View Molecule Toolbar"), tr("Toggles the visibility of the Molecule toolbar."),
01439                                              tr("This is the toolbar containing shortcuts to selected entries in "
01440                                                 "the Molecule menu.")));
01441   connect(actionViewToolBarCoordinates, SIGNAL(activated()), this, SLOT(viewToolBarCoordinates()));
01442 
01444   actionViewStatusBar = new QAction(QIconSet(), tr("&Statusbar"), 0, this);
01445   actionViewStatusBar->setToolTip(tr("Toggle the visibility of the statusbar"));
01446   actionViewStatusBar->setToggleAction(true);
01447   actionViewStatusBar->setWhatsThis(actionText(tr("View Statusbar"), tr("Toggles the visibility of the statusbar."),
01448                                     tr("This is de toolbar at the bottom of the main window which displays temporary messages.")));
01449   connect(actionViewStatusBar, SIGNAL(activated()), this, SLOT(viewStatusBar()));
01450 
01452   actionViewTaskBar = new QAction(QIconSet(), tr("T&askbar"), 0, this);
01453   actionViewTaskBar->setToolTip(tr("Toggle the visibility of the taskbar"));
01454   actionViewTaskBar->setToggleAction(true);
01455   actionViewTaskBar->setWhatsThis(actionText(tr("View Taskbar"), tr("Toggles the visibility of the taskbar."),
01456                                   tr("This is de toolbar providing a means for quickly switching between calculations. " 
01457                                      "It is only visible when at least 2 calculations are opened.")));
01458   connect(actionViewTaskBar, SIGNAL(activated()), this, SLOT(viewTaskBar()));
01459 
01461   actionMoleculeReadCoordinates = new QAction(IconSets::getIconSet(IconSets::MoleculeRead), tr("Read &coordinates..."), 0, this);
01462   actionMoleculeReadCoordinates->setToolTip(tr("Read new coordinates"));
01463   actionMoleculeReadCoordinates->setWhatsThis(actionText(tr("Read Coordinates"), tr("Reads a new set of coordinates from a file."),
01464                                               tr("The existing coordinates will be removed together with selections, forces, charges "
01465                                                  "and other properties. The view of the 3D scene will be reset completely. "
01466                                                  "This command is only available when no calculation is running."),
01467                                               IconSets::MoleculeRead));
01468   connect(actionMoleculeReadCoordinates, SIGNAL(activated()), this, SLOT(moleculeReadCoordinates()));
01469 
01471   actionMoleculeCenterView = new QAction(QIconSet(), tr("&Translation"), 0, this);
01472   actionMoleculeCenterView->setToolTip(tr("Center the molecule"));
01473   actionMoleculeCenterView->setWhatsThis(actionText(tr("Reset Translation"), tr("Restores the center of the molecule to the center of the 3D scene.")));
01474   connect(actionMoleculeCenterView, SIGNAL(activated()), this, SLOT(moleculeCenterView()));
01475 
01477   actionMoleculeResetOrientation = new QAction(QIconSet(), tr("&Orientation"), 0, this);
01478   actionMoleculeResetOrientation->setToolTip(tr("Reset the orientation of the molecule"));
01479   actionMoleculeResetOrientation->setWhatsThis(actionText(tr("Reset Orientation"), tr("Resets the rotational axes of the molecule."),
01480                                                tr("After the reset, the X-axis will again point to the right, "
01481                                                   "the Y-axis to the top and the Z-axis into the screen.")));
01482   connect(actionMoleculeResetOrientation, SIGNAL(activated()), this, SLOT(moleculeResetOrientation()));
01483 
01485   actionMoleculeZoomFit = new QAction(QIconSet(), tr("&Zoom"), 0, this);
01486   actionMoleculeZoomFit->setToolTip(tr("Zoom such that the molecule fits in the window"));
01487   actionMoleculeZoomFit->setWhatsThis(actionText(tr("Reset Zoom"), tr("Zooms the scene such that the molecule fits exactly in the window.")));
01488   connect(actionMoleculeZoomFit, SIGNAL(activated()), this, SLOT(moleculeZoomFit()));
01489 
01491   actionMoleculeResetView = new QAction(QIconSet(), tr("&View"), 0, this);
01492   actionMoleculeResetView->setToolTip(tr("Reset translation, orientation and zoom"));
01493   actionMoleculeResetView->setWhatsThis(actionText(tr("Reset View"), tr("Resets the translation, orientation and zoom of the molecule.")));
01494   connect(actionMoleculeResetView, SIGNAL(activated()), this, SLOT(moleculeResetView()));
01495 
01497   actionMoleculeAnimate = new QAction(IconSets::getIconSet(IconSets::MoleculeAnimate), tr("&Animate"), 0, this);  
01498   actionMoleculeAnimate->setToolTip(tr("Toggle the use of animation"));
01499   actionMoleculeAnimate->setToggleAction(true);
01500   actionMoleculeAnimate->setWhatsThis(actionText(tr("Animate Molecule"), tr("Toggles the use of animation."),
01501                                       tr("When the molecule is being animated through automated rotation around "
01502                                          "all axes, the direction and speed can be influenced by using the proper "
01503                                          "manipulations (mouse or keyboard) for the rotations around those axes."),
01504                                       IconSets::MoleculeAnimate));
01505   connect(actionMoleculeAnimate, SIGNAL(activated()), this, SLOT(moleculeAnimate()));
01506 
01507   // still allow FPS calculations, but only using a shortcut key
01508   actionMoleculeFPS = new QAction(QIconSet(), tr("Calculate &FPS"), CTRL+ALT+Key_F, this);  
01509   actionMoleculeFPS->setText(tr("Calculate the maximum attainable framerate"));
01510   connect(actionMoleculeFPS, SIGNAL(activated()), this, SLOT(moleculeFPS()));
01511 
01513   actionMoleculeImage = new QAction(IconSets::getIconSet(IconSets::Image), tr("&Save image..."), 0, this);
01514   actionMoleculeImage->setToolTip(tr("Save the current view as an image"));
01515   actionMoleculeImage->setWhatsThis(actionText(tr("Save Image"), tr("Saves the current view of the scene as an image."),
01516                                     tr("A number of fileformats can be chosen for the resulting file, "
01517                                        "but the size of the image will be determined by the size of the scene's window."),
01518                                     IconSets::Image));
01519   connect(actionMoleculeImage, SIGNAL(activated()), this, SLOT(moleculeImage()));
01520 
01522   actionMoleculeAddAtom = new QAction(QIconSet(), tr("&Add atoms..."), 0, this);
01523   actionMoleculeAddAtom->setToolTip(tr("Add atoms to the molecule"));
01524   actionMoleculeAddAtom->setWhatsThis(actionText(tr("Add Atoms"), tr("Allows addition of atoms to the molecule."),
01525                                       tr("This command opens up a window allowing the addition of any number "
01526                                          "and type of atom by positioning it using either cartesian (absolute or relative) "
01527                                          "or internal coordinates. This command is not available when a calculation is running")));
01528   connect(actionMoleculeAddAtom, SIGNAL(activated()), this, SLOT(moleculeAddAtoms()));
01529 
01531   actionMoleculeDeleteSelection = new QAction(QIconSet(), tr("&Delete selected atoms..."), Qt::Key_Delete, this);
01532   actionMoleculeDeleteSelection->setToolTip(tr("Remove the selected atoms"));
01533   actionMoleculeDeleteSelection->setWhatsThis(actionText(tr("Delete Selected Atoms"), tr("Deletes the selected atoms."),
01534                                               tr("This command is not available when no atoms are selected or when "
01535                                                  "a calculation is running.")));
01536   connect(actionMoleculeDeleteSelection, SIGNAL(activated()), this, SLOT(moleculeDeleteSelection()));
01537 
01539   actionMoleculeDensity = new QAction(QIconSet(), tr("Density &isosurfaces..."), 0, this);
01540   actionMoleculeDensity->setToolTip(tr("Change the density isosurfaces"));
01541   actionMoleculeDensity->setWhatsThis(actionText(tr("Density Isosurfaces"), tr("Allows changing the density isosurfaces."),
01542                                       tr("This command opens a window where up to 2 density (cube) files "
01543                                          "can be loaded and any number of isosurfaces can be defined. "
01544                                          "Loaded density files and generated isosurfaces are not saved with "
01545                                          "the calculation.")));
01546   connect(actionMoleculeDensity, SIGNAL(activated()), this, SLOT(moleculeDensity()));
01547 
01549   actionMoleculeDisplayMode = new QAction(QIconSet(), tr("&Display mode..."), 0, this);
01550   actionMoleculeDisplayMode->setToolTip(tr("Change the display mode of the molecule"));
01551   actionMoleculeDisplayMode->setWhatsThis(actionText(tr("Display Mode"), tr("Changes the local display mode of the molecule."),
01552                                           tr("In the program's preferences, the default rendering type for "
01553                                              "atoms, bonds, forces and labels can be set for all calculations. "
01554                                              "This command opens up a window where these settings can be changed "
01555                                              "for the current molecule only.")));
01556   connect(actionMoleculeDisplayMode, SIGNAL(activated()), this, SLOT(moleculeDisplayMode()));
01557 
01559   actionMoleculeAlterCartesian = new QAction(QIconSet(), tr("&Cartesian coordinates..."), 0, this);
01560   actionMoleculeAlterCartesian->setToolTip(tr("Alter the cartesian coordinates of the selected atoms"));
01561   actionMoleculeAlterCartesian->setWhatsThis(actionText(tr("Alter Cartesian Coordinates"), tr("Alters the cartesian coordinates of the selected atoms."),
01562                                               tr("Although changing the cartesian coordinates of the selected atoms "
01563                                                  "can be done by the proper mouse or keyboard manipulations, they can "
01564                                                  "not be used for precise changes. This command shows a window where "
01565                                                  "an exact position can be given in case of a single atom selection, "
01566                                                  "or a change in relative position in case of a multiatom selection. "
01567                                                  "It is not available when a calculation is running or no atoms are selected.")));
01568   connect(actionMoleculeAlterCartesian, SIGNAL(activated()), this, SLOT(moleculeAlterCartesian()));
01569 
01571   actionMoleculeAlterInternal = new QAction(QIconSet(), tr("&Internal coordinate..."), 0, this);
01572   actionMoleculeAlterInternal->setToolTip(tr("Alter the internal coordinate specified by the selected atoms."));
01573   actionMoleculeAlterInternal->setWhatsThis(actionText(tr("Alter Internal Coordinate"), tr("Alters the internal coordinate of the selected atoms."),
01574                                             tr("Although changing the internal coordinate of the selected atoms "
01575                                                "can be done by the proper mouse or keyboard manipulations, they can "
01576                                                "not be used for precise changes. When exactly 2, 3 or 4 atoms are selected, "
01577                                                "this command allows giving an exact value for the resulting bond, valence "
01578                                                "angle or torsion angle. This command is not available when the correct number "
01579                                                "of atoms is not selected or when a calculation is running.")));
01580   connect(actionMoleculeAlterInternal, SIGNAL(activated()), this, SLOT(moleculeAlterInternal()));
01581 
01583   actionMoleculeSelectAll = new QAction(QIconSet(), tr("&All"), Qt::CTRL + Qt::Key_A, this);
01584   actionMoleculeSelectAll->setToolTip(tr("Select all atoms"));
01585   actionMoleculeSelectAll->setWhatsThis(actionText(tr("Select All"), tr("Selects all atoms.")));
01586   connect(actionMoleculeSelectAll, SIGNAL(activated()), this, SLOT(moleculeSelectAll()));
01587 
01589   actionMoleculeSelectNone = new QAction(QIconSet(), tr("&None"), Qt::CTRL + Qt::SHIFT + Qt::Key_A, this);
01590   actionMoleculeSelectNone->setToolTip(tr("Deselect all atoms"));
01591   actionMoleculeSelectNone->setWhatsThis(actionText(tr("Select None"), tr("Deselects all atoms.")));
01592   connect(actionMoleculeSelectNone, SIGNAL(activated()), this, SLOT(moleculeSelectNone()));
01593 
01595   actionMoleculeSaveCoordinates = new QAction(IconSets::getIconSet(IconSets::MoleculeSave), tr("Save c&oordinates..."), 0, this);
01596   actionMoleculeSaveCoordinates->setToolTip(tr("Save the coordinates"));
01597   actionMoleculeSaveCoordinates->setWhatsThis(actionText(tr("Save Coordinates"), tr("Saves the molecule to a file."),
01598                                               tr("Shows a window allowing the coordinates to be saved in a variety of formats"),
01599                                               IconSets::MoleculeSave));
01600   connect(actionMoleculeSaveCoordinates, SIGNAL(activated()), this, SLOT(moleculeSaveCoordinates()));
01601 
01603   actionMoleculeSelection = new QAction(IconSets::getIconSet(IconSets::MoleculeSelection), tr("&Manipulate selection..."), 0, this);
01604   actionMoleculeSelection->setToolTip(tr("Toggle between manipulating the selected atoms and the entire system"));
01605   actionMoleculeSelection->setToggleAction(true); 
01606   actionMoleculeSelection->setWhatsThis(actionText(tr("Manipulate Selection"), tr("Toggles between manipulating the selected atoms and the entire system."),
01607                                         tr("By using the proper manipulation with mouse or keyboard, the 3D translation, "
01608                                            "rotation can be changed. When a selection is present, the same changes can be "
01609                                            "applied to the selected atoms alone using the additional <em>Aly</em> modifier key. "
01610                                            "On some systems (e.g. KDE) this key is already bound to other functionality and "
01611                                            "cannot be used. This command acts like a sticky <em>Alt</em> key: As long as it is "
01612                                            "activated, all manipulations will act on the selected atoms, regardless of the use "
01613                                            "of the <em>Alt</em> modifier."),
01614                                         IconSets::MoleculeSelection));
01615   connect(actionMoleculeSelection, SIGNAL(activated()), this, SLOT(moleculeSelection()));
01616 
01618   actionSetupGlobal = new QAction(IconSets::getIconSet(IconSets::SetupGlobal), tr("&Global..."), Key_F2, this);
01619   actionSetupGlobal->setToolTip(tr("Setup global options"));
01620   actionSetupGlobal->setWhatsThis(actionText(tr("Global Setup"), tr("Allows setting up the type of calculation."),
01621                                   tr("Depending on the type of calculation chosen, extra setup windows will "
01622                                      "become available. The global setup cannot be changed when a calculation "
01623                                      "is running."),
01624                                    IconSets::SetupGlobal));
01625   connect(actionSetupGlobal, SIGNAL(activated()), this, SLOT(setupGlobal()));
01626 
01628   actionSetupBrabo = new QAction(IconSets::getIconSet(IconSets::SetupBrabo), tr("&Energy && Forces..."), Key_F3, this);
01629   actionSetupBrabo->setToolTip(tr("Setup energy & forces"));
01630   actionSetupBrabo->setWhatsThis(actionText(tr("Energy & Forces Setup"), tr("Allows setting up all aspects of the calculation of the energy and forces."),
01631                                  tr("An interface is provided for easily changing the common options, but experts can use the "
01632                                     "'Extra' tables for each section of the input file for providing new or other options not covered. "
01633                                     "From the settings an input file will be generated which can be checked before accepting the changes. "
01634                                     "Even during the run of a calculation all settings can be changed. They will come into effect "
01635                                     "the next  time an energy evaluation is started."),
01636                                  IconSets::SetupBrabo));
01637   connect(actionSetupBrabo, SIGNAL(activated()), this, SLOT(setupBrabo()));
01638 
01640   actionSetupRelax = new QAction(IconSets::getIconSet(IconSets::SetupRelax), tr("Geometry &Optimization..."), Key_F4, this);
01641   actionSetupRelax->setToolTip(tr("Setup geometry optimization"));
01642   actionSetupRelax->setWhatsThis(actionText(tr("Geometry Optimization Setup"), tr("Allows setting up all aspects of the geometry optimization procedure."),
01643                                  tr("An interface is provided for easily changing the common options, but experts can use the "
01644                                     "'Extra' table for providing new or other options not covered. "
01645                                     "From the settings an input file will be generated which can be checked before accepting the changes. "
01646                                     "Even during the run of a calculation all settings can be changed. They will come into effect "
01647                                     "the next  time an optimization step is started."),
01648                                  IconSets::SetupRelax));
01649   connect(actionSetupRelax, SIGNAL(activated()), this, SLOT(setupRelax()));
01650 
01652   actionSetupFreq = new QAction(IconSets::getIconSet(IconSets::SetupFreq), tr("&Frequencies..."), Key_F5, this);
01653   actionSetupFreq->setText(tr("Setup frequencies"));
01654   connect(actionSetupFreq, SIGNAL(activated()), this, SLOT(setupFreq()));
01655 
01657   actionSetupBuur = new QAction(IconSets::getIconSet(IconSets::SetupBuur), tr("&Crystal..."), Key_F6, this);  
01658   actionSetupBuur->setText(tr("Setup crystal"));
01659   connect(actionSetupBuur, SIGNAL(activated()), this, SLOT(setupBuur()));
01660 
01662   actionRunStart = new QAction(IconSets::getIconSet(IconSets::Start), tr("S&tart"), Key_F9, this);
01663   actionRunStart->setToolTip(tr("Start the calculation"));
01664   actionRunStart->setToggleAction(true);
01665   actionRunStart->setWhatsThis(actionText(tr("Start Calculation"), tr("Starts a calculation."),
01666                                tr("A running calculation that is paused can be continued in the same way. "),
01667                                IconSets::Start));                                            
01668   connect(actionRunStart, SIGNAL(activated()), this, SLOT(runStart()));
01669 
01671   actionRunPause = new QAction(IconSets::getIconSet(IconSets::Pause), tr("&Pause"), Key_F10, this);
01672   actionRunPause->setToolTip(tr("Pause the calculation"));
01673   actionRunPause->setToggleAction(true);
01674   actionRunPause->setWhatsThis(actionText(tr("Pause Calculation"), tr("Pauses a running calculation."),
01675                                tr("When the calculation is already paused, it can be continued with this command. "
01676                                   "Only when the calculation is neither running nor paused, this command is not available. "
01677                                   "When pausing a calculation, it will be effectively paused when the current step "
01678                                   "(energy evaluation, charge calculation, optimization, etc.) has ended. Single Point "
01679                                   "Energy calculations cannot be paused as they consist of only one step."),
01680                                IconSets::Pause));
01681   connect(actionRunPause, SIGNAL(activated()), this, SLOT(runPause()));
01682 
01684   actionRunStop = new QAction(IconSets::getIconSet(IconSets::Stop), tr("&Stop..."), Key_F11, this);
01685   actionRunStop->setToolTip(tr("Stop the calculation"));
01686   actionRunStop->setWhatsThis(actionText(tr("Stop Calculation"), tr("Stops a running calculation."),
01687                               tr("The question will be asked whether to stop immediately or after the current step "
01688                                  "has ended. Stopping immediately will kill the running process."),
01689                               IconSets::Stop));
01690   connect(actionRunStop, SIGNAL(activated()), this, SLOT(runStop()));
01691 
01693   actionRunWrite = new QAction(IconSets::getIconSet(IconSets::Write), tr("&Write input"), 0, this);
01694   actionRunWrite->setToolTip(tr("Write the input files"));
01695   actionRunWrite->setWhatsThis(actionText(tr("Write Input Files"), tr("Writes all input files."),
01696                                tr("Although all needed input files are written at the start of a calculation and "
01697                                   "everytime the setup is being changed during the run, the input file for the evaluation "
01698                                   "of energy and forces is not written. This command can thus be used to get this and "
01699                                   "other files without having to start a calculation. They can then be used to start the "
01700                                   "calculation outside of the program, for example."),
01701                                IconSets::Write));
01702   connect(actionRunWrite, SIGNAL(activated()), this, SLOT(runWrite()));        
01703 
01705   actionRunClean = new QAction(IconSets::getIconSet(IconSets::Clean), tr("&Clean directory..."), 0, this);
01706   actionRunClean->setToolTip(tr("Clean the calculation directory"));
01707   actionRunClean->setWhatsThis(actionText(tr("Clean Directory"), tr("Cleans up the calculation directory."),
01708                                tr("All files pertaining to the calculation will be removed, including (saved) in- and output files, "
01709                                   "binary files, starting vectors, fortran files and others."),
01710                                IconSets::Clean));
01711   connect(actionRunClean, SIGNAL(activated()), this, SLOT(runClean()));
01712   
01714   actionResultsViewOutput = new QAction(IconSets::getIconSet(IconSets::Outputs), tr("&View results..."), Key_F12, this);
01715   actionResultsViewOutput->setToolTip(tr("View the output file(s)"));
01716   actionResultsViewOutput->setWhatsThis(actionText(tr("View Results"), tr("Shows the output file(s)."),
01717                                         tr("A table will be shown with all output files that were found in the calculation "
01718                                            "directory. They can subsequently be visualized."),
01719                                         IconSets::Outputs));
01720   connect(actionResultsViewOutput, SIGNAL(activated()), this, SLOT(resultsViewOutput()));
01721 
01723   actionToolsPlotMap = new QAction(QIconSet(), tr("Show &density map..."), 0, this);
01724   actionToolsPlotMap->setToolTip(tr("Show a 2D density map"));
01725   actionToolsPlotMap->setWhatsThis(actionText(tr("Show Density Map"), tr("Shows generated density maps."),
01726                                    tr("A window will be shown allowing loading and analysis of density map files "
01727                                       "(extension .map.1). A number of visualization options are available and the "
01728                                       "resulting image can be exported to a file.")));
01729   connect(actionToolsPlotMap, SIGNAL(activated()), this, SLOT(toolsPlotMap()));
01730 
01732   actionToolsOrbitals = new QAction(QIconSet(), tr("Show &orbitals..."), 0, this);
01733   actionToolsOrbitals->setToolTip(tr("Show 3D orbitals"));
01734   actionToolsOrbitals->setWhatsThis(actionText(tr("Show Orbitals"), tr("Shows orbitals of hydrogen-like atoms."),
01735                                     tr("These orbitals are calculated analytically and shown in a 3D scene much like "
01736                                        "the 3D scene of a calculation (and allowing similar manipulations). "
01737                                        "Quantum numbers, colors and rendering types can be adjusted. ")));
01738   connect(actionToolsOrbitals, SIGNAL(activated()), this, SLOT(toolsOrbitals()));  
01739 
01741   actionHelp = new QAction(IconSets::getIconSet(IconSets::Help), tr("Contents..."), Qt::Key_F1, this);
01742   actionHelp->setToolTip(tr("Shows useful info"));
01743   actionHelp->setWhatsThis(actionText(tr("Contents of Help"), tr("Shows a brief explanation of the program and the use of the context-sensitive help system."),
01744                            QString::null, IconSets::Help));
01745   connect(actionHelp, SIGNAL(activated()), this, SLOT(helpHelp()));
01746 
01748   actionWhatsThis = new QAction(IconSets::getIconSet(IconSets::WhatsThis), tr("Context sensitive help..."), Qt::SHIFT + Qt::Key_F1, this);
01749   actionWhatsThis->setToolTip(tr("Shows context sensitive help"));
01750   actionWhatsThis->setWhatsThis(actionText(tr("Context Sensitive Help"), tr("Well, if you are reading this, you already know how this thing works!."),
01751                            QString::null, IconSets::WhatsThis));
01752   connect(actionWhatsThis, SIGNAL(activated()), this, SLOT(helpWhatsThis()));
01753 
01755   actionCredits = new QAction(QIconSet(), tr("Credits..."), 0, this);
01756   actionCredits->setToolTip(tr("Shows some credits"));
01757   actionCredits->setWhatsThis(actionText(tr("Credits"), tr("Shows a window where some credit is given to the developers of the building blocks of this program.")));
01758   connect(actionCredits, SIGNAL(activated()), this, SLOT(helpCredits()));
01759 
01761   actionAbout = new QAction(QIconSet(), tr("About..."), 0, this);
01762   actionAbout->setToolTip(tr("Shows an About box"));
01763   actionAbout->setWhatsThis(actionText(tr("About"), tr("Gives some info about") + " " + Version::appName + ".",
01764                             tr("It is the same window you see flashing by when starting the application")));
01765   connect(actionAbout, SIGNAL(activated()), this, SLOT(helpAbout()));
01766 }
01767 
01769 void Xbrabo::initMenuBar()
01771 {  
01773   QPopupMenu* fileMenu = new QPopupMenu();
01774   actionFileNew->addTo(fileMenu);
01775   actionFileOpen->addTo(fileMenu);
01776   fileMenu->insertSeparator();
01777   actionFileSave->addTo(fileMenu);
01778   actionFileSaveAs->addTo(fileMenu);
01779   actionFileClose->addTo(fileMenu);
01780   fileMenu->insertSeparator();
01781   actionFileQuit->addTo(fileMenu);
01782 
01784   QPopupMenu* editMenu=new QPopupMenu();
01785   actionEditCut->addTo(editMenu);
01786   actionEditCopy->addTo(editMenu);
01787   actionEditPaste->addTo(editMenu);
01788   editMenu->insertSeparator();
01789   actionEditPrefs->addTo(editMenu);
01790 
01792   QPopupMenu* viewMenu = new QPopupMenu();
01793   viewMenu->setCheckable(true);
01794     QPopupMenu* toolbarMenu = new QPopupMenu(viewMenu);
01795     toolbarMenu->setCheckable(true);
01796     actionViewToolBarStandard->addTo(toolbarMenu);
01797     actionViewToolBarCalculation->addTo(toolbarMenu);
01798     actionViewToolBarCoordinates->addTo(toolbarMenu);
01799   viewMenu->insertItem(tr("&Toolbars"), toolbarMenu);
01800   actionViewStatusBar->addTo(viewMenu);
01801   actionViewTaskBar->addTo(viewMenu);
01802 
01804   QPopupMenu* moleculeMenu = new QPopupMenu();
01805   actionMoleculeReadCoordinates->addTo(moleculeMenu);
01806   actionMoleculeSaveCoordinates->addTo(moleculeMenu);
01807   actionMoleculeAddAtom->addTo(moleculeMenu);
01808   actionMoleculeDeleteSelection->addTo(moleculeMenu);
01809   QPopupMenu* alterMenu = new QPopupMenu();
01810     actionMoleculeAlterCartesian->addTo(alterMenu);
01811     actionMoleculeAlterInternal->addTo(alterMenu);
01812     moleculeMenu->insertItem(tr("A&lter"), alterMenu);
01813   QPopupMenu* selectMenu = new QPopupMenu();
01814     actionMoleculeSelectAll->addTo(selectMenu);
01815     actionMoleculeSelectNone->addTo(selectMenu);
01816     moleculeMenu->insertItem(tr("&Select"), selectMenu);
01817   actionMoleculeSelection->addTo(moleculeMenu);
01818   moleculeMenu->insertSeparator();
01819   actionMoleculeDisplayMode->addTo(moleculeMenu);
01820   actionMoleculeDensity->addTo(moleculeMenu);
01821   actionMoleculeAnimate->addTo(moleculeMenu);
01822   //actionMoleculeFPS->addTo(moleculeMenu);
01823   actionMoleculeImage->addTo(moleculeMenu);  
01824   QPopupMenu* resetMenu = new QPopupMenu();
01825     actionMoleculeCenterView->addTo(resetMenu);
01826     actionMoleculeResetOrientation->addTo(resetMenu);
01827     actionMoleculeZoomFit->addTo(resetMenu);
01828     actionMoleculeResetView->addTo(resetMenu);    
01829     moleculeMenu->insertItem(tr("&Reset"), resetMenu);
01830 
01832   QPopupMenu* setupMenu = new QPopupMenu();
01833   actionSetupGlobal->addTo(setupMenu);
01834   setupMenu->insertSeparator();
01835   actionSetupBrabo->addTo(setupMenu);
01836   actionSetupRelax->addTo(setupMenu);
01837   //actionSetupFreq->addTo(setupMenu);
01838   //actionSetupBuur->addTo(setupMenu);  
01839 
01841   QPopupMenu* runMenu = new QPopupMenu();
01842   actionRunStart->addTo(runMenu);
01843   actionRunPause->addTo(runMenu);
01844   actionRunStop->addTo(runMenu);
01845   actionRunWrite->addTo(runMenu);
01846   actionRunClean->addTo(runMenu);
01847   runMenu->insertSeparator();
01848   actionResultsViewOutput->addTo(runMenu);
01849   
01851   //resultsMenu = new QPopupMenu();
01852   //actionResultsViewOutput->addTo(resultsMenu);
01853 
01855   QPopupMenu* toolsMenu = new QPopupMenu();
01856   actionToolsPlotMap->addTo(toolsMenu);
01857   actionToolsOrbitals->addTo(toolsMenu);
01858     
01860   QPopupMenu* helpMenu = new QPopupMenu();
01861   actionHelp->addTo(helpMenu);
01862   actionWhatsThis->addTo(helpMenu);
01863   actionCredits->addTo(helpMenu);
01864   actionAbout->addTo(helpMenu);
01865 
01867   menuBar()->insertItem(tr("&File"), fileMenu);
01868   menuBar()->insertItem(tr("&Edit"), editMenu);
01869   menuBar()->insertItem(tr("&View"), viewMenu);
01870   menuBar()->insertItem(tr("&Molecule"), moleculeMenu);
01871   menuBar()->insertItem(tr("&Setup"), setupMenu);
01872   menuBar()->insertItem(tr("&Run"), runMenu);
01873   //menuBar()->insertItem(tr("Res&ults"), resultsMenu);
01874   menuBar()->insertItem(tr("&Tools"), toolsMenu);
01875   menuBar()->insertItem(tr("&Window"), windowMenu());
01876   menuBar()->insertItem(tr("&Help"), helpMenu);
01877 
01879   setMenuForSDIModeSysButtons( menuBar());
01880 }
01881 
01883 void Xbrabo::initToolBars()
01885 {  
01887   ToolBarStandard = new QToolBar(this);
01888   ToolBarStandard->hide();
01889   ToolBarStandard->setLabel(tr("Standard"));
01890   actionFileNew->addTo(ToolBarStandard);
01891   actionFileOpen->addTo(ToolBarStandard);
01892   actionFileSave->addTo(ToolBarStandard);
01893   ToolBarStandard->addSeparator();
01894   actionEditCut->addTo(ToolBarStandard);
01895   actionEditCopy->addTo(ToolBarStandard);
01896   actionEditPaste->addTo(ToolBarStandard);
01897   ToolBarStandard->addSeparator();
01898   actionEditPrefs->addTo(ToolBarStandard);  
01899   ToolBarStandard->addSeparator();
01900   actionHelp->addTo(ToolBarStandard);
01901   actionWhatsThis->addTo(ToolBarStandard);
01902 
01904   ToolBarCalculation = new QToolBar(this);
01905   ToolBarCalculation->hide();
01906   ToolBarCalculation->setLabel(tr("Calculation"));
01907   actionSetupGlobal->addTo(ToolBarCalculation);
01908   ToolBarCalculation->addSeparator();
01909   actionSetupBrabo->addTo(ToolBarCalculation);
01910   actionSetupRelax->addTo(ToolBarCalculation);
01911   //actionSetupFreq->addTo(ToolBarCalculation);
01912   //actionSetupBuur->addTo(ToolBarCalculation);  
01913   ToolBarCalculation->addSeparator();
01914   actionRunStart->addTo(ToolBarCalculation);
01915   actionRunPause->addTo(ToolBarCalculation);
01916   actionRunStop->addTo(ToolBarCalculation);
01917   ToolBarCalculation->addSeparator();
01918   actionResultsViewOutput->addTo(ToolBarCalculation);
01919   
01921   ToolBarCoordinates = new QToolBar(this);
01922   ToolBarCoordinates->hide();
01923   ToolBarCoordinates->setLabel(tr("Molecule"));
01924   actionMoleculeReadCoordinates->addTo(ToolBarCoordinates);
01925   actionMoleculeSaveCoordinates->addTo(ToolBarCoordinates);
01926   actionMoleculeSelection->addTo(ToolBarCoordinates);
01927   actionMoleculeAnimate->addTo(ToolBarCoordinates);
01928   actionMoleculeImage->addTo(ToolBarCoordinates);
01929 
01931   ToolBarStandard->show();
01932   ToolBarCalculation->show();
01933   ToolBarCoordinates->show();
01934 
01936   m_pTaskBar->setLabel(tr("Taskbar"));
01937 
01939   //connect(ToolBarStandard, SIGNAL(orientationChanged(Orientation)), this, SLOT(fixToplevelModeHeight()));
01940   connect(ToolBarStandard, SIGNAL(placeChanged(QDockWindow::Place)), this, SLOT(fixToplevelModeHeight()));
01941   connect(ToolBarStandard, SIGNAL(visibilityChanged(bool)), this, SLOT(fixToplevelModeHeight()));
01942   //connect(ToolBarCalculation, SIGNAL(orientationChanged(Orientation)), this, SLOT(fixToplevelModeHeight()));
01943   connect(ToolBarCalculation, SIGNAL(placeChanged(QDockWindow::Place)), this, SLOT(fixToplevelModeHeight()));
01944   connect(ToolBarCalculation, SIGNAL(visibilityChanged(bool)), this, SLOT(fixToplevelModeHeight()));
01945   //connect(ToolBarCoordinates, SIGNAL(orientationChanged(Orientation)), this, SLOT(fixToplevelModeHeight()));
01946   connect(ToolBarCoordinates, SIGNAL(placeChanged(QDockWindow::Place)), this, SLOT(fixToplevelModeHeight()));
01947   connect(ToolBarCoordinates, SIGNAL(visibilityChanged(bool)), this, SLOT(fixToplevelModeHeight()));
01948   //connect(m_pTaskBar, SIGNAL(orientationChanged(Orientation)), this, SLOT(fixToplevelModeHeight()));
01949   connect(m_pTaskBar, SIGNAL(placeChanged(QDockWindow::Place)), this, SLOT(fixToplevelModeHeight()));
01950   connect(m_pTaskBar, SIGNAL(visibilityChanged(bool)), this, SLOT(fixToplevelModeHeight()));
01951 }
01952 
01954 void Xbrabo::updatePreferences()
01957 {  
01959   BraboBase::setPreferredBasisset(editPreferences->preferredBasisset());
01960 
01962   GLView::setParameters(editPreferences->getGLBaseParameters());
01963 
01965   GLSimpleMoleculeView::setParameters(editPreferences->getGLMoleculeParameters());
01966 }
01967 
01969 void Xbrabo::updateToolbarsInfo()
01971 {
01972   QString result;
01973   QTextStream stream(&result, IO_WriteOnly);
01974   stream << *this;
01975   editPreferences->setToolbarsInfo(result, statusBar()->isVisible());
01976 }
01977 
01979 void Xbrabo::restoreToolbars()
01982 {
01983   QString toolbars;
01984   bool tempstatus;
01985   editPreferences->getToolbarsInfo(tempstatus, toolbars);
01986   
01987   if(!toolbars.isEmpty())
01988   {
01989     QTextStream stream(&toolbars, IO_ReadOnly);
01990     stream >> *this;
01991     if(tempstatus)
01992       statusBar()->show();
01993     else
01994       statusBar()->hide();    
01995   }
01996   actionViewToolBarStandard->setOn(ToolBarStandard->isVisible());
01997   actionViewToolBarCalculation->setOn(ToolBarCalculation->isVisible());
01998   actionViewToolBarCoordinates->setOn(ToolBarCoordinates->isVisible());
01999   actionViewStatusBar->setOn(statusBar()->isVisible());
02000   actionViewTaskBar->setOn(m_pTaskBar->isVisible());
02001   fixToplevelModeHeight();
02002 }
02003 
02005 QString Xbrabo::actionText(const QString title, const QString brief, const QString details, const IconSets::IconSetID iconID)
02011 {
02012   QString result = "<big><b>" + title + "</b></big> <hr>"; // keep the space before <hr> until this bug is solved (never for Qt pre 3.3.6)
02013   if(iconID != IconSets::LastIcon)
02014     result += "<img source=\"" + IconSets::factoryName(iconID) + "\" align=\"right\"/>";
02015   result += "<br>" + brief;
02016   if(!details.isEmpty())
02017     result += "<br>" + details;
02018   return result;
02019 }
02020 

Generated on Fri May 19 14:31:56 2006 for Brabosphere by  doxygen 1.4.6-NO