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!"));
523 void 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;
573 void 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 QRegExp re_begin(
"BEGIN Comments for object \"([^\\n]*)\"");
589 QRegExp 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 cursor = re_begin.indexIn(obj_metadata, cursor);
606 current_object_name = re_begin.cap(1);
607 cursor += re_begin.matchedLength();
608 state = STATE_CONSUME_INNER;
610 case STATE_CONSUME_INNER:
612 int next = re_end.indexIn(obj_metadata, cursor);
618 const QStringRef value = obj_metadata.midRef(cursor, next - cursor);
620 emit objectMetadataDeserialized(current_object_name, value.toString());
621 QJsonParseError json_error;
622 QJsonDocument json_doc =
623 QJsonDocument::fromJson(value.toUtf8(), &json_error);
624 if (json_error.error == QJsonParseError::NoError) {
625 emit objectMetadataDeserializedJson(
626 current_object_name, json_doc);
628 cursor = next + re_end.matchedLength();
629 state = STATE_SEARCH_BEGIN;
633 throw std::logic_error(
"metadataDeserialized(): Invalid state.");
void slotTextureChangeImage(QString _textureName, QImage &_image)
Called by plugins if texture image should be changed.
QString name
Name of the plugin ( requested from the plugin on load)
void objectPropertiesChanged(int _id)
Tell plugins that object properties such as object names have been changed.
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 textureIndex(QString _textureName, int _id, int &_index)
get the texture index
void textureFilename(int _id, QString _textureName, QString &_textureFilename)
get the texture's filename
void addTexture(QString, QString, uint, int)
The texture with the given name and filename has been added.
void textureChangeImage(QString _textureName, QImage &_image)
Change the image for a given texture.
void textureGetImage(QString _textureName, QImage &_image)
fetch texture image
void signalObjectUpdated(int)
When this Signal is emitted all Plugins are informed that the object list changed.
void visibilityChanged(int _id)
Tell plugins that the visibility of an object has changed.
void slotCrossPluginConnect(QString _pluginName1, const char *_signal, QString _pluginName2, const char *_slot)
Called to create inter plugin connections.
void deletedObject(int _objectId)
This slot is called by the object manager when an object is deleted.
void slotSwitchTexture(QString _textureName, int _id)
Tells Plugins to switch to the given Texture.
void slotSetRenderer(unsigned int _viewer, QString _rendererName)
called to switch the renderer for a specific viewer
void objectSelectionChanged(int)
This signal is emitted if the object has been changed (source/target)
void addMultiTexture(QString _textureGroup, QString _name, QString _filename, int _id, int &_textureId)
The texture with the given name and filename has been added.
void slotUpdateTexture(QString _name, int _identifier)
Tell the plugins to update the given texture.
void slotGetCurrentTexture(int _id, QString &_textureName)
Called by plugins if current texture should be retrieved.
void log(Logtype _type, QString _message)
Logg with OUT,WARN or ERR as type.
const UpdateType UPDATE_STATE(UpdateTypeSet(1)<< 12)
State has changed.
void slotObjectPropertiesChanged(int _id)
Called by plugins if object properties like names have changed.
void updatedTextures(QString, int)
This Signal is send to the plugins if a texture has been updated.
const QStringList ALL_OBJECTS
Iterable object range.
void slotSetTextureMode(QString _textureName, QString _mode, int _id)
A texture mode should be changed.
void slotTextureIndex(QString _textureName, int _id, int &_index)
Called by plugins if texture index should be fetched.
void slotTextureName(int _id, int _textureIndex, QString &_textureName)
Called by plugins if texture name should be fetched.
void slotTextureGetImage(QString _textureName, QImage &_image)
Called by plugins if texture image should be fetched.
void updateTexture(QString, int)
Tell the plugins to update the given texture.
void slotTextureIndexPropertyName(int _id, QString &_propertyName)
Called by plugins if texture index property name should be fetched.
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
void textureName(int _id, int _textureIndex, QString &_textureName)
get the texture name
void slotVisibilityChanged(int _id)
Called when a plugin changes the visibility of an object.
std::vector< PluginInfo > & plugins()
Index of Plugins toolbox widget.
void updateAllTextures()
Update all textures in the plugins.
void newObject(int _objectId)
This slot is called by the object manager when a new object is created.
RendererInfo * active(int _id)
Get the current active renderer.
void updateView()
Called when a plugin requests an update in the viewer.
void setActive(unsigned int _active, int _id)
set the active renderer
void setTextureMode(QString _textureName, QString _mode, int _id)
A texture mode should be changed.
QString updateTypeName(UpdateType _id)
Get the name of a type with given id.
void slotTextureUpdated(QString _textureName, int _identifier)
A Texture has been updated.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
void textureIndexPropertyName(int _id, QString &_propertyName)
get the texture index property name
void slotObjectSelectionChanged(int _id)
Called by Plugins if they changed the active object.
void slotAddTexture(QString _textureName, QString _filename, uint _dimension, int _id)
Called by a plugin if it creates a texture.
void getCurrentTexture(int _id, QString &_textureName)
get current texture
void getSubTextures(int _id, QString _multiTextureName, QStringList &_subTextures)
get a multi-texture's sub textures
void slotTextureFilename(int _id, QString _textureName, QString &_textureFilename)
Called by plugins if texture name should be fetched.
const DataType DATA_ALL(UINT_MAX)
Identifier for all available objects.
void slotGetCurrentRenderer(unsigned int _viewer, QString &_rendererName)
called to get the currently active renderer renderer for a specific viewer
void slotMultiTextureAdded(QString _textureGroup, QString _name, QString _filename, int _id, int &_textureId)
Called by a plugin if it creates a multitexture.
void slotGetSubTextures(int _id, QString _multiTextureName, QStringList &_subTextures)
Called by plugins if a multi-texture's sub textures should be fetched.
void slotCrossPluginConnectQueued(QString _pluginName1, const char *_signal, QString _pluginName2, const char *_slot)
Called to create inter plugin connections.
void resetScenegraph(bool _resetTrackBall)
void switchTexture(QString, int)
Switch Texture Plugins to a given Mode.
void slotUpdateAllTextures()
Update all textures in the plugins.