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
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"
34 #include "DlgRef_SpinBox.h"
36 #include "SalomeApp_Tools.h"
37 #include "utilities.h"
38 #include "SUIT_Session.h"
40 #include <TColStd_MapOfInteger.hxx>
42 #include <qlineedit.h>
45 #include <qpushbutton.h>
46 #include <qradiobutton.h>
47 #include <qbuttongroup.h>
49 //=================================================================================
50 // class : MeasureGUI_PropertiesDlg()
51 // purpose : Constructs a MeasureGUI_PropertiesDlg which is a child of 'parent', with the
52 // name 'name' and widget flags set to 'f'.
53 // The dialog will by default be modeless, unless you set 'modal' to
54 // TRUE to construct a modal dialog.
55 //=================================================================================
56 MeasureGUI_PropertiesDlg::MeasureGUI_PropertiesDlg( GeometryGUI* GUI, QWidget* parent )
57 : MeasureGUI_Skeleton( GUI, parent, "MeasureGUI_PropertiesDlg" )
59 QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap(
60 "GEOM",tr( "ICON_DLG_BASICPROPERTIES" ) ) );
61 QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap(
62 "GEOM",tr( "ICON_SELECT" ) ) );
64 setCaption( tr( "GEOM_PROPERTIES_TITLE" ) );
66 /***************************************************************/
68 GroupConstructors->setTitle( tr( "GEOM_PROPERTIES" ) );
69 RadioButton1->setPixmap( image0 );
71 myGrp = new MeasureGUI_1Sel3LineEdit_QTD( this, "myGrp" );
72 myGrp->GroupBox1->setTitle( tr( "GEOM_PROPERTIES_CONSTR" ) );
73 myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
74 myGrp->TextLabel2->setText( tr( "GEOM_LENGTH" ) );
75 myGrp->TextLabel3->setText( tr( "GEOM_PROPERTIES_SURFACE" ) );
76 myGrp->TextLabel4->setText( tr( "GEOM_PROPERTIES_VOLUME" ) );
77 myGrp->LineEdit2->setReadOnly( TRUE );
78 myGrp->LineEdit3->setReadOnly( TRUE );
79 myGrp->LineEdit4->setReadOnly( TRUE );
80 myGrp->PushButton1->setPixmap( image1 );
81 myGrp->LineEdit1->setReadOnly( true );
83 Layout1->addWidget( myGrp, 1, 0 );
85 /***************************************************************/
87 myHelpFileName = "using_measurement_tools_page.html#basic_prop_anchor";
94 //=================================================================================
95 // function : ~MeasureGUI_PropertiesDlg()
96 // purpose : Destroys the object and frees any allocated resources
97 //=================================================================================
98 MeasureGUI_PropertiesDlg::~MeasureGUI_PropertiesDlg()
103 //=================================================================================
106 //=================================================================================
107 void MeasureGUI_PropertiesDlg::Init()
109 mySelBtn = myGrp->PushButton1;
110 mySelEdit = myGrp->LineEdit1;
111 MeasureGUI_Skeleton::Init();
114 //=================================================================================
115 // function : activateSelection
117 //=================================================================================
118 void MeasureGUI_PropertiesDlg::activateSelection()
120 static TColStd_MapOfInteger aTypes;
121 if ( aTypes.IsEmpty() )
123 aTypes.Add( GEOM_COMPOUND );
124 // aTypes.Add( TopAbs_COMPSOLID );
125 aTypes.Add( GEOM_SOLID );
126 aTypes.Add( GEOM_SHELL );
127 aTypes.Add( GEOM_FACE );
128 aTypes.Add( GEOM_WIRE );
129 aTypes.Add( GEOM_EDGE );
132 globalSelection( aTypes );
135 //=================================================================================
136 // function : processObject
138 //=================================================================================
139 void MeasureGUI_PropertiesDlg::processObject()
141 double aLength, anArea, aVolume;
143 if ( !getParameters( aLength, anArea, aVolume ) )
145 mySelEdit->setText( "" );
146 myGrp->LineEdit2->setText( "" );
147 myGrp->LineEdit3->setText( "" );
148 myGrp->LineEdit4->setText( "" );
152 myGrp->LineEdit2->setText( DlgRef_SpinBox::PrintDoubleValue( aLength ) );
153 myGrp->LineEdit3->setText( DlgRef_SpinBox::PrintDoubleValue( anArea ) );
154 myGrp->LineEdit4->setText( DlgRef_SpinBox::PrintDoubleValue( aVolume ) );
158 //=================================================================================
159 // function : getParameters
161 //=================================================================================
162 bool MeasureGUI_PropertiesDlg::getParameters( double& theLength,
166 if ( myObj->_is_nil() )
172 GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->GetBasicProperties(
173 myObj, theLength, theArea, theVolume );
175 catch( const SALOME::SALOME_Exception& e )
177 SalomeApp_Tools::QtCatchCorbaException( e );
181 return getOperation()->IsDone();
185 //=================================================================================
186 // function : createOperation
188 //=================================================================================
189 SALOME_Prs* MeasureGUI_PropertiesDlg::buildPrs()
191 TopoDS_Shape aShape, aResult;
193 if ( myObj->_is_nil() ||
194 !GEOMBase::GetShape( myObj, aShape )||
196 aShape.ShapeType() != TopAbs_EDGE ||
197 !GEOMBase::CreateArrowForLinearEdge( aShape, aResult ) ||
201 return getDisplayer()->BuildPrs( aResult );