BCESolve
BCEObjWeightsTableModel Class Reference

Model for Objective Weights in the BCEViewer. More...

#include <bceobjweightstablemodel.hpp>

Inheritance diagram for BCEObjWeightsTableModel:
Collaboration diagram for BCEObjWeightsTableModel:

Public Member Functions

 BCEObjWeightsTableModel (BCEGame *_game)
 Constructor. More...
 
Qt::ItemFlags flags (const QModelIndex &index) const
 Returns flags. More...
 
int rowCount (const QModelIndex &parent=QModelIndex()) const Q_DECL_OVERRIDE
 Returns the number of row player actions.
 
int columnCount (const QModelIndex &parent=QModelIndex()) const Q_DECL_OVERRIDE
 Returns the number of column player actions.
 
void emitLayoutChanged ()
 Emits layoutChanged signal.
 
QVariant data (const QModelIndex &index, int role) const Q_DECL_OVERRIDE
 Reimplements the data method. More...
 
bool setData (const QModelIndex &index, const QVariant &value, int role)
 Reimplements the setData method. More...
 
QVariant headerData (int section, Qt::Orientation orientation, int role) const Q_DECL_OVERRIDE
 Returns formatted header data. More...
 
void addObjective (int position)
 Adds an objective to the weight data vector.
 
void removeObjective (int position)
 Removes an objective from the weight data and label vectors. More...
 
const vector< double > getSolverData ()
 Returns a reference to the weight data vector.
 
const vector< vector< double > > getMapBoundaryData ()
 Returns a reference to the weight data vector.
 
void resetObjectiveWeights ()
 Resets weights on objectives.
 

Protected Attributes

BCEGamegame
 Pointer to the associated game.
 

Private Member Functions

void setWeightData (vector< int > cellLocation, double value)
 Sets data in the objective weights vectors.
 

Private Attributes

vector< double > mainObjWeights
 Vector storing weights on main objective.
 
vector< double > secondaryObjWeights
 Vector storing weights on secondary objective.
 
vector< string > objectiveLabels
 Vector storing objective labels.
 

Detailed Description

Model for Objective Weights in the BCEViewer.

Specializes QAbstractTableModel for the BCEViewer program. Sets flags, reimplements the rowCount method to return the numbers of objectives.

Also contains two data members, mainObjWeights and secondaryObjWeights, that store the objective weights set by the user in the game tab. Interfacing with the game occurs through the add and remove objective functions in the bcegamehandler.

Constructor & Destructor Documentation

◆ BCEObjWeightsTableModel()

BCEObjWeightsTableModel::BCEObjWeightsTableModel ( BCEGame _game)
inline

Constructor.

Sets the size of the weightData vector equal to the number of objectives in the game. Sets default weight data to .5 on player 0 and player 1's objectives. Gets any existing objective labels from the game.

Member Function Documentation

◆ data()

QVariant BCEObjWeightsTableModel::data ( const QModelIndex &  index,
int  role 
) const

Reimplements the data method.

Retrieves the current weight set for a specified objective.

◆ flags()

Qt::ItemFlags BCEObjWeightsTableModel::flags ( const QModelIndex &  index) const
inline

Returns flags.

Returns flags that indicate the model is enabled, can be edited, and can be selected.

◆ headerData()

QVariant BCEObjWeightsTableModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role 
) const

Returns formatted header data.

Returns header data formatted to indicate the appropriate objective labels.

◆ removeObjective()

void BCEObjWeightsTableModel::removeObjective ( int  position)
inline

Removes an objective from the weight data and label vectors.

Note that BCEGameHandler performs the check to determine if the vector has at least 1 element.

◆ setData()

bool BCEObjWeightsTableModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role 
)

Reimplements the setData method.

Sets the weight on the specified objective.


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