58#include "OpenFlipper/BasePlugin/PluginFunctionsCore.hh"
76 if ( OpenFlipper::Options::doSlotDebugging() ) {
77 if ( sender() != 0 ) {
78 if ( sender()->metaObject() != 0 ) {
80 + tr(
" ) called by ") + QString( sender()->metaObject()->className() ) );
83 emit
log(
LOGINFO,
"updatedObject( " + QString::number(_identifier) +
", " +
updateTypeName(_type) + tr(
" ) called by Core") );
88 OpenFlipper::Options::redrawDisabled(
true);
92 if ( _identifier != -1 ) {
94 emit
log(
LOGERR,tr(
"updated_objects called for non existing object with id : ") + QString::number(_identifier) );
101 if ( _identifier == -1 ) {
103 if ( sender() != 0 ) {
104 if ( sender()->metaObject() != 0 ) {
106 + tr(
" ) called by ") + QString( sender()->metaObject()->className() + tr(
" which is inefficient)") ) );
109 emit
log(
LOGWARN,
"updatedObject( " + QString::number(_identifier) +
", " +
updateTypeName(_type) + tr(
" ) called by Core, which is inefficient!") );
131 object->update(_type);
134 OpenFlipper::Options::redrawDisabled(
false);
182 if (QThread::currentThread() != QApplication::instance()->thread())
185 QMetaObject::invokeMethod(
this,
"slotAddTexture",Qt::BlockingQueuedConnection, Q_ARG(QString, _textureName), Q_ARG(QString, _filename), Q_ARG(uint, _dimension), Q_ARG(
int, _id));
189 if ( OpenFlipper::Options::doSlotDebugging() ) {
190 if ( sender() != 0 ) {
191 if ( sender()->metaObject() != 0 ) {
192 emit
log(
LOGINFO,
"addTexture( " + _textureName +
"," + _filename +
"," + QString::number(_dimension) +
", " + QString::number(_id) + tr(
" ) called by ") +
193 QString( sender()->metaObject()->className() ) );
196 emit
log(
LOGINFO,
"addTexture( " + _textureName +
"," + _filename +
"," + QString::number(_dimension) +
", " + QString::number(_id) + tr(
" ) called by Core") );
200 emit
addTexture(_textureName , _filename,_dimension,_id);
208 if (QThread::currentThread() != QApplication::instance()->thread())
211 QMetaObject::invokeMethod(
this,
"slotAddTexture",Qt::BlockingQueuedConnection, Q_ARG(QString, _textureName), Q_ARG(QImage, _image), Q_ARG(uint, _dimension), Q_ARG(
int, _id));
215 if ( OpenFlipper::Options::doSlotDebugging() ) {
216 if ( sender() != 0 ) {
217 if ( sender()->metaObject() != 0 ) {
218 emit
log(
LOGINFO,
"addTexture( " + _textureName +
",QImage," + QString::number(_dimension) +
", " + QString::number(_id) + tr(
" ) called by ") +
219 QString( sender()->metaObject()->className() ) );
222 emit
log(
LOGINFO,
"addTexture( " + _textureName +
",image," + QString::number(_dimension) +
", " + QString::number(_id) + tr(
" ) called by Core") );
226 emit
addTexture(_textureName , _image,_dimension,_id);
234 if (QThread::currentThread() != QApplication::instance()->thread())
237 QMetaObject::invokeMethod(
this,
"slotAddTexture",Qt::BlockingQueuedConnection, Q_ARG(QString, _textureName), Q_ARG(QString, _filename), Q_ARG(uint, _dimension));
241 if ( OpenFlipper::Options::doSlotDebugging() ) {
242 if ( sender() != 0 ) {
243 if ( sender()->metaObject() != 0 ) {
244 emit
log(
LOGINFO,
"slotAddTexture( " + _textureName +
"," + _filename +
"," + QString::number(_dimension) + tr(
" ) called by ") +
245 QString( sender()->metaObject()->className() ) );
248 emit
log(
LOGINFO,
"slotAddTexture( " + _textureName +
"," + _filename +
"," +
", " + QString::number(_dimension) + tr(
" ) called by Core") );
252 emit
addTexture(_textureName , _filename,_dimension);
260 if (QThread::currentThread() != QApplication::instance()->thread())
263 QMetaObject::invokeMethod(
this,
"slotAddTexture",Qt::BlockingQueuedConnection, Q_ARG(QString, _textureName), Q_ARG(QImage, _image), Q_ARG(uint, _dimension));
267 if ( OpenFlipper::Options::doSlotDebugging() ) {
268 if ( sender() != 0 ) {
269 if ( sender()->metaObject() != 0 ) {
270 emit
log(
LOGINFO,
"slotAddTexture( " + _textureName +
",_image," + QString::number(_dimension) + tr(
" ) called by ") +
271 QString( sender()->metaObject()->className() ) );
274 emit
log(
LOGINFO,
"slotAddTexture( " + _textureName +
",_image," +
", " + QString::number(_dimension) + tr(
" ) called by Core") );
278 emit
addTexture(_textureName , _image,_dimension);
286 if ( OpenFlipper::Options::doSlotDebugging() ) {
287 if ( sender() != 0 ) {
288 if ( sender()->metaObject() != 0 ) {
289 emit
log(
LOGINFO,
"slotUpdateTexture( " + _name +
" , " + QString::number(_identifier) + tr(
" ) called by ") +
290 QString( sender()->metaObject()->className() ) );
304 if (QThread::currentThread() != QApplication::instance()->thread())
307 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));
311 if ( OpenFlipper::Options::doSlotDebugging() ) {
312 if ( sender() != 0 ) {
313 if ( sender()->metaObject() != 0 ) {
314 emit
log(
LOGINFO,
"slotMultiTextureAdded( " + _textureGroup +
", " + _name +
"," + _filename +
"," + QString::number(_id) + tr(
" ) called by ") +
315 QString( sender()->metaObject()->className() ) );
318 emit
log(
LOGINFO,
"slotMultiTextureAdded( " + _textureGroup +
", " + _name +
"," + _filename +
"," + QString::number(_id) + tr(
" ) called by Core") );
322 emit
addMultiTexture( _textureGroup , _name , _filename , _id , _textureId );
327 if (QThread::currentThread() != QApplication::instance()->thread())
330 QMetaObject::invokeMethod(
this,
"slotMultiTextureAdded",Qt::BlockingQueuedConnection, Q_ARG(QString, _textureGroup), Q_ARG(QString, _name), Q_ARG(QImage, _image), Q_ARG(
int, _id), Q_ARG(
int*, &_textureId));
334 if ( OpenFlipper::Options::doSlotDebugging() ) {
335 if ( sender() != 0 ) {
336 if ( sender()->metaObject() != 0 ) {
337 emit
log(
LOGINFO,
"slotMultiTextureAdded( " + _textureGroup +
", " + _name +
",_image," + QString::number(_id) + tr(
" ) called by ") +
338 QString( sender()->metaObject()->className() ) );
341 emit
log(
LOGINFO,
"slotMultiTextureAdded( " + _textureGroup +
", " + _name +
",_image," + QString::number(_id) + tr(
" ) called by Core") );
345 emit
addMultiTexture( _textureGroup , _name , _image , _id , _textureId );
360 if ( OpenFlipper::Options::doSlotDebugging() ) {
361 if ( sender() != 0 ) {
362 if ( sender()->metaObject() != 0 ) {
363 emit
log(
LOGINFO,
"slotSetTextureMode( " + _textureName +
" , " + _mode +
" , " + QString::number(_id) + tr(
" ) called by ") +
364 QString( sender()->metaObject()->className() ) );
377 if ( OpenFlipper::Options::doSlotDebugging() ) {
378 if ( sender() != 0 ) {
379 if ( sender()->metaObject() != 0 ) {
380 emit
log(
LOGINFO,
"slotSetTextureMode( " + _textureName +
" , " + _mode + tr(
" ) called by ") +
381 QString( sender()->metaObject()->className() ) );
393 if ( OpenFlipper::Options::doSlotDebugging() ) {
394 if ( sender() != 0 ) {
395 if ( sender()->metaObject() != 0 ) {
396 emit
log(
LOGINFO,
"slotTextureUpdated( " + _textureName +
" , " + QString::number(_identifier) + tr(
" ) called by ") +
397 QString( sender()->metaObject()->className() ) );
407 if ( OpenFlipper::Options::doSlotDebugging() ) {
408 if ( sender() != 0 ) {
409 if ( sender()->metaObject() != 0 ) {
410 emit
log(
LOGINFO,
"switchTexture( " + _textureName +
" , " + QString::number(_id) + tr(
" ) called by ") +
411 QString( sender()->metaObject()->className() ) );
421 if ( OpenFlipper::Options::doSlotDebugging() ) {
422 if ( sender() != 0 ) {
423 if ( sender()->metaObject() != 0 ) {
424 emit
log(
LOGINFO,
"switchTexture( " + _textureName + tr(
" ) called by ") +
425 QString( sender()->metaObject()->className() ) );
472 emit
textureName( _id, _textureIndex, _textureName);
508 emit
log(
LOGERR,tr(
"newObject received from objectManager with invalid id! This should not happen. The new Object will not work correctly!"));
523void connectPlugins(
Core* c,
const std::vector<PluginInfo>& plugins_, QString _pluginName1,
const char* _signal, QString _pluginName2,
const char* _slot,
bool _queued)
525 QObject* plugin1 = 0;
526 QObject* plugin2 = 0;
528 for (
int i = 0 ; i < (int)plugins_.size(); ++i ) {
529 if ( plugins_[i].rpcName == _pluginName1 ) {
530 plugin1 = plugins_[i].plugin;
532 if ( plugins_[i].rpcName == _pluginName2 ) {
533 plugin2 = plugins_[i].plugin;
537 if ( plugin1 == 0 ) {
538 emit c->
log(
LOGERR,QObject::tr(
"Cross Plugin Interconnection failed because plugin %1 was not found!").arg(_pluginName1));
542 if ( plugin2 == 0 ) {
543 emit c->
log(
LOGERR,QObject::tr(
"Cross Plugin Interconnection failed because plugin %1 was not found!").arg(_pluginName2));
549 QObject::connect(plugin1,_signal,plugin2,_slot, Qt::QueuedConnection);
551 QObject::connect(plugin1,_signal,plugin2,_slot);
555 connectPlugins(
this,
plugins(), _pluginName1, _signal, _pluginName2, _slot,
false);
559 connectPlugins(
this,
plugins(), _pluginName1, _signal, _pluginName2, _slot,
true);
566 renderManager().
setActive(_rendererName,_viewer);
570 _rendererName = renderManager().
active(_viewer)->
name;
573void Core::slotMetadataDeserialized(
574 const QVector<QPair<QString, QString> > &data) {
576 QString obj_metadata;
577 for (QVector<QPair<QString, QString> >::const_iterator
578 it = data.begin(); it != data.end(); ++it) {
579 if (it->first ==
"Mesh Comments")
580 obj_metadata = it->second;
582 emit genericMetadataDeserialized(it->first, it->second);
588 QRegularExpression re_begin(
"BEGIN Comments for object \"([^\\n]*)\"");
589 QRegularExpression re_end(
"\\nEND Comments for object \"([^\\n]*)\"");
597 QString current_object_name;
598 for (STATE state = STATE_SEARCH_BEGIN; state != STATE_EOS; ) {
600 case STATE_SEARCH_BEGIN: {
601 QRegularExpressionMatch match = re_begin.match(obj_metadata, cursor);
602 cursor = match.capturedStart();
607 current_object_name = match.captured(1);
608 cursor += match.capturedLength();
609 state = STATE_CONSUME_INNER;
612 case STATE_CONSUME_INNER:
614 QRegularExpressionMatch match = re_end.match(obj_metadata, cursor);
615 int next = match.capturedStart();
623 for (
int i=cursor;i<next-cursor;i++) {
624 value += obj_metadata.at(i);
627 emit objectMetadataDeserialized(current_object_name, value);
628 QJsonParseError json_error;
629 QJsonDocument json_doc =
630 QJsonDocument::fromJson(value.toUtf8(), &json_error);
631 if (json_error.error == QJsonParseError::NoError) {
632 emit objectMetadataDeserializedJson(
633 current_object_name, json_doc);
635 cursor = next + match.capturedLength();
636 state = STATE_SEARCH_BEGIN;
640 throw std::logic_error(
"metadataDeserialized(): Invalid state.");
const DataType DATA_ALL(UINT_MAX)
Identifier for all available objects.
void textureIndex(QString _textureName, int _id, int &_index)
get the texture index
void slotCrossPluginConnectQueued(const QString &_pluginName1, const char *_signal, const QString &_pluginName2, const char *_slot)
Called to create inter plugin connections.
void slotTextureIndexPropertyName(int _id, QString &_propertyName)
Called by plugins if texture index property name should be fetched.
void updateTexture(QString, int)
Tell the plugins to update the given texture.
void updatedTextures(QString, int)
This Signal is send to the plugins if a texture has been updated.
void addTexture(QString, QString, uint, int)
The texture with the given name and filename has been added.
void deletedObject(int _objectId)
This slot is called by the object manager when an object is deleted.
void slotAddTexture(QString _textureName, QString _filename, uint _dimension, int _id)
Called by a plugin if it creates a texture.
void slotObjectPropertiesChanged(int _id)
Called by plugins if object properties like names have changed.
void slotTextureName(int _id, int _textureIndex, QString &_textureName)
Called by plugins if texture name should be fetched.
void switchTexture(QString, int)
Switch Texture Plugins to a given Mode.
void slotTextureUpdated(const QString &_textureName, int _identifier)
A Texture has been updated.
void updateAllTextures()
Update all textures in the plugins.
void textureName(int _id, int _textureIndex, QString &_textureName)
get the texture name
void slotMultiTextureAdded(QString _textureGroup, QString _name, QString _filename, int _id, int &_textureId)
Called by a plugin if it creates a multitexture.
void slotSetTextureMode(const QString &_textureName, const QString &_mode, int _id)
A texture mode should be changed.
void slotTextureIndex(const QString &_textureName, int _id, int &_index)
Called by plugins if texture index should be fetched.
void visibilityChanged(int _id)
Tell plugins that the visibility of an object has changed.
void slotUpdateAllTextures()
Update all textures in the plugins.
void slotObjectSelectionChanged(int _id)
Called by Plugins if they changed the active object.
void objectSelectionChanged(int)
This signal is emitted if the object has been changed (source/target)
void slotTextureGetImage(const QString &_textureName, QImage &_image)
Called by plugins if texture image should be fetched.
void getSubTextures(int _id, QString _multiTextureName, QStringList &_subTextures)
get a multi-texture's sub textures
void objectPropertiesChanged(int _id)
Tell plugins that object properties such as object names have been changed.
std::vector< PluginInfo > & plugins()
Index of Plugins toolbox widget.
void slotCrossPluginConnect(const QString &_pluginName1, const char *_signal, const QString &_pluginName2, const char *_slot)
Called to create inter plugin connections.
void getCurrentTexture(int _id, QString &_textureName)
get current texture
void newObject(int _objectId)
This slot is called by the object manager when a new object is created.
void resetScenegraph(bool _resetTrackBall)
void slotSwitchTexture(const QString &_textureName, int _id)
Tells Plugins to switch to the given Texture.
void slotGetCurrentRenderer(unsigned int _viewer, QString &_rendererName)
called to get the currently active renderer renderer for a specific viewer
void slotUpdateTexture(const QString &_name, int _identifier)
Tell the plugins to update the given texture.
void slotObjectUpdated(int _identifier, const UpdateType &_type=UPDATE_ALL)
Called by the plugins if they changed something in the object list (deleted, added,...
void addMultiTexture(QString _textureGroup, QString _name, QString _filename, int _id, int &_textureId)
The texture with the given name and filename has been added.
void slotVisibilityChanged(int _id)
Called when a plugin changes the visibility of an object.
void updateView()
Called when a plugin requests an update in the viewer.
void log(Logtype _type, QString _message)
Logg with OUT,WARN or ERR as type.
void textureIndexPropertyName(int _id, QString &_propertyName)
get the texture index property name
void slotTextureFilename(int _id, const QString &_textureName, QString &_textureFilename)
Called by plugins if texture name should be fetched.
void textureFilename(int _id, QString _textureName, QString &_textureFilename)
get the texture's filename
void textureChangeImage(QString _textureName, QImage &_image)
Change the image for a given texture.
void slotSetRenderer(unsigned int _viewer, QString _rendererName)
called to switch the renderer for a specific viewer
void textureGetImage(QString _textureName, QImage &_image)
fetch texture image
void slotGetCurrentTexture(int _id, QString &_textureName)
Called by plugins if current texture should be retrieved.
void slotTextureChangeImage(const QString &_textureName, QImage &_image)
Called by plugins if texture image should be changed.
void slotGetSubTextures(int _id, const QString &_multiTextureName, QStringList &_subTextures)
Called by plugins if a multi-texture's sub textures should be fetched.
void signalObjectUpdated(int)
When this Signal is emitted all Plugins are informed that the object list changed.
void setTextureMode(QString _textureName, QString _mode, int _id)
A texture mode should be changed.
void setActive(unsigned int _active, int _id)
set the active renderer
RendererInfo * active(int _id)
Get the current active renderer.
QString name
Name of the plugin ( requested from the plugin on load)
const UpdateType UPDATE_STATE(UpdateTypeSet(4096))
State has changed.
QString updateTypeName(UpdateType _id)
Get the name of a type with given id.
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
ObjectRange objects(IteratorRestriction _restriction, DataType _dataType)
Iterable object range.
const QStringList ALL_OBJECTS
Iterable object range.