1 // GHS3DPRLPlugin GUI: GUI for plugged-in mesher GHS3DPRLPlugin
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 : GHS3DPRLPluginGUI_HypothesisCreator.cxx
24 // Author : Christian VAN WAMBEKE (CEA) (from Hexotic plugin Lioka RAZAFINDRAZAKA)
25 // Module : GHS3DPRLPlugin
28 #include "GHS3DPRLPluginGUI_HypothesisCreator.h"
30 #include <SMESHGUI_Utils.h>
31 #include <SMESHGUI_HypothesesUtils.h>
33 #include CORBA_SERVER_HEADER(GHS3DPRLPlugin_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>
48 #include <qwhatsthis.h>
52 GHS3DPRLPluginGUI_HypothesisCreator::GHS3DPRLPluginGUI_HypothesisCreator( const QString& theHypType )
53 : SMESHGUI_GenericHypothesisCreator( theHypType ),
58 GHS3DPRLPluginGUI_HypothesisCreator::~GHS3DPRLPluginGUI_HypothesisCreator()
62 bool GHS3DPRLPluginGUI_HypothesisCreator::checkParams() const
64 GHS3DPRLHypothesisData data_old, data_new;
65 readParamsFromHypo( data_old );
66 readParamsFromWidgets( data_new );
67 bool res = storeParamsToHypo( data_new );
71 QFrame* GHS3DPRLPluginGUI_HypothesisCreator::buildFrame()
73 QString toto="myframe";
74 QFrame* fr = new QFrame( 0, "myframe" );
75 fr->setMinimumSize( QSize( 300, 140 ) );
76 QVBoxLayout* lay = new QVBoxLayout( fr, 5, 0 );
78 QGroupBox* GroupC1 = new QGroupBox( 2, Qt::Horizontal, fr, "GroupC1" );
79 lay->addWidget( GroupC1 );
81 GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) );
82 GroupC1->layout()->setSpacing( 6 );
83 GroupC1->layout()->setMargin( 11 );
87 myNameText = new QLabel( tr( "SMESH_NAME" ), GroupC1 );
88 QWhatsThis::add( myNameText, tr( "GHS3DPRL_WhatsThis_Name" ) );
89 myName = new QLineEdit( GroupC1 );
92 GHS3DPRLPlugin::GHS3DPRLPlugin_Hypothesis_var h =
93 GHS3DPRLPlugin::GHS3DPRLPlugin_Hypothesis::_narrow( initParamsHypothesis() );
95 myMEDNameText = new QLabel( tr( "GHS3DPRL_MEDName" ), GroupC1 );
96 QWhatsThis::add( myMEDNameText, tr( "GHS3DPRL_WhatsThis_MEDName" ) );
97 myMEDName = new QLineEdit( GroupC1 );
98 QLabel* myNbPartText = new QLabel( tr( "GHS3DPRL_NbPart" ), GroupC1 );
99 QWhatsThis::add( myNbPartText, tr( "GHS3DPRL_WhatsThis_NbPart" ) );
100 myNbPart = new QtxIntSpinBox( GroupC1 );
101 // myHexesMinLevel->setMinValue( 3 );
102 myNbPart->setMinValue( 1 );
103 myNbPart->setMaxValue( 256 );
104 myNbPart->setLineStep( 1 );
106 myKeepFiles = new QCheckBox( tr( "GHS3DPRL_KeepFiles" ), GroupC1 );
107 QWhatsThis::add( myKeepFiles, tr( "GHS3DPRL_WhatsThis_KeepFiles" ) );
109 GroupC1->addSpace(0);
115 void GHS3DPRLPluginGUI_HypothesisCreator::retrieveParams() const
117 GHS3DPRLHypothesisData data;
118 readParamsFromHypo( data );
120 if( myName ) myName->setText( data.myName );
121 myMEDName->setText( data.myMEDName );
122 myNbPart->setValue( data.myNbPart );
123 myKeepFiles->setChecked( data.myKeepFiles );
124 myNbPart->setEnabled(true);
127 QString GHS3DPRLPluginGUI_HypothesisCreator::storeParams() const
129 GHS3DPRLHypothesisData data;
130 readParamsFromWidgets( data );
131 storeParamsToHypo( data );
134 valStr += tr("GHS3DPRL_MEDName") + " = " + data.myMEDName + "; ";
135 valStr += tr("GHS3DPRL_NbPart") + " = " + QString::number( data.myNbPart ) + "; ";
136 valStr += tr("GHS3DPRL_KeepFiles") + " = " + QString::number( data.myKeepFiles ) + "; ";
141 bool GHS3DPRLPluginGUI_HypothesisCreator::readParamsFromHypo( GHS3DPRLHypothesisData& h_data ) const
143 GHS3DPRLPlugin::GHS3DPRLPlugin_Hypothesis_var h =
144 GHS3DPRLPlugin::GHS3DPRLPlugin_Hypothesis::_narrow( initParamsHypothesis() );
146 HypothesisData* data = SMESH::GetHypothesisData( hypType() );
147 h_data.myName = isCreation() && data ? data->Label : "";
148 h_data.myMEDName = h->GetMEDName(); //"DOMAIN\0";
149 h_data.myNbPart = h->GetNbPart();
150 h_data.myKeepFiles = h->GetKeepFiles();
155 bool GHS3DPRLPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DPRLHypothesisData& h_data ) const
157 GHS3DPRLPlugin::GHS3DPRLPlugin_Hypothesis_var h =
158 GHS3DPRLPlugin::GHS3DPRLPlugin_Hypothesis::_narrow( hypothesis() );
164 SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.latin1() );
166 h->SetMEDName( h_data.myMEDName );
167 h->SetNbPart( h_data.myNbPart );
168 h->SetKeepFiles( h_data.myKeepFiles );
170 catch(const SALOME::SALOME_Exception& ex)
172 SalomeApp_Tools::QtCatchCorbaException(ex);
178 bool GHS3DPRLPluginGUI_HypothesisCreator::readParamsFromWidgets( GHS3DPRLHypothesisData& h_data ) const
180 h_data.myName = myName ? myName->text() : "";
181 h_data.myMEDName = myMEDName->text();
182 h_data.myNbPart = myNbPart->value();
183 h_data.myKeepFiles = myKeepFiles->isChecked();
188 QString GHS3DPRLPluginGUI_HypothesisCreator::caption() const
190 return tr( QString( "GHS3DPRL_%1_TITLE" ).arg(myIs3D?QString("3D"):QString("3D")) );
193 QPixmap GHS3DPRLPluginGUI_HypothesisCreator::icon() const
195 QString hypIconName = tr( QString("ICON_DLG_GHS3DPRL_PARAMETERS%1").arg(myIs3D?QString(""):QString("")) );
196 return SUIT_Session::session()->resourceMgr()->loadPixmap( "GHS3DPRLPlugin", hypIconName );
199 QString GHS3DPRLPluginGUI_HypothesisCreator::type() const
201 return tr( QString( "GHS3DPRL_%1_HYPOTHESIS" ).arg(myIs3D?QString("3D"):QString("3D")) );