qtSimple.cpp 14.7 KB
Newer Older
Sylvain Thery's avatar
Sylvain Thery committed
1
2
3
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
4
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg           *
Sylvain Thery's avatar
Sylvain Thery committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
*                                                                              *
* This library is free software; you can redistribute it and/or modify it      *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your     *
* option) any later version.                                                   *
*                                                                              *
* This library is distributed in the hope that it will be useful, but WITHOUT  *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or        *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License  *
* for more details.                                                            *
*                                                                              *
* You should have received a copy of the GNU Lesser General Public License     *
* along with this library; if not, write to the Free Software Foundation,      *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.           *
*                                                                              *
20
* Web site: http://cgogn.unistra.fr/                                           *
Sylvain Thery's avatar
Sylvain Thery committed
21
22
23
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/
Sylvain Thery's avatar
Sylvain Thery committed
24
#define CGoGN_UTILS_DLL_EXPORT 1
25
#include <cmath>
Sylvain Thery's avatar
Sylvain Thery committed
26
#include "Utils/GLSLShader.h"
27
28
#include "Utils/Qt/qtSimple.h"
#include "Utils/Qt/qtgl.h"
29
30
#include "glm/gtc/matrix_transform.hpp"
#include "glm/gtc/type_precision.hpp"
31
#include "glm/gtc/type_ptr.hpp"
Sylvain Thery's avatar
Sylvain Thery committed
32

Sylvain Thery's avatar
Sylvain Thery committed
33
#include <QTextEdit>
Sylvain Thery's avatar
Sylvain Thery committed
34
#include <QImage>
Sylvain Thery's avatar
Sylvain Thery committed
35
36
37
38
39
40
#include <QMenuBar>
#include <QAction>
#include <QDockWidget>
#include <QStatusBar>
#include <QFileDialog>
#include <QMessageBox>
Sylvain Thery's avatar
Sylvain Thery committed
41

