Commit b6c55654 authored by Jan Möbius's avatar Jan Möbius
Browse files

Removed function Menu from local examiner and move it to corewidget

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@4464 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 99f988a6
......@@ -204,92 +204,95 @@ void CoreWidget::updatePopupMenu(const QPoint& _point, unsigned int _examinerId)
// Add a functions menu
QAction* action;
QMenu* functionMenu = new QMenu("&Functions",contextMenu_);
if ( functionMenu_ == 0 ) {
functionMenu_ = new QMenu("&Functions",contextMenu_);
//====================================================================================================
//====================================================================================================
action = functionMenu->addAction("Set Background Color");
action->setToolTip("Set the background color for the viewer");
connect(action, SIGNAL(triggered()), this, SLOT(changeBackgroundColor()) );
action = functionMenu_->addAction("Set Background Color");
action->setToolTip("Set the background color for the viewer");
connect(action, SIGNAL(triggered()), this, SLOT(changeBackgroundColor()) );
//====================================================================================================
//====================================================================================================
functionMenu->addSeparator();
functionMenu_->addSeparator();
//====================================================================================================
//====================================================================================================
action = functionMenu->addAction("Snapshot");
action->setToolTip("Make a snapshot");
connect(action, SIGNAL(triggered()), this, SLOT( slotSnapshot() ) );
action = functionMenu_->addAction("Snapshot");
action->setToolTip("Make a snapshot");
connect(action, SIGNAL(triggered()), this, SLOT( slotSnapshot() ) );
//====================================================================================================
//====================================================================================================
action = functionMenu->addAction("Set Snapshot Name");
action->setToolTip("Set a name for snapshots");
connect(action, SIGNAL(triggered()), this, SLOT(slotSnapshotName()) );
action = functionMenu_->addAction("Set Snapshot Name");
action->setToolTip("Set a name for snapshots");
connect(action, SIGNAL(triggered()), this, SLOT(slotSnapshotName()) );
//====================================================================================================
//====================================================================================================
functionMenu->addSeparator();
functionMenu_->addSeparator();
//====================================================================================================
//====================================================================================================
action = functionMenu->addAction("Copy View");
action->setToolTip("Copy current view to clipboard");
connect(action, SIGNAL(triggered()), this, SLOT(slotCopyView()) );
action = functionMenu_->addAction("Copy View");
action->setToolTip("Copy current view to clipboard");
connect(action, SIGNAL(triggered()), this, SLOT(slotCopyView()) );
//====================================================================================================
//====================================================================================================
action = functionMenu->addAction("Paste View");
action->setToolTip("Paste current view from clipboard");
connect(action, SIGNAL(triggered()), this , SLOT( slotPasteView( ) ) );
action = functionMenu_->addAction("Paste View");
action->setToolTip("Paste current view from clipboard");
connect(action, SIGNAL(triggered()), this , SLOT( slotPasteView( ) ) );
//====================================================================================================
//====================================================================================================
functionMenu->addSeparator();
functionMenu_->addSeparator();
//====================================================================================================
//====================================================================================================
action = functionMenu->addAction("Synchronization");
action->setToolTip("Synchronize two different viewers");
action->setCheckable( true );
action->setChecked( OpenFlipper::Options::synchronization() );
for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
connect(action, SIGNAL(triggered(bool)), examiner_widgets_[i], SLOT(actionSynchronize(bool)) );
connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions(bool)) );
action = functionMenu_->addAction("Synchronization");
action->setToolTip("Synchronize two different viewers");
action->setCheckable( true );
action->setChecked( OpenFlipper::Options::synchronization() );
for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
connect(action, SIGNAL(triggered(bool)), examiner_widgets_[i], SLOT(setSynchronization(bool)) );
connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions(bool)) );
//====================================================================================================
//====================================================================================================
action = functionMenu->addAction("Animation");
action->setToolTip("Animate rotation of objects");
action->setCheckable( true );
action->setChecked( OpenFlipper::Options::animation() );
for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
connect(action, SIGNAL(triggered(bool)), examiner_widgets_[i], SLOT(actionAnimation(bool)) );
connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions(bool)) );
action = functionMenu_->addAction("Animation");
action->setToolTip("Animate rotation of objects");
action->setCheckable( true );
action->setChecked( OpenFlipper::Options::animation() );
for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
connect(action, SIGNAL(triggered(bool)), examiner_widgets_[i], SLOT(animation(bool)) );
connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions(bool)) );
//====================================================================================================
//====================================================================================================
action = functionMenu->addAction("Backface Culling");
action->setToolTip("Enable backface culling");
action->setCheckable( true );
action->setChecked( OpenFlipper::Options::backfaceCulling() );
for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
connect(action, SIGNAL(triggered(bool)), examiner_widgets_[i], SLOT(actionBackfaceCulling(bool)) );
connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions(bool)) );
action = functionMenu_->addAction("Backface Culling");
action->setToolTip("Enable backface culling");
action->setCheckable( true );
action->setChecked( OpenFlipper::Options::backfaceCulling() );
for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
connect(action, SIGNAL(triggered(bool)), examiner_widgets_[i], SLOT(backFaceCulling(bool)) );
connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions(bool)) );
//====================================================================================================
//====================================================================================================
action = functionMenu->addAction("Two-sided Lighting");
action->setToolTip("Enable two-sided lighting");
action->setCheckable( true );
action->setChecked( OpenFlipper::Options::twoSidedLighting() );
for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
connect(action, SIGNAL(triggered(bool)), examiner_widgets_[i], SLOT(actionTwoSidedLighting(bool)) );
connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions(bool)) );
action = functionMenu_->addAction("Two-sided Lighting");
action->setToolTip("Enable two-sided lighting");
action->setCheckable( true );
action->setChecked( OpenFlipper::Options::twoSidedLighting() );
for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
connect(action, SIGNAL(triggered(bool)), examiner_widgets_[i], SLOT(twoSidedLighting(bool)) );
connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions(bool)) );
functionMenu->setTearOffEnabled(true);
contextMenu_->addMenu(functionMenu );
functionMenu_->setTearOffEnabled(true);
}
contextMenu_->addMenu(functionMenu_ );
if ( ( examiner_widgets_[0]->getDrawMenu() != NULL ) && OpenFlipper::Options::drawModesInContextMenu() ) {
......
......@@ -77,7 +77,14 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
fileMenu_(0),
viewMenu_(0),
fileMenuEnd_(0),
stereoButton_(0),
projectionButton_(0),
moveButton_(0),
lightButton_(0),
pickButton_(0),
questionButton_(0),
contextMenu_(0),
functionMenu_(0),
contextSelectionMenu_(0),
stackMenu_(0),
stackedWidget_(0),
......@@ -131,7 +138,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
examinerWidget->disableKeyHandling(true);
examinerWidget->sceneGraph( PluginFunctions::getSceneGraphRootNode() );
examinerWidget->enablePopupMenu(false);
stackedWidget_->addWidget(examinerWidget);
......@@ -164,7 +170,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
// Initialize all examiners
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
examiner_widgets_[i]->sceneGraph( PluginFunctions::getSceneGraphRootNode() );
examiner_widgets_[i]->enablePopupMenu(false);
examiner_widgets_[i]->disableKeyHandling(true);
}
......
......@@ -460,6 +460,9 @@ public:
/// context Menu for the gl area
QMenu* contextMenu_;
/// Function Menu
QMenu* functionMenu_;
/// Context Menu containing all selection elements
QMenu* contextSelectionMenu_;
......@@ -629,6 +632,9 @@ public:
/// Change Icons if action mode is changed in an examiner
void slotActionModeChanged( QtBaseViewer::ActionMode _mode );
/// Called when the functionMenu has to be updated
void slotFunctionMenuUpdate();
private :
bool stereoActive_;
......
......@@ -113,4 +113,25 @@ void CoreWidget::slotActionModeChanged( QtBaseViewer::ActionMode _mode ) {
}
}
void CoreWidget::slotFunctionMenuUpdate() {
std::cerr << "DF" <<std::endl;
if ( examiner_widgets_.empty() )
return;
QList< QAction *> allActions = functionMenu_->actions();
for ( int i = 0 ; i < allActions.size(); ++i ) {
if ( allActions[i]->text() == "Synchronization" )
allActions[i]->setChecked(examiner_widgets_[0]->synchronization());
else if ( allActions[i]->text() == "Animation" )
allActions[i]->setChecked(examiner_widgets_[0]->animation());
else if ( allActions[i]->text() == "Backface Culling" )
allActions[i]->setChecked(examiner_widgets_[0]->backFaceCulling());
else if ( allActions[i]->text() == "Two-sided Lighting" )
allActions[i]->setChecked(examiner_widgets_[0]->twoSidedLighting());
}
}
//=============================================================================
......@@ -180,15 +180,12 @@ QtBaseViewer::QtBaseViewer( QWidget* _parent,
snapshot_=new QImage;
trackMouse_ = false;
popupEnabled_ = true;
// stereo
stereo_ = false;
pickMenu_ = 0;
funcMenu_ = 0;
drawMenu_ = 0;
......@@ -218,52 +215,6 @@ QtBaseViewer::QtBaseViewer( QWidget* _parent,
// Note: we start locked (initialization of updateLocked_)
// will be unlocked in initializeGL()
// Actions
action_.insert( "Background", new QAction( "Background color", this ) );
action_.insert( "Snapshot", new QAction( "Snapshot", this ) );
action_.insert( "SnapshotName", new QAction( "Set snapshot name", this ) );
action_.insert( "SnapshotSavesView", new QAction( "Snapshot saves view", this ) );
action_.insert( "CopyView", new QAction( "Copy view", this ) );
action_.insert( "PasteView", new QAction( "Paste view", this ) );
action_.insert( "PasteDropSize", new QAction( "Paste/Drop effects size", this ) );
action_.insert( "Synchronize", new QAction( "Synchronize", this ) );
action_.insert( "Animation", new QAction( "Animation", this ) );
action_.insert( "BackfaceCulling", new QAction( "Backface culling", this ) );
action_.insert( "TwoSidedLighting", new QAction( "Two-sided lighting", this ) );
connect( action_["Background"], SIGNAL( triggered() ),
this, SLOT( actionBackground() ) );
connect( action_["Snapshot"], SIGNAL( triggered() ),
this, SLOT( actionSnapshot() ) );
connect( action_["SnapshotName"], SIGNAL( triggered() ),
this, SLOT( actionSnapshotName() ) );
connect( action_["SnapshotSavesView"], SIGNAL( triggered() ),
this, SLOT( actionSnapshotSavesView() ) );
connect( action_["CopyView"], SIGNAL( triggered() ),
this, SLOT( actionCopyView() ) );
connect( action_["PasteView"], SIGNAL( triggered() ),
this, SLOT( actionPasteView() ) );
connect( action_["PasteDropSize"], SIGNAL( triggered() ),
this, SLOT( actionPasteDropSize() ) );
connect( action_["Synchronize"], SIGNAL( triggered() ),
this, SLOT( actionSynchronize() ) );
connect( action_["Animation"], SIGNAL( triggered() ),
this, SLOT( actionAnimation() ) );
connect( action_["BackfaceCulling"], SIGNAL( triggered() ),
this, SLOT( actionBackfaceCulling() ) );
connect( action_["TwoSidedLighting"], SIGNAL( triggered() ),
this, SLOT( actionTwoSidedLighting() ) );
action_["SnapshotSavesView"]->setCheckable( true );
action_["PasteDropSize"]->setCheckable( true );
action_["Synchronize"]->setCheckable( true );
action_["Animation"]->setCheckable( true );
action_["BackfaceCulling"]->setCheckable( true );
action_["TwoSidedLighting"]->setCheckable( true );
QSizePolicy sp = sizePolicy();
sp.setHorizontalPolicy( QSizePolicy::Expanding );
sp.setVerticalPolicy( QSizePolicy::Expanding );
......@@ -422,22 +373,6 @@ void QtBaseViewer::trackMouse(bool _track)
}
//-----------------------------------------------------------------------------
void QtBaseViewer::enablePopupMenu(bool _enable)
{
popupEnabled_ = _enable;
if ( popupEnabled_ ) {
glView_->setContextMenuPolicy( Qt::DefaultContextMenu );
} else {
glView_->setContextMenuPolicy( Qt::CustomContextMenu );
}
}
//-----------------------------------------------------------------------------
void QtBaseViewer::perspectiveProjection()
......@@ -635,34 +570,34 @@ void QtBaseViewer::faceOrientation(FaceOrientation _ori)
void QtBaseViewer::backFaceCulling(bool _b)
{
emit functionMenuUpdate();
makeCurrent();
if (funcMenu_==0) updatePopupMenu();
if ( (backFaceCulling_ = _b) )
glEnable( GL_CULL_FACE );
else
glDisable( GL_CULL_FACE );
action_["BackfaceCulling"]->setChecked( backFaceCulling_ );
updateGL();
}
void QtBaseViewer::twoSidedLighting(bool _b)
{
emit functionMenuUpdate();
makeCurrent();
if (funcMenu_==0) updatePopupMenu();
glstate_->set_twosided_lighting(twoSidedLighting_=_b);
action_["TwoSidedLighting"]->setChecked(twoSidedLighting_);
updateGL();
}
void QtBaseViewer::animation(bool _b)
{
emit functionMenuUpdate();
makeCurrent();
if (funcMenu_==0) updatePopupMenu();
animation_ = _b;
action_["Animation"]->setChecked( animation_ );
updateGL();
}
......@@ -1301,13 +1236,15 @@ bool QtBaseViewer::decodeView(const QString& _view)
glstate_->set_modelview(m);
if (w>0 && h>0 &&
action_["PasteDropSize"]->isChecked() )
{
glstate_->set_projection(p);
glView_->setFixedSize(w,h);
updateGeometry();
}
std::cerr << "Todo : Add Checkbox if size should also be pasted" << std::endl;
// if (w>0 && h>0 &&
// action_["PasteDropSize"]->isChecked() )
// {
// glstate_->set_projection(p);
// glView_->setFixedSize(w,h);
// updateGeometry();
// }
updateGL();
......@@ -1320,6 +1257,26 @@ bool QtBaseViewer::decodeView(const QString& _view)
//-----------------------------------------------------------------------------
void QtBaseViewer::actionCopyView()
{
QString view; encodeView(view);
QApplication::clipboard()->setText(view);
}
//-----------------------------------------------------------------------------
void QtBaseViewer::actionPasteView()
{
QString view; view=QApplication::clipboard()->text();
decodeView(view);
}
//-----------------------------------------------------------------------------
void QtBaseViewer::actionDrawMenu( QAction * _action )
{
unsigned int mode( _action->data().toUInt() );
......@@ -1358,110 +1315,10 @@ void QtBaseViewer::actionDrawMenu( QAction * _action )
//-----------------------------------------------------------------------------
void QtBaseViewer::actionBackground()
{
const ACG::Vec4f bc = glstate_->clear_color() * 255.0;
QColor backCol((int)bc[0], (int)bc[1], (int)bc[2]);
QColor c = QColorDialog::getColor(backCol,this);
if (c != backCol && c.isValid())
backgroundColor(ACG::Vec4f(((double) c.red()) / 255.0,
((double) c.green()) / 255.0,
((double) c.blue()) / 255.0,
1.0));
}
//-----------------------------------------------------------------------------
void QtBaseViewer::actionCopyView()
{
QString view; encodeView(view);
QApplication::clipboard()->setText(view);
}
//-----------------------------------------------------------------------------
void QtBaseViewer::actionPasteView()
{
QString view; view=QApplication::clipboard()->text();
decodeView(view);
}
//-----------------------------------------------------------------------------
void QtBaseViewer::actionPasteDropSize()
{
}
//-----------------------------------------------------------------------------
void QtBaseViewer::actionSynchronize()
{
setSynchronization( action_["Synchronize"]->isChecked() );
}
//-----------------------------------------------------------------------------
void QtBaseViewer::actionSynchronize(bool _enable)
{
setSynchronization( _enable );
}
bool QtBaseViewer::synchronization(){
return synchronized_;
}
//-----------------------------------------------------------------------------
void QtBaseViewer::actionAnimation()
{
animation(!animation());
}
//-----------------------------------------------------------------------------
void QtBaseViewer::actionAnimation(bool _enable)
{
animation(_enable);
}
//-----------------------------------------------------------------------------
void QtBaseViewer::actionBackfaceCulling()
{
backFaceCulling(!backFaceCulling());
}
//-----------------------------------------------------------------------------
void QtBaseViewer::actionBackfaceCulling(bool _enable)
{
backFaceCulling(_enable);
}
//-----------------------------------------------------------------------------
void QtBaseViewer::actionTwoSidedLighting()
{
twoSidedLighting(!twoSidedLighting());
}
//-----------------------------------------------------------------------------
void QtBaseViewer::actionTwoSidedLighting(bool _enable)
{
twoSidedLighting(_enable);
}
//-----------------------------------------------------------------------------
void
QtBaseViewer::createWidgets(const QGLFormat* _format,
QStatusBar* _sb,
......@@ -1470,7 +1327,6 @@ QtBaseViewer::createWidgets(const QGLFormat* _format,
statusbar_=privateStatusBar_=0;
setStatusBar(_sb);
drawMenu_=0;
funcMenu_=0;
pickMenu_=0;
......@@ -1510,6 +1366,8 @@ QtBaseViewer::createWidgets(const QGLFormat* _format,
glView_->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
glView_->setScene(glScene_);
glView_->setContextMenuPolicy( Qt::CustomContextMenu );
wheelZ_=new ACG::QtWidgets::QtWheel( 0,"wheel-z",ACG::QtWidgets::QtWheel::Vertical);
wheelZ_->setMinimumSize(wheelZ_->sizeHint());
wheelZ_->setMaximumSize(wheelZ_->sizeHint());
......@@ -1576,7 +1434,6 @@ QtBaseViewer::createWidgets(const QGLFormat* _format,
connect ( glScene_, SIGNAL( sceneRectChanged( const QRectF & ) ),
this, SLOT( sceneRectChanged( const QRectF & ) ) );
// If popupEnabled_ this signal will not be emitted!
// If popupEnabled_ is set to false the Contextmenu Mode will be set to customContextMenuRequested
// and this signal will be emitted on right click
connect( glView_ , SIGNAL( customContextMenuRequested( const QPoint& ) ) ,
......@@ -1653,33 +1510,6 @@ void QtBaseViewer::updatePopupMenu()
drawMenu_->addActions( drawGroup->actions() );
// function menu
if (!funcMenu_)
{
funcMenu_=new QMenu( this );
funcMenu_->addAction( action_[ "Background" ] );
funcMenu_->addSeparator();
funcMenu_->addAction( action_[ "Snapshot" ] );
funcMenu_->addAction( action_[ "SnapshotName" ] );
funcMenu_->addAction( action_[ "SnapshotSavesView" ] );
funcMenu_->addSeparator();
funcMenu_->addAction( action_[ "CopyView" ] );
funcMenu_->addAction( action_[ "PasteView" ] );
funcMenu_->addAction( action_[ "PasteDropSize" ] );
funcMenu_->addSeparator();
funcMenu_->addAction( action_[ "Synchronize" ] );
funcMenu_->addSeparator();
funcMenu_->addAction( action_[ "Animation" ] );
funcMenu_->addAction( action_[ "BackfaceCulling" ] );
funcMenu_->addAction( action_[ "TwoSidedLighting" ] );
connect( funcMenu_, SIGNAL( aboutToHide() ),
this, SLOT( hidePopupMenus() ) );
}
}
......@@ -1695,13 +1525,6 @@ void QtBaseViewer::hidePopupMenus()
drawMenu_->blockSignals(false);
}
if ( funcMenu_ )
{
funcMenu_->blockSignals(true);
funcMenu_->hide();
funcMenu_->blockSignals(false);
}