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.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : MeasureGUI_PropertiesDlg.cxx
23 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
26 #include "MeasureGUI_PropertiesDlg.h"
27 #include "MeasureGUI_Widgets.h"
29 #include <GEOMImpl_Types.hxx>
32 #include <SalomeApp_Tools.h>
33 #include <SUIT_Session.h>
34 #include <SUIT_ResourceMgr.h>
36 #include <TColStd_MapOfInteger.hxx>
38 //=================================================================================
39 // class : MeasureGUI_PropertiesDlg()
40 // purpose : Constructs a MeasureGUI_PropertiesDlg which is a child of 'parent', with the
41 // name 'name' and widget flags set to 'f'.
42 // The dialog will by default be modeless, unless you set 'modal' to
43 // true to construct a modal dialog.
44 //=================================================================================
45 MeasureGUI_PropertiesDlg::MeasureGUI_PropertiesDlg( GeometryGUI* GUI, QWidget* parent )
46 : MeasureGUI_Skeleton( GUI, parent )
48 QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap(
49 "GEOM", tr( "ICON_DLG_BASICPROPERTIES" ) ) );
50 QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap(
51 "GEOM", tr( "ICON_SELECT" ) ) );
53 setWindowTitle( tr( "GEOM_PROPERTIES_TITLE" ) );
55 /***************************************************************/
57 mainFrame()->GroupConstructors->setTitle( tr( "GEOM_PROPERTIES" ) );
58 mainFrame()->RadioButton1->setIcon( image0 );
60 myGrp = new MeasureGUI_1Sel3LineEdit( centralWidget() );
61 myGrp->GroupBox1->setTitle( tr( "GEOM_PROPERTIES_CONSTR" ) );
62 myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
63 myGrp->TextLabel2->setText( tr( "GEOM_LENGTH" ) );
64 myGrp->TextLabel3->setText( tr( "GEOM_PROPERTIES_SURFACE" ) );
65 myGrp->TextLabel4->setText( tr( "GEOM_PROPERTIES_VOLUME" ) );
66 myGrp->LineEdit1->setReadOnly( true );
67 myGrp->PushButton1->setIcon( image1 );
68 myGrp->LineEdit2->setReadOnly( true );
69 myGrp->LineEdit3->setReadOnly( true );
70 myGrp->LineEdit4->setReadOnly( true );
72 QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
73 layout->setMargin( 0 ); layout->setSpacing( 6 );
74 layout->addWidget( myGrp );
76 /***************************************************************/
78 myHelpFileName = "files/salome2_sp3_measuregui_functions.htm#Basic_properties";
85 //=================================================================================
86 // function : ~MeasureGUI_PropertiesDlg()
87 // purpose : Destroys the object and frees any allocated resources
88 //=================================================================================
89 MeasureGUI_PropertiesDlg::~MeasureGUI_PropertiesDlg()
94 //=================================================================================
97 //=================================================================================
98 void MeasureGUI_PropertiesDlg::Init()
100 mySelBtn = myGrp->PushButton1;
101 mySelEdit = myGrp->LineEdit1;
102 MeasureGUI_Skeleton::Init();
105 //=================================================================================
106 // function : activateSelection
108 //=================================================================================
109 void MeasureGUI_PropertiesDlg::activateSelection()
111 static TColStd_MapOfInteger aTypes;
112 if ( aTypes.IsEmpty() ) {
113 aTypes.Add( GEOM_COMPOUND );
114 // aTypes.Add( TopAbs_COMPSOLID );
115 aTypes.Add( GEOM_SOLID );
116 aTypes.Add( GEOM_SHELL );
117 aTypes.Add( GEOM_FACE );
118 aTypes.Add( GEOM_WIRE );
119 aTypes.Add( GEOM_EDGE );
122 globalSelection( aTypes );
125 //=================================================================================
126 // function : processObject
128 //=================================================================================
129 void MeasureGUI_PropertiesDlg::processObject()
131 double aLength, anArea, aVolume;
133 if ( !getParameters( aLength, anArea, aVolume ) ) {
134 mySelEdit->setText( "" );
135 myGrp->LineEdit2->setText( "" );
136 myGrp->LineEdit3->setText( "" );
137 myGrp->LineEdit4->setText( "" );
140 myGrp->LineEdit2->setText( QString( "%1" ).arg( aLength ) );
141 myGrp->LineEdit3->setText( QString( "%1" ).arg( anArea ) );
142 myGrp->LineEdit4->setText( QString( "%1" ).arg( aVolume ) );
146 //=================================================================================
147 // function : getParameters
149 //=================================================================================
150 bool MeasureGUI_PropertiesDlg::getParameters( double& theLength,
154 if ( myObj->_is_nil() )
158 GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->GetBasicProperties(
159 myObj, theLength, theArea, theVolume );
161 catch( const SALOME::SALOME_Exception& e ) {
162 SalomeApp_Tools::QtCatchCorbaException( e );
166 return getOperation()->IsDone();
170 //=================================================================================
171 // function : createOperation
173 //=================================================================================
174 SALOME_Prs* MeasureGUI_PropertiesDlg::buildPrs()
176 TopoDS_Shape aShape, aResult;
178 if ( myObj->_is_nil() ||
179 !GEOMBase::GetShape( myObj, aShape ) ||
181 aShape.ShapeType() != TopAbs_EDGE ||
182 !GEOMBase::CreateArrowForLinearEdge( aShape, aResult ) ||
186 return getDisplayer()->BuildPrs( aResult );