PyANGKernel.GKCommand

class GKCommand

Base class for all the commands (except Delete commands, see GKObjectDelCmd )

Details

A command is an operation that the user can undo (and then redo). Any change in any object in Aimsun Next due to user manipulation must be done in a command (with the exception of edition done in the editors. See GEditor for more information on this topic).

The developer, when writes a command, will: - Give a name to the command that will be used to show in the Edit menu which operation the user will undo or redo. Use QObject::tr to create the name as this string must the translated. - Implement a method (as setCommandData) to pass to the new command any data needed to do and undo the operation. For example, to translate an object, the command will need a pointer to the object to be translated an a GKPoint with the translation delta. In any case this method (name and signature) depends of the nature of the command. - Implement the method GKCommand::doit to execute the operation. - Implement the method GKCommand::undoit to revert the operation.

The developer can also implement the GKCommand::init method to verify if the operation can be executed or not.

Optionally the developer can implement also the isEqual and merge methods. See GKCommander for more information.

In Aimsun Next there are three types of commands: - Creation commands - Manipulation commands - Delete commands

Delete commands are handle by a specialized class, not derived from GKCommand but from GKObjectDelCmd .

<H2>Deleting an object with the C++ delete operator </H2>

When an object is created using a command it has to be deleted (using the delete operator) if the command is deleted and the command was undone. The commander deletes a command either when no longer the undo operation is possible or when the model is closed.

An example follows:

GKSectionReportNewCmd::~GKSectionReportNewCmd()
{
        // If the command is not done (was created but the user selects UNDO) then
        // the object must be deleted.
        if( isDone() == false ){
                delete obj;
        }
}

Inherited by: GKViewModeStyleNewCmd, GKViewModeNewCmd, GKViewBookmarkNewCmd, GKVehicleNewCmd, GKVehicleClassNewCmd, GKUserClassNewCmd, GKTurningNewCmd, GKTripPurposeNewCmd, GKTriggerNewCmd, GKTransportationModeNewCmd, GKTrafficStateNewCmd, GKTrafficDemandNewCmd, GKTrafficConditionNewCmd, GKTrafficArrivalsNewCmd, GKSuperNodeNewCmd, GKSubPathNewCmd, GKStrategyNewCmd, GKStopLineNewCmd, GKSplitNodeCmd, GKSectionTwoWaysOvertakingNewCmd, GKSectionTwoWaysOvertakingDelCmd, GKSectionObjectNewCmd, GKPedestrianCrossingNewCmd, GKSectionObjectChangeSectionCmd, GKSectionNewCmd, GKSectionJoinCmd, GKSectionChangeGeoCmd, GKSectionLateralNewCmd, GKSectionChangeNbLanesCmd, GKSectionLateralDelCmd, GKScriptNewCmd, GKScenarioNewCmd, GKScenarioChangeNewCmd, GKRoundAboutNewCmd, GKRoadTypeNewCmd, GKReplicationNewCmd, GKRealDataSetNewCmd, GKPublicLinePlanNewCmd, GKPublicLineNewCmd, GKProblemNewCmd, GKProblemNetNewCmd, GKPolylineNewCmd, GKPolygonNewCmd, GKPolicyNewCmd, GKPathAssignmentPlanNewCmd, GKPathAssignmentNewCmd, GKPTStationNewCmd, GKObjectDuplicateCmd, GKObjectDelCmd, GKTurningDelCmd, GKScriptDelCmd, GKPathAssignmentPlanDelCmd, GKPathAssignmentDelCmd, GKGroupingTypeDelCmd, GKODRouteNewCmd, GKODMatrixNewCmd, GKNodeNewCmd, GKNodeCurveTurningCmd, GKNetworkAttributesOverrideNewCmd, GKMultiCmd, GKObjectDelMultipleCmd, GKMergeNodesCmd, GKMasterControlPlanNewCmd, GKLayerNewCmd, GKLaneTypeNewCmd, GKGroupingTypeNewCmd, GKGroupNewCmd, GKGroupFromPolygonNewCmd, GKFunctionCostNewCmd, GKExtrudedPolylineNewCmd, GKExtrudedPolygonNewCmd, GKExperimentResultNewCmd, GKExperimentNewCmd, GKDynamicTrafficSnapshotNewCmd, GKDetectorStationNewCmd, GKCutMultipleCmd, GKControllerNewCmd, GKControlPlanNewCmd, GKCircleNewCmd, GKCentroidVectorNewCmd, GKCentroidSplitConnectionToNodeCmd, GKCentroidSplitCmd, GKCentroidNewCmd, GKCentroidJoinCmd, GKCentroidConfigurationNewCmd, GKCenConnectionNewCmd, GKBusStopChangeSectionCmd, GKBezierCurveNewCmd, GKAuthorityNewCmd

Synopsis

Methods

Virtual methods

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

__init__()
__init__(arg__1)
Parameters:

arg__1GKCommand

createdObject()
Return type:

GKObject

Created object for New Commands (doit required).

createdObjectRequiresEdition()
Return type:

bool

A object created by a new command requires edition to be customized? True only for objects that cannot be created in a valid state.

getInternalName()
Return type:

str

Returns the internal name

getModel()
Return type:

GKModel

Returns the model.

getName()
Return type:

str

Returns the command name

getTargets()
Return type:

.list of int

Returns a list of objects modified by this command. Optional for now.

This implementation returns the id of the created object (if any)

isDone()
Return type:

bool

Returns true if the command has been done (the commander has executed the GKCommand::doit method) and false if the command has been undone (the commander has executed the GKCommand::undoit method). Returns false if neither doit() nor undoit() has been called.

isEqual(arg__1)
Parameters:

arg__1GKCommand

Return type:

bool

Returns true is this command is equal to the command “other”. Equal means, in this context, that both commands apply the same operation to the same object (or objects). If you implement this operation then merge operation must be implemented too.

Never return true on creation commands. This type of command cannot be merged.

isUndoable()
Return type:

bool

Returns true if the command can be undone and false otherwise.

merge(arg__1)
Parameters:

arg__1GKCommand

If two command are equal the commander will join both in one. This method will merge the command “other” with the command “this”. The command “other” will be discarded.

setDone(avalue)
Parameters:

avalue – bool

Set the done attribute. Called by the commander ( GKCommander ) when needed.

See also

isDone()

setModel(amodel)
Parameters:

amodelGKModel

Set the model, done by the GKCommander when the command is add to it

setName(aname)
Parameters:

aname – str

Set the command name, usually done in the command constructor

setUndoable(value)
Parameters:

value – bool

If “value” is true this command can be undone and false otherwise.

See also

isUndoable()