Commit fd921d0d authored by Jan Möbius's avatar Jan Möbius
Browse files

Dennis: MultiView

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@4671 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 0bda2ce6
...@@ -269,10 +269,8 @@ QPoint mapToLocal( const QPoint _point ) { ...@@ -269,10 +269,8 @@ QPoint mapToLocal( const QPoint _point ) {
* They can be combined. * They can be combined.
*/ */
void setDrawMode( const unsigned int _mode ) { void setDrawMode( const unsigned int _mode ) {
for ( uint i = 0 ; i < examiner_widgets_.size() ; ++i ) { examiner_widgets_[activeExaminer_]->drawMode(_mode);
examiner_widgets_[i]->drawMode(_mode); examiner_widgets_[activeExaminer_]->updateGL();
examiner_widgets_[i]->updateGL();
}
} }
/** Get the current draw Mode of the examiner widget.\n /** Get the current draw Mode of the examiner widget.\n
...@@ -281,8 +279,7 @@ void setDrawMode( const unsigned int _mode ) { ...@@ -281,8 +279,7 @@ void setDrawMode( const unsigned int _mode ) {
* They can be combined. * They can be combined.
*/ */
unsigned int drawMode( ) { unsigned int drawMode( ) {
// No seperate draw modes available all should have the same so take first return examiner_widgets_[activeExaminer_]->drawMode();
return examiner_widgets_[0]->drawMode();
} }
bool scenegraph_pick( ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, unsigned int &_nodeIdx, unsigned int &_targetIdx, ACG::Vec3d *_hitPointPtr=0 ) { bool scenegraph_pick( ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, unsigned int &_nodeIdx, unsigned int &_targetIdx, ACG::Vec3d *_hitPointPtr=0 ) {
......
<?xml version = '1.0' encoding = 'UTF-8'?> <?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE KDevPrjSession> <!DOCTYPE KDevPrjSession>
<KDevPrjSession> <KDevPrjSession>
<DocsAndViews NumberOfDocuments="14" > <DocsAndViews NumberOfDocuments="3" >
<Doc0 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/OpenFlipper/Core/ParseIni.cc" > <Doc0 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/ObjectTypes/MeshObject/MeshObjectT.cc" >
<View0 Encoding="" line="548" Type="Source" /> <View0 Encoding="" line="489" Type="Source" />
</Doc0> </Doc0>
<Doc1 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/OpenFlipper/Core/openFunctions.cc" > <Doc1 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/ObjectTypes/MeshObject/MeshObjectT.hh" >
<View0 Encoding="" line="266" Type="Source" /> <View0 Encoding="" line="294" Type="Source" />
</Doc1> </Doc1>
<Doc2 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/Plugin-FilePolyLine/FilePolyLine.hh" > <Doc2 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/Plugin-TextureControl/TextureControl.cc" >
<View0 Encoding="" line="51" Type="Source" /> <View0 Encoding="" line="128" Type="Source" />
</Doc2> </Doc2>
<Doc3 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/OpenFlipper/Core/Core.cc" >
<View0 Encoding="" line="550" Type="Source" />
</Doc3>
<Doc4 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/OpenFlipper/BasePlugin/PluginFunctions.cc" >
<View0 Encoding="" line="258" Type="Source" />
</Doc4>
<Doc5 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/OpenFlipper/widgets/glWidget/QtBaseViewer.cc" >
<View0 Encoding="" line="1033" Type="Source" />
</Doc5>
<Doc6 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/OpenFlipper/widgets/glWidget/QtBaseViewerPicking.cc" >
<View0 Encoding="" line="65" Type="Source" />
</Doc6>
<Doc7 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/ACG/Scenegraph/TranslationManipulatorNode.cc" >
<View0 Encoding="" line="572" Type="Source" />
</Doc7>
<Doc8 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/Plugin-Move/MovePlugin.cc" >
<View0 Encoding="" line="71" Type="Source" />
</Doc8>
<Doc9 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/ACG/QtWidgets/QtBaseViewerPicking.cc" >
<View0 Encoding="" line="78" Type="Source" />
</Doc9>
<Doc10 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/Plugin-Scissor/QtPlaneSelect.cc" >
<View0 Encoding="" line="130" Type="Source" />
</Doc10>
<Doc11 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/ACG/Scenegraph/ManipulatorNode.cc" >
<View0 Encoding="" line="394" Type="Source" />
</Doc11>
<Doc12 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/ACG/QtWidgets/QtLasso.cc" >
<View0 Encoding="" line="391" Type="Source" />
</Doc12>
<Doc13 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/ACG/Scenegraph/TrackballNode.cc" >
<View0 Encoding="" line="261" Type="Source" />
</Doc13>
</DocsAndViews> </DocsAndViews>
<pluginList> <pluginList>
<kdevdebugger> <kdevdebugger>
......
...@@ -54,6 +54,7 @@ void CoreWidget::slotCustomContextMenu( const QPoint& _point ) { ...@@ -54,6 +54,7 @@ void CoreWidget::slotCustomContextMenu( const QPoint& _point ) {
QObject* senderPointer = sender(); QObject* senderPointer = sender();
unsigned int examinerId = 0; unsigned int examinerId = 0;
QPoint popupPosition; QPoint popupPosition;
QPoint scenePos;
if ( senderPointer == 0 ) { if ( senderPointer == 0 ) {
std::cerr << "Error : slotCustomContextMenu directly called! This should only be called by an examiner" << std::endl; std::cerr << "Error : slotCustomContextMenu directly called! This should only be called by an examiner" << std::endl;
...@@ -61,6 +62,8 @@ void CoreWidget::slotCustomContextMenu( const QPoint& _point ) { ...@@ -61,6 +62,8 @@ void CoreWidget::slotCustomContextMenu( const QPoint& _point ) {
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets(); ++i ) { for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets(); ++i ) {
if ( senderPointer == examiner_widgets_[i] ) { if ( senderPointer == examiner_widgets_[i] ) {
popupPosition = examiner_widgets_[i]->glMapToGlobal(_point); popupPosition = examiner_widgets_[i]->glMapToGlobal(_point);
QPointF f = examiner_widgets_[i]->mapToScene(QPointF(_point.x(), _point.y()));
scenePos = QPoint (f.x(), f.y());
examinerId = i; examinerId = i;
break; break;
} }
...@@ -70,7 +73,7 @@ void CoreWidget::slotCustomContextMenu( const QPoint& _point ) { ...@@ -70,7 +73,7 @@ void CoreWidget::slotCustomContextMenu( const QPoint& _point ) {
PluginFunctions::setActiveExaminer( examinerId ); PluginFunctions::setActiveExaminer( examinerId );
updatePopupMenu(_point,examinerId); updatePopupMenu(scenePos,examinerId);
// If not initialized, dont show it!! // If not initialized, dont show it!!
if ( !contextMenu_->isEmpty () ) if ( !contextMenu_->isEmpty () )
...@@ -288,16 +291,16 @@ void CoreWidget::updatePopupMenu(const QPoint& _point, unsigned int _examinerId) ...@@ -288,16 +291,16 @@ void CoreWidget::updatePopupMenu(const QPoint& _point, unsigned int _examinerId)
contextMenu_->addMenu(functionMenu_ ); contextMenu_->addMenu(functionMenu_ );
if ( ( examiner_widgets_[0]->getDrawMenu() != NULL ) && OpenFlipper::Options::drawModesInContextMenu() ) { if ( ( examiner_widgets_[_examinerId]->getDrawMenu() != NULL ) && OpenFlipper::Options::drawModesInContextMenu() ) {
examiner_widgets_[0]->getDrawMenu()->setTitle("&DrawModes"); examiner_widgets_[_examinerId]->getDrawMenu()->setTitle("&DrawModes");
QAction* drawMenuAction = contextMenu_->addMenu(examiner_widgets_[0]->getDrawMenu() ); QAction* drawMenuAction = contextMenu_->addMenu(examiner_widgets_[_examinerId]->getDrawMenu() );
QIcon icon; QIcon icon;
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"drawModes.png"); icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"drawModes.png");
drawMenuAction->setIcon(icon); drawMenuAction->setIcon(icon);
examiner_widgets_[0]->getDrawMenu()->setTearOffEnabled(true); examiner_widgets_[_examinerId]->getDrawMenu()->setTearOffEnabled(true);
} }
} }
......
...@@ -123,7 +123,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -123,7 +123,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
glView_->setViewportUpdateMode(QGraphicsView::FullViewportUpdate); glView_->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
glView_->setScene(glScene_); glView_->setScene(glScene_);
baseLayout_ = new QGraphicsGridLayout; baseLayout_ = new QtMultiViewLayout;
baseLayout_->setContentsMargins(0,0,0,0); baseLayout_->setContentsMargins(0,0,0,0);
centerWidget_ = new QGraphicsWidget; centerWidget_ = new QGraphicsWidget;
glScene_->addItem(centerWidget_); glScene_->addItem(centerWidget_);
...@@ -169,8 +169,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -169,8 +169,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
examinerWidget->sceneGraph( PluginFunctions::getSceneGraphRootNode() ); examinerWidget->sceneGraph( PluginFunctions::getSceneGraphRootNode() );
glScene_->addItem(examinerWidget); baseLayout_->addItem(examinerWidget, 0);
baseLayout_->addItem(examinerWidget, 0, 0);
} else { } else {
...@@ -183,7 +182,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -183,7 +182,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
"Examiner Widget", "Examiner Widget",
statusBar_ ); statusBar_ );
examiner_widgets_.push_back(newWidget); examiner_widgets_.push_back(newWidget);
glScene_->addItem(newWidget);
} }
// Initialize all examiners // Initialize all examiners
...@@ -191,14 +189,10 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -191,14 +189,10 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
examiner_widgets_[i]->sceneGraph( PluginFunctions::getSceneGraphRootNode() ); examiner_widgets_[i]->sceneGraph( PluginFunctions::getSceneGraphRootNode() );
} }
baseLayout_->addItem(examiner_widgets_[0],0,0); baseLayout_->addItem(examiner_widgets_[0],0);
baseLayout_->addItem(examiner_widgets_[1],0,1); baseLayout_->addItem(examiner_widgets_[1],1);
baseLayout_->addItem(examiner_widgets_[2],1,0); baseLayout_->addItem(examiner_widgets_[2],2);
baseLayout_->addItem(examiner_widgets_[3],1,1); baseLayout_->addItem(examiner_widgets_[3],3);
for ( unsigned int i = 1 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
examiner_widgets_[i]->hide();
} }
// Make examiner available to the plugins ( defined in PluginFunctions.hh) // Make examiner available to the plugins ( defined in PluginFunctions.hh)
......
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
#include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh> #include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh>
#include <OpenFlipper/widgets/glWidget/QtGLGraphicsScene.hh> #include <OpenFlipper/widgets/glWidget/QtGLGraphicsScene.hh>
#include <OpenFlipper/widgets/glWidget/QtGLGraphicsView.hh> #include <OpenFlipper/widgets/glWidget/QtGLGraphicsView.hh>
#include <OpenFlipper/widgets/glWidget/QtMultiViewLayout.hh>
// QT INCLUDES // QT INCLUDES
#include <QMainWindow> #include <QMainWindow>
...@@ -403,7 +404,7 @@ public: ...@@ -403,7 +404,7 @@ public:
QGraphicsWidget* centerWidget_; QGraphicsWidget* centerWidget_;
/// Base layout that holds gl views /// Base layout that holds gl views
QGraphicsGridLayout* baseLayout_; QtMultiViewLayout* baseLayout_;
// widget showing the scenegraph // widget showing the scenegraph
......
...@@ -553,19 +553,19 @@ void CoreWidget::coreKeyPressEvent (QKeyEvent* _e){ ...@@ -553,19 +553,19 @@ void CoreWidget::coreKeyPressEvent (QKeyEvent* _e){
case Qt::Key_Space: case Qt::Key_Space:
if ( OpenFlipper::Options::multiView() ) { if ( OpenFlipper::Options::multiView() ) {
emit log( "Switch to MultiView"); emit log( "Switch MultiView mode");
switch (baseLayout_->mode())
if ( !examiner_widgets_[1]->isVisible() ) { {
case QtMultiViewLayout::SingleView:
for ( uint i = 1 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) baseLayout_->setMode (QtMultiViewLayout::Grid);
examiner_widgets_[i]->show(); break;
case QtMultiViewLayout::Grid:
} else { baseLayout_->setMode (QtMultiViewLayout::HSplit);
break;
for ( uint i = 1 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) case QtMultiViewLayout::HSplit:
examiner_widgets_[i]->hide(); baseLayout_->setMode (QtMultiViewLayout::SingleView);
break;
} }
} }
break; break;
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include "QtBaseViewer.hh" #include "QtBaseViewer.hh"
#include "QtGLGraphicsScene.hh" #include "QtGLGraphicsScene.hh"
#include "QtGLGraphicsView.hh" #include "QtGLGraphicsView.hh"
#include "QtGLViewerLayout.hh"
#include <ACG/QtWidgets/QtWheel.hh> #include <ACG/QtWidgets/QtWheel.hh>
#include <ACG/Scenegraph/DrawModes.hh> #include <ACG/Scenegraph/DrawModes.hh>
#include <ACG/GL/gl.hh> #include <ACG/GL/gl.hh>
...@@ -238,9 +239,12 @@ void glViewer::swapBuffers() { ...@@ -238,9 +239,12 @@ void glViewer::swapBuffers() {
void glViewer::sceneGraph(ACG::SceneGraph::BaseNode* _root) void glViewer::sceneGraph(ACG::SceneGraph::BaseNode* _root)
{ {
if (sceneGraphRoot_ == _root)
return;
sceneGraphRoot_ = _root; sceneGraphRoot_ = _root;
if (sceneGraphRoot_) if (sceneGraphRoot_ )
{ {
// get draw modes // get draw modes
ACG::SceneGraph::CollectDrawModesAction action; ACG::SceneGraph::CollectDrawModesAction action;
...@@ -330,7 +334,13 @@ void glViewer::updateProjectionMatrix() ...@@ -330,7 +334,13 @@ void glViewer::updateProjectionMatrix()
{ {
case ORTHOGRAPHIC_PROJECTION: case ORTHOGRAPHIC_PROJECTION:
{ {
double aspect = (double) glWidth() / (double) glHeight(); double aspect;
if (isVisible())
aspect = (double) glWidth() / (double) glHeight();
else
aspect = 1.0;
glstate_->ortho( -orthoWidth_, orthoWidth_, glstate_->ortho( -orthoWidth_, orthoWidth_,
-orthoWidth_/aspect, orthoWidth_/aspect, -orthoWidth_/aspect, orthoWidth_/aspect,
near_, far_ ); near_, far_ );
...@@ -457,12 +467,12 @@ void glViewer::normalsMode(NormalsMode _mode) ...@@ -457,12 +467,12 @@ void glViewer::normalsMode(NormalsMode _mode)
void void
glViewer::copyToImage( QImage& _image, glViewer::copyToImage( QImage& _image,
unsigned int /* _l */ , unsigned int /* _t */ , unsigned int _l, unsigned int _t,
unsigned int /* _w */ , unsigned int /* _h */ , unsigned int _w, unsigned int _h,
GLenum /* _buffer */ ) GLenum /* _buffer */ )
{ {
makeCurrent(); makeCurrent();
_image = glWidget_->grabFrameBuffer(true); _image = glWidget_->grabFrameBuffer(true).copy (_l, _t, _w, _h).convertToFormat (QImage::Format_RGB32);
} }
...@@ -939,10 +949,6 @@ void glViewer::paintGL() ...@@ -939,10 +949,6 @@ void glViewer::paintGL()
static bool initialized = false; static bool initialized = false;
if (!initialized) if (!initialized)
{ {
// we use GLEW to manage extensions
// initialize it first
glewInit();
// lock update // lock update
properties_.lockUpdate(); properties_.lockUpdate();
...@@ -1049,15 +1055,6 @@ void glViewer::moveEvent (QGraphicsSceneMoveEvent *) ...@@ -1049,15 +1055,6 @@ void glViewer::moveEvent (QGraphicsSceneMoveEvent *)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void glViewer::paint(QPainter * _painter, const QStyleOptionGraphicsItem *, QWidget *)
{
if (_painter->paintEngine()->type() != QPaintEngine::OpenGL) {
std::cerr << "glViewer: paint needs a QGLWidget to be set as viewport on the graphics view\n";
return;
}
paintGL ();
}
void glViewer::encodeView(QString& _view) void glViewer::encodeView(QString& _view)
{ {
const ACG::GLMatrixd m = glstate_->modelview(); const ACG::GLMatrixd m = glstate_->modelview();
...@@ -1248,19 +1245,10 @@ glViewer::createWidgets(QStatusBar* _sb) ...@@ -1248,19 +1245,10 @@ glViewer::createWidgets(QStatusBar* _sb)
wheelY->setCacheMode(QGraphicsItem::DeviceCoordinateCache); wheelY->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
wheelZ->setCacheMode(QGraphicsItem::DeviceCoordinateCache); wheelZ->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
glBaseLayout_ = new QGraphicsGridLayout; glBaseLayout_ = new QtGLViewerLayout;
glBaseLayout_->addItem(wheelX, 1, 0); glBaseLayout_->addWheelX(wheelX);
glBaseLayout_->addItem(wheelY, 2, 1); glBaseLayout_->addWheelY(wheelY);
glBaseLayout_->addItem(wheelZ, 1, 3); glBaseLayout_->addWheelZ(wheelZ);
glBaseLayout_->setColumnStretchFactor(0,0);
glBaseLayout_->setColumnStretchFactor(1,0);
glBaseLayout_->setColumnStretchFactor(2,1);
glBaseLayout_->setColumnStretchFactor(3,0);
glBaseLayout_->setRowStretchFactor(0,1);
glBaseLayout_->setRowStretchFactor(1,0);
glBaseLayout_->setRowStretchFactor(2,0);
setLayout(glBaseLayout_); setLayout(glBaseLayout_);
} }
...@@ -1700,6 +1688,9 @@ void glViewer::actionPickMenu( QAction * _action ) ...@@ -1700,6 +1688,9 @@ void glViewer::actionPickMenu( QAction * _action )
void void
glViewer::viewMouseEvent(QMouseEvent* _event) glViewer::viewMouseEvent(QMouseEvent* _event)
{ {
QPointF f (mapFromScene(QPointF(_event->pos().x(), _event->pos().y())));
QPoint pos (f.x(), f.y());
switch (_event->type()) switch (_event->type())
{ {
case QEvent::MouseButtonPress: case QEvent::MouseButtonPress:
...@@ -1708,14 +1699,14 @@ glViewer::viewMouseEvent(QMouseEvent* _event) ...@@ -1708,14 +1699,14 @@ glViewer::viewMouseEvent(QMouseEvent* _event)
if (_event->modifiers() & Qt::ShiftModifier) if (_event->modifiers() & Qt::ShiftModifier)
{ {
ACG::Vec3d c; ACG::Vec3d c;
if (fast_pick(_event->pos(), c)) if (fast_pick(pos, c))
{ {
trackball_center_ = c; trackball_center_ = c;
trackball_radius_ = std::max(scene_radius_, (c-glstate_->eye()).norm()*0.9f); trackball_radius_ = std::max(scene_radius_, (c-glstate_->eye()).norm()*0.9f);
} }
} }
lastPoint_hitSphere_ = mapToSphere( lastPoint2D_=_event->pos(), lastPoint_hitSphere_ = mapToSphere( lastPoint2D_= pos,
lastPoint3D_ ); lastPoint3D_ );
isRotating_ = true; isRotating_ = true;
timer_->stop(); timer_->stop();
...@@ -1743,7 +1734,7 @@ glViewer::viewMouseEvent(QMouseEvent* _event) ...@@ -1743,7 +1734,7 @@ glViewer::viewMouseEvent(QMouseEvent* _event)
// mouse button should be pressed // mouse button should be pressed
if (_event->buttons() & (Qt::LeftButton | Qt::MidButton)) if (_event->buttons() & (Qt::LeftButton | Qt::MidButton))
{ {
QPoint newPoint2D = _event->pos(); QPoint newPoint2D = pos;
if ( (newPoint2D.x()<0) || (newPoint2D.x() > (int)glWidth()) || if ( (newPoint2D.x()<0) || (newPoint2D.x() > (int)glWidth()) ||
(newPoint2D.y()<0) || (newPoint2D.y() > (int)glHeight()) ) (newPoint2D.y()<0) || (newPoint2D.y() > (int)glHeight()) )
...@@ -1853,11 +1844,14 @@ glViewer::viewMouseEvent(QMouseEvent* _event) ...@@ -1853,11 +1844,14 @@ glViewer::viewMouseEvent(QMouseEvent* _event)
void void
glViewer::lightMouseEvent(QMouseEvent* _event) glViewer::lightMouseEvent(QMouseEvent* _event)
{ {
QPointF f (mapFromScene(QPointF(_event->pos().x(), _event->pos().y())));
QPoint pos (f.x(), f.y());
switch (_event->type()) switch (_event->type())
{ {
case QEvent::MouseButtonPress: case QEvent::MouseButtonPress:
{ {
lastPoint_hitSphere_ = mapToSphere( lastPoint2D_=_event->pos(), lastPoint_hitSphere_ = mapToSphere( lastPoint2D_= pos,
lastPoint3D_ ); lastPoint3D_ );
isRotating_ = true; isRotating_ = true;
timer_->stop(); timer_->stop();
...@@ -1870,7 +1864,7 @@ glViewer::lightMouseEvent(QMouseEvent* _event) ...@@ -1870,7 +1864,7 @@ glViewer::lightMouseEvent(QMouseEvent* _event)
// rotate lights // rotate lights
if (_event->buttons() & Qt::LeftButton) if (_event->buttons() & Qt::LeftButton)
{ {
QPoint newPoint2D = _event->pos(); QPoint newPoint2D = pos;
if ( (newPoint2D.x()<0) || (newPoint2D.x() > (int)glWidth()) || if ( (newPoint2D.x()<0) || (newPoint2D.x() > (int)glWidth()) ||
(newPoint2D.y()<0) || (newPoint2D.y() > (int)glHeight()) ) (newPoint2D.y()<0) || (newPoint2D.y() > (int)glHeight()) )
...@@ -1977,18 +1971,17 @@ bool glViewer::mapToSphere(const QPoint& _v2D, ACG::Vec3d& _v3D) const ...@@ -1977,18 +1971,17 @@ bool glViewer::mapToSphere(const QPoint& _v2D, ACG::Vec3d& _v3D) const
void glViewer::slotAnimation() void glViewer::slotAnimation()
{ {
static int msecs=0, count=0; static int msecs=0, count=0;
QTime t;
t.start();
makeCurrent(); makeCurrent();
rotate( lastRotationAxis_, lastRotationAngle_ ); rotate( lastRotationAxis_, lastRotationAngle_ );
updateGL(); updateGL();
if (!properties_.updateLocked()) { if (!properties_.updateLocked()) {
msecs += t.elapsed(); msecs += frame_time_;
if (count==10) { if (count >= 10 && msecs >= 500) {
assert(statusbar_!=0); assert(statusbar_!=0);
char s[100]; char s[100];
sprintf( s, "%.3f fps", (10000.0 / (float)msecs) ); sprintf( s, "%.3f fps", (1000.0 * count / (float)msecs) );
statusbar_->showMessage(s,2000); statusbar_->showMessage(s,2000);
count = msecs = 0; count = msecs = 0;
} }
...@@ -2025,6 +2018,7 @@ void glViewer::snapshot() ...@@ -2025,6 +2018,7 @@ void glViewer::snapshot()
qApp->processEvents(); qApp->processEvents();
makeCurrent(); makeCurrent();
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
paintGL(); paintGL();
glFinish(); glFinish();
......
...@@ -83,7 +83,6 @@ class QSplitter; ...@@ -83,7 +83,6 @@ class QSplitter;
class QTimer; class QTimer;
class QImage; class QImage;
class QSocketNotifier; class QSocketNotifier;
class QGraphicsGridLayout;
//== NAMESPACES =============================================================== //== NAMESPACES ===============================================================
...@@ -97,6 +96,7 @@ namespace ACG { ...@@ -97,6 +96,7 @@ namespace ACG {
} }
class QtGLGraphicsScene; class QtGLGraphicsScene;
class QtGLGraphicsView; class QtGLGraphicsView;
class QtGLViewerLayout;
class QtShiftPopupMenu; class QtShiftPopupMenu;
...@@ -408,8 +408,6 @@ protected: ...@@ -408,8 +408,6 @@ protected:
virtual void resizeEvent(QGraphicsSceneResizeEvent * _e); virtual void resizeEvent(QGraphicsSceneResizeEvent * _e);
/// handle move events