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