Commit bdbe5043 authored by Mike Kremer's avatar Mike Kremer

Introduced option that lets the user decide whether the pick toolbar should be...

Introduced option that lets the user decide whether the pick toolbar should be rendered directly into the scene (this sometimes crashes on some machines) or rather be attached as toolbar to the main widget.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@11638 383ad7c9-94d9-4d36-a494-682f7c89f535
parent ba565d99
......@@ -145,6 +145,8 @@ 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>();
......
......@@ -96,6 +96,7 @@
* * Core/Gui/glViewer/minimalSceneSize The minimal scene radius. If the scene is smaller, than the size will be set to this value (double)\n
* * Core/Gui/ToolBoxes/hidden Hide the toolbox sidebar (bool)\n
* * Core/Gui/ToolBoxes/ToolBoxOnTheRight Toolbox on the right or on the left (bool)\n
* * Core/Gui/ToolBars/PickToolbarInScene Render picking toolbar into gl scene or as toolbox into main widget
* * Core/Gui/TaskSwitcher/Hide Show or Hide the task switcher(bool)\n
* * Core/Gui/LogWindow/LogWindowMode Log Window Mode .. 0 InScene, 1 Window, 2 Hidden (int)\n
* * Core/Gui/LogWindow/OpenMeshErrors Log OpenMesh Errors? (bool)\n
......
......@@ -498,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
// ======================================================================
......@@ -1109,6 +1115,7 @@ CoreWidget::sceneRectChanged(const QRectF &rect)
{
centerWidget_->setGeometry (rect);
slidingLogger_->updateGeometry ();
pickToolbar_->updateGeometry();
}
//-----------------------------------------------------------------------------
......@@ -1153,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());
}
//=============================================================================
......@@ -477,6 +477,9 @@ public:
QSize defaultIconSize();
// Update pick toolbar settings
void updatePickToolbar();
public slots:
/// Show or hide toolbox
......@@ -655,7 +658,7 @@ public:
QScrollArea* toolBoxScroll_;
/// Toolbar showed in pickmode
QToolBar* pickToolbar_;
QtPickToolbar* pickToolbar_;
/// Cursor handling
CursorPainter* cursorPainter_;
......
......@@ -106,45 +106,38 @@ void CoreWidget::setActionMode(const Viewer::ActionMode _am){
cursorPainter_->setCursor(QCursor( QPixmap( OpenFlipper::Options::iconDirStr() + QDir::separator() + "cursor_whatsthis.png" ) ,0,0 ));
break;
}
// update toolbar
switch ( _am )
{
// Update pickmode toolbar
switch ( _am ) {
case Viewer::ExamineMode:
if ( pickToolbar_ != 0) {
pickToolbar_->hide();
removeToolBar(pickToolbar_);
pickToolbar_ = 0;
}
break;
case Viewer::LightMode:
pickToolbar_->detachToolbar ();
break;
case Viewer::PickingMode:
// Show the pickMode Toolbar for this picking mode if it is set
if ((pick_mode_idx_ != -1) && pick_modes_[pick_mode_idx_].toolbar() ) {
if ( pickToolbar_ != 0) {
// Remove old toolbar
pickToolbar_->hide();
removeToolBar(pickToolbar_);
pickToolbar_ = 0;
}
pickToolbar_ = pick_modes_[pick_mode_idx_].toolbar();
pickToolbar_->setOrientation(Qt::Vertical);
addToolBar(Qt::LeftToolBarArea,pickToolbar_);
pickToolbar_->show();
if (pick_mode_idx_ != -1) {
if (pick_modes_[pick_mode_idx_].toolbar() )
pickToolbar_->attachToolbar (pick_modes_[pick_mode_idx_].toolbar() );
else
pickToolbar_->detachToolbar ();
}
break;
case Viewer::QuestionMode:
default:
break;
}
//update Viewers
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
examiner_widgets_[i]->sceneGraph( PluginFunctions::getSceneGraphRootNode() );
examiner_widgets_[i]->trackMouse(false);
if(_am == Viewer::PickingMode) {
if (pick_mode_idx_ != -1) {
examiner_widgets_[i]->trackMouse(pick_modes_[pick_mode_idx_].tracking() );
}
}
}
//emit pickmodeChanged with either the name of the current pickmode or an empty string
......@@ -263,27 +256,10 @@ void CoreWidget::pickMode( int _id )
pick_mode_idx_ = _id;
pick_mode_name_ = pick_modes_[pick_mode_idx_].name();
if (pick_modes_[pick_mode_idx_].toolbar() ) {
if ( pickToolbar_ != 0) {
// Remove old toolbar
pickToolbar_->hide();
removeToolBar(pickToolbar_);
pickToolbar_ = 0;
}
pickToolbar_ = pick_modes_[pick_mode_idx_].toolbar();
pickToolbar_->setOrientation(Qt::Vertical);
addToolBar(Qt::LeftToolBarArea,pickToolbar_);
pickToolbar_->show();
} else
if ( pickToolbar_ != 0) {
// Remove old toolbar
pickToolbar_->hide();
removeToolBar(pickToolbar_);
pickToolbar_ = 0;
}
if (pick_modes_[pick_mode_idx_].toolbar() )
pickToolbar_->attachToolbar (pick_modes_[pick_mode_idx_].toolbar() );
else
pickToolbar_->detachToolbar ();
// adjust mouse tracking
if ( pickingMode() )
......@@ -366,20 +342,8 @@ void CoreWidget::setPickModeToolbar( const std::string _mode , QToolBar * _toolb
pick_modes_[i].toolbar( _toolbar );
// Activate the toolbar if this mode is currently active
if (pick_mode_name_ == _mode && pickingMode() ) {
if ( pickToolbar_ != 0) {
// Remove old toolbar
pickToolbar_->hide();
removeToolBar(pickToolbar_);
pickToolbar_ = 0;
}
pickToolbar_ = _toolbar;
pickToolbar_->setOrientation(Qt::Vertical);
addToolBar(Qt::LeftToolBarArea,pickToolbar_);
pickToolbar_->show();
}
if (pick_mode_name_ == _mode && pickingMode() )
pickToolbar_->attachToolbar (_toolbar);
break;
}
......@@ -395,12 +359,7 @@ void CoreWidget::removePickModeToolbar( const std::string _mode )
pick_modes_[i].toolbar(0);
if (pick_mode_name_ == _mode && pickingMode() )
if ( pickToolbar_ != 0) {
// Remove old toolbar
pickToolbar_->hide();
removeToolBar(pickToolbar_);
pickToolbar_ = 0;
}
pickToolbar_->detachToolbar ();
break;
}
}
......
......@@ -79,10 +79,11 @@
//== IMPLEMENTATION ==========================================================
QtPickToolbar::QtPickToolbar(QMainWindow *_core, QGraphicsItem *_parent) :
QtPickToolbar::QtPickToolbar(QMainWindow *_core, QGraphicsItem *_parent, bool _renderInScene) :
QGraphicsProxyWidget(_parent),
toolbar_(0),
core_(_core)
core_(_core),
renderInScene_(_renderInScene)
{
setCacheMode (QGraphicsItem::DeviceCoordinateCache);
setWindowFrameMargins (2, 2, 2, 2);
......@@ -95,37 +96,58 @@ QtPickToolbar::QtPickToolbar(QMainWindow *_core, QGraphicsItem *_parent) :
void QtPickToolbar::attachToolbar (QToolBar *_t)
{
if (!_t)
{
detachToolbar ();
return;
}
if (!_t) {
detachToolbar();
return;
}
if (_t == toolbar_)
return;
if (renderInScene_) {
if (_t == toolbar_)
return;
toolbar_ = _t;
toolbar_->setOrientation(Qt::Horizontal);
toolbar_->setParent(0);
toolbar_ = _t;
toolbar_->setParent(0);
setWidget(toolbar_);
setWindowFlags(Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint);
setWidget (toolbar_);
setWindowFlags(Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint);
show();
show ();
updateGeometry();
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 (toolbar_)
{
setWidget (0);
hide ();
toolbar_->setParent(0);
toolbar_ = 0;
}
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;
}
}
}
//-----------------------------------------------------------------------------
......@@ -134,6 +156,8 @@ void QtPickToolbar::paintWindowFrame(QPainter *_painter,
const QStyleOptionGraphicsItem* /*_option*/,
QWidget* /*_widget*/ )
{
if(!renderInScene_) return;
int w = geometry().width();
int h = geometry().height();
......@@ -164,6 +188,8 @@ Qt::WindowFrameSection QtPickToolbar::windowFrameSectionAt(const QPointF &/*_pos
void QtPickToolbar::updateGeometry ()
{
if(!renderInScene_) return;
if (parentWidget () && widget ())
{
resize (qMin ((int)parentWidget ()->geometry ().width () - 20, widget ()->sizeHint ().width ()),
......@@ -176,6 +202,7 @@ void QtPickToolbar::updateGeometry ()
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.
*/
......
......@@ -77,7 +77,7 @@ class DLLEXPORT QtPickToolbar : public QGraphicsProxyWidget
/** Create a pick toolbar.
\param _parent parent graphics item
*/
QtPickToolbar (QMainWindow *_core, QGraphicsItem *_parent = 0);
QtPickToolbar (QMainWindow *_core, QGraphicsItem *_parent = 0, bool _renderInScene = true);
/// recalculate geometry
void updateGeometry ();
......@@ -88,6 +88,9 @@ class DLLEXPORT QtPickToolbar : public QGraphicsProxyWidget
/// detach toolbar
void detachToolbar ();
// Set rendering flag
void setRenderFlag(bool _inScene) { renderInScene_ = _inScene; }
private:
/// paints decoration
......@@ -105,6 +108,9 @@ class DLLEXPORT QtPickToolbar : public QGraphicsProxyWidget
QToolBar *toolbar_;
QMainWindow *core_;
// Render pick toolbar into scene
bool renderInScene_;
};
//=============================================================================
......
......@@ -284,6 +284,8 @@ void OptionsWidget::showEvent ( QShowEvent * /*event*/ ) {
// UI settings
toolBoxOrientation->setCurrentIndex((OpenFlipperSettings().value("Core/Gui/ToolBoxes/ToolBoxOnTheRight",true).toBool() ? 0 : 1));
pickToolbarInScene->setChecked(OpenFlipperSettings().value("Core/Gui/ToolBars/PickToolbarInScene",true).toBool());
//stereo
// Grey out OpenGL stereo mode option if not available
......@@ -612,8 +614,10 @@ void OptionsWidget::slotApply() {
// Toolbox orientation
OpenFlipperSettings().setValue("Core/Gui/ToolBoxes/ToolBoxOnTheRight", (toolBoxOrientation->currentIndex() == 0));
// Render picking toolbar into scene
OpenFlipperSettings().setValue("Core/Gui/ToolBars/PickToolbarInScene", pickToolbarInScene->isChecked());
if ( iconDefault->isChecked() )
OpenFlipperSettings().setValue("Core/Toolbar/iconSize", 0);
else if ( iconSmall->isChecked() )
......
......@@ -32,7 +32,7 @@
<attribute name="title">
<string>General</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout_21">
<item>
<widget class="QCheckBox" name="fullscreen">
<property name="toolTip">
......@@ -138,6 +138,33 @@
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_13">
<property name="title">
<string>Pick Toolbar</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout_6">
<item row="0" column="0">
<widget class="QLabel" name="label_29">
<property name="text">
<string>Render pick toolbar into scene</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="pickToolbarInScene">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_11">
<property name="title">
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment