GlobalSearch::AbstractDialog Class Reference

A basic dialog that is preconfigured for use with GlobalSearch. More...

#include <globalsearch/ui/abstractdialog.h>

List of all members.

Public Slots

virtual void disconnectGUI ()
virtual void lockGUI ()
virtual void updateGUI ()
virtual void writeSettings (const QString &filename="")
virtual void readSettings (const QString &filename="")
virtual void saveSession ()=0
void updateStatus (int opt, int run, int fail)
void setGLWidget (Avogadro::GLWidget *w)
void newDebug (const QString &s)
void newWarning (const QString &s)
void newError (const QString &s)
void errorBox (const QString &s)
Progressbar functions

These functions are used to display and control a progress notification system for log processes.

bool startProgressUpdate (const QString &text, int min, int max)
void stopProgressUpdate ()
void updateProgressMinimum (int min)
void updateProgressMaximum (int max)
void updateProgressValue (int val)
void updateProgressLabel (const QString &text)
void repaintProgressBar ()

Signals

void tabsDisconnectGUI ()
void tabsLockGUI ()
void tabsUpdateGUI ()
void moleculeChanged (GlobalSearch::Structure *)
void newLog (const QString &str)
void sig_updateStatus (int, int, int)
void sig_startProgressUpdate (const QString &, int, int)
void sig_stopProgressUpdate ()
void sig_updateProgressMinimum (int)
void sig_updateProgressMaximum (int)
void sig_updateProgressValue (int)
void sig_updateProgressLabel (const QString &)
void sig_repaintProgressBar ()
void sig_errorBox (const QString &)

Public Member Functions

 AbstractDialog (Avogadro::GLWidget *glWidget=0, QWidget *parent=0, Qt::WindowFlags f=0)
void initialize ()
virtual ~AbstractDialog ()
Avogadro::GLWidget * getGLWidget ()
OptBasegetOptBase ()

Protected Slots

virtual void startSearch ()=0
virtual void resumeSession ()
void updateStatus_ (int, int, int)
void startProgressUpdate_ (const QString &, int, int)
void stopProgressUpdate_ ()
void updateProgressMinimum_ (int)
void updateProgressMaximum_ (int)
void updateProgressValue_ (int)
void updateProgressLabel_ (const QString &)
void repaintProgressBar_ ()
void errorBox_ (const QString &s)

Protected Member Functions

virtual void resumeSession_ (const QString &filename)

Protected Attributes

OptBasem_opt
Avogadro::Molecule * m_molecule
Avogadro::GLWidget * m_glWidget
QMutex * progMutex
QTimer * progTimer
QPushButton * ui_push_begin
QPushButton * ui_push_save
QPushButton * ui_push_resume
QLabel * ui_label_opt
QLabel * ui_label_run
QLabel * ui_label_fail
QLabel * ui_label_prog
QProgressBar * ui_progbar
QTabWidget * ui_tabs

Detailed Description

A basic dialog that is preconfigured for use with GlobalSearch.

Author:
David C. Lonie

AbstractDialog is set up for use with an OptBase class. See the accompanying .ui file for a QtDesigner template.

To properly use this class, modify abstractdialog.ui in Qt Designer without changing the names of any existing elements. Do not add tabs, this will be done later programmatically.

