]> SALOME platform Git repositories - modules/geom.git/blob - src/MeasureGUI/MeasureGUI_WhatisDlg.cxx
Salome HOME
7bd5a6a810155dfabc18ed31d57bfb01e9d2ebb1
[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   /* Initialisation */
88   Init();
89 }
90
91
92 //=================================================================================
93 // function : ~MeasureGUI_WhatisDlg()
94 // purpose  : Destroys the object and frees any allocated resources
95 //=================================================================================
96 MeasureGUI_WhatisDlg::~MeasureGUI_WhatisDlg()
97 {
98 }
99
100
101 //=================================================================================
102 // function : Init()
103 // purpose  :
104 //=================================================================================
105 void MeasureGUI_WhatisDlg::Init()
106 {
107   mySelBtn = myGrp->PushButton1;
108   mySelEdit = myGrp->LineEdit1;
109   MeasureGUI_Skeleton::Init();
110 }
111
112 //=================================================================================
113 // function : processObject
114 // purpose  :
115 //=================================================================================
116 void MeasureGUI_WhatisDlg::processObject()
117 {
118   QString aText;
119   myGrp->TextEdit1->setText( getParameters( aText ) ? aText : QString("") );
120 }
121
122
123 //=================================================================================
124 // function : getParameters
125 // purpose  :
126 //=================================================================================
127 bool MeasureGUI_WhatisDlg::getParameters( QString& theText )
128 {
129   if ( myObj->_is_nil() )
130     return false;
131   else
132   {
133     try
134     {
135       theText = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->WhatIs( myObj );
136     }
137     catch( const SALOME::SALOME_Exception& e )
138     {
139       SalomeApp_Tools::QtCatchCorbaException( e );
140       return false;
141     }
142
143     return getOperation()->IsDone();
144   }
145 }
146
147
148