]> SALOME platform Git repositories - modules/geom.git/blob - src/BuildGUI/BuildGUI.cxx
Salome HOME
DCQ : New Architecture
[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_Shape_ptr aWire, const Standard_Boolean wantPlanar)
168 {
169   try {
170     GEOM::GEOM_Shape_var result = myGeom->MakeFace(aWire, wantPlanar);
171     if(result->_is_nil()) {
172       QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE"));
173       return;
174     }
175     if (wantPlanar)
176       result->NameType(tr("GEOM_PLANE"));
177     else
178       result->NameType(tr("GEOM_FACE"));
179     if(myGeomBase->Display(result))
180       QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
181   }
182   catch(const SALOME::SALOME_Exception& S_ex) {
183     QtCatchCorbaException(S_ex);
184   }
185   return;
186 }
187
188
189 //=====================================================================================
190 // function : MakeShellAndDisplay()
191 // purpose  :
192 //=====================================================================================
193 void BuildGUI::MakeShellAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR)
194 {
195   try {
196     GEOM::GEOM_Shape_var result = myGeom->MakeShell(listShapesIOR);
197     if(result->_is_nil()) {
198       QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE"));
199       return;
200     }
201     result->NameType(tr("GEOM_SHELL"));
202     if(myGeomBase->Display(result))
203       QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
204   }
205   catch(const SALOME::SALOME_Exception& S_ex) {
206     QtCatchCorbaException(S_ex);
207   }
208   return;
209 }
210
211
212 //=====================================================================================
213 // function : MakeSolidAndDisplay()
214 // purpose  :
215 //=====================================================================================
216 void BuildGUI::MakeSolidAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR)
217 {
218   try {
219     GEOM::GEOM_Shape_var result = myGeom->MakeSolid(listShapesIOR);
220     if(result->_is_nil()) {
221       QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE"));
222       return;
223     }
224     result->NameType(tr("GEOM_SOLID"));
225     if(myGeomBase->Display(result))
226       QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
227   }
228   catch(const SALOME::SALOME_Exception& S_ex) {
229     QtCatchCorbaException(S_ex);
230   }
231   return;
232 }
233
234
235 //=====================================================================================
236 // function : MakeCompoundAndDisplay()
237 // purpose  :
238 //=====================================================================================
239 void BuildGUI::MakeCompoundAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR)
240 {
241   try {
242     GEOM::GEOM_Shape_var result = myGeom->MakeCompound(listShapesIOR);
243     if(result->_is_nil()) {
244       QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE"));
245       return;
246     }
247     result->NameType(tr("GEOM_COMPOUND"));
248     if(myGeomBase->Display(result))
249       QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
250   }
251   catch(const SALOME::SALOME_Exception& S_ex) {
252     QtCatchCorbaException(S_ex);
253   }
254   return;
255 }
256
257
258 //=====================================================================================
259 // EXPORTED METHODS
260 //=====================================================================================
261 extern "C"
262 {
263   bool OnGUIEvent(int theCommandID, QAD_Desktop* parent)
264   {return BuildGUI::OnGUIEvent(theCommandID, parent);}
265 }