The SKIRT project
advanced radiative transfer for astrophysics
Classes | Public Slots | Signals | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
WizardEngine Class Reference

#include <WizardEngine.hpp>

Inheritance diagram for WizardEngine:
Inheritance graph
[legend]

Classes

class  State
 

Public Slots

void advance (bool state=true, bool descend=true)
 
void advanceToEditSubItem (int subItemIndex)
 
void hierarchyWasChanged ()
 
void hierarchyWasLoaded (Item *root, QString filepath)
 
void hierarchyWasSaved (QString filepath)
 
void restartWizard ()
 
void retreat ()
 
void setBasicChoice (bool openExisting, string libraryPath, string schemaName)
 
void setPropertyValid (bool valid)
 
void setRootType (string newRootType)
 

Signals

void canAdvanceChangedTo (bool canAdvance)
 
void canRetreatChangedTo (bool canRetreat)
 
void dirtyChanged ()
 
void stateChanged ()
 
void titleChanged ()
 

Public Member Functions

 WizardEngine (QObject *parent)
 
 ~WizardEngine ()
 
bool canAdvance ()
 
bool canRetreat ()
 
QWidget * createPane ()
 
void emitStateChanged ()
 
QString filepath ()
 
QString hierarchyPath ()
 
bool isDirty ()
 
const SchemaDefschema ()
 

Private Types

enum class  Stage {
  BasicChoice , CreateRoot , OpenHierarchy , ConstructHierarchy ,
  SaveHierarchy
}
 

Private Member Functions

std::unique_ptr< PropertyHandlercreatePropertyHandler (int propertyIndex)
 
int propertyIndexForChild (Item *child)
 

Private Attributes

Item_current
 
bool _dirty
 
QString _filepath
 
int _firstPropertyIndex
 
int _lastPropertyIndex
 
NameManager _nameMgr
 
bool _openExisting
 
bool _propertyValid
 
std::unique_ptr< Item_root
 
std::unique_ptr< SchemaDef_schema
 
string _schemaName
 
Stage _stage
 
std::stack< size_t > _stateIndexStack
 
std::stack< State_stateStack
 
int _subItemIndex
 

Detailed Description

The WizardEngine class implements the back end of the wizard through which users can create and edit SMILE datasets. The MainWindow creates a single WizardEngine instance. This WizardEngine object manages the dataset under construction, keeps track of the wizard's state (i.e. which question should currently be displayed), allowing it to advance and retreat, and generates the user interface pane corresponding to the current state.

Constructor & Destructor Documentation

◆ WizardEngine()

WizardEngine::WizardEngine ( QObject *  parent)
explicit

The default (and only) constructor places the WizardEngine in its initial state, corresponding to the question "what would you like to do".

◆ ~WizardEngine()

WizardEngine::~WizardEngine ( )

The destructor deallocates the dataset under construction and releases any other resources being held.

Member Function Documentation

◆ advance

void WizardEngine::advance ( bool  state = true,
bool  descend = true 
)
slot

This function advances the wizard to the next state. It should only be called if canAdvance() returns true. Th optional flags are used for recursive calls. If state is set to false, the current advance state is not saved. If descend is set to false, the function will not descend into the current compound property.

◆ advanceToEditSubItem

void WizardEngine::advanceToEditSubItem ( int  subItemIndex)
slot

This function advances the wizard to a state that starts editing the specified item in the current item list property.

◆ canAdvance()

bool WizardEngine::canAdvance ( )

This function returns true if the wizard can currently advance; false otherwise.

◆ canAdvanceChangedTo

void WizardEngine::canAdvanceChangedTo ( bool  canAdvance)
signal

This signal is emitted when the return value of the canAdvance() function may have changed. The argument specifies the new value.

◆ canRetreat()

bool WizardEngine::canRetreat ( )

This function returns true if the wizard can currently retreat; false otherwise.

◆ canRetreatChangedTo

void WizardEngine::canRetreatChangedTo ( bool  canRetreat)
signal

