]> SALOME platform Git repositories - modules/geom.git/blob - src/GroupGUI/GroupGUI.cxx
Salome HOME
Update copyright information
[modules/geom.git] / src / GroupGUI / GroupGUI.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   : GroupGUI.cxx
24 //  Author : Sergey ANIKIN
25 //  Module : GEOM
26 //  $Header$
27 //
28 #include "GroupGUI.h"
29 #include "GroupGUI_GroupDlg.h" 
30
31 #include "GEOMImpl_Types.hxx"
32
33 #include "SUIT_Session.h"
34 #include "SUIT_Desktop.h"
35 #include "SUIT_MessageBox.h"
36 #include "SalomeApp_Application.h"
37 #include "SalomeApp_Study.h"
38 #include "LightApp_SelectionMgr.h"
39
40 //=======================================================================
41 // function : GroupGUI()
42 // purpose  : Constructor
43 //=======================================================================
44 GroupGUI::GroupGUI(GeometryGUI* parent)
45 : GEOMGUI(parent)
46 {
47 }
48
49 //=======================================================================
50 // function : ~GroupGUI()
51 // purpose  : Destructor
52 //=======================================================================
53 GroupGUI::~GroupGUI()
54 {
55 }
56
57
58 //=======================================================================
59 // function : OnGUIEvent()
60 // purpose  : 
61 //=======================================================================
62 bool GroupGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
63 {
64   SalomeApp_Application* app = getGeometryGUI()->getApp();
65   if ( !app ) return false;
66
67   getGeometryGUI()->EmitSignalDeactivateDialog();
68
69   QDialog* aDlg = NULL;
70
71   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
72   if ( !appStudy ) return false;
73   _PTR(Study) aStudy = appStudy->studyDS();
74
75   if ( aStudy->GetProperties()->IsLocked() ) {
76     SUIT_MessageBox::warn1 ( parent,
77                              QObject::tr("WRN_WARNING"), 
78                              QObject::tr("WRN_STUDY_LOCKED"),
79                              QObject::tr("BUT_OK") );
80     return false;
81   }
82
83   switch ( theCommandID ) {
84   case 800: 
85   case 8001: // CREATE GROUP
86     aDlg = new GroupGUI_GroupDlg (GroupGUI_GroupDlg::CreateGroup, getGeometryGUI(), parent); 
87     break;
88   case 801:  // 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         Standard_Boolean aResult = Standard_False;
99         GEOM::GEOM_Object_var anObj =
100           GEOMBase::ConvertIOinGEOMObject( aList.First(), aResult );
101
102         if (aResult && !CORBA::is_nil(anObj) && anObj->GetType() == GEOM_GROUP) {
103           aDlg = new GroupGUI_GroupDlg (GroupGUI_GroupDlg::EditGroup, getGeometryGUI(), parent); 
104           break;
105         }
106       }
107       SUIT_MessageBox::warn1(parent, tr("WRN_WARNING"), tr("NO_GROUP"), tr("BUT_OK") );
108       break;
109     }
110   default: 
111     app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); 
112     break;
113   }
114
115   if (aDlg != NULL)
116     aDlg->show();
117
118   return true;
119 }
120
121 //=====================================================================================
122 // EXPORTED METHODS
123 //=====================================================================================
124 extern "C"
125 {
126 #ifdef WNT
127         __declspec( dllexport )
128 #endif
129   GEOMGUI* GetLibGUI(GeometryGUI* p)
130   {
131     return new GroupGUI(p);
132   }
133 }