Aimsun Next Scripting  22
Public Types | Public Member Functions | List of all members
GAnyObjectChooser Class Reference
Inheritance diagram for GAnyObjectChooser:

Public Types

enum  ChooserMode { eOneObject = 0 , eManyObjects = 1 , eOneObjectList = 2 }
 

Public Member Functions

 GAnyObjectChooser (QWidget *parent=0)
 
 ~GAnyObjectChooser ()
 
void setType (GKModel *amodel, GKType *atype, const ChooserMode &amode, bool listSubTypes=true)
 
void setTypes (GKModel *amodel, const QStringList &someTypes, const ChooserMode &amode, bool listSubTypes=true)
 
void setConsidersEmptyAsNew (bool value)
 
bool considersEmptyAsNew () const
 
GKObjectgetObject () const
 
const QVector< GKObject * > getSelectedObjects () const
 
GKTypegetType () const
 
QVector< GKType * > getAvailableTypes () const
 
bool isEmpty () const
 

Detailed Description

The selector widget allows the application to ask either for one object (eOneObject or eOneObjectList) or for many (eManyObjects) from a particular type.

If you ask for one object, use the GAnyObjectChooser::getObject call to get the selected object (if any, can be None). If you ask for many, use the GAnyObjectChooser::getObjects call (if any, the list can be empty).

Example:

GAnyObjectChooser widget( gui );
GKCentroidConfiguration *centroids = nullptr;
widget.setType( gui->getModel(), gui->getModel()->getType( "GKCentroidConfiguration" ), ChooserMode::eOneObject );
widget.show();
...
centroids = dynamic_cast<GKCentroidConfiguration*>( widget.getObject() );
if( centroids ){
... do something with the selected object ...
}
A widget to select one or many object/s from a particular type.
Definition: GAnyObjectChooser.sip:71
It is a centroid set, which is appropriate to simulate either a part of the network or the whole netw...
Definition: GKCentroidConfiguration.sip:37
virtual void setType(GKType *atype)

It is possible to set a filter to control which objects will be added. In the next example only objects with ID lower than the filterData will be considered:

bool myFilter( GKObject * object, void * filterData )
{
return object->getId() < (int)(filterData);
}
Main class, almost all the objects derive from this class.
Definition: GKObject.sip:238

And, to use the filter:

GAnyObjectChooser widget( gui );
GKCentroidConfiguration *centroids = nullptr;
widget.setFilter( myFilter, (void *)10 );
widget.setType( gui->getModel(), gui->getModel()->getType( "GKCentroidConfiguration" ), ChooserMode::eOneObject );
...
centroids = dynamic_cast<GKCentroidConfiguration*>( widget.getObject() );
if( centroids ){
... do something with the selected object ...
}

Member Enumeration Documentation

◆ ChooserMode

Select one or many objects?

Enumerator
eOneObject 
eManyObjects 
eOneObjectList 

Constructor & Destructor Documentation

◆ GAnyObjectChooser()

GAnyObjectChooser::GAnyObjectChooser ( QWidget *  parent = 0)

◆ ~GAnyObjectChooser()

GAnyObjectChooser::~GAnyObjectChooser ( )

Member Function Documentation

◆ considersEmptyAsNew()

bool GAnyObjectChooser::considersEmptyAsNew ( ) const

See setConsidersEmptyAsNew.

◆ getAvailableTypes()

QVector< GKType * > GAnyObjectChooser::getAvailableTypes ( ) const

Returns the available types.

◆ getObject()

GKObject * GAnyObjectChooser::getObject ( ) const

Returns the selected object or None if none was selected.

◆ getSelectedObjects()

const QVector< GKObject * > GAnyObjectChooser::getSelectedObjects ( ) const

Returns the list of selected objects or an empty list if none was selected.

◆ getType()

GKType * GAnyObjectChooser::getType ( ) const

Returns the type currently selected

◆ isEmpty()

bool GAnyObjectChooser::isEmpty ( ) const

Returns true if there's no available objects for the specified filter and type.

◆ setConsidersEmptyAsNew()

void GAnyObjectChooser::setConsidersEmptyAsNew ( bool  value)

By default the None object is labelled as None. Pass true to label it as New

◆ setType()

void GAnyObjectChooser::setType ( GKModel amodel,
GKType atype,
const ChooserMode amode,
bool  listSubTypes = true 
)

Sets the model from where objects will be read and the type of the objects to consider. If only objects of the specified type want to be listed (and not the ones inheriting from it) the listSubTypes should be False.

◆ setTypes()

void GAnyObjectChooser::setTypes ( GKModel amodel,
const QStringList &  someTypes,
const ChooserMode amode,
bool  listSubTypes = true 
)

Sets the model from where objects will be read and only some types will be considered. Parameter someTypes must contain the internal type names. If someTypes QStringList is empty, then all possible types available in the model will be considered. If only objects of the specified types want to be listed (and not the ones inheriting from it) the listSubTypesm should be False.

© Aimsun SLU
Aimsun ®