Sylvain Thery's avatar
Sylvain Thery committed
42
43
namespace CGoGN
{
Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
44

Sylvain Thery's avatar
Sylvain Thery committed
45
46
namespace Utils
{
Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
47

Sylvain Thery's avatar
Sylvain Thery committed
48
49
50
namespace QT
{

51
SimpleQT::SimpleQT() :
Pierre Kraemer's avatar
Pierre Kraemer committed
52
53
54
55
	m_dock(NULL),
	m_projection_matrix(m_mat.m_matrices[0]),
	m_modelView_matrix(m_mat.m_matrices[1]),
	m_transfo_matrix(m_mat.m_matrices[2])
Sylvain Thery's avatar
Sylvain Thery committed
56
{
57
58
	if (GLSLShader::CURRENT_OGL_VERSION >= 3)
	{
Sylvain Thery's avatar
Sylvain Thery committed
59
60
61
62
63
		QGLFormat glFormat;
		glFormat.setVersion( Utils::GLSLShader::MAJOR_OGL_CORE, Utils::GLSLShader::MINOR_OGL_CORE);
		glFormat.setProfile( QGLFormat::CoreProfile ); // Requires >=Qt-4.8.0
		glFormat.setSampleBuffers( true );
		QGLFormat::setDefaultFormat(glFormat);
64
	}
Sylvain Thery's avatar
Sylvain Thery committed
65
	m_glWidget = new GLWidget(this);
66
67


Sylvain Thery's avatar
Sylvain Thery committed
68
69
70
	setCentralWidget(m_glWidget);
	setWindowTitle(tr("CGoGN"));

Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
71
	m_fileMenu = menuBar()->addMenu(tr("&File"));
Sylvain Thery's avatar
Sylvain Thery committed
72

Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
73
	QAction* action = new QAction(tr("New"), this);
Sylvain Thery's avatar
Sylvain Thery committed
74
75
76
	connect(action, SIGNAL(triggered()), this, SLOT(cb_New()));
	m_fileMenu->addAction(action);

Pierre Kraemer's avatar
Pierre Kraemer committed
77
	action = new QAction(tr("Open"), this);
Sylvain Thery's avatar
Sylvain Thery committed
78
79
80
	connect(action, SIGNAL(triggered()), this, SLOT(cb_Open()));
	m_fileMenu->addAction(action);

Pierre Kraemer's avatar
Pierre Kraemer committed
81
	action = new QAction(tr("Save"), this);
Sylvain Thery's avatar
Sylvain Thery committed
82
83
84
85
86
	connect(action, SIGNAL(triggered()), this, SLOT(cb_Save()));
	m_fileMenu->addAction(action);

	m_fileMenu->addSeparator();

Pierre Kraemer's avatar
Pierre Kraemer committed
87
	action = new QAction(tr("Quit"), this);
Sylvain Thery's avatar
Sylvain Thery committed
88
89
90
91
92
93
94
	connect(action, SIGNAL(triggered()), this, SLOT(cb_Quit()));
	m_fileMenu->addAction(action);

	m_appMenu = menuBar()->addMenu(tr("&Application"));

	QMenu* m_helpMenu = menuBar()->addMenu(tr("&Help"));

Pierre Kraemer's avatar
Pierre Kraemer committed
95
	action = new QAction(tr("console on/off"), this);
96
97
98
	connect(action, SIGNAL(triggered()), this, SLOT(cb_consoleOnOff()));
	m_helpMenu->addAction(action);

Pierre Kraemer's avatar
Pierre Kraemer committed
99
	action = new QAction(tr("console clear"), this);
100
101
102
	connect(action, SIGNAL(triggered()), this, SLOT(cb_consoleClear()));
	m_helpMenu->addAction(action);

Pierre Kraemer's avatar
Pierre Kraemer committed
103
	action = new QAction(tr("About"), this);
Sylvain Thery's avatar
Sylvain Thery committed
104
105
106
	connect(action, SIGNAL(triggered()), this, SLOT(cb_about()));
	m_helpMenu->addAction(action);

Pierre Kraemer's avatar
Pierre Kraemer committed
107
	action = new QAction(tr("About CGoGN"), this);
Sylvain Thery's avatar
Sylvain Thery committed
108
109
110
	connect(action, SIGNAL(triggered()), this, SLOT(cb_about_cgogn()));
	m_helpMenu->addAction(action);

Sylvain Thery's avatar
Sylvain Thery committed
111
112
	m_dockConsole = new QDockWidget(tr("Console"), this);
	m_dockConsole->setAllowedAreas(Qt::BottomDockWidgetArea);
Pierre Kraemer's avatar
Pierre Kraemer committed
113
	m_dockConsole->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetClosable);
Sylvain Thery's avatar
Sylvain Thery committed
114
115
116
117
118
	addDockWidget(Qt::BottomDockWidgetArea, m_dockConsole);

	m_textConsole = new QTextEdit();
	m_textConsole->setLineWrapMode(QTextEdit::NoWrap);
	m_textConsole->setTabStopWidth(20);
119
//	m_textConsole->setReadOnly(true);
Sylvain Thery's avatar
Sylvain Thery committed
120
121
122
123

	m_dockConsole->setWidget(m_textConsole);

	m_dockConsole->hide();
124
125

	m_transfo_matrix = glm::mat4(1.0f);
David Cazier's avatar
David Cazier committed
126
127

