1 // GEOM GEOMGUI : GUI for Geometry component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : MeasureGUI_PropertiesDlg.cxx
25 // Author : Lucien PIGNOLONI
29 #include "MeasureGUI_PropertiesDlg.h"
30 #include "MeasureGUI_1Sel3LineEdit_QTD.h"
31 #include "GEOM_Displayer.h"
32 #include "GEOMImpl_Types.hxx"
35 #include "SalomeApp_Tools.h"
36 #include "utilities.h"
37 #include "SUIT_Session.h"
39 #include <TColStd_MapOfInteger.hxx>
41 #include <qlineedit.h>
44 #include <qpushbutton.h>
45 #include <qradiobutton.h>
46 #include <qbuttongroup.h>
48 //=================================================================================
49 // class : MeasureGUI_PropertiesDlg()
50 // purpose : Constructs a MeasureGUI_PropertiesDlg which is a child of 'parent', with the
51 // name 'name' and widget flags set to 'f'.
52 // The dialog will by default be modeless, unless you set 'modal' to
53 // TRUE to construct a modal dialog.
54 //=================================================================================
55 MeasureGUI_PropertiesDlg::MeasureGUI_PropertiesDlg( GeometryGUI* GUI, QWidget* parent )
56 : MeasureGUI_Skeleton( GUI, parent, "MeasureGUI_PropertiesDlg" )
58 QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap(
59 "GEOM",tr( "ICON_DLG_BASICPROPERTIES" ) ) );
60 QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap(
61 "GEOM",tr( "ICON_SELECT" ) ) );
63 setCaption( tr( "GEOM_PROPERTIES_TITLE" ) );
65 /***************************************************************/
67 GroupConstructors->setTitle( tr( "GEOM_PROPERTIES" ) );
68 RadioButton1->setPixmap( image0 );
70 myGrp = new MeasureGUI_1Sel3LineEdit_QTD( this, "myGrp" );
71 myGrp->GroupBox1->setTitle( tr( "GEOM_PROPERTIES_CONSTR" ) );
72 myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
73 myGrp->TextLabel2->setText( tr( "GEOM_LENGTH" ) );
74 myGrp->TextLabel3->setText( tr( "GEOM_PROPERTIES_SURFACE" ) );
75 myGrp->TextLabel4->setText( tr( "GEOM_PROPERTIES_VOLUME" ) );
76 myGrp->LineEdit2->setReadOnly( TRUE );
77 myGrp->LineEdit3->setReadOnly( TRUE );
78 myGrp->LineEdit4->setReadOnly( TRUE );
79 myGrp->PushButton1->setPixmap( image1 );
80 myGrp->LineEdit1->setReadOnly( true );
82 Layout1->addWidget( myGrp, 1, 0 );
84 /***************************************************************/
86 myHelpFileName = "files/salome2_sp3_measuregui_functions.htm#Basic_properties";
93 //=================================================================================
94 // function : ~MeasureGUI_PropertiesDlg()
95 // purpose : Destroys the object and frees any allocated resources
96 //=================================================================================
97 MeasureGUI_PropertiesDlg::~MeasureGUI_PropertiesDlg()
102 //=================================================================================
105 //=================================================================================
106 void MeasureGUI_PropertiesDlg::Init()
108 mySelBtn = myGrp->PushButton1;
109 mySelEdit = myGrp->LineEdit1;
110 MeasureGUI_Skeleton::Init();
113 //=================================================================================
114 // function : activateSelection
116 //=================================================================================
117 void MeasureGUI_PropertiesDlg::activateSelection()
119 static TColStd_MapOfInteger aTypes;
120 if ( aTypes.IsEmpty() )
122 aTypes.Add( GEOM_COMPOUND );
123 // aTypes.Add( TopAbs_COMPSOLID );
124 aTypes.Add( GEOM_SOLID );
125 aTypes.Add( GEOM_SHELL );
126 aTypes.Add( GEOM_FACE );
127 aTypes.Add( GEOM_WIRE );
128 aTypes.Add( GEOM_EDGE );
131 globalSelection( aTypes );
134 //=================================================================================
135 // function : processObject
137 //=================================================================================
138 void MeasureGUI_PropertiesDlg::processObject()
140 double aLength, anArea, aVolume;
142 if ( !getParameters( aLength, anArea, aVolume ) )
144 mySelEdit->setText( "" );
145 myGrp->LineEdit2->setText( "" );
146 myGrp->LineEdit3->setText( "" );
147 myGrp->LineEdit4->setText( "" );
151 myGrp->LineEdit2->setText( QString( "%1" ).arg( aLength ) );
152 myGrp->LineEdit3->setText( QString( "%1" ).arg( anArea ) );
153 myGrp->LineEdit4->setText( QString( "%1" ).arg( aVolume ) );
157 //=================================================================================
158 // function : getParameters
160 //=================================================================================
161 bool MeasureGUI_PropertiesDlg::getParameters( double& theLength,
165 if ( myObj->_is_nil() )
171 GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->GetBasicProperties(
172 myObj, theLength, theArea, theVolume );
174 catch( const SALOME::SALOME_Exception& e )
176 SalomeApp_Tools::QtCatchCorbaException( e );
180 return getOperation()->IsDone();
184 //=================================================================================
185 // function : createOperation
187 //=================================================================================
188 SALOME_Prs* MeasureGUI_PropertiesDlg::buildPrs()
190 TopoDS_Shape aShape, aResult;
192 if ( myObj->_is_nil() ||
193 !GEOMBase::GetShape( myObj, aShape )||
195 aShape.ShapeType() != TopAbs_EDGE ||
196 !GEOMBase::CreateArrowForLinearEdge( aShape, aResult ) ||
200 return getDisplayer()->BuildPrs( aResult );