goat3d

diff goatview/src/goatview.cc @ 99:d7ab4f13f5af

Merge
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 21 May 2014 05:01:34 +0300
parents 32dccb16678f b43d33f3ba69
children fae6dc0fd462
line diff
     1.1 --- a/goatview/src/goatview.cc	Wed May 21 05:00:21 2014 +0300
     1.2 +++ b/goatview/src/goatview.cc	Wed May 21 05:01:34 2014 +0300
     1.3 @@ -76,7 +76,7 @@
     1.4  bool GoatView::load_scene(const char *fname)
     1.5  {
     1.6  	if(scene) {
     1.7 -		goat3d_free(scene);
     1.8 +		close_scene();
     1.9  	}
    1.10  	if(!(scene = goat3d_create()) || goat3d_load(scene, fname) == -1) {
    1.11  		QMessageBox::critical(this, "Error", "Failed to load scene file: " + QString(fname));
    1.12 @@ -159,6 +159,12 @@
    1.13  	connect(act_open_anm, &QAction::triggered, this, &GoatView::open_anim);
    1.14  	menu_file->addAction(act_open_anm);
    1.15  
    1.16 +	QAction *act_close = new QAction("&Close", this);
    1.17 +	connect(act_close, &QAction::triggered, this, &GoatView::close_scene);
    1.18 +	menu_file->addAction(act_close);
    1.19 +
    1.20 +	menu_file->addSeparator();
    1.21 +
    1.22  	QAction *act_quit = new QAction("&Quit", this);
    1.23  	act_quit->setShortcuts(QKeySequence::Quit);
    1.24  	connect(act_quit, &QAction::triggered, [&](){ qApp->quit(); });
    1.25 @@ -322,12 +328,20 @@
    1.26  	statusBar()->showMessage("Successfully loaded scene: " + QString(fname.c_str()));
    1.27  }
    1.28  
    1.29 +void GoatView::close_scene()
    1.30 +{
    1.31 +	scene_model->clear_scene();
    1.32 +	treeview->reset();
    1.33 +	goat3d_free(scene);
    1.34 +	scene = 0;
    1.35 +}
    1.36 +
    1.37  void GoatView::open_anim()
    1.38  {
    1.39  	std::string fname = QFileDialog::getOpenFileName(this, "Open animation file", "",
    1.40  		"Goat3D Animation (*.goatanm);;All Files (*)").toStdString();
    1.41  	if(fname.empty()) {
    1.42 -		statusBar()->showMessage("Abot: No file selected!");
    1.43 +		statusBar()->showMessage("Abort: No file selected!");
    1.44  		return;
    1.45  	}
    1.46