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

Removed synch from internal widget

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@4479 383ad7c9-94d9-4d36-a494-682f7c89f535
parent d8f6b0a2
......@@ -839,22 +839,6 @@ void Core::slotExit() {
qApp->quit();
}
/// Synchronise two viewers
bool Core::add_sync_host(const QString& _name)
{
// Todo : Only syncing one Viewer
if ( OpenFlipper::Options::gui() ) {
emit log(LOGINFO,"Adding SyncHost");
bool ok = coreWidget_->examiner_widgets_[0]->add_sync_host(_name);
if (ok)
coreWidget_->examiner_widgets_[0]->setSynchronization(true);
else
emit log(LOGERR,"Sync failed! ");
return ok;
}
return false;
}
/// log to file
void Core::slotLogToFile(Logtype _type, QString _message){
......
......@@ -432,7 +432,6 @@ void Core::writeApplicationOptions(INIFile& _ini) {
_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_widgets_[0]->wheelZoomFactor());
......
......@@ -251,16 +251,6 @@ void CoreWidget::updatePopupMenu(const QPoint& _point, unsigned int _examinerId)
//====================================================================================================
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 );
......@@ -352,7 +342,6 @@ void CoreWidget::slotCopyView( ) {
}
void CoreWidget::updateGlobalOptions(bool /*_enable*/){
OpenFlipper::Options::synchronization( examiner_widgets_[0]->synchronization() );
OpenFlipper::Options::animation( examiner_widgets_[0]->animation() );
OpenFlipper::Options::backfaceCulling( examiner_widgets_[0]->backFaceCulling() );
OpenFlipper::Options::twoSidedLighting( examiner_widgets_[0]->twoSidedLighting() );
......
......@@ -121,9 +121,7 @@ void CoreWidget::slotFunctionMenuUpdate() {
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" )
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());
......
......@@ -192,23 +192,6 @@ QtBaseViewer::QtBaseViewer( QWidget* _parent,
examineMode();
// clipboard sync stuff
synchronized_ = false;
skipNextSync_ = false;
socket_ = new QUdpSocket();
for (int i=6666; i<6676; ++i)
if ( socket_->bind( i ) )
{
std::cout << "listen on port " << i << "\n";
break;
}
add_sync_host("127.0.0.1");
// Note: we start locked (initialization of updateLocked_)
// will be unlocked in initializeGL()
......@@ -232,8 +215,6 @@ QtBaseViewer::~QtBaseViewer()
delete snapshot_;
delete glstate_;
delete sceneGraphDialog_;
delete socket_;
// delete socket_notifier_;
}
......@@ -1295,10 +1276,6 @@ void QtBaseViewer::actionDrawMenu( QAction * _action )
//-----------------------------------------------------------------------------
bool QtBaseViewer::synchronization(){
return synchronized_;
}
void
QtBaseViewer::createWidgets(const QGLFormat* _format,
QStatusBar* _sb,
......@@ -1539,8 +1516,6 @@ void QtBaseViewer::rotate(const ACG::Vec3d& _axis,
glstate_->translate(-t[0], -t[1], -t[2], ACG::MULT_FROM_LEFT);
glstate_->rotate(_angle, _axis[0], _axis[1], _axis[2], ACG::MULT_FROM_LEFT);
glstate_->translate( t[0], t[1], t[2], ACG::MULT_FROM_LEFT);
sync_send( glstate_->modelview(), glstate_->inverse_modelview() );
}
......
......@@ -894,57 +894,6 @@ private:
/** @} */
//===========================================================================
/** @name Synchronize different viewers
* @{ */
//===========================================================================
public:
/** Synchronize with other QtBaseViewer. A QtBaseViewer can
be synchronized with other instances. The viewing position is
copied from the other widget after each transformation.
*/
void sync_connect(const QtBaseViewer*);
/// unsync two sync_connect()ed QtBaseViewer's
void sync_disconnect(const QtBaseViewer*);
/// add host to synchronize with, given by its name
bool add_sync_host(const QString& _name);
/// add host to synchronize with, given by its address
void add_sync_host(QHostAddress& _adr);
bool synchronization();
public slots:
/// toggle global synchronization
virtual void setSynchronization(bool _b);
private slots:
void sync_receive();
void sync_send(const ACG::GLMatrixd& _modelview,
const ACG::GLMatrixd& _inverse_modelview);
private:
/// synchronized with different viewer?
bool synchronized_;
/// Skips the next synch event
bool skipNextSync_;
/// socket used for synchronization
QUdpSocket * socket_;
/// List of hosts which should receive sync information
std::vector<QHostAddress> sync_hosts_;
/** @} */
//===========================================================================
/** @name Snapshots
* @{ */
......
//=============================================================================
//
// 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: 3599 $
// $Author: moebius $
// $Date: 2008-10-29 09:01:26 +0100 (Mi, 29. Okt 2008) $
//
//=============================================================================
//=============================================================================
//
// CLASS QtBaseViewer - IMPLEMENTATION
//
//=============================================================================
//== INCLUDES =================================================================
#include "QtBaseViewer.hh"
#include "QtGLGraphicsScene.hh"
#include "QtGLGraphicsView.hh"
#include <QHostInfo>
//== NAMESPACES ===============================================================
//== IMPLEMENTATION ==========================================================
void QtBaseViewer::sync_connect(const QtBaseViewer* _other)
{
connect(_other,
SIGNAL(signalSetView(const GLMatrixd&, const GLMatrixd&)),
this,
SLOT(setView(const GLMatrixd&, const GLMatrixd&)));
}
//-----------------------------------------------------------------------------
void QtBaseViewer::sync_disconnect(const QtBaseViewer* _other)
{
disconnect(_other,
SIGNAL(signalSetView(const GLMatrixd&, const GLMatrixd&)),
this,
SLOT(setView(const GLMatrixd&, const GLMatrixd&)));
}
//-----------------------------------------------------------------------------
void QtBaseViewer::sync_send(const ACG::GLMatrixd&, const ACG::GLMatrixd&)
{
const ACG::GLMatrixd m = glstate_->modelview();
const ACG::GLMatrixd p = glstate_->projection();
QByteArray datagram;
QDataStream out(&datagram, QIODevice::WriteOnly);
out.setVersion(5);
quint64 myId = (quint64) winId();
out << myId
<< m(0,0) << m(0,1) << m(0,2) << m(0,3)
<< m(1,0) << m(1,1) << m(1,2) << m(1,3)
<< m(2,0) << m(2,1) << m(2,2) << m(2,3)
<< m(3,0) << m(3,1) << m(3,2) << m(3,3)
<< p(0,0) << p(0,1) << p(0,2) << p(0,3)
<< p(1,0) << p(1,1) << p(1,2) << p(1,3)
<< p(2,0) << p(2,1) << p(2,2) << p(2,3)
<< p(3,0) << p(3,1) << p(3,2) << p(3,3)
<< glWidth() << glHeight()
<< projectionMode_
<< orthoWidth_;
for (int h=0, n=sync_hosts_.size(); h<n; ++h)
for (int i=6666; i<6676; ++i)
if (i != socket_->localPort() || h != 0)
socket_->writeDatagram( datagram, datagram.size(),sync_hosts_[h], i);
}
void QtBaseViewer::sync_receive()
{
ACG::GLMatrixd m, p;
int w, h, pMode;
quint64 id, myId = (quint64) winId();
QByteArray datagram( socket_->pendingDatagramSize(), 'x' );
socket_->readDatagram( datagram.data(), datagram.size() );
if (datagram.size() < 280)
return;
QDataStream in( & datagram, QIODevice::ReadOnly);
in.setVersion(5);
in >> id;
if (id == myId)
return;
in >> m(0,0) >> m(0,1) >> m(0,2) >> m(0,3)
>> m(1,0) >> m(1,1) >> m(1,2) >> m(1,3)
>> m(2,0) >> m(2,1) >> m(2,2) >> m(2,3)
>> m(3,0) >> m(3,1) >> m(3,2) >> m(3,3)
>> p(0,0) >> p(0,1) >> p(0,2) >> p(0,3)
>> p(1,0) >> p(1,1) >> p(1,2) >> p(1,3)
>> p(2,0) >> p(2,1) >> p(2,2) >> p(2,3)
>> p(3,0) >> p(3,1) >> p(3,2) >> p(3,3)
>> w >> h >> pMode >> orthoWidth_;
blockSignals(true);
makeCurrent();
if (projectionMode_ != (ProjectionMode)pMode)
projectionMode((ProjectionMode)pMode);
glstate_->set_modelview(m);
std::cerr << "Todo : Checkbox if size should be applied to" << std::endl;
// if (w>0 && h>0 &&
// action_["PasteDropSize"]->isChecked() )
// {
// glstate_->set_projection(p);
// glView_->setFixedSize(w,h);
// updateGeometry();
// }
blockSignals(false);
updateGL();
}
//-----------------------------------------------------------------------------
void QtBaseViewer::setSynchronization(bool _b)
{
emit functionMenuUpdate();
synchronized_ = _b;
if (synchronized_)
{
connect(socket_,
SIGNAL(readyRead()),
this,
SLOT(sync_receive()));
connect(this,
SIGNAL(signalSetView(const GLMatrixd&, const GLMatrixd&)),
this,
SLOT(sync_send(const GLMatrixd&, const GLMatrixd&)));
}
else
{
disconnect(socket_,
SIGNAL( readyRead() ),
this,
SLOT(sync_receive()));
disconnect(this,
SIGNAL(signalSetView(const GLMatrixd&, const GLMatrixd&)),
this,
SLOT(sync_send(const GLMatrixd&, const GLMatrixd&)));
}
}
//----------------------------------------------------------------------------
bool QtBaseViewer::add_sync_host(const QString& _name)
{
QHostAddress adr;
if (adr.setAddress(_name))
{
add_sync_host(adr);
return true;
}
// QT4
// use DNS otherwise
QHostInfo hi = QHostInfo::fromName( _name );
QList<QHostAddress> list = hi.addresses();
if (!list.empty())
{
add_sync_host(list.front());
return true;
}
return false;
}
void QtBaseViewer::add_sync_host(QHostAddress& _adr)
{
sync_hosts_.push_back(_adr);
}
//=============================================================================
//=============================================================================
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