2005-12-28 14:17:39 +05:00
|
|
|
// SMESH StdMeshersGUI : GUI for plugged-in meshers
|
|
|
|
//
|
|
|
|
// Copyright (C) 2003 CEA
|
|
|
|
//
|
|
|
|
// This library 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 2.1 of the License.
|
|
|
|
//
|
|
|
|
// This library 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 this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
//
|
2006-06-01 17:39:17 +06:00
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
2005-12-28 14:17:39 +05:00
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// File : StdMeshersGUI_StdHypothesisCreator.cxx
|
|
|
|
// Author : Alexander SOLOVYOV
|
|
|
|
// Module : SMESH
|
|
|
|
// $Header: /home/server/cvs/SMESH/SMESH_SRC/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx
|
|
|
|
|
|
|
|
#include "StdMeshersGUI_StdHypothesisCreator.h"
|
|
|
|
|
|
|
|
#include <SMESHGUI.h>
|
|
|
|
#include <SMESHGUI_SpinBox.h>
|
|
|
|
#include <SMESHGUI_HypothesesUtils.h>
|
|
|
|
#include <SMESHGUI_Utils.h>
|
|
|
|
|
|
|
|
#include <SUIT_ResourceMgr.h>
|
|
|
|
|
|
|
|
#include <SALOMEconfig.h>
|
|
|
|
#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
|
|
|
|
#include CORBA_SERVER_HEADER(SMESH_Mesh)
|
|
|
|
|
|
|
|
#include <qpixmap.h>
|
2006-02-07 20:01:11 +05:00
|
|
|
#include <qhbox.h>
|
|
|
|
#include <qslider.h>
|
|
|
|
#include <qlabel.h>
|
2005-12-28 14:17:39 +05:00
|
|
|
|
|
|
|
|
|
|
|
const double VALUE_MAX = 1.0e+15, // COORD_MAX
|
|
|
|
VALUE_MAX_2 = VALUE_MAX * VALUE_MAX,
|
|
|
|
VALUE_MAX_3 = VALUE_MAX_2 * VALUE_MAX,
|
|
|
|
VALUE_SMALL = 1.0e-15,
|
|
|
|
VALUE_SMALL_2 = VALUE_SMALL * VALUE_SMALL,
|
|
|
|
VALUE_SMALL_3 = VALUE_SMALL_2 * VALUE_SMALL;
|
|
|
|
|
|
|
|
StdMeshersGUI_StdHypothesisCreator::StdMeshersGUI_StdHypothesisCreator( const QString& type )
|
|
|
|
: SMESHGUI_GenericHypothesisCreator( type )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
StdMeshersGUI_StdHypothesisCreator::~StdMeshersGUI_StdHypothesisCreator()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
QFrame* StdMeshersGUI_StdHypothesisCreator::buildFrame()
|
|
|
|
{
|
|
|
|
return buildStdFrame();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool StdMeshersGUI_StdHypothesisCreator::checkParams() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void StdMeshersGUI_StdHypothesisCreator::retrieveParams() const
|
|
|
|
{
|
|
|
|
//here this method must be empty because buildStdParam sets values itself
|
|
|
|
}
|
|
|
|
|
2006-02-07 20:01:11 +05:00
|
|
|
QString StdMeshersGUI_StdHypothesisCreator::storeParams() const
|
2005-12-28 14:17:39 +05:00
|
|
|
{
|
|
|
|
ListOfStdParams params;
|
|
|
|
bool res = getStdParamFromDlg( params );
|
|
|
|
if( isCreation() )
|
|
|
|
{
|
|
|
|
SMESH::SetName( SMESH::FindSObject( hypothesis() ), params[0].myValue.toString().latin1() );
|
|
|
|
params.remove( params.begin() );
|
|
|
|
}
|
|
|
|
|
2006-02-07 20:01:11 +05:00
|
|
|
QString valueStr = stdParamValues( params );
|
|
|
|
|
2005-12-28 14:17:39 +05:00
|
|
|
if( res && !params.isEmpty() )
|
|
|
|
{
|
|
|
|
if( hypType()=="LocalLength" )
|
|
|
|
{
|
|
|
|
StdMeshers::StdMeshers_LocalLength_var h =
|
|
|
|
StdMeshers::StdMeshers_LocalLength::_narrow( hypothesis() );
|
|
|
|
|
|
|
|
h->SetLength( params[0].myValue.toDouble() );
|
|
|
|
}
|
|
|
|
else if( hypType()=="Arithmetic1D" )
|
|
|
|
{
|
|
|
|
StdMeshers::StdMeshers_Arithmetic1D_var h =
|
|
|
|
StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() );
|
|
|
|
|
|
|
|
h->SetLength( params[0].myValue.toDouble(), true );
|
|
|
|
h->SetLength( params[1].myValue.toDouble(), false );
|
|
|
|
}
|
|
|
|
else if( hypType()=="MaxElementArea" )
|
|
|
|
{
|
|
|
|
StdMeshers::StdMeshers_MaxElementArea_var h =
|
|
|
|
StdMeshers::StdMeshers_MaxElementArea::_narrow( hypothesis() );
|
|
|
|
|
|
|
|
h->SetMaxElementArea( params[0].myValue.toDouble() );
|
|
|
|
}
|
|
|
|
else if( hypType()=="MaxElementVolume" )
|
|
|
|
{
|
|
|
|
StdMeshers::StdMeshers_MaxElementVolume_var h =
|
|
|
|
StdMeshers::StdMeshers_MaxElementVolume::_narrow( hypothesis() );
|
|
|
|
|
|
|
|
h->SetMaxElementVolume( params[0].myValue.toDouble() );
|
|
|
|
}
|
|
|
|
else if( hypType()=="StartEndLength" )
|
|
|
|
{
|
|
|
|
StdMeshers::StdMeshers_StartEndLength_var h =
|
|
|
|
StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() );
|
|
|
|
|
|
|
|
h->SetLength( params[0].myValue.toDouble(), true );
|
|
|
|
h->SetLength( params[1].myValue.toDouble(), false );
|
|
|
|
}
|
|
|
|
else if( hypType()=="Deflection1D" )
|
|
|
|
{
|
|
|
|
StdMeshers::StdMeshers_Deflection1D_var h =
|
|
|
|
StdMeshers::StdMeshers_Deflection1D::_narrow( hypothesis() );
|
|
|
|
|
|
|
|
h->SetDeflection( params[0].myValue.toDouble() );
|
|
|
|
}
|
2006-02-07 20:01:11 +05:00
|
|
|
else if( hypType()=="AutomaticLength" )
|
|
|
|
{
|
|
|
|
StdMeshers::StdMeshers_AutomaticLength_var h =
|
|
|
|
StdMeshers::StdMeshers_AutomaticLength::_narrow( hypothesis() );
|
|
|
|
|
|
|
|
h->SetFineness( params[0].myValue.toDouble() );
|
|
|
|
}
|
2005-12-28 14:17:39 +05:00
|
|
|
}
|
2006-02-07 20:01:11 +05:00
|
|
|
return valueStr;
|
2005-12-28 14:17:39 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
|
|
|
|
{
|
|
|
|
bool res = true;
|
|
|
|
SMESHGUI_GenericHypothesisCreator::StdParam item;
|
|
|
|
|
|
|
|
p.clear();
|
|
|
|
if( isCreation() )
|
|
|
|
{
|
|
|
|
HypothesisData* data = SMESH::GetHypothesisData( hypType() );
|
|
|
|
item.myName = tr( "SMESH_NAME" );
|
|
|
|
item.myValue = data ? data->Label : QString();
|
|
|
|
p.append( item );
|
|
|
|
}
|
|
|
|
|
2006-02-07 20:01:11 +05:00
|
|
|
SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis();
|
|
|
|
|
2005-12-28 14:17:39 +05:00
|
|
|
if( hypType()=="LocalLength" )
|
|
|
|
{
|
|
|
|
StdMeshers::StdMeshers_LocalLength_var h =
|
2006-02-07 20:01:11 +05:00
|
|
|
StdMeshers::StdMeshers_LocalLength::_narrow( hyp );
|
2005-12-28 14:17:39 +05:00
|
|
|
|
|
|
|
item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
|
2006-02-07 20:01:11 +05:00
|
|
|
item.myValue = h->GetLength();
|
2005-12-28 14:17:39 +05:00
|
|
|
p.append( item );
|
|
|
|
}
|
|
|
|
else if( hypType()=="Arithmetic1D" )
|
|
|
|
{
|
|
|
|
StdMeshers::StdMeshers_Arithmetic1D_var h =
|
2006-02-07 20:01:11 +05:00
|
|
|
StdMeshers::StdMeshers_Arithmetic1D::_narrow( hyp );
|
2005-12-28 14:17:39 +05:00
|
|
|
|
|
|
|
item.myName = tr( "SMESH_START_LENGTH_PARAM" );
|
2006-02-07 20:01:11 +05:00
|
|
|
item.myValue = h->GetLength( true );
|
2005-12-28 14:17:39 +05:00
|
|
|
p.append( item );
|
|
|
|
item.myName = tr( "SMESH_END_LENGTH_PARAM" );
|
2006-02-07 20:01:11 +05:00
|
|
|
item.myValue = h->GetLength( false );
|
2005-12-28 14:17:39 +05:00
|
|
|
p.append( item );
|
|
|
|
}
|
|
|
|
else if( hypType()=="MaxElementArea" )
|
|
|
|
{
|
|
|
|
StdMeshers::StdMeshers_MaxElementArea_var h =
|
2006-02-07 20:01:11 +05:00
|
|
|
StdMeshers::StdMeshers_MaxElementArea::_narrow( hyp );
|
2005-12-28 14:17:39 +05:00
|
|
|
|
|
|
|
item.myName = tr( "SMESH_MAX_ELEMENT_AREA_PARAM" );
|
2006-02-07 20:01:11 +05:00
|
|
|
item.myValue = h->GetMaxElementArea();
|
2005-12-28 14:17:39 +05:00
|
|
|
p.append( item );
|
|
|
|
}
|
|
|
|
else if( hypType()=="MaxElementVolume" )
|
|
|
|
{
|
|
|
|
StdMeshers::StdMeshers_MaxElementVolume_var h =
|
2006-02-07 20:01:11 +05:00
|
|
|
StdMeshers::StdMeshers_MaxElementVolume::_narrow( hyp );
|
2005-12-28 14:17:39 +05:00
|
|
|
|
|
|
|
item.myName = tr( "SMESH_MAX_ELEMENT_VOLUME_PARAM" );
|
2006-02-07 20:01:11 +05:00
|
|
|
item.myValue = h->GetMaxElementVolume();
|
2005-12-28 14:17:39 +05:00
|
|
|
p.append( item );
|
|
|
|
}
|
|
|
|
else if( hypType()=="StartEndLength" )
|
|
|
|
{
|
|
|
|
StdMeshers::StdMeshers_StartEndLength_var h =
|
2006-02-07 20:01:11 +05:00
|
|
|
StdMeshers::StdMeshers_StartEndLength::_narrow( hyp );
|
2005-12-28 14:17:39 +05:00
|
|
|
|
|
|
|
item.myName = tr( "SMESH_START_LENGTH_PARAM" );
|
2006-02-07 20:01:11 +05:00
|
|
|
item.myValue = h->GetLength( true );
|
2005-12-28 14:17:39 +05:00
|
|
|
p.append( item );
|
|
|
|
item.myName = tr( "SMESH_END_LENGTH_PARAM" );
|
2006-02-07 20:01:11 +05:00
|
|
|
item.myValue = h->GetLength( false );
|
2005-12-28 14:17:39 +05:00
|
|
|
p.append( item );
|
|
|
|
}
|
|
|
|
else if( hypType()=="Deflection1D" )
|
|
|
|
{
|
|
|
|
StdMeshers::StdMeshers_Deflection1D_var h =
|
2006-02-07 20:01:11 +05:00
|
|
|
StdMeshers::StdMeshers_Deflection1D::_narrow( hyp );
|
2005-12-28 14:17:39 +05:00
|
|
|
|
|
|
|
item.myName = tr( "SMESH_DEFLECTION1D_PARAM" );
|
2006-02-07 20:01:11 +05:00
|
|
|
item.myValue = h->GetDeflection();
|
|
|
|
p.append( item );
|
|
|
|
}
|
|
|
|
else if( hypType()=="AutomaticLength" )
|
|
|
|
{
|
|
|
|
StdMeshers::StdMeshers_AutomaticLength_var h =
|
|
|
|
StdMeshers::StdMeshers_AutomaticLength::_narrow( hyp );
|
|
|
|
|
|
|
|
item.myName = tr( "SMESH_FINENESS_PARAM" );
|
|
|
|
item.myValue = h->GetFineness();
|
2005-12-28 14:17:39 +05:00
|
|
|
p.append( item );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
res = false;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget( QWidget* w, const int ) const
|
|
|
|
{
|
|
|
|
SMESHGUI_SpinBox* sb = w->inherits( "SMESHGUI_SpinBox" ) ? ( SMESHGUI_SpinBox* )w : 0;
|
|
|
|
if( hypType()=="LocalLength" && sb )
|
|
|
|
{
|
|
|
|
sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, 6 );
|
|
|
|
}
|
|
|
|
else if( hypType()=="Arithmetic1D" && sb )
|
|
|
|
{
|
|
|
|
sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, 6 );
|
|
|
|
}
|
|
|
|
else if( hypType()=="MaxElementArea" && sb )
|
|
|
|
{
|
|
|
|
sb->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 1.0, 6 );
|
|
|
|
}
|
|
|
|
else if( hypType()=="MaxElementVolume" && sb )
|
|
|
|
{
|
|
|
|
sb->RangeStepAndValidator( VALUE_SMALL_3, VALUE_MAX_3, 1.0, 6 );
|
|
|
|
}
|
|
|
|
else if( hypType()=="StartEndLength" && sb )
|
|
|
|
{
|
|
|
|
sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, 6 );
|
|
|
|
}
|
|
|
|
else if( hypType()=="Deflection1D" && sb )
|
|
|
|
{
|
|
|
|
sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, 6 );
|
|
|
|
}
|
2006-05-06 14:51:48 +06:00
|
|
|
else if ( sb ) // default validator for possible ancestors
|
|
|
|
{
|
|
|
|
sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, 6 );
|
|
|
|
}
|
2005-12-28 14:17:39 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
QString StdMeshersGUI_StdHypothesisCreator::caption() const
|
|
|
|
{
|
|
|
|
return tr( QString( "SMESH_%1_TITLE" ).arg( hypTypeName( hypType() ) ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
QPixmap StdMeshersGUI_StdHypothesisCreator::icon() const
|
|
|
|
{
|
|
|
|
QString hypIconName = tr( QString( "ICON_DLG_%1" ).arg( hypTypeName( hypType() ) ) );
|
|
|
|
return SMESHGUI::resourceMgr()->loadPixmap( "SMESH", hypIconName );
|
|
|
|
}
|
|
|
|
|
|
|
|
QString StdMeshersGUI_StdHypothesisCreator::type() const
|
|
|
|
{
|
|
|
|
return tr( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeName( hypType() ) ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) const
|
|
|
|
{
|
|
|
|
static QMap<QString,QString> types;
|
|
|
|
if( types.isEmpty() )
|
|
|
|
{
|
|
|
|
types.insert( "LocalLength", "LOCAL_LENGTH" );
|
|
|
|
types.insert( "NumberOfSegments", "NB_SEGMENTS" );
|
|
|
|
types.insert( "MaxElementArea", "MAX_ELEMENT_AREA" );
|
|
|
|
types.insert( "MaxElementVolume", "MAX_ELEMENT_VOLUME" );
|
|
|
|
types.insert( "StartEndLength", "START_END_LENGTH" );
|
|
|
|
types.insert( "Deflection1D", "DEFLECTION1D" );
|
|
|
|
types.insert( "Arithmetic1D", "ARITHMETIC_1D" );
|
2006-02-07 20:01:11 +05:00
|
|
|
types.insert( "AutomaticLength", "AUTOMATIC_LENGTH" );
|
2005-12-28 14:17:39 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
QString res;
|
|
|
|
if( types.contains( t ) )
|
|
|
|
res = types[ t ];
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
2006-02-07 20:01:11 +05:00
|
|
|
|
|
|
|
//================================================================================
|
|
|
|
/*!
|
|
|
|
* \brief Widget: slider with left and right labels
|
|
|
|
*/
|
|
|
|
//================================================================================
|
|
|
|
|
|
|
|
class TDoubleSliderWith2Lables: public QHBox
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TDoubleSliderWith2Lables( const QString& leftLabel, const QString& rightLabel,
|
|
|
|
const double initValue, const double bottom,
|
|
|
|
const double top , const double precision,
|
|
|
|
QWidget * parent=0 , const char * name=0 )
|
|
|
|
:QHBox(parent,name), _bottom(bottom), _precision(precision)
|
|
|
|
{
|
|
|
|
if ( !leftLabel.isEmpty() ) (new QLabel( this ))->setText( leftLabel );
|
|
|
|
_slider = new QSlider( Horizontal, this );
|
|
|
|
_slider->setRange( 0, toInt( top ));
|
|
|
|
_slider->setValue( toInt( initValue ));
|
|
|
|
if ( !rightLabel.isEmpty() ) (new QLabel( this ))->setText( rightLabel );
|
|
|
|
}
|
|
|
|
double value() const { return _bottom + _slider->value() * _precision; }
|
|
|
|
QSlider * getSlider() const { return _slider; }
|
|
|
|
int toInt( double val ) const { return (int) ceil(( val - _bottom ) / _precision ); }
|
|
|
|
private:
|
|
|
|
double _bottom, _precision;
|
|
|
|
QSlider * _slider;
|
|
|
|
};
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
//function : getCustomWidget
|
|
|
|
//purpose :
|
|
|
|
//=======================================================================
|
|
|
|
|
|
|
|
QWidget* StdMeshersGUI_StdHypothesisCreator::getCustomWidget( const StdParam & param,
|
|
|
|
QWidget* parent) const
|
|
|
|
{
|
|
|
|
if ( hypType()=="AutomaticLength" && param.myValue.type() == QVariant::Double )
|
|
|
|
return new TDoubleSliderWith2Lables( "0 ", " 1", param.myValue.toDouble(),
|
|
|
|
0, 1, 0.01, parent );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
//function : getParamFromCustomWidget
|
|
|
|
//purpose :
|
|
|
|
//=======================================================================
|
|
|
|
|
|
|
|
bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & param,
|
|
|
|
QWidget* widget) const
|
|
|
|
{
|
|
|
|
if ( hypType()=="AutomaticLength" ) {
|
|
|
|
TDoubleSliderWith2Lables* w = dynamic_cast<TDoubleSliderWith2Lables*>( widget );
|
|
|
|
if ( w ) {
|
|
|
|
param.myValue = w->value();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|