Include a block like this in the derived class's constructor to setup the UI:

    // Initialize UI
    ui.setupUi(this);
    ui_push_begin   = ui.push_begin;
    ui_push_save    = ui.push_save;
    ui_push_resume  = ui.push_resume;
    ui_label_opt    = ui.label_opt;
    ui_label_run    = ui.label_run;
    ui_label_fail   = ui.label_fail;
    ui_label_prog   = ui.label_prog;
    ui_progbar      = ui.progbar;
    ui_tabs         = ui.tabs;

    // Tabs: be sure to include and define in derived header.
    // Initialize tabs (modify as needed)
    m_tab_init     = new TabInit(this, m_opt);
    m_tab_edit     = new TabEdit(this, m_opt);
    m_tab_opt      = new TabOpt(this, m_opt);
    m_tab_sys      = new TabSys(this, m_opt);
    m_tab_progress = new TabProgress(this, m_opt);
    m_tab_plot     = new TabPlot(this, m_opt);
    m_tab_log      = new TabLog(this, m_opt);

    // Populate tab widget (modify as needed)
    ui.tabs->clear();
    ui.tabs->addTab(m_tab_init->getTabWidget(),	    tr("Cell &Initialization"));
    ui.tabs->addTab(m_tab_edit->getTabWidget(),     tr("Optimization &Templates"));
    ui.tabs->addTab(m_tab_opt->getTabWidget(),      tr("&Optimization Settings"));
    ui.tabs->addTab(m_tab_sys->getTabWidget(),      tr("&System Settings"));
    ui.tabs->addTab(m_tab_progress->getTabWidget(), tr("&Progress"));
    ui.tabs->addTab(m_tab_plot->getTabWidget(),     tr("&Plot"));
    ui.tabs->addTab(m_tab_log->getTabWidget(),      tr("&Log"));

    // Select the first tab by default
    ui.tabs->setCurrentIndex(0);

    // Hide the progress bar/label
    ui.label_prog->setVisible(false);
    ui.progbar->setVisible(false);

It is also essential to call initialize() at the end of the derived constructor.

Definition at line 99 of file abstractdialog.h.


Constructor & Destructor Documentation

GlobalSearch::AbstractDialog::AbstractDialog ( Avogadro::GLWidget *  glWidget = 0,
QWidget *  parent = 0,
Qt::WindowFlags  f = 0 
) [explicit]

Constructor.

When deriving, be sure to call initialize() after initializing m_opt and ui.

See also:
initialize
Parameters:
glWidget The GLwidget from the Avogadro instance
parent Parent object
f Window flags
GlobalSearch::AbstractDialog::~AbstractDialog (  )  [virtual]

Destructor. Deletes m_opt.

Consider calling something along the lines of

    if (m_opt->saveOnExit) {
      m_opt->tracker()->lockForRead();
      writeSettings();
      saveSession();
      m_opt->tracker()->unlock();
    }

in the derived destructor.

Definition at line 132 of file abstractdialog.cpp.

References m_opt.


Member Function Documentation

void GlobalSearch::AbstractDialog::disconnectGUI (  )  [virtual, slot]

Call this to disable GUI updates. Useful when benchmarking non-interactively.

Note:
This call is passed on to all tabs.

Definition at line 137 of file abstractdialog.cpp.

References m_opt, sig_updateStatus(), tabsDisconnectGUI(), updateGUI(), and updateStatus_().

void GlobalSearch::AbstractDialog::errorBox ( const QString &  s  )  [inline, slot]

Displays an error box with the indicated message. This function will block the GUI thread until user clicks "Ok".

Note:
Do not use this function, but instead send call OptBase::error
Parameters:
s Error message.

Definition at line 336 of file abstractdialog.h.

References sig_errorBox().

Referenced by newError().

void GlobalSearch::AbstractDialog::errorBox_ ( const QString &  s  )  [inline, protected, slot]

Hidden call. Ensures that the GUI is modified from the appropriate thread.

See also:
errorBox

Definition at line 416 of file abstractdialog.h.

Referenced by initialize().

Avogadro::GLWidget* GlobalSearch::AbstractDialog::getGLWidget (  )  [inline]
Returns:
The GLWidget of the main Avogadro window.

Definition at line 144 of file abstractdialog.h.

References m_glWidget.

OptBase* GlobalSearch::AbstractDialog::getOptBase (  )  [inline]
Returns:
The associated OptBase derived class.

Definition at line 149 of file abstractdialog.h.

References m_opt.

void GlobalSearch::AbstractDialog::initialize (  ) 
void GlobalSearch::AbstractDialog::lockGUI (  )  [virtual, slot]

Called when the search session starts to disable GUI components that should only be modified during initialization.

Note:
This call is passed on to all tabs.

Definition at line 147 of file abstractdialog.cpp.

References tabsLockGUI(), ui_push_begin, ui_push_resume, and ui_push_save.

Referenced by initialize().

