Salome HOME
*** empty log message ***
[modules/geom.git] / src / MeasureGUI / MeasureGUI_WhatisDlg.cxx
1 // GEOM GEOMGUI : GUI for Geometry 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // File   : MeasureGUI_WhatisDlg.cxx
23 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
24 //
25
26 #include "MeasureGUI_WhatisDlg.h"
27 #include "MeasureGUI_Widgets.h"
28
29 #include <GEOMBase.h>
30
31 #include <SUIT_Session.h>
32 #include <SUIT_ResourceMgr.h>
33 #include <SalomeApp_Tools.h>
34
35 //=================================================================================
36 // class    : MeasureGUI_WhatisDlg( )
37 // purpose  : Constructs a MeasureGUI_WhatisDlg which is a child of 'parent', with the
38 //            name 'name' and widget flags set to 'f'.
39 //            The dialog will by default be modeless, unless you set 'modal' to
40 //            true to construct a modal dialog.
41 //=================================================================================
42 MeasureGUI_WhatisDlg::MeasureGUI_WhatisDlg( GeometryGUI* GUI, QWidget* parent )
43   : MeasureGUI_Skeleton( GUI, parent )
44 {
45   QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap(
46     "GEOM", tr( "ICON_DLG_WHATIS" ) ) );
47   QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap(
48     "GEOM", tr( "ICON_SELECT" ) ) );
49
50   setWindowTitle( tr( "GEOM_WHATIS_TITLE" ) );
51
52   /***************************************************************/
53   
54   mainFrame()->GroupConstructors->setTitle( tr( "GEOM_WHATIS" ) );
55   mainFrame()->RadioButton1->setIcon( image0 );
56
57   myGrp = new MeasureGUI_1Sel1TextView( centralWidget() );
58   myGrp->GroupBox1->setTitle( tr( "GEOM_WHATIS_OBJECT" ) );
59   myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
60   myGrp->TextView1->setReadOnly( true );
61   myGrp->PushButton1->setIcon( image1 );
62   myGrp->LineEdit1->setReadOnly( true );
63
64   QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
65   layout->setMargin( 0 ); layout->setSpacing( 6 );
66   layout->addWidget( myGrp );
67
68   /***************************************************************/
69
70   myHelpFileName = "files/salome2_sp3_measuregui_functions.htm#Whatis";
71
72   /* Initialisation */
73   Init();
74 }
75
76
77 //=================================================================================
78 // function : ~MeasureGUI_WhatisDlg()
79 // purpose  : Destroys the object and frees any allocated resources
80 //=================================================================================
81 MeasureGUI_WhatisDlg::~MeasureGUI_WhatisDlg()
82 {
83 }
84
85
86 //=================================================================================
87 // function : Init()
88 // purpose  :
89 //=================================================================================
90 void MeasureGUI_WhatisDlg::Init()
91 {
92   mySelBtn = myGrp->PushButton1;
93   mySelEdit = myGrp->LineEdit1;
94   MeasureGUI_Skeleton::Init();
95 }
96
97 //=================================================================================
98 // function : processObject
99 // purpose  :
100 //=================================================================================
101 void MeasureGUI_WhatisDlg::processObject()
102 {
103   QString aText;
104   myGrp->TextView1->setText( getParameters( aText ) ? aText : QString( "" ) );
105 }
106
107
108 //=================================================================================
109 // function : getParameters
110 // purpose  :
111 //=================================================================================
112 bool MeasureGUI_WhatisDlg::getParameters( QString& theText )
113 {
114   if ( myObj->_is_nil() )
115     return false;
116   else {
117     try {
118       theText = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->WhatIs( myObj );
119     }
120     catch( const SALOME::SALOME_Exception& e ) {
121       SalomeApp_Tools::QtCatchCorbaException( e );
122       return false;
123     }
124
125     return getOperation()->IsDone();
126   }
127 }
128
129
130