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: 7344 $                                                         *
00038  *   $Author: moebius $                                                      *
00039  *   $Date: 2009-10-08 11:06:20 +0200 (Do, 08. Okt 2009) $                   *
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/PluginFunctions.hh"
00064 
00065 //== IMPLEMENTATION ==========================================================
00066 
00067 //========================================================================================
00068 // ===             Object List Communication                       =======================
00069 //========================================================================================
00070 
00074 void Core::slotObjectUpdated(int _identifier) {
00075   if ( OpenFlipper::Options::doSlotDebugging() ) {
00076     if ( sender() != 0 ) {
00077       if ( sender()->metaObject() != 0 ) {
00078         emit log(LOGINFO,"updatedObject( " + QString::number(_identifier) + tr(" ) called by ") +
00079                  QString( sender()->metaObject()->className() ) );
00080       }
00081     } else {
00082       emit log(LOGINFO,"updatedObject( " + QString::number(_identifier) + 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();
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 //   std::cerr << "objectSelection changed triggers updatedObjects for now" << std::endl;
00133 //   emit updatedObject(_id);
00134 }
00135 
00136 void Core::slotObjectPropertiesChanged( int _id )
00137 {
00138   emit objectPropertiesChanged(_id);
00139 }
00140 
00141 //========================================================================================
00142 // ===             Texture Communication                       ===========================
00143 //========================================================================================
00144 
00145 
00149 void Core::slotAddTexture( QString _textureName , QString _filename, uint _dimension, int _id) {
00150   emit addTexture(_textureName , _filename,_dimension,_id);
00151 }
00152 
00156 void Core::slotAddTexture( QString _textureName , QString _filename, uint _dimension) {
00157   emit addTexture(_textureName , _filename,_dimension);
00158 }
00159 
00163 void Core::slotUpdateTexture( QString _name , int _identifier){
00164 
00165   if ( OpenFlipper::Options::doSlotDebugging() ) {
00166     if ( sender() != 0 ) {
00167       if ( sender()->metaObject() != 0 ) {
00168         emit log(LOGINFO,"slotUpdateTexture( "  + _name + " , " + QString::number(_identifier) + tr(" ) called by ") +
00169                  QString( sender()->metaObject()->className() ) );
00170       }
00171     }
00172   }
00173 
00174   emit updateTexture(_name, _identifier);
00175 }
00176 
00177 
00178 void Core::slotMultiTextureAdded( QString _textureGroup , QString _name , QString _filename , int _id , int& _textureId ) {
00179   emit addMultiTexture( _textureGroup , _name , _filename , _id , _textureId  );
00180 }
00181 
00185 void Core::slotUpdateAllTextures( ){
00186   emit updateAllTextures();
00187 }
00188 
00192 void Core::slotSetTextureMode(QString _textureName, QString _mode, int _id) {
00193 
00194   if ( OpenFlipper::Options::doSlotDebugging() ) {
00195     if ( sender() != 0 ) {
00196       if ( sender()->metaObject() != 0 ) {
00197         emit log(LOGINFO,"slotSetTextureMode( " + _textureName + " , " + _mode + " , " + QString::number(_id) + tr(" ) called by ") +
00198                  QString( sender()->metaObject()->className() ) );
00199       }
00200     }
00201   }
00202 
00203   emit setTextureMode(_textureName,_mode,_id);
00204 }
00205 
00209 void Core::slotSetTextureMode(QString _textureName ,QString _mode) {
00210 
00211   if ( OpenFlipper::Options::doSlotDebugging() ) {
00212     if ( sender() != 0 ) {
00213       if ( sender()->metaObject() != 0 ) {
00214         emit log(LOGINFO,"slotSetTextureMode( " + _textureName + " , " + _mode + tr(" ) called by ") +
00215                  QString( sender()->metaObject()->className() ) );
00216       }
00217     }
00218   }
00219 
00220   emit setTextureMode(_textureName,_mode);
00221 }
00222 
00226 void Core::slotTextureUpdated( QString _textureName , int _identifier ) {
00227   if ( OpenFlipper::Options::doSlotDebugging() ) {
00228     if ( sender() != 0 ) {
00229       if ( sender()->metaObject() != 0 ) {
00230         emit log(LOGINFO,"slotTextureUpdated( " + _textureName + " , " + QString::number(_identifier) + tr(" ) called by ") +
00231                  QString( sender()->metaObject()->className() ) );
00232       }
00233     }
00234   }
00235   emit updatedTextures(_textureName,_identifier);
00236 }
00237 
00240 void Core::slotSwitchTexture( QString _textureName, int _id ) {
00241   emit switchTexture(_textureName, _id);
00242 }
00243 
00246 void Core::slotSwitchTexture( QString _textureName ) {
00247   emit switchTexture(_textureName);
00248 }
00249 
00250 
00253 void Core::slotTextureChangeImage( QString _textureName , QImage& _image ) {
00254   emit textureChangeImage( _textureName ,_image );
00255 }
00256 
00259 void Core::slotTextureChangeImage( QString _textureName , QImage& _image , int _id )  {
00260   emit textureChangeImage( _textureName , _image , _id );
00261 }
00262 
00263 //========================================================================================
00264 // ===             Backup Communication                       ============================
00265 //========================================================================================
00266 
00268 void Core::backupRequest( int _id , QString _name ) {
00269   emit createBackup(  _id , _name , nextBackupId_);
00270   ++nextBackupId_;
00271 }
00272 
00273 
00274 
00275 
00276 
00277 //=============================================================================

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