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

Merge branch 'unstable' into 'master'

sync with Unstable

See merge request !64
parents 9b30bc3b de30cd77
...@@ -65,11 +65,11 @@ ...@@ -65,11 +65,11 @@
#ifndef PLUGINFUNCTIONS_HH #ifndef PLUGINFUNCTIONS_HH
#define PLUGINFUNCTIONS_HH #define PLUGINFUNCTIONS_HH
#include <OpenFlipper/common/Types.hh>
#include <QPair> #include <QPair>
#include <QFileDialog> #include <QFileDialog>
#include <OpenFlipper/common/Types.hh>
#include <OpenFlipper/common/OFGLWidget.hh> #include <OpenFlipper/common/OFGLWidget.hh>
#include <ACG/Scenegraph/SceneGraph.hh> #include <ACG/Scenegraph/SceneGraph.hh>
......
...@@ -54,8 +54,9 @@ ...@@ -54,8 +54,9 @@
#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 4)) #if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 4))
#include <QOpenGLWidget> //only forward declaration
#include <QSurfaceFormat> class QOpenGLWidget;
class QSurfaceFormat;
typedef QOpenGLWidget OFGLWidget; typedef QOpenGLWidget OFGLWidget;
typedef QSurfaceFormat OFGLFormat; typedef QSurfaceFormat OFGLFormat;
......
...@@ -55,8 +55,9 @@ ...@@ -55,8 +55,9 @@
//============================================================================= //=============================================================================
//== INCLUDES ================================================================= //== INCLUDES =================================================================
#include "GLState.hh"
#include <ACG/GL/acg_glew.hh> #include <ACG/GL/acg_glew.hh>
#include "GLState.hh"
#include <OpenMesh/Core/Utils/vector_cast.hh> #include <OpenMesh/Core/Utils/vector_cast.hh>
#include <cstring> #include <cstring>
......
...@@ -62,12 +62,10 @@ ...@@ -62,12 +62,10 @@
#include <cstdlib> #include <cstdlib>
#include <sstream> #include <sstream>
//with the QT_NO_OPENGL define set, Qt will hopefully not undef //avoid inclusion clashes. Bad inclusion order or mixing
//our opengl function macros. if some inclusion clash //QtOpenGL and plain opengl functions in a single cc will cause an error
//occurs this will cause a compile error (intended) //#define QT_NO_OPENGL
//if you want to use opengl calls, use separate compilation units //#pragma message("defined no opengl")
//for Qt and opengl stuff, or make sure this header is included last.
#define QT_NO_OPENGL
#if defined(ARCH_DARWIN) #if defined(ARCH_DARWIN)
......
...@@ -46,14 +46,15 @@ ...@@ -46,14 +46,15 @@
* $Date$ * * $Date$ *
* * * *
\*===========================================================================*/ \*===========================================================================*/
#include "globjects.hh"
#include <QImage>
#include <QGLWidget>
#include <ACG/GL/acg_glew.hh> #include <ACG/GL/acg_glew.hh>
#include <ACG/GL/globjects.hh>
#include <ACG/GL/GLFormatInfo.hh> #include <ACG/GL/GLFormatInfo.hh>
#include <ACG/ShaderUtils/GLSLShader.hh> #include <ACG/ShaderUtils/GLSLShader.hh>
#include <ACG/Utils/ImageConversion.hh>
#include <QImage>
#include <QGLWidget>
namespace ACG { namespace ACG {
...@@ -640,7 +641,7 @@ bool Texture2D::loadFromFile( const std::string& _filename, GLenum _minFilter, G ...@@ -640,7 +641,7 @@ bool Texture2D::loadFromFile( const std::string& _filename, GLenum _minFilter, G
if (mipmaps) if (mipmaps)
autogenerateMipMaps(); autogenerateMipMaps();
QImage gltex = QGLWidget::convertToGLFormat ( qtex ); QImage gltex = ACG::Util::convertToGLFormat(gltex);
setData(0, GL_RGBA, gltex.width(), gltex.height(), GL_RGBA, GL_UNSIGNED_BYTE, gltex.bits()); setData(0, GL_RGBA, gltex.width(), gltex.height(), GL_RGBA, GL_UNSIGNED_BYTE, gltex.bits());
} }
......
...@@ -58,14 +58,14 @@ ...@@ -58,14 +58,14 @@
//== INCLUDES ================================================================= //== INCLUDES =================================================================
#include "QtBaseViewer.hh"
#include <ACG/GL/acg_glew.hh> #include <ACG/GL/acg_glew.hh>
#include "QtBaseViewer.hh"
#include "QtGLGraphicsScene.hh" #include "QtGLGraphicsScene.hh"
#include "QtGLGraphicsView.hh" #include "QtGLGraphicsView.hh"
#include "QtSceneGraphWidget.hh" #include "QtSceneGraphWidget.hh"
#include "QtWheel.hh" #include "QtWheel.hh"
#include "../Scenegraph/SceneGraph.hh"
#include <QMimeData> #include <QMimeData>
#include <QToolButton> #include <QToolButton>
...@@ -161,7 +161,7 @@ QtBaseViewer::QtBaseViewer( QWidget* _parent, ...@@ -161,7 +161,7 @@ QtBaseViewer::QtBaseViewer( QWidget* _parent,
{ {
// check for OpenGL support // check for OpenGL support
if ( !QGLFormat::hasOpenGL() ) if ( !hasOpenGL() )
{ {
std::cerr << "This system has no OpenGL support.\n"; std::cerr << "This system has no OpenGL support.\n";
exit(1); exit(1);
...@@ -346,7 +346,11 @@ void QtBaseViewer::setStatusBar(QStatusBar* _sb) ...@@ -346,7 +346,11 @@ void QtBaseViewer::setStatusBar(QStatusBar* _sb)
} }
} }
void QtBaseViewer::backgroundColor(const Vec4f& _color){
glstate_->set_clear_color(_color); updateGL();
}
/// get background color
Vec4f QtBaseViewer::backgroundColor(){ return glstate_->clear_color(); }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -375,18 +379,6 @@ void QtBaseViewer::applyOptions(int _options) ...@@ -375,18 +379,6 @@ void QtBaseViewer::applyOptions(int _options)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void QtBaseViewer::makeCurrent() {
glWidget_->makeCurrent();
}
void QtBaseViewer::swapBuffers() {
glWidget_->swapBuffers();
}
//-----------------------------------------------------------------------------
void QtBaseViewer::sceneGraph(SceneGraph::BaseNode* _root) void QtBaseViewer::sceneGraph(SceneGraph::BaseNode* _root)
{ {
sceneGraphRoot_ = _root; sceneGraphRoot_ = _root;
...@@ -784,20 +776,6 @@ void QtBaseViewer::normalsMode(NormalsMode _mode) ...@@ -784,20 +776,6 @@ void QtBaseViewer::normalsMode(NormalsMode _mode)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void
QtBaseViewer::copyToImage( QImage& _image,
unsigned int /* _l */ , unsigned int /* _t */ ,
unsigned int /* _w */ , unsigned int /* _h */ ,
GLenum /* _buffer */ )
{
makeCurrent();
_image = glWidget_->grabFrameBuffer(true);
}
//-----------------------------------------------------------------------------
void QtBaseViewer::drawNow() void QtBaseViewer::drawNow()
{ {
makeCurrent(); makeCurrent();
...@@ -1603,315 +1581,6 @@ void QtBaseViewer::actionTwoSidedLighting(bool _enable) ...@@ -1603,315 +1581,6 @@ void QtBaseViewer::actionTwoSidedLighting(bool _enable)
twoSidedLighting(_enable); twoSidedLighting(_enable);
} }
//-----------------------------------------------------------------------------
void
QtBaseViewer::createWidgets(const QGLFormat* _format,
QStatusBar* _sb,
const QtBaseViewer* _share)
{
statusbar_=privateStatusBar_=0;
setStatusBar(_sb);
drawMenu_=0;
funcMenu_=0;
pickMenu_=0;
// contains splitter and eventually status bar
// QT3: Q3VBoxLayout* layout=new Q3VBoxLayout(this,0,0,"toplevel layout");
QVBoxLayout* layout=new QVBoxLayout(this);
layout->setSpacing( 0 );
layout->setMargin( 0 );
// contains glarea and buttons
// QT3: Q3Frame* work=new Q3Frame(this,"box-glarea-buttons");
QFrame* work=new QFrame(this);
layout->addWidget(work,1); // gets all stretch
// private status bar
assert(statusbar_!=0);
if (privateStatusBar_!=0)
layout->addWidget(privateStatusBar_,0); // no stretch
// Construct GL context & widget
QGLWidget* share = 0;
if (_share) share = _share->glWidget_;
QGLFormat format;
format.setAlpha(true);
if (_format!=0) format = *_format;
glWidget_ = new QGLWidget(format, 0, share);
glView_ = new QtGLGraphicsView(this, work);
glScene_ = new QtGLGraphicsScene (this);
glView_->setViewport(glWidget_);
glView_->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
glView_->setScene(glScene_);
glView_->setFrameStyle(QFrame::NoFrame);
wheelZ_=new QtWheel( 0,"wheel-z",QtWheel::Vertical);
wheelZ_->setMinimumSize(wheelZ_->sizeHint());
wheelZ_->setMaximumSize(wheelZ_->sizeHint());
connect(wheelZ_,SIGNAL(angleChangedBy(double)),
this,SLOT(slotWheelZ(double)));
wheelZ_->setToolTip( "Translate along <b>z-axis</b>.");
wheelZ_->setWhatsThis( "Translate along <b>z-axis</b>.");
if ((options_&ShowWheelZ)==0)
wheelZ_->hide();
wheelY_=new QtWheel( 0,"wheel-y",QtWheel::Horizontal);
wheelY_->setMinimumSize(wheelY_->sizeHint());
wheelY_->setMaximumSize(wheelY_->sizeHint());
connect(wheelY_,SIGNAL(angleChangedBy(double)),
this,SLOT(slotWheelY(double)));
wheelY_->setToolTip("Rotate around <b>y-axis</b>.");
wheelY_->setWhatsThis( "Rotate around <b>y-axis</b>.");
if ((options_&ShowWheelY)==0)
wheelY_->hide();
wheelX_=new QtWheel( 0,"wheel-x",QtWheel::Vertical);
wheelX_->setMinimumSize(wheelX_->sizeHint());
wheelX_->setMaximumSize(wheelX_->sizeHint());
connect(wheelX_,SIGNAL(angleChangedBy(double)),
this,SLOT(slotWheelX(double)));
wheelX_->setToolTip("Rotate around <b>x-axis</b>.");
wheelX_->setWhatsThis( "Rotate around <b>x-axis</b>.");
if ((options_&ShowWheelX)==0)
wheelX_->hide();
QGraphicsWidget *wheelX = glScene_->addWidget (wheelX_);
QGraphicsWidget *wheelY = glScene_->addWidget (wheelY_);
QGraphicsWidget *wheelZ = glScene_->addWidget (wheelZ_);
wheelX_->setWindowOpacity (0.5);
wheelY_->setWindowOpacity (0.5);
wheelZ_->setWindowOpacity (0.5);
wheelX->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
wheelY->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
wheelZ->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
glBaseLayout_ = new QGraphicsGridLayout;
glBaseLayout_->addItem(wheelX, 1, 0);
glBaseLayout_->addItem(wheelY, 2, 1);
glBaseLayout_->addItem(wheelZ, 1, 3);
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);
glBase_ = new QGraphicsWidget;
glBase_->setLayout(glBaseLayout_);
glScene_->addItem(glBase_);
glBase_->setGeometry (glScene_->sceneRect ());
//QRectF r = glScene_->sceneRect ();
connect ( glScene_, SIGNAL( sceneRectChanged( const QRectF & ) ),
this, SLOT( sceneRectChanged( const QRectF & ) ) );
// If popupEnabled_ this signal will not be emitted!
// If popupEnabled_ is set to false the Contextmenu Mode will be set to customContextMenuRequested
// and this signal will be emitted on right click
connect( glView_ , SIGNAL( customContextMenuRequested( const QPoint& ) ) ,
this , SIGNAL( signalCustomContextMenuRequested( const QPoint& ) ) );
// is stereo possible ?
if (format.stereo())
std::cerr << "Stereo buffer requested: "
<< (glWidget_->format().stereo() ? "ok\n" : "failed\n");
// toolbar
buttonBar_= new QToolBar( "Viewer Toolbar", work );
buttonBar_->setOrientation(Qt::Vertical);
moveButton_ = new QToolButton( buttonBar_ );
moveButton_->setIcon( QPixmap(moveIcon) );
moveButton_->setMinimumSize( 16, 16 );
moveButton_->setMaximumSize( 32, 32 );
moveButton_->setToolTip( "Switch to <b>move</b> mode." );
moveButton_->setWhatsThis(
"Switch to <b>move</b> mode.<br>"
"<ul><li><b>Rotate</b> using <b>left</b> mouse button.</li>"
"<li><b>Translate</b> using <b>middle</b> mouse button.</li>"
"<li><b>Zoom</b> using <b>left+middle</b> mouse buttons.</li></ul>" );
QObject::connect( moveButton_, SIGNAL( clicked() ),
this, SLOT( examineMode() ) );
buttonBar_->addWidget( moveButton_)->setText("Move");
lightButton_ = new QToolButton( buttonBar_ );
lightButton_->setIcon( QPixmap(lightIcon) );
lightButton_->setMinimumSize( 16, 16 );
lightButton_->setMaximumSize( 32, 32 );
lightButton_->setToolTip("Switch to <b>light</b> mode.");
lightButton_->setWhatsThis(
"Switch to <b>light</b> mode.<br>"
"Rotate lights using left mouse button.");
QObject::connect( lightButton_, SIGNAL( clicked() ),
this, SLOT( lightMode() ) );
buttonBar_->addWidget( lightButton_)->setText("Light");
pickButton_ = new QToolButton( buttonBar_ );
pickButton_->setIcon( QPixmap(pickIcon) );
pickButton_->setMinimumSize( 16, 16 );
pickButton_->setMaximumSize( 32, 32 );
pickButton_->setToolTip("Switch to <b>picking</b> mode.");
pickButton_->setWhatsThis(
"Switch to <b>picking</b> mode.<br>"
"Use picking functions like flipping edges.<br>"
"To change the mode use the right click<br>"
"context menu in the viewer.");
QObject::connect( pickButton_, SIGNAL( clicked() ),
this, SLOT( pickingMode() ) );
buttonBar_->addWidget( pickButton_)->setText("Pick");
questionButton_ = new QToolButton( buttonBar_ );
questionButton_->setIcon( QPixmap(questionIcon) );
questionButton_->setMinimumSize( 16, 16 );
questionButton_->setMaximumSize( 32, 32 );
questionButton_->setToolTip("Switch to <b>identification</b> mode.");
questionButton_->setWhatsThis(
"Switch to <b>identification</b> mode.<br>"
"Use identification mode to get information "
"about objects. Click on an object and see "
"the log output for information about the "
"object.");
QObject::connect( questionButton_, SIGNAL( clicked() ),
this, SLOT( questionMode() ) );
buttonBar_->addWidget( questionButton_)->setText("Question");
buttonBar_->addSeparator();
homeButton_ = new QToolButton( buttonBar_ );
homeButton_->setIcon( QPixmap(homeIcon) );
homeButton_->setMinimumSize( 16, 16 );
homeButton_->setMaximumSize( 32, 32 );
homeButton_->setCheckable( false );
homeButton_->setToolTip("Restore <b>home</b> view.");
homeButton_->setWhatsThis(
"Restore home view<br><br>"
"Resets the view to the home view");
QObject::connect( homeButton_, SIGNAL( clicked() ),
this, SLOT( home() ) );
buttonBar_->addWidget( homeButton_)->setText("Home");
setHomeButton_ = new QToolButton( buttonBar_ );
setHomeButton_->setIcon( QPixmap(sethomeIcon) );
setHomeButton_->setMinimumSize( 16, 16 );
setHomeButton_->setMaximumSize( 32, 32 );
setHomeButton_->setCheckable( false );
setHomeButton_->setToolTip("Set <b>home</b> view");
setHomeButton_->setWhatsThis(
"Store home view<br><br>"
"Stores the current view as the home view");
QObject::connect( setHomeButton_, SIGNAL( clicked() ),
this, SLOT( setHome() ) );
buttonBar_->addWidget( setHomeButton_)->setText("Set Home");
viewAllButton_ = new QToolButton( buttonBar_ );
viewAllButton_->setIcon( QPixmap(viewallIcon) );
viewAllButton_->setMinimumSize( 16, 16 );
viewAllButton_->setMaximumSize( 32, 32 );
viewAllButton_->setCheckable( false );
viewAllButton_->setToolTip("View all.");
viewAllButton_->setWhatsThis(
"View all<br><br>"
"Move the objects in the scene so that"
" the whole scene is visible.");
QObject::connect( viewAllButton_, SIGNAL( clicked() ),
this, SLOT( viewAll() ) );
buttonBar_->addWidget( viewAllButton_)->setText("View all");
projectionButton_ = new QToolButton( buttonBar_ );
projectionButton_->setIcon( QPixmap(perspectiveIcon) );
projectionButton_->setMinimumSize( 16, 16 );
projectionButton_->setMaximumSize( 32, 32 );
projectionButton_->setCheckable( false );
projectionButton_->setToolTip(
"Switch between <b>perspective</b> and "
"<b>parrallel</b> projection mode.");
projectionButton_->setWhatsThis(
"Switch projection modes<br><br>"
"Switch between <b>perspective</b> and "
"<b>parrallel</b> projection mode.");
QObject::connect( projectionButton_, SIGNAL( clicked() ),
this, SLOT( toggleProjectionMode() ) );
buttonBar_->addWidget( projectionButton_)->setText( "Projection" );
if (glWidget_->format().stereo())
{
stereoButton_ = new QToolButton( buttonBar_ );
stereoButton_->setIcon( QPixmap(monoIcon) );
stereoButton_->setMinimumSize( 16, 16 );
stereoButton_->setMaximumSize( 32, 32 );
stereoButton_->setCheckable( true );
stereoButton_->setToolTip( "Toggle stereo viewing");
stereoButton_->setWhatsThis(
"Toggle stereo mode<br><br>"
"Use this button to switch between stereo "
"and mono view. To use this feature you need "
"a stereo capable graphics card and a stereo "
"display/projection system.");
QObject::connect( stereoButton_, SIGNAL( clicked() ),
this, SLOT( toggleStereoMode() ) );
buttonBar_->addWidget( stereoButton_)->setText( "Stereo");
}
buttonBar_->addSeparator();
sceneGraphButton_ = new QToolButton( buttonBar_ );
sceneGraphButton_->setIcon( QPixmap(sceneGraphIcon) );
sceneGraphButton_->setMinimumSize( 16, 16 );
sceneGraphButton_->setMaximumSize( 32, 32 );
sceneGraphButton_->setCheckable( false );
sceneGraphButton_->setToolTip("Toggle scene graph viewer.");
sceneGraphButton_->setWhatsThis(
"Toggle scene graph viewer<br><br>"
"The scene graph viewer enables you to examine the "
"displayed scene graph and to modify certain nodes.<br><br>"
"There are three modi for the scene graph viewer:"
"<ul><li><b>hidden</b></li>"
"<li><b>split</b>: share space</li>"
"<li><b>dialog</b>: own dialog window</li></ul>"
"This button toggles between these modi.");
QObject::connect( sceneGraphButton_, SIGNAL( clicked() ),
this, SLOT( showSceneGraphDialog() ) );
buttonBar_->addWidget( sceneGraphButton_)->setText( "SceneGraph" );
glLayout_ = new QGridLayout(work);
glLayout_->setSpacing( 0 );
glLayout_->setMargin( 0 );
glLayout_->addWidget(glView_, 0,0);
glLayout_->addWidget(buttonBar_, 0,1);
glLayout_->setColumnStretch(0,1);
glLayout_->setColumnStretch(1,0);
if (!(options_ & ShowToolBar))
buttonBar_->hide();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
......
...@@ -61,9 +61,11 @@ ...@@ -61,9 +61,11 @@
//== INCLUDES ================================================================= //== INCLUDES =================================================================
#include "../GL/GLState.hh"
#include "../Scenegraph/SceneGraph.hh"
#include "../Scenegraph/DrawModes.hh" #include "../Scenegraph/DrawModes.hh"
#include "../Config/ACGDefines.hh"
#include "../Math/VectorT.hh"
#include "../Math/GLMatrixT.hh"
#include "../Scenegraph/PickTarget.hh"
#include <QGLFormat> #include <QGLFormat>
#include <QBoxLayout> #include <QBoxLayout>
...@@ -98,12 +100,16 @@ class QImage; ...@@ -98,12 +100,16 @@ class QImage;
class QSocketNotifier; class QSocketNotifier;
class QGraphicsWidget; class QGraphicsWidget;
class QGraphicsGridLayout; class QGraphicsGridLayout;
class QGLFormat;
class QGLWidget;
//== NAMESPACES =============================================================== //== NAMESPACES ===============================================================
namespace ACG { namespace ACG {
class GLState;
namespace SceneGraph {
class BaseNode;
}
namespace QtWidgets { namespace QtWidgets {
...@@ -116,7 +122,6 @@ class QtGLGraphicsView; ...@@ -116,7 +122,6 @@ class QtGLGraphicsView;
class QtSceneGraphDialog; class QtSceneGraphDialog;
class QtShiftPopupMenu; class QtShiftPopupMenu;
//== CLASS DEFINITION ========================================================= //== CLASS DEFINITION =========================================================