Developer Documentation
MaterialPicker.cc
1/*===========================================================================*\
2* *
3* OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39* *
40\*===========================================================================*/
41
42
43
44
45#include "MaterialPicker.hh"
46
49#include <ACG/QtWidgets/QtMaterialDialog.hh>
50#include <sstream>
51
52#include <ACG/Scenegraph/MaterialNode.hh>
53
54#include <QMessageBox>
55#include <QMenu>
56
57//------------------------------------------------------------------------------
58MaterialPicker::MaterialPicker()
59 :
60 pickModeName_("MaterialPicker"),
61 propName_(name()+QString("/Materials")),
62 pickMaterialButton_(nullptr),
63 fillMaterialButton_(nullptr),
64 materialListWidget_(nullptr),
65 toolIcon_(nullptr),
66 materialStrings_(),
67 shortKeyRow_(),
68 materialNode_(),
69 pickMaterial_(false),
70 fillMaterial_(false)
71
72{
73}
74
75//------------------------------------------------------------------------------
76
77MaterialPicker::~MaterialPicker() {
78 if (toolIcon_)
79 delete toolIcon_;
80}
81
82//------------------------------------------------------------------------------
83
84void MaterialPicker::initializePlugin() {
85 QWidget* toolBox = new QWidget();
86
87 pickMaterialButton_ = new QPushButton("&pick Material", toolBox);
88 fillMaterialButton_ = new QPushButton("&fill Material", toolBox);
89 QPushButton* clearListButton = new QPushButton("Clear List", toolBox);
90 QPushButton* removeItemButton = new QPushButton("Remove", toolBox);
91
92 pickMaterialButton_->setCheckable(true);
93 fillMaterialButton_->setCheckable(true);
94
95 QLabel* materials = new QLabel("Materials:");
96
97 materialListWidget_ = new QListWidget(toolBox);
98
99 //load saved materials
100 materialStrings_ = OpenFlipperSettings().value(propName_, QStringList()).toStringList();
101 for (int i = 0; i < materialStrings_.size(); ++i)
102 {
103 QStringList savedString = materialStrings_[i].split(";");
104 std::stringstream stream;
105 MaterialInfo materialInfo;
106 stream << savedString[1].toStdString();
107 stream >> materialInfo.color_material;
108 stream.str("");
109 stream.clear();
110 stream << savedString[2].toStdString();
111 stream >> materialInfo.base_color;
112 stream.str("");
113 stream.clear();
114 stream << savedString[3].toStdString();
115 stream >> materialInfo.ambient_color;
116 stream.str("");
117 stream.clear();
118 stream << savedString[4].toStdString();
119 stream >> materialInfo.diffuse_color;
120 stream.str("");
121 stream.clear();
122 stream << savedString[5].toStdString();
123 stream >> materialInfo.specular_color;
124 stream.str("");
125 stream.clear();
126 stream << savedString[6].toStdString();
127 stream >> materialInfo.shininess;
128 stream.str("");
129 stream.clear();
130 stream << savedString[7].toStdString();
131 stream >> materialInfo.reflectance;
132 stream.str("");
133 stream.clear();
134 stream << savedString[8].toStdString();
135 stream >> materialInfo.key;
136
137 if (materialInfo.key != Qt::Key_unknown) {
138 shortKeyRow_[materialInfo.key] = materialListWidget_->count();
139 }
140
141 materialListWidget_->addItem( itemName(savedString[0],materialInfo.key) );
142 materialList_.push_back(materialInfo);
143 }
144
145 //if material was saved, set first as current
146 if (materialStrings_.size())
147 materialListWidget_->setCurrentItem(materialListWidget_->item(0));
148 else
149 fillMaterialButton_->setEnabled(false);
150
151 QGridLayout* removeGrid = new QGridLayout();
152 removeGrid->addWidget(removeItemButton,0,0);
153 removeGrid->addWidget(clearListButton,0,1);
154
155 QGridLayout* pickGrid = new QGridLayout();
156 pickGrid->addWidget(pickMaterialButton_, 0, 0);
157 pickGrid->addWidget(fillMaterialButton_, 0, 1);
158
159 QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom, toolBox);
160 layout->addWidget(materials);
161 layout->addWidget(materialListWidget_);
162
163 layout->addLayout(removeGrid);
164 layout->addLayout(pickGrid);
165
166 connect(pickMaterialButton_, SIGNAL(clicked()), this, SLOT(slotPickMaterialMode()));
167 connect(fillMaterialButton_, SIGNAL(clicked()), this, SLOT(slotFillMaterialMode()));
168 connect(clearListButton, SIGNAL(clicked()), this, SLOT(clearList()));
169 connect(materialListWidget_, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(editMode(QListWidgetItem*)));
170 connect(materialListWidget_->itemDelegate(), SIGNAL(closeEditor(QWidget*, QAbstractItemDelegate::EndEditHint)),this,SLOT(saveNewName(QWidget*, QAbstractItemDelegate::EndEditHint)));
171 connect(removeItemButton, SIGNAL(clicked()), this, SLOT(slotRemoveCurrentItem()));
172 connect(materialListWidget_,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(createContextMenu(const QPoint&)));
173
174 materialListWidget_->setContextMenuPolicy(Qt::CustomContextMenu);
175 toolIcon_ = new QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"material_picker.png");
176 emit addToolbox( tr("Material Picker"), toolBox, toolIcon_);
177}
178//------------------------------------------------------------------------------
179
180void MaterialPicker::removeItem(QListWidgetItem* _item)
181{
182 unsigned index = materialListWidget_->row(_item);
183 materialListWidget_->takeItem(index);
184 materialList_.erase(materialList_.begin()+index);
185 materialStrings_.erase(materialStrings_.begin()+index);
186 if (materialStrings_.isEmpty())
187 OpenFlipperSettings().remove(propName_);
188 else
189 OpenFlipperSettings().setValue(propName_, materialStrings_);
190 fillMaterialButton_->setEnabled(materialListWidget_->count());
191
192 //update hotkey table
193 std::map<int,size_t>::iterator eraseIter = shortKeyRow_.end();
194 for (std::map<int,size_t>::iterator iter = shortKeyRow_.begin(); iter != shortKeyRow_.end(); ++iter)
195 {
196 if (iter->second > index)
197 --(iter->second);
198 else if (iter->second == index)
199 eraseIter = iter;
200 }
201 if (eraseIter != shortKeyRow_.end())
202 shortKeyRow_.erase(eraseIter);
203
204}
205
206//------------------------------------------------------------------------------
207
208void MaterialPicker::clearList() {
209 materialListWidget_->clear();
210 materialList_.clear();
211 materialStrings_.clear();
212 fillMaterialButton_->setEnabled(false);
213
214 //setting value empty instead of removing will cause an error at start up
215 OpenFlipperSettings().remove(propName_);
216}
217
218//------------------------------------------------------------------------------
219
220void MaterialPicker::slotRemoveCurrentItem()
221{
222 if (!materialListWidget_->count())
223 return;
224
225 QMessageBox msgBox;
226 QListWidgetItem* item = materialListWidget_->currentItem();
227 msgBox.setText(tr("Remove ")+plainName(item->text(),materialListWidget_->currentRow())+tr("?"));
228 msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
229 msgBox.setDefaultButton(QMessageBox::Ok);
230 int ret = msgBox.exec();
231
232 if (ret == QMessageBox::Ok)
233 removeItem(materialListWidget_->currentItem());
234}
235//------------------------------------------------------------------------------
236
237void MaterialPicker::slotPickMaterialMode() {
238 pickMaterialButton_->setChecked(true);
239 fillMaterialButton_->setChecked(false);
240 pickMaterial_ = true;
241 fillMaterial_ = false;
242
243 PluginFunctions::actionMode( Viewer::PickingMode );
244 PluginFunctions::pickMode(pickModeName_);
245}
246
247//------------------------------------------------------------------------------
248
249void MaterialPicker::slotFillMaterialMode() {
250 fillMaterialButton_->setChecked(true);
251 pickMaterialButton_->setChecked(false);
252 fillMaterial_ = true;
253 pickMaterial_ = false;
254
255 PluginFunctions::actionMode( Viewer::PickingMode );
256 PluginFunctions::pickMode(pickModeName_);
257}
258
259//------------------------------------------------------------------------------
260
261void MaterialPicker::pluginsInitialized() {
262 emit addPickMode(pickModeName_);
263 for (unsigned i = 0; i < supportedKeys_; ++i)
264 emit registerKey (Qt::Key_1+i, Qt::ControlModifier, QString(tr("Material %1")).arg(i+1), false);
265}
266
267//------------------------------------------------------------------------------
268
269void MaterialPicker::slotMouseEvent(QMouseEvent* _event) {
270 if ( PluginFunctions::pickMode() != pickModeName_)
271 return;
272
273 if (_event->type() == QEvent::MouseButtonPress) {
274 size_t node_idx, target_idx;
275 OpenMesh::Vec3d hitPoint;
276
277 // Get picked object's identifier by picking in scenegraph
278 if ( PluginFunctions::scenegraphPick(ACG::SceneGraph::PICK_ANYTHING ,_event->pos(), node_idx, target_idx, &hitPoint) ){
279 BaseObjectData* object;
280 if ( PluginFunctions::getPickedObject(node_idx, object) ) {
281
282 // pick material
283 if ( pickMaterial_ && !fillMaterial_ ) {
284 MaterialNode* material = object->materialNode();
285
286 if (material) {
287
288 // store the material information
289 MaterialInfo materialInfo;
290 materialInfo.color_material = material->colorMaterial();
291 materialInfo.base_color = material->base_color();
292 materialInfo.ambient_color = material->ambient_color();
293 materialInfo.diffuse_color = material->diffuse_color();
294 materialInfo.specular_color = material->specular_color();
295 materialInfo.shininess = material->shininess();
296 materialInfo.reflectance = material->reflectance();
297
298 materialInfo.key = Qt::Key_unknown;
299 if (shortKeyRow_.size() < supportedKeys_)
300 {
301 materialInfo.key = Qt::Key_1+(int)shortKeyRow_.size();
302 shortKeyRow_[materialInfo.key] = materialListWidget_->count();
303 }
304
305 // update list widget and material list
306 QString name = QString("material id: %1").arg(material->id());
307 materialListWidget_->addItem( itemName(name,materialInfo.key) );
308
309 materialListWidget_->setCurrentItem( materialListWidget_->item(materialListWidget_->count() - 1) );
310
311 materialList_.push_back(materialInfo);
312
313 //save material
314 QString matStr = materialString(materialInfo,name);
315 materialStrings_.push_back(matStr);
316 OpenFlipperSettings().setValue(propName_, materialStrings_);
317
318 fillMaterialButton_->setEnabled(true);
319 OpenFlipperSettings().setValue(propName_, materialStrings_);
320 }
321
322 // apply material from current item in list widget to picked object
323 } else if ( fillMaterial_ && !pickMaterial_ ){
324 MaterialNode* material = object->materialNode();
325
326 if (material) {
327
328 if (materialListWidget_->count() > 0)
329 {
330 int row = materialListWidget_->currentRow();
331 material->colorMaterial(materialList_[row].color_material);
332 material->set_base_color(materialList_[row].base_color);
333 material->set_ambient_color(materialList_[row].ambient_color);
334 material->set_diffuse_color(materialList_[row].diffuse_color);
335 material->set_specular_color(materialList_[row].specular_color);
336 material->set_shininess(materialList_[row].shininess);
337 material->set_reflectance(materialList_[row].reflectance);
338 }
339
340 }
341 }
342 }
343 }
344 }
345}
346
347//------------------------------------------------------------------------------
348
349void MaterialPicker::editModeCurrent()
350{
351 editMode(materialListWidget_->currentItem());
352}
353
354//------------------------------------------------------------------------------
355void MaterialPicker::editMode(QListWidgetItem* _item) {
356 _item->setFlags(_item->flags() | Qt::ItemIsEditable);
357 materialListWidget_->editItem(_item);
358 _item->setText( plainName(_item->text(),materialListWidget_->row(_item)));
359}
360
361//------------------------------------------------------------------------------
362void MaterialPicker::saveNewName ( QWidget * _editor, QAbstractItemDelegate::EndEditHint _hint )
363{
364 saveNewName(materialListWidget_->currentItem());
365}
366//------------------------------------------------------------------------------
367QString MaterialPicker::plainName(const QString &string, int index)
368{
369 if (materialList_[index].key == Qt::Key_unknown)
370 return string;
371
372 QString str(string);
373 return str.remove(0,4);
374}
375//------------------------------------------------------------------------------
376void MaterialPicker::saveNewName (QListWidgetItem* _item)
377{
378 unsigned index = materialListWidget_->row(_item);
379 QString str = materialStrings_[index];
380 QStringList strList = str.split(";");
381
382 //pass name
383 strList[0] = _item->text();
384 //highlight hotkey support
385 if (materialList_[index].key != Qt::Key_unknown)
386 _item->setText( itemName(strList[0], materialList_[index].key) );
387
388
389 //create new String to save
390 str = "";
391 for (int i = 0; i < strList.size()-1; ++i)
392 str += strList[i] + ";";
393 str += strList[strList.size()-1];
394 materialStrings_[index] = str;
395 OpenFlipperSettings().setValue(propName_, materialStrings_);
396}
397//------------------------------------------------------------------------------
398
399QString MaterialPicker::itemName(const QString &_name, int _key)
400{
401 if (_key == Qt::Key_unknown)
402 return _name;
403
404 return QString(tr("(%1) ")).arg(QString::number(_key-Qt::Key_1+1)) +_name;
405}
406
407//------------------------------------------------------------------------------
408
409void MaterialPicker::slotPickModeChanged(const std::string& _mode) {
410 pickMaterialButton_->setChecked( _mode == pickModeName_ && pickMaterial_ );
411 fillMaterialButton_->setChecked( _mode == pickModeName_ && fillMaterial_ );
412}
413
414//------------------------------------------------------------------------------
415void MaterialPicker::slotKeyEvent(QKeyEvent* _event)
416{
417 for (unsigned i = 0; i < supportedKeys_; ++i)
418 {
419 int key = Qt::Key_1+i;
420 if (_event->key() == key && _event->modifiers() == Qt::ControlModifier)
421 {
422 if (shortKeyRow_.find(key) == shortKeyRow_.end())
423 return;
424 slotFillMaterialMode();
425 materialListWidget_->setCurrentRow((int)shortKeyRow_[key]);
426 }
427 }
428}
429//------------------------------------------------------------------------------
431{
432 std::map<int,size_t>::iterator iter = shortKeyRow_.find(_key);
433
434 if (iter != shortKeyRow_.end())
435 {
436 //remove old key
437 int oldIndex = (int)iter->second;
438 QListWidgetItem* oldItem = materialListWidget_->item(oldIndex);
439 //remove name
440 oldItem->setText( plainName(oldItem->text(),oldIndex) );
441 materialList_[oldIndex].key = Qt::Key_unknown; //unregister key after rename, otherwise the renaming will fail
442 materialStrings_[oldIndex] = materialString(materialList_[oldIndex],oldItem->text());
443 saveNewName(oldItem);
444 }
445
446 //set the new item (save and hint)
447 int newIndex = materialListWidget_->currentRow();
448 QListWidgetItem* newItem = materialListWidget_->item(newIndex);
449 materialList_[newIndex].key = _key;
450
451 materialStrings_[newIndex] = materialString(materialList_[newIndex],newItem->text());
452 saveNewName(newItem);
453
454 shortKeyRow_[_key] = newIndex;
455}
456//------------------------------------------------------------------------------
457QString MaterialPicker::materialString(const MaterialInfo& _mat, const QString &_name)
458{
459 std::stringstream stream;
460 stream << _name.toStdString();
461 stream << ";" << _mat.color_material;
462 stream << ";" << _mat.base_color;
463 stream << ";" << _mat.ambient_color;
464 stream << ";" << _mat.diffuse_color;
465 stream << ";" << _mat.specular_color;
466 stream << ";" << _mat.shininess;
467 stream << ";" << _mat.reflectance;
468 stream << ";" << _mat.key;
469
470 return QString(stream.str().c_str());
471}
472//------------------------------------------------------------------------------
473void MaterialPicker::slotMaterialProperties()
474{
475 if (materialNode_)
476 return;
477
478 //QListWidgetItem* item = materialListWidget_->currentItem();
479 materialListWidget_->setDisabled(true);
480
481 materialNode_.reset(new MaterialNode());
482 int row = materialListWidget_->currentRow();
483 materialNode_->colorMaterial(materialList_[row].color_material);
484 materialNode_->set_base_color(materialList_[row].base_color);
485 materialNode_->set_ambient_color(materialList_[row].ambient_color);
486 materialNode_->set_diffuse_color(materialList_[row].diffuse_color);
487 materialNode_->set_specular_color(materialList_[row].specular_color);
488 materialNode_->set_shininess(materialList_[row].shininess);
489 materialNode_->set_reflectance(materialList_[row].reflectance);
490
491 ACG::QtWidgets::QtMaterialDialog* dialog = new ACG::QtWidgets::QtMaterialDialog( 0, materialNode_.get() );
492
493 dialog->setWindowFlags(dialog->windowFlags() | Qt::WindowStaysOnTopHint);
494
495 connect(dialog,SIGNAL(finished(int)),this,SLOT(slotEnableListWidget(int)));
496 connect(dialog,SIGNAL(accepted()),this,SLOT(slotMaterialChanged()));
497
498 dialog->setWindowIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-material.png"));
499
500 dialog->show();
501
502}
503//------------------------------------------------------------------------------
504void MaterialPicker::slotMaterialChanged()
505{
506 if (materialNode_)
507 {
508 int index = materialListWidget_->currentRow();
509 // store the material information
510 MaterialInfo materialInfo;
511 materialInfo.color_material = materialNode_->colorMaterial();
512 materialInfo.base_color = materialNode_->base_color();
513 materialInfo.ambient_color = materialNode_->ambient_color();
514 materialInfo.diffuse_color = materialNode_->diffuse_color();
515 materialInfo.specular_color = materialNode_->specular_color();
516 materialInfo.shininess = materialNode_->shininess();
517 materialInfo.reflectance = materialNode_->reflectance();
518 materialInfo.key = materialList_[index].key;
519 QString name = plainName(materialListWidget_->currentItem()->text(),materialListWidget_->currentRow());
520 materialStrings_[index] = materialString(materialInfo,name);
521 materialList_[index] = materialInfo;
522 OpenFlipperSettings().setValue(propName_, materialStrings_);
523 }
524 OpenFlipperSettings().setValue(propName_, materialStrings_);
525}
526
527//------------------------------------------------------------------------------
528void MaterialPicker::slotEnableListWidget(int _save){
529 materialListWidget_->setEnabled(true);
530 if (_save == QDialog::Accepted)
531 slotMaterialChanged();
532 materialNode_.reset();
533}
534
535//------------------------------------------------------------------------------
536void MaterialPicker::createContextMenu(const QPoint& _point)
537{
538 QMenu *menu = new QMenu(materialListWidget_);
539
540 QAction* actionMaterialProperties = menu->addAction(tr("Material Properties"));
541 QIcon icon;
542 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-material.png");
543 actionMaterialProperties->setIcon(icon);
544 actionMaterialProperties->setEnabled(true);
545 connect(actionMaterialProperties,SIGNAL(triggered(bool)),this,SLOT(slotMaterialProperties()));
546
547 actionMaterialProperties = menu->addAction(tr("Rename"));
548 connect(actionMaterialProperties,SIGNAL(triggered(bool)),this,SLOT(editModeCurrent()));
549
550 actionMaterialProperties = menu->addAction(tr("Remove"));
551 connect(actionMaterialProperties, SIGNAL(triggered(bool)),this,SLOT(slotRemoveCurrentItem()));
552
553 menu->addSeparator();
554
555 //add hotkey selectors
556 for (unsigned i = 0; i < supportedKeys_; ++i)
557 {
558
559 QAction* action = menu->addAction(tr("Key %1").arg(i+1));
560 connect(action,&QAction::triggered, [=]() { changeHotKey(Qt::Key_1+i); } );
561
562 std::map<int,size_t>::iterator iter = shortKeyRow_.find(Qt::Key_1 + i);
563
564 //Disable already selected hotkey number
565 if (iter != shortKeyRow_.end() && iter->second == static_cast<size_t>(materialListWidget_->currentRow()))
566 action->setDisabled(true);
567 }
568
569 menu->exec(materialListWidget_->mapToGlobal(_point),0);
570
571
572
573}
574
575
ACG::SceneGraph::MaterialNode MaterialNode
Materialnode.
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
unsigned int id() const
Definition: BaseNode.hh:423
void set_diffuse_color(const Vec4f &_d)
set the diffuse color.
void set_specular_color(const Vec4f &_s)
set the specular color
const Vec4f & base_color() const
get the base color ( same as emission() )
void set_base_color(const Vec4f &_c)
set the base color ( Same as set_emission(const Vec4f& _c) )
float shininess() const
get shininess
void set_reflectance(double _m)
set reflectance
double reflectance() const
get reflectance
const Vec4f & diffuse_color() const
get the diffuse color.
void set_ambient_color(const Vec4f &_a)
set the ambient color.
const Vec4f & ambient_color() const
get the ambient color.
const Vec4f & specular_color() const
get the specular color
void colorMaterial(const bool _cm)
Set colorMaterial.
void set_shininess(float _s)
set shininess
bool fillMaterial_
stores the state of the fill material button
bool pickMaterial_
stores the state of the pick material button
QString materialString(const MaterialInfo &_mat, const QString &_name)
returns a formatted string for saving
void saveNewName(QWidget *_editor, QAbstractItemDelegate::EndEditHint _hint)
saves the new material name with hotkey hint
void changeHotKey(const int _key)
change specified HotKey to current item
QString name()
Return a name for the plugin.
void editMode(QListWidgetItem *_item)
items can be renamed by double clicking them
QString itemName(const QString &_name, int _key)
returns the item name with hotkey hint
QString plainName(const QString &string, int index)
returns the plain name of the material without hotkey hint
void createContextMenu(const QPoint &_point)
creates context menu on current item (current is the item at mouse position)
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
void setValue(const QString &key, const QVariant &value)
Wrapper function which makes it possible to enable Debugging output with -DOPENFLIPPER_SETTINGS_DEBUG...
@ PICK_ANYTHING
pick any of the prior targets (should be implemented for all nodes)
Definition: PickTarget.hh:84
const std::string pickMode()
Get the current Picking mode.
bool getPickedObject(const size_t _node_idx, BaseObjectData *&_object)
Get the picked mesh.
bool scenegraphPick(ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, size_t &_nodeIdx, size_t &_targetIdx, ACG::Vec3d *_hitPointPtr=0)
Execute picking operation on scenegraph.
Viewer::ActionMode actionMode()
Get the current Action mode.