Commit 59b6edaa authored by Matthias Möller's avatar Matthias Möller

add "getGroupElements" script function + test

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@16266 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 99f57dfc
......@@ -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:
......
......@@ -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;
}
......@@ -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();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment