Salome HOME
Update GUI documentation for bugs 16559
[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 //
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
80   myGrp->TextEdit1->setReadOnly( TRUE );
81   // fix height to fit all text
82   myGrp->TextEdit1->setWordWrap(QTextEdit::NoWrap);
83   myGrp->TextEdit1->setTextFormat(Qt::PlainText);
84   QString allLines ("\n\n\n\n\n\n\n\n\n"); // 10 lines
85   myGrp->TextEdit1->setText(allLines);
86   int sbHeight = myGrp->TextEdit1->horizontalScrollBar()->height();
87   myGrp->TextEdit1->setFixedHeight(myGrp->TextEdit1->contentsHeight() + sbHeight);
88
89   myGrp->PushButton1->setPixmap( image1 );
90   myGrp->LineEdit1->setReadOnly( true );
91
92   Layout1->addWidget( myGrp, 1, 0 );
93
94   /***************************************************************/
95
96   myHelpFileName = "using_measurement_tools_page.html#whatis_anchor";
97
98   /* Initialisation */
99   Init();
100 }
101
102
103 //=================================================================================
104 // function : ~MeasureGUI_WhatisDlg()
105 // purpose  : Destroys the object and frees any allocated resources
106 //=================================================================================
107 MeasureGUI_WhatisDlg::~MeasureGUI_WhatisDlg()
108 {
109 }
110
111
112 //=================================================================================
113 // function : Init()
114 // purpose  :
115 //=================================================================================
116 void MeasureGUI_WhatisDlg::Init()
117 {
118   mySelBtn = myGrp->PushButton1;
119   mySelEdit = myGrp->LineEdit1;
120   MeasureGUI_Skeleton::Init();
121 }
122
123
124 //=================================================================================
125 // function : processObject
126 // purpose  :
127 //=================================================================================
128 void MeasureGUI_WhatisDlg::processObject()
129 {
130   QString aText;
131   myGrp->TextEdit1->setText( getParameters( aText ) ? aText : QString("") );
132 }
133
134
135 //=================================================================================
136 // function : getParameters
137 // purpose  :
138 //=================================================================================
139 bool MeasureGUI_WhatisDlg::getParameters( QString& theText )
140 {
141   if ( myObj->_is_nil() )
142     return false;
143   else
144   {
145     try
146     {
147       theText = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->WhatIs( myObj );
148     }
149     catch( const SALOME::SALOME_Exception& e )
150     {
151       SalomeApp_Tools::QtCatchCorbaException( e );
152       return false;
153     }
154
155     return getOperation()->IsDone();
156   }
157 }