Commit 79f290fa authored by Mike Kremer's avatar Mike Kremer
Browse files

Render picking toolbar directly into graphics scene.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@11965 383ad7c9-94d9-4d36-a494-682f7c89f535
parent a1397b09
......@@ -147,9 +147,6 @@ 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,7 +146,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
windowMenu_(0),
AC_ShowViewModeControls_(0),
AC_ShowToolbox_(0),
pickToolbar_(0),
cursorPainter_(0),
sceneGraphDialog_(0),
fileMenu_(0),
......@@ -498,12 +497,6 @@ 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
// ======================================================================
......@@ -1115,7 +1108,6 @@ CoreWidget::sceneRectChanged(const QRectF &rect)
{
centerWidget_->setGeometry (rect);
slidingLogger_->updateGeometry ();
pickToolbar_->updateGeometry();
}
//-----------------------------------------------------------------------------
......@@ -1160,13 +1152,5 @@ void CoreWidget::setForceNativeCursor ( bool _state )
cursorPainter_->setForceNative (_state);
}
//-----------------------------------------------------------------------------
void CoreWidget::updatePickToolbar() {
pickToolbar_->detachToolbar();
pickToolbar_->setRenderFlag(OpenFlipperSettings().value("Core/Gui/ToolBars/PickToolbarInScene", true).toBool());
}
//=============================================================================
......@@ -74,7 +74,6 @@
#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,9 +475,6 @@ public:
void setForceNativeCursor ( bool _state );
QSize defaultIconSize();
// Update pick toolbar settings
void updatePickToolbar();
public slots:
......@@ -657,8 +653,9 @@ public:
/// Toolbox scroll area
QScrollArea* toolBoxScroll_;
/// Toolbar showed in pickmode
QtPickToolbar* pickToolbar_;
/// Handle to picking toolbar
typedef std::map<QToolBar*,QGraphicsItem*> PickToolBarMap;
PickToolBarMap curPickingToolbarItems_;
/// Cursor handling
CursorPainter* cursorPainter_;
......@@ -1287,6 +1284,12 @@ 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:
pickToolbar_->detachToolbar ();
hidePickToolBar();
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() )
pickToolbar_->attachToolbar (pick_modes_[pick_mode_idx_].toolbar() );
setActivePickToolBar(pick_modes_[pick_mode_idx_].toolbar());
else
pickToolbar_->detachToolbar ();
hidePickToolBar();
}
break;
......@@ -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, 3);
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) {
......@@ -257,9 +296,9 @@ void CoreWidget::pickMode( int _id )
pick_mode_name_ = pick_modes_[pick_mode_idx_].name();
if (pick_modes_[pick_mode_idx_].toolbar() )
pickToolbar_->attachToolbar (pick_modes_[pick_mode_idx_].toolbar() );
setActivePickToolBar(pick_modes_[pick_mode_idx_].toolbar());
else
pickToolbar_->detachToolbar ();
hidePickToolBar();
// adjust mouse tracking
if ( pickingMode() )
......@@ -343,7 +382,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() )
pickToolbar_->attachToolbar (_toolbar);
setActivePickToolBar(_toolbar);
break;
}
......@@ -359,7 +398,7 @@ void CoreWidget::removePickModeToolbar( const std::string _mode )
pick_modes_[i].toolbar(0);
if (pick_mode_name_ == _mode && pickingMode() )
pickToolbar_->detachToolbar ();
hidePickToolBar();
break;
}
}
......
......@@ -289,8 +289,6 @@ 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
......@@ -620,9 +618,6 @@ 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);
......
......@@ -23,7 +23,7 @@
<string/>
</property>
<property name="currentIndex">
<number>6</number>
<number>0</number>
</property>
<property name="usesScrollButtons">
<bool>true</bool>
......@@ -138,33 +138,6 @@
</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