void GlobalSearch::AbstractDialog::moleculeChanged ( GlobalSearch::Structure  )  [signal]

Emitted to change/update the molecule displayed in the Avogadro main window.

void GlobalSearch::AbstractDialog::newDebug ( const QString &  s  )  [inline, slot]

Called by OptBase::debug and sends a message to the log tab.

Note:
Do not use this function, but instead send call OptBase::debug
Parameters:
s The debugging message.

Definition at line 303 of file abstractdialog.h.

References newLog().

Referenced by initialize().

void GlobalSearch::AbstractDialog::newError ( const QString &  s  )  [inline, slot]

Called by OptBase::error. Sends a message to the log tab and calls errorBox.

Note:
Do not use this function, but instead send call OptBase::error
Parameters:
s The error message.

Definition at line 324 of file abstractdialog.h.

References errorBox(), and newLog().

Referenced by initialize().

void GlobalSearch::AbstractDialog::newLog ( const QString &  str  )  [signal]

Emitted when there is a new log message ready.

See also:
OptBase::debug
OptBase::warning
OptBase::error
Parameters:
str Log message

Referenced by newDebug(), newError(), and newWarning().

void GlobalSearch::AbstractDialog::newWarning ( const QString &  s  )  [inline, slot]

Called by OptBase::warning and sends a message to the log tab.

Note:
Do not use this function, but instead send call OptBase::warning
Parameters:
s The warning message.

Definition at line 313 of file abstractdialog.h.

References newLog().

Referenced by initialize().

virtual void GlobalSearch::AbstractDialog::readSettings ( const QString &  filename = ""  )  [inline, virtual, slot]

Read persistant settings or resume information. If the filename is omitted, settings are read from the Avogadro configuration file. Otherwise, they are read from the provided file.

Note:
This call is passed on to all tabs.
Parameters:
filename Optional filename to holding resume information

Definition at line 192 of file abstractdialog.h.

Referenced by initialize().

void GlobalSearch::AbstractDialog::repaintProgressBar (  )  [inline, slot]

Forces a redraw of the progress bar.

Note:
This shouldn't need to be called, as it is handled automatically.

Definition at line 291 of file abstractdialog.h.

References sig_repaintProgressBar().

Referenced by startProgressUpdate_(), stopProgressUpdate_(), updateProgressLabel_(), updateProgressMaximum_(), updateProgressMinimum_(), and updateProgressValue_().

void GlobalSearch::AbstractDialog::repaintProgressBar_ (  )  [protected, slot]

Hidden call. Ensures that the GUI is modified from the appropriate thread.

See also:
repaintProgressBar

Definition at line 271 of file abstractdialog.cpp.

References ui_label_prog, and ui_progbar.

Referenced by initialize().

void GlobalSearch::AbstractDialog::resumeSession (  )  [protected, virtual, slot]

Prompt user for a resume file and then call resumeSession_ in a background thread.

Definition at line 181 of file abstractdialog.cpp.

References GlobalSearch::OptBase::filePath, GlobalSearch::OptBase::getIDString(), m_opt, and resumeSession_().

Referenced by initialize().

void GlobalSearch::AbstractDialog::resumeSession_ ( const QString &  filename  )  [protected, virtual]
virtual void GlobalSearch::AbstractDialog::saveSession (  )  [pure virtual, slot]

Saves resume information to a state file in OptBase::filePath.

This should look something like:

  void DerivedDialog::saveSession() {
    // Notify if this was user requested.
    if (m_opt->savePending) {
      return;
    }
    bool notify = false;
    if (sender() == ui_push_save) {
      notify = true;
    }
    m_opt->savePending = true;
    QtConcurrent::run(m_opt, &DerivedOptBase::save, QString(""), notify);
  }

Referenced by initialize().

void GlobalSearch::AbstractDialog::setGLWidget ( Avogadro::GLWidget *  w  )  [inline, slot]

Update the cached Avogadro::GLWidget pointer

Parameters:
w The Avogadro GLWidget

Definition at line 234 of file abstractdialog.h.

References m_glWidget.

void GlobalSearch::AbstractDialog::sig_errorBox ( const QString &   )  [signal]

