]> SALOME platform Git repositories - modules/geom.git/blob - src/GroupGUI/GroupGUI.cxx
Salome HOME
Merge from V6_main (04/10/2012)
[modules/geom.git] / src / GroupGUI / GroupGUI.cxx
1 // Copyright (C) 2007-2012  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   : GroupGUI.cxx
24 // Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com)
25
26 #include "GroupGUI.h"
27 #include "GroupGUI_GroupDlg.h" 
28 #include "GroupGUI_BooleanDlg.h" 
29
30 #include <GeometryGUI.h>
31 #include "GeometryGUI_Operations.h"
32
33 #include <GEOMBase.h>
34 #include <GEOMImpl_Types.hxx>
35
36 #include <SUIT_Session.h>
37 #include <SUIT_Desktop.h>
38 #include <SUIT_MessageBox.h>
39 #include <SalomeApp_Application.h>
40 #include <SalomeApp_Study.h>
41 #include <LightApp_SelectionMgr.h>
42
43 //=======================================================================
44 // function : GroupGUI()
45 // purpose  : Constructor
46 //=======================================================================
47 GroupGUI::GroupGUI (GeometryGUI* parent)
48   : GEOMGUI(parent)
49 {
50 }
51
52 //=======================================================================
53 // function : ~GroupGUI()
54 // purpose  : Destructor
55 //=======================================================================
56 GroupGUI::~GroupGUI()
57 {
58 }
59
60
61 //=======================================================================
62 // function : OnGUIEvent()
63 // purpose  : 
64 //=======================================================================
65 bool GroupGUI::OnGUIEvent (int theCommandID, SUIT_Desktop* parent)
66 {
67   SalomeApp_Application* app = getGeometryGUI()->getApp();
68   if (!app) return false;
69
70   getGeometryGUI()->EmitSignalDeactivateDialog();
71
72   QDialog* aDlg = 0;
73
74   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
75   if (!appStudy) return false;
76   _PTR(Study) aStudy = appStudy->studyDS();
77
78   if (aStudy->GetProperties()->IsLocked()) {
79     SUIT_MessageBox::warning(parent, tr("WRN_WARNING"), tr("WRN_STUDY_LOCKED"));
80     return false;
81   }
82
83   switch (theCommandID) {
84   case GEOMOp::OpGroupCreate: 
85   case GEOMOp::OpGroupCreatePopup: // CREATE GROUP
86     aDlg = new GroupGUI_GroupDlg (GroupGUI_GroupDlg::CreateGroup, getGeometryGUI(), parent); 
87     break;
88   case GEOMOp::OpGroupEdit: // EDIT GROUP
89     {
90       SALOME_ListIO aList;
91       aList.Clear();
92
93       LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
94       if (aSelMgr)
95         aSelMgr->selectedObjects(aList);
96
97       if (aList.Extent() == 1) {
98         GEOM::GEOM_Object_var anObj =
99           GEOMBase::ConvertIOinGEOMObject(aList.First());
100
101         if (!CORBA::is_nil(anObj) && anObj->GetType() == GEOM_GROUP) {
102           aDlg = new GroupGUI_GroupDlg (GroupGUI_GroupDlg::EditGroup, getGeometryGUI(), parent); 
103           break;
104         }
105       }
106       SUIT_MessageBox::warning(parent, tr("WRN_WARNING"), tr("NO_GROUP"));
107     }
108     break;
109   case GEOMOp::OpGroupUnion: // UNION GROUPS
110     aDlg = new GroupGUI_BooleanDlg (GroupGUI_BooleanDlg::UNION, getGeometryGUI(), parent); 
111     break;
112   case GEOMOp::OpGroupIntersect: // INTERSECT GROUPS
113     aDlg = new GroupGUI_BooleanDlg (GroupGUI_BooleanDlg::INTERSECT, getGeometryGUI(), parent); 
114     break;
115   case GEOMOp::OpGroupCut: // CUT GROUPS
116     aDlg = new GroupGUI_BooleanDlg (GroupGUI_BooleanDlg::CUT, getGeometryGUI(), parent); 
117     break;
118   default: 
119     app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); 
120     break;
121   }
122
123   if (aDlg) {
124     aDlg->updateGeometry();
125     aDlg->resize(aDlg->minimumSizeHint());
126     aDlg->show();
127   }
128
129   return true;
130 }
131
132 //=====================================================================================
133 // EXPORTED METHODS
134 //=====================================================================================
135 extern "C"
136 {
137 #ifdef WIN32
138   __declspec( dllexport )
139 #endif
140   GEOMGUI* GetLibGUI( GeometryGUI* p )
141   {
142     return new GroupGUI( p );
143   }
144 }