1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // GEOM GEOMGUI : GUI for Geometry component
23 // File : TransformationGUI.cxx
24 // Author : Damien COQUERET, Open CASCADE S.A.S.
26 #include "TransformationGUI.h"
29 #include <GeometryGUI.h>
30 #include "GeometryGUI_Operations.h"
32 #include <SUIT_Desktop.h>
33 #include <SUIT_ViewModel.h>
34 #include <SUIT_ViewWindow.h>
35 #include <SUIT_ViewManager.h>
36 #include <LightApp_SelectionMgr.h>
37 #include <SalomeApp_Application.h>
38 #include <SalomeApp_Study.h>
39 #include <SALOME_ListIteratorOfListIO.hxx>
41 #include "TransformationGUI_MultiTranslationDlg.h" // Method MULTI TRANSLATION
42 #include "TransformationGUI_MultiRotationDlg.h" // Method MULTI ROTATION
43 #include "TransformationGUI_TranslationDlg.h" // Method TRANSLATION
44 #include "TransformationGUI_RotationDlg.h" // Method ROTATION
45 #include "TransformationGUI_MirrorDlg.h" // Method MIRROR
46 #include "TransformationGUI_ScaleDlg.h" // Method SCALE
47 #include "TransformationGUI_OffsetDlg.h" // Method OFFSET
48 #include "TransformationGUI_PositionDlg.h" // Method POSITION
50 //=======================================================================
51 // function : TransformationGUI()
52 // purpose : Constructor
53 //=======================================================================
54 TransformationGUI::TransformationGUI( GeometryGUI* parent )
59 //=======================================================================
60 // function : ~TransformationGUI()
61 // purpose : Destructor
62 //=======================================================================
63 TransformationGUI::~TransformationGUI()
68 //=======================================================================
69 // function : OnGUIEvent()
71 //=======================================================================
72 bool TransformationGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
74 SalomeApp_Application* app = getGeometryGUI()->getApp();
75 if ( !app ) return false;
77 getGeometryGUI()->EmitSignalDeactivateDialog();
80 switch ( theCommandID ) {
81 case GEOMOp::OpTranslate: // TRANSLATION
82 aDlg = new TransformationGUI_TranslationDlg( getGeometryGUI(), parent );
84 case GEOMOp::OpRotate: // ROTATION
85 aDlg = new TransformationGUI_RotationDlg( getGeometryGUI(), parent );
87 case GEOMOp::OpChangeLoc: // POSITION
88 aDlg = new TransformationGUI_PositionDlg( getGeometryGUI(), parent );
90 case GEOMOp::OpMirror: // MIRROR
91 aDlg = new TransformationGUI_MirrorDlg( getGeometryGUI(), parent );
93 case GEOMOp::OpScale: // SCALE
94 aDlg = new TransformationGUI_ScaleDlg( getGeometryGUI(), parent );
96 case GEOMOp::OpOffset: // OFFSET
97 aDlg = new TransformationGUI_OffsetDlg( getGeometryGUI(), parent );
99 case GEOMOp::OpMultiTranslate: // MULTI TRANSLATION
100 aDlg = new TransformationGUI_MultiTranslationDlg( getGeometryGUI(), parent );
102 case GEOMOp::OpMultiRotate: // MULTI ROTATION
103 aDlg = new TransformationGUI_MultiRotationDlg( getGeometryGUI(), parent );
105 case GEOMOp::OpReimport: // RELOAD IMPORTED SHAPE
107 SalomeApp_Study* anAppStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
109 GEOM::GEOM_ITransformOperations_var anOp =
110 GeometryGUI::GetGeomGen()->GetITransformOperations(anAppStudy->id());
111 if (anOp->_is_nil()) return false;
113 GEOM_Displayer aDisp (anAppStudy);
114 SUIT_Desktop* desk = app->desktop();
115 QList<SUIT_ViewWindow*> wnds = desk->windows();
117 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
118 SALOME_ListIO aSelList;
119 aSelMgr->selectedObjects(aSelList);
121 SALOME_ListIteratorOfListIO aSelIt (aSelList);
122 for (; aSelIt.More(); aSelIt.Next()) {
123 Handle(SALOME_InteractiveObject) io = aSelIt.Value();
124 Standard_Boolean testResult = Standard_False;
125 GEOM::GEOM_Object_var aGeomObj = GEOMBase::ConvertIOinGEOMObject(io, testResult);
127 anOp->RecomputeObject(aGeomObj);
129 SUIT_ViewWindow* wnd;
130 QListIterator<SUIT_ViewWindow*> it (wnds);
131 while (it.hasNext() && (wnd = it.next()))
133 if (SUIT_ViewManager* vman = wnd->getViewManager()) {
134 if (SUIT_ViewModel* vmodel = vman->getViewModel()) {
135 if (SALOME_View* view = dynamic_cast<SALOME_View*>(vmodel)) {
136 if (view->isVisible(io)) {
137 aDisp.Erase(io, false, false, view);
138 aDisp.Display(io, true, view);
140 // ? Redisplay subshapes ?
146 } // for (; aSelIt.More(); aSelIt.Next())
150 app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) );
161 //=====================================================================================
163 //=====================================================================================
167 __declspec( dllexport )
169 GEOMGUI* GetLibGUI( GeometryGUI* parent )
171 return new TransformationGUI( parent );