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

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@4511 383ad7c9-94d9-4d36-a494-682f7c89f535
parent bf92191c
......@@ -65,7 +65,7 @@ class GlobalAccessInterface {
* This function is called to set a pointer to the global examiner Widget.\n
* @param _examiner_widget Pointer to the Examiner Widget in the Main app
*/
virtual void set_examiner( QtBaseViewer* /*_examiner_widget*/) = 0;
virtual void set_examiner( glViewer* /*_examiner_widget*/) = 0;
};
......
......@@ -41,6 +41,7 @@
#include <OpenFlipper/common/Types.hh>
#include "PluginFunctions.hh"
#include "PluginFunctionsCore.hh"
namespace PluginFunctions {
......@@ -54,10 +55,10 @@ static BaseObject* objectRoot_;
*
* This pointer is internally used to acces the examiner widget in the main apllication
*/
static std::vector< QtBaseViewer* > examiner_widgets_;
static std::vector< glViewer* > examiner_widgets_;
/// TODO : Remove this variable and implement multiView correctly here
static QtBaseViewer* examiner_widget_;
static glViewer* examiner_widget_;
static unsigned int activeExaminer_ = 0;
......@@ -69,11 +70,13 @@ static SeparatorNode* root_node_;
static SeparatorNode* sceneGraph_root_node_;
static Viewer::ViewerProperties dummyProperties;
void setDataRoot( BaseObject* _root ) {
objectRoot_ = _root;
}
void set_examiner( std::vector< QtBaseViewer* > _examiner_widgets ) {
void setViewers( std::vector< glViewer* > _examiner_widgets ) {
PluginFunctions::examiner_widgets_ = _examiner_widgets;
PluginFunctions::examiner_widget_ = examiner_widgets_[0];
}
......@@ -86,11 +89,11 @@ unsigned int activeExaminer( ) {
return activeExaminer_;
}
void set_rootNode( SeparatorNode* _root_node ) {
void setRootNode( SeparatorNode* _root_node ) {
PluginFunctions::root_node_ = _root_node;
}
void set_sceneGraphRootNode( SeparatorNode* _root_node ) {
void setSceneGraphRootNode( SeparatorNode* _root_node ) {
PluginFunctions::sceneGraph_root_node_ = _root_node;
}
......@@ -334,9 +337,10 @@ void pickMode ( const unsigned int _examiner, std::string _mode) {
examiner_widgets_[_examiner]->pickMode(_mode);
}
void actionMode ( QtBaseViewer::ActionMode _mode) {
void actionMode ( Viewer::ActionMode _mode) {
for ( uint i = 0 ; i < examiner_widgets_.size() ; ++i )
examiner_widgets_[i]->actionMode(_mode);
viewerProperties(i).actionMode(_mode);
}
ACG::GLState& glState() {
......@@ -347,8 +351,21 @@ void getCurrentViewImage(QImage& _image) {
examiner_widget_->copyToImage( _image );
}
QtBaseViewer::ActionMode actionMode() {
return examiner_widget_->actionMode();
Viewer::ActionMode actionMode() {
return viewerProperties(activeExaminer_).actionMode();
}
Viewer::ViewerProperties& viewerProperties(int _id) {
if ( _id >= (int)examiner_widgets_.size() ) {
std::cerr << " Error, requested properties for non-existing Viewer!" << std::endl;
return dummyProperties;
}
if ( _id == -1 )
_id = activeExaminer_;
return (*examiner_widgets_[_id]->properties());
}
void perspectiveProjection() {
......
......@@ -49,9 +49,10 @@
#include <OpenFlipper/common/Types.hh>
// #include <ACG/Math/VectorT.hh>
#include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh>
#include <ACG/Scenegraph/SceneGraph.hh>
// #include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh>
#include <ACG/GL/GLState.hh>
#include <OpenFlipper/common/ViewerProperties.hh>
/** The Namespace PluginFunctions contains functions for all plugins. These functions should be used to get the
* objects to work on or to set modes in the examiner widget. */
......@@ -191,9 +192,6 @@ int visible_count();
/** @name Examiner handling
* @{ */
//=======================================
/// Set the internal examiner pointer ( DO NOT USE!! )
DLLEXPORT
void set_examiner( std::vector< QtBaseViewer* > _examiner_widgets );
/// Set the active id of the examiner which got the last mouse events
DLLEXPORT
......@@ -203,14 +201,6 @@ void setActiveExaminer( const unsigned int _id );
DLLEXPORT
unsigned int activeExaminer();
/// Set the internal scenegraph root node pointer ( DO NOT USE!! )
DLLEXPORT
void set_sceneGraphRootNode( SeparatorNode* _root_node );
/// Set the internal data root node pointer ( DO NOT USE!! )
DLLEXPORT
void set_rootNode( SeparatorNode* _root_node );
/** Execute picking operation on scenegraph
* This picking function will pick in the last active examiner context which is automatically
* Set by mouseevents from the core
......@@ -272,11 +262,20 @@ void addGlobalNode(ACG::SceneGraph::BaseNode* _node);
/// Set the current Action Mode (PickMode,ExamineMode,...)
DLLEXPORT
void actionMode ( QtBaseViewer::ActionMode _mode);
void actionMode ( Viewer::ActionMode _mode);
/// Get the current Action mode
DLLEXPORT
QtBaseViewer::ActionMode actionMode();
Viewer::ActionMode actionMode();
/** Get the viewer properties
* -1 will get the properties of the active Viewer which is the default
*/
DLLEXPORT
Viewer::ViewerProperties& viewerProperties(int _id = -1);
/** Lock scene rotation via mouse
*
......
//=============================================================================
//
// 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: 4482 $
// $Author: moebius $
// $Date: 2009-01-28 11:12:14 +0100 (Mi, 28. Jan 2009) $
//
//=============================================================================
//=============================================================================
//
// Standard Functions
//
//=============================================================================
/**
* \file PluginFunctions.hh
* This file contains functions to setup the internal structures for PluginFunctions.
* Dont Use these Functions in your Plugins!
*/
//
#ifndef PLUGINFUNCTIONSCORE_HH
#define PLUGINFUNCTIONSCORE_HH
#include <OpenFlipper/common/GlobalDefines.hh>
#include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh>
namespace PluginFunctions {
//=======================================
// Set pointers for global handling in PluginFunctions without exporting them to the Plugins
/** @name Setup Functions
* @{ */
//=======================================
/// Set the internal examiner pointer ( DO NOT USE!! )
DLLEXPORT
void setViewers( std::vector< glViewer* > _examiner_widgets );
/// Set the internal scenegraph root node pointer ( DO NOT USE!! )
DLLEXPORT
void setSceneGraphRootNode( SeparatorNode* _root_node );
/// Set the internal data root node pointer ( DO NOT USE!! )
DLLEXPORT
void setRootNode( SeparatorNode* _root_node );
/** @} */
}
#endif //PLUGINFUNCTIONSCORE_HH
......@@ -83,6 +83,7 @@
#include <ACG/Scenegraph/SeparatorNode.hh>
#include "OpenFlipper/BasePlugin/PluginFunctions.hh"
#include "OpenFlipper/BasePlugin/PluginFunctionsCore.hh"
#include <OpenMesh/Core/System/omstream.hh>
......@@ -141,9 +142,9 @@ void
Core::init() {
// Make root_node available to the plugins ( defined in PluginFunctions.hh)
PluginFunctions::set_rootNode( root_node_ );
PluginFunctions::setRootNode( root_node_ );
PluginFunctions::set_sceneGraphRootNode( root_node_scenegraph_ );
PluginFunctions::setSceneGraphRootNode( root_node_scenegraph_ );
// Initialize the first object as the root Object for the object tree
objectRoot_ = dynamic_cast< BaseObject* > ( new GroupObject("ObjectRoot") );
......@@ -200,10 +201,6 @@ Core::init() {
coreWidget_->setWindowTitle( OpenFlipper::Options::windowTitle() );
// Make examiner available to the plugins ( defined in PluginFunctions.hh)
PluginFunctions::set_examiner( coreWidget_->examiner_widgets_ );
}
// ======================================================================
......
This diff is collapsed.
//=============================================================================
//
// 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: 4482 $
// $Author: moebius $
// $Date: 2009-01-28 11:12:14 +0100 (Mi, 28. Jan 2009) $
//
//=============================================================================
//=============================================================================
//
// Property storage Class for glWidgets
//
//=============================================================================
#include <OpenFlipper/common/GlobalDefines.hh>
#include "ViewerProperties.hh"
#include <iostream>
namespace Viewer {
ViewerProperties::ViewerProperties():
actionMode_(Viewer::PickingMode),
lastActionMode_(Viewer::PickingMode)
{
}
ViewerProperties::~ViewerProperties() {
}
void ViewerProperties::actionMode(Viewer::ActionMode _am) {
std::cerr << "ActionModeChanged" << std::endl;
if (_am != actionMode_) {
lastActionMode_ = actionMode_;
actionMode_ = _am;
emit actionModeChanged(_am);
}
}
}
\ No newline at end of file
//=============================================================================
//
// 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: 4482 $
// $Author: moebius $
// $Date: 2009-01-28 11:12:14 +0100 (Mi, 28. Jan 2009) $
//
//=============================================================================
//=============================================================================
//
// Property storage Class for glWidgets
//
//=============================================================================
/**
* \file ViewerProperties.hh
* This file contains a class for managing all viewer settings
*/
//
#ifndef VIEWERPROPERTIES_HH
#define VIEWERPROPERTIES_HH
#include <QObject>
namespace Viewer {
/// How to react on mouse events?
enum ActionMode {
// examine geometry, get transformations from mouse events
ExamineMode,
/** Picking mode. Actually no pick()ing is performed (!) but events are
forwarded to the application via signalMouseEvent().
*/
PickingMode,
// same as picking, but emit signalMouseEventIdentify()
QuestionMode,
// Ligh rotation mode
LightMode
};
class ViewerProperties : public QObject {
Q_OBJECT
public:
ViewerProperties();
~ViewerProperties();
//===========================================================================
/** @name Action Mode States
* @{ */
//===========================================================================
public slots:
bool examineMode() { return(actionMode_ == Viewer::ExamineMode ); };
bool pickingMode() { return(actionMode_ == Viewer::PickingMode ); };
bool lightMode() { return(actionMode_ == Viewer::LightMode ); };
bool questionMode(){ return(actionMode_ == Viewer::QuestionMode ); };
/** Set action mode.
The ActionMode determines the type of reaction on mouse events.
*/
void setExamineMode() { actionMode(Viewer::ExamineMode ); };
void setPickingMode() { actionMode(Viewer::PickingMode ); };
void setLightMode() { actionMode(Viewer::LightMode ); };
void setQuestionMode(){ actionMode(Viewer::QuestionMode ); };
public:
void actionMode(Viewer::ActionMode _am);
Viewer::ActionMode actionMode() { return actionMode_; };
Viewer::ActionMode lastActionMode() { return lastActionMode_; };
private :
Viewer::ActionMode actionMode_, lastActionMode_;
/** @} */
//===========================================================================
/** @name Action Mode States
* @{ */
//===========================================================================
/** @} */
signals:
/** \brief This signal is emitted when the configuration has been changed
*/
void updated();
void actionModeChanged( Viewer::ActionMode );
};
}
#endif //VIEWERPROPERTIES_HH
\ No newline at end of file
......@@ -48,6 +48,7 @@
#include <OpenFlipper/common/GlobalOptions.hh>
#include <OpenFlipper/common/RecentFiles.hh>
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <OpenFlipper/BasePlugin/PluginFunctionsCore.hh>
#include <OpenFlipper/BasePlugin/KeyInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
......@@ -131,7 +132,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
if ( !OpenFlipper::Options::multiView() ) {
QtBaseViewer* examinerWidget = new QtBaseViewer(stackedWidget_,
glViewer* examinerWidget = new glViewer(stackedWidget_,
"Examiner Widget",
statusBar_ ,
&format);
......@@ -148,7 +149,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
tmp = new QWidget(stackedWidget_);
// Create master examiner widget
QtBaseViewer* examinerWidget = new QtBaseViewer(tmp,
glViewer* examinerWidget = new glViewer(tmp,
"Examiner Widget",
statusBar_ ,
&format,
......@@ -158,7 +159,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
// Create all other examiners using the same gl context as the others
for ( unsigned int i = 1 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
QtBaseViewer* newWidget = new QtBaseViewer(tmp,
glViewer* newWidget = new glViewer(tmp,
"Examiner Widget",
statusBar_ ,
&format,
......@@ -183,6 +184,9 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
stackedWidget_->addWidget(tmp);
}
// Make examiner available to the plugins ( defined in PluginFunctions.hh)
PluginFunctions::setViewers( examiner_widgets_ );
......@@ -232,8 +236,9 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
"<li><b>Translate</b> using <b>middle</b> mouse button.</li>"
"<li><b>Zoom</b> using <b>left+middle</b> mouse buttons.</li></ul>" );
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
connect( moveButton_,SIGNAL( clicked() ), examiner_widgets_[i], SLOT( examineMode() ) );
connect( examiner_widgets_[i],SIGNAL( actionModeChanged( QtBaseViewer::ActionMode ) ),this , SLOT( slotActionModeChanged(QtBaseViewer::ActionMode) ) );
connect( moveButton_,SIGNAL( clicked() ), &PluginFunctions::viewerProperties(i), SLOT( setExamineMode() ) );
connect( examiner_widgets_[i] , SIGNAL( signalActionModeChanged( Viewer::ActionMode ) ),
this , SLOT( slotActionModeChanged(Viewer::ActionMode) ) );
}
viewerToolbar_->addWidget( moveButton_ )->setText("Move");
......@@ -249,7 +254,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
"Switch to <b>light</b> mode.<br>"
"Rotate lights using left mouse button.");
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
connect( lightButton_,SIGNAL( clicked() ), examiner_widgets_[i], SLOT( lightMode() ) );
connect( lightButton_,SIGNAL( clicked() ), &PluginFunctions::viewerProperties(i), SLOT( setLightMode() ) );
viewerToolbar_->addWidget( lightButton_)->setText("Light");
......@@ -264,7 +269,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
"To change the mode use the right click<br>"
"context menu in the viewer.");
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
connect( pickButton_,SIGNAL( clicked() ), examiner_widgets_[i], SLOT( pickingMode() ) );
connect( pickButton_,SIGNAL( clicked() ), &PluginFunctions::viewerProperties(i), SLOT( setPickingMode() ) );
viewerToolbar_->addWidget( pickButton_)->setText("Pick");
......@@ -280,7 +285,7 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
"the log output for information about the "
"object.");
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
connect( questionButton_,SIGNAL( clicked() ), examiner_widgets_[i], SLOT( questionMode() ) );
connect( questionButton_,SIGNAL( clicked() ), &PluginFunctions::viewerProperties(i), SLOT( setQuestionMode() ) );
viewerToolbar_->addWidget( questionButton_)->setText("Question");
viewerToolbar_->addSeparator();
......
......@@ -346,7 +346,7 @@ public:
public :
/// Examiner Widget
std::vector< QtBaseViewer* > examiner_widgets_;
std::vector< glViewer* > examiner_widgets_;
///Spliter between toplevel objects and the textedit at the bottom
QSplitter* splitter_;
......@@ -641,7 +641,7 @@ public:
void slotProjectionModeChanged( bool _ortho );
/// Change Icons if action mode is changed in an examiner
void slotActionModeChanged( QtBaseViewer::ActionMode _mode );
void slotActionModeChanged( Viewer::ActionMode _mode );
/// Called when the functionMenu has to be updated
void slotFunctionMenuUpdate();
......
......@@ -5,6 +5,8 @@
#include <OpenFlipper/common/GlobalOptions.hh>
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
//-----------------------------------------------------------------------------
KeyBinding CoreWidget::getKeyBinding(QObject* _plugin, int _keyIndex ){
......@@ -260,9 +262,9 @@ void CoreWidget::slotRegisterSlotKeyBindings(){
kb.description = plugins_[i].rpcFunctions[j];
kb.multiUse = true;
kb.slot = true;
plugins_[i].keys.append( kb );
keys_.insert( std::make_pair( std::make_pair(-1, 0) , std::make_pair(plugins_[i].plugin, plugins_[i].keys.size()-1) ) );
invKeys_.insert( std::make_pair( std::make_pair(plugins_[i].plugin, plugins_[i].keys.size()-1) , std::make_pair(-1, 0) ) );
}
......@@ -433,7 +435,7 @@ void CoreWidget::coreKeyPressEvent (QKeyEvent* _e){
switch (_e->key()) {
case Qt::Key_Escape:
for ( uint i = 0 ; i < examiner_widgets_.size(); ++i)
examiner_widgets_[i]->actionMode(examiner_widgets_[i]->lastActionMode());
PluginFunctions::viewerProperties(i).actionMode( PluginFunctions::viewerProperties(i).lastActionMode() );
break;
case Qt::Key_Print:
......
......@@ -76,7 +76,7 @@ void CoreWidget::slotProjectionModeChanged( bool _ortho ) {
}
void CoreWidget::slotActionModeChanged( QtBaseViewer::ActionMode _mode ) {
void CoreWidget::slotActionModeChanged( Viewer::ActionMode _mode ) {
moveButton_->setDown(false);
lightButton_->setDown(false);
pickButton_->setDown(false);
......@@ -84,28 +84,28 @@ void CoreWidget::slotActionModeChanged( QtBaseViewer::ActionMode _mode ) {
switch (_mode)
{
case QtBaseViewer::ExamineMode:
case Viewer::ExamineMode:
{
moveButton_->setDown(true);
break;
}
case QtBaseViewer::LightMode:
case Viewer::LightMode:
{
lightButton_->setDown(true);
break;
}
case QtBaseViewer::PickingMode:
case Viewer::PickingMode:
{
pickButton_->setDown(true);
break;
}
case QtBaseViewer::QuestionMode:
case Viewer::QuestionMode:
{
questionButton_->setDown(true);
break;
......
This diff is collapsed.
......@@ -34,7 +34,7 @@
//=============================================================================
//
// CLASS QtBaseViewer
// CLASS glViewer
//
//=============================================================================
......@@ -43,7 +43,8 @@
//== INCLUDES =================================================================
#include <OpenFlipper/common/GlobalDefines.hh>
#include <OpenFlipper/common/Types.hh>
#include <OpenFlipper/common/ViewerProperties.hh>
#include <ACG/GL/GLState.hh>
#include <ACG/Scenegraph/SceneGraph.hh>
......@@ -101,14 +102,14 @@ class QtShiftPopupMenu;
//== CLASS DEFINITION =========================================================
/** \class QtBaseViewer QtBaseViewer.hh <OpenFlipper/widgets/glWidget/QtBaseViewer.hh>
/** \class glViewer glViewer.hh <OpenFlipper/widgets/glWidget/glViewer.hh>
Base Viewer Widget: All viewers are derived from this one. Implement
Mouse & Keyboard Events. Redefine Signals and Slots.
See for example "QtExaminerViewer"
**/
class DLLEXPORT QtBaseViewer : public QWidget
class DLLEXPORT glViewer : public QWidget
{
Q_OBJECT
......@@ -117,21 +118,21 @@ public:
//--------------------------------------------------- constructor / destructor
/** Create a QtBaseViewer.
/** Create a glViewer.
\param _parent parent widget
\param _name name (qt internal, qt debugging)
\param _statusBar pointer to an existing status bar for this widget,
if \c statusBar==0 then a \a private status bar will be created
\param _format OpenGL context settings, will be passed to glarea()
*/
QtBaseViewer( QWidget* _parent=0,
glViewer( QWidget* _parent=0,
const char* _name=0,
QStatusBar *_statusBar=0,
const QGLFormat* _format=0,
const QtBaseViewer* _share=0);
const glViewer* _share=0);