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 "SALOMEGUI_QtCatchCorbaException.hxx"
32 #include "GEOM_Displayer.h"
33 #include "utilities.h"
34 #include "QAD_Desktop.h"
35 #include "GEOMImpl_Types.hxx"
38 #include <TColStd_MapOfInteger.hxx>
40 #include <qlineedit.h>
42 #include <qpushbutton.h>
43 #include <qradiobutton.h>
44 #include <qbuttongroup.h>
46 //=================================================================================
47 // class : MeasureGUI_PropertiesDlg()
48 // purpose : Constructs a MeasureGUI_PropertiesDlg which is a child of 'parent', with the
49 // name 'name' and widget flags set to 'f'.
50 // The dialog will by default be modeless, unless you set 'modal' to
51 // TRUE to construct a modal dialog.
52 //=================================================================================
53 MeasureGUI_PropertiesDlg::MeasureGUI_PropertiesDlg( QWidget* parent, SALOME_Selection* Sel )
54 : MeasureGUI_Skeleton( parent, "MeasureGUI_PropertiesDlg", Sel )
56 QPixmap image0( QAD_Desktop::getResourceManager()->loadPixmap(
57 "GEOM",tr( "ICON_DLG_BASICPROPERTIES" ) ) );
58 QPixmap image1( QAD_Desktop::getResourceManager()->loadPixmap(
59 "GEOM",tr( "ICON_SELECT" ) ) );
61 setCaption( tr( "GEOM_PROPERTIES_TITLE" ) );
63 /***************************************************************/
65 GroupConstructors->setTitle( tr( "GEOM_PROPERTIES" ) );
66 RadioButton1->setPixmap( image0 );
68 myGrp = new MeasureGUI_1Sel3LineEdit_QTD( this, "myGrp" );
69 myGrp->GroupBox1->setTitle( tr( "GEOM_PROPERTIES_CONSTR" ) );
70 myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
71 myGrp->TextLabel2->setText( tr( "GEOM_LENGTH" ) );
72 myGrp->TextLabel3->setText( tr( "GEOM_PROPERTIES_SURFACE" ) );
73 myGrp->TextLabel4->setText( tr( "GEOM_PROPERTIES_VOLUME" ) );
74 myGrp->LineEdit2->setReadOnly( TRUE );
75 myGrp->LineEdit3->setReadOnly( TRUE );
76 myGrp->LineEdit4->setReadOnly( TRUE );
77 myGrp->PushButton1->setPixmap( image1 );
78 myGrp->LineEdit1->setReadOnly( true );
80 Layout1->addWidget( myGrp, 1, 0 );
82 /***************************************************************/
89 //=================================================================================
90 // function : ~MeasureGUI_PropertiesDlg()
91 // purpose : Destroys the object and frees any allocated resources
92 //=================================================================================
93 MeasureGUI_PropertiesDlg::~MeasureGUI_PropertiesDlg()
98 //=================================================================================
101 //=================================================================================
102 void MeasureGUI_PropertiesDlg::Init( SALOME_Selection* Sel )
104 mySelBtn = myGrp->PushButton1;
105 mySelEdit = myGrp->LineEdit1;
106 MeasureGUI_Skeleton::Init( Sel );
109 //=================================================================================
110 // function : activateSelection
112 //=================================================================================
113 void MeasureGUI_PropertiesDlg::activateSelection()
115 static TColStd_MapOfInteger aTypes;
116 if ( aTypes.IsEmpty() )
118 aTypes.Add( GEOM_COMPOUND );
119 // aTypes.Add( TopAbs_COMPSOLID );
120 aTypes.Add( GEOM_SOLID );
121 aTypes.Add( GEOM_SHELL );
122 aTypes.Add( GEOM_FACE );
123 aTypes.Add( GEOM_WIRE );
124 aTypes.Add( GEOM_EDGE );
127 globalSelection( aTypes );
130 //=================================================================================
131 // function : processObject
133 //=================================================================================
134 void MeasureGUI_PropertiesDlg::processObject()
136 double aLength, anArea, aVolume;
138 if ( !getParameters( aLength, anArea, aVolume ) )
140 mySelEdit->setText( "" );
141 myGrp->LineEdit2->setText( "" );
142 myGrp->LineEdit3->setText( "" );
143 myGrp->LineEdit4->setText( "" );
147 myGrp->LineEdit2->setText( QString( "%1" ).arg( aLength ) );
148 myGrp->LineEdit3->setText( QString( "%1" ).arg( anArea ) );
149 myGrp->LineEdit4->setText( QString( "%1" ).arg( aVolume ) );
153 //=================================================================================
154 // function : getParameters
156 //=================================================================================
157 bool MeasureGUI_PropertiesDlg::getParameters( double& theLength,
161 if ( myObj->_is_nil() )
167 GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->GetBasicProperties(
168 myObj, theLength, theArea, theVolume );
170 catch( const SALOME::SALOME_Exception& e )
172 QtCatchCorbaException( e );
176 return getOperation()->IsDone();
180 //=================================================================================
181 // function : createOperation
183 //=================================================================================
184 SALOME_Prs* MeasureGUI_PropertiesDlg::buildPrs()
186 TopoDS_Shape aShape, aResult;
188 if ( myObj->_is_nil() ||
189 !GEOMBase::GetShape( myObj, aShape )||
191 aShape.ShapeType() != TopAbs_EDGE ||
192 !GEOMBase::CreateArrowForLinearEdge( aShape, aResult ) ||
196 return getDisplayer()->BuildPrs( aResult );