Hidden call. Ensures that the GUI is modified from the appropriate thread.

See also:
errorBox

Referenced by errorBox(), and initialize().

void GlobalSearch::AbstractDialog::sig_repaintProgressBar (  )  [signal]

Hidden call. Ensures that the GUI is modified from the appropriate thread.

See also:
repaintProgressBar

Referenced by initialize(), and repaintProgressBar().

void GlobalSearch::AbstractDialog::sig_startProgressUpdate ( const QString &  ,
int  ,
int   
) [signal]

Hidden call. Ensures that the GUI is modified from the appropriate thread.

See also:
startProgressUpdate

Referenced by initialize(), and startProgressUpdate().

void GlobalSearch::AbstractDialog::sig_stopProgressUpdate (  )  [signal]

Hidden call. Ensures that the GUI is modified from the appropriate thread.

See also:
stopProgressUpdate

Referenced by initialize(), and stopProgressUpdate().

void GlobalSearch::AbstractDialog::sig_updateProgressLabel ( const QString &   )  [signal]

Hidden call. Ensures that the GUI is modified from the appropriate thread.

See also:
updateProgressLabel

Referenced by initialize(), and updateProgressLabel().

void GlobalSearch::AbstractDialog::sig_updateProgressMaximum ( int   )  [signal]

Hidden call. Ensures that the GUI is modified from the appropriate thread.

See also:
updateProgressMaximum

Referenced by initialize(), and updateProgressMaximum().

void GlobalSearch::AbstractDialog::sig_updateProgressMinimum ( int   )  [signal]

Hidden call. Ensures that the GUI is modified from the appropriate thread.

See also:
updateProgressMinimum

Referenced by initialize(), and updateProgressMinimum().

void GlobalSearch::AbstractDialog::sig_updateProgressValue ( int   )  [signal]

Hidden call. Ensures that the GUI is modified from the appropriate thread.

See also:
updateProgressValue

Referenced by initialize(), and updateProgressValue().

void GlobalSearch::AbstractDialog::sig_updateStatus ( int  ,
int  ,
int   
) [signal]

Hidden call. Ensures that the GUI is modified from the appropriate thread.

See also:
updateStatus

Referenced by disconnectGUI(), initialize(), and updateStatus().

bool GlobalSearch::AbstractDialog::startProgressUpdate ( const QString &  text,
int  min,
int  max 
) [slot]

Show the progressbar and initialize a status update.

Only one progress update may run at a time.

Parameters:
text Label text describing the operation
min Minimum progress value
max Maximum progress value
Returns:
False if the progress bar is already in use, true otherwise.

Definition at line 167 of file abstractdialog.cpp.

References progMutex, and sig_startProgressUpdate().

Referenced by resumeSession_(), and GlobalSearch::OptBase::save().

void GlobalSearch::AbstractDialog::startProgressUpdate_ ( const QString &  text,
int  min,
int  max 
) [protected, slot]

Hidden call. Ensures that the GUI is modified from the appropriate thread.

See also:
startProgressUpdate

Definition at line 231 of file abstractdialog.cpp.

References progTimer, repaintProgressBar(), ui_label_prog, and ui_progbar.

Referenced by initialize().

virtual void GlobalSearch::AbstractDialog::startSearch (  )  [protected, pure virtual, slot]

Begin the search. Suggested form for derived class:

  void DerivedDialog::startSearch() {
    QtConcurrent::run(m_opt, &DerivedOptBase::startSearch);
  }

Referenced by initialize().

void GlobalSearch::AbstractDialog::stopProgressUpdate (  )  [slot]

Reset and hide progress bar and label. Also frees the associated mutex, allowing other processes to use it.

Definition at line 175 of file abstractdialog.cpp.

References progMutex, and sig_stopProgressUpdate().

Referenced by resumeSession_(), and GlobalSearch::OptBase::save().

void GlobalSearch::AbstractDialog::stopProgressUpdate_ (  )  [protected, slot]

Hidden call. Ensures that the GUI is modified from the appropriate thread.

See also:
stopProgressUpdate

