Commit 0c5fc5c1 authored by Jan Möbius's avatar Jan Möbius

Added a deleteAllObjects function to loadSaveInterface

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5402 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 037a3bbe
......@@ -12,12 +12,12 @@
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// OpenFlipper is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenFlipper. If not, see <http://www.gnu.org/licenses/>.
//
......@@ -35,57 +35,57 @@
//
// C++ Interface: Load/Save Interface
//
// Description:
// Description:
//
//
// Author: Jan Moebius <jan_moebius@web.de>, (C) 2007
//
#ifndef LOADSAVEINTERFACE_HH
#define LOADSAVEINTERFACE_HH
#ifndef LOADSAVEINTERFACE_HH
#define LOADSAVEINTERFACE_HH
#include <OpenFlipper/common/Types.hh>
/** \brief Interface for all plugins which want to load or save files
*
*
* Using this interface you can instruct the core to open/save objects or
* create new empty objects.
*/
* create new empty objects.
*/
class LoadSaveInterface {
public:
/// Destructor
virtual ~LoadSaveInterface() {};
signals :
/** Tries to load the file as a given type
*
*
* @param _filename Filename of the File to load
* @param _type Type to be loaded
* @param _type Type to be loaded
* @param _id Here the id of the loaded object is returned. id its -1 something went wrong
*/
virtual void load(QString /*_filename*/, DataType /*_type*/, int& /*_id*/) {};
/** Add an empty object of the given type
*
*
* @param _type Type to be created
* @param _id Here the id of the loaded object is returned. id its -1 something went wrong
*/
virtual void addEmptyObject( DataType /*_type*/, int& /*_id*/) {};
/**
*
*
* @param _id Object to Save
* @param _filename Filename to save it to (Leave as "" to automatically determine filename)
*/
virtual void save(int /*_id*/ , QString /*_filename*/ ) {};
/** \brief file has been opened
* @param _id Id of the opened object
*/
virtual void openedFile( int /*_id*/ ) {};
/** \brief Emit this signal if an empty object has been created
* @param _id Id of the added object
*/
......@@ -106,17 +106,22 @@ class LoadSaveInterface {
*/
virtual void deleteObject( int /*_id*/ ){};
/** \brief Delete all Objects
*
*/
virtual void deleteAllObjects(){};
private slots :
/** \brief A file has been opened
*
*
* This slot is called if a file has been opened by the core.\n
* @param _id Id of the new object
*/
virtual void fileOpened( int /*_id*/ ) {};
/** \brief An empty object has been added
*
*
* This slot is called if an empty object has been added by the core.\n
* @param _id Id of the new object
*/
......@@ -131,5 +136,5 @@ class LoadSaveInterface {
};
Q_DECLARE_INTERFACE(LoadSaveInterface,"OpenFlipper.LoadSaveInterface/1.0")
#endif // LOADSAVEINTERFACE_HH
......@@ -1206,6 +1206,25 @@ void Core::slotDeleteObject( int _id ){
slotObjectUpdated(-1);
}
void Core::slotDeleteAllObjects( ){
// Remember ids
std::vector< int > ids;
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS) ;
o_it != PluginFunctions::objectsEnd(); ++o_it) {
ids.push_back( o_it->id() );
}
// remove the whole subtree below the root
objectRoot_->deleteSubtree();
for ( uint i = 0 ; i < ids.size(); ++i ) {
emit objectDeleted(ids[i]);
}
slotObjectUpdated(-1);
}
// //-----------------------------------------------------------------------------
//
// void Core::slotGetPlugin(QString _name, QObject* & _plugin ){
......
......@@ -270,6 +270,9 @@ signals:
/// Called when a plugin wants to delete an object
void slotDeleteObject( int _id );
/// Called when a plugin wants to delete all objects
void slotDeleteAllObjects( );
/// Get a Pointer to the Plugin with given _name (if it is loaded)
// void slotGetPlugin(QString _name, QObject* & _plugin );
......
......@@ -71,6 +71,7 @@
#include "OpenFlipper/BasePlugin/FileInterface.hh"
#include "OpenFlipper/BasePlugin/RPCInterface.hh"
#include "OpenFlipper/BasePlugin/ScriptInterface.hh"
// #include "OpenFlipper/BasePlugin/SecurityInterface.hh"
#include "OpenFlipper/INIFile/INIFile.hh"
......@@ -399,11 +400,11 @@ void Core::loadPlugin(QString filename, bool silent){
QString name_nospace = basePlugin->name();
name_nospace.remove(" ");
if (plugins[k].name == name_nospace){
if (silent || OpenFlipper::Options::nogui() ){ //dont load the plugin
emit log(LOGWARN, "\t\t\t Already loaded from " + plugins[k].path);
emit log(LOGOUT,"=============================================================================================");
return;
if (plugins[k].name == name_nospace){
if (silent || OpenFlipper::Options::nogui() ){ //dont load the plugin
emit log(LOGWARN, "\t\t\t Already loaded from " + plugins[k].path);
emit log(LOGOUT,"=============================================================================================");
return;
}else{ //ask the user
int ret = QMessageBox::question(coreWidget_,
tr("Plugin already loaded"),
......@@ -429,6 +430,28 @@ void Core::loadPlugin(QString filename, bool silent){
return;
}
// //Check if it is a BasePlugin
// SecurityInterface * securePlugin = qobject_cast< SecurityInterface * >(plugin);
// if ( securePlugin ) {
// emit log(LOGINFO,"Plugin uses security interface. Trying to authenticate against plugin ...");
//
// QMetaObject::invokeMethod(plugin,"authenticate" ) ;
//
// std::cerr << "2" << std::endl;
//
// securePlugin->authenticate();
//
// if ( true )
//
// emit log(LOGINFO,"... ok. Loading plugin ");
// else {
// emit log(LOGERR,"... failed. Plugin access denied.");
// emit log(LOGOUT,"=============================================================================================");
// return;
// }
// }
emit log(LOGOUT,"Plugin Desciption :\t\t " + basePlugin->description());
supported = "BaseInterface ";
......@@ -883,6 +906,10 @@ void Core::loadPlugin(QString filename, bool silent){
connect(plugin , SIGNAL( deleteObject( int ) ) ,
this , SLOT( slotDeleteObject( int ) ),Qt::DirectConnection);
if ( checkSignal(plugin,"deleteAllObjects()" ) )
connect(plugin , SIGNAL( deleteAllObjects() ) ,
this , SLOT( slotDeleteAllObjects() ),Qt::DirectConnection);
if ( checkSlot(plugin,"objectDeleted(int)" ) )
connect(this , SIGNAL( objectDeleted( int ) ) ,
plugin , SLOT( objectDeleted( int ) ),Qt::DirectConnection);
......
<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE KDevPrjSession>
<KDevPrjSession>
<DocsAndViews NumberOfDocuments="3" >
<Doc0 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper-Free/Plugin-Selection/SelectionPluginT.cc" >
<View0 Encoding="" line="60" Type="Source" />
<DocsAndViews NumberOfDocuments="2" >
<Doc0 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/ObjectTypes/MeshObject/MeshObjectT.hh" >
<View0 Encoding="" line="0" Type="Source" />
</Doc0>
<Doc1 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper-Free/OpenMesh/Doc/Concepts/MeshKernel.hh" >
<View0 Encoding="" line="96" Type="Source" />
<Doc1 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/ACG/Scenegraph/PolyLineNodeT.hh" >
<View0 Encoding="" line="116" Type="Source" />
</Doc1>
<Doc2 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper-Free/OpenMesh/Core/Mesh/IteratorsT.hh" >
<View0 Encoding="" line="78" Type="Source" />
</Doc2>
</DocsAndViews>
<pluginList>
<kdevdebugger>
......
......@@ -69,27 +69,27 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
shiftPressed_(false),
viewModes_(_viewModes),
viewModeButton_(0),
viewModeMenu_(0),
viewModeMenu_(0),
splitter_(0),
logWidget_(0),
recentFilesMenu_(0),
helpMenu_(0),
sceneGraphDialog_(0),
fileMenu_(0),
viewMenu_(0),
toolsMenu_(0),
fileMenu_(0),
viewMenu_(0),
toolsMenu_(0),
fileMenuEnd_(0),
stereoButton_(0),
moveButton_(0),
lightButton_(0),
pickButton_(0),
questionButton_(0),
globalDrawMenu_(0),
drawGroup_(0),
viewGroup_(0),
globalDrawMenu_(0),
drawGroup_(0),
viewGroup_(0),
perspectiveProjectionAction_(0),
activeDrawModes_(0),
availableGlobalDrawModes_(0),
activeDrawModes_(0),
availableGlobalDrawModes_(0),
contextMenu_(0),
contextSelectionMenu_(0),
drawGroupViewer_(0),
......@@ -171,7 +171,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
loggerState_ = OpenFlipper::Options::Normal;
QList<int> wsizes( splitter_->sizes() );
if (OpenFlipper::Options::loggerState() == OpenFlipper::Options::InScene) {
slidingLogger_->attachWidget (logWidget_);
splitter_->insertWidget (1, tempLogWidget);
......@@ -302,9 +302,9 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
"<li><b>Zoom</b> using <b>left+middle</b> mouse buttons.</li></ul>" );
connect( moveButton_,SIGNAL( clicked() ), this, SLOT( setExamineMode() ) );
/*
connect( this, SIGNAL( actionModeChanged( Viewer::ActionMode ) ),
this, SLOT( slotActionModeChanged(Viewer::ActionMode) ) );
this, SLOT( slotActionModeChanged(Viewer::ActionMode) ) );*/
viewerToolbar_->addWidget( moveButton_ )->setText("Move");
moveButton_->setDown(true);
......@@ -350,7 +350,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
"object.");
connect( questionButton_,SIGNAL( clicked() ), this, SLOT( setQuestionMode() ) );
viewerToolbar_->addWidget( questionButton_)->setText("Question");
viewerToolbar_->addSeparator();
if (OpenFlipper::Options::stereo())
......@@ -553,7 +553,7 @@ CoreWidget::showLogger(OpenFlipper::Options::LoggerState _state) {
wsizes[0] = wsizes[0]+wsizes[1] - originalLoggerSize_;
wsizes[1] = originalLoggerSize_;
splitter_->setSizes(wsizes);
baseLayout_->setContentsMargins (left, top, right, 0);
baseLayout_->setContentsMargins (left, top, right, 0);
}
break;
case OpenFlipper::Options::Hidden:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment