Commit bc614da3 authored by Hans-Christian Ebke's avatar Hans-Christian Ebke

Added context menu item to copy material to targeted objects.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@15071 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 5be60cbb
...@@ -147,9 +147,12 @@ void DataControlPlugin::pluginsInitialized() { ...@@ -147,9 +147,12 @@ void DataControlPlugin::pluginsInitialized() {
icon = QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-material.png"); icon = QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-material.png");
QAction* material = new QAction(icon, tr("Material Properties"), 0); QAction* material = new QAction(icon, tr("Material Properties"), 0);
connect (material, SIGNAL( triggered() ), this, SLOT ( slotMaterialProperties() )); connect (material, SIGNAL( triggered() ), this, SLOT ( slotMaterialProperties() ));
emit addContextMenuItem(material , DATA_ALL , CONTEXTOBJECTMENU); emit addContextMenuItem(material , DATA_ALL , CONTEXTOBJECTMENU);
QAction* copyMaterial = new QAction(tr("Copy Material Properties to Targeted Objects"), 0);
connect (copyMaterial, SIGNAL( triggered() ), this, SLOT ( slotCopyMaterialToTargeted() ));
emit addContextMenuItem(copyMaterial , DATA_ALL , CONTEXTOBJECTMENU);
PluginFunctions::setDefaultViewObjectMarker (&objectMarker); PluginFunctions::setDefaultViewObjectMarker (&objectMarker);
PluginFunctions::setViewObjectMarker (&objectMarker); PluginFunctions::setViewObjectMarker (&objectMarker);
......
...@@ -224,6 +224,9 @@ class DataControlPlugin : public QObject, BaseInterface, ToolboxInterface, KeyIn ...@@ -224,6 +224,9 @@ class DataControlPlugin : public QObject, BaseInterface, ToolboxInterface, KeyIn
///Called by the popup menu to set material properties ///Called by the popup menu to set material properties
void slotMaterialProperties(); void slotMaterialProperties();
///Called by the popup menu to copy material properties
void slotCopyMaterialToTargeted();
/** \brief Called when the material properties were changed inside the material dialog /** \brief Called when the material properties were changed inside the material dialog
* *
* @param _node unused * @param _node unused
......
...@@ -319,16 +319,23 @@ void DataControlPlugin::slotCustomContextMenuRequested ( const QPoint & _pos ) { ...@@ -319,16 +319,23 @@ void DataControlPlugin::slotCustomContextMenuRequested ( const QPoint & _pos ) {
action = menu.addAction(tr("Zoom to object"),this,SLOT ( slotZoomTo() )); action = menu.addAction(tr("Zoom to object"),this,SLOT ( slotZoomTo() ));
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"zoom-in.png"); icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"zoom-in.png");
action->setIcon(icon); action->setIcon(icon);
action = menu.addAction(tr("Copy"),this,SLOT ( slotCopy() )); action = menu.addAction(tr("Copy"),this,SLOT ( slotCopy() ));
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"edit-copy.png"); icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"edit-copy.png");
action->setIcon(icon); action->setIcon(icon);
action = menu.addAction(tr("Rename"),this,SLOT ( slotRename() )); action = menu.addAction(tr("Rename"),this,SLOT ( slotRename() ));
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"edit-rename.png"); icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"edit-rename.png");
action->setIcon(icon); action->setIcon(icon);
action = menu.addAction(tr("Material Properties"),this,SLOT ( slotMaterialProperties() )); action = menu.addAction(tr("Material Properties"),this,SLOT ( slotMaterialProperties() ));
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-material.png"); icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-material.png");
action->setIcon(icon); action->setIcon(icon);
menu.addAction(tr("Copy Material Properties to Targeted Objects"), this, SLOT ( slotCopyMaterialToTargeted() ));
menu.addAction(tr("Group"),this,SLOT ( slotGroup() )); menu.addAction(tr("Group"),this,SLOT ( slotGroup() ));
menu.addSeparator(); menu.addSeparator();
action = menu.addAction(tr("Remove"),this,SLOT ( slotPopupRemove() )); action = menu.addAction(tr("Remove"),this,SLOT ( slotPopupRemove() ));
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-delete-item.png"); icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-delete-item.png");
...@@ -482,6 +489,54 @@ void DataControlPlugin::slotRename(){ ...@@ -482,6 +489,54 @@ void DataControlPlugin::slotRename(){
/** \brief show the material properties dialog /** \brief show the material properties dialog
* *
*/ */
void DataControlPlugin::slotCopyMaterialToTargeted() {
BaseObject* item = 0;
//check if it was called from object contextMenu or from the toolBox
QAction* action = dynamic_cast< QAction* > ( sender() );
if ( action ){
bool ok = false;
int id = action->data().toInt(&ok);
if ( ok && id > 0 )
PluginFunctions::getObject(id,item);
}
if ( item == 0 ){
// the slot was called from toolbox
QItemSelectionModel* selection = view_->selectionModel();
// Get all selected rows
QModelIndexList indexList = selection->selectedRows ( 0 );
int selectedRows = indexList.size();
if (selectedRows == 1){
int id = model_->itemId( indexList[0] );
if ( id > 0 )
PluginFunctions::getObject(id,item);
}
}
if ( item != 0 ){
BaseObjectData* itemData = dynamic_cast< BaseObjectData* > (item);
const ACG::SceneGraph::Material &sourceMaterial = itemData->materialNode()->material();
for (PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS);
o_it != PluginFunctions::objectsEnd(); ++o_it) {
MaterialNode * const materialNode = o_it->materialNode();
if (materialNode) {
materialNode->material() = sourceMaterial;
}
}
emit updateView();
}
}
void DataControlPlugin::slotMaterialProperties(){ void DataControlPlugin::slotMaterialProperties(){
BaseObject* item = 0; BaseObject* item = 0;
......
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