Salome HOME
1460732e7c0ac984899a7fe6e1bb2b64e58d22de
[modules/geom.git] / src / BuildGUI / BuildGUI.cxx
1 //  GEOM GEOMGUI : GUI for Geometry component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : BooleanGUI.cxx
25 //  Author : Damien COQUERET
26 //  Module : GEOM
27 //  $Header: 
28
29 using namespace std;
30 #include "BuildGUI.h"
31
32 #include "SALOMEGUI_QtCatchCorbaException.hxx"
33
34 #include "BuildGUI_EdgeDlg.h"       // Method EDGE
35 #include "BuildGUI_WireDlg.h"       // Method WIRE
36 #include "BuildGUI_FaceDlg.h"       // Method FACE
37 #include "BuildGUI_ShellDlg.h"      // Method SHELL
38 #include "BuildGUI_SolidDlg.h"      // Method SOLID
39 #include "BuildGUI_CompoundDlg.h"   // Method COMPOUND
40
41 //=======================================================================
42 // function : BuildGUI()
43 // purpose  : Constructor
44 //=======================================================================
45 BuildGUI::BuildGUI() :
46   QObject()
47 {
48   myGeomBase = new GEOMBase();
49   myGeomGUI = GEOMContext::GetGeomGUI();
50   myGeom = myGeomGUI->myComponentGeom;
51 }
52
53
54 //=======================================================================
55 // function : ~BuildGUI()
56 // purpose  : Destructor
57 //=======================================================================
58 BuildGUI::~BuildGUI()
59 {
60 }
61
62
63 //=======================================================================
64 // function : OnGUIEvent()
65 // purpose  : 
66 //=======================================================================
67 bool BuildGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
68 {
69   BuildGUI* myBuildGUI = new BuildGUI();
70   myBuildGUI->myGeomGUI->EmitSignalDeactivateDialog();
71   SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
72
73   switch (theCommandID)
74     {
75     case 4081: // GEOM::EDGE
76       {
77         BuildGUI_EdgeDlg *aDlg = new BuildGUI_EdgeDlg(parent, "", myBuildGUI, Sel);
78         break;
79       }
80     case 4082: // GEOM::WIRE
81       {
82         BuildGUI_WireDlg *aDlg = new BuildGUI_WireDlg(parent, "", myBuildGUI, Sel);
83         break;
84       }
85     case 4083: // GEOM::FACE
86       {
87         BuildGUI_FaceDlg *aDlg = new BuildGUI_FaceDlg(parent, "", myBuildGUI, Sel);
88         break;
89       }
90     case 4084: // GEOM::SHELL
91       {
92         BuildGUI_ShellDlg *aDlg = new BuildGUI_ShellDlg(parent, "", myBuildGUI, Sel);
93         break;
94       }
95     case 4085: // GEOM::SOLID
96       {
97         BuildGUI_SolidDlg *aDlg = new BuildGUI_SolidDlg(parent, "", myBuildGUI, Sel);
98         break;
99       }
100     case 4086: // GEOM::COMPOUND
101       {
102         BuildGUI_CompoundDlg *aDlg = new BuildGUI_CompoundDlg(parent, "", myBuildGUI, Sel);
103         break;
104       }
105     default:
106       {
107         parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
108         break;
109       }
110     }
111   return true;
112 }
113
114
115 //=====================================================================================
116 // function : MakeLinearEdgeAndDisplay()
117 // purpose  :
118 //=====================================================================================
119 void BuildGUI::MakeLinearEdgeAndDisplay(const gp_Pnt P1, const gp_Pnt P2)
120 {
121   try {
122     GEOM::PointStruct ps1 = myGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z());
123     GEOM::PointStruct ps2 = myGeom->MakePointStruct(P2.X(), P2.Y(), P2.Z());
124     GEOM::GEOM_Shape_var result = myGeom->MakeEdge(ps1, ps2);
125     if(result->_is_nil()) {
126       QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE"));
127       return;
128     }
129     result->NameType(tr("GEOM_EDGE"));
130     if(myGeomBase->Display(result))
131       QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
132   }
133   catch(const SALOME::SALOME_Exception& S_ex) {
134     QtCatchCorbaException(S_ex);
135   }
136   return;
137 }
138
139
140 //=====================================================================================
141 // function : MakeWireAndDisplay()
142 // purpose  :
143 //=====================================================================================
144 void BuildGUI::MakeWireAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR)
145 {
146   try {
147     GEOM::GEOM_Shape_var result = myGeom->MakeWire(listShapesIOR);
148     if(result->_is_nil()) {
149       QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE"));
150       return;
151     }
152     result->NameType(tr("GEOM_WIRE"));
153     if(myGeomBase->Display(result))
154       QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
155   }
156   catch(const SALOME::SALOME_Exception& S_ex) {
157     QtCatchCorbaException(S_ex);
158   }
159   return;
160 }
161
162
163 //=====================================================================================
164 // function : MakeFaceAndDisplay()
165 // purpose  :
166 //=====================================================================================
167 void BuildGUI::MakeFaceAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR,
168                                   const Standard_Boolean wantPlanar)
169 {
170   try {
171     GEOM::GEOM_Shape_var result = myGeom->MakeFaces(listShapesIOR, wantPlanar);
172     if(result->_is_nil()) {
173       QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE"));
174       return;
175     }
176     if (wantPlanar)
177       result->NameType(tr("GEOM_PLANE"));
178     else
179       result->NameType(tr("GEOM_FACE"));
180     if(myGeomBase->Display(result))
181       QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
182   }
183   catch(const SALOME::SALOME_Exception& S_ex) {
184     QtCatchCorbaException(S_ex);
185   }
186   return;
187 }
188
189
190 //=====================================================================================
191 // function : MakeShellAndDisplay()
192 // purpose  :
193 //=====================================================================================
194 void BuildGUI::MakeShellAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR)
195 {
196   try {
197     GEOM::GEOM_Shape_var result = myGeom->MakeShell(listShapesIOR);
198     if(result->_is_nil()) {
199       QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE"));
200       return;
201     }
202     result->NameType(tr("GEOM_SHELL"));
203     if(myGeomBase->Display(result))
204       QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
205   }
206   catch(const SALOME::SALOME_Exception& S_ex) {
207     QtCatchCorbaException(S_ex);
208   }
209   return;
210 }
211
212
213 //=====================================================================================
214 // function : MakeSolidAndDisplay()
215 // purpose  :
216 //=====================================================================================
217 void BuildGUI::MakeSolidAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR)
218 {
219   try {
220     GEOM::GEOM_Shape_var result = myGeom->MakeSolid(listShapesIOR);
221     if(result->_is_nil()) {
222       QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE"));
223       return;
224     }
225     result->NameType(tr("GEOM_SOLID"));
226     if(myGeomBase->Display(result))
227       QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
228   }
229   catch(const SALOME::SALOME_Exception& S_ex) {
230     QtCatchCorbaException(S_ex);
231   }
232   return;
233 }
234
235
236 //=====================================================================================
237 // function : MakeCompoundAndDisplay()
238 // purpose  :
239 //=====================================================================================
240 void BuildGUI::MakeCompoundAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR)
241 {
242   try {
243     GEOM::GEOM_Shape_var result = myGeom->MakeCompound(listShapesIOR);
244     if(result->_is_nil()) {
245       QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE"));
246       return;
247     }
248     result->NameType(tr("GEOM_COMPOUND"));
249     if(myGeomBase->Display(result))
250       QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
251   }
252   catch(const SALOME::SALOME_Exception& S_ex) {
253     QtCatchCorbaException(S_ex);
254   }
255   return;
256 }
257
258
259 //=====================================================================================
260 // EXPORTED METHODS
261 //=====================================================================================
262 extern "C"
263 {
264   bool OnGUIEvent(int theCommandID, QAD_Desktop* parent)
265   {return BuildGUI::OnGUIEvent(theCommandID, parent);}
266 }