Commit 6507389b authored by Jan Möbius's avatar Jan Möbius

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@4613 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 3c8c8e5f
<?xml version = '1.0' encoding = 'UTF-8'?> <?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE KDevPrjSession> <!DOCTYPE KDevPrjSession>
<KDevPrjSession> <KDevPrjSession>
<DocsAndViews NumberOfDocuments="3" > <DocsAndViews NumberOfDocuments="14" >
<Doc0 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/Plugin-TemplateModeling/Init.cc" > <Doc0 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/OpenFlipper/Core/ParseIni.cc" >
<View0 Encoding="" line="1151" Type="Source" /> <View0 Encoding="" line="548" Type="Source" />
</Doc0> </Doc0>
<Doc1 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/OpenFlipper/widgets/glWidget/QtBaseViewer.hh" > <Doc1 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/OpenFlipper/Core/openFunctions.cc" >
<View0 Encoding="" line="875" Type="Source" /> <View0 Encoding="" line="266" Type="Source" />
</Doc1> </Doc1>
<Doc2 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/OpenFlipper/widgets/glWidget/QtGLGraphicsScene.cc" > <Doc2 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/Plugin-FilePolyLine/FilePolyLine.hh" >
<View0 Encoding="" line="0" Type="Source" /> <View0 Encoding="" line="51" 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>
......
...@@ -90,7 +90,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -90,7 +90,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
functionMenu_(0), functionMenu_(0),
contextSelectionMenu_(0), contextSelectionMenu_(0),
stackMenu_(0), stackMenu_(0),
stackedWidget_(0),
helpBrowserDeveloper_(0), helpBrowserDeveloper_(0),
helpBrowserUser_(0), helpBrowserUser_(0),
aboutWidget_(0), aboutWidget_(0),
...@@ -104,6 +103,38 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -104,6 +103,38 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
setCentralWidget(splitter_); setCentralWidget(splitter_);
stackedWidget_ = new QStackedWidget(splitter_); stackedWidget_ = new QStackedWidget(splitter_);
QGLFormat format;
QGLFormat::setDefaultFormat(format);
format.setStereo( OpenFlipper::Options::stereo() );
format.setAlpha(true);
// Construct GL context & widget
glWidget_ = new QGLWidget(format);
glView_ = new QtGLGraphicsView(stackedWidget_);
glScene_ = new QtGLGraphicsScene (&examiner_widgets_);
// is stereo possible ?
if (format.stereo())
std::cerr << "Stereo buffer requested: "
<< (glWidget_->format().stereo() ? "ok\n" : "failed\n");
glView_->setViewport(glWidget_);
glView_->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
glView_->setScene(glScene_);
baseLayout_ = new QGraphicsGridLayout;
baseLayout_->setContentsMargins(0,0,0,0);
centerWidget_ = new QGraphicsWidget;
glScene_->addItem(centerWidget_);
centerWidget_->setGeometry (glScene_->sceneRect ());
connect ( glView_, SIGNAL( sceneRectChanged( const QRectF & ) ),
this, SLOT( sceneRectChanged( const QRectF & ) ) );
stackedWidget_->addWidget(glView_);
stackWidgetList_.push_back( StackWidgetInfo( false, "3D Examiner Widget", glView_ ) );
// ====================================================================== // ======================================================================
// Set up the logging window // Set up the logging window
// ====================================================================== // ======================================================================
...@@ -124,47 +155,34 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -124,47 +155,34 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
// ====================================================================== // ======================================================================
// Create examiner // Create examiner
// ====================================================================== // ======================================================================
QGLFormat format;
QGLFormat::setDefaultFormat(format);
format.setStereo( OpenFlipper::Options::stereo() );
QWidget* tmp = 0;
if ( !OpenFlipper::Options::multiView() ) { if ( !OpenFlipper::Options::multiView() ) {
glViewer* examinerWidget = new glViewer(stackedWidget_, glViewer* examinerWidget = new glViewer(glScene_,
"Examiner Widget", glWidget_,
statusBar_ , centerWidget_,
&format); "Examiner Widget",
statusBar_);
examiner_widgets_.push_back(examinerWidget); examiner_widgets_.push_back(examinerWidget);
examinerWidget->sceneGraph( PluginFunctions::getSceneGraphRootNode() ); examinerWidget->sceneGraph( PluginFunctions::getSceneGraphRootNode() );
stackedWidget_->addWidget(examinerWidget); glScene_->addItem(examinerWidget);
baseLayout_->addItem(examinerWidget, 0, 0);
} else { } else {
// Create collector widget which holds all viewers
tmp = new QWidget(stackedWidget_);
// Create master examiner widget
glViewer* examinerWidget = new glViewer(tmp,
"Examiner Widget",
statusBar_ ,
&format,
0);
examiner_widgets_.push_back(examinerWidget);
// Create all other examiners using the same gl context as the others // Create examiners
for ( unsigned int i = 1 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) { for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
glViewer* newWidget = new glViewer(tmp, glViewer* newWidget = new glViewer(glScene_,
"Examiner Widget", glWidget_,
statusBar_ , centerWidget_,
&format, "Examiner Widget",
examinerWidget); statusBar_ );
examiner_widgets_.push_back(newWidget); examiner_widgets_.push_back(newWidget);
glScene_->addItem(newWidget);
} }
// Initialize all examiners // Initialize all examiners
...@@ -172,22 +190,20 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -172,22 +190,20 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
examiner_widgets_[i]->sceneGraph( PluginFunctions::getSceneGraphRootNode() ); examiner_widgets_[i]->sceneGraph( PluginFunctions::getSceneGraphRootNode() );
} }
QGridLayout* layout = new QGridLayout(tmp); baseLayout_->addItem(examiner_widgets_[0],0,0);
layout->addWidget(examiner_widgets_[0],0,0); baseLayout_->addItem(examiner_widgets_[1],0,1);
layout->addWidget(examiner_widgets_[1],0,1); baseLayout_->addItem(examiner_widgets_[2],1,0);
layout->addWidget(examiner_widgets_[2],1,0); baseLayout_->addItem(examiner_widgets_[3],1,1);
layout->addWidget(examiner_widgets_[3],1,1);
for ( unsigned int i = 1 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) for ( unsigned int i = 1 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
examiner_widgets_[i]->hide(); examiner_widgets_[i]->hide();
stackedWidget_->addWidget(tmp);
} }
// Make examiner available to the plugins ( defined in PluginFunctions.hh) // Make examiner available to the plugins ( defined in PluginFunctions.hh)
PluginFunctions::setViewers( examiner_widgets_ ); PluginFunctions::setViewers( examiner_widgets_ );
centerWidget_->setLayout(baseLayout_);
// ====================================================================== // ======================================================================
...@@ -397,13 +413,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -397,13 +413,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
addToolBar(Qt::TopToolBarArea,viewerToolbar_); addToolBar(Qt::TopToolBarArea,viewerToolbar_);
if ( !OpenFlipper::Options::multiView() ) {
stackWidgetList_.push_back( StackWidgetInfo( false, "3D Examiner Widget", examiner_widgets_[0] ) );
} else {
stackWidgetList_.push_back( StackWidgetInfo( false, "3D Examiner Widget", tmp ) );
}
// Remember logger size // Remember logger size
wsizes = splitter_->sizes(); wsizes = splitter_->sizes();
originalLoggerSize_ = wsizes[1]; originalLoggerSize_ = wsizes[1];
...@@ -654,6 +663,15 @@ CoreWidget::slotShowSceneGraphDialog() ...@@ -654,6 +663,15 @@ CoreWidget::slotShowSceneGraphDialog()
} }
} }
//-----------------------------------------------------------------------------
void
CoreWidget::sceneRectChanged(const QRectF &rect)
{
centerWidget_->setGeometry (rect);
}
//============================================================================= //=============================================================================
...@@ -57,6 +57,8 @@ ...@@ -57,6 +57,8 @@
#include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh> #include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh>
#include <OpenFlipper/widgets/glWidget/QtGLGraphicsScene.hh>
#include <OpenFlipper/widgets/glWidget/QtGLGraphicsView.hh>
// QT INCLUDES // QT INCLUDES
#include <QMainWindow> #include <QMainWindow>
...@@ -366,6 +368,22 @@ public: ...@@ -366,6 +368,22 @@ public:
/// Help Menu /// Help Menu
QMenu* helpMenu_; QMenu* helpMenu_;
/// gl widget used as drawing area to paint the graphics scene
QGLWidget* glWidget_;
/// graphics scene used to paint gl context and widgets
QtGLGraphicsScene* glScene_;
/// graphics view that holds the gl scene
QtGLGraphicsView* glView_;
/// center widged
QGraphicsWidget* centerWidget_;
/// Base layout that holds gl views
QGraphicsGridLayout* baseLayout_;
// widget showing the scenegraph // widget showing the scenegraph
ACG::QtWidgets::QtSceneGraphDialog* sceneGraphDialog_; ACG::QtWidgets::QtSceneGraphDialog* sceneGraphDialog_;
...@@ -384,6 +402,10 @@ public: ...@@ -384,6 +402,10 @@ public:
*/ */
void slotLog(Logtype _type, QString _message); void slotLog(Logtype _type, QString _message);
/** Updates the size of the main graphics widget in the scene
*/
void sceneRectChanged(const QRectF &rect);
//=========================================================================== //===========================================================================
/** @name Menubar controls /** @name Menubar controls
* @{ */ * @{ */
......
...@@ -108,7 +108,7 @@ void CoreWidget::startDrag ( QMouseEvent* _event ) ...@@ -108,7 +108,7 @@ void CoreWidget::startDrag ( QMouseEvent* _event )
QString view; QString view;
examiner_widgets_[PluginFunctions::activeExaminer()]->encodeView ( view ); examiner_widgets_[PluginFunctions::activeExaminer()]->encodeView ( view );
QDrag * drag = new QDrag ( examiner_widgets_[PluginFunctions::activeExaminer()] ); QDrag * drag = new QDrag ( this );
QMimeData * mime_data = new QMimeData; QMimeData * mime_data = new QMimeData;
mime_data->setText ( view ); mime_data->setText ( view );
......
...@@ -445,9 +445,10 @@ void CoreWidget::coreKeyPressEvent (QKeyEvent* _e){ ...@@ -445,9 +445,10 @@ 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 to MultiView");
if ( examiner_widgets_[1]->isHidden() ) {
for ( uint i = 1 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) if ( !examiner_widgets_[1]->isVisible() ) {
for ( uint i = 1 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
examiner_widgets_[i]->show(); examiner_widgets_[i]->show();
} else { } else {
......
...@@ -88,6 +88,8 @@ ...@@ -88,6 +88,8 @@
#include <QGraphicsWidget> #include <QGraphicsWidget>
#include <QGraphicsGridLayout> #include <QGraphicsGridLayout>
#include <QGraphicsProxyWidget> #include <QGraphicsProxyWidget>
#include <QPainter>
#include <QPaintEngine>
#ifdef max #ifdef max
# undef max # undef max
...@@ -110,29 +112,25 @@ static const char VIEW_MAGIC[] = ...@@ -110,29 +112,25 @@ static const char VIEW_MAGIC[] =
//== IMPLEMENTATION ========================================================== //== IMPLEMENTATION ==========================================================
glViewer::glViewer( QWidget* _parent, glViewer::glViewer( QtGLGraphicsScene* _scene,
const char* /* _name */ , QGLWidget* _glWidget,
QStatusBar *_statusBar, QGraphicsWidget* _parent,
const QGLFormat* _format, const char* /* _name */ ,
const glViewer* _share) : QStatusBar *_statusBar) :
QWidget(_parent), QGraphicsWidget(_parent),
statusbar_(_statusBar), statusbar_(_statusBar),
glareaGrabbed_(false), glareaGrabbed_(false),
projectionUpdateLocked_(false), projectionUpdateLocked_(false),
blending_(true), blending_(true),
glScene_(_scene),
glWidget_(_glWidget),
pick_mode_name_(""), pick_mode_name_(""),
pick_mode_idx_(-1), pick_mode_idx_(-1),
glstate_(0) glstate_(0)
{ {
// check for OpenGL support
if ( !QGLFormat::hasOpenGL() )
{
std::cerr << "This system has no OpenGL support.\n";
exit(1);
}
// widget stuff // widget stuff
createWidgets(_format,_statusBar,_share); createWidgets(_statusBar);
// bind GL context to GL state class // bind GL context to GL state class
glstate_ = new ACG::GLState(); glstate_ = new ACG::GLState();
...@@ -192,6 +190,7 @@ glViewer::glViewer( QWidget* _parent, ...@@ -192,6 +190,7 @@ glViewer::glViewer( QWidget* _parent,
properties_.setExamineMode(); properties_.setExamineMode();
setAcceptDrops(true);
} }
...@@ -382,7 +381,7 @@ void glViewer::viewingDirection( const ACG::Vec3d& _dir, const ACG::Vec3d& _up ) ...@@ -382,7 +381,7 @@ void glViewer::viewingDirection( const ACG::Vec3d& _dir, const ACG::Vec3d& _up )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void glViewer::updateActionMode(Viewer::ActionMode _am) void glViewer::updateActionMode(Viewer::ActionMode)
{ {
trackMouse(false); trackMouse(false);
...@@ -392,28 +391,24 @@ void glViewer::updateActionMode(Viewer::ActionMode _am) ...@@ -392,28 +391,24 @@ void glViewer::updateActionMode(Viewer::ActionMode _am)
{ {
case Viewer::ExamineMode: case Viewer::ExamineMode:
{ {
glView_->setCursor(Qt::PointingHandCursor); setCursor(Qt::PointingHandCursor);
glBase_->setCursor(Qt::PointingHandCursor);
break; break;
} }
case Viewer::LightMode: case Viewer::LightMode:
{ {
glView_->setCursor(Qt::PointingHandCursor); setCursor(Qt::PointingHandCursor);
glBase_->setCursor(Qt::PointingHandCursor);
break; break;
} }
case Viewer::PickingMode: case Viewer::PickingMode:
{ {
glView_->setCursor(Qt::ArrowCursor); setCursor(Qt::ArrowCursor);
glBase_->setCursor(Qt::ArrowCursor);
if (pick_mode_idx_ != -1) { if (pick_mode_idx_ != -1) {
trackMouse(pick_modes_[pick_mode_idx_].tracking); trackMouse(pick_modes_[pick_mode_idx_].tracking);
glView_->setCursor(pick_modes_[pick_mode_idx_].cursor); setCursor(pick_modes_[pick_mode_idx_].cursor);
glBase_->setCursor(pick_modes_[pick_mode_idx_].cursor);
} }
break; break;
...@@ -422,8 +417,7 @@ void glViewer::updateActionMode(Viewer::ActionMode _am) ...@@ -422,8 +417,7 @@ void glViewer::updateActionMode(Viewer::ActionMode _am)
case Viewer::QuestionMode: case Viewer::QuestionMode:
{ {
glView_->setCursor(Qt::WhatsThisCursor); setCursor(Qt::WhatsThisCursor);
glBase_->setCursor(Qt::WhatsThisCursor);
break; break;
} }
} }
...@@ -475,19 +469,11 @@ glViewer::copyToImage( QImage& _image, ...@@ -475,19 +469,11 @@ glViewer::copyToImage( QImage& _image,
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void glViewer::drawNow()
{
makeCurrent();
paintGL();
swapBuffers();
glView_->repaint();
}
void glViewer::updateGL() void glViewer::updateGL()
{ {
if (!properties_.updateLocked() && !isHidden() ) if (!properties_.updateLocked() && isVisible() )
{ {
glScene_->update(); update();
} }
} }
...@@ -615,7 +601,8 @@ glViewer::drawScene_stereo() ...@@ -615,7 +601,8 @@ glViewer::drawScene_stereo()
glTranslatef(-offset, 0.0, 0.0); glTranslatef(-offset, 0.0, 0.0);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glDrawBuffer(GL_BACK_LEFT); glDrawBuffer(GL_BACK_LEFT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glstate_->clearBuffers ();
glClear(GL_DEPTH_BUFFER_BIT);
drawScene_mono(); drawScene_mono();
...@@ -626,7 +613,8 @@ glViewer::drawScene_stereo() ...@@ -626,7 +613,8 @@ glViewer::drawScene_stereo()
glTranslatef(offset, 0.0, 0.0); glTranslatef(offset, 0.0, 0.0);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glDrawBuffer(GL_BACK_RIGHT); glDrawBuffer(GL_BACK_RIGHT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glstate_->clearBuffers ();
glClear(GL_DEPTH_BUFFER_BIT);
drawScene_mono(); drawScene_mono();
glDrawBuffer(GL_BACK); glDrawBuffer(GL_BACK);
} }
...@@ -768,7 +756,8 @@ void glViewer::flyTo(const ACG::Vec3d& _position, ...@@ -768,7 +756,8 @@ void glViewer::flyTo(const ACG::Vec3d& _position,
if (fabs(a) > FLT_MIN) if (fabs(a) > FLT_MIN)
rotate(axis, a, _center); rotate(axis, a, _center);
drawNow(); update();
qApp->processEvents();
} }
} }
...@@ -1019,7 +1008,7 @@ void glViewer::paintGL() ...@@ -1019,7 +1008,7 @@ void glViewer::paintGL()
// clear (stereo mode clears buffers on its own) // clear (stereo mode clears buffers on its own)
if (!stereo_) if (!stereo_)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glstate_->clearBuffers ();
properties_.unLockUpdate(); properties_.unLockUpdate();
...@@ -1039,16 +1028,35 @@ void glViewer::paintGL() ...@@ -1039,16 +1028,35 @@ void glViewer::paintGL()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void glViewer::resizeGL(int _w, int _h) void glViewer::resizeEvent(QGraphicsSceneResizeEvent *)
{ {
updateProjectionMatrix(); updateProjectionMatrix();
glstate_->viewport(0, 0, _w, _h); glstate_->viewport(scenePos().x(),
updateGL(); scene()->height () - scenePos().y() - size().height (),
size().width (), size().height (),
scene()->width (), scene()->height ());
update();
} }
void glViewer::moveEvent (QGraphicsSceneMoveEvent *)
{
glstate_->viewport(scenePos().x(),
scene()->height () - scenePos().y() - size().height (),
size().width (), size().height (),
scene()->width (), scene()->height ());
update();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
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 ();
}