mirror of https://github.com/CGAL/cgal
Add action, with shortcuts, to:
- activate a polyhedron (Ctrl+Space) - put polyhedron as selection A (Ctrl+A) - put polyhedron as selection B (Ctrl+B)
This commit is contained in:
parent
125b698c13
commit
cf3e194f55
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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...
|
||||
|
|
|
|||
|
|
@ -143,6 +143,9 @@
|
|||
<property name="title" >
|
||||
<string>&Edit</string>
|
||||
</property>
|
||||
<addaction name="actionActivatePolyhedron" />
|
||||
<addaction name="actionSetPolyhedronA" />
|
||||
<addaction name="actionSetPolyhedronB" />
|
||||
<addaction name="actionOptions" />
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuAlgorithms" >
|
||||
|
|
@ -323,16 +326,25 @@
|
|||
<property name="text" >
|
||||
<string>&Union</string>
|
||||
</property>
|
||||
<property name="shortcut" >
|
||||
<string>Ctrl+O, U</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionIntersection" >
|
||||
<property name="text" >
|
||||
<string>&Intersection</string>
|
||||
</property>
|
||||
<property name="shortcut" >
|
||||
<string>Ctrl+O, I</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDifference" >
|
||||
<property name="text" >
|
||||
<string>&Difference</string>
|
||||
</property>
|
||||
<property name="shortcut" >
|
||||
<string>Ctrl+O, D</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionFitPlane" >
|
||||
<property name="text" >
|
||||
|
|
@ -394,9 +406,6 @@
|
|||
<property name="text" >
|
||||
<string>&Antialiasing</string>
|
||||
</property>
|
||||
<property name="shortcut" >
|
||||
<string>Ctrl+A</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="dummyAction" >
|
||||
<property name="text" >
|
||||
|
|
@ -483,6 +492,30 @@
|
|||
<string>Ctrl+E</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionActivatePolyhedron" >
|
||||
<property name="text" >
|
||||
<string>Activate selected polyhedron</string>
|
||||
</property>
|
||||
<property name="shortcut" >
|
||||
<string>Ctrl+Space</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSetPolyhedronA" >
|
||||
<property name="text" >
|
||||
<string>Set polyhedron A</string>
|
||||
</property>
|
||||
<property name="shortcut" >
|
||||
<string>Ctrl+A</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSetPolyhedronB" >
|
||||
<property name="text" >
|
||||
<string>Set polyhedron B</string>
|
||||
</property>
|
||||
<property name="shortcut" >
|
||||
<string>Ctrl+B</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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<Scene::RenderingMode>(model->data(index, ::Qt::EditRole).toInt());
|
||||
std::cerr << "render mode = " << rendering_mode << "\n";
|
||||
if(rendering_mode == Scene::Wireframe)
|
||||
model->setData(index, static_cast<int>(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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue