1 // HexoticPlugin GUI: GUI for plugged-in mesher HexoticPlugin
3 // Copyright (C) 2003 CEA
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License.
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // See http://www.salome-platform.org or email : webmaster.salome@opencascade.org
23 // File : HexoticPluginGUI_HypothesisCreator.cxx
24 // Author : Lioka RAZAFINDRAZAKA (CEA)
25 // Module : HexoticPlugin
28 #include "HexoticPluginGUI_HypothesisCreator.h"
30 #include <SMESHGUI_Utils.h>
31 #include <SMESHGUI_HypothesesUtils.h>
33 #include CORBA_SERVER_HEADER(HexoticPlugin_Algorithm)
35 #include <SUIT_Session.h>
37 #include <SalomeApp_Tools.h>
39 #include <QtxIntSpinBox.h>
40 #include <QtxDblSpinBox.h>
42 #include <QtxComboBox.h>
45 #include <qgroupbox.h>
48 #include <qlineedit.h>
49 #include <qcheckbox.h>
62 HexoticPluginGUI_HypothesisCreator::HexoticPluginGUI_HypothesisCreator( const QString& theHypType )
63 : SMESHGUI_GenericHypothesisCreator( theHypType ),
68 HexoticPluginGUI_HypothesisCreator::~HexoticPluginGUI_HypothesisCreator()
72 bool HexoticPluginGUI_HypothesisCreator::checkParams() const
74 HexoticHypothesisData data_old, data_new;
75 readParamsFromHypo( data_old );
76 readParamsFromWidgets( data_new );
77 bool res = storeParamsToHypo( data_new );
81 QFrame* HexoticPluginGUI_HypothesisCreator::buildFrame()
83 QFrame* fr = new QFrame( 0, "myframe" );
84 QVBoxLayout* lay = new QVBoxLayout( fr, 7, 0 );
86 QGroupBox* GroupC1 = new QGroupBox( 2, Qt::Horizontal, fr, "GroupC1" );
87 lay->addWidget( GroupC1 );
89 GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) );
90 GroupC1->layout()->setSpacing( 6 );
91 GroupC1->layout()->setMargin( 11 );
95 new QLabel( tr( "SMESH_NAME" ), GroupC1 );
96 myName = new QLineEdit( GroupC1 );
99 HexoticPlugin::HexoticPlugin_Hypothesis_var h =
100 HexoticPlugin::HexoticPlugin_Hypothesis::_narrow( initParamsHypothesis() );
102 new QLabel( tr( "Hexotic_HEXES_MIN_LEVEL" ), GroupC1 );
103 myHexesMinLevel = new QtxIntSpinBox( GroupC1 );
104 // myHexesMinLevel->setMinValue( 3 );
105 myHexesMinLevel->setMinValue( h->GetHexesMinLevel() );
106 myHexesMinLevel->setMaxValue( 10 );
107 myHexesMinLevel->setLineStep( 1 );
109 new QLabel( tr( "Hexotic_HEXES_MAX_LEVEL" ), GroupC1 );
110 myHexesMaxLevel = new QtxIntSpinBox( GroupC1 );
111 myHexesMaxLevel->setMinValue( 3 );
112 myHexesMaxLevel->setMaxValue( 10 );
113 myHexesMaxLevel->setLineStep( 1 );
115 myHexoticQuadrangles = new QCheckBox( tr( "Hexotic_QUADRANGLES" ), GroupC1 );
116 GroupC1->addSpace(0);
119 myHexoticIgnoreRidges = new QCheckBox( tr( "Hexotic_IGNORE_RIDGES" ), GroupC1 );
120 GroupC1->addSpace(0);
122 myHexoticInvalidElements = new QCheckBox( tr( "Hexotic_INVALID_ELEMENTS" ), GroupC1 );
123 GroupC1->addSpace(0);
125 new QLabel( tr( "Hexotic_SHARP_ANGLE_THRESHOLD" ), GroupC1 );
126 myHexoticSharpAngleThreshold = new QtxIntSpinBox( GroupC1 );
127 myHexoticSharpAngleThreshold->setMinValue( 0 );
128 myHexoticSharpAngleThreshold->setMaxValue( 90 );
129 myHexoticSharpAngleThreshold->setLineStep( 1 );
134 void HexoticPluginGUI_HypothesisCreator::retrieveParams() const
136 HexoticHypothesisData data;
137 readParamsFromHypo( data );
140 myName->setText( data.myName );
141 myHexesMinLevel->setValue( data.myHexesMinLevel );
142 myHexesMaxLevel->setValue( data.myHexesMaxLevel );
143 myHexoticSharpAngleThreshold->setValue( data.myHexoticSharpAngleThreshold );
145 myHexoticQuadrangles->setChecked( data.myHexoticQuadrangles );
146 myHexoticIgnoreRidges->setChecked( data.myHexoticIgnoreRidges );
147 myHexoticInvalidElements->setChecked( data.myHexoticInvalidElements );
149 myHexesMinLevel->setEnabled(true);
150 myHexesMaxLevel->setEnabled(true);
151 myHexoticSharpAngleThreshold->setEnabled(true);
154 QString HexoticPluginGUI_HypothesisCreator::storeParams() const
156 HexoticHypothesisData data;
157 readParamsFromWidgets( data );
158 storeParamsToHypo( data );
161 valStr += tr("Hexotic_SEG_MIN_SIZE") + " = " + QString::number( data.myHexesMinLevel ) + "; ";
162 valStr += tr("Hexotic_SEG_MAX_SIZE") + " = " + QString::number( data.myHexesMaxLevel ) + "; ";
163 valStr += tr("Hexotic_QUADRANGLES") + " = " + QString::number( data.myHexoticQuadrangles ) + "; ";
164 valStr += tr("Hexotic_IGNORE_RIDGES") + " = " + QString::number( data.myHexoticIgnoreRidges ) + "; ";
165 valStr += tr("Hexotic_INVALID_ELEMENTS") + " = " + QString::number( data.myHexoticInvalidElements ) + "; ";
166 valStr += tr("Hexotic_SHARP_ANGLE_THRESHOLD") + " = " + QString::number( data.myHexoticSharpAngleThreshold ) + "; ";
171 bool HexoticPluginGUI_HypothesisCreator::readParamsFromHypo( HexoticHypothesisData& h_data ) const
173 HexoticPlugin::HexoticPlugin_Hypothesis_var h =
174 HexoticPlugin::HexoticPlugin_Hypothesis::_narrow( initParamsHypothesis() );
176 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
177 h_data.myName = isCreation() && data ? data->Label : "";
178 h_data.myHexesMinLevel = h->GetHexesMinLevel();
179 h_data.myHexesMaxLevel = h->GetHexesMaxLevel();
180 h_data.myHexoticQuadrangles = h->GetHexoticQuadrangles();
181 h_data.myHexoticIgnoreRidges = h->GetHexoticIgnoreRidges();
182 h_data.myHexoticInvalidElements = h->GetHexoticInvalidElements();
183 h_data.myHexoticSharpAngleThreshold = h->GetHexoticSharpAngleThreshold();
188 bool HexoticPluginGUI_HypothesisCreator::storeParamsToHypo( const HexoticHypothesisData& h_data ) const
190 HexoticPlugin::HexoticPlugin_Hypothesis_var h =
191 HexoticPlugin::HexoticPlugin_Hypothesis::_narrow( hypothesis() );
197 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.latin1() );
199 h->SetHexesMinLevel( h_data.myHexesMinLevel );
200 h->SetHexesMaxLevel( h_data.myHexesMaxLevel );
201 h->SetHexoticQuadrangles( h_data.myHexoticQuadrangles );
202 h->SetHexoticIgnoreRidges( h_data.myHexoticIgnoreRidges );
203 h->SetHexoticInvalidElements( h_data.myHexoticInvalidElements );
204 h->SetHexoticSharpAngleThreshold( h_data.myHexoticSharpAngleThreshold );
206 catch(const SALOME::SALOME_Exception& ex)
208 SalomeApp_Tools::QtCatchCorbaException(ex);
214 bool HexoticPluginGUI_HypothesisCreator::readParamsFromWidgets( HexoticHypothesisData& h_data ) const
216 h_data.myName = myName ? myName->text() : "";
217 h_data.myHexesMinLevel = myHexesMinLevel->value();
218 h_data.myHexesMaxLevel = myHexesMaxLevel->value();
219 h_data.myHexoticQuadrangles = myHexoticQuadrangles->isChecked();
220 h_data.myHexoticIgnoreRidges = myHexoticIgnoreRidges->isChecked();
221 h_data.myHexoticInvalidElements = myHexoticInvalidElements->isChecked();
222 h_data.myHexoticSharpAngleThreshold = myHexoticSharpAngleThreshold->value();
227 QString HexoticPluginGUI_HypothesisCreator::caption() const
229 return tr( QString( "Hexotic_%1_TITLE" ).arg(myIs3D?QString("3D"):QString("3D")) );
232 QPixmap HexoticPluginGUI_HypothesisCreator::icon() const
234 QString hypIconName = tr( QString("ICON_DLG_Hexotic_PARAMETERS%1").arg(myIs3D?QString(""):QString("")) );
235 return SUIT_Session::session()->resourceMgr()->loadPixmap( "HexoticPlugin", hypIconName );
238 QString HexoticPluginGUI_HypothesisCreator::type() const
240 return tr( QString( "Hexotic_%1_HYPOTHESIS" ).arg(myIs3D?QString("3D"):QString("3D")) );