]> SALOME platform Git repositories - modules/geom.git/blob - src/GroupGUI/GroupGUI.cxx
Salome HOME
Merge with version on tag OCC-V2_1_0d
[modules/geom.git] / src / GroupGUI / GroupGUI.cxx
1 //  GEOM GEOMGUI : GUI for Geometry component
2 //
3 //  Copyright (C) 2003  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.org 
21 //
22 //
23 //
24 //  File   : GroupGUI.cxx
25 //  Author : Sergey ANIKIN
26 //  Module : GEOM
27 //  $Header$
28
29 #include "GroupGUI.h"
30 #include "GroupGUI_GroupDlg.h" 
31
32 #include "GEOMImpl_Types.hxx"
33
34 #include "SALOMEGUI_QtCatchCorbaException.hxx"
35 #include "QAD_Desktop.h"
36 #include "QAD_MessageBox.h"
37
38 GroupGUI* GroupGUI::myGUIObject = 0;
39
40 //=======================================================================
41 // function : GetGroupGUI()
42 // purpose  : Get the only GroupGUI object [ static ]
43 //=======================================================================
44 GroupGUI* GroupGUI::GetGroupGUI()
45 {
46   if ( myGUIObject == 0 ) 
47     myGUIObject = new GroupGUI();
48
49   return myGUIObject;
50 }
51
52 //=======================================================================
53 // function : GroupGUI()
54 // purpose  : Constructor
55 //=======================================================================
56 GroupGUI::GroupGUI()
57 : GEOMGUI()
58 {
59 }
60
61
62 //=======================================================================
63 // function : ~GroupGUI()
64 // purpose  : Destructor
65 //=======================================================================
66 GroupGUI::~GroupGUI()
67 {
68 }
69
70
71 //=======================================================================
72 // function : OnGUIEvent()
73 // purpose  : 
74 //=======================================================================
75 bool GroupGUI::OnGUIEvent( int theCommandID, QAD_Desktop* parent )
76 {
77   GeometryGUI::GetGeomGUI()->EmitSignalDeactivateDialog();
78   
79   SALOME_Selection* Sel = SALOME_Selection::Selection(
80     QAD_Application::getDesktop()->getActiveStudy()->getSelection() );
81
82   QDialog* aDlg = NULL;
83
84   if ( QAD_Application::getDesktop()->getActiveStudy()->isLocked() ) {
85     QAD_MessageBox::warn1 ( QAD_Application::getDesktop(),
86                            QObject::tr("WRN_WARNING"), 
87                            QObject::tr("WRN_STUDY_LOCKED"),
88                            QObject::tr("BUT_OK") );
89     return false;
90   }
91
92   switch ( theCommandID ) {
93   case 800: 
94     aDlg = new GroupGUI_GroupDlg( GroupGUI_GroupDlg::CreateGroup, parent, "", Sel ); 
95     break;
96   case 801: 
97     {
98       if ( Sel->IObjectCount() == 1 ) {
99         Standard_Boolean aResult = Standard_False;
100         GEOM::GEOM_Object_var anObj =
101           GEOMBase::ConvertIOinGEOMObject( Sel->firstIObject(), aResult );
102
103         if ( aResult && !CORBA::is_nil( anObj ) && anObj->GetType() == GEOM_GROUP ) {
104           aDlg = new GroupGUI_GroupDlg( GroupGUI_GroupDlg::EditGroup,   parent, "", Sel ); 
105           break;
106         }
107       }
108       QAD_MessageBox::warn1 ( QAD_Application::getDesktop(),
109                              tr("WRN_WARNING"), 
110                              tr("NO_GROUP"),
111                              tr("BUT_OK") );
112       break;
113     }
114   default: 
115     parent->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) ); 
116     break;
117   }
118   
119   if ( aDlg != NULL )
120     aDlg->show();
121   
122   return true;
123 }
124
125 //=====================================================================================
126 // EXPORTED METHODS
127 //=====================================================================================
128 extern "C"
129 {
130   GEOMGUI* GetLibGUI()
131   {
132     return GroupGUI::GetGroupGUI();
133   }
134 }