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() {
windowStates.beginGroup ("Core");
windowStates.beginGroup ("LogSlider");
//coreWidget_->slidingLogger_->restoreState (windowStates);
coreWidget_->slidingLogger_->restoreState (windowStates);
windowStates.endGroup ();
coreWidget_->toolBox_->restoreState (windowStates);
windowStates.endGroup ();
......@@ -1043,7 +1043,7 @@ Core::writeOnExit() {
windowStates.beginGroup ("Core");
windowStates.beginGroup ("LogSlider");
//coreWidget_->slidingLogger_->saveState (windowStates);
coreWidget_->slidingLogger_->saveState (windowStates);
windowStates.endGroup ();
coreWidget_->toolBox_->saveState (windowStates);
windowStates.endGroup ();
......
......@@ -147,6 +147,9 @@ void Core::applyOptions(){
// toolbox orientation
coreWidget_->setToolBoxOrientationOnTheRight(OpenFlipperSettings().value("Core/Gui/ToolBoxes/ToolBoxOnTheRight",true).toBool());
// Update pick toolbar settings
coreWidget_->updatePickToolbar();
//set defaultBackgroundColor
QColor c = OpenFlipperSettings().value("Core/Gui/glViewer/defaultBackgroundColor").value<QColor>();
......
......@@ -146,9 +146,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
windowMenu_(0),
AC_ShowViewModeControls_(0),
AC_ShowToolbox_(0),
glScene_(0),
centerWidget_(0),
slidingLogger_(0),
pickToolbar_(0),
cursorPainter_(0),
sceneGraphDialog_(0),
fileMenu_(0),
......@@ -261,45 +259,37 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
// Set up the logging window
// ======================================================================
slidingLogger_ = new QtSlideWindow (tr("Log Viewer"));
slidingLogger_ = new QtSlideWindow (tr("Log Viewer"), centerWidget_);
tempLogWidget = new QWidget;
logWidget_ = new LoggerWidget(splitter_);
logWidget_->setSizePolicy( QSizePolicy ( QSizePolicy::Preferred , QSizePolicy::Preferred ) );
logWidget_->resize( splitter_->width(), 240);
// Attach sliding logger
slidingLogger_->attachWidget (logWidget_);
logWidget_->resize( splitter_->width() ,240);
originalLoggerSize_ = 0;
loggerState_ = OpenFlipper::Options::Normal;
// Add logger to gl scene
glScene_->addItem(slidingLogger_);
QList<int> wsizes( splitter_->sizes() );
if (OpenFlipper::Options::loggerState() == OpenFlipper::Options::InScene) {
slidingLogger_->attachWidget (logWidget_);
splitter_->insertWidget (1, tempLogWidget);
if(wsizes.size() > 0) wsizes[0] = 1;
if(wsizes.size() > 1) wsizes[1] = 0;
wsizes[0] = 1;
wsizes[1] = 0;
splitter_->setSizes(wsizes);
loggerState_ = OpenFlipper::Options::InScene;
baseLayout_->setContentsMargins (0, 0, 0, 16);
showInSceneLogger();
} else if (OpenFlipper::Options::loggerState() == OpenFlipper::Options::Hidden) {
splitter_->insertWidget (1, tempLogWidget);
if(wsizes.size() > 0) wsizes[0] = 1;
if(wsizes.size() > 1) wsizes[1] = 0;
wsizes[0] = 1;
wsizes[1] = 0;
splitter_->setSizes(wsizes);
loggerState_ = OpenFlipper::Options::Hidden;
hideInSceneLogger();
} else {
// Set initial values to have a usable state
if(wsizes.size() > 0) wsizes[0] = 480;
if(wsizes.size() > 1) wsizes[1] = 240;
wsizes[0] = 480;
wsizes[1] = 240;
splitter_->setSizes(wsizes);
hideInSceneLogger();
}
......@@ -508,6 +498,12 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
wsizes = splitter_->sizes();
originalLoggerSize_ = wsizes[1];
// ======================================================================
// Create pickmode toolbar
// ======================================================================
pickToolbar_ = new QtPickToolbar(this, centerWidget_, OpenFlipperSettings().value("Core/Gui/ToolBars/PickToolbarInScene",true).toBool());
// ======================================================================
// Create ToolBox area
// ======================================================================
......@@ -768,77 +764,122 @@ CoreWidget::toggleLogger() {
*/
void
CoreWidget::showLogger(OpenFlipper::Options::LoggerState _state) {
//Hide Logger
if (_state == loggerState_)
return;
//Hide Logger
if (_state == loggerState_)
return;
qreal left, top, right, bottom;
baseLayout_->getContentsMargins(&left, &top, &right, &bottom);
qreal left, top, right, bottom;
baseLayout_->getContentsMargins (&left, &top, &right, &bottom);
switch (_state) {
case OpenFlipper::Options::InScene: {
QList<int> wsizes(splitter_->sizes());
switch (_state)
{
case OpenFlipper::Options::InScene:
{
QList<int> wsizes( splitter_->sizes() );
// Remember old size
if (loggerState_ == OpenFlipper::Options::Normal)
originalLoggerSize_ = wsizes[1];
originalLoggerSize_ = wsizes[1];
if (originalLoggerSize_ == 0)
originalLoggerSize_ = 240;
if ( originalLoggerSize_ == 0)
originalLoggerSize_ = 240;
splitter_->insertWidget(1, tempLogWidget);
wsizes[0] = wsizes[0] + wsizes[1];
splitter_->insertWidget (1, tempLogWidget);
wsizes[0] = wsizes[0]+wsizes[1];
wsizes[1] = 0;
splitter_->setSizes(wsizes);
logWidget_->resize(logWidget_->width(), originalLoggerSize_);
baseLayout_->setContentsMargins(left, top, right, 16);
showInSceneLogger();
break;
}
case OpenFlipper::Options::Normal: {
if (originalLoggerSize_ == 0)
originalLoggerSize_ = 240;
logWidget_->resize (logWidget_->width (), originalLoggerSize_);
slidingLogger_->attachWidget (logWidget_);
baseLayout_->setContentsMargins (left, top, right, 16);
}
break;
case OpenFlipper::Options::Normal:
{
if ( originalLoggerSize_ == 0)
originalLoggerSize_ = 240;
QList<int> wsizes(splitter_->sizes());
QList<int> wsizes( splitter_->sizes() );
if (loggerState_ == OpenFlipper::Options::InScene)
originalLoggerSize_ = logWidget_->height();
originalLoggerSize_ = logWidget_->height ();
splitter_->insertWidget(1, logWidget_);
logWidget_->show();
slidingLogger_->detachWidget ();
splitter_->insertWidget (1, logWidget_);
logWidget_->show ();
wsizes[0] = wsizes[0] + wsizes[1] - originalLoggerSize_;
wsizes[0] = wsizes[0]+wsizes[1] - originalLoggerSize_;
wsizes[1] = originalLoggerSize_;
splitter_->setSizes(wsizes);
baseLayout_->setContentsMargins(left, top, right, 0);
hideInSceneLogger();
break;
}
case OpenFlipper::Options::Hidden: {
QList<int> wsizes(splitter_->sizes());
baseLayout_->setContentsMargins (left, top, right, 0);
}
break;
case OpenFlipper::Options::Hidden:
{
QList<int> wsizes( splitter_->sizes() );
// Remember old size
if (loggerState_ == OpenFlipper::Options::Normal)
originalLoggerSize_ = wsizes[1];
originalLoggerSize_ = wsizes[1];
if (loggerState_ == OpenFlipper::Options::InScene) {
originalLoggerSize_ = logWidget_->height();
}
if (loggerState_ == OpenFlipper::Options::InScene)
{
slidingLogger_->detachWidget ();
originalLoggerSize_ = logWidget_->height ();
}
splitter_->insertWidget(1, tempLogWidget);
wsizes[0] = wsizes[0] + wsizes[1];
splitter_->insertWidget (1, tempLogWidget);
wsizes[0] = wsizes[0]+wsizes[1];
wsizes[1] = 0;
splitter_->setSizes(wsizes);
baseLayout_->setContentsMargins(left, top, right, 0);
baseLayout_->setContentsMargins (left, top, right, 0);
}
break;
}
loggerState_ = _state;
hideInSceneLogger();
break;
}
} // End switch
/*
if ( !_state ) {
QList<int> wsizes( splitter_->sizes() );
// 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()
//-----------------------------------------------------------------------------
void
CoreWidget::sceneRectChanged(const QRectF& _rect)
CoreWidget::sceneRectChanged(const QRectF &rect)
{
centerWidget_->setGeometry (_rect);
if(loggerState_ == OpenFlipper::Options::InScene)
updateInSceneLoggerGeometry(_rect);
centerWidget_->setGeometry (rect);
slidingLogger_->updateGeometry ();
pickToolbar_->updateGeometry();
}
//-----------------------------------------------------------------------------
......@@ -1119,5 +1160,13 @@ void CoreWidget::setForceNativeCursor ( bool _state )
cursorPainter_->setForceNative (_state);
}
//-----------------------------------------------------------------------------
void CoreWidget::updatePickToolbar() {
pickToolbar_->detachToolbar();
pickToolbar_->setRenderFlag(OpenFlipperSettings().value("Core/Gui/ToolBars/PickToolbarInScene", true).toBool());
}
//=============================================================================
......@@ -74,6 +74,7 @@
#include <OpenFlipper/widgets/glWidget/QtGLGraphicsView.hh>
#include <OpenFlipper/widgets/glWidget/QtMultiViewLayout.hh>
#include <OpenFlipper/widgets/glWidget/QtSlideWindow.hh>
#include <OpenFlipper/widgets/glWidget/QtPickToolbar.hh>
// QT INCLUDES
#include <QMainWindow>
......@@ -476,6 +477,9 @@ public:
QSize defaultIconSize();
// Update pick toolbar settings
void updatePickToolbar();
public slots:
/// Show or hide toolbox
......@@ -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
* @{ */
......@@ -671,9 +657,8 @@ public:
/// Toolbox scroll area
QScrollArea* toolBoxScroll_;
/// Handle to picking toolbar
typedef std::map<QToolBar*,QGraphicsItem*> PickToolBarMap;
PickToolBarMap curPickingToolbarItems_;
/// Toolbar showed in pickmode
QtPickToolbar* pickToolbar_;
/// Cursor handling
CursorPainter* cursorPainter_;
......@@ -704,7 +689,7 @@ public:
/** Updates the size of the main graphics widget in the scene
*/
void sceneRectChanged(const QRectF& _rect);
void sceneRectChanged(const QRectF &rect);
//===========================================================================
/** @name Menubar controls
......@@ -1302,12 +1287,6 @@ public:
void getPickMode(std::string& _name);
/// Set toolbar to be active pick toolbar
void setActivePickToolBar(QToolBar* _tool);
/// Hide picking toolbar
void hidePickToolBar();
public slots:
/** \brief set a new cursor for the pick mode
......
......@@ -110,16 +110,16 @@ void CoreWidget::setActionMode(const Viewer::ActionMode _am){
// Update pickmode toolbar
switch ( _am ) {
case Viewer::ExamineMode:
hidePickToolBar();
pickToolbar_->detachToolbar ();
break;
case Viewer::PickingMode:
// Show the pickMode Toolbar for this picking mode if it is set
if (pick_mode_idx_ != -1) {
if (pick_modes_[pick_mode_idx_].toolbar() )
setActivePickToolBar(pick_modes_[pick_mode_idx_].toolbar() );
pickToolbar_->attachToolbar (pick_modes_[pick_mode_idx_].toolbar() );
else
hidePickToolBar();
pickToolbar_->detachToolbar ();
}
break;
......@@ -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()
{
if (pickMenu_ != 0) {
......@@ -296,9 +257,9 @@ void CoreWidget::pickMode( int _id )
pick_mode_name_ = pick_modes_[pick_mode_idx_].name();
if (pick_modes_[pick_mode_idx_].toolbar() )
setActivePickToolBar(pick_modes_[pick_mode_idx_].toolbar() );
pickToolbar_->attachToolbar (pick_modes_[pick_mode_idx_].toolbar() );
else
hidePickToolBar();
pickToolbar_->detachToolbar ();
// adjust mouse tracking
if ( pickingMode() )
......@@ -382,7 +343,7 @@ void CoreWidget::setPickModeToolbar( const std::string _mode , QToolBar * _toolb
// Activate the toolbar if this mode is currently active
if (pick_mode_name_ == _mode && pickingMode() )
setActivePickToolBar(_toolbar);
pickToolbar_->attachToolbar (_toolbar);
break;
}
......@@ -398,7 +359,7 @@ void CoreWidget::removePickModeToolbar( const std::string _mode )
pick_modes_[i].toolbar(0);
if (pick_mode_name_ == _mode && pickingMode() )
hidePickToolBar();
pickToolbar_->detachToolbar ();
break;
}
}
......
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
//
// CLASS QtPickToolbar
//
//=============================================================================
//== GLOBAL DEFINITIONS=========================================================
#define BACKGROUND_RED 0xff
#define BACKGROUND_GREEN 0xff
#define BACKGROUND_BLUE 0xff
#define BACKGROUND_ALPHA 0xcf
#define SLIDE_DURATION 1000
//== INCLUDES =================================================================
#include <OpenFlipper/common/GlobalOptions.hh>
#include <QPainter>
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QDialog>
#include <QVBoxLayout>
#include <QToolBar>
#include <QStatusBar>
#include <QStatusTipEvent>
#include "QtPickToolbar.hh"
#include "QtGraphicsButton.hh"
//== IMPLEMENTATION ==========================================================
QtPickToolbar::QtPickToolbar(QMainWindow *_core, QGraphicsItem *_parent, bool _renderInScene) :
QGraphicsProxyWidget(_parent),
toolbar_(0),
core_(_core),
renderInScene_(_renderInScene)
{
setCacheMode (QGraphicsItem::DeviceCoordinateCache);
setWindowFrameMargins (2, 2, 2, 2);
setZValue (2.0);
hide ();
}
//-----------------------------------------------------------------------------
void QtPickToolbar::attachToolbar (QToolBar *_t)
{
if (!_t) {
detachToolbar();
return;
}
if (_t == toolbar_)
return;
if (renderInScene_) {
toolbar_ = _t;
toolbar_->setOrientation(Qt::Horizontal);
toolbar_->setParent(0);
setWidget(toolbar_);
setWindowFlags(Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint);
show();
updateGeometry();
} else {
// Remove old toolbar
if(toolbar_) {
core_->removeToolBar(toolbar_);
}
toolbar_ = _t;
core_->addToolBar(Qt::LeftToolBarArea, toolbar_);
toolbar_->setOrientation(Qt::Vertical);
toolbar_->show();
}
}
//-----------------------------------------------------------------------------
void QtPickToolbar::detachToolbar ()
{
if (renderInScene_) {
if (toolbar_) {
setWidget(0);
hide();
toolbar_->setParent(0);
toolbar_ = 0;
}
} else {
if(toolbar_) {
toolbar_->hide();
core_->removeToolBar(toolbar_);
toolbar_->setParent(0);
toolbar_ = 0;
}
}
}
//-----------------------------------------------------------------------------
void QtPickToolbar::paintWindowFrame(QPainter *_painter,
const QStyleOptionGraphicsItem* /*_option*/,
QWidget* /*_widget*/ )
{
if(!renderInScene_) return;
int w = geometry().width();
int h = geometry().height();
_painter->setRenderHint(QPainter::Antialiasing, true);
_painter->setBrush(QBrush(QColor(BACKGROUND_RED,
BACKGROUND_GREEN,
BACKGROUND_BLUE,
BACKGROUND_ALPHA)));
_painter->setPen(QColor(BACKGROUND_RED / 4,
BACKGROUND_GREEN / 4,
BACKGROUND_BLUE / 4,
BACKGROUND_ALPHA));
_painter->drawRoundedRect(-2, -6, w + 4, h + 8, 4, 4);
_painter->setPen(Qt::SolidLine);
}
//-----------------------------------------------------------------------------
Qt::WindowFrameSection QtPickToolbar::windowFrameSectionAt(const QPointF &/*_pos*/) const
{
return Qt::NoSection;
}
//-----------------------------------------------------------------------------
void QtPickToolbar::updateGeometry ()
{
if(!renderInScene_) return;
if (parentWidget () && widget ())
{
resize (qMin ((int)parentWidget ()->geometry ().width () - 20, widget ()->sizeHint ().width ()),
widget ()->sizeHint ().height ());
setPos ((parentWidget ()->geometry ().width () - geometry ().width ()) / 2, 0);
}
}
//-----------------------------------------------------------------------------
bool QtPickToolbar::eventFilter(QObject *_obj, QEvent *_event)
{
if(!renderInScene_) return false;
/* The QGraphicsProxyWidged does not sent the StatusTip messages to the main
application window status bar. So we have to do it manually.
*/
if (_event->type () == QEvent::StatusTip)
{
if (core_->statusBar ())
core_->statusBar ()->showMessage (dynamic_cast<QStatusTipEvent *>(_event)->tip());
return QGraphicsProxyWidget::eventFilter(_obj, _event);
}
else
return QGraphicsProxyWidget::eventFilter(_obj, _event);
}
//=============================================================================
//=============================================================================
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *