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'?>
<!DOCTYPE KDevPrjSession>
<KDevPrjSession>
<DocsAndViews NumberOfDocuments="3" >
<Doc0 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/Plugin-TemplateModeling/Init.cc" >
<View0 Encoding="" line="1151" Type="Source" />
<DocsAndViews NumberOfDocuments="14" >
<Doc0 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/OpenFlipper/Core/ParseIni.cc" >
<View0 Encoding="" line="548" Type="Source" />
</Doc0>
<Doc1 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/OpenFlipper/widgets/glWidget/QtBaseViewer.hh" >
<View0 Encoding="" line="875" Type="Source" />
<Doc1 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/OpenFlipper/Core/openFunctions.cc" >
<View0 Encoding="" line="266" Type="Source" />
</Doc1>
<Doc2 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/OpenFlipper/widgets/glWidget/QtGLGraphicsScene.cc" >
<View0 Encoding="" line="0" Type="Source" />
<Doc2 NumberOfViews="1" URL="file:///data/home1/moebius/projects/OpenFlipper/Plugin-FilePolyLine/FilePolyLine.hh" >
<View0 Encoding="" line="51" Type="Source" />
</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>
<pluginList>
<kdevdebugger>
......
......@@ -90,7 +90,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
functionMenu_(0),
contextSelectionMenu_(0),
stackMenu_(0),
stackedWidget_(0),
helpBrowserDeveloper_(0),
helpBrowserUser_(0),
aboutWidget_(0),
......@@ -104,6 +103,38 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
setCentralWidget(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
// ======================================================================
......@@ -124,47 +155,34 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
// ======================================================================
// Create examiner
// ======================================================================
QGLFormat format;
QGLFormat::setDefaultFormat(format);
format.setStereo( OpenFlipper::Options::stereo() );
QWidget* tmp = 0;
if ( !OpenFlipper::Options::multiView() ) {
glViewer* examinerWidget = new glViewer(stackedWidget_,
"Examiner Widget",
statusBar_ ,
&format);
glViewer* examinerWidget = new glViewer(glScene_,
glWidget_,
centerWidget_,
"Examiner Widget",
statusBar_);
examiner_widgets_.push_back(examinerWidget);
examinerWidget->sceneGraph( PluginFunctions::getSceneGraphRootNode() );
stackedWidget_->addWidget(examinerWidget);
glScene_->addItem(examinerWidget);
baseLayout_->addItem(examinerWidget, 0, 0);
} 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
for ( unsigned int i = 1 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
glViewer* newWidget = new glViewer(tmp,
"Examiner Widget",
statusBar_ ,
&format,
examinerWidget);
// Create examiners
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
glViewer* newWidget = new glViewer(glScene_,
glWidget_,
centerWidget_,
"Examiner Widget",
statusBar_ );
examiner_widgets_.push_back(newWidget);
glScene_->addItem(newWidget);
}
// Initialize all examiners
......@@ -172,22 +190,20 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
examiner_widgets_[i]->sceneGraph( PluginFunctions::getSceneGraphRootNode() );
}
QGridLayout* layout = new QGridLayout(tmp);
layout->addWidget(examiner_widgets_[0],0,0);
layout->addWidget(examiner_widgets_[1],0,1);
layout->addWidget(examiner_widgets_[2],1,0);
layout->addWidget(examiner_widgets_[3],1,1);
baseLayout_->addItem(examiner_widgets_[0],0,0);
baseLayout_->addItem(examiner_widgets_[1],0,1);
baseLayout_->addItem(examiner_widgets_[2],1,0);
baseLayout_->addItem(examiner_widgets_[3],1,1);
for ( unsigned int i = 1 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
examiner_widgets_[i]->hide();
stackedWidget_->addWidget(tmp);
}
// Make examiner available to the plugins ( defined in PluginFunctions.hh)
PluginFunctions::setViewers( examiner_widgets_ );
centerWidget_->setLayout(baseLayout_);
// ======================================================================
......@@ -397,13 +413,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
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
wsizes = splitter_->sizes();
originalLoggerSize_ = wsizes[1];
......@@ -654,6 +663,15 @@ CoreWidget::slotShowSceneGraphDialog()
}
}
//-----------------------------------------------------------------------------
void
CoreWidget::sceneRectChanged(const QRectF &rect)
{
centerWidget_->setGeometry (rect);
}
//=============================================================================
......@@ -57,6 +57,8 @@
#include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh>
#include <OpenFlipper/widgets/glWidget/QtGLGraphicsScene.hh>
#include <OpenFlipper/widgets/glWidget/QtGLGraphicsView.hh>
// QT INCLUDES
#include <QMainWindow>
......@@ -366,6 +368,22 @@ public:
/// Help Menu
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
ACG::QtWidgets::QtSceneGraphDialog* sceneGraphDialog_;
......@@ -384,6 +402,10 @@ public:
*/
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
* @{ */
......
......@@ -108,7 +108,7 @@ void CoreWidget::startDrag ( QMouseEvent* _event )
QString 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;
mime_data->setText ( view );
......
......@@ -445,9 +445,10 @@ void CoreWidget::coreKeyPressEvent (QKeyEvent* _e){
case Qt::Key_Space:
if ( OpenFlipper::Options::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();
} else {
......
......@@ -88,6 +88,8 @@
#include <QGraphicsWidget>
#include <QGraphicsGridLayout>
#include <QGraphicsProxyWidget>
#include <QPainter>
#include <QPaintEngine>
#ifdef max
# undef max
......@@ -110,29 +112,25 @@ static const char VIEW_MAGIC[] =
//== IMPLEMENTATION ==========================================================
glViewer::glViewer( QWidget* _parent,
const char* /* _name */ ,
QStatusBar *_statusBar,
const QGLFormat* _format,
const glViewer* _share) :
QWidget(_parent),
glViewer::glViewer( QtGLGraphicsScene* _scene,
QGLWidget* _glWidget,
QGraphicsWidget* _parent,
const char* /* _name */ ,
QStatusBar *_statusBar) :
QGraphicsWidget(_parent),
statusbar_(_statusBar),
glareaGrabbed_(false),
projectionUpdateLocked_(false),
blending_(true),
glScene_(_scene),
glWidget_(_glWidget),
pick_mode_name_(""),
pick_mode_idx_(-1),
glstate_(0)
{
// check for OpenGL support
if ( !QGLFormat::hasOpenGL() )
{
std::cerr << "This system has no OpenGL support.\n";
exit(1);
}
// widget stuff
createWidgets(_format,_statusBar,_share);
createWidgets(_statusBar);
// bind GL context to GL state class
glstate_ = new ACG::GLState();
......@@ -192,6 +190,7 @@ glViewer::glViewer( QWidget* _parent,
properties_.setExamineMode();
setAcceptDrops(true);
}
......@@ -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);
......@@ -392,28 +391,24 @@ void glViewer::updateActionMode(Viewer::ActionMode _am)
{
case Viewer::ExamineMode:
{
glView_->setCursor(Qt::PointingHandCursor);
glBase_->setCursor(Qt::PointingHandCursor);
setCursor(Qt::PointingHandCursor);
break;
}
case Viewer::LightMode:
{
glView_->setCursor(Qt::PointingHandCursor);
glBase_->setCursor(Qt::PointingHandCursor);
setCursor(Qt::PointingHandCursor);
break;
}
case Viewer::PickingMode:
{
glView_->setCursor(Qt::ArrowCursor);
glBase_->setCursor(Qt::ArrowCursor);
setCursor(Qt::ArrowCursor);
if (pick_mode_idx_ != -1) {
trackMouse(pick_modes_[pick_mode_idx_].tracking);
glView_->setCursor(pick_modes_[pick_mode_idx_].cursor);
glBase_->setCursor(pick_modes_[pick_mode_idx_].cursor);
trackMouse(pick_modes_[pick_mode_idx_].tracking);
setCursor(pick_modes_[pick_mode_idx_].cursor);
}
break;
......@@ -422,8 +417,7 @@ void glViewer::updateActionMode(Viewer::ActionMode _am)
case Viewer::QuestionMode:
{
glView_->setCursor(Qt::WhatsThisCursor);
glBase_->setCursor(Qt::WhatsThisCursor);
setCursor(Qt::WhatsThisCursor);
break;
}
}
......@@ -475,19 +469,11 @@ glViewer::copyToImage( QImage& _image,
//-----------------------------------------------------------------------------
void glViewer::drawNow()
{
makeCurrent();
paintGL();
swapBuffers();
glView_->repaint();
}
void glViewer::updateGL()
{
if (!properties_.updateLocked() && !isHidden() )
if (!properties_.updateLocked() && isVisible() )
{
glScene_->update();
update();
}
}
......@@ -615,7 +601,8 @@ glViewer::drawScene_stereo()
glTranslatef(-offset, 0.0, 0.0);
glMatrixMode(GL_MODELVIEW);
glDrawBuffer(GL_BACK_LEFT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glstate_->clearBuffers ();
glClear(GL_DEPTH_BUFFER_BIT);
drawScene_mono();
......@@ -626,7 +613,8 @@ glViewer::drawScene_stereo()
glTranslatef(offset, 0.0, 0.0);
glMatrixMode(GL_MODELVIEW);
glDrawBuffer(GL_BACK_RIGHT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glstate_->clearBuffers ();
glClear(GL_DEPTH_BUFFER_BIT);
drawScene_mono();
glDrawBuffer(GL_BACK);
}
......@@ -768,7 +756,8 @@ void glViewer::flyTo(const ACG::Vec3d& _position,
if (fabs(a) > FLT_MIN)
rotate(axis, a, _center);
drawNow();
update();
qApp->processEvents();
}
}
......@@ -1019,7 +1008,7 @@ void glViewer::paintGL()
// clear (stereo mode clears buffers on its own)
if (!stereo_)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glstate_->clearBuffers ();
properties_.unLockUpdate();
......@@ -1039,16 +1028,35 @@ void glViewer::paintGL()
//-----------------------------------------------------------------------------
void glViewer::resizeGL(int _w, int _h)
void glViewer::resizeEvent(QGraphicsSceneResizeEvent *)
{
updateProjectionMatrix();
glstate_->viewport(0, 0, _w, _h);
updateGL();
glstate_->viewport(scenePos().x(),
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 ();
}
void glViewer::encodeView(QString& _view)
{
......@@ -1195,46 +1203,13 @@ void glViewer::actionDrawMenu( QAction * _action )
//-----------------------------------------------------------------------------
void
glViewer::createWidgets(const QGLFormat* _format,
QStatusBar* _sb,
const glViewer* _share)
glViewer::createWidgets(QStatusBar* _sb)
{
setStatusBar(_sb);
drawMenu_=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
// 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_->setContextMenuPolicy( Qt::CustomContextMenu );
wheelZ_=new ACG::QtWidgets::QtWheel( 0,"wheel-z",ACG::QtWidgets::QtWheel::Vertical);
wheelZ_->setMinimumSize(wheelZ_->sizeHint());
......@@ -1287,34 +1262,7 @@ glViewer::createWidgets(const QGLFormat* _format,
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_ 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");
glLayout_ = new QGridLayout(work);
glLayout_->setSpacing( 0 );
glLayout_->setMargin( 0 );
glLayout_->addWidget(glView_, 0,0);
glLayout_->setColumnStretch(0,1);
glLayout_->setColumnStretch(1,0);
setLayout(glBaseLayout_);
}
......@@ -1329,7 +1277,7 @@ void glViewer::updatePopupMenu()
if ( ! drawMenu_ )
{
drawMenu_ = new QMenu( this );
drawMenu_ = new QMenu( scene()->views().first() );
connect( drawMenu_, SIGNAL( aboutToHide() ),
this, SLOT( hidePopupMenus() ) );
......@@ -1428,20 +1376,24 @@ void glViewer::rotate(const ACG::Vec3d& _axis,
unsigned int glViewer::glWidth() const {
return glView_->width();
return size().width();
}
unsigned int glViewer::glHeight() const {
return glView_->height();
return size().height();
}
QSize glViewer::glSize() const {
return glView_->size();
return QSize(size().width(),size().height());
}
QPoint glViewer::glMapFromGlobal( const QPoint& _pos ) const {
return glView_->mapFromGlobal(_pos);
QPoint p (scene()->views().front()->mapFromGlobal(_pos));
QPointF f (mapFromScene(QPointF(p.x(), p.y ())));
return QPoint (f.x(), f.y());
}
QPoint glViewer::glMapToGlobal( const QPoint& _pos ) const {
return glView_->mapToGlobal(_pos);
QPointF f (mapToScene(QPointF(_pos.x(), _pos.y ())));
QPoint p (f.x(), f.y());
return scene()->views().front()->mapToGlobal(p);
}
//-----------------------------------------------------------------------------
......@@ -1469,14 +1421,6 @@ void glViewer::slotWheelZ(double _dist)
}
//-----------------------------------------------------------------------------
void glViewer::sceneRectChanged(const QRectF &rect)
{
glBase_->setGeometry (rect);
}
//-----------------------------------------------------------------------------
......@@ -1484,35 +1428,33 @@ void glViewer::grabGLArea()
{
glareaGrabbed_ = true;
glView_->setCursor(Qt::BlankCursor);
glBase_->setCursor(Qt::BlankCursor);
glView_->grabMouse();
glView_->grabKeyboard();
setCursor(Qt::BlankCursor);
grabMouse();
grabKeyboard();