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

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@14869 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 6012d50b
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() ) ;
}
}
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 );
#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 slots:
// Deprecated
int addEmpty() { return -1; };
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);
int addNewPolyLine();
QString version() { return QString("1.01"); };
private :
QString get_unique_name(PolyLineObject* _object);
};
#endif //FILEPOLYLINEPLUGIN_HH
#include "FilePolyLine.hh"
int FilePolyLinePlugin::addNewPolyLine( ) {
return addEmpty();
}
<?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>
include (plugin)
openflipper_plugin ( INSTALLDATA Icons )
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision: 6753 $ *
* $Author: kremer $ *
* $Date: 2009-08-05 12:38:20 +0200 (Mi, 05. Aug 2009) $ *
* *
\*===========================================================================*/
#include "TypePolyLine.hh"
#include "OpenFlipper/BasePlugin/PluginFunctions.hh"
TypePolyLinePlugin::TypePolyLinePlugin() {
}
bool TypePolyLinePlugin::registerType() {
addDataType("PolyLine",tr("PolyLine"));
setTypeIcon( "PolyLine", "PolyLineType.png");
return true;
}
int TypePolyLinePlugin::addEmpty(){
// new object data struct
PolyLineObject * object = new PolyLineObject();
if ( PluginFunctions::objectCount() == 1 )
object->target(true);
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() );
// 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 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 );
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision: 7683 $ *
* $Author: kremer $ *
* $Date: 2009-11-30 13:51:21 +0100 (Mo, 30. Nov 2009) $ *
* *
\*===========================================================================*/
#ifndef TYPEPOLYLINEPLUGIN_HH
#define TYPEPOLYLINEPLUGIN_HH
#include <QObject>
#include <OpenFlipper/common/Types.hh>
#include <ObjectTypes/PolyLine/PolyLine.hh>
#include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/BasePlugin/TypeInterface.hh>
class TypePolyLinePlugin : 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( ) {} ;
public :
~TypePolyLinePlugin() {};
TypePolyLinePlugin();
QString name() { return (QString("TypePolyLine")); };
QString description( ) { return (QString(tr("Register PolyLine type"))); };
bool registerType();
public slots:
// Base Interface
QString version() { return QString("1.0"); };
// Type Interface
int addEmpty();
DataType supportedType() { return DATA_POLY_LINE; };
private:
/// Return unique name for object
QString get_unique_name(PolyLineObject* _object);
};
#endif //TYPEPOLYLINEPLUGIN_HH
Supports Markdown
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