nicer applicable

This commit is contained in:
Andreas Fabri 2017-03-10 16:41:40 +01:00 committed by Maxime Gimeno
parent 81f0c7152a
commit b4a44aa9ec
2 changed files with 7 additions and 11 deletions

View File

@ -30,11 +30,9 @@ class Polyhedron_demo_intersection_plugin :
public:
bool applicable(QAction*) const {
int nb_selected=0;
Q_FOREACH(CGAL::Three::Scene_interface::Item_id index, scene->selectionIndices())
if ( qobject_cast<Scene_polyhedron_item*>(scene->item(index)) )
++nb_selected;
return nb_selected==2;
return scene->selectionIndices().size() == 2 &&
qobject_cast<Scene_polyhedron_item*>(scene->item(scene->selectionIndices().first())) &&
qobject_cast<Scene_polyhedron_item*>(scene->item(scene->selectionIndices().last()));
}
QList<QAction*> actions() const {

View File

@ -29,12 +29,10 @@ class Polyhedron_demo_intersection_plugin :
public:
bool applicable(QAction*) const {
int nb_selected=0;
Q_FOREACH(CGAL::Three::Scene_interface::Item_id index, scene->selectionIndices())
if ( qobject_cast<Scene_surface_mesh_item*>(scene->item(index)) )
++nb_selected;
return nb_selected==2;
bool applicable(QAction*) const {
return scene->selectionIndices().size() == 2 &&
qobject_cast<Scene_surface_mesh_item*>(scene->item(scene->selectionIndices().first())) &&
qobject_cast<Scene_surface_mesh_item*>(scene->item(scene->selectionIndices().last()));
}
QList<QAction*> actions() const {