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
28 #include "TransformationGUI.h"
31 #include "GeometryGUI.h"
33 #include <SUIT_Session.h>
34 #include <SUIT_Desktop.h>
35 #include <SUIT_ViewModel.h>
36 #include <SUIT_ViewWindow.h>
37 #include <SUIT_ViewManager.h>
38 #include <LightApp_SelectionMgr.h>
39 #include <SalomeApp_Application.h>
40 #include <SalomeApp_Study.h>
41 #include <SALOME_ListIteratorOfListIO.hxx>
43 #include "TransformationGUI_MultiTranslationDlg.h" // Method MULTI TRANSLATION
44 #include "TransformationGUI_MultiRotationDlg.h" // Method MULTI ROTATION
45 #include "TransformationGUI_TranslationDlg.h" // Method TRANSLATION
46 #include "TransformationGUI_RotationDlg.h" // Method ROTATION
47 #include "TransformationGUI_MirrorDlg.h" // Method MIRROR
48 #include "TransformationGUI_ScaleDlg.h" // Method SCALE
49 #include "TransformationGUI_OffsetDlg.h" // Method OFFSET
50 #include "TransformationGUI_PositionDlg.h" // Method POSITION
54 //=======================================================================
55 // function : TransformationGUI()
56 // purpose : Constructor
57 //=======================================================================
58 TransformationGUI::TransformationGUI(GeometryGUI* parent) : GEOMGUI(parent)
62 //=======================================================================
63 // function : ~TransformationGUI()
64 // purpose : Destructor
65 //=======================================================================
66 TransformationGUI::~TransformationGUI()
71 //=======================================================================
72 // function : OnGUIEvent()
74 //=======================================================================
75 bool TransformationGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
77 SalomeApp_Application* app = getGeometryGUI()->getApp();
78 if (!app) return false;
80 getGeometryGUI()->EmitSignalDeactivateDialog();
85 case 5021: // TRANSLATION
86 aDlg = new TransformationGUI_TranslationDlg( getGeometryGUI(), parent, "" );
88 case 5022: // ROTATION
89 aDlg = new TransformationGUI_RotationDlg( getGeometryGUI(), parent, "" );
91 case 5023: // POSITION
92 aDlg = new TransformationGUI_PositionDlg( getGeometryGUI(), parent, "" );
95 aDlg = new TransformationGUI_MirrorDlg( getGeometryGUI(), parent, "" );
98 aDlg = new TransformationGUI_ScaleDlg( getGeometryGUI(), parent, "" );
101 aDlg = new TransformationGUI_OffsetDlg( getGeometryGUI(), parent, "" );
103 case 5027: // MULTI TRANSLATION
104 aDlg = new TransformationGUI_MultiTranslationDlg( getGeometryGUI(), parent, "" );
106 case 5028: // MULTI ROTATION
107 aDlg = new TransformationGUI_MultiRotationDlg( getGeometryGUI(), parent, "" );
109 case 5029: // RELOAD IMPORTED SHAPE
111 SalomeApp_Study* anAppStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
113 GEOM::GEOM_ITransformOperations_var anOp =
114 GeometryGUI::GetGeomGen()->GetITransformOperations(anAppStudy->id());
115 if (anOp->_is_nil()) return false;
117 GEOM_Displayer aDisp (anAppStudy);
118 SUIT_Desktop* desk = app->desktop();
119 QPtrList<SUIT_ViewWindow> wnds = desk->windows();
121 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
122 SALOME_ListIO aSelList;
123 aSelMgr->selectedObjects(aSelList);
125 SALOME_ListIteratorOfListIO aSelIt (aSelList);
126 for (; aSelIt.More(); aSelIt.Next()) {
127 Handle(SALOME_InteractiveObject) io = aSelIt.Value();
128 Standard_Boolean testResult = Standard_False;
129 GEOM::GEOM_Object_var aGeomObj = GEOMBase::ConvertIOinGEOMObject(io, testResult);
131 anOp->RecomputeObject(aGeomObj);
133 SUIT_ViewWindow* wnd;
134 for ( wnd = wnds.first(); wnd; wnd = wnds.next() )
136 if (SUIT_ViewManager* vman = wnd->getViewManager()) {
137 if (SUIT_ViewModel* vmodel = vman->getViewModel()) {
138 if (SALOME_View* view = dynamic_cast<SALOME_View*>(vmodel)) {
139 if (view->isVisible(io)) {
140 aDisp.Erase(io, false, false, view);
141 aDisp.Display(io, true, view);
143 // ? Redisplay subshapes ?
149 } // for (; aSelIt.More(); aSelIt.Next())
153 app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
164 //=====================================================================================
166 //=====================================================================================
170 __declspec( dllexport )
172 GEOMGUI* GetLibGUI( GeometryGUI* parent )
174 return new TransformationGUI( parent );