Commit 3524a931 authored by Kenneth Vanhoey's avatar Kenneth Vanhoey

some connections added : exit_cb called from QCloseEvent

parent fd8ceea1
......@@ -55,6 +55,7 @@ class SimpleQT : public QMainWindow
public:
SimpleQT();
SimpleQT(const SimpleQT&) ;
virtual ~SimpleQT();
......@@ -165,12 +166,15 @@ protected:
std::stack<glm::mat4> m_stack_trf;
void closeEvent(QCloseEvent *event);
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *e);
public:
void operator=(const SimpleQT& v) ;
/**
* set width and pos center of object to draw
*/
......@@ -314,7 +318,7 @@ public:
/**
* end of program, some things to clean ?
*/
virtual void cb_exit() {}
virtual void cb_exit() { }
/**
* Ask to Qt to update the GL widget.
......
......@@ -122,6 +122,8 @@ public:
void mouseMoveEvent(QMouseEvent* event);
void closeEvent(QCloseEvent *event);
void keyPressEvent(QKeyEvent* event);
void keyReleaseEvent(QKeyEvent* event);
......
......@@ -104,11 +104,54 @@ m_dock(NULL)
m_transfo_matrix = glm::mat4(1.0f);
}
SimpleQT::SimpleQT(const SimpleQT& sqt)
{
m_glWidget = new GLWidget(this);
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 ;
}
SimpleQT::~SimpleQT()
{
delete m_glWidget; // ??
}
void SimpleQT::operator=(const SimpleQT& sqt) {
m_glWidget = new GLWidget(this);
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 ;
}
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);
......@@ -222,6 +265,11 @@ void SimpleQT::setCallBack( const QObject* sender, const char* signal, const cha
connect(sender, signal, this, method);
}
void SimpleQT::closeEvent(QCloseEvent *event) {
m_glWidget->closeEvent(event) ;
QWidget::closeEvent(event) ;
}
void SimpleQT::keyPressEvent(QKeyEvent *e)
{
if (e->modifiers() & Qt::ShiftModifier)
......
......@@ -308,6 +308,12 @@ void GLWidget::wheelEvent(QWheelEvent* event)
m_cbs->cb_wheelEvent(event->delta(), event->x(), getHeight() - event->y());
}
void GLWidget::closeEvent(QCloseEvent *event)
{
if (m_cbs)
m_cbs->cb_exit() ;
}
void GLWidget::keyPressEvent(QKeyEvent* event)
{
if (event->key() == Qt::Key_Escape)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment