Commit 4dc6b656 authored by Mike Kremer's avatar Mike Kremer
Browse files

Made picking toolbar and logger widget be rendered into the opengl scene.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@11959 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 0156bd68
...@@ -588,7 +588,7 @@ Core::init() { ...@@ -588,7 +588,7 @@ Core::init() {
windowStates.beginGroup ("Core"); windowStates.beginGroup ("Core");
windowStates.beginGroup ("LogSlider"); windowStates.beginGroup ("LogSlider");
coreWidget_->slidingLogger_->restoreState (windowStates); //coreWidget_->slidingLogger_->restoreState (windowStates);
windowStates.endGroup (); windowStates.endGroup ();
coreWidget_->toolBox_->restoreState (windowStates); coreWidget_->toolBox_->restoreState (windowStates);
windowStates.endGroup (); windowStates.endGroup ();
...@@ -1043,7 +1043,7 @@ Core::writeOnExit() { ...@@ -1043,7 +1043,7 @@ Core::writeOnExit() {
windowStates.beginGroup ("Core"); windowStates.beginGroup ("Core");
windowStates.beginGroup ("LogSlider"); windowStates.beginGroup ("LogSlider");
coreWidget_->slidingLogger_->saveState (windowStates); //coreWidget_->slidingLogger_->saveState (windowStates);
windowStates.endGroup (); windowStates.endGroup ();
coreWidget_->toolBox_->saveState (windowStates); coreWidget_->toolBox_->saveState (windowStates);
windowStates.endGroup (); windowStates.endGroup ();
......
...@@ -147,9 +147,6 @@ void Core::applyOptions(){ ...@@ -147,9 +147,6 @@ void Core::applyOptions(){
// toolbox orientation // toolbox orientation
coreWidget_->setToolBoxOrientationOnTheRight(OpenFlipperSettings().value("Core/Gui/ToolBoxes/ToolBoxOnTheRight",true).toBool()); coreWidget_->setToolBoxOrientationOnTheRight(OpenFlipperSettings().value("Core/Gui/ToolBoxes/ToolBoxOnTheRight",true).toBool());
// Update pick toolbar settings
coreWidget_->updatePickToolbar();
//set defaultBackgroundColor //set defaultBackgroundColor
QColor c = OpenFlipperSettings().value("Core/Gui/glViewer/defaultBackgroundColor").value<QColor>(); QColor c = OpenFlipperSettings().value("Core/Gui/glViewer/defaultBackgroundColor").value<QColor>();
......
...@@ -146,7 +146,9 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -146,7 +146,9 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
windowMenu_(0), windowMenu_(0),
AC_ShowViewModeControls_(0), AC_ShowViewModeControls_(0),
AC_ShowToolbox_(0), AC_ShowToolbox_(0),
pickToolbar_(0), glScene_(0),
centerWidget_(0),
slidingLogger_(0),
cursorPainter_(0), cursorPainter_(0),
sceneGraphDialog_(0), sceneGraphDialog_(0),
fileMenu_(0), fileMenu_(0),
...@@ -259,37 +261,45 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -259,37 +261,45 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
// Set up the logging window // Set up the logging window
// ====================================================================== // ======================================================================
slidingLogger_ = new QtSlideWindow (tr("Log Viewer"), centerWidget_); slidingLogger_ = new QtSlideWindow (tr("Log Viewer"));
tempLogWidget = new QWidget; tempLogWidget = new QWidget;
logWidget_ = new LoggerWidget(splitter_); logWidget_ = new LoggerWidget(splitter_);
logWidget_->setSizePolicy( QSizePolicy ( QSizePolicy::Preferred , QSizePolicy::Preferred ) ); logWidget_->setSizePolicy( QSizePolicy ( QSizePolicy::Preferred , QSizePolicy::Preferred ) );
logWidget_->resize( splitter_->width() ,240); logWidget_->resize( splitter_->width(), 240);
// Attach sliding logger
slidingLogger_->attachWidget (logWidget_);
originalLoggerSize_ = 0; originalLoggerSize_ = 0;
loggerState_ = OpenFlipper::Options::Normal; loggerState_ = OpenFlipper::Options::Normal;
// Add logger to gl scene
glScene_->addItem(slidingLogger_);
QList<int> wsizes( splitter_->sizes() ); QList<int> wsizes( splitter_->sizes() );
if (OpenFlipper::Options::loggerState() == OpenFlipper::Options::InScene) { if (OpenFlipper::Options::loggerState() == OpenFlipper::Options::InScene) {
slidingLogger_->attachWidget (logWidget_);
splitter_->insertWidget (1, tempLogWidget); splitter_->insertWidget (1, tempLogWidget);
wsizes[0] = 1; if(wsizes.size() > 0) wsizes[0] = 1;
wsizes[1] = 0; if(wsizes.size() > 1) wsizes[1] = 0;
splitter_->setSizes(wsizes); splitter_->setSizes(wsizes);
loggerState_ = OpenFlipper::Options::InScene; loggerState_ = OpenFlipper::Options::InScene;
baseLayout_->setContentsMargins (0, 0, 0, 16); baseLayout_->setContentsMargins (0, 0, 0, 16);
showInSceneLogger();
} else if (OpenFlipper::Options::loggerState() == OpenFlipper::Options::Hidden) { } else if (OpenFlipper::Options::loggerState() == OpenFlipper::Options::Hidden) {
splitter_->insertWidget (1, tempLogWidget); splitter_->insertWidget (1, tempLogWidget);
wsizes[0] = 1; if(wsizes.size() > 0) wsizes[0] = 1;
wsizes[1] = 0; if(wsizes.size() > 1) wsizes[1] = 0;
splitter_->setSizes(wsizes); splitter_->setSizes(wsizes);
loggerState_ = OpenFlipper::Options::Hidden; loggerState_ = OpenFlipper::Options::Hidden;
hideInSceneLogger();
} else { } else {
// Set initial values to have a usable state // Set initial values to have a usable state
wsizes[0] = 480; if(wsizes.size() > 0) wsizes[0] = 480;
wsizes[1] = 240; if(wsizes.size() > 1) wsizes[1] = 240;
splitter_->setSizes(wsizes); splitter_->setSizes(wsizes);
hideInSceneLogger();
} }
...@@ -498,12 +508,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -498,12 +508,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
wsizes = splitter_->sizes(); wsizes = splitter_->sizes();
originalLoggerSize_ = wsizes[1]; originalLoggerSize_ = wsizes[1];
// ======================================================================
// Create pickmode toolbar
// ======================================================================
pickToolbar_ = new QtPickToolbar(this, centerWidget_, OpenFlipperSettings().value("Core/Gui/ToolBars/PickToolbarInScene",true).toBool());
// ====================================================================== // ======================================================================
// Create ToolBox area // Create ToolBox area
// ====================================================================== // ======================================================================
...@@ -764,122 +768,77 @@ CoreWidget::toggleLogger() { ...@@ -764,122 +768,77 @@ CoreWidget::toggleLogger() {
*/ */
void void
CoreWidget::showLogger(OpenFlipper::Options::LoggerState _state) { CoreWidget::showLogger(OpenFlipper::Options::LoggerState _state) {
//Hide Logger //Hide Logger
if (_state == loggerState_) if (_state == loggerState_)
return; return;
qreal left, top, right, bottom; qreal left, top, right, bottom;
baseLayout_->getContentsMargins (&left, &top, &right, &bottom); baseLayout_->getContentsMargins(&left, &top, &right, &bottom);
switch (_state) switch (_state) {
{ case OpenFlipper::Options::InScene: {
case OpenFlipper::Options::InScene: QList<int> wsizes(splitter_->sizes());
{
QList<int> wsizes( splitter_->sizes() );
// Remember old size // Remember old size
if (loggerState_ == OpenFlipper::Options::Normal) if (loggerState_ == OpenFlipper::Options::Normal)
originalLoggerSize_ = wsizes[1]; originalLoggerSize_ = wsizes[1];
if ( originalLoggerSize_ == 0) if (originalLoggerSize_ == 0)
originalLoggerSize_ = 240; originalLoggerSize_ = 240;
splitter_->insertWidget (1, tempLogWidget); splitter_->insertWidget(1, tempLogWidget);
wsizes[0] = wsizes[0]+wsizes[1]; wsizes[0] = wsizes[0] + wsizes[1];
wsizes[1] = 0; wsizes[1] = 0;
splitter_->setSizes(wsizes); splitter_->setSizes(wsizes);
logWidget_->resize (logWidget_->width (), originalLoggerSize_); logWidget_->resize(logWidget_->width(), originalLoggerSize_);
slidingLogger_->attachWidget (logWidget_); baseLayout_->setContentsMargins(left, top, right, 16);
baseLayout_->setContentsMargins (left, top, right, 16);
} showInSceneLogger();
break; break;
case OpenFlipper::Options::Normal: }
{ case OpenFlipper::Options::Normal: {
if ( originalLoggerSize_ == 0) if (originalLoggerSize_ == 0)
originalLoggerSize_ = 240; originalLoggerSize_ = 240;
QList<int> wsizes( splitter_->sizes() ); QList<int> wsizes(splitter_->sizes());
if (loggerState_ == OpenFlipper::Options::InScene) if (loggerState_ == OpenFlipper::Options::InScene)
originalLoggerSize_ = logWidget_->height (); originalLoggerSize_ = logWidget_->height();
slidingLogger_->detachWidget (); splitter_->insertWidget(1, logWidget_);
splitter_->insertWidget (1, logWidget_); logWidget_->show();
logWidget_->show ();
wsizes[0] = wsizes[0]+wsizes[1] - originalLoggerSize_; wsizes[0] = wsizes[0] + wsizes[1] - originalLoggerSize_;
wsizes[1] = originalLoggerSize_; wsizes[1] = originalLoggerSize_;
splitter_->setSizes(wsizes); splitter_->setSizes(wsizes);
baseLayout_->setContentsMargins (left, top, right, 0); baseLayout_->setContentsMargins(left, top, right, 0);
}
break; hideInSceneLogger();
case OpenFlipper::Options::Hidden: break;
{ }
QList<int> wsizes( splitter_->sizes() ); case OpenFlipper::Options::Hidden: {
QList<int> wsizes(splitter_->sizes());
// Remember old size // Remember old size
if (loggerState_ == OpenFlipper::Options::Normal) if (loggerState_ == OpenFlipper::Options::Normal)
originalLoggerSize_ = wsizes[1]; originalLoggerSize_ = wsizes[1];
if (loggerState_ == OpenFlipper::Options::InScene) if (loggerState_ == OpenFlipper::Options::InScene) {
{ originalLoggerSize_ = logWidget_->height();
slidingLogger_->detachWidget (); }
originalLoggerSize_ = logWidget_->height ();
}
splitter_->insertWidget (1, tempLogWidget); splitter_->insertWidget(1, tempLogWidget);
wsizes[0] = wsizes[0]+wsizes[1]; wsizes[0] = wsizes[0] + wsizes[1];
wsizes[1] = 0; wsizes[1] = 0;
splitter_->setSizes(wsizes); splitter_->setSizes(wsizes);
baseLayout_->setContentsMargins (left, top, right, 0); baseLayout_->setContentsMargins(left, top, right, 0);
}
break;
}
loggerState_ = _state;
/* hideInSceneLogger();
if ( !_state ) { break;
QList<int> wsizes( splitter_->sizes() ); }
} // End switch
// Remember old size
originalLoggerSize_ = wsizes[1];
int height = logWidget_->height ();
splitter_->insertWidget (1, tempLogWidget);
wsizes[0] = wsizes[0]+wsizes[1];
wsizes[1] = 0;
splitter_->setSizes(wsizes);
logWidget_->resize (logWidget_->width (), height);
slidingLogger_->attachWidget (logWidget_);
} else if (splitter_->widget (1) == logWidget_) {
if ( originalLoggerSize_ == 0)
originalLoggerSize_ = 240;
QList<int> wsizes( splitter_->sizes() );
if (wsizes[0] == 0)
wsizes[0] = height();
wsizes[0] = wsizes[0]+wsizes[1] - originalLoggerSize_;
wsizes[1] = originalLoggerSize_;
splitter_->setSizes(wsizes);
} else {
QList<int> wsizes( splitter_->sizes() );
int height = logWidget_->height ();
slidingLogger_->detachWidget ();
splitter_->insertWidget (1, logWidget_);
wsizes[0] = wsizes[0]+wsizes[1] - height; loggerState_ = _state;
wsizes[1] = height;
splitter_->setSizes(wsizes);
}
*/
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -1111,11 +1070,11 @@ CoreWidget::slotShowSceneGraphDialog() ...@@ -1111,11 +1070,11 @@ CoreWidget::slotShowSceneGraphDialog()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
CoreWidget::sceneRectChanged(const QRectF &rect) CoreWidget::sceneRectChanged(const QRectF& _rect)
{ {
centerWidget_->setGeometry (rect); centerWidget_->setGeometry (_rect);
slidingLogger_->updateGeometry (); if(loggerState_ == OpenFlipper::Options::InScene)
pickToolbar_->updateGeometry(); updateInSceneLoggerGeometry(_rect);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -1160,13 +1119,5 @@ void CoreWidget::setForceNativeCursor ( bool _state ) ...@@ -1160,13 +1119,5 @@ void CoreWidget::setForceNativeCursor ( bool _state )
cursorPainter_->setForceNative (_state); cursorPainter_->setForceNative (_state);
} }
//-----------------------------------------------------------------------------
void CoreWidget::updatePickToolbar() {
pickToolbar_->detachToolbar();
pickToolbar_->setRenderFlag(OpenFlipperSettings().value("Core/Gui/ToolBars/PickToolbarInScene", true).toBool());
}
//============================================================================= //=============================================================================
...@@ -74,7 +74,6 @@ ...@@ -74,7 +74,6 @@
#include <OpenFlipper/widgets/glWidget/QtGLGraphicsView.hh> #include <OpenFlipper/widgets/glWidget/QtGLGraphicsView.hh>
#include <OpenFlipper/widgets/glWidget/QtMultiViewLayout.hh> #include <OpenFlipper/widgets/glWidget/QtMultiViewLayout.hh>
#include <OpenFlipper/widgets/glWidget/QtSlideWindow.hh> #include <OpenFlipper/widgets/glWidget/QtSlideWindow.hh>
#include <OpenFlipper/widgets/glWidget/QtPickToolbar.hh>
// QT INCLUDES // QT INCLUDES
#include <QMainWindow> #include <QMainWindow>
...@@ -477,9 +476,6 @@ public: ...@@ -477,9 +476,6 @@ public:
QSize defaultIconSize(); QSize defaultIconSize();
// Update pick toolbar settings
void updatePickToolbar();
public slots: public slots:
/// Show or hide toolbox /// Show or hide toolbox
...@@ -494,6 +490,24 @@ public: ...@@ -494,6 +490,24 @@ public:
/** @} */ /** @} */
//===========================================================================
/** @name GUI Controls
* @{ */
//===========================================================================
public slots:
/// Show in-scene logger widget
void showInSceneLogger();
/// Hide in-scene logger widget
void hideInSceneLogger();
/// Update logger's geometry
void updateInSceneLoggerGeometry(const QRectF& _rect);
/** @} */
//=========================================================================== //===========================================================================
/** @name Tool Widgets / View Modes /** @name Tool Widgets / View Modes
* @{ */ * @{ */
...@@ -657,8 +671,9 @@ public: ...@@ -657,8 +671,9 @@ public:
/// Toolbox scroll area /// Toolbox scroll area
QScrollArea* toolBoxScroll_; QScrollArea* toolBoxScroll_;
/// Toolbar showed in pickmode /// Handle to picking toolbar
QtPickToolbar* pickToolbar_; typedef std::map<QToolBar*,QGraphicsItem*> PickToolBarMap;
PickToolBarMap curPickingToolbarItems_;
/// Cursor handling /// Cursor handling
CursorPainter* cursorPainter_; CursorPainter* cursorPainter_;
...@@ -689,7 +704,7 @@ public: ...@@ -689,7 +704,7 @@ public:
/** Updates the size of the main graphics widget in the scene /** Updates the size of the main graphics widget in the scene
*/ */
void sceneRectChanged(const QRectF &rect); void sceneRectChanged(const QRectF& _rect);
//=========================================================================== //===========================================================================
/** @name Menubar controls /** @name Menubar controls
...@@ -1287,6 +1302,12 @@ public: ...@@ -1287,6 +1302,12 @@ public:
void getPickMode(std::string& _name); void getPickMode(std::string& _name);
/// Set toolbar to be active pick toolbar
void setActivePickToolBar(QToolBar* _tool);
/// Hide picking toolbar
void hidePickToolBar();
public slots: public slots:
/** \brief set a new cursor for the pick mode /** \brief set a new cursor for the pick mode
......
#include "CoreWidget.hh"
//========================================================
void CoreWidget::showInSceneLogger() {
if(slidingLogger_ != 0) {
slidingLogger_->show();
updateInSceneLoggerGeometry(glScene_->sceneRect());
}
}
//========================================================
void CoreWidget::hideInSceneLogger() {
if(slidingLogger_ != 0) {
slidingLogger_->hide();
}
}
//========================================================
void CoreWidget::updateInSceneLoggerGeometry(const QRectF& _rect) {
if(!slidingLogger_) return;
slidingLogger_->setParentGeometry(_rect);
slidingLogger_->updateGeometry();
}
...@@ -110,16 +110,16 @@ void CoreWidget::setActionMode(const Viewer::ActionMode _am){ ...@@ -110,16 +110,16 @@ void CoreWidget::setActionMode(const Viewer::ActionMode _am){
// Update pickmode toolbar // Update pickmode toolbar
switch ( _am ) { switch ( _am ) {
case Viewer::ExamineMode: case Viewer::ExamineMode:
pickToolbar_->detachToolbar (); hidePickToolBar();
break; break;
case Viewer::PickingMode: case Viewer::PickingMode:
// Show the pickMode Toolbar for this picking mode if it is set // Show the pickMode Toolbar for this picking mode if it is set
if (pick_mode_idx_ != -1) { if (pick_mode_idx_ != -1) {
if (pick_modes_[pick_mode_idx_].toolbar() ) if (pick_modes_[pick_mode_idx_].toolbar() )
pickToolbar_->attachToolbar (pick_modes_[pick_mode_idx_].toolbar() ); setActivePickToolBar(pick_modes_[pick_mode_idx_].toolbar() );
else else
pickToolbar_->detachToolbar (); hidePickToolBar();
} }
break; break;
...@@ -177,6 +177,45 @@ void CoreWidget::getPickMode(std::string& _mode){ ...@@ -177,6 +177,45 @@ void CoreWidget::getPickMode(std::string& _mode){
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void CoreWidget::setActivePickToolBar(QToolBar* _tool) {
if(_tool != 0) {
// Hide all picking toolbars
hidePickToolBar();
// Try to find toolbar in local map
PickToolBarMap::iterator ret = curPickingToolbarItems_.find(_tool);
if(ret == curPickingToolbarItems_.end()) {
// Add widget
QGraphicsItem* item = glScene_->addWidget(_tool);
// Put it into center of the screen
int midP = (glScene_->width() / 2) - (int)(_tool->width() / 2);
item->setPos(midP, 0);
item->show();
curPickingToolbarItems_.insert(std::pair<QToolBar*,QGraphicsItem*>(_tool,item));
} else {
// Widget has already been added once, so just show it
ret->second->show();
}
} else {
hidePickToolBar();
}
}
//-----------------------------------------------------------------------------
void CoreWidget::hidePickToolBar() {
// Hide all picking toolbars
for(PickToolBarMap::iterator it = curPickingToolbarItems_.begin();
it != curPickingToolbarItems_.end(); ++it) {
it->second->hide();
}
}
//-----------------------------------------------------------------------------
void CoreWidget::updatePickMenu() void CoreWidget::updatePickMenu()
{ {
if (pickMenu_ != 0) { if (pickMenu_ != 0) {
...@@ -257,9 +296,9 @@ void CoreWidget::pickMode( int _id ) ...@@ -257,9 +296,9 @@ void CoreWidget::pickMode( int _id )
pick_mode_name_ = pick_modes_[pick_mode_idx_].name(); pick_mode_name_ = pick_modes_[pick_mode_idx_].name();
if (pick_modes_[pick_mode_idx_].toolbar() ) if (pick_modes_[pick_mode_idx_].toolbar() )
pickToolbar_->attachToolbar (pick_modes_[pick_mode_idx_].toolbar() ); setActivePickToolBar(pick_modes_[pick_mode_idx_].toolbar() );
else else
pickToolbar_->detachToolbar (); hidePickToolBar();
// adjust mouse tracking // adjust mouse tracking
if ( pickingMode() ) if ( pickingMode() )
...@@ -343,7 +382,7 @@ void CoreWidget::setPickModeToolbar( const std::string _mode , QToolBar * _toolb ...@@ -343,7 +382,7 @@ void CoreWidget::setPickModeToolbar( const std::string _mode , QToolBar * _toolb
<