Definition at line 242 of file abstractdialog.cpp.

References progTimer, repaintProgressBar(), ui_label_prog, and ui_progbar.

Referenced by initialize().

void GlobalSearch::AbstractDialog::tabsDisconnectGUI (  )  [signal]

Emitted when tabs should run their disconnectGUI function

Referenced by disconnectGUI().

void GlobalSearch::AbstractDialog::tabsLockGUI (  )  [signal]

Emitted when tabs should run their lockGUI function

Referenced by lockGUI().

void GlobalSearch::AbstractDialog::tabsUpdateGUI (  )  [signal]

Emitted when tabs should run their updateGUI function

Referenced by updateGUI().

void GlobalSearch::AbstractDialog::updateGUI (  )  [virtual, slot]

Refresh the GUI from data stored in m_opt.

Note:
This call is passed on to all tabs.

Definition at line 155 of file abstractdialog.cpp.

References GlobalSearch::OptBase::description, GlobalSearch::OptBase::getIDString(), GlobalSearch::OptBase::host, m_opt, GlobalSearch::OptBase::readOnly, and tabsUpdateGUI().

Referenced by disconnectGUI(), and initialize().

void GlobalSearch::AbstractDialog::updateProgressLabel ( const QString &  text  )  [inline, slot]
Parameters:
text The text for the progress label.

Definition at line 282 of file abstractdialog.h.

References sig_updateProgressLabel().

Referenced by GlobalSearch::OptBase::save().

void GlobalSearch::AbstractDialog::updateProgressLabel_ ( const QString &  text  )  [protected, slot]

Hidden call. Ensures that the GUI is modified from the appropriate thread.

See also:
updateProgressLabel

Definition at line 266 of file abstractdialog.cpp.

References repaintProgressBar(), and ui_label_prog.

Referenced by initialize().

void GlobalSearch::AbstractDialog::updateProgressMaximum ( int  max  )  [inline, slot]
Parameters:
max The maximum value for the progress bar.

Definition at line 270 of file abstractdialog.h.

References sig_updateProgressMaximum().

void GlobalSearch::AbstractDialog::updateProgressMaximum_ ( int  max  )  [protected, slot]

Hidden call. Ensures that the GUI is modified from the appropriate thread.

See also:
updateProgressMaximum

Definition at line 256 of file abstractdialog.cpp.

References repaintProgressBar(), and ui_progbar.

Referenced by initialize().

void GlobalSearch::AbstractDialog::updateProgressMinimum ( int  min  )  [inline, slot]
Parameters:
min The minimum value for the progress bar.

Definition at line 264 of file abstractdialog.h.

References sig_updateProgressMinimum().

void GlobalSearch::AbstractDialog::updateProgressMinimum_ ( int  min  )  [protected, slot]

Hidden call. Ensures that the GUI is modified from the appropriate thread.

See also:
updateProgressMinimum

Definition at line 251 of file abstractdialog.cpp.

References repaintProgressBar(), and ui_progbar.

Referenced by initialize().

void GlobalSearch::AbstractDialog::updateProgressValue ( int  val  )  [inline, slot]
Parameters:
val The current value for the progress bar.

Definition at line 276 of file abstractdialog.h.

References sig_updateProgressValue().

void GlobalSearch::AbstractDialog::updateProgressValue_ ( int  val  )  [protected, slot]

Hidden call. Ensures that the GUI is modified from the appropriate thread.

See also:
updateProgressValue

Definition at line 261 of file abstractdialog.cpp.

References repaintProgressBar(), and ui_progbar.

Referenced by initialize().

void GlobalSearch::AbstractDialog::updateStatus ( int  opt,
int  run,
int  fail 
) [inline, slot]

Update the GUI with how many Structures are optimized, running, or failing.

Parameters:
opt Number of optimized structures
run Number of running structures
fail Number of failing structures

Definition at line 226 of file abstractdialog.h.

References sig_updateStatus().

Referenced by initialize().

void GlobalSearch::AbstractDialog::updateStatus_ ( int  opt,
int  run,
int  fail 
) [protected, slot]

Hidden call. Ensures that the GUI is modified from the appropriate thread.

