Commit 49723191 authored by Jan Möbius's avatar Jan Möbius

Removed the get_unique_name functions when adding any object, as this would...

Removed the get_unique_name functions when adding any object, as this would cause linear time when adding new objects.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@15115 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 70d09c85
......@@ -309,32 +309,5 @@ bool FileLightPlugin::saveObject(int _id, QString _filename)
return true;
}
QString FileLightPlugin::get_unique_name(LightObject* _object)
{
bool name_unique = false;
int cur_idx = _object->id();
while(!name_unique)
{
name_unique = true;
QString cur_name = QString(tr("Light %1.lgt").arg( cur_idx ));
PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS, DATA_LIGHT );
for(; o_it != PluginFunctions::objectsEnd(); ++o_it)
{
if( o_it->name() == cur_name)
{
name_unique = false;
cur_idx += 10;
break;
}
}
}
return QString(tr("Light %1.lgt").arg( cur_idx ));
}
Q_EXPORT_PLUGIN2( filelightplugin , FileLightPlugin );
......@@ -103,9 +103,6 @@ class FileLightPlugin : public QObject, BaseInterface, FileInterface, LoadSaveIn
QString version() { return QString("1.0"); };
private :
QString get_unique_name(LightObject* _object);
};
#endif //FILELIGHTPLUGIN_HH
......@@ -154,32 +154,5 @@ bool FilePlaPlugin::saveObject(int _id, QString _filename)
return true;
}
QString FilePlaPlugin::get_unique_name(PlaneObject* _object)
{
bool name_unique = false;
int cur_idx = _object->id();
while(!name_unique)
{
name_unique = true;
QString cur_name = QString(tr("Plane %1.pla").arg( cur_idx ));
PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS, DATA_PLANE );
for(; o_it != PluginFunctions::objectsEnd(); ++o_it)
{
if( o_it->name() == cur_name)
{
name_unique = false;
cur_idx += 10;
break;
}
}
}
return QString(tr("Plane %1.pla").arg( cur_idx ));
}
Q_EXPORT_PLUGIN2( fileplaplugin , FilePlaPlugin );
......@@ -101,9 +101,6 @@ class FilePlaPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInte
QString version() { return QString("1.0"); };
private :
QString get_unique_name(PlaneObject* _object);
};
#endif //FILEPLAPLUGIN_HH
......@@ -106,33 +106,5 @@ void FilePolyLinePlugin::saveIniFile( INIFile& _ini ,int _id) {
}
}
QString FilePolyLinePlugin::get_unique_name(PolyLineObject* _object)
{
bool name_unique = false;
int cur_idx = _object->id();
while(!name_unique)
{
name_unique = true;
QString cur_name = QString(tr("PolyLine %1.pol").arg( cur_idx ));
PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS, DATA_POLY_LINE );
for(; o_it != PluginFunctions::objectsEnd(); ++o_it)
{
if( o_it->name() == cur_name)
{
name_unique = false;
cur_idx += 10;
break;
}
}
}
return QString(tr("PolyLine %1.pol").arg( cur_idx ));
}
Q_EXPORT_PLUGIN2( filepolylineplugin , FilePolyLinePlugin );
......@@ -67,9 +67,6 @@ class FilePolyLinePlugin : public QObject, BaseInterface, FileInterface, LoadSav
QString version() { return QString("1.01"); };
private :
QString get_unique_name(PolyLineObject* _object);
};
#endif //FILEPOLYLINEPLUGIN_HH
......@@ -367,32 +367,5 @@ void FileSKLPlugin::saveIniFile( INIFile& _ini ,int _id) {
}
QString FileSKLPlugin::get_unique_name(SkeletonObject* _object)
{
bool name_unique = false;
int cur_idx = _object->id();
while(!name_unique)
{
name_unique = true;
QString cur_name = QString("Skeleton " + QString::number( cur_idx ) + ".skl");
PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS, DATA_SKELETON );
for(; o_it != PluginFunctions::objectsEnd(); ++o_it)
{
if( o_it->name() == cur_name)
{
name_unique = false;
cur_idx += 10;
break;
}
}
}
return QString("Skeleton " + QString::number( cur_idx ) + ".skl");
}
Q_EXPORT_PLUGIN2( filesklplugin , FileSKLPlugin );
......@@ -109,7 +109,6 @@ class FileSKLPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInte
template<typename Skeleton> bool LoadSkeleton(Skeleton *_pSkeleton, QString _filename);
template<typename Skeleton> bool SaveSkeleton(Skeleton *_pSkeleton, QString _filename);
QString get_unique_name(SkeletonObject* _object);
};
#endif //FILESKLPLUGIN_HH
......@@ -186,32 +186,6 @@ bool FileSPHPlugin::saveObject(int _id, QString _filename)
return true;
}
QString FileSPHPlugin::get_unique_name(SphereObject* _object)
{
bool name_unique = false;
int cur_idx = _object->id();
while(!name_unique)
{
name_unique = true;
QString cur_name = QString(tr("Sphere %1.sph").arg( cur_idx ));
PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS, DATA_SPHERE );
for(; o_it != PluginFunctions::objectsEnd(); ++o_it)
{
if( o_it->name() == cur_name)
{
name_unique = false;
cur_idx += 10;
break;
}
}
}
return QString(tr("Sphere %1.sph").arg( cur_idx ));
}
Q_EXPORT_PLUGIN2( filesphplugin , FileSPHPlugin );
......@@ -103,9 +103,6 @@ class FileSPHPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInte
QString version() { return QString("1.0"); };
private :
QString get_unique_name(SphereObject* _object);
};
#endif //FILESPHPLUGIN_HH
......@@ -114,7 +114,7 @@ int TypeCameraPlugin::addEmpty() {
object->target ( true );
}
QString name = get_unique_name ( object );
QString name = QString(tr("New Camera %1.cam").arg( object->id() ));
// call the local function to update names
object->setName ( name );
......@@ -130,32 +130,5 @@ int TypeCameraPlugin::addEmpty() {
return object->id();
}
QString TypeCameraPlugin::get_unique_name ( CameraObject* _object ) {
bool name_unique = false;
int cur_idx = _object->id();
while ( !name_unique ) {
name_unique = true;
QString cur_name = QString ( tr ( "Camera %1.off" ).arg ( cur_idx ) );
PluginFunctions::ObjectIterator o_it ( PluginFunctions::ALL_OBJECTS, DATA_CAMERA );
for ( ; o_it != PluginFunctions::objectsEnd(); ++o_it ) {
if ( o_it->name() == cur_name ) {
name_unique = false;
cur_idx += 10;
break;
}
}
}
return QString ( tr ( "Camera %1.off" ).arg ( cur_idx ) );
}
Q_EXPORT_PLUGIN2 ( typecameraplugin , TypeCameraPlugin );
......@@ -109,9 +109,6 @@ class TypeCameraPlugin : public QObject, BaseInterface, LoadSaveInterface, Loggi
void contextMenuClicked(QAction* _contextAction);
private:
/// Return unique name for object
QString get_unique_name(CameraObject* _object);
QMenu* contextMenu_;
......
......@@ -64,7 +64,7 @@ int TypeCoordsysPlugin::addEmpty(){
if (PluginFunctions::targetCount() == 0 )
object->target(true);
QString name = get_unique_name(object);
QString name = QString(tr("New Coordinate System %1.cos").arg( object->id() ));
// call the local function to update names
QFileInfo f(name);
......@@ -79,32 +79,5 @@ int TypeCoordsysPlugin::addEmpty(){
return object->id();
}
QString TypeCoordsysPlugin::get_unique_name(CoordsysObject* _object)
{
bool name_unique = false;
int cur_idx = _object->id();
while(!name_unique)
{
name_unique = true;
QString cur_name = QString(tr("Coordsys %1.cos").arg( cur_idx ));
PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS, DATA_COORDSYS );
for(; o_it != PluginFunctions::objectsEnd(); ++o_it)
{
if( o_it->name() == cur_name)
{
name_unique = false;
cur_idx += 10;
break;
}
}
}
return QString(tr("Coordsys %1.cos").arg( cur_idx ));
}
Q_EXPORT_PLUGIN2( typecoordsysplugin , TypeCoordsysPlugin );
......@@ -94,11 +94,6 @@ class TypeCoordsysPlugin : public QObject, BaseInterface, LoggingInterface, Type
DataType supportedType() { return DATA_COORDSYS; };
private:
/// Return unique name for object
QString get_unique_name(CoordsysObject* _object);
};
#endif //TYPECOORDSYSPLUGIN_HH
......@@ -128,7 +128,7 @@ int TypeHexahedralMeshPlugin::addEmpty() {
if (PluginFunctions::targetCount() == 0)
object->target(true);
QString name = get_unique_name(object);
QString name = QString(tr("New Hexahedral Mesh %1.ovm").arg( object->id() ));
// call the local function to update names
QFileInfo f(name);
......@@ -157,33 +157,6 @@ int TypeHexahedralMeshPlugin::addEmpty() {
//----------------------------------------------------------------------------
QString TypeHexahedralMeshPlugin::get_unique_name(HexahedralMeshObject* _object) {
bool name_unique = false;
int cur_idx = _object->id();
while (!name_unique) {
name_unique = true;
QString cur_name = QString(tr("Mesh HexahedralMesh %1.ovm").arg(cur_idx));
PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS, DATA_HEXAHEDRAL_MESH);
for (; o_it != PluginFunctions::objectsEnd(); ++o_it) {
if (o_it->name() == cur_name) {
name_unique = false;
cur_idx += 10;
break;
}
}
}
return QString(tr("Mesh HexahedralMesh %1.ovm").arg(cur_idx));
}
//----------------------------------------------------------------------------
void TypeHexahedralMeshPlugin::slotKeyEvent(QKeyEvent* _event) {
switch (_event->key()) {
......
......@@ -140,8 +140,6 @@ public slots:
private:
QString get_unique_name(HexahedralMeshObject* _object);
QAction* render_switch_;
QAction* translucency_action_;
......
......@@ -368,7 +368,7 @@ int TypeLightPlugin::addEmpty() {
// new object data struct
LightObject * object = new LightObject();
QString name = get_unique_name(object);
QString name = QString(tr("New Light %1.lgt").arg( object->id() ));
// call the local function to update names
QFileInfo f(name);
......@@ -418,13 +418,6 @@ void TypeLightPlugin::objectDeleted(int _id) {
}
QString TypeLightPlugin::get_unique_name(LightObject* _object) {
int cur_idx = _object->id();
return QString(tr("Light new %1.lgt").arg( cur_idx ));
}
float TypeLightPlugin::findDepth() {
// Init depth
......
......@@ -173,9 +173,6 @@ class TypeLightPlugin : public QObject, BaseInterface, LoadSaveInterface, Loggin
private:
/// Return unique name for object
QString get_unique_name(LightObject* _object);
/// Find depth of nearest light source
float findDepth();
......
......@@ -66,7 +66,7 @@ int TypePlanePlugin::addEmpty(){
if (PluginFunctions::targetCount() == 0 )
object->target(true);
QString name = get_unique_name(object);
QString name = QString(tr("New Plane %1.pla").arg( object->id() ));
// call the local function to update names
QFileInfo f(name);
......@@ -81,12 +81,5 @@ int TypePlanePlugin::addEmpty(){
return object->id();
}
QString TypePlanePlugin::get_unique_name(PlaneObject* _object)
{
int cur_idx = _object->id();
return QString(tr("Plane new %1.pla").arg( cur_idx ));
}
Q_EXPORT_PLUGIN2( typeplaneplugin , TypePlanePlugin );
......@@ -94,11 +94,6 @@ class TypePlanePlugin : public QObject, BaseInterface, LoadSaveInterface, Loggin
int addEmpty();
DataType supportedType() { return DATA_PLANE; };
private:
/// Return unique name for object
QString get_unique_name(PlaneObject* _object);
};
#endif //TYPEPLANEPLUGIN_HH
......@@ -66,9 +66,7 @@ int TypePolyLinePlugin::addEmpty(){
if (PluginFunctions::targetCount() == 0 )
object->target(true);
// Unique name is too slow as it iterates over all objects!
// QString name = get_unique_name(object);
QString name = tr("PolyLine New %1.pol").arg( object->id() );
QString name = tr("New PolyLine %1.pol").arg( object->id() );
// call the local function to update names
QFileInfo f(name);
......@@ -85,14 +83,5 @@ int TypePolyLinePlugin::addEmpty(){
return object->id();
}
QString TypePolyLinePlugin::get_unique_name(PolyLineObject* _object)
{
// bool name_unique = false;
int cur_idx = _object->id();
return QString(tr("PolyLine new %1.pol").arg( cur_idx ));
}
Q_EXPORT_PLUGIN2( typepolylineplugin , TypePolyLinePlugin );
......@@ -90,11 +90,6 @@ class TypePolyLinePlugin : public QObject, BaseInterface, LoadSaveInterface, Log
// Type Interface
int addEmpty();
DataType supportedType() { return DATA_POLY_LINE; };
private:
/// Return unique name for object
QString get_unique_name(PolyLineObject* _object);
};
......
......@@ -75,7 +75,7 @@ int TypePolyMeshPlugin::addEmpty(){
if (PluginFunctions::targetCount() == 0 )
object->target(true);
QString name = get_unique_name(object);
QString name = QString(tr("New PolyMesh %1.off").arg( object->id() ));
// call the local function to update names
QFileInfo f(name);
......@@ -92,17 +92,6 @@ int TypePolyMeshPlugin::addEmpty(){
//-----------------------------------------------------------------------------
QString TypePolyMeshPlugin::get_unique_name(PolyMeshObject* _object)
{
int cur_idx = _object->id();
QString cur_name = QString(tr("PolyMesh new %1.off").arg( cur_idx + 1 ));
return QString(tr("PolyMesh new %1.off").arg( cur_idx + 1 ));
}
//-----------------------------------------------------------------------------
void TypePolyMeshPlugin::generateBackup( int _id, QString _name, UpdateType _type ){
BaseObjectData* object = 0;
......
......@@ -98,11 +98,6 @@ class TypePolyMeshPlugin : public QObject, BaseInterface, LoadSaveInterface, Log
// Type Interface
void generateBackup( int _id, QString _name, UpdateType _type );
private:
/// Return unique name for object
QString get_unique_name(PolyMeshObject* _object);
};
#endif //TYPEPOLYMESHPLUGIN_HH
......@@ -111,7 +111,7 @@ int TypePolyhedralMeshPlugin::addEmpty() {
if (PluginFunctions::targetCount() == 0)
object->target(true);
QString name = get_unique_name(object);
QString name = QString(tr("New PolyHedral Mesh %1.ovm").arg( object->id() ));
// call the local function to update names
QFileInfo f(name);
......@@ -137,30 +137,6 @@ int TypePolyhedralMeshPlugin::addEmpty() {
return object->id();
}
QString TypePolyhedralMeshPlugin::get_unique_name(PolyhedralMeshObject* _object) {
bool name_unique = false;
int cur_idx = _object->id();
while (!name_unique) {
name_unique = true;
QString cur_name = QString(tr("Polyhedral Mesh %1.ovm").arg(cur_idx));
PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS, DATA_POLYHEDRAL_MESH);
for (; o_it != PluginFunctions::objectsEnd(); ++o_it) {
if (o_it->name() == cur_name) {
name_unique = false;
cur_idx += 10;
break;
}
}
}
return QString(tr("Polyhedral Mesh %1.ovm").arg(cur_idx));
}
//----------------------------------------------------------------------------
......
......@@ -129,8 +129,6 @@ public slots:
private:
QString get_unique_name(PolyhedralMeshObject* _object);
QAction* render_switch_;
QAction* translucency_action_;
......
......@@ -192,7 +192,7 @@ int TypeSkeletonPlugin::addEmpty(){
if (PluginFunctions::targetCount() == 0 )
object->target(true);
QString name = get_unique_name(object);
QString name = QString(tr("New Skeleton %1.skl").arg( object->id() ));
// call the local function to update names
QFileInfo f(name);
......@@ -207,14 +207,6 @@ int TypeSkeletonPlugin::addEmpty(){
return object->id();
}
QString TypeSkeletonPlugin::get_unique_name(SkeletonObject* _object)
{
int cur_idx = _object->id();
return QString(tr("Skeleton new %1.off").arg( cur_idx ));
}
void TypeSkeletonPlugin::generateBackup( int _id, QString _name, UpdateType _type ){
BaseObjectData* object = 0;
......
......@@ -114,11 +114,6 @@ class TypeSkeletonPlugin : public QObject, BaseInterface, LoadSaveInterface, Log
// Type Interface
void generateBackup( int _id, QString _name, UpdateType _type );
private:
/// Return unique name for object
QString get_unique_name(SkeletonObject* _object);
};
#endif //TYPESKELETONPLUGIN_HH
......@@ -67,7 +67,7 @@ int TypeSpherePlugin::addEmpty(){
if (PluginFunctions::targetCount() == 0 )
object->target(true);
QString name = get_unique_name(object);
QString name = QString(tr("New Sphere %1.sph").arg( object->id() ));
// call the local function to update names
QFileInfo f(name);
......@@ -82,32 +82,5 @@ int TypeSpherePlugin::addEmpty(){
return object->id();
}
QString TypeSpherePlugin::get_unique_name(SphereObject* _object)
{
bool name_unique = false;
int cur_idx = _object->id();
while(!name_unique)
{
name_unique = true;
QString cur_name = QString(tr("Sphere %1.sph").arg( cur_idx ));
PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS, DATA_SPHERE );
for(; o_it != PluginFunctions::objectsEnd(); ++o_it)
{
if( o_it->name() == cur_name)
{
name_unique = false;
cur_idx += 10;
break;
}
}
}
return QString(tr("Sphere %1.sph").arg( cur_idx ));
}
Q_EXPORT_PLUGIN2( typesphereplugin , TypeSpherePlugin );
......@@ -94,11 +94,6 @@ class TypeSpherePlugin : public QObject, BaseInterface, LoadSaveInterface, Loggi
int addEmpty();
DataType supportedType() { return DATA_SPHERE; };
private:
/// Return unique name for object
QString get_unique_name(SphereObject* _object);
};
#endif //TYPESPHEREPLUGIN_HH
......@@ -215,7 +215,7 @@ int TypeSplatCloudPlugin::addEmpty()
if( PluginFunctions::targetCount() == 0 )
object->target( true );
QString name = get_unique_name( object );
QString name = QString(tr("New Splat Cloud %1.spl").arg( object->