Commit a4e0a50a authored by Jan Möbius's avatar Jan Möbius

Dennis:

Added-pick-mode-toolbar-interface



git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5976 383ad7c9-94d9-4d36-a494-682f7c89f535
parent f775cf4e
......@@ -92,6 +92,23 @@ class PickingInterface {
*/
virtual void setPickModeMouseTracking( const std::string /*_mode*/ , bool /*_mouseTracking*/ ) {};
/** \brief Set the additinal toolbar of the given PickMode
*
* Set the additional toolbar that should be shown in the pickMode
*
* @param _mode Identifier of Picking mode
* @param _toolbar the toolbar
*/
virtual void setPickModeToolbar( const std::string /*_mode*/ , QToolBar * /*_toolbar*/ ) {};
/** \brief Removes the additinal toolbar of the given PickMode
*
* Set the additional toolbar that should be shown in the pickMode
*
* @param _mode Identifier of Picking mode
*/
virtual void removePickModeToolbar( const std::string /*_mode*/ ) {};
/** \brief The pickingMode has changed
*
* This slot is called if the user changes the current picking mode
......
......@@ -738,11 +738,19 @@ void Core::loadPlugin(QString filename, bool silent){
connect(plugin,SIGNAL(setPickModeCursor( const std::string ,QCursor)),
coreWidget_,SLOT(setPickModeCursor( const std::string ,QCursor)),Qt::DirectConnection);
if ( checkSignal(plugin,"setPickModeMouseTracking(const std::string,bool)") )
for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
connect(plugin,SIGNAL(setPickModeMouseTracking( const std::string ,bool)),
coreWidget_,SLOT(setPickModeMouseTracking( const std::string ,bool)),Qt::DirectConnection);
if ( checkSignal(plugin,"setPickModeToolbar(const std::string,QToolBar*)") )
connect(plugin,SIGNAL(setPickModeToolbar (const std::string, QToolBar*)),
coreWidget_,SLOT(setPickModeToolbar (const std::string, QToolBar*)),Qt::DirectConnection);
if ( checkSignal(plugin,"removePickModeToolbar(const std::string)") )
connect(plugin,SIGNAL(removePickModeToolbar( const std::string)),
coreWidget_,SLOT(removePickModeToolbar( const std::string)),Qt::DirectConnection);
}
//Check if the plugin supports INI-Interface
......
......@@ -456,6 +456,11 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
wsizes[1] = 240;
toolSplitter_->setSizes(wsizes);
// ======================================================================
// Create pick ToolBar
// ======================================================================
pickToolbar_ = new QtPickToolbar (this, centerWidget_);
// ======================================================================
// Context menu setup
......@@ -856,6 +861,7 @@ CoreWidget::sceneRectChanged(const QRectF &rect)
{
centerWidget_->setGeometry (rect);
slidingLogger_->updateGeometry ();
pickToolbar_->updateGeometry ();
}
......
......@@ -63,6 +63,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>
......@@ -431,6 +432,9 @@ public:
/// Toolbox scroll area
QScrollArea* toolBoxScroll_;
/// Toolbar showed in pickmode
QtPickToolbar* pickToolbar_;
// widget showing the scenegraph
ACG::QtWidgets::QtSceneGraphDialog* sceneGraphDialog_;
......@@ -952,6 +956,23 @@ public:
*/
void setPickModeMouseTracking(const std::string& _name, bool _mouseTracking);
/** \brief Set the additinal toolbar of the given PickMode
*
* Set the additional toolbar that should be shown in the pickMode
*
* @param _mode Identifier of Picking mode
* @param _toolbar the toolbar
*/
void setPickModeToolbar( const std::string _mode , QToolBar * _toolbar );
/** \brief Removes the additinal toolbar of the given PickMode
*
* Set the additional toolbar that should be shown in the pickMode
*
* @param _mode Identifier of Picking mode
*/
void removePickModeToolbar( const std::string _mode );
void actionPickMenu( QAction * _action );
signals:
......@@ -968,8 +989,8 @@ public:
struct PickMode
{
/// Constructor
PickMode(const std::string& _n, bool _t, bool _v, QCursor _c) :
name(_n), tracking(_t), visible(_v), cursor(_c) {}
PickMode(const std::string& _n, bool _t, bool _v, QCursor _c, QToolBar *_tb = NULL) :
name(_n), tracking(_t), visible(_v), cursor(_c), toolbar(_tb) {}
/// Name of the pickMode
std::string name;
......@@ -985,6 +1006,10 @@ public:
/** Cursor used in this pickMode
*/
QCursor cursor;
/** Additinal toolbar showd in this pickMode
*/
QToolBar * toolbar;
};
/** Vector of all Picking modes
......
......@@ -105,6 +105,7 @@ void CoreWidget::setActionMode(const Viewer::ActionMode _am){
case Viewer::ExamineMode:
{
examiner_widgets_[i]->setCursor(Qt::PointingHandCursor);
pickToolbar_->detachToolbar ();
break;
}
......@@ -122,6 +123,10 @@ void CoreWidget::setActionMode(const Viewer::ActionMode _am){
if (pick_mode_idx_ != -1) {
examiner_widgets_[i]->trackMouse(pick_modes_[pick_mode_idx_].tracking);
examiner_widgets_[i]->setCursor(pick_modes_[pick_mode_idx_].cursor);
if (pick_modes_[pick_mode_idx_].toolbar)
pickToolbar_->attachToolbar (pick_modes_[pick_mode_idx_].toolbar);
else
pickToolbar_->detachToolbar ();
}
break;
......@@ -252,6 +257,11 @@ 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)
pickToolbar_->attachToolbar (pick_modes_[pick_mode_idx_].toolbar);
else
pickToolbar_->detachToolbar ();
// adjust mouse tracking
if ( pickingMode() )
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
......@@ -261,7 +271,6 @@ void CoreWidget::pickMode( int _id )
if ( pickingMode() )
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
examiner_widgets_[i]->setCursor( pick_modes_[pick_mode_idx_].cursor);
// emit signal
emit(signalPickModeChanged(pick_mode_name_));
......@@ -325,6 +334,33 @@ void CoreWidget::setPickModeMouseTracking(const std::string& _name, bool _mouseT
//-----------------------------------------------------------------------------
void CoreWidget::setPickModeToolbar( const std::string _mode , QToolBar * _toolbar )
{
for (uint i=0; i < pick_modes_.size(); i++)
if ( pick_modes_[i].name == _mode ){
pick_modes_[i].toolbar = _toolbar;
if (pick_mode_name_ == _mode && pickingMode() )
pickToolbar_->attachToolbar (_toolbar);
break;
}
}
//-----------------------------------------------------------------------------
void CoreWidget::removePickModeToolbar( const std::string _mode )
{
for (uint i=0; i < pick_modes_.size(); i++)
if ( pick_modes_[i].name == _mode ){
pick_modes_[i].toolbar = NULL;
if (pick_mode_name_ == _mode && pickingMode() )
pickToolbar_->detachToolbar ();
break;
}
}
//-----------------------------------------------------------------------------
void CoreWidget::clearPickModes()
{
......
//=============================================================================
//
// OpenFlipper
// Copyright (C) 2008 by Computer Graphics Group, RWTH Aachen
// www.openflipper.org
//
//-----------------------------------------------------------------------------
//
// License
//
// 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.
//
// 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 Lesser General Public License
// along with OpenFlipper. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
//
// $Revision: 5601 $
// $Author: moebius $
// $Date: 2009-04-09 09:19:47 +0200 (Do, 09. Apr 2009) $
//
//=============================================================================
//=============================================================================
//
// 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) :
QGraphicsProxyWidget(_parent),
toolbar_(0),
core_(_core)
{
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;
toolbar_ = _t;
toolbar_->setParent(0);
setWidget (toolbar_);
setWindowFlags(Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint);
show ();
updateGeometry ();
}
//-----------------------------------------------------------------------------
void QtPickToolbar::detachToolbar ()
{
if (toolbar_)
{
setWidget (0);
hide ();
toolbar_->setParent(0);
toolbar_ = 0;
}
}
//-----------------------------------------------------------------------------
void QtPickToolbar::paintWindowFrame(QPainter *_painter,
const QStyleOptionGraphicsItem* /*_option*/,
QWidget* /*_widget*/ )
{
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 (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)
{
/* 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) 2008 by Computer Graphics Group, RWTH Aachen
// www.openflipper.org
//
//-----------------------------------------------------------------------------
//
// License
//
// 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.
//
// 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 Lesser General Public License
// along with OpenFlipper. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
//
// $Revision: 5222 $
// $Author: moebius $
// $Date: 2009-03-07 10:34:38 +0100 (Sa, 07. Mär 2009) $
//
//=============================================================================
#ifndef QT_PICK_TOOLBAR_
#define QT_PICK_TOOLBAR_
//=============================================================================
//
// CLASS QtPickToolbar
//
//=============================================================================
//== INCLUDES =================================================================
#include <QSettings>
#include <QMainWindow>
#include <QGraphicsProxyWidget>
#include <OpenFlipper/common/GlobalDefines.hh>
//== FORWARDDECLARATIONS ======================================================
class QToolBar;
//== CLASS DEFINITION =========================================================
/** \class QtPickToolbar QtPickToolbar.hh <OpenFlipper/widgets/glWidget/QtPickToolbar.hh>
A graphics scene widget that displays a toolbar inside the graphics scene
**/
class DLLEXPORT QtPickToolbar : public QGraphicsProxyWidget
{
Q_OBJECT
public:
/** Create a pick toolbar.
\param _parent parent graphics item
*/
QtPickToolbar (QMainWindow *_core, QGraphicsItem *_parent = 0);
/// recalculate geometry
void updateGeometry ();
/// attach a QToolBar
void attachToolbar (QToolBar *_m);
/// detach toolbar
void detachToolbar ();
private:
/// paints decoration
virtual void paintWindowFrame(QPainter *_painter, const QStyleOptionGraphicsItem *_option, QWidget *_widget = 0);
/// categorize frame area
virtual Qt::WindowFrameSection windowFrameSectionAt(const QPointF &_pos) const;
/// event filter to track status tip events
bool eventFilter(QObject *_obj, QEvent *_event);
private:
// child widget
QToolBar *toolbar_;
QMainWindow *core_;
};
//=============================================================================
//=============================================================================
#endif // QT_SLIDE_WINDOW_ defined
//=============================================================================
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