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>
31 #include <SUIT_Desktop.h>
32 #include <SUIT_ViewModel.h>
33 #include <SUIT_ViewWindow.h>
34 #include <SUIT_ViewManager.h>
35 #include <LightApp_SelectionMgr.h>
36 #include <SalomeApp_Application.h>
37 #include <SalomeApp_Study.h>
38 #include <SALOME_ListIteratorOfListIO.hxx>
40 #include "TransformationGUI_MultiTranslationDlg.h" // Method MULTI TRANSLATION
41 #include "TransformationGUI_MultiRotationDlg.h" // Method MULTI ROTATION
42 #include "TransformationGUI_TranslationDlg.h" // Method TRANSLATION
43 #include "TransformationGUI_RotationDlg.h" // Method ROTATION
44 #include "TransformationGUI_MirrorDlg.h" // Method MIRROR
45 #include "TransformationGUI_ScaleDlg.h" // Method SCALE
46 #include "TransformationGUI_OffsetDlg.h" // Method OFFSET
47 #include "TransformationGUI_PositionDlg.h" // Method POSITION
49 //=======================================================================
50 // function : TransformationGUI()
51 // purpose : Constructor
52 //=======================================================================
53 TransformationGUI::TransformationGUI( GeometryGUI* parent )
58 //=======================================================================
59 // function : ~TransformationGUI()
60 // purpose : Destructor
61 //=======================================================================
62 TransformationGUI::~TransformationGUI()
67 //=======================================================================
68 // function : OnGUIEvent()
70 //=======================================================================
71 bool TransformationGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
73 SalomeApp_Application* app = getGeometryGUI()->getApp();
74 if ( !app ) return false;
76 getGeometryGUI()->EmitSignalDeactivateDialog();
79 switch ( theCommandID ) {
80 case 5021: // TRANSLATION
81 aDlg = new TransformationGUI_TranslationDlg( getGeometryGUI(), parent );
83 case 5022: // ROTATION
84 aDlg = new TransformationGUI_RotationDlg( getGeometryGUI(), parent );
86 case 5023: // POSITION
87 aDlg = new TransformationGUI_PositionDlg( getGeometryGUI(), parent );
90 aDlg = new TransformationGUI_MirrorDlg( getGeometryGUI(), parent );
93 aDlg = new TransformationGUI_ScaleDlg( getGeometryGUI(), parent );
96 aDlg = new TransformationGUI_OffsetDlg( getGeometryGUI(), parent );
98 case 5027: // MULTI TRANSLATION
99 aDlg = new TransformationGUI_MultiTranslationDlg( getGeometryGUI(), parent );
101 case 5028: // MULTI ROTATION
102 aDlg = new TransformationGUI_MultiRotationDlg( getGeometryGUI(), parent );
104 case 5029: // RELOAD IMPORTED SHAPE
106 SalomeApp_Study* anAppStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
108 GEOM::GEOM_ITransformOperations_var anOp =
109 GeometryGUI::GetGeomGen()->GetITransformOperations(anAppStudy->id());
110 if (anOp->_is_nil()) return false;
112 GEOM_Displayer aDisp (anAppStudy);
113 SUIT_Desktop* desk = app->desktop();
114 QList<SUIT_ViewWindow*> wnds = desk->windows();
116 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
117 SALOME_ListIO aSelList;
118 aSelMgr->selectedObjects(aSelList);
120 SALOME_ListIteratorOfListIO aSelIt (aSelList);
121 for (; aSelIt.More(); aSelIt.Next()) {
122 Handle(SALOME_InteractiveObject) io = aSelIt.Value();
123 Standard_Boolean testResult = Standard_False;
124 GEOM::GEOM_Object_var aGeomObj = GEOMBase::ConvertIOinGEOMObject(io, testResult);
126 anOp->RecomputeObject(aGeomObj);
128 SUIT_ViewWindow* wnd;
129 QListIterator<SUIT_ViewWindow*> it (wnds);
130 while (it.hasNext() && (wnd = it.next()))
132 if (SUIT_ViewManager* vman = wnd->getViewManager()) {
133 if (SUIT_ViewModel* vmodel = vman->getViewModel()) {
134 if (SALOME_View* view = dynamic_cast<SALOME_View*>(vmodel)) {
135 if (view->isVisible(io)) {
136 aDisp.Erase(io, false, false, view);
137 aDisp.Display(io, true, view);
139 // ? Redisplay subshapes ?
145 } // for (; aSelIt.More(); aSelIt.Next())
149 app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) );
160 //=====================================================================================
162 //=====================================================================================
166 __declspec( dllexport )
168 GEOMGUI* GetLibGUI( GeometryGUI* parent )
170 return new TransformationGUI( parent );