Salome HOME
*** empty log message ***
[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.com
21 //
22 // File   : GroupGUI.cxx
23 // Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com)
24 //
25
26 #include "GroupGUI.h"
27 #include "GroupGUI_GroupDlg.h" 
28
29 #include <GeometryGUI.h>
30 #include <GEOMBase.h>
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 = 0;
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::warning( parent,
77                               tr( "WRN_WARNING" ), 
78                               tr( "WRN_STUDY_LOCKED" ) );
79     return false;
80   }
81
82   switch ( theCommandID ) {
83   case 800: 
84   case 8001: // CREATE GROUP
85     aDlg = new GroupGUI_GroupDlg( GroupGUI_GroupDlg::CreateGroup, getGeometryGUI(), parent ); 
86     break;
87   case 801:  // EDIT GROUP
88     {
89       SALOME_ListIO aList;
90       aList.Clear();
91
92       LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
93       if ( aSelMgr )
94         aSelMgr->selectedObjects( aList );
95
96       if ( aList.Extent() == 1 ) {
97         Standard_Boolean aResult = Standard_False;
98         GEOM::GEOM_Object_var anObj =
99           GEOMBase::ConvertIOinGEOMObject( aList.First(), aResult );
100
101         if ( aResult && !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       break;
108     }
109   default: 
110     app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) ); 
111     break;
112   }
113
114   if ( aDlg ) {
115     aDlg->updateGeometry();
116     aDlg->resize( aDlg->minimumSize() );
117     aDlg->show();
118   }
119
120   return true;
121 }
122
123 //=====================================================================================
124 // EXPORTED METHODS
125 //=====================================================================================
126 extern "C"
127 {
128 #ifdef WIN32
129   __declspec( dllexport )
130 #endif
131   GEOMGUI* GetLibGUI( GeometryGUI* p )
132   {
133     return new GroupGUI( p );
134   }
135 }