Salome HOME
PAL9391
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_Dialog.cxx
1 //  SMESH SMESHGUI : GUI for SMESH component
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
21 //
22 //
23 //
24 //  File   : SMESHGUI_Dialog.cxx
25 //  Author : Alexander SOLOVYOV
26 //  Module : SMESH
27 //  $Header$
28
29 #include <SMESHGUI_Dialog.h>
30 #include <SMESH_Type.h>
31 #include <SUIT_Session.h>
32 #include <SalomeApp_Application.h>
33
34 //=================================================================================
35 // function : SMESHGUI_Dialog
36 // purpose  : Constructor
37 //=================================================================================
38 SMESHGUI_Dialog::SMESHGUI_Dialog( QWidget* parent, const bool modal,
39                                   const bool allowResize, const int flags )
40 : SalomeApp_Dialog( parent == 0 ? desktop() : parent, "", modal, allowResize, flags )
41 {
42   int pr = prefix( "SMESH" );
43   typeName( pr + MESH ) = tr( "DLG_MESH" );
44   typeName( pr + HYPOTHESIS ) = tr( "DLG_HYPO" );
45   typeName( pr + ALGORITHM ) = tr( "DLG_ALGO" );
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   SUIT_Desktop *PP = desktop();
66   int x = abs( PP->x() + PP->size().width() - size().width() - 10 ),
67       y = abs( PP->y() + PP->size().height() - size().height() - 10 );
68   move(x, y);
69   SalomeApp_Dialog::show();
70 }
71
72 //=================================================================================
73 // function : setContentActive
74 // purpose  :
75 //=================================================================================
76 void SMESHGUI_Dialog::setContentActive( const bool active ) const
77 {
78   mainFrame()->setEnabled( active );
79 }
80
81 //=================================================================================
82 // function : desktop
83 // purpose  :
84 //=================================================================================
85 SUIT_Desktop* SMESHGUI_Dialog::desktop() const
86 {
87   SUIT_Desktop* d = 0;
88   SUIT_Session* s = SUIT_Session::session();
89   if( s )
90   {
91     SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( s->activeApplication() );
92     if( app )
93       d = app->desktop();
94   }
95   return d;
96 }
97
98 //=======================================================================
99 // name    : prefix
100 // Purpose : Get prefix for module types
101 //=======================================================================
102 int SMESHGUI_Dialog::prefix( const QString& name )
103 {
104   if( name == "GEOM" )
105     return 100;
106   else if( name == "SMESH" )
107     return 200;
108   else if( name == "SMESH element" )
109     return 300;
110   else
111     return 0;
112 }
113
114 //=======================================================================
115 // name    : resourceMgr
116 // Purpose : Gets resource manager
117 //=======================================================================
118 SUIT_ResourceMgr* resourceMgr()
119 {
120   return SUIT_Session::session()->resourceMgr();
121 }
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139