diff --git a/DataControlPlugin.hh b/DataControlPlugin.hh index 00c0b467997fcad1dcd2f099c98f86edbdb88252..84335432954a08fbd12840fbaf874f2fe514d7e8 100644 --- a/DataControlPlugin.hh +++ b/DataControlPlugin.hh @@ -392,6 +392,9 @@ class DataControlPlugin : public QObject, BaseInterface, ToolboxInterface, KeyIn /// Print information about all open objects to the console void printObjectInfoToLog(); + /// Get all elements of the given group + IdList getGroupElements(int _groupId); + /** @} */ public slots: diff --git a/DataControlPluginScripting.cc b/DataControlPluginScripting.cc index bf091d1138e904d62208b38c252915d13549f23c..9aa73182540989f65b9013bd7a78ccd83a192cfa 100644 --- a/DataControlPluginScripting.cc +++ b/DataControlPluginScripting.cc @@ -101,6 +101,9 @@ void DataControlPlugin::setDescriptions(){ emit setSlotDescription("objectDelete(int)",tr("Delete an object"), QStringList(tr("objectId")), QStringList(tr("Delete the given object."))); + emit setSlotDescription("getGroupElements(int)",tr("Get elements of a group"), + QStringList(tr("groupId")), QStringList(tr("Id of the group."))); + emit setSlotDescription("copyObject(int)",tr("Create a copy of an object"), QStringList(tr("objectId")), QStringList(tr("Object to copy."))); @@ -638,3 +641,23 @@ bool DataControlPlugin::addObjectToGroup(int _objectId, int _groupId) } return false; } + +//****************************************************************************** +/** \brief get all objects of an given group + * + * get all objects of an given group with id _groupId + * + * @return id list of group elements +*/ + +IdList DataControlPlugin::getGroupElements(int _groupId) +{ + BaseObject* group = 0; + PluginFunctions::getObject(_groupId,group); + IdList result; + + for (int i = 0; i < group->childCount(); ++i) + result.push_back(group->child(i)->id()); + + return result; +} diff --git a/tests/group.ofs b/tests/group.ofs index b56518316e904bef8c1897e2dd2fe36325798f28..a344e42adc655507a06af51363d87b0b7ad07d0b 100644 --- a/tests/group.ofs +++ b/tests/group.ofs @@ -88,4 +88,28 @@ if (datacontrol.addObjectToGroup(id3,id2)) { print("Could add an object to an object which is not a Group.") core.exitFailure(); -} \ No newline at end of file +} + +//Get group elements +id1 = primitivesgenerator.addSphere() +id2 = primitivesgenerator.addSphere() +elements = [id1,id2] +groupid = datacontrol.groupObjects(elements) +resuldList = datacontrol.getGroupElements(groupid) + +if (resuldList.length != elements.length) +{ + print("error: getGroupElements") + print("number of received elements is: "+elements.length+" expected was: "+resuldList.length) + core.exitFailure(); +} +for (i = 0; i < resultId; ++i) +{ + if (resuldList[i] != groupId[i]) + { + print("error: getGroupElements") + print("id of received object differs") + print("expected was: "+groupId[i]+" result is: "+resuldIdList[i]) + core.exitFailure(); + } +}