1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : GHS3DPRLPluginGUI_HypothesisCreator.cxx
22 // Author : Christian VAN WAMBEKE (CEA) (from Hexotic plugin Lioka RAZAFINDRAZAKA)
25 #include "GHS3DPRLPluginGUI_HypothesisCreator.h"
27 #include <SMESHGUI_Utils.h>
28 #include <SMESHGUI_HypothesesUtils.h>
30 #include CORBA_SERVER_HEADER(GHS3DPRLPlugin_Algorithm)
32 #include <SUIT_Session.h>
33 #include <SUIT_ResourceMgr.h>
34 #include <SalomeApp_Tools.h>
35 #include <QtxIntSpinBox.h>
42 #include <QVBoxLayout>
43 #include <QGridLayout>
45 GHS3DPRLPluginGUI_HypothesisCreator::GHS3DPRLPluginGUI_HypothesisCreator( const QString& theHypType )
46 : SMESHGUI_GenericHypothesisCreator( theHypType ),
49 //printf("Hypo creator GHS3DPRLPlugin !!!!!!!!!!!!!!!!!!!!!!!!!! RNV");
52 GHS3DPRLPluginGUI_HypothesisCreator::~GHS3DPRLPluginGUI_HypothesisCreator()
56 bool GHS3DPRLPluginGUI_HypothesisCreator::checkParams() const
58 GHS3DPRLHypothesisData data_old, data_new;
59 readParamsFromHypo( data_old );
60 readParamsFromWidgets( data_new );
61 bool res = storeParamsToHypo( data_new );
62 storeParamsToHypo( data_old );
66 QFrame* GHS3DPRLPluginGUI_HypothesisCreator::buildFrame()
68 QFrame* fr = new QFrame( 0 );
69 QVBoxLayout* lay = new QVBoxLayout( fr );
73 QGroupBox* GroupC1 = new QGroupBox( tr( "SMESH_ARGUMENTS" ), fr );
74 lay->addWidget( GroupC1 );
76 QGridLayout* l = new QGridLayout( GroupC1 );
83 QLabel* aNameLab = new QLabel( tr( "SMESH_NAME" ), GroupC1 );
84 aNameLab->setWhatsThis( tr( "GHS3DPRL_WhatsThis_Name" ) );
85 l->addWidget( aNameLab, row, 0, 1, 1 );
86 myName = new QLineEdit( GroupC1 );
87 l->addWidget( myName, row++, 1, 1, 1 );
90 //GHS3DPRLPlugin::GHS3DPRLPlugin_Hypothesis_var h =
91 //GHS3DPRLPlugin::GHS3DPRLPlugin_Hypothesis::_narrow( initParamsHypothesis() );
93 QLabel* aMEDNameText = new QLabel( tr( "GHS3DPRL_MEDName" ), GroupC1 );
94 aMEDNameText->setWhatsThis( tr( "GHS3DPRL_WhatsThis_MEDName" ) );
95 l->addWidget( aMEDNameText, row, 0, 1, 1 );
96 myMEDName = new QLineEdit( GroupC1 );
97 l->addWidget( myMEDName, row++, 1, 1, 1 );
99 QLabel* aNbPartText = new QLabel( tr( "GHS3DPRL_NbPart" ), GroupC1 );
100 aNbPartText->setWhatsThis( tr( "GHS3DPRL_WhatsThis_NbPart" ) );
101 l->addWidget( aNbPartText, row, 0, 1, 1 );
102 myNbPart = new QtxIntSpinBox( GroupC1 );
103 l->addWidget( myNbPart, row++, 1, 1, 1 );
104 myNbPart->setMinimum( 1 );
105 myNbPart->setMaximum( 256 );
106 myNbPart->setSingleStep( 1 );
108 myKeepFiles = new QCheckBox( tr( "GHS3DPRL_KeepFiles" ), GroupC1 );
109 myKeepFiles->setWhatsThis( tr( "GHS3DPRL_WhatsThis_KeepFiles" ) );
110 l->addWidget( myKeepFiles, row++, 0, 1, 2 );
112 myBackground = new QCheckBox( tr( "GHS3DPRL_Background" ), GroupC1 );
113 myBackground->setWhatsThis( tr( "GHS3DPRL_WhatsThis_Background" ) );
114 l->addWidget( myBackground, row++, 0, 1, 2 );
116 //myToMeshHoles = new QCheckBox( tr( "GHS3DPRL_ToMeshHoles" ), GroupC1 );
117 //myToMeshHoles->setWhatsThis( tr( "GHS3DPRL_WhatsThis_ToMeshHoles" ) );
118 //l->addWidget( myToMeshHoles, row++, 0, 1, 2 );
120 myToMergeSubdomains = new QCheckBox( tr( "GHS3DPRL_ToMergeSubdomains" ), GroupC1 );
121 myToMergeSubdomains->setWhatsThis( tr( "GHS3DPRL_WhatsThis_ToMergeSubdomains" ) );
122 l->addWidget( myToMergeSubdomains, row++, 0, 1, 2 );
124 myToTagSubdomains = new QCheckBox( tr( "GHS3DPRL_ToTagSubdomains" ), GroupC1 );
125 myToTagSubdomains->setWhatsThis( tr( "GHS3DPRL_WhatsThis_ToTagSubdomains" ) );
126 l->addWidget( myToTagSubdomains, row++, 0, 1, 2 );
128 myToOutputInterfaces = new QCheckBox( tr( "GHS3DPRL_ToOutputInterfaces" ), GroupC1 );
129 myToOutputInterfaces->setWhatsThis( tr( "GHS3DPRL_WhatsThis_ToOutputInterfaces" ) );
130 l->addWidget( myToOutputInterfaces, row++, 0, 1, 2 );
132 myToDiscardSubdomains = new QCheckBox( tr( "GHS3DPRL_ToDiscardSubdomains" ), GroupC1 );
133 myToDiscardSubdomains->setWhatsThis( tr( "GHS3DPRL_WhatsThis_ToDiscardSubdomains" ) );
134 l->addWidget( myToDiscardSubdomains, row++, 0, 1, 2 );
141 void GHS3DPRLPluginGUI_HypothesisCreator::retrieveParams() const
143 GHS3DPRLHypothesisData data;
144 readParamsFromHypo( data );
146 if ( myName ) myName->setText( data.myName );
147 myMEDName->setText( data.myMEDName );
148 myNbPart->setValue( data.myNbPart );
149 myKeepFiles->setChecked( data.myKeepFiles );
150 myBackground->setChecked( data.myBackground );
151 //myToMeshHoles->setChecked( data.myToMeshHoles );
152 myToMergeSubdomains->setChecked( data.myToMergeSubdomains );
153 myToTagSubdomains->setChecked( data.myToTagSubdomains );
154 myToOutputInterfaces->setChecked( data.myToOutputInterfaces );
155 myToDiscardSubdomains->setChecked( data.myToDiscardSubdomains );
156 //myNbPart->setEnabled( true );
159 QString GHS3DPRLPluginGUI_HypothesisCreator::storeParams() const
161 GHS3DPRLHypothesisData data;
162 readParamsFromWidgets( data );
163 storeParamsToHypo( data );
166 valStr += tr( "GHS3DPRL_MEDName" ) + " = " + data.myMEDName + "; ";
167 valStr += tr( "GHS3DPRL_NbPart" ) + " = " + QString::number( data.myNbPart ) + "; ";
168 //valStr += tr( "GHS3DPRL_ToMeshHoles" ) + " = " + QString::number( data.myToMeshHoles ) + "; ";
169 valStr += tr( "GHS3DPRL_ToMergeSubdomains" ) + " = " + QString::number( data.myToMergeSubdomains ) + "; ";
170 valStr += tr( "GHS3DPRL_ToTagSubdomains" ) + " = " + QString::number( data.myToTagSubdomains ) + "; ";
171 valStr += tr( "GHS3DPRL_ToOutputInterfaces" ) + " = " + QString::number( data.myToOutputInterfaces ) + "; ";
172 valStr += tr( "GHS3DPRL_ToDiscardSubdomains" ) + " = " + QString::number( data.myToDiscardSubdomains ) + "; ";
173 valStr += tr( "GHS3DPRL_KeepFiles" ) + " = " + QString::number( data.myKeepFiles ) + "; ";
174 valStr += tr( "GHS3DPRL_Background" ) + " = " + QString::number( data.myBackground ) + "; ";
179 bool GHS3DPRLPluginGUI_HypothesisCreator::readParamsFromHypo( GHS3DPRLHypothesisData& h_data ) const
181 GHS3DPRLPlugin::GHS3DPRLPlugin_Hypothesis_var h =
182 GHS3DPRLPlugin::GHS3DPRLPlugin_Hypothesis::_narrow( initParamsHypothesis() );
184 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
185 h_data.myName = isCreation() && data ? hypName() : "";
186 h_data.myMEDName = h->GetMEDName(); //"DOMAIN\0";
187 h_data.myNbPart = h->GetNbPart();
188 h_data.myKeepFiles = h->GetKeepFiles();
189 h_data.myBackground = h->GetBackground();
190 //h_data.myToMeshHoles = h->GetToMeshHoles();
191 h_data.myToMergeSubdomains = h->GetToMergeSubdomains();
192 h_data.myToTagSubdomains = h->GetToTagSubdomains();
193 h_data.myToOutputInterfaces = h->GetToOutputInterfaces();
194 h_data.myToDiscardSubdomains = h->GetToDiscardSubdomains();
199 bool GHS3DPRLPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DPRLHypothesisData& h_data ) const
201 GHS3DPRLPlugin::GHS3DPRLPlugin_Hypothesis_var h =
202 GHS3DPRLPlugin::GHS3DPRLPlugin_Hypothesis::_narrow( hypothesis() );
208 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
210 h->SetMEDName( h_data.myMEDName.toLatin1().constData() );
211 h->SetNbPart( h_data.myNbPart );
212 h->SetKeepFiles( h_data.myKeepFiles );
213 h->SetBackground( h_data.myBackground );
214 //h->SetToMeshHoles( h_data.myToMeshHoles );
215 h->SetToMergeSubdomains( h_data.myToMergeSubdomains );
216 h->SetToTagSubdomains( h_data.myToTagSubdomains );
217 h->SetToOutputInterfaces( h_data.myToOutputInterfaces );
218 h->SetToDiscardSubdomains( h_data.myToDiscardSubdomains );
220 catch ( const SALOME::SALOME_Exception& ex )
222 SalomeApp_Tools::QtCatchCorbaException( ex );
228 bool GHS3DPRLPluginGUI_HypothesisCreator::readParamsFromWidgets( GHS3DPRLHypothesisData& h_data ) const
230 h_data.myName = myName ? myName->text() : "";
231 h_data.myMEDName = myMEDName->text().simplified().replace(' ', '_');
232 h_data.myNbPart = myNbPart->value();
233 h_data.myKeepFiles = myKeepFiles->isChecked();
234 h_data.myBackground = myBackground->isChecked();
235 //h_data.myToMeshHoles = myToMeshHoles->isChecked();
236 h_data.myToMergeSubdomains = myToMergeSubdomains->isChecked();
237 h_data.myToTagSubdomains = myToTagSubdomains->isChecked();
238 h_data.myToOutputInterfaces = myToOutputInterfaces->isChecked();
239 h_data.myToDiscardSubdomains = myToDiscardSubdomains->isChecked();
243 QString GHS3DPRLPluginGUI_HypothesisCreator::caption() const
245 return myIs3D ? tr( "GHS3DPRL_3D_TITLE" ) : tr( "GHS3DPRL_3D_TITLE" ); // ??? 3D/2D ???
248 QPixmap GHS3DPRLPluginGUI_HypothesisCreator::icon() const
250 QString hypIconName = myIs3D ? tr( "ICON_DLG_GHS3DPRL_PARAMETERS" ) : tr( "ICON_DLG_GHS3DPRL_PARAMETERS" ); // ??? 3D/2D ???
251 return SUIT_Session::session()->resourceMgr()->loadPixmap( "GHS3DPRLPlugin", hypIconName );
254 QString GHS3DPRLPluginGUI_HypothesisCreator::type() const
256 return myIs3D ? tr( "GHS3DPRL_3D_HYPOTHESIS" ): tr( "GHS3DPRL_3D_HYPOTHESIS" ); // ??? 3D/2D ???
259 QString GHS3DPRLPluginGUI_HypothesisCreator::helpPage() const
261 return "ghs3dprl_hypo_page.html";