2008-08-29 04:32:52 -05:00
|
|
|
|
|
|
|
// -*- C++ -*-
|
|
|
|
//
|
2008-11-26 03:35:07 -06:00
|
|
|
// This file is part of the Coriolis Software.
|
2012-12-31 05:52:42 -06:00
|
|
|
// Copyright (c) UPMC/LIP6 2008-2012, All Rights Reserved
|
2008-08-29 04:32:52 -05:00
|
|
|
//
|
2012-12-31 05:52:42 -06:00
|
|
|
// +-----------------------------------------------------------------+
|
2008-08-29 04:32:52 -05:00
|
|
|
// | H U R R I C A N E |
|
|
|
|
// | V L S I B a c k e n d D a t a - B a s e |
|
|
|
|
// | |
|
|
|
|
// | Author : Jean-Paul CHAPUT |
|
|
|
|
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
|
|
|
|
// | =============================================================== |
|
2008-11-26 03:35:07 -06:00
|
|
|
// | C++ Module : "./GraphicsWidget.cpp" |
|
2012-12-31 05:52:42 -06:00
|
|
|
// +-----------------------------------------------------------------+
|
2008-08-29 04:32:52 -05:00
|
|
|
|
|
|
|
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QRadioButton>
|
|
|
|
#include <QButtonGroup>
|
|
|
|
#include <QGroupBox>
|
2008-11-26 03:35:07 -06:00
|
|
|
#include <QVBoxLayout>
|
2008-08-29 04:32:52 -05:00
|
|
|
#include <QGridLayout>
|
|
|
|
|
|
|
|
#include "hurricane/viewer/Graphics.h"
|
|
|
|
#include "hurricane/viewer/DisplayStyle.h"
|
2008-11-26 04:13:31 -06:00
|
|
|
#include "hurricane/viewer/GraphicsWidget.h"
|
2008-08-29 04:32:52 -05:00
|
|
|
|
|
|
|
|
|
|
|
namespace Hurricane {
|
|
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
2008-11-26 03:35:07 -06:00
|
|
|
// Class : "GraphicsWidget".
|
2008-08-29 04:32:52 -05:00
|
|
|
|
|
|
|
|
2008-11-26 03:35:07 -06:00
|
|
|
GraphicsWidget::GraphicsWidget ( QWidget* parent )
|
2009-02-03 09:05:05 -06:00
|
|
|
: QWidget (parent)
|
|
|
|
, _cellWidget (NULL)
|
|
|
|
, _updateState(ExternalEmit)
|
2008-08-29 04:32:52 -05:00
|
|
|
{
|
|
|
|
setAttribute ( Qt::WA_QuitOnClose, false );
|
|
|
|
setWindowTitle ( tr("Display Styles") );
|
|
|
|
setFont ( Graphics::getNormalFont(true) );
|
|
|
|
|
|
|
|
QButtonGroup* group = new QButtonGroup ();
|
|
|
|
QGroupBox* groupBox = new QGroupBox ( tr("Display Styles") );
|
|
|
|
QGridLayout* gLayout = new QGridLayout ();
|
2008-11-26 03:35:07 -06:00
|
|
|
QVBoxLayout* wLayout = new QVBoxLayout ();
|
2008-08-29 04:32:52 -05:00
|
|
|
|
|
|
|
const vector<DisplayStyle*>& styles = Graphics::getStyles ();
|
|
|
|
DisplayStyle* activeStyle = Graphics::getStyle ();
|
|
|
|
|
|
|
|
size_t hideFallback = (styles.size() > 1) ? 1 : 0;
|
|
|
|
for ( size_t istyle=hideFallback ; istyle < styles.size() ; istyle++ ) {
|
|
|
|
QRadioButton* button = new QRadioButton ();
|
|
|
|
button->setText ( getString(styles[istyle]->getName()).c_str() );
|
|
|
|
if ( activeStyle == styles[istyle] )
|
|
|
|
button->setChecked ( true );
|
|
|
|
QLabel* label = new QLabel ();
|
|
|
|
label->setText ( styles[istyle]->getDescription().c_str() );
|
|
|
|
label->setFont ( Graphics::getNormalFont() );
|
|
|
|
|
|
|
|
gLayout->addWidget ( button, istyle-hideFallback, 0 );
|
|
|
|
gLayout->addWidget ( label , istyle-hideFallback, 1 );
|
2012-11-16 06:48:38 -06:00
|
|
|
group->addButton ( button, istyle );
|
2008-08-29 04:32:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
groupBox->setLayout ( gLayout );
|
2008-11-26 03:35:07 -06:00
|
|
|
wLayout->addWidget ( groupBox );
|
|
|
|
wLayout->addStretch ();
|
2008-08-29 04:32:52 -05:00
|
|
|
setLayout ( wLayout );
|
|
|
|
|
2009-02-03 09:05:05 -06:00
|
|
|
connect ( group, SIGNAL(buttonClicked(int)), this, SLOT(setStyle(int)) );
|
2008-08-29 04:32:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-02-03 09:05:05 -06:00
|
|
|
void GraphicsWidget::setCellWidget ( CellWidget* cw )
|
2008-08-29 04:32:52 -05:00
|
|
|
{
|
2009-02-03 09:05:05 -06:00
|
|
|
if ( _cellWidget ) {
|
|
|
|
disconnect ( _cellWidget, 0, this , 0 );
|
|
|
|
disconnect ( this , 0, _cellWidget, 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
_cellWidget = cw;
|
|
|
|
if ( !_cellWidget ) return;
|
|
|
|
|
|
|
|
connect ( _cellWidget, SIGNAL(styleChanged()), this, SLOT(changeStyle()) );
|
|
|
|
|
|
|
|
_updateState = ExternalEmit;
|
|
|
|
changeStyle ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GraphicsWidget::changeStyle ()
|
|
|
|
{
|
|
|
|
if ( _updateState != InternalEmit ) {
|
|
|
|
// Should read style here and sets the widget accordingly.
|
|
|
|
}
|
|
|
|
_updateState = ExternalEmit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GraphicsWidget::setStyle ( int id )
|
|
|
|
{
|
|
|
|
if ( _cellWidget ) {
|
|
|
|
_updateState = InternalEmit;
|
|
|
|
_cellWidget->setStyle ( (size_t)id );
|
|
|
|
}
|
2008-08-29 04:32:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|