64 #include "OpenFlipper/BasePlugin/PluginFunctionsCore.hh" 82 if ( OpenFlipper::Options::doSlotDebugging() ) {
83 if ( sender() != 0 ) {
84 if ( sender()->metaObject() != 0 ) {
86 + tr(
" ) called by ") + QString( sender()->metaObject()->className() ) );
89 emit
log(
LOGINFO,
"updatedObject( " + QString::number(_identifier) +
", " +
updateTypeName(_type) + tr(
" ) called by Core") );
94 OpenFlipper::Options::redrawDisabled(
true);
98 if ( _identifier != -1 ) {
100 emit
log(
LOGERR,tr(
"updated_objects called for non existing object with id : ") + QString::number(_identifier) );
107 if ( _identifier == -1 ) {
109 if ( sender() != 0 ) {
110 if ( sender()->metaObject() != 0 ) {
112 + tr(
" ) called by ") + QString( sender()->metaObject()->className() + tr(
" which is inefficient)") ) );
115 emit
log(
LOGWARN,
"updatedObject( " + QString::number(_identifier) +
", " +
updateTypeName(_type) + tr(
" ) called by Core, which is inefficient!") );
137 object->update(_type);
140 OpenFlipper::Options::redrawDisabled(
false);
188 if (QThread::currentThread() != QApplication::instance()->thread())
191 QMetaObject::invokeMethod(
this,
"slotAddTexture",Qt::BlockingQueuedConnection, Q_ARG(QString, _textureName), Q_ARG(QString, _filename), Q_ARG(uint, _dimension), Q_ARG(
int, _id));
195 if ( OpenFlipper::Options::doSlotDebugging() ) {
196 if ( sender() != 0 ) {
197 if ( sender()->metaObject() != 0 ) {
198 emit
log(
LOGINFO,
"addTexture( " + _textureName +
"," + _filename +
"," + QString::number(_dimension) +
", " + QString::number(_id) + tr(
" ) called by ") +
199 QString( sender()->metaObject()->className() ) );
202 emit
log(
LOGINFO,
"addTexture( " + _textureName +
"," + _filename +
"," + QString::number(_dimension) +
", " + QString::number(_id) + tr(
" ) called by Core") );
206 emit
addTexture(_textureName , _filename,_dimension,_id);
214 if (QThread::currentThread() != QApplication::instance()->thread())
217 QMetaObject::invokeMethod(
this,
"slotAddTexture",Qt::BlockingQueuedConnection, Q_ARG(QString, _textureName), Q_ARG(QString, _filename), Q_ARG(uint, _dimension));
221 if ( OpenFlipper::Options::doSlotDebugging() ) {
222 if ( sender() != 0 ) {
223 if ( sender()->metaObject() != 0 ) {
224 emit
log(
LOGINFO,
"slotAddTexture( " + _textureName +
"," + _filename +
"," + QString::number(_dimension) + tr(
" ) called by ") +
225 QString( sender()->metaObject()->className() ) );
228 emit
log(
LOGINFO,
"slotAddTexture( " + _textureName +
"," + _filename +
"," +
", " + QString::number(_dimension) + tr(
" ) called by Core") );
232 emit
addTexture(_textureName , _filename,_dimension);
240 if ( OpenFlipper::Options::doSlotDebugging() ) {
241 if ( sender() != 0 ) {
242 if ( sender()->metaObject() != 0 ) {
243 emit
log(
LOGINFO,
"slotUpdateTexture( " + _name +
" , " + QString::number(_identifier) + tr(
" ) called by ") +
244 QString( sender()->metaObject()->className() ) );
258 if (QThread::currentThread() != QApplication::instance()->thread())
261 QMetaObject::invokeMethod(
this,
"slotMultiTextureAdded",Qt::BlockingQueuedConnection, Q_ARG(QString, _textureGroup), Q_ARG(QString, _name), Q_ARG(QString, _filename), Q_ARG(
int, _id), Q_ARG(
int*, &_textureId));
265 if ( OpenFlipper::Options::doSlotDebugging() ) {
266 if ( sender() != 0 ) {
267 if ( sender()->metaObject() != 0 ) {
268 emit
log(
LOGINFO,
"slotMultiTextureAdded( " + _textureGroup +
", " + _name +
"," + _filename +
"," + QString::number(_id) + tr(
" ) called by ") +
269 QString( sender()->metaObject()->className() ) );
272 emit
log(
LOGINFO,
"slotMultiTextureAdded( " + _textureGroup +
", " + _name +
"," + _filename +
"," + QString::number(_id) + tr(
" ) called by Core") );
276 emit
addMultiTexture( _textureGroup , _name , _filename , _id , _textureId );
291 if ( OpenFlipper::Options::doSlotDebugging() ) {
292 if ( sender() != 0 ) {
293 if ( sender()->metaObject() != 0 ) {
294 emit
log(
LOGINFO,
"slotSetTextureMode( " + _textureName +
" , " + _mode +
" , " + QString::number(_id) + tr(
" ) called by ") +
295 QString( sender()->metaObject()->className() ) );
308 if ( OpenFlipper::Options::doSlotDebugging() ) {
309 if ( sender() != 0 ) {
310 if ( sender()->metaObject() != 0 ) {
311 emit
log(
LOGINFO,
"slotSetTextureMode( " + _textureName +
" , " + _mode + tr(
" ) called by ") +
312 QString( sender()->metaObject()->className() ) );
324 if ( OpenFlipper::Options::doSlotDebugging() ) {
325 if ( sender() != 0 ) {
326 if ( sender()->metaObject() != 0 ) {
327 emit
log(
LOGINFO,
"slotTextureUpdated( " + _textureName +
" , " + QString::number(_identifier) + tr(
" ) called by ") +
328 QString( sender()->metaObject()->className() ) );
387 emit
textureName( _id, _textureIndex, _textureName);
423 emit
log(
LOGERR,tr(
"newObject received from objectManager with invalid id! This should not happen. The new Object will not work correctly!"));
437 QObject* plugin1 = 0;
438 QObject* plugin2 = 0;
440 for (
int i = 0 ; i < (int)
plugins_.size(); ++i ) {
441 if (
plugins_[i].rpcName == _pluginName1 ) {
444 if (
plugins_[i].rpcName == _pluginName2 ) {
449 if ( plugin1 == 0 ) {
450 emit
log(
LOGERR,tr(
"Cross Plugin Interconnection failed because plugin %1 was not found!").arg(_pluginName1));
454 if ( plugin2 == 0 ) {
455 emit
log(
LOGERR,tr(
"Cross Plugin Interconnection failed because plugin %1 was not found!").arg(_pluginName2));
460 connect(plugin1,_signal,plugin2,_slot);
467 renderManager().
setActive(_rendererName,_viewer);
471 _rendererName = renderManager().
active(_viewer)->
name;
474 void Core::slotMetadataDeserialized(
475 const QVector<QPair<QString, QString> > &data) {
477 QString obj_metadata;
478 for (QVector<QPair<QString, QString> >::const_iterator
479 it = data.begin(); it != data.end(); ++it) {
480 if (it->first ==
"Mesh Comments")
481 obj_metadata = it->second;
483 emit genericMetadataDeserialized(it->first, it->second);
489 QRegExp re_begin(
"BEGIN Comments for object \"([^\\n]*)\"");
490 QRegExp re_end(
"\\nEND Comments for object \"([^\\n]*)\"");
498 QString current_object_name;
499 for (STATE state = STATE_SEARCH_BEGIN; state != STATE_EOS; ) {
501 case STATE_SEARCH_BEGIN:
502 cursor = re_begin.indexIn(obj_metadata, cursor);
507 current_object_name = re_begin.cap(1);
508 cursor += re_begin.matchedLength();
509 state = STATE_CONSUME_INNER;
511 case STATE_CONSUME_INNER:
513 int next = re_end.indexIn(obj_metadata, cursor);
519 const QStringRef value = obj_metadata.midRef(cursor, next - cursor);
521 emit objectMetadataDeserialized(current_object_name, value.toString());
522 #if QT_VERSION >= 0x050000 523 QJsonParseError json_error;
524 QJsonDocument json_doc =
525 QJsonDocument::fromJson(value.toUtf8(), &json_error);
526 if (json_error.error == QJsonParseError::NoError) {
527 emit objectMetadataDeserializedJson(
528 current_object_name, json_doc);
531 cursor = next + re_end.matchedLength();
532 state = STATE_SEARCH_BEGIN;
536 throw std::logic_error(
"metadataDeserialized(): Invalid state.");
void getCurrentTexture(int _id, QString &_textureName)
get current texture
void objectSelectionChanged(int)
This signal is emitted if the object has been changed (source/target)
void resetScenegraph(bool _resetTrackBall)
void slotObjectSelectionChanged(int _id)
Called by Plugins if they changed the active object.
void updateAllTextures()
Update all textures in the plugins.
RendererInfo * active(int _id)
Get the current active renderer.
void signalObjectUpdated(int)
When this Signal is emitted all Plugins are informed that the object list changed.
void slotMultiTextureAdded(QString _textureGroup, QString _name, QString _filename, int _id, int &_textureId)
Called by a plugin if it creates a multitexture.
std::vector< PluginInfo > plugins_
List of all loaded plugins_.
void slotGetSubTextures(int _id, QString _multiTextureName, QStringList &_subTextures)
Called by plugins if a multi-texture's sub textures should be fetched.
void slotGetCurrentTexture(int _id, QString &_textureName)
Called by plugins if current texture should be retrieved.
void textureChangeImage(QString _textureName, QImage &_image)
Change the image for a given texture.
void getSubTextures(int _id, QString _multiTextureName, QStringList &_subTextures)
get a multi-texture's sub textures
void slotTextureGetImage(QString _textureName, QImage &_image)
Called by plugins if texture image should be fetched.
void textureIndexPropertyName(int _id, QString &_propertyName)
get the texture index property name
void slotTextureIndexPropertyName(int _id, QString &_propertyName)
Called by plugins if texture index property name should be fetched.
bool getObject(int _identifier, BSplineCurveObject *&_object)
void slotUpdateTexture(QString _name, int _identifier)
Tell the plugins to update the given texture.
void slotVisibilityChanged(int _id)
Called when a plugin changes the visibility of an object.
void slotSetRenderer(unsigned int _viewer, QString _rendererName)
called to switch the renderer for a specific viewer
QString updateTypeName(UpdateType _id)
Get the name of a type with given id.
void setTextureMode(QString _textureName, QString _mode, int _id)
A texture mode should be changed.
void slotUpdateAllTextures()
Update all textures in the plugins.
const QStringList ALL_OBJECTS
Iterable object range.
void slotCrossPluginConnect(QString _pluginName1, const char *_signal, QString _pluginName2, const char *_slot)
Called to create inter plugin connections.
void updateTexture(QString, int)
Tell the plugins to update the given texture.
void slotObjectPropertiesChanged(int _id)
Called by plugins if object properties like names have changed.
void textureIndex(QString _textureName, int _id, int &_index)
get the texture index
void objectPropertiesChanged(int _id)
Tell plugins that object properties such as object names have been changed.
void textureGetImage(QString _textureName, QImage &_image)
fetch texture image
void slotSwitchTexture(QString _textureName, int _id)
Tells Plugins to switch to the given Texture.
void addMultiTexture(QString _textureGroup, QString _name, QString _filename, int _id, int &_textureId)
The texture with the given name and filename has been added.
const DataType DATA_ALL(UINT_MAX)
Identifier for all available objects.
void slotTextureName(int _id, int _textureIndex, QString &_textureName)
Called by plugins if texture name should be fetched.
void updateView()
Called when a plugin requests an update in the viewer.
void slotGetCurrentRenderer(unsigned int _viewer, QString &_rendererName)
called to get the currently active renderer renderer for a specific viewer
void addTexture(QString, QString, uint, int)
The texture with the given name and filename has been added.
void log(Logtype _type, QString _message)
Logg with OUT,WARN or ERR as type.
void newObject(int _objectId)
This slot is called by the object manager when a new object is created.
void slotTextureIndex(QString _textureName, int _id, int &_index)
Called by plugins if texture index should be fetched.
void slotTextureUpdated(QString _textureName, int _identifier)
A Texture has been updated.
void slotObjectUpdated(int _identifier, const UpdateType &_type=UPDATE_ALL)
Called by the plugins if they changed something in the object list (deleted, added, or other property changes)
void setActive(unsigned int _active, int _id)
set the active renderer
void switchTexture(QString, int)
Switch Texture Plugins to a given Mode.
void slotAddTexture(QString _textureName, QString _filename, uint _dimension, int _id)
Called by a plugin if it creates a texture.
void visibilityChanged(int _id)
Tell plugins that the visibility of an object has changed.
void deletedObject(int _objectId)
This slot is called by the object manager when an object is deleted.
void slotTextureFilename(int _id, QString _textureName, QString &_textureFilename)
Called by plugins if texture name should be fetched.
const UpdateType UPDATE_STATE(UpdateTypeSet(1)<< 12)
State has changed.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
void slotSetTextureMode(QString _textureName, QString _mode, int _id)
A texture mode should be changed.
void textureFilename(int _id, QString _textureName, QString &_textureFilename)
get the texture's filename
QString name
Name of the plugin ( requested from the plugin on load)
void slotTextureChangeImage(QString _textureName, QImage &_image)
Called by plugins if texture image should be changed.
void updatedTextures(QString, int)
This Signal is send to the plugins if a texture has been updated.
void textureName(int _id, int _textureIndex, QString &_textureName)
get the texture name