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
30 #include <SALOMEconfig.h>
31 #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
34 #include "SMESHGUI_Hypotheses.h"
36 #include "StdMeshersGUI_LocalLengthDlg.h"
37 #include "StdMeshersGUI_NbSegmentsDlg.h"
38 #include "StdMeshersGUI_MaxElementAreaDlg.h"
39 #include "StdMeshersGUI_MaxElementVolumeDlg.h"
41 #include "QAD_Desktop.h"
42 #include "QAD_ResourceMgr.h"
46 //=============================================================================
47 /*! class HypothesisCreator
50 //=============================================================================
51 class StdMeshersGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
54 StdMeshersGUI_HypothesisCreator (const QString& aHypType,
55 const QString& aServerLibName,
57 : myHypType(aHypType),
58 myServerLibName(aServerLibName),
59 mySMESHGUI(aSMESHGUI) {}
61 virtual void CreateHypothesis (const bool isAlgo, QWidget* parent = 0);
62 virtual void EditHypothesis (SMESH::SMESH_Hypothesis_ptr theHyp);
66 QString myServerLibName;
70 //=============================================================================
71 /*! HypothesisCreator::CreateHypothesis
74 //=============================================================================
75 void StdMeshersGUI_HypothesisCreator::CreateHypothesis
76 (bool isAlgo, QWidget* parent)
78 MESSAGE("StdMeshersGUI_HypothesisCreator::CreateHypothesis");
80 // Get default name for hypothesis/algorithm creation
81 char* sHypType = (char*)myHypType.latin1();
82 HypothesisData* aHypData = mySMESHGUI->GetHypothesisData(sHypType);
85 aHypName = aHypData->Label;
89 // Create hypothesis/algorithm
92 mySMESHGUI->CreateHypothesis(myHypType, aHypName, isAlgo);
96 // Show Dialog for hypothesis creation
97 if (myHypType == "LocalLength")
98 StdMeshersGUI_LocalLengthDlg *aDlg = new StdMeshersGUI_LocalLengthDlg(myHypType, parent, "");
99 else if (myHypType == "NumberOfSegments")
100 StdMeshersGUI_NbSegmentsDlg *aDlg = new StdMeshersGUI_NbSegmentsDlg(myHypType, parent, "");
101 else if (myHypType == "MaxElementArea")
102 StdMeshersGUI_MaxElementAreaDlg *aDlg = new StdMeshersGUI_MaxElementAreaDlg(myHypType, parent, "");
103 else if (myHypType == "MaxElementVolume")
104 StdMeshersGUI_MaxElementVolumeDlg *aDlg = new StdMeshersGUI_MaxElementVolumeDlg(myHypType, parent, "");
105 else if (myHypType == "LengthFromEdges")
106 mySMESHGUI->CreateHypothesis(myHypType, aHypName, isAlgo); // without GUI
107 else if (myHypType == "NotConformAllowed")
108 mySMESHGUI->CreateHypothesis(myHypType, aHypName, isAlgo); // without GUI
113 //=============================================================================
114 /*! HypothesisCreator::EditHypothesis
117 //=============================================================================
118 void StdMeshersGUI_HypothesisCreator::EditHypothesis
119 (SMESH::SMESH_Hypothesis_ptr theHyp)
121 MESSAGE("StdMeshersGUI_HypothesisCreator::EditHypothesis");
123 Standard_Boolean res = Standard_True;
124 SALOMEDS::Study::ListOfSObject_var listSOmesh =
125 mySMESHGUI->GetMeshesUsingAlgoOrHypothesis(theHyp);
126 QString Name = theHyp->GetName();
127 if (Name.compare("LocalLength") == 0)
129 StdMeshers::StdMeshers_LocalLength_var LL =
130 StdMeshers::StdMeshers_LocalLength::_narrow(theHyp);
131 double beforeLength = LL->GetLength() ;
132 double Length = mySMESHGUI->Parameter(res,
134 QObject::tr("SMESH_LOCAL_LENGTH_HYPOTHESIS"),
135 QObject::tr("SMESH_VALUE"),
137 if (res && Length != beforeLength)
139 LL->SetLength(Length);
140 for (int i=0; i<listSOmesh->length(); i++)
142 mySMESHGUI->GetStudyAPI().ModifiedMesh(listSOmesh[i], false);
146 else if (Name.compare("NumberOfSegments") == 0)
148 StdMeshers::StdMeshers_NumberOfSegments_var NOS =
149 StdMeshers::StdMeshers_NumberOfSegments::_narrow(theHyp);
150 int beforeNbSeg = NOS->GetNumberOfSegments() ;
151 int NbSeg = mySMESHGUI->Parameter(res,
153 QObject::tr("SMESH_NB_SEGMENTS_HYPOTHESIS"),
154 QObject::tr("SMESH_VALUE"),
156 if (res && NbSeg != beforeNbSeg)
158 NOS->SetNumberOfSegments(NbSeg);
159 for (int i=0; i<listSOmesh->length(); i++)
161 SALOMEDS::SObject_var SO = listSOmesh[i] ;
162 mySMESHGUI->GetStudyAPI().ModifiedMesh(listSOmesh[i], false);
166 else if (Name.compare("MaxElementArea") == 0)
168 StdMeshers::StdMeshers_MaxElementArea_var MEA =
169 StdMeshers::StdMeshers_MaxElementArea::_narrow(theHyp);
170 double beforeMaxArea = MEA->GetMaxElementArea();
171 double MaxArea = mySMESHGUI->Parameter(res,
173 QObject::tr("SMESH_MAX_ELEMENT_AREA_HYPOTHESIS"),
174 QObject::tr("SMESH_VALUE"),
176 if (res && MaxArea != beforeMaxArea)
178 MEA->SetMaxElementArea(MaxArea);
179 for (int i=0; i<listSOmesh->length(); i++)
181 mySMESHGUI->GetStudyAPI().ModifiedMesh(listSOmesh[i], false);
185 else if (Name.compare("MaxElementVolume") == 0)
187 StdMeshers::StdMeshers_MaxElementVolume_var MEV =
188 StdMeshers::StdMeshers_MaxElementVolume::_narrow(theHyp);
189 double beforeMaxVolume = MEV->GetMaxElementVolume() ;
190 double MaxVolume = mySMESHGUI->Parameter(res,
192 QObject::tr("SMESH_MAX_ELEMENT_VOLUME_HYPOTHESIS"),
193 QObject::tr("SMESH_VALUE"),
195 if (res && MaxVolume != beforeMaxVolume)
197 MEV->SetMaxElementVolume(MaxVolume);
198 for (int i=0; i<listSOmesh->length(); i++)
200 mySMESHGUI->GetStudyAPI().ModifiedMesh(listSOmesh[i], false);
204 // else if (Name.compare("Regular_1D") == 0)
206 // else if (Name.compare("MEFISTO_2D") == 0)
212 //=============================================================================
213 /*! GetHypothesisCreator
216 //=============================================================================
219 SMESHGUI_GenericHypothesisCreator* GetHypothesisCreator
220 (QString aHypType, QString aServerLibName, SMESHGUI* aSMESHGUI)
222 return new StdMeshersGUI_HypothesisCreator
223 (aHypType, aServerLibName, aSMESHGUI);