Commit c14e4879 authored by Mike Kremer's avatar Mike Kremer

Reverted last commit since there are still some bugs in it. Revising it next week.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@11960 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 4dc6b656
...@@ -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,6 +147,9 @@ void Core::applyOptions(){ ...@@ -147,6 +147,9 @@ 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,9 +146,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -146,9 +146,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
windowMenu_(0), windowMenu_(0),
AC_ShowViewModeControls_(0), AC_ShowViewModeControls_(0),
AC_ShowToolbox_(0), AC_ShowToolbox_(0),
glScene_(0), pickToolbar_(0),
centerWidget_(0),
slidingLogger_(0),
cursorPainter_(0), cursorPainter_(0),
sceneGraphDialog_(0), sceneGraphDialog_(0),
fileMenu_(0), fileMenu_(0),
...@@ -261,45 +259,37 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -261,45 +259,37 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
// Set up the logging window // Set up the logging window
// ====================================================================== // ======================================================================
slidingLogger_ = new QtSlideWindow (tr("Log Viewer")); slidingLogger_ = new QtSlideWindow (tr("Log Viewer"), centerWidget_);
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);
if(wsizes.size() > 0) wsizes[0] = 1; wsizes[0] = 1;
if(wsizes.size() > 1) wsizes[1] = 0; 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);
if(wsizes.size() > 0) wsizes[0] = 1; wsizes[0] = 1;
if(wsizes.size() > 1) wsizes[1] = 0; 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
if(wsizes.size() > 0) wsizes[0] = 480; wsizes[0] = 480;
if(wsizes.size() > 1) wsizes[1] = 240; wsizes[1] = 240;
splitter_->setSizes(wsizes); splitter_->setSizes(wsizes);
hideInSceneLogger();
} }
...@@ -508,6 +498,12 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -508,6 +498,12 @@ 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
// ====================================================================== // ======================================================================
...@@ -768,77 +764,122 @@ CoreWidget::toggleLogger() { ...@@ -768,77 +764,122 @@ 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: { {
QList<int> wsizes(splitter_->sizes()); case OpenFlipper::Options::InScene:
{
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_);
baseLayout_->setContentsMargins(left, top, right, 16); slidingLogger_->attachWidget (logWidget_);
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 ();
splitter_->insertWidget(1, logWidget_); slidingLogger_->detachWidget ();
logWidget_->show(); splitter_->insertWidget (1, logWidget_);
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);
}
hideInSceneLogger(); break;
break; case OpenFlipper::Options::Hidden:
} {
case OpenFlipper::Options::Hidden: { 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 (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(); /*
break; if ( !_state ) {
} 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 ();
loggerState_ = _state; slidingLogger_->detachWidget ();
splitter_->insertWidget (1, logWidget_);
wsizes[0] = wsizes[0]+wsizes[1] - height;
wsizes[1] = height;
splitter_->setSizes(wsizes);
}
*/
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -1070,11 +1111,11 @@ CoreWidget::slotShowSceneGraphDialog() ...@@ -1070,11 +1111,11 @@ CoreWidget::slotShowSceneGraphDialog()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
CoreWidget::sceneRectChanged(const QRectF& _rect) CoreWidget::sceneRectChanged(const QRectF &rect)
{ {
centerWidget_->setGeometry (_rect); centerWidget_->setGeometry (rect);
if(loggerState_ == OpenFlipper::Options::InScene) slidingLogger_->updateGeometry ();
updateInSceneLoggerGeometry(_rect); pickToolbar_->updateGeometry();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -1119,5 +1160,13 @@ void CoreWidget::setForceNativeCursor ( bool _state ) ...@@ -1119,5 +1160,13 @@ 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,6 +74,7 @@ ...@@ -74,6 +74,7 @@
#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>
...@@ -476,6 +477,9 @@ public: ...@@ -476,6 +477,9 @@ public:
QSize defaultIconSize(); QSize defaultIconSize();
// Update pick toolbar settings
void updatePickToolbar();
public slots: public slots:
/// Show or hide toolbox /// Show or hide toolbox
...@@ -490,24 +494,6 @@ public: ...@@ -490,24 +494,6 @@ 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
* @{ */ * @{ */
...@@ -671,9 +657,8 @@ public: ...@@ -671,9 +657,8 @@ public:
/// Toolbox scroll area /// Toolbox scroll area
QScrollArea* toolBoxScroll_; QScrollArea* toolBoxScroll_;
/// Handle to picking toolbar /// Toolbar showed in pickmode
typedef std::map<QToolBar*,QGraphicsItem*> PickToolBarMap; QtPickToolbar* pickToolbar_;
PickToolBarMap curPickingToolbarItems_;
/// Cursor handling /// Cursor handling
CursorPainter* cursorPainter_; CursorPainter* cursorPainter_;
...@@ -704,7 +689,7 @@ public: ...@@ -704,7 +689,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
...@@ -1302,12 +1287,6 @@ public: ...@@ -1302,12 +1287,6 @@ 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
......
...@@ -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:
hidePickToolBar(); pickToolbar_->detachToolbar ();
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() )
setActivePickToolBar(pick_modes_[pick_mode_idx_].toolbar() ); pickToolbar_->attachToolbar (pick_modes_[pick_mode_idx_].toolbar() );
else else
hidePickToolBar(); pickToolbar_->detachToolbar ();
} }
break; break;
...@@ -177,45 +177,6 @@ void CoreWidget::getPickMode(std::string& _mode){ ...@@ -177,45 +177,6 @@ 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) {
...@@ -296,9 +257,9 @@ void CoreWidget::pickMode( int _id ) ...@@ -296,9 +257,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() )
setActivePickToolBar(pick_modes_[pick_mode_idx_].toolbar() ); pickToolbar_->attachToolbar (pick_modes_[pick_mode_idx_].toolbar() );
else else
hidePickToolBar(); pickToolbar_->detachToolbar ();
// adjust mouse tracking // adjust mouse tracking
if ( pickingMode() ) if ( pickingMode() )
...@@ -382,7 +343,7 @@ void CoreWidget::setPickModeToolbar( const std::string _mode , QToolBar * _toolb ...@@ -382,7 +343,7 @@ void CoreWidget::setPickModeToolbar( const std::string _mode , QToolBar * _toolb
// Activate the toolbar if this mode is currently active // Activate the toolbar if this mode is currently active
if (pick_mode_name_ == _mode && pickingMode() ) if (pick_mode_name_ == _mode && pickingMode() )
setActivePickToolBar(_toolbar); pickToolbar_->attachToolbar (_toolbar);
break; break;
} }
...@@ -398,7 +359,7 @@ void CoreWidget::removePickModeToolbar( const std::string _mode ) ...@@ -398,7 +359,7 @@ void CoreWidget::removePickModeToolbar( const std::string _mode )
pick_modes_[i].toolbar(0); pick_modes_[i].toolbar(0);
if (pick_mode_name_ == _mode && pickingMode() ) if (pick_mode_name_ == _mode && pickingMode() )
hidePickToolBar(); pickToolbar_->detachToolbar ();
break; break;
} }
} }
......
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *