Salome HOME
36643d6d3085b96f7e930074a6c0571be0ba829c
[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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : MeasureGUI_WhatisDlg.cxx
25 //  Author : Nicolas REJNERI
26 //  Module : GEOM
27 //  $Header$
28
29 #include "MeasureGUI_WhatisDlg.h"
30 #include "MeasureGUI_1Sel1TextView_QTD.h"
31 #include "GEOMBase.h"
32
33 #include <TopTools_MapOfShape.hxx>
34 #include <TCollection_AsciiString.hxx>
35 #include <TopTools_ListOfShape.hxx>
36 #include <TopTools_ListIteratorOfListOfShape.hxx>
37 #include <TopoDS.hxx>
38 #include <TopoDS_Iterator.hxx>
39
40 #include <BRep_Tool.hxx>
41
42 #include "utilities.h"
43 #include "SUIT_Session.h"
44 #include "SalomeApp_Tools.h"
45
46 #include <qtextedit.h>
47 #include <qlineedit.h>
48 #include <qlabel.h>
49 #include <qlayout.h>
50 #include <qpushbutton.h>
51 #include <qradiobutton.h>
52 #include <qbuttongroup.h>
53
54 //=================================================================================
55 // class    : MeasureGUI_WhatisDlg( )
56 // purpose  : Constructs a MeasureGUI_WhatisDlg which is a child of 'parent', with the
57 //            name 'name' and widget flags set to 'f'.
58 //            The dialog will by default be modeless, unless you set 'modal' to
59 //            TRUE to construct a modal dialog.
60 //=================================================================================
61 MeasureGUI_WhatisDlg::MeasureGUI_WhatisDlg( GeometryGUI* GUI, QWidget* parent )
62 : MeasureGUI_Skeleton( GUI, parent, "MeasureGUI_WhatisDlg" )
63 {
64   QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap(
65     "GEOM",tr( "ICON_DLG_WHATIS" ) ) );
66   QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap(
67     "GEOM",tr( "ICON_SELECT" ) ) );
68
69   setCaption( tr( "GEOM_WHATIS_TITLE" ) );
70
71   /***************************************************************/
72   
73   GroupConstructors->setTitle( tr( "GEOM_WHATIS" ) );
74   RadioButton1->setPixmap( image0 );
75
76   myGrp = new MeasureGUI_1Sel1TextView_QTD( this, "myGrp" );
77   myGrp->GroupBox1->setTitle( tr( "GEOM_WHATIS_OBJECT" ) );
78   myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
79   myGrp->TextEdit1->setReadOnly( TRUE );
80   myGrp->PushButton1->setPixmap( image1 );
81   myGrp->LineEdit1->setReadOnly( true );
82
83   Layout1->addWidget( myGrp, 1, 0 );
84
85   /***************************************************************/
86
87   myHelpFileName = "files/salome2_sp3_measuregui_functions.htm#Whatis";
88
89   /* Initialisation */
90   Init();
91 }
92
93
94 //=================================================================================
95 // function : ~MeasureGUI_WhatisDlg()
96 // purpose  : Destroys the object and frees any allocated resources
97 //=================================================================================
98 MeasureGUI_WhatisDlg::~MeasureGUI_WhatisDlg()
99 {
100 }
101
102
103 //=================================================================================
104 // function : Init()
105 // purpose  :
106 //=================================================================================
107 void MeasureGUI_WhatisDlg::Init()
108 {
109   mySelBtn = myGrp->PushButton1;
110   mySelEdit = myGrp->LineEdit1;
111   MeasureGUI_Skeleton::Init();
112 }
113
114 //=================================================================================
115 // function : processObject
116 // purpose  :
117 //=================================================================================
118 void MeasureGUI_WhatisDlg::processObject()
119 {
120   QString aText;
121   myGrp->TextEdit1->setText( getParameters( aText ) ? aText : QString("") );
122 }
123
124
125 //=================================================================================
126 // function : getParameters
127 // purpose  :
128 //=================================================================================
129 bool MeasureGUI_WhatisDlg::getParameters( QString& theText )
130 {
131   if ( myObj->_is_nil() )
132     return false;
133   else
134   {
135     try
136     {
137       theText = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->WhatIs( myObj );
138     }
139     catch( const SALOME::SALOME_Exception& e )
140     {
141       SalomeApp_Tools::QtCatchCorbaException( e );
142       return false;
143     }
144
145     return getOperation()->IsDone();
146   }
147 }
148
149
150