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 "QAD_Desktop.h"
41 #include "QAD_ResourceMgr.h"
45 #include "utilities.h"
49 //=============================================================================
50 /*! class HypothesisCreator
53 //=============================================================================
54 class StdMeshersGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
57 StdMeshersGUI_HypothesisCreator (const QString& aHypType,
58 const QString& aServerLibName,
60 : myHypType(aHypType),
61 myServerLibName(aServerLibName),
62 mySMESHGUI(aSMESHGUI) {}
64 virtual void CreateHypothesis (const bool isAlgo, QWidget* parent = 0);
65 virtual void EditHypothesis (SMESH::SMESH_Hypothesis_ptr theHyp);
69 QString myServerLibName;
73 //=============================================================================
74 /*! HypothesisCreator::CreateHypothesis
77 //=============================================================================
78 void StdMeshersGUI_HypothesisCreator::CreateHypothesis
79 (bool isAlgo, QWidget* parent)
81 MESSAGE("StdMeshersGUI_HypothesisCreator::CreateHypothesis");
83 // Get default name for hypothesis/algorithm creation
84 char* sHypType = (char*)myHypType.latin1();
85 HypothesisData* aHypData = SMESH::GetHypothesisData(sHypType);
88 aHypName = aHypData->Label;
92 // Create hypothesis/algorithm
95 SMESH::CreateHypothesis(myHypType, aHypName, isAlgo);
99 if ( StdMeshersGUI_Parameters::HasParameters( myHypType ))
100 // Show Dialog for hypothesis creation
101 StdMeshersGUI_CreateStdHypothesisDlg *aDlg =
102 new StdMeshersGUI_CreateStdHypothesisDlg(myHypType, parent, "");
104 SMESH::CreateHypothesis(myHypType, aHypName, isAlgo); // without GUI
108 //=============================================================================
109 /*! HypothesisCreator::EditHypothesis
112 //=============================================================================
113 void StdMeshersGUI_HypothesisCreator::EditHypothesis
114 (SMESH::SMESH_Hypothesis_ptr theHyp)
116 MESSAGE("StdMeshersGUI_HypothesisCreator::EditHypothesis");
118 SALOMEDS::Study::ListOfSObject_var listSOmesh =
119 SMESH::GetMeshesUsingAlgoOrHypothesis(theHyp);
121 list<SMESHGUI_aParameterPtr> paramList;
122 StdMeshersGUI_Parameters::GetParameters( theHyp, paramList );
124 bool modified = false;
125 if ( SMESHGUI_aParameterDlg::Parameters( paramList, QObject::tr("SMESH_VALUE")) )
126 modified = StdMeshersGUI_Parameters::SetParameters( theHyp, paramList );
129 //set new Attribute Comment for hypothesis which parameters were modified
130 QString aParams = "";
131 StdMeshersGUI_Parameters::GetParameters( theHyp, paramList, aParams );
132 SALOMEDS::SObject_var SHyp = SMESH::FindSObject(theHyp);
133 if (!SHyp->_is_nil())
134 if (!aParams.isEmpty()) {
135 SMESH::SetValue(SHyp, aParams);
136 //mySMESHGUI->GetActiveStudy()->updateObjBrowser(true);
139 for (int i=0; i<listSOmesh->length(); i++)
140 SMESH::ModifiedMesh(listSOmesh[i], false);
144 //=============================================================================
145 /*! GetHypothesisCreator
148 //=============================================================================
151 SMESHGUI_GenericHypothesisCreator* GetHypothesisCreator
152 (QString aHypType, QString aServerLibName, SMESHGUI* aSMESHGUI)
154 return new StdMeshersGUI_HypothesisCreator
155 (aHypType, aServerLibName, aSMESHGUI);