Salome HOME
Merge from BR_phase16 branch (09/12/09)
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_Dialog.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 // SMESH SMESHGUI : GUI for SMESH component
23 // File   : SMESHGUI_Dialog.cxx
24 // Author : Alexander SOLOVYOV, Open CASCADE S.A.S.
25 // SMESH includes
26 //
27 #include "SMESHGUI_Dialog.h"
28
29 #include <SMESH_Type.h>
30
31 // SALOME GUI includes
32 #include <SUIT_Desktop.h>
33 #include <SUIT_Session.h>
34 #include <SalomeApp_Application.h>
35
36 // Qt includes
37 #include <QFrame>
38
39 //=================================================================================
40 // function : SMESHGUI_Dialog
41 // purpose  : Constructor
42 //=================================================================================
43 SMESHGUI_Dialog::SMESHGUI_Dialog( QWidget* parent, const bool modal,
44                                   const bool allowResize, const int flags )
45 : LightApp_Dialog( parent == 0 ? desktop() : parent, "", modal, allowResize, flags )
46 {
47   int pr = prefix( "SMESH" );
48   typeName( pr + MESH ) = tr( "DLG_MESH" );
49   typeName( pr + HYPOTHESIS ) = tr( "DLG_HYPO" );
50   typeName( pr + ALGORITHM ) = tr( "DLG_ALGO" );
51   setButtonText(1, tr("SMESH_BUT_APPLY_AND_CLOSE")); //rename OK to Apply and Close
52   if ( flags & Close )
53     setButtonPosition( Right, Close );
54 }
55
56 //=================================================================================
57 // function : ~SMESHGUI_Dialog
58 // purpose  : Destructor
59 //=================================================================================
60 SMESHGUI_Dialog::~SMESHGUI_Dialog()
61 {
62 }
63
64 //=================================================================================
65 // function : show
66 // purpose  :
67 //=================================================================================
68 void SMESHGUI_Dialog::show()
69 {
70   adjustSize();
71   LightApp_Dialog::show();
72 }
73
74 //=================================================================================
75 // function : setContentActive
76 // purpose  :
77 //=================================================================================
78 void SMESHGUI_Dialog::setContentActive( const bool active )
79 {
80   mainFrame()->setEnabled( active );
81   setButtonEnabled( active, OK );
82   setButtonEnabled( active, Apply );
83   setButtonEnabled( active, Cancel );
84   setButtonEnabled( active, Close );
85   setButtonEnabled( active, Help );
86 }
87
88 //=================================================================================
89 // function : desktop
90 // purpose  :
91 //=================================================================================
92 SUIT_Desktop* SMESHGUI_Dialog::desktop() const
93 {
94   SUIT_Desktop* d = 0;
95   SUIT_Session* s = SUIT_Session::session();
96   if( s )
97   {
98     SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( s->activeApplication() );
99     if( app )
100       d = app->desktop();
101   }
102   return d;
103 }
104
105 //=======================================================================
106 // name    : prefix
107 // Purpose : Get prefix for module types
108 //=======================================================================
109 int SMESHGUI_Dialog::prefix( const QString& name )
110 {
111   if( name == "GEOM" )
112     return 100;
113   else if( name == "SMESH" )
114     return 200;
115   else if( name == "SMESH element" )
116     return 300;
117   else
118     return 0;
119 }
120
121 //=======================================================================
122 // name    : resourceMgr
123 // Purpose : Gets resource manager
124 //=======================================================================
125 SUIT_ResourceMgr* SMESHGUI_Dialog::resourceMgr() const
126 {
127   return SUIT_Session::session()->resourceMgr();
128 }