Salome HOME
IPAL21120 SIGSEGV on Meshing attached Compound with Automatic Hexadralization
[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
25 //  Module : SMESH
26 //  $Header$
27 //
28 #include <SMESHGUI_Dialog.h>
29 #include <SMESH_Type.h>
30 #include <SUIT_Session.h>
31 #include <SalomeApp_Application.h>
32
33 //=================================================================================
34 // function : SMESHGUI_Dialog
35 // purpose  : Constructor
36 //=================================================================================
37 SMESHGUI_Dialog::SMESHGUI_Dialog( QWidget* parent, const bool modal,
38                                   const bool allowResize, const int flags )
39 : LightApp_Dialog( parent == 0 ? desktop() : parent, "", modal, allowResize, flags )
40 {
41   int pr = prefix( "SMESH" );
42   typeName( pr + MESH ) = tr( "DLG_MESH" );
43   typeName( pr + HYPOTHESIS ) = tr( "DLG_HYPO" );
44   typeName( pr + ALGORITHM ) = tr( "DLG_ALGO" );
45   setButtonText(1, "A&pply and Close"); //rename OK to Apply and Close
46   if ( flags & Close )
47     setButtonPosition( Right, Close );
48 }
49
50 //=================================================================================
51 // function : ~SMESHGUI_Dialog
52 // purpose  : Destructor
53 //=================================================================================
54 SMESHGUI_Dialog::~SMESHGUI_Dialog()
55 {
56 }
57
58 //=================================================================================
59 // function : show
60 // purpose  :
61 //=================================================================================
62 void SMESHGUI_Dialog::show()
63 {
64   adjustSize();
65   LightApp_Dialog::show();
66 }
67
68 //=================================================================================
69 // function : setContentActive
70 // purpose  :
71 //=================================================================================
72 void SMESHGUI_Dialog::setContentActive( const bool active )
73 {
74   mainFrame()->setEnabled( active );
75   setButtonEnabled( active, OK );
76   setButtonEnabled( active, Apply );
77   setButtonEnabled( active, Cancel );
78   setButtonEnabled( active, Close );
79   setButtonEnabled( active, Help );
80 }
81
82 //=================================================================================
83 // function : desktop
84 // purpose  :
85 //=================================================================================
86 SUIT_Desktop* SMESHGUI_Dialog::desktop() const
87 {
88   SUIT_Desktop* d = 0;
89   SUIT_Session* s = SUIT_Session::session();
90   if( s )
91   {
92     SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( s->activeApplication() );
93     if( app )
94       d = app->desktop();
95   }
96   return d;
97 }
98
99 //=======================================================================
100 // name    : prefix
101 // Purpose : Get prefix for module types
102 //=======================================================================
103 int SMESHGUI_Dialog::prefix( const QString& name )
104 {
105   if( name == "GEOM" )
106     return 100;
107   else if( name == "SMESH" )
108     return 200;
109   else if( name == "SMESH element" )
110     return 300;
111   else
112     return 0;
113 }
114
115 //=======================================================================
116 // name    : resourceMgr
117 // Purpose : Gets resource manager
118 //=======================================================================
119 SUIT_ResourceMgr* SMESHGUI_Dialog::resourceMgr()
120 {
121   return SUIT_Session::session()->resourceMgr();
122 }
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140