Commit 9daa0b9d authored by Jan Möbius's avatar Jan Möbius

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 0ca38467
...@@ -204,92 +204,95 @@ void CoreWidget::updatePopupMenu(const QPoint& _point, unsigned int _examinerId) ...@@ -204,92 +204,95 @@ void CoreWidget::updatePopupMenu(const QPoint& _point, unsigned int _examinerId)
// Add a functions menu // Add a functions menu
QAction* action; QAction* action;
QMenu* functionMenu = new QMenu("&Functions",contextMenu_); if ( functionMenu_ == 0 ) {
functionMenu_ = new QMenu("&Functions",contextMenu_);
//==================================================================================================== //====================================================================================================
action = functionMenu->addAction("Set Background Color"); action = functionMenu_->addAction("Set Background Color");
action->setToolTip("Set the background color for the viewer"); action->setToolTip("Set the background color for the viewer");
connect(action, SIGNAL(triggered()), this, SLOT(changeBackgroundColor()) ); connect(action, SIGNAL(triggered()), this, SLOT(changeBackgroundColor()) );
//==================================================================================================== //====================================================================================================
functionMenu->addSeparator(); functionMenu_->addSeparator();
//==================================================================================================== //====================================================================================================
action = functionMenu->addAction("Snapshot"); action = functionMenu_->addAction("Snapshot");
action->setToolTip("Make a snapshot"); action->setToolTip("Make a snapshot");
connect(action, SIGNAL(triggered()), this, SLOT( slotSnapshot() ) ); connect(action, SIGNAL(triggered()), this, SLOT( slotSnapshot() ) );
//==================================================================================================== //====================================================================================================
action = functionMenu->addAction("Set Snapshot Name"); action = functionMenu_->addAction("Set Snapshot Name");
action->setToolTip("Set a name for snapshots"); action->setToolTip("Set a name for snapshots");
connect(action, SIGNAL(triggered()), this, SLOT(slotSnapshotName()) ); connect(action, SIGNAL(triggered()), this, SLOT(slotSnapshotName()) );
//==================================================================================================== //====================================================================================================
functionMenu->addSeparator(); functionMenu_->addSeparator();
//==================================================================================================== //====================================================================================================
action = functionMenu->addAction("Copy View"); action = functionMenu_->addAction("Copy View");
action->setToolTip("Copy current view to clipboard"); action->setToolTip("Copy current view to clipboard");
connect(action, SIGNAL(triggered()), this, SLOT(slotCopyView()) ); connect(action, SIGNAL(triggered()), this, SLOT(slotCopyView()) );
//==================================================================================================== //====================================================================================================
action = functionMenu->addAction("Paste View"); action = functionMenu_->addAction("Paste View");
action->setToolTip("Paste current view from clipboard"); action->setToolTip("Paste current view from clipboard");
connect(action, SIGNAL(triggered()), this , SLOT( slotPasteView( ) ) ); connect(action, SIGNAL(triggered()), this , SLOT( slotPasteView( ) ) );
//==================================================================================================== //====================================================================================================
functionMenu->addSeparator(); functionMenu_->addSeparator();
//==================================================================================================== //====================================================================================================
action = functionMenu->addAction("Synchronization"); action = functionMenu_->addAction("Synchronization");
action->setToolTip("Synchronize two different viewers"); action->setToolTip("Synchronize two different viewers");
action->setCheckable( true ); action->setCheckable( true );
action->setChecked( OpenFlipper::Options::synchronization() ); action->setChecked( OpenFlipper::Options::synchronization() );
for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) 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)), examiner_widgets_[i], SLOT(setSynchronization(bool)) );
connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions(bool)) ); connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions(bool)) );
//==================================================================================================== //====================================================================================================
action = functionMenu->addAction("Animation"); action = functionMenu_->addAction("Animation");
action->setToolTip("Animate rotation of objects"); action->setToolTip("Animate rotation of objects");
action->setCheckable( true ); action->setCheckable( true );
action->setChecked( OpenFlipper::Options::animation() ); action->setChecked( OpenFlipper::Options::animation() );
for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) 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)), examiner_widgets_[i], SLOT(animation(bool)) );
connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions(bool)) ); connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions(bool)) );
//==================================================================================================== //====================================================================================================
action = functionMenu->addAction("Backface Culling"); action = functionMenu_->addAction("Backface Culling");
action->setToolTip("Enable backface culling"); action->setToolTip("Enable backface culling");
action->setCheckable( true ); action->setCheckable( true );
action->setChecked( OpenFlipper::Options::backfaceCulling() ); action->setChecked( OpenFlipper::Options::backfaceCulling() );
for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) 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)), examiner_widgets_[i], SLOT(backFaceCulling(bool)) );
connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions(bool)) ); connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions(bool)) );
//==================================================================================================== //====================================================================================================
action = functionMenu->addAction("Two-sided Lighting"); action = functionMenu_->addAction("Two-sided Lighting");
action->setToolTip("Enable two-sided lighting"); action->setToolTip("Enable two-sided lighting");
action->setCheckable( true ); action->setCheckable( true );
action->setChecked( OpenFlipper::Options::twoSidedLighting() ); action->setChecked( OpenFlipper::Options::twoSidedLighting() );
for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) 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)), examiner_widgets_[i], SLOT(twoSidedLighting(bool)) );
connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions(bool)) ); connect(action, SIGNAL(triggered(bool)), this, SLOT(updateGlobalOptions(bool)) );
functionMenu->setTearOffEnabled(true); functionMenu_->setTearOffEnabled(true);
contextMenu_->addMenu(functionMenu ); }
contextMenu_->addMenu(functionMenu_ );
if ( ( examiner_widgets_[0]->getDrawMenu() != NULL ) && OpenFlipper::Options::drawModesInContextMenu() ) { if ( ( examiner_widgets_[0]->getDrawMenu() != NULL ) && OpenFlipper::Options::drawModesInContextMenu() ) {
......
...@@ -77,7 +77,14 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -77,7 +77,14 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
fileMenu_(0), fileMenu_(0),
viewMenu_(0), viewMenu_(0),
fileMenuEnd_(0), fileMenuEnd_(0),
stereoButton_(0),
projectionButton_(0),
moveButton_(0),
lightButton_(0),
pickButton_(0),
questionButton_(0),
contextMenu_(0), contextMenu_(0),
functionMenu_(0),
contextSelectionMenu_(0), contextSelectionMenu_(0),
stackMenu_(0), stackMenu_(0),
stackedWidget_(0), stackedWidget_(0),
...@@ -131,7 +138,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -131,7 +138,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
examinerWidget->disableKeyHandling(true); examinerWidget->disableKeyHandling(true);
examinerWidget->sceneGraph( PluginFunctions::getSceneGraphRootNode() ); examinerWidget->sceneGraph( PluginFunctions::getSceneGraphRootNode() );
examinerWidget->enablePopupMenu(false);
stackedWidget_->addWidget(examinerWidget); stackedWidget_->addWidget(examinerWidget);
...@@ -164,7 +170,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -164,7 +170,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
// Initialize all examiners // Initialize all examiners
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) { for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
examiner_widgets_[i]->sceneGraph( PluginFunctions::getSceneGraphRootNode() ); examiner_widgets_[i]->sceneGraph( PluginFunctions::getSceneGraphRootNode() );
examiner_widgets_[i]->enablePopupMenu(false);
examiner_widgets_[i]->disableKeyHandling(true); examiner_widgets_[i]->disableKeyHandling(true);
} }
......
...@@ -460,6 +460,9 @@ public: ...@@ -460,6 +460,9 @@ public:
/// context Menu for the gl area /// context Menu for the gl area
QMenu* contextMenu_; QMenu* contextMenu_;
/// Function Menu
QMenu* functionMenu_;
/// Context Menu containing all selection elements /// Context Menu containing all selection elements
QMenu* contextSelectionMenu_; QMenu* contextSelectionMenu_;
...@@ -629,6 +632,9 @@ public: ...@@ -629,6 +632,9 @@ public:
/// Change Icons if action mode is changed in an examiner /// Change Icons if action mode is changed in an examiner
void slotActionModeChanged( QtBaseViewer::ActionMode _mode ); void slotActionModeChanged( QtBaseViewer::ActionMode _mode );
/// Called when the functionMenu has to be updated
void slotFunctionMenuUpdate();
private : private :
bool stereoActive_; bool stereoActive_;
......
...@@ -113,4 +113,25 @@ void CoreWidget::slotActionModeChanged( QtBaseViewer::ActionMode _mode ) { ...@@ -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, ...@@ -180,15 +180,12 @@ QtBaseViewer::QtBaseViewer( QWidget* _parent,
snapshot_=new QImage; snapshot_=new QImage;
trackMouse_ = false; trackMouse_ = false;
popupEnabled_ = true;
// stereo // stereo
stereo_ = false; stereo_ = false;
pickMenu_ = 0; pickMenu_ = 0;
funcMenu_ = 0;
drawMenu_ = 0; drawMenu_ = 0;
...@@ -218,52 +215,6 @@ QtBaseViewer::QtBaseViewer( QWidget* _parent, ...@@ -218,52 +215,6 @@ QtBaseViewer::QtBaseViewer( QWidget* _parent,
// Note: we start locked (initialization of updateLocked_) // Note: we start locked (initialization of updateLocked_)
// will be unlocked in initializeGL() // 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(); QSizePolicy sp = sizePolicy();
sp.setHorizontalPolicy( QSizePolicy::Expanding ); sp.setHorizontalPolicy( QSizePolicy::Expanding );
sp.setVerticalPolicy( QSizePolicy::Expanding ); sp.setVerticalPolicy( QSizePolicy::Expanding );
...@@ -422,22 +373,6 @@ void QtBaseViewer::trackMouse(bool _track) ...@@ -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() void QtBaseViewer::perspectiveProjection()
...@@ -635,34 +570,34 @@ void QtBaseViewer::faceOrientation(FaceOrientation _ori) ...@@ -635,34 +570,34 @@ void QtBaseViewer::faceOrientation(FaceOrientation _ori)
void QtBaseViewer::backFaceCulling(bool _b) void QtBaseViewer::backFaceCulling(bool _b)
{ {
emit functionMenuUpdate();
makeCurrent(); makeCurrent();
if (funcMenu_==0) updatePopupMenu();
if ( (backFaceCulling_ = _b) ) if ( (backFaceCulling_ = _b) )
glEnable( GL_CULL_FACE ); glEnable( GL_CULL_FACE );
else else
glDisable( GL_CULL_FACE ); glDisable( GL_CULL_FACE );
action_["BackfaceCulling"]->setChecked( backFaceCulling_ );
updateGL(); updateGL();
} }
void QtBaseViewer::twoSidedLighting(bool _b) void QtBaseViewer::twoSidedLighting(bool _b)
{ {
emit functionMenuUpdate();
makeCurrent(); makeCurrent();
if (funcMenu_==0) updatePopupMenu();
glstate_->set_twosided_lighting(twoSidedLighting_=_b); glstate_->set_twosided_lighting(twoSidedLighting_=_b);
action_["TwoSidedLighting"]->setChecked(twoSidedLighting_);
updateGL(); updateGL();
} }
void QtBaseViewer::animation(bool _b) void QtBaseViewer::animation(bool _b)
{ {
emit functionMenuUpdate();
makeCurrent(); makeCurrent();
if (funcMenu_==0) updatePopupMenu();
animation_ = _b; animation_ = _b;
action_["Animation"]->setChecked( animation_ );
updateGL(); updateGL();
} }
...@@ -1301,13 +1236,15 @@ bool QtBaseViewer::decodeView(const QString& _view) ...@@ -1301,13 +1236,15 @@ bool QtBaseViewer::decodeView(const QString& _view)
glstate_->set_modelview(m); glstate_->set_modelview(m);
if (w>0 && h>0 && std::cerr << "Todo : Add Checkbox if size should also be pasted" << std::endl;
action_["PasteDropSize"]->isChecked() )
{ // if (w>0 && h>0 &&
glstate_->set_projection(p); // action_["PasteDropSize"]->isChecked() )
glView_->setFixedSize(w,h); // {
updateGeometry(); // glstate_->set_projection(p);
} // glView_->setFixedSize(w,h);
// updateGeometry();
// }
updateGL(); updateGL();
...@@ -1320,6 +1257,26 @@ bool QtBaseViewer::decodeView(const QString& _view) ...@@ -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 ) void QtBaseViewer::actionDrawMenu( QAction * _action )
{ {
unsigned int mode( _action->data().toUInt() ); unsigned int mode( _action->data().toUInt() );
...@@ -1358,110 +1315,10 @@ void QtBaseViewer::actionDrawMenu( QAction * _action ) ...@@ -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(){ bool QtBaseViewer::synchronization(){
return synchronized_; 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);
}
//-----------------------------------------------------------------------------