Commit 5febc83a authored by Mike Kremer's avatar Mike Kremer

Offering individual context menu for light sources allowing the user to switch them on/off.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@9006 383ad7c9-94d9-4d36-a494-682f7c89f535
parent e8422d58
......@@ -56,6 +56,7 @@
#include <OpenFlipper/BasePlugin/INIInterface.hh>
#include <OpenFlipper/BasePlugin/LoadSaveInterface.hh>
#include <OpenFlipper/common/Types.hh>
#include <ObjectTypes/Light/Light.hh>
#include "Toolbox.hh"
#include "TreeModel.hh"
......@@ -206,6 +207,9 @@ class DataControlPlugin : public QObject, BaseInterface, ToolboxInterface, KeyIn
///Called by the popup menu to zoom to an object
void slotZoomTo();
/// Called by the popup menu in order to turn lights on/off
void slotSwitchLight();
///Called by the popup menu to set material properties
void slotMaterialProperties();
......
......@@ -284,23 +284,38 @@ void DataControlPlugin::slotCustomContextMenuRequested ( const QPoint & _pos ) {
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-delete-item.png");
action->setIcon(icon);
} else {
action = menu.addAction(tr("Zoom to object"),this,SLOT ( slotZoomTo() ));
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"zoom-in.png");
action->setIcon(icon);
action = menu.addAction(tr("Copy"),this,SLOT ( slotCopy() ));
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"edit-copy.png");
action->setIcon(icon);
action = menu.addAction(tr("Rename"),this,SLOT ( slotRename() ));
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"edit-rename.png");
action->setIcon(icon);
action = menu.addAction(tr("Material Properties"),this,SLOT ( slotMaterialProperties() ));
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-material.png");
action->setIcon(icon);
menu.addAction(tr("Group"),this,SLOT ( slotGroup() ));
menu.addSeparator();
action = menu.addAction(tr("Remove"),this,SLOT ( slotPopupRemove() ));
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-delete-item.png");
action->setIcon(icon);
if(item->dataType() == DATA_LIGHT) {
action = menu.addAction(tr("Copy"),this,SLOT ( slotCopy() ));
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"edit-copy.png");
action->setIcon(icon);
action = menu.addAction(tr("Rename"),this,SLOT ( slotRename() ));
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"edit-rename.png");
action->setIcon(icon);
action = menu.addAction(tr("Remove"),this,SLOT ( slotPopupRemove() ));
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-delete-item.png");
action->setIcon(icon);
action = menu.addAction(tr("Switch On/Off"),this,SLOT ( slotSwitchLight() ));
//icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-switch-light.png");
//action->setIcon(icon);
} else {
action = menu.addAction(tr("Zoom to object"),this,SLOT ( slotZoomTo() ));
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"zoom-in.png");
action->setIcon(icon);
action = menu.addAction(tr("Copy"),this,SLOT ( slotCopy() ));
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"edit-copy.png");
action->setIcon(icon);
action = menu.addAction(tr("Rename"),this,SLOT ( slotRename() ));
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"edit-rename.png");
action->setIcon(icon);
action = menu.addAction(tr("Material Properties"),this,SLOT ( slotMaterialProperties() ));
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-material.png");
action->setIcon(icon);
menu.addAction(tr("Group"),this,SLOT ( slotGroup() ));
menu.addSeparator();
action = menu.addAction(tr("Remove"),this,SLOT ( slotPopupRemove() ));
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-delete-item.png");
action->setIcon(icon);
}
}
......@@ -510,6 +525,36 @@ void DataControlPlugin::slotNodeChanged( ACG::SceneGraph::BaseNode* /*_node*/ ){
//******************************************************************************
/**
* \brief Switch light source on or off
*/
void DataControlPlugin::slotSwitchLight() {
QItemSelectionModel* selection = view_->selectionModel();
// Get all selected rows
QModelIndexList indexList = selection->selectedRows ( 0 );
int selectedRows = indexList.size();
if (selectedRows == 1) {
LightObject* light = 0;
int id = model_->itemId( indexList[0]);
if (id == -1 || !PluginFunctions::getObject( id, light ) )
return;
if(light == 0) return;
light->lightSource()->enabled() ?
light->lightSource()->disable() :
light->lightSource()->enable();
emit updatedObject(id);
}
}
//******************************************************************************
/** \brief Zoom to an object
*
*/
......
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