diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp
index 1bf6d430bbd..257e708b1b7 100644
--- a/Polyhedron/demo/Polyhedron/MainWindow.cpp
+++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp
@@ -330,3 +330,24 @@ void MainWindow::on_actionDuplicatePolyhedron_triggered()
}
}
+void MainWindow::on_actionActivatePolyhedron_triggered()
+{
+ Q_FOREACH(QModelIndex index, treeView->selectionModel()->selectedRows())
+ {
+ int i = index.row();
+ scene->setPolyhedronActivated(i,
+ !scene->isPolyhedronActivated(i));
+ }
+}
+
+void MainWindow::on_actionSetPolyhedronA_triggered()
+{
+ int i = getSelectedPolygonIndex();
+ scene->setPolyhedronA(i);
+}
+
+void MainWindow::on_actionSetPolyhedronB_triggered()
+{
+ int i = getSelectedPolygonIndex();
+ scene->setPolyhedronB(i);
+}
diff --git a/Polyhedron/demo/Polyhedron/MainWindow.h b/Polyhedron/demo/Polyhedron/MainWindow.h
index e9146d13d6e..c0dfdf8d996 100644
--- a/Polyhedron/demo/Polyhedron/MainWindow.h
+++ b/Polyhedron/demo/Polyhedron/MainWindow.h
@@ -42,6 +42,10 @@ protected slots:
void on_actionErasePolyhedron_triggered();
void on_actionDuplicatePolyhedron_triggered();
+ void on_actionActivatePolyhedron_triggered();
+ void on_actionSetPolyhedronA_triggered();
+ void on_actionSetPolyhedronB_triggered();
+
// save
// TODO: save all, save current (do we store the current file name?)
void on_actionSaveAs_triggered(); // save selected polyhedron as...
diff --git a/Polyhedron/demo/Polyhedron/MainWindow.ui b/Polyhedron/demo/Polyhedron/MainWindow.ui
index 55139188c75..88c8beb62b6 100644
--- a/Polyhedron/demo/Polyhedron/MainWindow.ui
+++ b/Polyhedron/demo/Polyhedron/MainWindow.ui
@@ -143,6 +143,9 @@
&Edit
+
+
+
diff --git a/Polyhedron/demo/Polyhedron/MainWindow_subdivision_methods.cpp b/Polyhedron/demo/Polyhedron/MainWindow_subdivision_methods.cpp
index d0ad1fbe0f4..6dded9de9c9 100644
--- a/Polyhedron/demo/Polyhedron/MainWindow_subdivision_methods.cpp
+++ b/Polyhedron/demo/Polyhedron/MainWindow_subdivision_methods.cpp
@@ -6,26 +6,26 @@
void MainWindow::on_actionLoop_triggered()
{
- Polyhedron* poly = getSelectedPolygon();
- if(!poly) return;
- // CGAL::Subdivision_method_3::Loop_subdivision(*poly, 1);
- scene->polyhedronChanged(poly);
+ Polyhedron* poly = getSelectedPolygon();
+ if(!poly) return;
+ CGAL::Subdivision_method_3::Loop_subdivision(*poly, 1);
+ scene->polyhedronChanged(poly);
}
void MainWindow::on_actionCatmullClark_triggered()
{
- Polyhedron* poly = getSelectedPolygon();
- if(!poly) return;
- //CGAL::Subdivision_method_3::CatmullClark_subdivision(*poly, 1);
- scene->polyhedronChanged(poly);
+ Polyhedron* poly = getSelectedPolygon();
+ if(!poly) return;
+ CGAL::Subdivision_method_3::CatmullClark_subdivision(*poly, 1);
+ scene->polyhedronChanged(poly);
}
void MainWindow::on_actionSqrt3_triggered()
{
- Polyhedron* poly = getSelectedPolygon();
- if(!poly) return;
- //CGAL::Subdivision_method_3::Sqrt3_subdivision(*poly, 1);
- scene->polyhedronChanged(poly);
+ Polyhedron* poly = getSelectedPolygon();
+ if(!poly) return;
+ CGAL::Subdivision_method_3::Sqrt3_subdivision(*poly, 1);
+ scene->polyhedronChanged(poly);
}
diff --git a/Polyhedron/demo/Polyhedron/Scene.cpp b/Polyhedron/demo/Polyhedron/Scene.cpp
index 2554f2aa105..2dc027edf2c 100644
--- a/Polyhedron/demo/Polyhedron/Scene.cpp
+++ b/Polyhedron/demo/Polyhedron/Scene.cpp
@@ -424,6 +424,15 @@ bool Scene::isPolyhedronActivated(int index) const
return polyhedra[index].activated;
}
+void Scene::setPolyhedronActivated(int index, bool b)
+{
+ if( index < 0 || index >= polyhedra.size() )
+ return;
+ polyhedra[index].activated = b;
+ emit dataChanged(QAbstractItemModel::createIndex(index, ActivatedColumn),
+ QAbstractItemModel::createIndex(index, ActivatedColumn));
+}
+
Scene::RenderingMode Scene::polyhedronRenderingMode(int index) const
{
if( index < 0 || index >= polyhedra.size() )
@@ -502,7 +511,6 @@ bool SceneDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
if (event->type() == QEvent::MouseButtonPress) {
Scene::RenderingMode rendering_mode =
static_cast(model->data(index, ::Qt::EditRole).toInt());
- std::cerr << "render mode = " << rendering_mode << "\n";
if(rendering_mode == Scene::Wireframe)
model->setData(index, static_cast(Scene::Fill));
else
@@ -571,3 +579,26 @@ void SceneDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
drawFocus(painter, option, option.rect); // since we draw the grid ourselves
}
}
+
+void Scene::setPolyhedronA(int i)
+{
+ item_A = i;
+ if(item_A == item_B)
+ {
+ item_B = -1;
+ }
+ emit dataChanged(QAbstractItemModel::createIndex(0, ABColumn),
+ QAbstractItemModel::createIndex(polyhedra.size()-1, ABColumn));
+}
+
+void Scene::setPolyhedronB(int i)
+{
+ item_B = i;
+ if(item_A == item_B)
+ {
+ item_A = -1;
+ }
+ emit updated();
+ emit dataChanged(QAbstractItemModel::createIndex(0, ABColumn),
+ QAbstractItemModel::createIndex(polyhedra.size()-1, ABColumn));
+}
diff --git a/Polyhedron/demo/Polyhedron/Scene.h b/Polyhedron/demo/Polyhedron/Scene.h
index a71cea19679..dde3967f292 100644
--- a/Polyhedron/demo/Polyhedron/Scene.h
+++ b/Polyhedron/demo/Polyhedron/Scene.h
@@ -57,7 +57,7 @@ public:
int duplicate(int); // Returns the index of the new polyhedra
- // accessors
+ // Accessors (getters)
Polyhedron* polyhedron(int i) const;
QColor polyhedronColor(int) const;
QString polyhedronName(int) const;
@@ -66,7 +66,6 @@ public:
int selectionAindex() const;
int selectionBindex() const;
-
// for backward compatibility
Polyhedron* getPolyhedron(int i) { return polyhedron(i); }
@@ -103,6 +102,10 @@ public slots:
viewEdges = b;
emit updated();
}
+ // Accessors (setters)
+ void setPolyhedronActivated(int, bool b);
+ void setPolyhedronA(int i);
+ void setPolyhedronB(int i);
signals:
void updated_bbox();
diff --git a/Polyhedron/demo/Polyhedron/TODO.txt b/Polyhedron/demo/Polyhedron/TODO.txt
index 93d8053ee0d..d6c6ca14682 100644
--- a/Polyhedron/demo/Polyhedron/TODO.txt
+++ b/Polyhedron/demo/Polyhedron/TODO.txt
@@ -1,5 +1,3 @@
- merge all -> merge all polyhedra into one (with several connected components)
-- display lists for rendering
-- superimpose edges as option
- use the signal QMenu::aboutToShow() to enable/disable some menu entries.
- check that display list is deleted when destroys one entry