Add the necessary to allow persistence between calls

This commit is contained in:
Andreas Fabri 2008-10-01 09:17:07 +00:00
parent 6212a25eac
commit 7ad693501b
5 changed files with 47 additions and 21 deletions

View File

@ -296,7 +296,7 @@ MainWindow::MainWindow()
//
// Manual handling of actions
//
QObject::connect(this->actionExit, SIGNAL(triggered()),
QObject::connect(this->actionQuit, SIGNAL(triggered()),
this, SLOT(close()));
// We put mutually exclusive actions in an QActionGroup
@ -329,7 +329,7 @@ MainWindow::MainWindow()
this->addAboutDemo(":/cgal/help/about_Constrained_Delaunay_triangulation_2.html");
this->addAboutCGAL();
this->addRecentFiles(this->menuFile, this->actionExit);
this->addRecentFiles(this->menuFile, this->actionQuit);
connect(this, SIGNAL(openRecentFile(QString)),
this, SLOT(open(QString)));
}

View File

@ -78,7 +78,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>29</height>
<height>19</height>
</rect>
</property>
<widget class="QMenu" name="menuFile" >
@ -90,7 +90,7 @@
<addaction name="actionLoadConstraints" />
<addaction name="actionSaveConstraints" />
<addaction name="separator" />
<addaction name="actionExit" />
<addaction name="actionQuit" />
</widget>
<widget class="QMenu" name="menuEdit" >
<property name="title" >
@ -130,7 +130,7 @@
<string>About &amp;CGAL</string>
</property>
</action>
<action name="actionExit" >
<action name="actionQuit" >
<property name="text" >
<string>&amp;Quit</string>
</property>

View File

@ -82,6 +82,7 @@ public slots:
void on_actionRecenter_triggered();
void open(const QString& fileName);
signals:
void changed();
@ -140,7 +141,8 @@ MainWindow::MainWindow()
//
// Manual handling of actions
//
QObject::connect(this->actionExit, SIGNAL(triggered()),
QObject::connect(this->actionQuit, SIGNAL(triggered()),
this, SLOT(close()));
// We put mutually exclusive actions in an QActionGroup
@ -173,6 +175,10 @@ MainWindow::MainWindow()
this->setupOptionsMenu();
this->addAboutDemo(":/cgal/help/about_Delaunay_triangulation_2.html");
this->addAboutCGAL();
this->addRecentFiles(this->menuFile, this->actionQuit);
connect(this, SIGNAL(openRecentFile(QString)),
this, SLOT(open(QString)));
}
@ -310,21 +316,33 @@ MainWindow::on_actionLoadPoints_triggered()
tr("Open Points file"),
".");
if(! fileName.isEmpty()){
std::ifstream ifs(qPrintable(fileName));
K::Point_2 p;
std::vector<K::Point_2> points;
while(ifs >> p) {
points.push_back(p);
}
dt.insert(points.begin(), points.end());
actionRecenter->trigger();
emit(changed());
open(fileName);
}
}
void
MainWindow::open(const QString& fileName)
{
// wait cursor
QApplication::setOverrideCursor(Qt::WaitCursor);
std::ifstream ifs(qPrintable(fileName));
K::Point_2 p;
std::vector<K::Point_2> points;
while(ifs >> p) {
points.push_back(p);
}
dt.insert(points.begin(), points.end());
// default cursor
QApplication::restoreOverrideCursor();
this->addToRecentFiles(fileName);
actionRecenter->trigger();
emit(changed());
}
void
MainWindow::on_actionSavePoints_triggered()
{
@ -358,6 +376,10 @@ int main(int argc, char **argv)
{
QApplication app(argc, argv);
app.setOrganizationDomain("geometryfactory.com");
app.setOrganizationName("GeometryFactory");
app.setApplicationName("Delaunay_triangulation_2 demo");
// Import resources from libCGALQt4.
// See http://doc.trolltech.com/4.4/qdir.html#Q_INIT_RESOURCE
Q_INIT_RESOURCE(File);

View File

@ -78,7 +78,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>29</height>
<height>19</height>
</rect>
</property>
<widget class="QMenu" name="menuFile" >
@ -90,7 +90,7 @@
<addaction name="actionLoadPoints" />
<addaction name="actionSavePoints" />
<addaction name="separator" />
<addaction name="actionExit" />
<addaction name="actionQuit" />
</widget>
<widget class="QMenu" name="menuEdit" >
<property name="title" >
@ -126,7 +126,7 @@
<string>About &amp;CGAL</string>
</property>
</action>
<action name="actionExit" >
<action name="actionQuit" >
<property name="text" >
<string>&amp;Quit</string>
</property>

View File

@ -91,7 +91,7 @@ MainWindow::MainWindow()
QObject::connect(this, SIGNAL(changed()),
dgi, SLOT(modelChanged()));
dgi->setVerticesPen(QPen(Qt::red, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
dgi->setVerticesPen(QPen(Qt::red, 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
scene.addItem(dgi);
// Add a GraphicItem for the Powerdiagram diagram
@ -290,6 +290,10 @@ int main(int argc, char **argv)
{
QApplication app(argc, argv);
app.setOrganizationDomain("geometryfactory.com");
app.setOrganizationName("GeometryFactory");
app.setApplicationName("Regular_triangulation_2 demo");
// Import resources from libCGALQt4.
// See http://doc.trolltech.com/4.4/qdir.html#Q_INIT_RESOURCE
Q_INIT_RESOURCE(File);