]> SALOME platform Git repositories - modules/geom.git/blob - src/TransformationGUI/TransformationGUI.cxx
Salome HOME
1361025037bed80e10c67fc536d2ebe26acf88e4
[modules/geom.git] / src / TransformationGUI / TransformationGUI.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // GEOM GEOMGUI : GUI for Geometry component
23 // File   : TransformationGUI.cxx
24 // Author : Damien COQUERET, Open CASCADE S.A.S.
25 //
26 #include "TransformationGUI.h"
27
28 #include <GEOMBase.h>
29 #include <GeometryGUI.h>
30
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>
39
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
48
49 //=======================================================================
50 // function : TransformationGUI()
51 // purpose  : Constructor
52 //=======================================================================
53 TransformationGUI::TransformationGUI( GeometryGUI* parent )
54   : GEOMGUI( parent )
55 {
56 }
57
58 //=======================================================================
59 // function : ~TransformationGUI()
60 // purpose  : Destructor
61 //=======================================================================
62 TransformationGUI::~TransformationGUI()
63 {
64 }
65
66
67 //=======================================================================
68 // function : OnGUIEvent()
69 // purpose  : 
70 //=======================================================================
71 bool TransformationGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
72 {
73   SalomeApp_Application* app = getGeometryGUI()->getApp();
74   if ( !app ) return false;
75
76   getGeometryGUI()->EmitSignalDeactivateDialog();
77   QDialog* aDlg = NULL;
78
79   switch ( theCommandID ) {
80   case 5021: // TRANSLATION
81     aDlg = new TransformationGUI_TranslationDlg( getGeometryGUI(), parent );
82     break;
83   case 5022: // ROTATION
84     aDlg = new TransformationGUI_RotationDlg( getGeometryGUI(), parent );
85     break;
86   case 5023: // POSITION
87     aDlg = new TransformationGUI_PositionDlg( getGeometryGUI(), parent );
88     break;
89   case 5024: // MIRROR
90     aDlg = new TransformationGUI_MirrorDlg( getGeometryGUI(), parent );
91     break;
92   case 5025: // SCALE
93     aDlg = new TransformationGUI_ScaleDlg( getGeometryGUI(), parent );
94     break;
95   case 5026: // OFFSET
96     aDlg = new TransformationGUI_OffsetDlg( getGeometryGUI(), parent );
97     break;
98   case 5027: // MULTI TRANSLATION
99     aDlg = new TransformationGUI_MultiTranslationDlg( getGeometryGUI(), parent );
100     break;
101   case 5028: // MULTI ROTATION
102     aDlg = new TransformationGUI_MultiRotationDlg( getGeometryGUI(), parent );
103     break;
104   case 5029: // RELOAD IMPORTED SHAPE
105     {
106       SalomeApp_Study* anAppStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
107
108       GEOM::GEOM_ITransformOperations_var anOp =
109         GeometryGUI::GetGeomGen()->GetITransformOperations(anAppStudy->id());
110       if (anOp->_is_nil()) return false;
111
112       GEOM_Displayer aDisp (anAppStudy);
113       SUIT_Desktop* desk = app->desktop();
114       QList<SUIT_ViewWindow*> wnds = desk->windows();
115
116       LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
117       SALOME_ListIO aSelList;
118       aSelMgr->selectedObjects(aSelList);
119
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);
125         if (testResult) {
126           anOp->RecomputeObject(aGeomObj);
127
128           SUIT_ViewWindow* wnd;
129           QListIterator<SUIT_ViewWindow*> it (wnds);
130           while (it.hasNext() && (wnd = it.next()))
131           {
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);
138                   }
139                   // ? Redisplay subshapes ?
140                 }
141               }
142             }
143           }
144         }
145       } // for (; aSelIt.More(); aSelIt.Next())
146     }
147     break;
148   default:
149     app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) );
150     break;
151   }
152
153   if ( aDlg != NULL )
154     aDlg->show();
155
156   return true;
157 }
158
159
160 //=====================================================================================
161 // EXPORTED METHODS
162 //=====================================================================================
163 extern "C"
164 {
165 #ifdef WNT
166   __declspec( dllexport )
167 #endif
168   GEOMGUI* GetLibGUI( GeometryGUI* parent )
169   {
170     return new TransformationGUI( parent );
171   }
172 }