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

First multi view version

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@4013 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 5336a447
......@@ -190,8 +190,13 @@ Core::init() {
coreWidget_->setWindowTitle( OpenFlipper::Options::windowTitle() );
// Make examiner available to the plugins ( defined in PluginFunctions.hh)
PluginFunctions::set_examiner( coreWidget_->examiner_widget_ );
PluginFunctions::set_examiner( coreWidget_->examiner_widgets_[0] );
if ( OpenFlipper::Options::multiView() ) {
std::cerr << "Todo : Pluginfunctions set multiple examiners" << std::endl;
}
}
......@@ -560,8 +565,12 @@ void Core::updateView() {
if ( OpenFlipper::Options::gui() && !OpenFlipper::Options::loadingSettings() && !OpenFlipper::Options::redrawDisabled() ) {
coreWidget_->examiner_widget_->sceneGraph(root_node_scenegraph_);
coreWidget_->examiner_widget_->updateGL();
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
coreWidget_->examiner_widgets_[i]->sceneGraph(root_node_scenegraph_);
coreWidget_->examiner_widgets_[i]->updateGL();
}
}
}
......
......@@ -419,13 +419,17 @@ void Core::writeApplicationOptions(INIFile& _ini) {
if ( OpenFlipper::Options::gui() ) {
_ini.add_entry("Options","BackfaceCulling",coreWidget_->examiner_widget_->backFaceCulling());
_ini.add_entry("Options","Animation",coreWidget_->examiner_widget_->animation());
_ini.add_entry("Options","Synchronization",coreWidget_->examiner_widget_->synchronization());
_ini.add_entry("Options","twoSidedLighting",coreWidget_->examiner_widget_->twoSidedLighting());
if ( OpenFlipper::Options::multiView() ) {
std::cerr << "Todo : Save application options for multiple views" << std::endl;
}
_ini.add_entry("Options","BackfaceCulling",coreWidget_->examiner_widgets_[0]->backFaceCulling());
_ini.add_entry("Options","Animation",coreWidget_->examiner_widgets_[0]->animation());
_ini.add_entry("Options","Synchronization",coreWidget_->examiner_widgets_[0]->synchronization());
_ini.add_entry("Options","twoSidedLighting",coreWidget_->examiner_widgets_[0]->twoSidedLighting());
_ini.add_entry("Options","WheelZoomFactor",coreWidget_->examiner_widget_->wheelZoomFactor());
_ini.add_entry("Options","WheelZoomFactorShift",coreWidget_->examiner_widget_->wheelZoomFactorShift());
_ini.add_entry("Options","WheelZoomFactor",coreWidget_->examiner_widgets_[0]->wheelZoomFactor());
_ini.add_entry("Options","WheelZoomFactorShift",coreWidget_->examiner_widgets_[0]->wheelZoomFactorShift());
//============================================================================
// Save the current draw modes
......
......@@ -45,17 +45,21 @@
void Core::resetScenegraph() {
if ( OpenFlipper::Options::gui() && !OpenFlipper::Options::loadingSettings() ) {
// update scene graph
coreWidget_->examiner_widget_->lockUpdate();
coreWidget_->examiner_widget_->sceneGraph(root_node_scenegraph_);
coreWidget_->examiner_widget_->viewAll();
coreWidget_->examiner_widget_->setScenePos( coreWidget_->examiner_widget_->scene_center() ,
coreWidget_->examiner_widget_->scene_radius() /* 10.0*/ );
coreWidget_->examiner_widget_->setHome();
coreWidget_->examiner_widget_->drawMode( OpenFlipper::Options::standardDrawMode() );
coreWidget_->examiner_widget_->unlockUpdate();
coreWidget_->examiner_widget_->updateGL();
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
// update scene graph
coreWidget_->examiner_widgets_[i]->lockUpdate();
coreWidget_->examiner_widgets_[i]->sceneGraph(root_node_scenegraph_);
coreWidget_->examiner_widgets_[i]->viewAll();
coreWidget_->examiner_widgets_[i]->setScenePos( coreWidget_->examiner_widget_->scene_center() ,
coreWidget_->examiner_widget_->scene_radius() /* 10.0*/ );
coreWidget_->examiner_widgets_[i]->setHome();
coreWidget_->examiner_widgets_[i]->drawMode( OpenFlipper::Options::standardDrawMode() );
coreWidget_->examiner_widgets_[i]->unlockUpdate();
coreWidget_->examiner_widgets_[i]->updateGL();
}
}
}
......@@ -259,7 +263,7 @@ void Core::loadObject() {
if (supportedTypes_.size() != 0){
static LoadWidget* widget = 0;
// Open Widget
if ( !widget ){
widget = new LoadWidget(supportedTypes_);
......@@ -279,17 +283,17 @@ void Core::loadSettings(){
if ( OpenFlipper::Options::gui() ){
QString complete_name;
complete_name = ACG::getOpenFileName(coreWidget_,
tr("Load Settings"),
tr("INI files (*.ini);;OBJ files (*.obj)"),
OpenFlipper::Options::currentDirStr());
if (complete_name.isEmpty())
return;
QString newpath = complete_name.section(OpenFlipper::Options::dirSeparator(),0,-2);
OpenFlipper::Options::currentDir(newpath);
if ( complete_name.endsWith("ini") ) {
openIniFile(complete_name);
applyOptions();
......@@ -297,14 +301,14 @@ void Core::loadSettings(){
openObjFile(complete_name);
applyOptions();
}
coreWidget_->addRecent(complete_name, DATA_NONE);
}
}
/// Load settings from file
void Core::loadSettings(QString _filename){
if ( !QFile(_filename).exists() )
return;
......
......@@ -71,17 +71,7 @@ void Core::applyOptions(){
// Logger
coreWidget_->showLogger( !OpenFlipper::Options::hideLogger() );
//animation
coreWidget_->examiner_widget_->animation(OpenFlipper::Options::animation());
//Backface Culling
coreWidget_->examiner_widget_->backFaceCulling(OpenFlipper::Options::backfaceCulling());
//wheel zoom factor
coreWidget_->examiner_widget_->setWheelZoomFactor(OpenFlipper::Options::wheelZoomFactor());
coreWidget_->examiner_widget_->setWheelZoomFactorShift(OpenFlipper::Options::wheelZoomFactorShift());
// Picking Debugger
// Prepare Picking Debugger Flag
ACG::SceneGraph::PickTarget target;
if ( OpenFlipper::Options::pickingRenderMode() == "PICK_ANYHING") {
target = ACG::SceneGraph::PICK_ANYTHING;
......@@ -94,7 +84,23 @@ void Core::applyOptions(){
} else {
target = ACG::SceneGraph::PICK_ANYTHING;
}
coreWidget_->examiner_widget_->renderPicking(OpenFlipper::Options::renderPicking(), target );
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
//animation
coreWidget_->examiner_widgets_[i]->animation(OpenFlipper::Options::animation());
//Backface Culling
coreWidget_->examiner_widgets_[i]->backFaceCulling(OpenFlipper::Options::backfaceCulling());
//wheel zoom factor
coreWidget_->examiner_widgets_[i]->setWheelZoomFactor(OpenFlipper::Options::wheelZoomFactor());
coreWidget_->examiner_widgets_[i]->setWheelZoomFactorShift(OpenFlipper::Options::wheelZoomFactorShift());
// Picking Debugger
coreWidget_->examiner_widgets_[i]->renderPicking(OpenFlipper::Options::renderPicking(), target );
}
//hideToolbox
......
......@@ -51,14 +51,33 @@
void CoreWidget::slotCustomContextMenu( const QPoint& _point ) {
updatePopupMenu(_point);
QObject* senderPointer = sender();
unsigned int examinerId = 0;
QPoint popupPosition;
if ( senderPointer == 0 ) {
std::cerr << "Error : slotCustomContextMenu directly called! This should only be called by an examiner" << std::endl;
} else {
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets(); ++i ) {
if ( senderPointer == examiner_widgets_[i] ) {
popupPosition = examiner_widgets_[i]->glMapToGlobal(_point);
examinerId = i;
break;
}
}
}
updatePopupMenu(_point,examinerId);
// If not initialized, dont show it!!
if ( !contextMenu_->isEmpty () )
contextMenu_->exec( examiner_widget_->mapToGlobal(_point) );
contextMenu_->exec( popupPosition );
}
void CoreWidget::updatePopupMenu(const QPoint& _point) {
void CoreWidget::updatePopupMenu(const QPoint& _point, unsigned int _examinerId) {
contextMenu_->clear();
contextSelectionMenu_->clear();
......@@ -79,7 +98,7 @@ void CoreWidget::updatePopupMenu(const QPoint& _point) {
unsigned int node_idx, target_idx;
ACG::Vec3d hit_point;
BaseObjectData* object;
if (PluginFunctions::scenegraph_pick(ACG::SceneGraph::PICK_ANYTHING, _point,node_idx, target_idx, &hit_point)) {
if (examiner_widgets_[_examinerId]->pick( ACG::SceneGraph::PICK_ANYTHING,_point,node_idx, target_idx, &hit_point ) ) {
if ( PluginFunctions::get_picked_object(node_idx, object) )
objectId = object->id();
}
......
......@@ -68,7 +68,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
viewModeButton_(0),
viewModeMenu_(0),
viewGroup_(0),
examiner_widget_(0),
splitter_(0),
textedit_(0),
recentFilesMenu_(0),
......@@ -116,13 +115,65 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
QGLFormat format;
QGLFormat::setDefaultFormat(format);
format.setStereo( OpenFlipper::Options::stereo() );
examiner_widget_ = new ACG::QtWidgets::QtExaminerViewer(stackedWidget_,
"Examiner Widget",
statusBar_ ,
&format);
examiner_widget_->sceneGraph( PluginFunctions::getSceneGraphRootNode() );
examiner_widget_->enablePopupMenu(false);
stackedWidget_->addWidget(examiner_widget_);
QWidget* tmp = 0;
if ( !OpenFlipper::Options::multiView() ) {
examiner_widget_ = new ACG::QtWidgets::QtExaminerViewer(stackedWidget_,
"Examiner Widget",
statusBar_ ,
&format);
examiner_widgets_.push_back(examiner_widget_);
examiner_widget_->sceneGraph( PluginFunctions::getSceneGraphRootNode() );
examiner_widget_->enablePopupMenu(false);
stackedWidget_->addWidget(examiner_widget_);
} else {
// Create collector widget which holds all viewers
tmp = new QWidget(stackedWidget_);
// Create master examiner widget
examiner_widget_ = new ACG::QtWidgets::QtExaminerViewer(tmp,
"Examiner Widget",
statusBar_ ,
&format,
0,
ACG::QtWidgets::QtExaminerViewer::Nothing);
examiner_widgets_.push_back(examiner_widget_);
// Create all other examiners using the same gl context as the others
for ( unsigned int i = 1 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
ACG::QtWidgets::QtExaminerViewer* newWidget = new ACG::QtWidgets::QtExaminerViewer(tmp,
"Examiner Widget",
statusBar_ ,
&format,
examiner_widget_,
ACG::QtWidgets::QtExaminerViewer::Nothing);
examiner_widgets_.push_back(newWidget);
}
// Initialize all examiners
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
examiner_widgets_[i]->sceneGraph( PluginFunctions::getSceneGraphRootNode() );
examiner_widgets_[i]->enablePopupMenu(false);
}
QGridLayout* layout = new QGridLayout(tmp);
layout->addWidget(examiner_widgets_[0],0,0);
layout->addWidget(examiner_widgets_[1],0,1);
layout->addWidget(examiner_widgets_[2],1,0);
layout->addWidget(examiner_widgets_[3],1,1);
stackedWidget_->addWidget(tmp);
}
// ======================================================================
// Setup dragging for examiner widget
......@@ -135,6 +186,13 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
connect( examiner_widget_, SIGNAL(dropEvent( QDropEvent*)),
this, SLOT(dropEvent(QDropEvent* )));
if ( OpenFlipper::Options::multiView() ) {
// TODO: Check drag and drop for multiview
std::cerr << "Todo : Check drag and drop for multiview" << std::endl;
}
// ======================================================================
// Create main Toolbar
// ======================================================================
......@@ -148,8 +206,16 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
// Get Toolbar from examiner and integrate it into main window
// ======================================================================
// Take control over the toolbar
viewerToolbar_ = examiner_widget_->removeToolBar();
viewerToolbar_ = examiner_widgets_[0]->removeToolBar();
for ( unsigned int i = 1 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
examiner_widgets_[i]->removeToolBar();
examiner_widgets_[i]->removeToolBar();
examiner_widgets_[i]->removeToolBar();
}
addToolBar(Qt::TopToolBarArea,viewerToolbar_);
viewerToolbar_->setParent(this);
viewerToolbar_->setAllowedAreas(Qt::AllToolBarAreas);
......@@ -225,7 +291,11 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
// std::cerr << actions[i]->text().toStdString() << std::endl;
}
stackWidgetList_.push_back( StackWidgetInfo( false, "3D Examiner Widget", examiner_widget_ ) );
if ( !OpenFlipper::Options::multiView() ) {
stackWidgetList_.push_back( StackWidgetInfo( false, "3D Examiner Widget", examiner_widgets_[0] ) );
} else {
stackWidgetList_.push_back( StackWidgetInfo( false, "3D Examiner Widget", tmp ) );
}
// Remember logger size
wsizes = splitter_->sizes();
......@@ -249,8 +319,10 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
// Context menu setup
// ======================================================================
connect( examiner_widget_ , SIGNAL(signalCustomContextMenuRequested( const QPoint&) ) ,
this , SLOT( slotCustomContextMenu( const QPoint&) ) );
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
connect( examiner_widgets_[i] , SIGNAL(signalCustomContextMenuRequested( const QPoint&) ) ,
this , SLOT( slotCustomContextMenu( const QPoint&) ) );
}
contextMenu_ = new QMenu(this);
contextSelectionMenu_ = new QMenu("Selection",0);
......
......@@ -296,7 +296,10 @@ public:
public :
/// Examiner Widget
ACG::QtWidgets::QtExaminerViewer *examiner_widget_;
std::vector< ACG::QtWidgets::QtExaminerViewer* > examiner_widgets_;
/// temporary pointer pointing to first element of above vector for porting to multi view mode
ACG::QtWidgets::QtExaminerViewer* examiner_widget_;
///Spliter between toplevel objects and the textedit at the bottom
QSplitter* splitter_;
......@@ -382,7 +385,12 @@ public:
void changeBackgroundColor();
private :
void updatePopupMenu(const QPoint& _point);
/** Update the contextmenu for the given position inside an examiner widget
*
* @param _point Picking position in coordinates of the viewer
* @param _examinerId Id of the examinerWidget used
*/
void updatePopupMenu(const QPoint& _point, unsigned int _examinerId);
private :
/// context Menu for the gl area
......
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