1 // Copyright (C) 2007-2012 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.
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 !!!!!!!!!!!!!!!!!!!!!!!!!! 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 );
125 void GHS3DPRLPluginGUI_HypothesisCreator::retrieveParams() const
127 GHS3DPRLHypothesisData data;
128 readParamsFromHypo( data );
130 if ( myName ) myName->setText( data.myName );
131 myMEDName->setText( data.myMEDName );
132 myNbPart->setValue( data.myNbPart );
133 myKeepFiles->setChecked( data.myKeepFiles );
134 myBackground->setChecked( data.myBackground );
135 myToMeshHoles->setChecked( data.myToMeshHoles );
136 //myNbPart->setEnabled( true );
139 QString GHS3DPRLPluginGUI_HypothesisCreator::storeParams() const
141 GHS3DPRLHypothesisData data;
142 readParamsFromWidgets( data );
143 storeParamsToHypo( data );
146 valStr += tr( "GHS3DPRL_MEDName" ) + " = " + data.myMEDName + "; ";
147 valStr += tr( "GHS3DPRL_NbPart" ) + " = " + QString::number( data.myNbPart ) + "; ";
148 valStr += tr( "GHS3DPRL_ToMeshHoles" ) + " = " + QString::number( data.myToMeshHoles ) + "; ";
149 valStr += tr( "GHS3DPRL_KeepFiles" ) + " = " + QString::number( data.myKeepFiles ) + "; ";
150 valStr += tr( "GHS3DPRL_Background" ) + " = " + QString::number( data.myBackground ) + "; ";
155 bool GHS3DPRLPluginGUI_HypothesisCreator::readParamsFromHypo( GHS3DPRLHypothesisData& h_data ) const
157 GHS3DPRLPlugin::GHS3DPRLPlugin_Hypothesis_var h =
158 GHS3DPRLPlugin::GHS3DPRLPlugin_Hypothesis::_narrow( initParamsHypothesis() );
160 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
161 h_data.myName = isCreation() && data ? hypName() : "";
162 h_data.myMEDName = h->GetMEDName(); //"DOMAIN\0";
163 h_data.myNbPart = h->GetNbPart();
164 h_data.myKeepFiles = h->GetKeepFiles();
165 h_data.myBackground = h->GetBackground();
166 h_data.myToMeshHoles = h->GetToMeshHoles();
171 bool GHS3DPRLPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DPRLHypothesisData& h_data ) const
173 GHS3DPRLPlugin::GHS3DPRLPlugin_Hypothesis_var h =
174 GHS3DPRLPlugin::GHS3DPRLPlugin_Hypothesis::_narrow( hypothesis() );
180 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().constData() );
182 h->SetMEDName( h_data.myMEDName.toLatin1().constData() );
183 h->SetNbPart( h_data.myNbPart );
184 h->SetKeepFiles( h_data.myKeepFiles );
185 h->SetBackground( h_data.myBackground );
186 h->SetToMeshHoles( h_data.myToMeshHoles );
188 catch ( const SALOME::SALOME_Exception& ex )
190 SalomeApp_Tools::QtCatchCorbaException( ex );
196 bool GHS3DPRLPluginGUI_HypothesisCreator::readParamsFromWidgets( GHS3DPRLHypothesisData& h_data ) const
198 h_data.myName = myName ? myName->text() : "";
199 h_data.myMEDName = myMEDName->text().simplified().replace(' ', '_');
200 h_data.myNbPart = myNbPart->value();
201 h_data.myKeepFiles = myKeepFiles->isChecked();
202 h_data.myBackground = myBackground->isChecked();
203 h_data.myToMeshHoles = myToMeshHoles->isChecked();
207 QString GHS3DPRLPluginGUI_HypothesisCreator::caption() const
209 return myIs3D ? tr( "GHS3DPRL_3D_TITLE" ) : tr( "GHS3DPRL_3D_TITLE" ); // ??? 3D/2D ???
212 QPixmap GHS3DPRLPluginGUI_HypothesisCreator::icon() const
214 QString hypIconName = myIs3D ? tr( "ICON_DLG_GHS3DPRL_PARAMETERS" ) : tr( "ICON_DLG_GHS3DPRL_PARAMETERS" ); // ??? 3D/2D ???
215 return SUIT_Session::session()->resourceMgr()->loadPixmap( "GHS3DPRLPlugin", hypIconName );
218 QString GHS3DPRLPluginGUI_HypothesisCreator::type() const
220 return myIs3D ? tr( "GHS3DPRL_3D_HYPOTHESIS" ): tr( "GHS3DPRL_3D_HYPOTHESIS" ); // ??? 3D/2D ???
223 QString GHS3DPRLPluginGUI_HypothesisCreator::helpPage() const
225 return "ghs3dprl_hypo_page.html";