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 : TransformationGUI.cxx
25 // Author : Damien COQUERET
30 #include "TransformationGUI.h"
32 #include "SALOMEGUI_QtCatchCorbaException.hxx"
34 #include "TransformationGUI_MultiTranslationDlg.h" // Method MULTI TRANSLATION
35 #include "TransformationGUI_MultiRotationDlg.h" // Method MULTI ROTATION
36 #include "TransformationGUI_TranslationDlg.h" // Method TRANSLATION
37 #include "TransformationGUI_RotationDlg.h" // Method ROTATION
38 #include "TransformationGUI_MirrorDlg.h" // Method MIRROR
39 #include "TransformationGUI_ScaleDlg.h" // Method SCALE
41 //=======================================================================
42 // function : TransformationGUI()
43 // purpose : Constructor
44 //=======================================================================
45 TransformationGUI::TransformationGUI() :
48 myGeomBase = new GEOMBase();
49 myGeomGUI = GEOMContext::GetGeomGUI();
50 myGeom = myGeomGUI->myComponentGeom;
54 //=======================================================================
55 // function : ~TransformationGUI()
56 // purpose : Destructor
57 //=======================================================================
58 TransformationGUI::~TransformationGUI()
63 //=======================================================================
64 // function : OnGUIEvent()
66 //=======================================================================
67 bool TransformationGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
69 TransformationGUI* myTransformationGUI = new TransformationGUI();
70 myTransformationGUI->myGeomGUI->EmitSignalDeactivateDialog();
71 SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
75 case 5021: // TRANSLATION
77 TransformationGUI_TranslationDlg *aDlg = new TransformationGUI_TranslationDlg(parent, "", myTransformationGUI, Sel);
80 case 5022: // ROTATION
82 TransformationGUI_RotationDlg *aDlg = new TransformationGUI_RotationDlg(parent, "", myTransformationGUI, Sel);
87 TransformationGUI_MirrorDlg *aDlg = new TransformationGUI_MirrorDlg(parent, "", myTransformationGUI, Sel);
92 TransformationGUI_ScaleDlg *aDlg = new TransformationGUI_ScaleDlg(parent, "", myTransformationGUI, Sel );
95 case 5025: // MULTI TRANSLATION
97 TransformationGUI_MultiTranslationDlg *aDlg = new TransformationGUI_MultiTranslationDlg(parent, "", myTransformationGUI, Sel);
100 case 5026: // MULTI ROTATION
102 TransformationGUI_MultiRotationDlg *aDlg = new TransformationGUI_MultiRotationDlg(parent, "", myTransformationGUI, Sel);
107 parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
115 //=================================================================================
116 // function : MakeTranslationAndDisplay()
117 // purpose : Translate a shape
118 //=================================================================================
119 void TransformationGUI::MakeTranslationAndDisplay(GEOM::GEOM_Shape_ptr Shape, gp_Vec V)
122 GEOM::GEOM_Shape_var result = myGeom->MakeTranslation(Shape, V.X(), V.Y(), V.Z());
123 if(result->_is_nil()) {
124 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT"));
127 result->NameType(Shape->NameType());
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 : MakeRotationAndDisplay()
141 //=======================================================================================
142 void TransformationGUI::MakeRotationAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc,
143 const gp_Dir dir, const Standard_Real angle)
146 const GEOM::AxisStruct axis = myGeom->MakeAxisStruct(loc.X(), loc.Y(), loc.Z(),
147 dir.X(), dir.Y(), dir.Z());
148 GEOM::GEOM_Shape_var result = myGeom->MakeRotation(Shape, axis, angle);
149 if(result->_is_nil()) {
150 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT"));
153 result->NameType(Shape->NameType());
154 if(myGeomBase->Display(result))
155 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
157 catch(const SALOME::SALOME_Exception& S_ex) {
158 QtCatchCorbaException(S_ex);
164 //=====================================================================================
165 // function : MakeMirrorAndDisplay()
167 //=====================================================================================
168 void TransformationGUI::MakeMirrorAndDisplay(GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2)
171 GEOM::GEOM_Shape_var result = myGeom->MakeMirrorByPlane(Shape1, Shape2);
172 if(result->_is_nil()) {
173 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE"));
176 result->NameType(Shape1->NameType());
177 if(myGeomBase->Display(result))
178 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
180 catch(const SALOME::SALOME_Exception& S_ex) {
181 QtCatchCorbaException(S_ex);
187 //=====================================================================================
188 // function : MakeScaleAndDisplay()
190 //=====================================================================================
191 void TransformationGUI::MakeScaleAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Pnt centralPoint,
192 const Standard_Real factor)
195 GEOM::PointStruct P = myGeom->MakePointStruct(centralPoint.X(), centralPoint.Y(), centralPoint.Z());
196 GEOM::GEOM_Shape_var result = myGeom->MakeScaleTransform(Shape, P, factor);
197 result->NameType(Shape->NameType());
198 if(myGeomBase->Display(result))
199 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
201 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE"));
203 catch(const SALOME::SALOME_Exception& S_ex) {
204 QtCatchCorbaException(S_ex);
210 //=================================================================================
211 // function : MakeMultiTranslation1DAndDisplay()
212 // purpose : Multi-Translate a shape
213 //=================================================================================
214 void TransformationGUI::MakeMultiTranslation1DAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir,
215 const double Step, const short NbTimes)
218 GEOM::PointStruct d = myGeom->MakePointStruct(Dir.X(), Dir.Y(), Dir.Z());
219 GEOM::DirStruct dstruct = myGeom->MakeDirection(d);
221 GEOM::GEOM_Shape_var result = myGeom->MakeMultiTranslation1D(Shape, dstruct, Step, NbTimes);
222 if(result->_is_nil()) {
223 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT"));
226 result->NameType(tr("GEOM_COMPOUND"));
227 if(myGeomBase->Display(result))
228 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
230 catch(const SALOME::SALOME_Exception& S_ex) {
231 QtCatchCorbaException(S_ex);
237 //=================================================================================
238 // function : MakeMultiTranslation2DAndDisplay()
239 // purpose : Multi-Translate a shape
240 //=================================================================================
241 void TransformationGUI::MakeMultiTranslation2DAndDisplay(GEOM::GEOM_Shape_ptr Shape,
242 const gp_Dir Dir1,const double Step1, const short NbTimes1,
243 const gp_Dir Dir2, const double Step2, const short NbTimes2)
246 GEOM::PointStruct d1 = myGeom->MakePointStruct(Dir1.X(), Dir1.Y(), Dir1.Z());
247 GEOM::DirStruct dstruct1 = myGeom->MakeDirection(d1);
248 GEOM::PointStruct d2 = myGeom->MakePointStruct(Dir2.X(), Dir2.Y(), Dir2.Z());
249 GEOM::DirStruct dstruct2 = myGeom->MakeDirection(d2);
251 GEOM::GEOM_Shape_var result = myGeom->MakeMultiTranslation2D(Shape, dstruct1, Step1, NbTimes1,
252 dstruct2, Step2, NbTimes2);
253 if(result->_is_nil()) {
254 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT"));
257 result->NameType(tr("GEOM_COMPOUND"));
258 if(myGeomBase->Display(result))
259 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
261 catch(const SALOME::SALOME_Exception& S_ex) {
262 QtCatchCorbaException(S_ex);
268 //=================================================================================
269 // function : MakeMultiRotation1DAndDisplay()
270 // purpose : Multi-Rotate a shape
271 //=================================================================================
272 void TransformationGUI::MakeMultiRotation1DAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir,
273 const gp_Pnt Loc, const short NbTimes)
276 GEOM::PointStruct d = myGeom->MakePointStruct(Dir.X(), Dir.Y(), Dir.Z());
277 GEOM::DirStruct dstruct = myGeom->MakeDirection(d) ;
278 GEOM::PointStruct pstruct = myGeom->MakePointStruct(Loc.X(), Loc.Y(), Loc.Z());
280 GEOM::GEOM_Shape_var result = myGeom->MakeMultiRotation1D(Shape, dstruct, pstruct, NbTimes);
281 if(result->_is_nil()) {
282 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT"));
285 result->NameType(tr("GEOM_COMPOUND"));
286 if(myGeomBase->Display(result))
287 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
289 catch(const SALOME::SALOME_Exception& S_ex) {
290 QtCatchCorbaException(S_ex);
296 //=================================================================================
297 // function : MakeMultiRotation2DAndDisplay()
298 // purpose : Multi-Rotate a shape
299 //=================================================================================
300 void TransformationGUI::MakeMultiRotation2DAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir,
301 const gp_Pnt Loc, const double Ang, const short NbTimes1,
302 const double Step, const short NbTimes2)
305 GEOM::PointStruct d = myGeom->MakePointStruct(Dir.X(), Dir.Y(), Dir.Z());
306 GEOM::DirStruct dstruct = myGeom->MakeDirection(d);
307 GEOM::PointStruct pstruct = myGeom->MakePointStruct(Loc.X(), Loc.Y(), Loc.Z());
309 GEOM::GEOM_Shape_var result = myGeom->MakeMultiRotation2D(Shape, dstruct, pstruct,
310 Ang, NbTimes1, Step, NbTimes2);
311 if(result->_is_nil()) {
312 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT"));
315 result->NameType(tr("GEOM_COMPOUND"));
316 if(myGeomBase->Display(result))
317 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
319 catch(const SALOME::SALOME_Exception& S_ex) {
320 QtCatchCorbaException(S_ex);
326 //=====================================================================================
328 //=====================================================================================
331 bool OnGUIEvent(int theCommandID, QAD_Desktop* parent)
332 {return TransformationGUI::OnGUIEvent(theCommandID, parent);}