Création d'un compte pour un collaborateur extérieur au laboratoire depuis l'intranet ICube : https://intranet.icube.unistra.fr/fr/labs/member/profile

Commit 49887cd8 authored by Frédéric Larue's avatar Frédéric Larue
Browse files

UIParamVector2 and UIParamVector3 added.

parent 25fa9adc
......@@ -35,6 +35,8 @@
#include "UIParamSlider.h"
#include "UIParamPath.h"
#include "UIParamByteSize.h"
#include "UIParamVector2.h"
#include "UIParamVector3.h"
......@@ -85,6 +87,8 @@ public:
inline UIParamSlider* GetSlider ( const QString &paramName ) const { return GetParam<UIParamSlider >( paramName ); }
inline UIParamPath* GetPath ( const QString &paramName ) const { return GetParam<UIParamPath >( paramName ); }
inline UIParamByteSize* GetByteSize ( const QString &paramName ) const { return GetParam<UIParamByteSize >( paramName ); }
inline UIParamVector2* GetVector2 ( const QString &paramName ) const { return GetParam<UIParamVector2 >( paramName ); }
inline UIParamVector3* GetVector3 ( const QString &paramName ) const { return GetParam<UIParamVector3 >( paramName ); }
inline UIParamAnimation* GetAnimationCtrl () const { return m_AnimationCtrl; }
inline const QList<UIParamAction*>& GetActions() const { return m_Actions; }
......
/*
* (c) LSIIT, UMR CNRS/UdS
* Authors: F. Larue.
*
* See licence.txt for additional information.
*/
#include "UIParamVector2.h"
UIParamVector2::UIParamVector2( const QString& id,
const QString& name,
const QString& description,
float x, float y,
float min, float max, float step ) : UIParam(id,name,description)
{
QGridLayout *l = new QGridLayout();
l->setContentsMargins(0,0,0,0);
l->setSpacing(0);
m_SpinChannels.resize(2);
for(int i=0; i<2; ++i)
{
m_SpinChannels[i] = new QDoubleSpinBox();
m_SpinChannels[i]->setRange( min, max );
m_SpinChannels[i]->setSingleStep( step );
l->addWidget(m_SpinChannels[i],0,i);
}
m_SpinChannels[0]->setValue( x );
m_SpinChannels[1]->setValue( y );
connect( m_SpinChannels[0], SIGNAL(valueChanged(double)), this, SLOT(VectorChannelChanged()) );
connect( m_SpinChannels[1], SIGNAL(valueChanged(double)), this, SLOT(VectorChannelChanged()) );
m_Widget = new QWidget();
m_Widget->setLayout(l);
}
void UIParamVector2::VectorChannelChanged()
{
emit valueChanged( QVector2D( m_SpinChannels[0]->value(), m_SpinChannels[1]->value() ) );
}
QString UIParamVector2::ValueString() const
{
QString str = QString::number( m_SpinChannels[0]->value() ) + " " +
QString::number( m_SpinChannels[1]->value() );
return str;
}
bool UIParamVector2::SetValueString( const QString &valueString )
{
QStringList dimensions = valueString.simplified().split( ' ' );
if( dimensions.size() != 2 )
return false;
bool ok;
double x = dimensions.front().toDouble( &ok );
if( !ok )
return false;
double y = dimensions.back().toDouble( &ok );
if( !ok )
return false;
SetValue( QVector2D(x,y) );
return true;
}
/*
* (c) LSIIT, UMR CNRS/UdS
* Authors: F. Larue.
*
* See licence.txt for additional information.
*/
#ifndef UIPARAMVECTOR2_H
#define UIPARAMVECTOR2_H
#include "UIParam.h"
class UIParamVector2 : public UIParam
{
Q_OBJECT
QVector<QDoubleSpinBox*> m_SpinChannels;
public:
UIParamVector2( const QString& id,
const QString& name,
const QString& description,
float x, float y,
float min = -100.0f, float max = 100.0f, float step = 1.0f );
inline UIParamVector2( const QString& id,
const QString& name,
const QString& description,
const QVector2D& v,
float min = -100.0f, float max = 100.0f, float step = 1.0f ) : UIParamVector2( id, name, description, v.x(), v.y(), min, max, step ) {}
inline void SetValue( const QVector2D &v ) { m_SpinChannels[0]->setValue(v.x()); m_SpinChannels[1]->setValue(v.y()); }
inline QVector2D Value() const { return QVector2D( m_SpinChannels[0]->value(), m_SpinChannels[1]->value() ); }
inline const QVector<QDoubleSpinBox*> Widget() const { return m_SpinChannels; }
inline QVector<QDoubleSpinBox*> Widget() { return m_SpinChannels; }
inline void ConnectModificationSignal();
virtual QString ValueString() const;
virtual bool SetValueString( const QString &valueString );
signals:
void valueChanged( const QVector2D& v );
public slots:
void VectorChannelChanged();
};
void UIParamVector2::ConnectModificationSignal()
{
QObject::connect( m_SpinChannels[0], SIGNAL(valueChanged(double)), this, SLOT(triggerParameterUpdate()) );
QObject::connect( m_SpinChannels[1], SIGNAL(valueChanged(double)), this, SLOT(triggerParameterUpdate()) );
}
#endif // UIPARAMVECTOR2_H
/*
* (c) LSIIT, UMR CNRS/UdS
* Authors: F. Larue.
*
* See licence.txt for additional information.
*/
#include "UIParamVector3.h"
UIParamVector3::UIParamVector3( const QString& id,
const QString& name,
const QString& description,
float x, float y, float z,
float min, float max, float step ) : UIParam(id,name,description)
{
QGridLayout *l = new QGridLayout();
l->setContentsMargins(0,0,0,0);
l->setSpacing(0);
m_SpinChannels.resize(3);
for(int i=0; i<3; ++i)
{
m_SpinChannels[i] = new QDoubleSpinBox();
m_SpinChannels[i]->setRange( min, max );
m_SpinChannels[i]->setSingleStep( step );
l->addWidget(m_SpinChannels[i],0,i);
}
m_SpinChannels[0]->setValue( x );
m_SpinChannels[1]->setValue( y );
m_SpinChannels[2]->setValue( z );
connect( m_SpinChannels[0], SIGNAL(valueChanged(double)), this, SLOT(VectorChannelChanged()) );
connect( m_SpinChannels[1], SIGNAL(valueChanged(double)), this, SLOT(VectorChannelChanged()) );
connect( m_SpinChannels[2], SIGNAL(valueChanged(double)), this, SLOT(VectorChannelChanged()) );
m_Widget = new QWidget();
m_Widget->setLayout(l);
}
void UIParamVector3::VectorChannelChanged()
{
emit valueChanged( QVector3D( m_SpinChannels[0]->value(), m_SpinChannels[1]->value(), m_SpinChannels[2]->value() ) );
}
QString UIParamVector3::ValueString() const
{
QString str = QString::number( m_SpinChannels[0]->value() ) + " " +
QString::number( m_SpinChannels[1]->value() ) + " " +
QString::number( m_SpinChannels[2]->value() );
return str;
}
bool UIParamVector3::SetValueString( const QString &valueString )
{
QStringList dimensions = valueString.simplified().split( ' ' );
if( dimensions.size() != 3 )
return false;
bool ok;
double x = dimensions[0].toDouble( &ok );
if( !ok )
return false;
double y = dimensions[1].toDouble( &ok );
if( !ok )
return false;
double z = dimensions[2].toDouble( &ok );
if( !ok )
return false;
SetValue( QVector3D(x,y,z) );
return true;
}
/*
* (c) LSIIT, UMR CNRS/UdS
* Authors: F. Larue.
*
* See licence.txt for additional information.
*/
#ifndef UIPARAMVECTOR3_H
#define UIPARAMVECTOR3_H
#include "UIParam.h"
class UIParamVector3 : public UIParam
{
Q_OBJECT
QVector<QDoubleSpinBox*> m_SpinChannels;
public:
UIParamVector3( const QString& id,
const QString& name,
const QString& description,
float x, float y, float z,
float min = -100.0f, float max = 100.0f, float step = 1.0f );
inline UIParamVector3( const QString& id,
const QString& name,
const QString& description,
const QVector3D& v,
float min = -100.0f, float max = 100.0f, float step = 1.0f ) : UIParamVector3( id, name, description, v.x(), v.y(), v.z(), min, max, step ) {}
inline void SetValue( const QVector3D &v ) { m_SpinChannels[0]->setValue(v.x()); m_SpinChannels[1]->setValue(v.y()); m_SpinChannels[2]->setValue(v.z()); }
inline QVector3D Value() const { return QVector3D( m_SpinChannels[0]->value(), m_SpinChannels[1]->value(), m_SpinChannels[2]->value() ); }
inline const QVector<QDoubleSpinBox*> Widget() const { return m_SpinChannels; }
inline QVector<QDoubleSpinBox*> Widget() { return m_SpinChannels; }
inline void ConnectModificationSignal();
virtual QString ValueString() const;
virtual bool SetValueString( const QString &valueString );
signals:
void valueChanged( const QVector3D& v );
public slots:
void VectorChannelChanged();
};
void UIParamVector3::ConnectModificationSignal()
{
QObject::connect( m_SpinChannels[0], SIGNAL(valueChanged(double)), this, SLOT(triggerParameterUpdate()) );
QObject::connect( m_SpinChannels[1], SIGNAL(valueChanged(double)), this, SLOT(triggerParameterUpdate()) );
QObject::connect( m_SpinChannels[2], SIGNAL(valueChanged(double)), this, SLOT(triggerParameterUpdate()) );
}
#endif // UIPARAMVECTOR3_H
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