1 // SMESH StdMeshersGUI : GUI for plugged-in meshers
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 : StdMeshersGUI.cxx
24 // Author : Julia DOROVSKIKH
28 #include "SALOMEconfig.h"
29 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
32 #include "SMESHGUI_Utils.h"
33 #include "SMESHGUI_Hypotheses.h"
34 #include "SMESHGUI_HypothesesUtils.h"
36 #include "SMESHGUI_aParameterDlg.h"
37 #include "StdMeshersGUI_Parameters.h"
38 #include "StdMeshersGUI_CreateStdHypothesisDlg.h"
40 #include "SUIT_Desktop.h"
41 #include "SUIT_ResourceMgr.h"
43 #include <SalomeApp_Tools.h>
47 #include "utilities.h"
51 //=============================================================================
52 /*! class HypothesisCreator
55 //=============================================================================
56 class StdMeshersGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
59 StdMeshersGUI_HypothesisCreator (const QString& aHypType,
60 const QString& aServerLibName,
62 : myHypType(aHypType),
63 myServerLibName(aServerLibName),
64 mySMESHGUI(aSMESHGUI) {}
66 virtual void CreateHypothesis (const bool isAlgo, QWidget* parent = 0);
67 virtual void EditHypothesis (SMESH::SMESH_Hypothesis_ptr theHyp);
71 QString myServerLibName;
75 //=============================================================================
76 /*! HypothesisCreator::CreateHypothesis
79 //=============================================================================
80 void StdMeshersGUI_HypothesisCreator::CreateHypothesis
81 (bool isAlgo, QWidget* parent)
83 MESSAGE("StdMeshersGUI_HypothesisCreator::CreateHypothesis");
85 // Get default name for hypothesis/algorithm creation
86 char* sHypType = (char*)myHypType.latin1();
87 HypothesisData* aHypData = SMESH::GetHypothesisData(sHypType);
90 aHypName = aHypData->Label;
94 // Create hypothesis/algorithm
97 SMESH::CreateHypothesis(myHypType, aHypName, isAlgo);
101 if ( StdMeshersGUI_Parameters::HasParameters( myHypType ))
103 // Show Dialog for hypothesis creation
104 StdMeshersGUI_CreateStdHypothesisDlg *aDlg =
105 new StdMeshersGUI_CreateStdHypothesisDlg(myHypType, parent, "");
106 /* Move widget on the botton right corner of main widget */
108 // mySMESHGUI->DefineDlgPosition( aDlg, x, y ) ;
109 // aDlg->move( x, y ) ;
110 aDlg->exec() ; /* displays Dialog */
113 SMESH::CreateHypothesis(myHypType, aHypName, isAlgo); // without GUI
117 //=============================================================================
118 /*! HypothesisCreator::EditHypothesis
121 //=============================================================================
122 void StdMeshersGUI_HypothesisCreator::EditHypothesis
123 (SMESH::SMESH_Hypothesis_ptr theHyp)
125 MESSAGE("StdMeshersGUI_HypothesisCreator::EditHypothesis");
127 SMESH::SObjectList listSOmesh = SMESH::GetMeshesUsingAlgoOrHypothesis(theHyp);
129 list<SMESHGUI_aParameterPtr> paramList;
130 StdMeshersGUI_Parameters::GetParameters( theHyp, paramList );
132 bool modified = false;
133 if ( SMESHGUI_aParameterDlg::Parameters( SMESHGUI::GetSMESHGUI(), paramList, QObject::tr("SMESH_VALUE")) )
137 modified = StdMeshersGUI_Parameters::SetParameters( theHyp, paramList );
139 catch (const SALOME::SALOME_Exception& S_ex)
141 SalomeApp_Tools::QtCatchCorbaException(S_ex);
147 //set new Attribute Comment for hypothesis which parameters were modified
148 QString aParams = "";
149 StdMeshersGUI_Parameters::GetParameters( theHyp, paramList, aParams );
150 _PTR(SObject) SHyp = SMESH::FindSObject(theHyp);
152 if (!aParams.isEmpty()) {
153 SMESH::SetValue(SHyp, aParams);
154 //mySMESHGUI->GetActiveStudy()->updateObjBrowser(true);
157 if ( listSOmesh.size() > 0 ) {
158 _PTR(SObject) submSO = listSOmesh[0];
159 SMESH::SMESH_Mesh_var aMesh =
160 SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(submSO);
161 SMESH::SMESH_subMesh_var aSubMesh =
162 SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(submSO);
163 if ( !aSubMesh->_is_nil() )
164 aMesh = aSubMesh->GetFather();
165 _PTR(SObject) meshSO = SMESH::FindSObject( aMesh );
166 SMESH::ModifiedMesh( meshSO, false);
171 //=============================================================================
172 /*! GetHypothesisCreator
175 //=============================================================================
178 SMESHGUI_GenericHypothesisCreator* GetHypothesisCreator
179 (QString aHypType, QString aServerLibName, SMESHGUI* aSMESHGUI)
181 return new StdMeshersGUI_HypothesisCreator
182 (aHypType, aServerLibName, aSMESHGUI);