See also:
updateStatus

Definition at line 225 of file abstractdialog.cpp.

References ui_label_fail, ui_label_opt, and ui_label_run.

Referenced by disconnectGUI(), and initialize().

virtual void GlobalSearch::AbstractDialog::writeSettings ( const QString &  filename = ""  )  [inline, virtual, slot]

Write persistant settings or resume information. If the filename is omitted, settings are written to the Avogadro configuration file. Otherwise, they are written to the provided file.

Note:
This call is passed on to all tabs.
Parameters:
filename Optional filename to hold resume information

Definition at line 181 of file abstractdialog.h.

Referenced by resumeSession_(), and GlobalSearch::OptBase::save().


Member Data Documentation

Avogadro::GLWidget* GlobalSearch::AbstractDialog::m_glWidget [protected]

Cached pointer to the Avogadro GLWidget.

Definition at line 532 of file abstractdialog.h.

Referenced by getGLWidget(), and setGLWidget().

Avogadro::Molecule* GlobalSearch::AbstractDialog::m_molecule [protected]

The molecule object in the main Avogadro window.

Definition at line 527 of file abstractdialog.h.

Cached pointer to the associated OptBase object.

Definition at line 522 of file abstractdialog.h.

Referenced by disconnectGUI(), getOptBase(), initialize(), resumeSession(), resumeSession_(), updateGUI(), and ~AbstractDialog().

Mutex governing progress bar usage.

Definition at line 537 of file abstractdialog.h.

Referenced by startProgressUpdate(), and stopProgressUpdate().

Timer to automatically refresh the progress bar.

Definition at line 542 of file abstractdialog.h.

Referenced by initialize(), startProgressUpdate_(), and stopProgressUpdate_().

Pointer to GUI element. Do not use in derived class code.

Note:
This must be set up in the derived-constructor. See class description.

Definition at line 584 of file abstractdialog.h.

Referenced by updateStatus_().

Pointer to GUI element. Do not use in derived class code.

Note:
This must be set up in the derived-constructor. See class description.

Definition at line 570 of file abstractdialog.h.

Referenced by updateStatus_().

Pointer to GUI element. Do not use in derived class code.

Note:
This must be set up in the derived-constructor. See class description.

Definition at line 591 of file abstractdialog.h.

Referenced by initialize(), repaintProgressBar_(), startProgressUpdate_(), stopProgressUpdate_(), and updateProgressLabel_().

Pointer to GUI element. Do not use in derived class code.

Note:
This must be set up in the derived-constructor. See class description.

Definition at line 577 of file abstractdialog.h.

Referenced by updateStatus_().

QProgressBar* GlobalSearch::AbstractDialog::ui_progbar [protected]

Pointer to GUI element. Do not use in derived class code.

Note:
This must be set up in the derived-constructor. See class description.

Definition at line 598 of file abstractdialog.h.

Referenced by initialize(), repaintProgressBar_(), startProgressUpdate_(), stopProgressUpdate_(), updateProgressMaximum_(), updateProgressMinimum_(), and updateProgressValue_().

Pointer to GUI element. Do not use in derived class code.

Note:
This must be set up in the derived-constructor. See class description.

Definition at line 549 of file abstractdialog.h.

Referenced by initialize(), and lockGUI().

Pointer to GUI element. Do not use in derived class code.

Note:
This must be set up in the derived-constructor. See class description.

Definition at line 563 of file abstractdialog.h.

Referenced by initialize(), and lockGUI().

Pointer to GUI element. Do not use in derived class code.

Note:
This must be set up in the derived-constructor. See class description.

Definition at line 556 of file abstractdialog.h.

Referenced by initialize(), and lockGUI().

QTabWidget* GlobalSearch::AbstractDialog::ui_tabs [protected]

Pointer to GUI element. Do not use in derived class code.

Note:
This must be set up in the derived-constructor. See class description.

Definition at line 605 of file abstractdialog.h.

Referenced by initialize().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations Enumerator
Generated on Mon Jul 16 14:40:05 2012 for GlobalSearch by  doxygen 1.6.3