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 <QtxComboBox.h>
43 #include <qgroupbox.h>
46 #include <qlineedit.h>
47 #include <qcheckbox.h>
60 HexoticPluginGUI_HypothesisCreator::HexoticPluginGUI_HypothesisCreator( const QString& theHypType )
61 : SMESHGUI_GenericHypothesisCreator( theHypType ),
66 HexoticPluginGUI_HypothesisCreator::~HexoticPluginGUI_HypothesisCreator()
70 bool HexoticPluginGUI_HypothesisCreator::checkParams() const
72 HexoticHypothesisData data_old, data_new;
73 readParamsFromHypo( data_old );
74 readParamsFromWidgets( data_new );
75 bool res = storeParamsToHypo( data_new );
79 QFrame* HexoticPluginGUI_HypothesisCreator::buildFrame()
81 QFrame* fr = new QFrame( 0, "myframe" );
82 QVBoxLayout* lay = new QVBoxLayout( fr, 5, 0 );
84 QGroupBox* GroupC1 = new QGroupBox( 2, Qt::Horizontal, fr, "GroupC1" );
85 lay->addWidget( GroupC1 );
87 GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) );
88 GroupC1->layout()->setSpacing( 6 );
89 GroupC1->layout()->setMargin( 11 );
93 new QLabel( tr( "SMESH_NAME" ), GroupC1 );
94 myName = new QLineEdit( GroupC1 );
97 HexoticPlugin::HexoticPlugin_Hypothesis_var h =
98 HexoticPlugin::HexoticPlugin_Hypothesis::_narrow( initParamsHypothesis() );
100 new QLabel( tr( "Hexotic_HEXES_MIN_LEVEL" ), GroupC1 );
101 myHexesMinLevel = new QtxIntSpinBox( GroupC1 );
102 // myHexesMinLevel->setMinValue( 3 );
103 myHexesMinLevel->setMinValue( h->GetHexesMinLevel() );
104 myHexesMinLevel->setMaxValue( 8 );
105 myHexesMinLevel->setLineStep( 1 );
107 new QLabel( tr( "Hexotic_HEXES_MAX_LEVEL" ), GroupC1 );
108 myHexesMaxLevel = new QtxIntSpinBox( GroupC1 );
109 myHexesMaxLevel->setMinValue( 3 );
110 myHexesMaxLevel->setMaxValue( 8 );
111 myHexesMaxLevel->setLineStep( 1 );
113 myHexoticQuadrangles = new QCheckBox( tr( "Hexotic_QUADRANGLES" ), GroupC1 );
114 GroupC1->addSpace(0);
120 void HexoticPluginGUI_HypothesisCreator::retrieveParams() const
122 HexoticHypothesisData data;
123 readParamsFromHypo( data );
126 myName->setText( data.myName );
127 myHexesMinLevel->setValue( data.myHexesMinLevel );
128 myHexesMaxLevel->setValue( data.myHexesMaxLevel );
129 myHexoticQuadrangles->setChecked( data.myHexoticQuadrangles );
131 myHexesMinLevel->setEnabled(true);
132 myHexesMaxLevel->setEnabled(true);
135 QString HexoticPluginGUI_HypothesisCreator::storeParams() const
137 HexoticHypothesisData data;
138 readParamsFromWidgets( data );
139 storeParamsToHypo( data );
142 valStr += tr("Hexotic_SEG_MIN_SIZE") + " = " + QString::number( data.myHexesMinLevel ) + "; ";
143 valStr += tr("Hexotic_SEG_MAX_SIZE") + " = " + QString::number( data.myHexesMaxLevel ) + "; ";
144 valStr += tr("Hexotic_QUADRANGLES") + " = " + QString::number( data.myHexoticQuadrangles ) + "; ";
149 bool HexoticPluginGUI_HypothesisCreator::readParamsFromHypo( HexoticHypothesisData& h_data ) const
151 HexoticPlugin::HexoticPlugin_Hypothesis_var h =
152 HexoticPlugin::HexoticPlugin_Hypothesis::_narrow( initParamsHypothesis() );
154 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
155 h_data.myName = isCreation() && data ? data->Label : "";
156 h_data.myHexesMinLevel = h->GetHexesMinLevel();
157 h_data.myHexesMaxLevel = h->GetHexesMaxLevel();
158 h_data.myHexoticQuadrangles = h->GetHexoticQuadrangles();
163 bool HexoticPluginGUI_HypothesisCreator::storeParamsToHypo( const HexoticHypothesisData& h_data ) const
165 HexoticPlugin::HexoticPlugin_Hypothesis_var h =
166 HexoticPlugin::HexoticPlugin_Hypothesis::_narrow( hypothesis() );
172 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.latin1() );
174 h->SetHexesMinLevel( h_data.myHexesMinLevel );
175 h->SetHexesMaxLevel( h_data.myHexesMaxLevel );
176 h->SetHexoticQuadrangles( h_data.myHexoticQuadrangles );
178 catch(const SALOME::SALOME_Exception& ex)
180 SalomeApp_Tools::QtCatchCorbaException(ex);
186 bool HexoticPluginGUI_HypothesisCreator::readParamsFromWidgets( HexoticHypothesisData& h_data ) const
188 h_data.myName = myName ? myName->text() : "";
189 h_data.myHexesMinLevel = myHexesMinLevel->value();
190 h_data.myHexesMaxLevel = myHexesMaxLevel->value();
191 h_data.myHexoticQuadrangles = myHexoticQuadrangles->isChecked();
196 QString HexoticPluginGUI_HypothesisCreator::caption() const
198 return tr( QString( "Hexotic_%1_TITLE" ).arg(myIs3D?QString("3D"):QString("3D")) );
201 QPixmap HexoticPluginGUI_HypothesisCreator::icon() const
203 QString hypIconName = tr( QString("ICON_DLG_Hexotic_PARAMETERS%1").arg(myIs3D?QString(""):QString("")) );
204 return SUIT_Session::session()->resourceMgr()->loadPixmap( "HexoticPlugin", hypIconName );
207 QString HexoticPluginGUI_HypothesisCreator::type() const
209 return tr( QString( "Hexotic_%1_HYPOTHESIS" ).arg(myIs3D?QString("3D"):QString("3D")) );