1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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 // GEOM GEOMGUI : GUI for Geometry component
23 // File : MeasureGUI_PropertiesDlg.cxx
24 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
26 #include "MeasureGUI_PropertiesDlg.h"
27 #include "MeasureGUI_Widgets.h"
29 #include <GEOMImpl_Types.hxx>
33 #include <SalomeApp_Tools.h>
34 #include <SUIT_Session.h>
35 #include <SUIT_ResourceMgr.h>
37 #include <TColStd_MapOfInteger.hxx>
39 //=================================================================================
40 // class : MeasureGUI_PropertiesDlg()
41 // purpose : Constructs a MeasureGUI_PropertiesDlg which is a child of 'parent', with the
42 // name 'name' and widget flags set to 'f'.
43 // The dialog will by default be modeless, unless you set 'modal' to
44 // true to construct a modal dialog.
45 //=================================================================================
46 MeasureGUI_PropertiesDlg::MeasureGUI_PropertiesDlg( GeometryGUI* GUI, QWidget* parent )
47 : MeasureGUI_Skeleton( GUI, parent )
49 QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap(
50 "GEOM", tr( "ICON_DLG_BASICPROPERTIES" ) ) );
51 QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap(
52 "GEOM", tr( "ICON_SELECT" ) ) );
54 setWindowTitle( tr( "GEOM_PROPERTIES_TITLE" ) );
56 /***************************************************************/
58 mainFrame()->GroupConstructors->setTitle( tr( "GEOM_PROPERTIES" ) );
59 mainFrame()->RadioButton1->setIcon( image0 );
61 myGrp = new MeasureGUI_1Sel3LineEdit( centralWidget() );
62 myGrp->GroupBox1->setTitle( tr( "GEOM_PROPERTIES_CONSTR" ) );
63 myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
64 myGrp->TextLabel2->setText( tr( "GEOM_LENGTH" ) );
65 myGrp->TextLabel3->setText( tr( "GEOM_PROPERTIES_SURFACE" ) );
66 myGrp->TextLabel4->setText( tr( "GEOM_PROPERTIES_VOLUME" ) );
67 myGrp->LineEdit1->setReadOnly( true );
68 myGrp->PushButton1->setIcon( image1 );
69 myGrp->LineEdit2->setReadOnly( true );
70 myGrp->LineEdit3->setReadOnly( true );
71 myGrp->LineEdit4->setReadOnly( true );
73 QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
74 layout->setMargin( 0 ); layout->setSpacing( 6 );
75 layout->addWidget( myGrp );
77 /***************************************************************/
79 myHelpFileName = "using_measurement_tools_page.html#basic_prop_anchor";
86 //=================================================================================
87 // function : ~MeasureGUI_PropertiesDlg()
88 // purpose : Destroys the object and frees any allocated resources
89 //=================================================================================
90 MeasureGUI_PropertiesDlg::~MeasureGUI_PropertiesDlg()
95 //=================================================================================
98 //=================================================================================
99 void MeasureGUI_PropertiesDlg::Init()
101 mySelBtn = myGrp->PushButton1;
102 mySelEdit = myGrp->LineEdit1;
103 MeasureGUI_Skeleton::Init();
106 //=================================================================================
107 // function : activateSelection
109 //=================================================================================
110 void MeasureGUI_PropertiesDlg::activateSelection()
112 static TColStd_MapOfInteger aTypes;
113 if ( aTypes.IsEmpty() ) {
114 aTypes.Add( GEOM_COMPOUND );
115 // aTypes.Add( TopAbs_COMPSOLID );
116 aTypes.Add( GEOM_SOLID );
117 aTypes.Add( GEOM_SHELL );
118 aTypes.Add( GEOM_FACE );
119 aTypes.Add( GEOM_WIRE );
120 aTypes.Add( GEOM_EDGE );
123 globalSelection( aTypes );
126 //=================================================================================
127 // function : processObject
129 //=================================================================================
130 void MeasureGUI_PropertiesDlg::processObject()
132 double aLength, anArea, aVolume;
134 if ( !getParameters( aLength, anArea, aVolume ) ) {
135 mySelEdit->setText( "" );
136 myGrp->LineEdit2->setText( "" );
137 myGrp->LineEdit3->setText( "" );
138 myGrp->LineEdit4->setText( "" );
141 myGrp->LineEdit2->setText( DlgRef::PrintDoubleValue( aLength ) );
142 myGrp->LineEdit3->setText( DlgRef::PrintDoubleValue( anArea ) );
143 myGrp->LineEdit4->setText( DlgRef::PrintDoubleValue( aVolume ) );
147 //=================================================================================
148 // function : getParameters
150 //=================================================================================
151 bool MeasureGUI_PropertiesDlg::getParameters( double& theLength,
155 if ( myObj->_is_nil() )
159 GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->GetBasicProperties(
160 myObj, theLength, theArea, theVolume );
162 catch( const SALOME::SALOME_Exception& e ) {
163 SalomeApp_Tools::QtCatchCorbaException( e );
167 return getOperation()->IsDone();
171 //=================================================================================
172 // function : createOperation
174 //=================================================================================
175 SALOME_Prs* MeasureGUI_PropertiesDlg::buildPrs()
177 TopoDS_Shape aShape, aResult;
179 if ( myObj->_is_nil() ||
180 !GEOMBase::GetShape( myObj, aShape ) ||
182 aShape.ShapeType() != TopAbs_EDGE ||
183 !GEOMBase::CreateArrowForLinearEdge( aShape, aResult ) ||
187 return getDisplayer()->BuildPrs( aResult );