1 // GEOM GEOMGUI : GUI for Geometry component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : GenerationGUI.cxx
25 // Author : Damien COQUERET
30 #include "GenerationGUI.h"
32 #include "SALOMEGUI_QtCatchCorbaException.hxx"
34 #include "GenerationGUI_PrismDlg.h" // Method PRISM
35 #include "GenerationGUI_RevolDlg.h" // Method REVOL
36 #include "GenerationGUI_FillingDlg.h" // Method FILLING
37 #include "GenerationGUI_PipeDlg.h" // Method PIPE
39 //=======================================================================
40 // function : GenerationGUI()
41 // purpose : Constructor
42 //=======================================================================
43 GenerationGUI::GenerationGUI() :
46 myGeomBase = new GEOMBase();
47 myGeomGUI = GEOMContext::GetGeomGUI();
48 myGeom = myGeomGUI->myComponentGeom;
52 //=======================================================================
53 // function : ~GenerationGUI()
54 // purpose : Destructor
55 //=======================================================================
56 GenerationGUI::~GenerationGUI()
61 //=======================================================================
62 // function : OnGUIEvent()
64 //=======================================================================
65 bool GenerationGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
67 GenerationGUI* myGenerationGUI = new GenerationGUI();
68 myGenerationGUI->myGeomGUI->EmitSignalDeactivateDialog();
69 SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
75 GenerationGUI_PrismDlg *aDlg = new GenerationGUI_PrismDlg(parent, "", myGenerationGUI, Sel);
80 GenerationGUI_RevolDlg *aDlg = new GenerationGUI_RevolDlg(parent, "", myGenerationGUI, Sel);
85 GenerationGUI_FillingDlg *aDlg = new GenerationGUI_FillingDlg(parent, "", myGenerationGUI, Sel);
90 GenerationGUI_PipeDlg *aDlg = new GenerationGUI_PipeDlg(parent, "", myGenerationGUI, Sel);
95 parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
103 //=======================================================================
104 // function : MakePrismAndDisplay()
105 // purpose : P1 and P2 is to define a vector for prism
106 //=======================================================================
107 void GenerationGUI::MakePrismAndDisplay(GEOM::GEOM_Shape_ptr BaseShape, const gp_Pnt P1, const gp_Pnt P2)
110 if(BaseShape->_is_nil()) {
111 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE"));
115 GEOM::PointStruct PS1 = myGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z());
116 GEOM::PointStruct PS2 = myGeom->MakePointStruct(P2.X(), P2.Y(), P2.Z());
117 GEOM::GEOM_Shape_ptr result = myGeom->MakePrism(BaseShape, PS1, PS2);
118 if(result->_is_nil()) {
119 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE"));
123 TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, result);
124 Standard_CString type;
125 myGeomBase->GetShapeTypeString(S,type);
126 result->NameType(type);
128 if(myGeomBase->Display(result))
129 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
131 catch(const SALOME::SALOME_Exception& S_ex) {
132 QtCatchCorbaException(S_ex);
138 //=======================================================================================
139 // function : MakeRevolutionAndDisplay()
141 //=======================================================================================
142 void GenerationGUI::MakeRevolutionAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc, const gp_Dir dir, const Standard_Real revolAngle)
145 GEOM::AxisStruct axis = myGeom->MakeAxisStruct(loc.X(), loc.Y(), loc.Z(), dir.X(), dir.Y(), dir.Z());
146 GEOM::GEOM_Shape_ptr result = myGeom->MakeRevolution(Shape, axis, revolAngle) ;
147 if(result->_is_nil()) {
148 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT"));
152 TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, result);
153 Standard_CString type;
154 myGeomBase->GetShapeTypeString(S,type);
155 result->NameType(type);
157 if(myGeomBase->Display(result))
158 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
160 catch(const SALOME::SALOME_Exception& S_ex) {
161 QtCatchCorbaException(S_ex);
167 //=====================================================================================
168 // function : MakeFillingAndDisplay()
170 //=====================================================================================
171 void GenerationGUI::MakeFillingAndDisplay(GEOM::GEOM_Shape_ptr SectionShape, const short mindeg,
172 const short maxdeg, const double tol3d,
173 const double tol2d, const short nbiter)
176 GEOM::GEOM_Shape_ptr result = myGeom->MakeFilling(SectionShape, mindeg, maxdeg,
177 tol3d, tol2d, nbiter);
178 if(result->_is_nil()) {
179 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE"));
183 TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, result);
184 Standard_CString type;
185 myGeomBase->GetShapeTypeString(S,type);
186 result->NameType(type);
188 if(myGeomBase->Display(result))
189 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
192 catch(const SALOME::SALOME_Exception& S_ex) {
193 QtCatchCorbaException(S_ex);
199 //=====================================================================================
200 // function : MakePipeAndDisplay()
202 //=====================================================================================
203 void GenerationGUI::MakePipeAndDisplay(GEOM::GEOM_Shape_ptr aPath, GEOM::GEOM_Shape_ptr aBase)
206 GEOM::GEOM_Shape_ptr result = myGeom->MakePipe(aPath, aBase);
207 if (!result->_is_nil() && myGeomBase->Display(result)) {
208 TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, result);
209 Standard_CString type;
210 myGeomBase->GetShapeTypeString(S,type);
211 result->NameType(type);
213 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
216 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT"));
219 catch (const SALOME::SALOME_Exception& S_ex) {
220 QtCatchCorbaException(S_ex);
226 //=====================================================================================
228 //=====================================================================================
231 bool OnGUIEvent(int theCommandID, QAD_Desktop* parent)
232 {return GenerationGUI::OnGUIEvent(theCommandID, parent);}