	resize(1200,800);
128
	m_glWidget->setFocus(Qt::MouseFocusReason);
Sylvain Thery's avatar
Sylvain Thery committed
129
130
}

131
SimpleQT::SimpleQT(const SimpleQT& sqt):
132
	QMainWindow(),
Pierre Kraemer's avatar
Pierre Kraemer committed
133
134
135
136
	m_dock(NULL),
	m_projection_matrix(m_mat.m_matrices[0]),
	m_modelView_matrix(m_mat.m_matrices[1]),
	m_transfo_matrix(m_mat.m_matrices[2])
137
{
138
139
	if (GLSLShader::CURRENT_OGL_VERSION >= 3)
	{
Sylvain Thery's avatar
Sylvain Thery committed
140
141
142
143
144
		QGLFormat glFormat;
		glFormat.setVersion( Utils::GLSLShader::MAJOR_OGL_CORE, Utils::GLSLShader::MINOR_OGL_CORE);
		glFormat.setProfile( QGLFormat::CoreProfile ); // Requires >=Qt-4.8.0
		glFormat.setSampleBuffers( true );
		QGLFormat::setDefaultFormat(glFormat);
145
	}
Sylvain Thery's avatar
Sylvain Thery committed
146
147

	m_glWidget = new GLWidget(this);
148

149
150
151
152
153
154
155
	setCentralWidget(m_glWidget);

	m_dock = new QDockWidget(sqt.m_dock) ;
	m_dockConsole = new QDockWidget(sqt.m_dockConsole) ;
	m_textConsole = new QTextEdit(sqt.m_textConsole) ;
	m_dockOn = sqt.m_dockOn ;

156

157
158
159
160
161
162
163
164
	for (unsigned int i = 0; i < 4; ++i)
	{
		m_curquat[i] = sqt.m_curquat[i];
		m_lastquat[i] = sqt.m_lastquat[i];
	}
	m_trans_x = sqt.m_trans_x ;
	m_trans_y = sqt.m_trans_y ;
	m_trans_z = sqt.m_trans_z ;
165
166

	m_glWidget->setFocus(Qt::MouseFocusReason);
167
168
}

Sylvain Thery's avatar
Sylvain Thery committed
169
170
171
172
173
SimpleQT::~SimpleQT()
{
	delete m_glWidget; // ??
}

174
175
void SimpleQT::operator=(const SimpleQT& sqt)
{
176
177
	if (GLSLShader::CURRENT_OGL_VERSION >= 3)
	{
Sylvain Thery's avatar
Sylvain Thery committed
178
179
180
181
182
		QGLFormat glFormat;
		glFormat.setVersion( Utils::GLSLShader::MAJOR_OGL_CORE, Utils::GLSLShader::MINOR_OGL_CORE);
		glFormat.setProfile( QGLFormat::CoreProfile ); // Requires >=Qt-4.8.0
		glFormat.setSampleBuffers( true );
		QGLFormat::setDefaultFormat(glFormat);
183
	}
Sylvain Thery's avatar
Sylvain Thery committed
184
185

	m_glWidget = new GLWidget(this);
186

187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
	setCentralWidget(m_glWidget) ;

	m_dock = new QDockWidget(sqt.m_dock) ;
	m_dockConsole = new QDockWidget(sqt.m_dockConsole) ;
	m_textConsole = new QTextEdit(sqt.m_textConsole) ;
	m_dockOn = sqt.m_dockOn ;

	m_projection_matrix = sqt.m_projection_matrix;
	m_modelView_matrix = sqt.m_modelView_matrix;
	for (unsigned int i = 0; i < 4; ++i)
	{
		m_curquat[i] = sqt.m_curquat[i];
		m_lastquat[i] = sqt.m_lastquat[i];
	}
	m_trans_x = sqt.m_trans_x ;
	m_trans_y = sqt.m_trans_y ;
	m_trans_z = sqt.m_trans_z ;
}

206
void SimpleQT::setDock(QDockWidget *dock)
207
{
208
209
210
	m_dock = dock;
	addDockWidget(Qt::RightDockWidgetArea, m_dock);
	m_dock->show();
211
212
}

213
QDockWidget* SimpleQT::dockWidget()
214
{
215
	return m_dock;
216
217
}

218
void SimpleQT::setCallBack( const QObject* sender, const char* signal, const char* method)
Sylvain Thery's avatar
Sylvain Thery committed
219
{
220
	connect(sender, signal, this, method);
Sylvain Thery's avatar
Sylvain Thery committed
221
222
}

223
void SimpleQT::windowTitle(const char* windowTitle)
Sylvain Thery's avatar
Sylvain Thery committed
224
{
225
	setWindowTitle(tr(windowTitle));
Sylvain Thery's avatar
Sylvain Thery committed
226
227
}

228
void SimpleQT::dockTitle(const char* dockTitle)
Sylvain Thery's avatar
Sylvain Thery committed
229
{
230
231
	if (m_dock)
		m_dock->setWindowTitle(tr(dockTitle));
Sylvain Thery's avatar
Sylvain Thery committed
232
233
}

234
void SimpleQT::statusMsg(const char* msg, int timeoutms)
235
{
236
237
238
239
240
241
242
243
244
245
246
247
	if (msg)
	{
		QString message = tr(msg);
		statusBar()->showMessage(message,timeoutms);
	}
	else
	{
		if (statusBar()->isHidden())
			statusBar()->show();
		else
			statusBar()->hide();
	}
248
249
}

Sylvain Thery's avatar
Sylvain Thery committed
250
251
QDockWidget* SimpleQT::addEmptyDock()
{
Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
252
253
254
255
	m_dock = new QDockWidget(tr("Control"), this);
	m_dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
	m_dock->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetClosable);
	addDockWidget(Qt::RightDockWidgetArea, m_dock);
Sylvain Thery's avatar
Sylvain Thery committed
256

Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
257
258
	m_dock->hide();
	return m_dock;
Sylvain Thery's avatar
Sylvain Thery committed
259
260
261
262
263
264
265
266
267
268
}

void SimpleQT::visibilityDock(bool visible)
{
	if (visible)
		m_dock->show();
	else
		m_dock->hide();
}

Sylvain Thery's avatar
Sylvain Thery committed
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
void SimpleQT::visibilityConsole(bool visible)
{
	if (visible)
		m_dockConsole->show();
	else
		m_dockConsole->hide();
}

void SimpleQT::toggleVisibilityDock()
{
	if (m_dock->isHidden())
		m_dock->show();
	else
		m_dock->hide();
}

void SimpleQT::toggleVisibilityConsole()
{
	if (m_dockConsole->isHidden())
		m_dockConsole->show();
	else
		m_dockConsole->hide();
}

293
void SimpleQT::add_menu_entry(const std::string label, const char* method)
Sylvain Thery's avatar
Sylvain Thery committed
294
{
295
296
297
	QAction * action = new QAction(tr(label.c_str()), this);
	connect(action, SIGNAL(triggered()), this, method);
	m_appMenu->addAction(action);
Sylvain Thery's avatar
Sylvain Thery committed
298
299
}

300
void SimpleQT::init_app_menu()
Sylvain Thery's avatar
Sylvain Thery committed
301
{
302
	m_appMenu->clear();
Sylvain Thery's avatar
Sylvain Thery committed
303
304
}

305
void SimpleQT::setHelpMsg(const std::string& msg)
306
{
307
	m_helpString = msg;
308
}
Sylvain Thery's avatar
Sylvain Thery committed
309

310
void SimpleQT::setGLWidgetMouseTracking(bool b)
Sylvain Thery's avatar
Sylvain Thery committed
311
{
312
	m_glWidget->setMouseTracking(b);
Sylvain Thery's avatar
Sylvain Thery committed
313
314
}

315
316
void SimpleQT::closeEvent(QCloseEvent *event)
{
317
	QWidget::closeEvent(event) ;
318
	cb_exit();
319
320
}

Sylvain Thery's avatar
Sylvain Thery committed
321
322
void SimpleQT::keyPressEvent(QKeyEvent *e)
{
Sylvain Thery's avatar
Sylvain Thery committed
323
	if (e->modifiers() & Qt::ShiftModifier)
Sylvain Thery's avatar
Sylvain Thery committed
324
	{
Sylvain Thery's avatar
Sylvain Thery committed
325
326
		if ((e->key() == Qt::Key_Return))
			toggleVisibilityConsole();
Sylvain Thery's avatar
Sylvain Thery committed
327
	}
Sylvain Thery's avatar
Sylvain Thery committed
328
329
330
331
332
333
	else
	{
		if ((e->key() == Qt::Key_Return) && m_dock != NULL)
			toggleVisibilityDock();
	}

Sylvain Thery's avatar
Sylvain Thery committed
334
335
336
337
338
    if (e->key() == Qt::Key_Escape)
    	close();
    else
        QWidget::keyPressEvent(e);

Sylvain Thery's avatar
Sylvain Thery committed
339
    m_glWidget->keyPressEvent(e); // ?
Sylvain Thery's avatar
Sylvain Thery committed
340
341
342
343
}

void SimpleQT::keyReleaseEvent(QKeyEvent *e)
{
344
	QWidget::keyReleaseEvent(e);
Sylvain Thery's avatar
Sylvain Thery committed
345
346
347
    m_glWidget->keyReleaseEvent(e);
}

348
void SimpleQT::glMousePosition(int& x, int& y)
Sylvain Thery's avatar
Sylvain Thery committed
349
{
350
351
352
	QPoint xy = m_glWidget->mapFromGlobal(QCursor::pos());
	x = xy.x();
	y = m_glWidget->getHeight() - xy.y();
Sylvain Thery's avatar
Sylvain Thery committed
353
354
}

355

356
357


358
359
void SimpleQT::synchronize(SimpleQT* sqt)
{
360
361
	m_glWidget->getObjPos() = sqt->m_glWidget->getObjPos() ;

362
363
	m_projection_matrix = sqt->m_projection_matrix;
	m_modelView_matrix = sqt->m_modelView_matrix;
Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
364
	for (unsigned int i = 0; i < 4; ++i)
365
366
367
368
369
370
371
372
373
374
375
376
377
378
	{
		m_curquat[i] = sqt->m_curquat[i];
		m_lastquat[i] = sqt->m_lastquat[i];
	}
	m_trans_x = sqt->trans_x();
	m_trans_y = sqt->trans_y();
	m_trans_z = sqt->trans_z();

	SimpleQT::cb_updateMatrix();

	m_glWidget->modelModified();
	m_glWidget->updateGL();
}

Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
379
void SimpleQT::registerShader(GLSLShader* ptr)
380
{
Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
381
	GLSLShader::registerShader(this, ptr) ;
382
383
}

Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
384
void SimpleQT::unregisterShader(GLSLShader* ptr)
385
{
Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
386
	GLSLShader::unregisterShader(this, ptr) ;
387
388
}

389
void SimpleQT::cb_updateMatrix()
390
{
391
392
393
	glm::mat4 model(m_modelView_matrix);
	model *= m_transfo_matrix;

394
395
396
397
	if (GLSLShader::CURRENT_OGL_VERSION == 1)
	{
		glMatrixMode(GL_PROJECTION);
		glLoadMatrixf(glm::value_ptr(m_projection_matrix));
398

399
		glMatrixMode(GL_MODELVIEW);
400
		glLoadMatrixf(glm::value_ptr(model));
401
402
403
	}
	else
	{
404
405
		for(std::set< std::pair<void*, GLSLShader*> >::iterator it = GLSLShader::m_registeredShaders->begin();
			it != GLSLShader::m_registeredShaders->end();
406
407
408
409
			++it)
		{
			if ((it->first == NULL) || (it->first == this))
			{
410
				it->second->updateMatrices(m_projection_matrix, model);
411
412
413
414
			}
		}
	}
}
415

416
417
418
void SimpleQT::updateGL()
{
	m_glWidget->updateGL();
419
420
}

421
422
423
void SimpleQT::updateGLMatrices()
{
	m_glWidget->modelModified();
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
424
    updateGL();
425
}
426
427
428

void SimpleQT::transfoRotate(float angle, float x, float y, float z)
{
429
	transfoMatrix() = glm::rotate(transfoMatrix(), glm::radians(angle), glm::vec3(x,y,z));
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
}

void SimpleQT::transfoTranslate(float tx, float ty, float tz)
{
	transfoMatrix() = glm::translate(transfoMatrix(), glm::vec3(tx,ty,tz));
}

void SimpleQT::transfoScale(float sx, float sy, float sz)
{
	transfoMatrix() = glm::scale(transfoMatrix(), glm::vec3(sx,sy,sz));
}

void SimpleQT::pushTransfoMatrix()
{
	m_stack_trf.push(transfoMatrix());
}

bool SimpleQT::popTransfoMatrix()
{
	if (m_stack_trf.empty())
		return false;
	transfoMatrix() = m_stack_trf.top();
	m_stack_trf.pop();
	return true;
}

456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
std::string SimpleQT::selectFile(const std::string& title, const std::string& dir, const std::string& filters)
{
    QString fileName = QFileDialog::getOpenFileName(this, tr(title.c_str()), tr(dir.c_str()), tr(filters.c_str()), 0, 0);
    return fileName.toStdString();
}

std::string SimpleQT::selectFileSave(const std::string& title, const std::string& dir, const std::string& filters)
{
    QString fileName = QFileDialog::getSaveFileName(this, tr(title.c_str()), tr(dir.c_str()), tr(filters.c_str()), 0, 0);
    return fileName.toStdString();
}

void SimpleQT::cb_about_cgogn()
{
	QString str("CGoGN:\nCombinatorial and Geometric modeling\n"
				"with Generic N-dimensional Maps\n"
472
				"Web site: http://cgogn.unistra.fr \n"
473
474
475
476
477
478
479
480
				"Contact information: cgogn@unistra.fr");
	QMessageBox::about(this, tr("About CGoGN"), str);
}

void SimpleQT::cb_about()
{
   QMessageBox::about(this, tr("About App"), m_helpString.c_str());
}
481

482
void SimpleQT::snapshot(const QString& filename, const char* format, const int& quality)
Sylvain Thery's avatar
Sylvain Thery committed
483
484
{
	QImage im = m_glWidget->grabFrameBuffer(false);
485
	im.save(filename, format, quality);
Sylvain Thery's avatar
Sylvain Thery committed
486
487
}

488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
void SimpleQT::exportPOV2file(const QString& filename)
{
    std::ofstream out(filename.toStdString().c_str(), std::ios::out) ;
    if (!out.good())
    {
        CGoGNerr << "Unable to open file" << CGoGNendl ;
    }

    out << m_glWidget->getObjPos().x << std::endl ;
    out << m_glWidget->getObjPos().y << std::endl ;
    out << m_glWidget->getObjPos().z << std::endl ;

    for (unsigned int i = 0 ; i < 4 ; ++i)
        for (unsigned int j = 0 ; j < 4 ; ++j)
            out << m_projection_matrix[i][j] << std::endl ;

    for (unsigned int i = 0 ; i < 4 ; ++i)
        for (unsigned int j = 0 ; j < 4 ; ++j)
            out << m_modelView_matrix[i][j] << std::endl ;

    for (unsigned int i = 0; i < 4; ++i)
    {
        out << m_curquat[i] << std::endl ;
        out << m_lastquat[i] << std::endl ;
    }

    out << m_trans_x << std::endl ;
    out << m_trans_y << std::endl ;
    out << m_trans_z << std::endl ;

    QRect geom = this->geometry() ;
    out << geom.width() << std::endl ;
    out << geom.height() << std::endl ;
}

void SimpleQT::importFile2POV(const QString& filename)
{
    std::ifstream in(filename.toStdString().c_str(), std::ios::in) ;
    if (!in.good())
    {
        CGoGNerr << "Unable to open file" << CGoGNendl ;
    }

    in >> m_glWidget->getObjPos().x ;
    in >> m_glWidget->getObjPos().y ;
    in >> m_glWidget->getObjPos().z ;

    for (unsigned int i = 0 ; i < 4 ; ++i)
        for (unsigned int j = 0 ; j < 4 ; ++j)
            in >> m_projection_matrix[i][j] ;

    for (unsigned int i = 0 ; i < 4 ; ++i)
        for (unsigned int j = 0 ; j < 4 ; ++j)
            in >> m_modelView_matrix[i][j] ;

    for (unsigned int i = 0; i < 4; ++i)
    {
        in >> m_curquat[i] ;
        in >> m_lastquat[i] ;
    }

    in >> m_trans_x ;
    in >> m_trans_y ;
    in >> m_trans_z ;

    unsigned int width, height ;
    in >> width ;
    in >> height ;

    this->resize(width, height) ;

    SimpleQT::cb_updateMatrix() ;
    m_glWidget->modelModified() ;
    updateGL() ;
}


565
566
567
568
569
570
void SimpleQT::setGeometry(int x, int y, int w, int h)
{
	move(x,y);
	resize(w,h);
}

Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
571
} // namespace QT
Sylvain Thery's avatar
Sylvain Thery committed
572

Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
573
} // namespace Utils
Sylvain Thery's avatar
Sylvain Thery committed
574

Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
575
} // namespace CGoGN