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