Commit 0e4080c9 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 c64afb50
...@@ -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,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -146,7 +146,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
windowMenu_(0), windowMenu_(0),
AC_ShowViewModeControls_(0), AC_ShowViewModeControls_(0),
AC_ShowToolbox_(0), AC_ShowToolbox_(0),
pickToolbar_(0),
cursorPainter_(0), cursorPainter_(0),
sceneGraphDialog_(0), sceneGraphDialog_(0),
fileMenu_(0), fileMenu_(0),
...@@ -498,12 +497,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -498,12 +497,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
// ====================================================================== // ======================================================================
...@@ -1115,7 +1108,6 @@ CoreWidget::sceneRectChanged(const QRectF &rect) ...@@ -1115,7 +1108,6 @@ CoreWidget::sceneRectChanged(const QRectF &rect)
{ {
centerWidget_->setGeometry (rect); centerWidget_->setGeometry (rect);
slidingLogger_->updateGeometry (); slidingLogger_->updateGeometry ();
pickToolbar_->updateGeometry();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -1160,13 +1152,5 @@ void CoreWidget::setForceNativeCursor ( bool _state ) ...@@ -1160,13 +1152,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>
...@@ -476,9 +475,6 @@ public: ...@@ -476,9 +475,6 @@ public:
void setForceNativeCursor ( bool _state ); void setForceNativeCursor ( bool _state );
QSize defaultIconSize(); QSize defaultIconSize();
// Update pick toolbar settings
void updatePickToolbar();
public slots: public slots:
...@@ -657,8 +653,9 @@ public: ...@@ -657,8 +653,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_;
...@@ -1287,6 +1284,12 @@ public: ...@@ -1287,6 +1284,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
......
...@@ -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, 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() 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
// 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() )
pickToolbar_->attachToolbar (_toolbar); setActivePickToolBar(_toolbar);
break; break;
} }
...@@ -359,7 +398,7 @@ void CoreWidget::removePickModeToolbar( const std::string _mode ) ...@@ -359,7 +398,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() )
pickToolbar_->detachToolbar (); hidePickToolBar();
break; break;
} }
} }
......
...@@ -289,8 +289,6 @@ void OptionsWidget::showEvent ( QShowEvent * /*event*/ ) { ...@@ -289,8 +289,6 @@ void OptionsWidget::showEvent ( QShowEvent * /*event*/ ) {
// UI settings // UI settings
toolBoxOrientation->setCurrentIndex((OpenFlipperSettings().value("Core/Gui/ToolBoxes/ToolBoxOnTheRight",true).toBool() ? 0 : 1)); toolBoxOrientation->setCurrentIndex((OpenFlipperSettings().value("Core/Gui/ToolBoxes/ToolBoxOnTheRight",true).toBool() ? 0 : 1));
pickToolbarInScene->setChecked(OpenFlipperSettings().value("Core/Gui/ToolBars/PickToolbarInScene",true).toBool());
//stereo //stereo
...@@ -620,9 +618,6 @@ void OptionsWidget::slotApply() { ...@@ -620,9 +618,6 @@ void OptionsWidget::slotApply() {
// Toolbox orientation // Toolbox orientation
OpenFlipperSettings().setValue("Core/Gui/ToolBoxes/ToolBoxOnTheRight", (toolBoxOrientation->currentIndex() == 0)); 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() ) if ( iconDefault->isChecked() )
OpenFlipperSettings().setValue("Core/Toolbar/iconSize", 0); OpenFlipperSettings().setValue("Core/Toolbar/iconSize", 0);
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<string/> <string/>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>6</number> <number>0</number>
</property> </property>
<property name="usesScrollButtons"> <property name="usesScrollButtons">
<bool>true</bool> <bool>true</bool>
...@@ -138,33 +138,6 @@ ...@@ -138,33 +138,6 @@
</widget> </widget>
</widget> </widget>
</item> </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> <item>
<widget class="QGroupBox" name="groupBox_11"> <widget class="QGroupBox" name="groupBox_11">
<property name="title"> <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