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

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
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