00001 // Copyright (C) 2007-2011 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 // SMESH SMESHGUI : GUI for SMESH component 00024 // File : SMESHGUI_Dialog.cxx 00025 // Author : Alexander SOLOVYOV, Open CASCADE S.A.S. 00026 // SMESH includes 00027 // 00028 #include "SMESHGUI_Dialog.h" 00029 00030 #include <SMESH_Type.h> 00031 00032 // SALOME GUI includes 00033 #include <SUIT_Desktop.h> 00034 #include <SUIT_Session.h> 00035 #include <SalomeApp_Application.h> 00036 00037 // Qt includes 00038 #include <QFrame> 00039 00040 //================================================================================= 00041 // function : SMESHGUI_Dialog 00042 // purpose : Constructor 00043 //================================================================================= 00044 SMESHGUI_Dialog::SMESHGUI_Dialog( QWidget* parent, const bool modal, 00045 const bool allowResize, const int flags ) 00046 : LightApp_Dialog( parent == 0 ? desktop() : parent, "", modal, allowResize, flags ) 00047 { 00048 int pr = prefix( "SMESH" ); 00049 typeName( pr + MESH ) = tr( "DLG_MESH" ); 00050 typeName( pr + HYPOTHESIS ) = tr( "DLG_HYPO" ); 00051 typeName( pr + ALGORITHM ) = tr( "DLG_ALGO" ); 00052 setButtonText(1, tr("SMESH_BUT_APPLY_AND_CLOSE")); //rename OK to Apply and Close 00053 if ( flags & Close ) 00054 setButtonPosition( Right, Close ); 00055 } 00056 00057 //================================================================================= 00058 // function : ~SMESHGUI_Dialog 00059 // purpose : Destructor 00060 //================================================================================= 00061 SMESHGUI_Dialog::~SMESHGUI_Dialog() 00062 { 00063 } 00064 00065 //================================================================================= 00066 // function : show 00067 // purpose : 00068 //================================================================================= 00069 void SMESHGUI_Dialog::show() 00070 { 00071 adjustSize(); 00072 LightApp_Dialog::show(); 00073 } 00074 00075 //================================================================================= 00076 // function : setContentActive 00077 // purpose : 00078 //================================================================================= 00079 void SMESHGUI_Dialog::setContentActive( const bool active ) 00080 { 00081 mainFrame()->setEnabled( active ); 00082 setButtonEnabled( active, OK ); 00083 setButtonEnabled( active, Apply ); 00084 setButtonEnabled( active, Cancel ); 00085 setButtonEnabled( active, Close ); 00086 setButtonEnabled( active, Help ); 00087 } 00088 00089 //================================================================================= 00090 // function : desktop 00091 // purpose : 00092 //================================================================================= 00093 SUIT_Desktop* SMESHGUI_Dialog::desktop() const 00094 { 00095 SUIT_Desktop* d = 0; 00096 SUIT_Session* s = SUIT_Session::session(); 00097 if( s ) 00098 { 00099 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( s->activeApplication() ); 00100 if( app ) 00101 d = app->desktop(); 00102 } 00103 return d; 00104 } 00105 00106 //======================================================================= 00107 // name : prefix 00108 // Purpose : Get prefix for module types 00109 //======================================================================= 00110 int SMESHGUI_Dialog::prefix( const QString& name ) 00111 { 00112 if( name == "GEOM" ) 00113 return 100; 00114 else if( name == "SMESH" ) 00115 return 200; 00116 else if( name == "SMESH element" ) 00117 return 300; 00118 else 00119 return 0; 00120 } 00121 00122 //======================================================================= 00123 // name : resourceMgr 00124 // Purpose : Gets resource manager 00125 //======================================================================= 00126 SUIT_ResourceMgr* SMESHGUI_Dialog::resourceMgr() const 00127 { 00128 return SUIT_Session::session()->resourceMgr(); 00129 }