Back to index

salome-geom  6.5.0
GroupGUI.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // GEOM GEOMGUI : GUI for Geometry component
00024 // File   : GroupGUI.cxx
00025 // Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com)
00026 //
00027 #include "GroupGUI.h"
00028 #include "GroupGUI_GroupDlg.h" 
00029 
00030 #include <GeometryGUI.h>
00031 #include "GeometryGUI_Operations.h"
00032 
00033 #include <GEOMBase.h>
00034 #include <GEOMImpl_Types.hxx>
00035 
00036 #include <SUIT_Session.h>
00037 #include <SUIT_Desktop.h>
00038 #include <SUIT_MessageBox.h>
00039 #include <SalomeApp_Application.h>
00040 #include <SalomeApp_Study.h>
00041 #include <LightApp_SelectionMgr.h>
00042 
00043 //=======================================================================
00044 // function : GroupGUI()
00045 // purpose  : Constructor
00046 //=======================================================================
00047 GroupGUI::GroupGUI( GeometryGUI* parent )
00048   : GEOMGUI( parent )
00049 {
00050 }
00051 
00052 //=======================================================================
00053 // function : ~GroupGUI()
00054 // purpose  : Destructor
00055 //=======================================================================
00056 GroupGUI::~GroupGUI()
00057 {
00058 }
00059 
00060 
00061 //=======================================================================
00062 // function : OnGUIEvent()
00063 // purpose  : 
00064 //=======================================================================
00065 bool GroupGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
00066 {
00067   SalomeApp_Application* app = getGeometryGUI()->getApp();
00068   if ( !app ) return false;
00069 
00070   getGeometryGUI()->EmitSignalDeactivateDialog();
00071 
00072   QDialog* aDlg = 0;
00073 
00074   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
00075   if ( !appStudy ) return false;
00076   _PTR(Study) aStudy = appStudy->studyDS();
00077 
00078   if ( aStudy->GetProperties()->IsLocked() ) {
00079     SUIT_MessageBox::warning( parent,
00080                               tr( "WRN_WARNING" ), 
00081                               tr( "WRN_STUDY_LOCKED" ) );
00082     return false;
00083   }
00084 
00085   switch ( theCommandID ) {
00086   case GEOMOp::OpGroupCreate: 
00087   case GEOMOp::OpGroupCreatePopup: // CREATE GROUP
00088     aDlg = new GroupGUI_GroupDlg( GroupGUI_GroupDlg::CreateGroup, getGeometryGUI(), parent ); 
00089     break;
00090   case GEOMOp::OpGroupEdit:  // EDIT GROUP
00091     {
00092       SALOME_ListIO aList;
00093       aList.Clear();
00094 
00095       LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
00096       if ( aSelMgr )
00097         aSelMgr->selectedObjects( aList );
00098 
00099       if ( aList.Extent() == 1 ) {
00100         GEOM::GEOM_Object_var anObj =
00101           GEOMBase::ConvertIOinGEOMObject( aList.First() );
00102 
00103         if ( !CORBA::is_nil( anObj ) && anObj->GetType() == GEOM_GROUP ) {
00104           aDlg = new GroupGUI_GroupDlg( GroupGUI_GroupDlg::EditGroup, getGeometryGUI(), parent ); 
00105           break;
00106         }
00107       }
00108       SUIT_MessageBox::warning( parent, tr( "WRN_WARNING" ), tr( "NO_GROUP" ) );
00109       break;
00110     }
00111   default: 
00112     app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) ); 
00113     break;
00114   }
00115 
00116   if ( aDlg ) {
00117     aDlg->updateGeometry();
00118     aDlg->resize( aDlg->minimumSizeHint() );
00119     aDlg->show();
00120   }
00121 
00122   return true;
00123 }
00124 
00125 //=====================================================================================
00126 // EXPORTED METHODS
00127 //=====================================================================================
00128 extern "C"
00129 {
00130 #ifdef WIN32
00131   __declspec( dllexport )
00132 #endif
00133   GEOMGUI* GetLibGUI( GeometryGUI* p )
00134   {
00135     return new GroupGUI( p );
00136   }
00137 }