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

Plugin Collections for file, type and postprocessor plugins



git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@15803 383ad7c9-94d9-4d36-a494-682f7c89f535
parents
include (plugin)
openflipper_plugin ( TRANSLATION_LANGUAGES de_DE )
#include <QtGui>
#include <QFileInfo>
#include "FilePolyLine.hh"
#include <iostream>
#include <ACG/GL/GLState.hh>
#include "OpenFlipper/BasePlugin/PluginFunctions.hh"
#include "OpenFlipper/common/GlobalOptions.hh"
#include <OpenMesh/Core/IO/IOManager.hh>
#include <OpenFlipper/ACGHelper/DrawModeConverter.hh>
void FilePolyLinePlugin::initializePlugin() {
// Data type has already been added by polyline type plugin
}
QString FilePolyLinePlugin::getLoadFilters() {
return QString( tr("Poly-Line files ( *.pol )" ));
};
QString FilePolyLinePlugin::getSaveFilters() {
return QString( tr("Poly-Line files ( *.pol )" ));
};
DataType FilePolyLinePlugin::supportedType() {
DataType type = DATA_POLY_LINE;
return type;
}
int FilePolyLinePlugin::loadObject(QString _filename)
{
int id = -1;
emit addEmptyObject( DATA_POLY_LINE, id );
PolyLineObject* pol(0);
if(PluginFunctions::getObject( id, pol))
{
pol->line()->load(_filename.toAscii());
pol->setFromFileName(_filename);
pol->setName(QFileInfo(_filename).fileName());
}
emit openedFile( pol->id() );
return id;
};
bool FilePolyLinePlugin::saveObject(int _id, QString _filename)
{
BaseObjectData* obj(0);
if(PluginFunctions::getObject( _id, obj))
{
PolyLineObject* pol = PluginFunctions::polyLineObject(obj);
if( pol)
{
std::cerr << "call Line Function\n";
std::cerr << (const char*) _filename.toAscii() << std::endl;
obj->setName(_filename.section(OpenFlipper::Options::dirSeparator(),-1));
obj->setPath(_filename.section(OpenFlipper::Options::dirSeparator(),0,-2) );
pol->line()->save((const char*) _filename.toAscii());
}
}
return true;
}
void FilePolyLinePlugin::loadIniFileLast( INIFile& _ini ,int _id ) {
BaseObjectData* baseObject;
if ( !PluginFunctions::getObject(_id,baseObject) ) {
emit log(LOGERR,tr("Cannot find object for id %1 in saveFile!").arg(_id));
return;
}
PolyLineObject* object = PluginFunctions::polyLineObject(baseObject);
if ( object ) {
ACG::Vec4f col(0.0,0.0,0.0,0.0);
if ( _ini.get_entryVecf( col, object->name() , "BaseColor" ) )
object->materialNode()->set_base_color(col);
}
}
void FilePolyLinePlugin::saveIniFile( INIFile& _ini ,int _id) {
BaseObjectData* baseObject;
if ( !PluginFunctions::getObject(_id,baseObject) ) {
emit log(LOGERR,tr("Cannot find object for id %1 in saveFile!").arg(_id) );
return;
}
PolyLineObject* object = PluginFunctions::polyLineObject(baseObject);
if ( object ) {
_ini.add_entryVec( object->name() ,
"BaseColor" ,
object->materialNode()->base_color() ) ;
}
}
Q_EXPORT_PLUGIN2( filepolylineplugin , FilePolyLinePlugin );
#ifndef FILEPOLYLINEPLUGIN_HH
#define FILEPOLYLINEPLUGIN_HH
#include <QObject>
#include <QMenuBar>
#include <OpenFlipper/common/Types.hh>
#include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/FileInterface.hh>
#include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/BasePlugin/ScriptInterface.hh>
#include <OpenFlipper/BasePlugin/INIInterface.hh>
#include <ObjectTypes/PolyLine/PolyLine.hh>
class FilePolyLinePlugin : public QObject, BaseInterface, FileInterface, LoadSaveInterface, LoggingInterface, ScriptInterface, INIInterface
{
Q_OBJECT
Q_INTERFACES(FileInterface)
Q_INTERFACES(LoadSaveInterface)
Q_INTERFACES(LoggingInterface)
Q_INTERFACES(BaseInterface)
Q_INTERFACES(ScriptInterface)
Q_INTERFACES(INIInterface)
signals:
void openedFile( int _id );
void addEmptyObject( DataType _type, int& _id);
void load(QString _filename, DataType _type, int& _id);
void save(int _id , QString _filename );
void log(Logtype _type, QString _message);
void log(QString _message);
void emptyObjectAdded( int _id );
private slots:
void fileOpened( int /*_id*/ ){};
void loadIniFileLast( INIFile& _ini ,int _id );
void saveIniFile( INIFile& _ini ,int _id);
void noguiSupported( ) {} ;
void initializePlugin();
public :
~FilePolyLinePlugin() {};
QString name() { return (QString("FilePolyLine")); };
QString description( ) { return (QString(tr("Load/Save Poly Lines"))); };
DataType supportedType();
QString getSaveFilters();
QString getLoadFilters();
QWidget* saveOptionsWidget(QString /*_currentFilter*/) { return 0; };
QWidget* loadOptionsWidget(QString /*_currentFilter*/) { return 0; };
public slots:
int loadObject(QString _filename);
bool saveObject(int _id, QString _filename);
QString version() { return QString("1.01"); };
};
#endif //FILEPOLYLINEPLUGIN_HH
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="de_DE" sourcelanguage="en">
<context>
<name>FilePolyLinePlugin</name>
<message>
<location filename="../FilePolyLine.cc" line="18"/>
<source>Polygonal Line</source>
<translation>Polygonale Linie</translation>
</message>
<message>
<location filename="../FilePolyLine.cc" line="23"/>
<location filename="../FilePolyLine.cc" line="27"/>
<source>Poly-Line files ( *.pol )</source>
<translation>Poly Linien Dateien</translation>
</message>
<message>
<location filename="../FilePolyLine.cc" line="113"/>
<location filename="../FilePolyLine.cc" line="131"/>
<source>Cannot find object for id %1 in saveFile!</source>
<translation>Kann Objekt mit der Nummer %1 nicht finden!</translation>
</message>
<message>
<location filename="../FilePolyLine.cc" line="155"/>
<location filename="../FilePolyLine.cc" line="169"/>
<source>PolyLine %1.pol</source>
<translation>PolygonaleLinie %1.pol</translation>
</message>
<message>
<location filename="../FilePolyLine.hh" line="52"/>
<source>Load/Save Poly Lines</source>
<translation>Lade/Speichere Polygonale Linien</translation>
</message>
</context>
</TS>
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