mirror of https://github.com/CGAL/cgal
Largest_empty_iso_rectangle: Improve Demo
This commit is contained in:
parent
1d6830501d
commit
8c0d5bd59b
|
|
@ -98,6 +98,8 @@ public Q_SLOTS:
|
||||||
|
|
||||||
void on_actionClear_triggered();
|
void on_actionClear_triggered();
|
||||||
|
|
||||||
|
void on_actionOpen_triggered();
|
||||||
|
|
||||||
void processInput(CGAL::Object);
|
void processInput(CGAL::Object);
|
||||||
|
|
||||||
void on_actionRecenter_triggered();
|
void on_actionRecenter_triggered();
|
||||||
|
|
@ -105,7 +107,7 @@ public Q_SLOTS:
|
||||||
void on_actionGeneratePointsInSquare_triggered();
|
void on_actionGeneratePointsInSquare_triggered();
|
||||||
void on_actionGeneratePointsInDisc_triggered();
|
void on_actionGeneratePointsInDisc_triggered();
|
||||||
void clear();
|
void clear();
|
||||||
|
void open(QString fileName);
|
||||||
void update_largest_empty_rectangle();
|
void update_largest_empty_rectangle();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
|
@ -229,6 +231,50 @@ MainWindow::on_actionClear_triggered()
|
||||||
Q_EMIT( changed());
|
Q_EMIT( changed());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MainWindow::on_actionOpen_triggered()
|
||||||
|
{
|
||||||
|
QString fileName = QFileDialog::getOpenFileName(this,
|
||||||
|
tr("Open points file"),
|
||||||
|
"."
|
||||||
|
,tr("xy files (*.xy)")
|
||||||
|
);
|
||||||
|
if(! fileName.isEmpty()){
|
||||||
|
open(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MainWindow::open(QString fileName)
|
||||||
|
{
|
||||||
|
// wait cursor
|
||||||
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
|
std::ifstream ifs(qPrintable(fileName));
|
||||||
|
|
||||||
|
clear();
|
||||||
|
|
||||||
|
Point_2 p;
|
||||||
|
while(ifs >> p){
|
||||||
|
points.push_back(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL::Bbox_2 bbox = CGAL::bbox_2(points.begin(), points.end());
|
||||||
|
square = Iso_rectangle_2(bbox);
|
||||||
|
|
||||||
|
ler = Largest_empty_iso_rectangle_2(square);
|
||||||
|
ler.insert(points.begin(), points.end());
|
||||||
|
|
||||||
|
frame[0]->setLine(convert(Segment_2(square.vertex(0),square.vertex(1))));
|
||||||
|
frame[1]->setLine(convert(Segment_2(square.vertex(1), square.vertex(2))));
|
||||||
|
frame[2]->setLine(convert(Segment_2(square.vertex(2), square.vertex(3))));
|
||||||
|
frame[3]->setLine(convert(Segment_2(square.vertex(3), square.vertex(0))));
|
||||||
|
|
||||||
|
QApplication::restoreOverrideCursor();
|
||||||
|
on_actionRecenter_triggered();
|
||||||
|
Q_EMIT( changed());
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MainWindow::on_actionRecenter_triggered()
|
MainWindow::on_actionRecenter_triggered()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>500</width>
|
<width>500</width>
|
||||||
<height>26</height>
|
<height>22</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile">
|
<widget class="QMenu" name="menuFile">
|
||||||
|
|
@ -90,6 +90,7 @@
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionClear"/>
|
<addaction name="actionClear"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionOpen"/>
|
||||||
<addaction name="actionQuit"/>
|
<addaction name="actionQuit"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuTools">
|
<widget class="QMenu" name="menuTools">
|
||||||
|
|
@ -199,6 +200,11 @@
|
||||||
<string>Generate Segment Fans</string>
|
<string>Generate Segment Fans</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionOpen">
|
||||||
|
<property name="text">
|
||||||
|
<string>Open</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="Largest_empty_rectangle_2.qrc"/>
|
<include location="Largest_empty_rectangle_2.qrc"/>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue