Commit ae393126 authored by Mike Kremer's avatar Mike Kremer

Implemented new addEmpty() and supportedType() in TypePlane plugin.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7841 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 211877f6
......@@ -41,11 +41,9 @@
\*===========================================================================*/
#include "TypePlane.hh"
#include "OpenFlipper/BasePlugin/PluginFunctions.hh"
TypePlanePlugin::TypePlanePlugin() {
......@@ -57,5 +55,60 @@ bool TypePlanePlugin::registerType() {
return true;
}
int TypePlanePlugin::addEmpty( DataType _type ){
// new object data struct
PlaneObject * object = new PlaneObject(dynamic_cast < ACG::SceneGraph::SeparatorNode* >( PluginFunctions::getRootNode() ));
if ( PluginFunctions::objectCount() == 1 )
object->target(true);
if (PluginFunctions::targetCount() == 0 )
object->target(true);
QString name = get_unique_name(object);
// call the local function to update names
QFileInfo f(name);
object->setName( f.fileName() );
object->update();
object->show();
emit log(LOGINFO, object->getObjectinfo());
emit emptyObjectAdded (object->id() );
return object->id();
}
QString TypePlanePlugin::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( typeplaneplugin , TypePlanePlugin );
......@@ -48,17 +48,29 @@
#include <QObject>
#include <OpenFlipper/common/Types.hh>
#include <ObjectTypes/Plane/Plane.hh>
#include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/BasePlugin/TypeInterface.hh>
class TypePlanePlugin : public QObject, BaseInterface, TypeInterface
class TypePlanePlugin : public QObject, BaseInterface, LoadSaveInterface, LoggingInterface, TypeInterface
{
Q_OBJECT
Q_INTERFACES(BaseInterface)
Q_INTERFACES(LoadSaveInterface)
Q_INTERFACES(LoggingInterface)
Q_INTERFACES(TypeInterface)
signals:
// Logging interface
void log(Logtype _type, QString _message);
void log(QString _message);
// LoadSave Interface
void emptyObjectAdded( int _id );
private slots:
void noguiSupported( ) {} ;
......@@ -69,13 +81,23 @@ class TypePlanePlugin : public QObject, BaseInterface, TypeInterface
TypePlanePlugin();
QString name() { return (QString("TypePlane")); };
QString description( ) { return (QString(tr("Register Plane type "))); };
QString description( ) { return (QString(tr("Register Plane type"))); };
bool registerType();
public slots:
// Base Interface
QString version() { return QString("1.0"); };
// Type Interface
int addEmpty( DataType _type );
DataType supportedType() { return DATA_PLANE; };
private:
/// Return unique name for object
QString get_unique_name(PlaneObject* _object);
};
......
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