Commit 0282b659 authored by Martin Schultz's avatar Martin Schultz

added nogui support for merge plugin

added overloaded function for merging that accepts an idlist and additional datatype
to support scripting
parent 6503bb28
......@@ -49,6 +49,10 @@ namespace
}
}
/**
* Member functions
*/
void MergePlugin::slotCleanup( DataType _type, bool _deleteSeparateObjects )
{
//clean up conversion objects
......@@ -123,6 +127,8 @@ MergePlugin::MergePlugin() :
/// init the Toolbox
void MergePlugin::initializePlugin() {
if ( ! OpenFlipper::Options::gui())
return;
tool_ = new MergeToolBox();
QSize size(300, 300);
......@@ -140,12 +146,28 @@ void MergePlugin::initializePlugin() {
void MergePlugin::pluginsInitialized()
{
//populate scripting function
emit setSlotDescription("mergeObjects(const std::vector< BaseObjectData* >,QString,bool)", "Merges multiple meshes into one mesh. returns the ID of the new mesh or -1 in case of error.",
emit setSlotDescription("mergeObjects(const std::vector< BaseObjectData* >,QString,bool,DataType)", "Merges multiple meshes into one mesh. returns the ID of the new mesh or -1 in case of error.",
QString("objects,mergedName,deleteSeparateObjects").split(","),
QString(" vector of BaseObjectData* containing Poly or TriMeshes to be merged, name for the merged object, flag to remove separated objects default is true").split(","));
QString(" vector of BaseObjectData* containing Poly or TriMeshes to be merged, name for the merged object, flag to remove separated objects default is true, DataType for the new mesh if used in nogui mode").split(","));
emit setSlotDescription("mergeObjects(IdList,QString,bool,DataType)", "Merges multiple meshes into one mesh. returns the ID of the new mesh or -1 in case of error.",
QString("objects,mergedName,deleteSeparateObjects").split(","),
QString(" vector of Object Ids of Poly or TriMeshes to be merged, name for the merged object, flag to remove separated objects default is true, DataType for the new mesh if used in nogui mode").split(","));
}
int MergePlugin::mergeObjects(const std::vector< BaseObjectData* > & _objects, QString _name, bool _deleteSeparateObjects)
int MergePlugin::mergeObjects(IdList _objects, QString _name, bool _deleteSeparateObjects, DataType _type)
{
std::vector< BaseObjectData* > objects;
for(int i : _objects)
{
BaseObject* obj;
PluginFunctions::getObject(i,obj);
objects.push_back(PluginFunctions::baseObjectData(obj));
}
return mergeObjects(objects, _name, _deleteSeparateObjects, _type);
}
int MergePlugin::mergeObjects(const std::vector< BaseObjectData* > & _objects, QString _name, bool _deleteSeparateObjects, DataType _type)
{
int result = -1;
if (_objects.size() < 2)
......@@ -153,8 +175,11 @@ int MergePlugin::mergeObjects(const std::vector< BaseObjectData* > & _objects, Q
objects = _objects;
//check dataType
DataType type = checkType(objects);
DataType type;
if ( OpenFlipper::Options::gui())
type = checkType(objects);
else
type = _type;
//user pushed the cancel button
if(type != DATA_TRIANGLE_MESH && type != DATA_POLY_MESH)
......
......@@ -63,6 +63,10 @@ private :
DataType checkType(const std::vector< BaseObjectData* > &);
private slots :
// Tell system that this plugin runs without ui
void noguiSupported( ) {} ;
public slots:
// BaseInterface
void initializePlugin();
......@@ -77,7 +81,17 @@ public slots:
* @param _deleteSeparateObjects flag to determine if the separate objects shall be deleted after merging (default is true)
* @return
*/
int mergeObjects(const std::vector< BaseObjectData* > & _objects, QString _name = "merged object", bool _deleteSeparateObjects = true);
int mergeObjects(const std::vector< BaseObjectData* > & _objects, QString _name = "merged object", bool _deleteSeparateObjects = true, DataType type_ = typeId("TriangleMesh"));
/**
* @brief mergeObjects
* @param _objects
* @param _name
* @param _deleteSeparateObjects
* @param type_
* @return
*/
int mergeObjects(IdList _objects, QString _name = "merged object", bool _deleteSeparateObjects = true, DataType type_ = typeId("TriangleMesh"));
/**
* @brief slotCleanup is called when the cleanup event is processed at the end of mergeObjects.
......
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