This signal is emitted when the return value of the canRetreat() function may have changed. The argument specifies the new value.

◆ createPane()

QWidget * WizardEngine::createPane ( )

This function creates a fresh QWidget object corresponding to the current wizard state, returns a pointer to it, and transfers ownership to the caller. The QWidget has no parent, but is otherwise fully equipped to handle the keyboard and mouse events for any UI elements it contains. For example, the UI elements are equipped so that they can properly update the corresponding portion of the dataset under construction.

◆ createPropertyHandler()

std::unique_ptr< PropertyHandler > WizardEngine::createPropertyHandler ( int  propertyIndex)
private

This function creates and returns a unique pointer to a property handler for the property of the current item with the specified property index. The function does not check whether the property index is within range.

◆ dirtyChanged

void WizardEngine::dirtyChanged ( )
signal

This signal is emitted when the dirty state of the current dataset has changed.

◆ emitStateChanged()

void WizardEngine::emitStateChanged ( )

This function emits the stateChanged(), canAdvanceChangedTo() and canRetreatChangedTo() signals.

◆ filepath()

QString WizardEngine::filepath ( )

This function returns the path of the file to which the current dataset has already been saved (although it may have changed since then), or the empty string if it has never been saved.

◆ hierarchyPath()

QString WizardEngine::hierarchyPath ( )

This function returns a human-readable description of the path to the property currently being handled in the dataset.

◆ hierarchyWasChanged

void WizardEngine::hierarchyWasChanged ( )
slot

This function sets the dirty flag.

◆ hierarchyWasLoaded

void WizardEngine::hierarchyWasLoaded ( Item root,
QString  filepath 
)
slot

This function deletes the current dataset (if present), and replaces it by the new dataset specified through it root item. The function adopts ownership for specified dataset. This function further clears the dirty flag and remembers the filepath from which the dataset was loaded.

◆ hierarchyWasSaved

void WizardEngine::hierarchyWasSaved ( QString  filepath)
slot

This function clears the dirty flag and remembers the filepath in which the dataset was saved.

◆ isDirty()

bool WizardEngine::isDirty ( )

This function returns true if the wizard currently holds unsaved information; false otherwise.

◆ propertyIndexForChild()

int WizardEngine::propertyIndexForChild ( Item child)
private

This function returns the property index for the specified child item in its parent item, or -1 if the specified child item does not have a parent or if it is not a child of its parent (which should never happen). The result does not depend on the evaluation of conditional expressions against the current name sets.

◆ restartWizard

void WizardEngine::restartWizard ( )
slot

This function intializes the state of the wizard as if it has just been started, and causes the basic choice pane to be shown.

◆ retreat

void WizardEngine::retreat ( )
slot

This function retreats the wizard to the previous state. It should only be called if canRetreat() returns true.

◆ schema()

const SchemaDef * WizardEngine::schema ( )

This function returns a pointer to the schema definition for the current dataset (without transfer of ownership), or the null pointer if no dataset has yet been opened or created.

◆ setBasicChoice

void WizardEngine::setBasicChoice ( bool  openExisting,
string  libraryPath,
string  schemaName 
)
slot

This function updates the basic choice to the specified values.

◆ setPropertyValid

void WizardEngine::setPropertyValid ( bool  valid)
slot

This function updates the flag that indicates whether the value of the property currently being handled is valid.

◆ setRootType

void WizardEngine::setRootType ( string  newRootType)
slot

If the current root does not have the specified type (or if there is no current root), this function deletes the current dataset (if present), and replaces it by a newly created root item of the specified type. If the current root already has the specified type, this function does nothing.

◆ stateChanged

void WizardEngine::stateChanged ( )
signal

This signal is emitted when the state of the wizard has changed.

◆ titleChanged

void WizardEngine::titleChanged ( )
signal

This signal is emitted when the filename in which the current dataset was saved has changed.


The documentation for this class was generated from the following file: