PluginCommunication.cc

00001 /*===========================================================================*\
00002  *                                                                           *
00003  *                              OpenFlipper                                  *
00004  *      Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen      *
00005  *                           www.openflipper.org                             *
00006  *                                                                           *
00007  *---------------------------------------------------------------------------*
00008  *  This file is part of OpenFlipper.                                        *
00009  *                                                                           *
00010  *  OpenFlipper is free software: you can redistribute it and/or modify      *
00011  *  it under the terms of the GNU Lesser General Public License as           *
00012  *  published by the Free Software Foundation, either version 3 of           *
00013  *  the License, or (at your option) any later version with the              *
00014  *  following exceptions:                                                    *
00015  *                                                                           *
00016  *  If other files instantiate templates or use macros                       *
00017  *  or inline functions from this file, or you compile this file and         *
00018  *  link it with other files to produce an executable, this file does        *
00019  *  not by itself cause the resulting executable to be covered by the        *
00020  *  GNU Lesser General Public License. This exception does not however       *
00021  *  invalidate any other reasons why the executable file might be            *
00022  *  covered by the GNU Lesser General Public License.                        *
00023  *                                                                           *
00024  *  OpenFlipper is distributed in the hope that it will be useful,           *
00025  *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00026  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
00027  *  GNU Lesser General Public License for more details.                      *
00028  *                                                                           *
00029  *  You should have received a copy of the GNU LesserGeneral Public          *
00030  *  License along with OpenFlipper. If not,                                  *
00031  *  see <http://www.gnu.org/licenses/>.                                      *
00032  *                                                                           *
00033 \*===========================================================================*/
00034 
00035 /*===========================================================================*\
00036  *                                                                           *
00037  *   $Revision: 8694 $                                                         *
00038  *   $Author: wilden $                                                      *
00039  *   $Date: 2010-03-09 18:49:22 +0100 (Di, 09. Mär 2010) $                   *
00040  *                                                                           *
00041 \*===========================================================================*/
00042 
00043 
00044 
00045 
00046 //=============================================================================
00047 //
00048 //  CLASS Core - IMPLEMENTATION of Comunication with plugins
00049 //
00050 //=============================================================================
00051 
00052 
00053 //== INCLUDES =================================================================
00054 
00055 #include "Core.hh"
00056 
00057 #include <QToolBox>
00058 
00059 #include "OpenFlipper/BasePlugin/BaseInterface.hh"
00060 #include "OpenFlipper/BasePlugin/ToolboxInterface.hh"
00061 #include "OpenFlipper/BasePlugin/TextureInterface.hh"
00062 
00063 #include "OpenFlipper/BasePlugin/PluginFunctionsCore.hh"
00064 
00065 //== IMPLEMENTATION ==========================================================
00066 
00067 //========================================================================================
00068 // ===             Object List Communication                       =======================
00069 //========================================================================================
00070 
00074 void Core::slotObjectUpdated(int _identifier, UpdateType _type) {
00075   if ( OpenFlipper::Options::doSlotDebugging() ) {
00076     if ( sender() != 0 ) {
00077       if ( sender()->metaObject() != 0 ) {
00078         emit log(LOGINFO,"updatedObject( " + QString::number(_identifier) + ", " + updateTypeName(_type)
00079                  + tr(" ) called by ") + QString( sender()->metaObject()->className() ) );
00080       }
00081     } else {
00082       emit log(LOGINFO,"updatedObject( " + QString::number(_identifier) + ", " + updateTypeName(_type) + tr(" ) called by Core") );
00083     }
00084   }
00085 
00086   // Disable redraws as everything here has to update the object only once
00087   OpenFlipper::Options::redrawDisabled(true);
00088 
00089   // If we are called for a special object, we update it ourself so the Plugins dont need to do that.
00090   BaseObject* object = 0;
00091   if ( _identifier != -1 ) {
00092     if ( !PluginFunctions::getObject(_identifier,object) ) {
00093       emit log(LOGERR,tr("updated_objects called for non existing object with id : ") + QString::number(_identifier) );
00094       return;
00095     }
00096   }
00097 
00098   // just inform the plugins as we dont do anything else
00099   emit signalObjectUpdated(_identifier);
00100 
00101   if ( object != 0 )
00102     object->update(_type);
00103 
00104   // Reenable redraws
00105   OpenFlipper::Options::redrawDisabled(false);
00106 
00107 
00108   // Reset scenegraph but keep scene center!
00109   resetScenegraph(false);
00110 
00111   updateView();
00112 }
00113 
00114 void Core::slotVisibilityChanged( int _id ) {
00115 
00116   // tell plugins
00117   emit visibilityChanged( _id );
00118 
00119   // Reset scenegraph but keep scene center!
00120   resetScenegraph(false);
00121   
00122   updateView();
00123 }
00124 
00127 void Core::slotObjectSelectionChanged( int _id )
00128 {
00129   // just inform the plugins as we dont do anything else
00130   emit objectSelectionChanged(_id);
00131 
00132   updateView();
00133 }
00134 
00135 void Core::slotObjectPropertiesChanged( int _id )
00136 {
00137   emit objectPropertiesChanged(_id);
00138 }
00139 
00140 //========================================================================================
00141 // ===             Texture Communication                       ===========================
00142 //========================================================================================
00143 
00144 
00148 void Core::slotAddTexture( QString _textureName , QString _filename, uint _dimension, int _id) {
00149   if ( OpenFlipper::Options::doSlotDebugging() ) {
00150     if ( sender() != 0 ) {
00151       if ( sender()->metaObject() != 0 ) {
00152         emit log(LOGINFO,"addTexture( " + _textureName + "," + _filename + ","  +  QString::number(_dimension) + ", " + QString::number(_id) +  tr(" ) called by ") +
00153         QString( sender()->metaObject()->className() ) );
00154       }
00155     } else {
00156       emit log(LOGINFO,"addTexture( " + _textureName + "," + _filename + "," +  QString::number(_dimension) + ", " + QString::number(_id) +  tr(" ) called by Core") );
00157     }
00158   }
00159   
00160   emit addTexture(_textureName , _filename,_dimension,_id);
00161 }
00162 
00166 void Core::slotAddTexture( QString _textureName , QString _filename, uint _dimension) {
00167   
00168   if ( OpenFlipper::Options::doSlotDebugging() ) {
00169     if ( sender() != 0 ) {
00170       if ( sender()->metaObject() != 0 ) {
00171         emit log(LOGINFO,"slotAddTexture( " + _textureName + "," + _filename + ","  +  QString::number(_dimension)  +  tr(" ) called by ") +
00172         QString( sender()->metaObject()->className() ) );
00173       }
00174     } else {
00175       emit log(LOGINFO,"slotAddTexture( " + _textureName + "," + _filename + "," +", " +  QString::number(_dimension) + tr(" ) called by Core") );
00176     }
00177   }
00178   
00179   emit addTexture(_textureName , _filename,_dimension);
00180 }
00181 
00185 void Core::slotUpdateTexture( QString _name , int _identifier){
00186 
00187   if ( OpenFlipper::Options::doSlotDebugging() ) {
00188     if ( sender() != 0 ) {
00189       if ( sender()->metaObject() != 0 ) {
00190         emit log(LOGINFO,"slotUpdateTexture( "  + _name + " , " + QString::number(_identifier) + tr(" ) called by ") +
00191                  QString( sender()->metaObject()->className() ) );
00192       }
00193     }
00194   }
00195 
00196   emit updateTexture(_name, _identifier);
00197 }
00198 
00199 
00200 void Core::slotMultiTextureAdded( QString _textureGroup , QString _name , QString _filename , int _id , int& _textureId ) {
00201   
00202   if ( OpenFlipper::Options::doSlotDebugging() ) {
00203     if ( sender() != 0 ) {
00204       if ( sender()->metaObject() != 0 ) {
00205         emit log(LOGINFO,"slotMultiTextureAdded( " + _textureGroup + ", " + _name + "," + _filename + ","  + QString::number(_id) + tr(" ) called by ") +
00206         QString( sender()->metaObject()->className() ) );
00207       }
00208     } else {
00209       emit log(LOGINFO,"slotMultiTextureAdded( " + _textureGroup + ", " + _name + "," + _filename + ","  + QString::number(_id) + tr(" ) called by Core") );
00210     }
00211   }
00212   
00213   emit addMultiTexture( _textureGroup , _name , _filename , _id , _textureId  );
00214 }
00215 
00219 void Core::slotUpdateAllTextures( ){
00220   emit updateAllTextures();
00221 }
00222 
00226 void Core::slotSetTextureMode(QString _textureName, QString _mode, int _id) {
00227 
00228   if ( OpenFlipper::Options::doSlotDebugging() ) {
00229     if ( sender() != 0 ) {
00230       if ( sender()->metaObject() != 0 ) {
00231         emit log(LOGINFO,"slotSetTextureMode( " + _textureName + " , " + _mode + " , " + QString::number(_id) + tr(" ) called by ") +
00232                  QString( sender()->metaObject()->className() ) );
00233       }
00234     }
00235   }
00236 
00237   emit setTextureMode(_textureName,_mode,_id);
00238 }
00239 
00243 void Core::slotSetTextureMode(QString _textureName ,QString _mode) {
00244 
00245   if ( OpenFlipper::Options::doSlotDebugging() ) {
00246     if ( sender() != 0 ) {
00247       if ( sender()->metaObject() != 0 ) {
00248         emit log(LOGINFO,"slotSetTextureMode( " + _textureName + " , " + _mode + tr(" ) called by ") +
00249                  QString( sender()->metaObject()->className() ) );
00250       }
00251     }
00252   }
00253 
00254   emit setTextureMode(_textureName,_mode);
00255 }
00256 
00260 void Core::slotTextureUpdated( QString _textureName , int _identifier ) {
00261   if ( OpenFlipper::Options::doSlotDebugging() ) {
00262     if ( sender() != 0 ) {
00263       if ( sender()->metaObject() != 0 ) {
00264         emit log(LOGINFO,"slotTextureUpdated( " + _textureName + " , " + QString::number(_identifier) + tr(" ) called by ") +
00265                  QString( sender()->metaObject()->className() ) );
00266       }
00267     }
00268   }
00269   emit updatedTextures(_textureName,_identifier);
00270 }
00271 
00274 void Core::slotSwitchTexture( QString _textureName, int _id ) {
00275   emit switchTexture(_textureName, _id);
00276 }
00277 
00280 void Core::slotSwitchTexture( QString _textureName ) {
00281   emit switchTexture(_textureName);
00282 }
00283 
00284 
00287 void Core::slotTextureChangeImage( QString _textureName , QImage& _image ) {
00288   emit textureChangeImage( _textureName ,_image );
00289 }
00290 
00293 void Core::slotTextureChangeImage( QString _textureName , QImage& _image , int _id )  {
00294   emit textureChangeImage( _textureName , _image , _id );
00295 }
00296 
00297 //========================================================================================
00298 // ===             Backup Communication                       ============================
00299 //========================================================================================
00300 
00302 void Core::backupRequest( int _id , QString _name ) {
00303   emit createBackup(  _id , _name , nextBackupId_);
00304   ++nextBackupId_;
00305 }
00306 
00307 //========================================================================================
00308 // ===            Object Manager                              ============================
00309 //========================================================================================
00310 
00312 void Core::newObject(int _objectId) {
00313   
00314    BaseObject* baseObject = 0;
00315    PluginFunctions::getObject(_objectId,baseObject);
00316    
00317    if ( baseObject ) {
00318     connect( baseObject, SIGNAL(visibilityChanged(int)),       this, SLOT(slotVisibilityChanged(int)),       Qt::DirectConnection) ;
00319     connect( baseObject, SIGNAL(objectSelectionChanged(int)),  this, SLOT(slotObjectSelectionChanged(int)),  Qt::DirectConnection );
00320     connect( baseObject, SIGNAL(objectPropertiesChanged(int)), this, SLOT(slotObjectPropertiesChanged(int)), Qt::DirectConnection );
00321    } else {
00322      emit log(LOGERR,tr("newObject received from objectManager with invalid id! This should not happen. The new Object will not work correctly!"));
00323    }
00324    
00325 }
00326 
00328 void Core::deletedObject(int _objectId) {
00329 }
00330 
00331 
00332 
00333 
00334 
00335 //=============================================================================

acg pic Project OpenFlipper, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .