1 // Copyright (C) 2007-2011 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
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File : MeasureGUI_PropertiesDlg.cxx
25 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
27 #include "MeasureGUI_PropertiesDlg.h"
28 #include "MeasureGUI_Widgets.h"
30 #include <GEOMImpl_Types.hxx>
34 #include <SalomeApp_Tools.h>
35 #include <SUIT_Session.h>
36 #include <SUIT_ResourceMgr.h>
38 #include <TColStd_MapOfInteger.hxx>
40 //=================================================================================
41 // class : MeasureGUI_PropertiesDlg()
42 // purpose : Constructs a MeasureGUI_PropertiesDlg which is a child of 'parent', with the
43 // name 'name' and widget flags set to 'f'.
44 // The dialog will by default be modeless, unless you set 'modal' to
45 // true to construct a modal dialog.
46 //=================================================================================
47 MeasureGUI_PropertiesDlg::MeasureGUI_PropertiesDlg( GeometryGUI* GUI, QWidget* parent )
48 : MeasureGUI_Skeleton( GUI, parent )
50 QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap(
51 "GEOM", tr( "ICON_DLG_BASICPROPERTIES" ) ) );
52 QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap(
53 "GEOM", tr( "ICON_SELECT" ) ) );
55 setWindowTitle( tr( "GEOM_PROPERTIES_TITLE" ) );
57 /***************************************************************/
59 mainFrame()->GroupConstructors->setTitle( tr( "GEOM_PROPERTIES" ) );
60 mainFrame()->RadioButton1->setIcon( image0 );
62 myGrp = new MeasureGUI_1Sel3LineEdit( centralWidget() );
63 myGrp->GroupBox1->setTitle( tr( "GEOM_PROPERTIES_CONSTR" ) );
64 myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
65 myGrp->TextLabel2->setText( tr( "GEOM_LENGTH" ) );
66 myGrp->TextLabel3->setText( tr( "GEOM_PROPERTIES_SURFACE" ) );
67 myGrp->TextLabel4->setText( tr( "GEOM_PROPERTIES_VOLUME" ) );
68 myGrp->LineEdit1->setReadOnly( true );
69 myGrp->PushButton1->setIcon( image1 );
70 myGrp->LineEdit2->setReadOnly( true );
71 myGrp->LineEdit3->setReadOnly( true );
72 myGrp->LineEdit4->setReadOnly( true );
74 QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
75 layout->setMargin( 0 ); layout->setSpacing( 6 );
76 layout->addWidget( myGrp );
78 /***************************************************************/
80 myHelpFileName = "using_measurement_tools_page.html#basic_prop_anchor";
87 //=================================================================================
88 // function : ~MeasureGUI_PropertiesDlg()
89 // purpose : Destroys the object and frees any allocated resources
90 //=================================================================================
91 MeasureGUI_PropertiesDlg::~MeasureGUI_PropertiesDlg()
96 //=================================================================================
99 //=================================================================================
100 void MeasureGUI_PropertiesDlg::Init()
102 mySelBtn = myGrp->PushButton1;
103 mySelEdit = myGrp->LineEdit1;
104 MeasureGUI_Skeleton::Init();
107 //=================================================================================
108 // function : activateSelection
110 //=================================================================================
111 void MeasureGUI_PropertiesDlg::activateSelection()
113 static TColStd_MapOfInteger aTypes;
114 if ( aTypes.IsEmpty() ) {
115 aTypes.Add( GEOM_COMPOUND );
116 // aTypes.Add( TopAbs_COMPSOLID );
117 aTypes.Add( GEOM_SOLID );
118 aTypes.Add( GEOM_SHELL );
119 aTypes.Add( GEOM_FACE );
120 aTypes.Add( GEOM_WIRE );
121 aTypes.Add( GEOM_EDGE );
124 globalSelection( aTypes );
127 //=================================================================================
128 // function : processObject
130 //=================================================================================
131 void MeasureGUI_PropertiesDlg::processObject()
133 double aLength, anArea, aVolume;
135 if ( !getParameters( aLength, anArea, aVolume ) ) {
136 mySelEdit->setText( "" );
137 myGrp->LineEdit2->setText( "" );
138 myGrp->LineEdit3->setText( "" );
139 myGrp->LineEdit4->setText( "" );
142 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
143 int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
144 myGrp->LineEdit2->setText( DlgRef::PrintDoubleValue( aLength, aPrecision ) );
145 myGrp->LineEdit3->setText( DlgRef::PrintDoubleValue( anArea, aPrecision ) );
146 myGrp->LineEdit4->setText( DlgRef::PrintDoubleValue( aVolume, aPrecision ) );
150 //=================================================================================
151 // function : getParameters
153 //=================================================================================
154 bool MeasureGUI_PropertiesDlg::getParameters( double& theLength,
158 if ( myObj->_is_nil() )
161 GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() );
163 anOper->GetBasicProperties( myObj, theLength, theArea, theVolume );
165 catch( const SALOME::SALOME_Exception& e ) {
166 SalomeApp_Tools::QtCatchCorbaException( e );
170 return anOper->IsDone();
174 //=================================================================================
175 // function : createOperation
177 //=================================================================================
178 SALOME_Prs* MeasureGUI_PropertiesDlg::buildPrs()
183 if ( GEOMBase::GetShape( myObj, shape, TopAbs_EDGE ) ) {
184 shape = GEOMBase::CreateArrowForLinearEdge( shape );
185 if ( !shape.IsNull() )
186 prs = getDisplayer()->BuildPrs( shape );