X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMeasureGUI%2FMeasureGUI_MaxToleranceDlg.cxx;h=87d8d44d1df5bed457d18a826ce88cd254c4b947;hb=5b3622aa2363853841fd5b4205c78a715bfee4a4;hp=93f2da25f1ab34a4d54581cbf2e8da1f08e43ad0;hpb=c577ca78d7a6e286526662cf54df6de1f4f2f449;p=modules%2Fgeom.git diff --git a/src/MeasureGUI/MeasureGUI_MaxToleranceDlg.cxx b/src/MeasureGUI/MeasureGUI_MaxToleranceDlg.cxx index 93f2da25f..87d8d44d1 100644 --- a/src/MeasureGUI/MeasureGUI_MaxToleranceDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_MaxToleranceDlg.cxx @@ -1,78 +1,84 @@ -// GEOM GEOMGUI : GUI for Geometry component +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// File : MeasureGUI_MaxToleranceDlg.cxx -// Author : Nicolas REJNERI -// Module : GEOM -// $Header$ -using namespace std; +// GEOM GEOMGUI : GUI for Geometry component +// File : MeasureGUI_MaxToleranceDlg.cxx +// Author : Nicolas REJNERI, Open CASCADE S.A.S. +// #include "MeasureGUI_MaxToleranceDlg.h" +#include "MeasureGUI_Widgets.h" +#include "DlgRef.h" -#include -#include -#include -#include -#include +#include +#include +#include //================================================================================= // class : MeasureGUI_MaxToleranceDlg() -// purpose : Constructs a MeasureGUI_MaxToleranceDlg which is a child of 'parent', with the +// purpose : Constructs a MeasureGUI_MaxToleranceDlg which is a child of 'parent', with the // name 'name' and widget flags set to 'f'. // The dialog will by default be modeless, unless you set 'modal' to -// TRUE to construct a modal dialog. +// true to construct a modal dialog. //================================================================================= -MeasureGUI_MaxToleranceDlg::MeasureGUI_MaxToleranceDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl) - :MeasureGUI_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +MeasureGUI_MaxToleranceDlg::MeasureGUI_MaxToleranceDlg( GeometryGUI* GUI, QWidget* parent ) + : MeasureGUI_Skeleton( GUI, parent ) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_TOLERANCE"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( + "GEOM", tr( "ICON_DLG_TOLERANCE" ) ) ); + QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( + "GEOM", tr( "ICON_SELECT" ) ) ); - setCaption(tr("GEOM_TOLERANCE_TITLE")); + setWindowTitle( tr( "GEOM_TOLERANCE_TITLE" ) ); /***************************************************************/ - GroupConstructors->setTitle(tr("GEOM_TOLERANCE")); - RadioButton1->setPixmap(image0); - - GroupC1 = new MeasureGUI_1Sel6LineEdit_QTD(this, "GroupC1"); - GroupC1->GroupBox1->setTitle(tr("GEOM_TOLERANCE_CONSTR")); - GroupC1->TextLabel1->setText(tr("GEOM_OBJECT")); - GroupC1->TextLabel2->setText(tr("GEOM_MIN")); - GroupC1->TextLabel3->setText(tr("GEOM_MAX")); - GroupC1->TextLabel4->setText(tr("GEOM_TOLERANCE_FACE")); - GroupC1->TextLabel5->setText(tr("GEOM_TOLERANCE_EDGE")); - GroupC1->TextLabel6->setText(tr("GEOM_TOLERANCE_VERTEX")); - GroupC1->LineEdit11->setReadOnly(TRUE); - GroupC1->LineEdit12->setReadOnly(TRUE); - GroupC1->LineEdit21->setReadOnly(TRUE); - GroupC1->LineEdit22->setReadOnly(TRUE); - GroupC1->LineEdit31->setReadOnly(TRUE); - GroupC1->LineEdit32->setReadOnly(TRUE); - GroupC1->PushButton1->setPixmap(image1); - - Layout1->addWidget(GroupC1, 1, 0); + + mainFrame()->GroupConstructors->setTitle( tr( "GEOM_TOLERANCE" ) ); + mainFrame()->RadioButton1->setIcon( image0 ); + + myGrp = new MeasureGUI_1Sel6LineEdit( centralWidget() ); + myGrp->GroupBox1->setTitle( tr( "GEOM_TOLERANCE_CONSTR" ) ); + myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) ); + myGrp->TextLabel2->setText( tr( "GEOM_MIN" ) ); + myGrp->TextLabel3->setText( tr( "GEOM_MAX" ) ); + myGrp->TextLabel4->setText( tr( "GEOM_TOLERANCE_FACE" ) ); + myGrp->TextLabel5->setText( tr( "GEOM_TOLERANCE_EDGE" ) ); + myGrp->TextLabel6->setText( tr( "GEOM_TOLERANCE_VERTEX" ) ); + myGrp->LineEdit11->setReadOnly( true ); + myGrp->LineEdit12->setReadOnly( true ); + myGrp->LineEdit21->setReadOnly( true ); + myGrp->LineEdit22->setReadOnly( true ); + myGrp->LineEdit31->setReadOnly( true ); + myGrp->LineEdit32->setReadOnly( true ); + myGrp->PushButton1->setIcon( image1 ); + myGrp->LineEdit1->setReadOnly( true ); + + QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); + layout->setMargin( 0 ); layout->setSpacing( 6 ); + layout->addWidget( myGrp ); + /***************************************************************/ + myHelpFileName = "using_measurement_tools_page.html#tolerance_anchor"; + /* Initialisation */ Init(); } @@ -84,7 +90,6 @@ MeasureGUI_MaxToleranceDlg::MeasureGUI_MaxToleranceDlg(QWidget* parent, const ch //================================================================================= MeasureGUI_MaxToleranceDlg::~MeasureGUI_MaxToleranceDlg() { - // no need to delete child widgets, Qt does it all for us } @@ -94,191 +99,79 @@ MeasureGUI_MaxToleranceDlg::~MeasureGUI_MaxToleranceDlg() //================================================================================= void MeasureGUI_MaxToleranceDlg::Init() { - /* init variables */ - myEditCurrentArgument = GroupC1->LineEdit1; - - /* signals and slots connections */ - connect(GroupC1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupC1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - /* displays Dialog */ - GroupC1->show(); - this->show(); - - return; + mySelBtn = myGrp->PushButton1; + mySelEdit = myGrp->LineEdit1; + MeasureGUI_Skeleton::Init(); } - //================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection as changed or other case -//================================================================================= -void MeasureGUI_MaxToleranceDlg::SelectionIntoArgument() -{ - myEditCurrentArgument->setText(""); - QString aString = ""; - - GroupC1->LineEdit11->setText(""); - GroupC1->LineEdit12->setText(""); - GroupC1->LineEdit21->setText(""); - GroupC1->LineEdit22->setText(""); - GroupC1->LineEdit31->setText(""); - GroupC1->LineEdit32->setText(""); - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) - return; - - /* nbSel == 1 */ - TopoDS_Shape S; - if(!myGeomBase->GetTopoFromSelection(mySelection, S) || S.IsNull()) - return; - - if(S.IsNull()) - return; - - GroupC1->LineEdit1->setText(aString); - - this->CalculateMaxTolerance(S); - return; -} - - -//================================================================================= -// function : SetEditCurrentArgument() +// function : processObject // purpose : //================================================================================= -void MeasureGUI_MaxToleranceDlg::SetEditCurrentArgument() +void MeasureGUI_MaxToleranceDlg::processObject() { - QPushButton* send = (QPushButton*)sender(); - - if(send == GroupC1->PushButton1) { - GroupC1->LineEdit1->setFocus(); - myEditCurrentArgument = GroupC1->LineEdit1; - } - - this->SelectionIntoArgument(); - return; -} + double aMinFaceToler, aMaxFaceToler; + double aMinEdgeToler, aMaxEdgeToler; + double aMinVertexToler, aMaxVertexToler; + + if ( !getParameters( aMinFaceToler, aMaxFaceToler, + aMinEdgeToler, aMaxEdgeToler, + aMinVertexToler, aMaxVertexToler ) ) { + myGrp->LineEdit11->setText( "" ); + myGrp->LineEdit12->setText( "" ); + + myGrp->LineEdit21->setText( "" ); + myGrp->LineEdit22->setText( "" ); + + myGrp->LineEdit31->setText( "" ); + myGrp->LineEdit32->setText( "" ); - -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void MeasureGUI_MaxToleranceDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupC1->LineEdit1) - myEditCurrentArgument = GroupC1->LineEdit1; - else return; + } - MeasureGUI_Skeleton::LineEditReturnPressed(); - return; -} + double invalidMin = RealLast(); + double invalidMax = -RealLast(); + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + int aPrecision = resMgr->integerValue( "Geometry", "len_tol_precision", -9); -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void MeasureGUI_MaxToleranceDlg::ActivateThisDialog() -{ - MeasureGUI_Skeleton::ActivateThisDialog(); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - return; -} + myGrp->LineEdit11->setText( aMinFaceToler != invalidMin ? DlgRef::PrintDoubleValue( aMinFaceToler, aPrecision ) : QString("") ); + myGrp->LineEdit12->setText( aMaxFaceToler != invalidMax ? DlgRef::PrintDoubleValue( aMaxFaceToler, aPrecision ) : QString("") ); + myGrp->LineEdit21->setText( aMinEdgeToler != invalidMin ? DlgRef::PrintDoubleValue( aMinEdgeToler, aPrecision ) : QString("") ); + myGrp->LineEdit22->setText( aMaxEdgeToler != invalidMax ? DlgRef::PrintDoubleValue( aMaxEdgeToler, aPrecision ) : QString("") ); -//================================================================================= -// function : enterEvent() -// purpose : -//================================================================================= -void MeasureGUI_MaxToleranceDlg::enterEvent(QEvent* e) -{ - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + myGrp->LineEdit31->setText( aMinVertexToler != invalidMin ? DlgRef::PrintDoubleValue( aMinVertexToler, aPrecision ) : QString("") ); + myGrp->LineEdit32->setText( aMaxVertexToler != invalidMax ? DlgRef::PrintDoubleValue( aMaxVertexToler, aPrecision ) : QString("") ); } - //================================================================================= -// function : CalculateMaxTolerance() -// purpose : +// function : getParameters +// purpose : Get tolerances. Returns false is myObj is nill. If there is no a +// type of entity ( face, edge or vertex ) in selected object then corresponding +// tolerances is less than 0 //================================================================================= -void MeasureGUI_MaxToleranceDlg::CalculateMaxTolerance(const TopoDS_Shape& S) +bool MeasureGUI_MaxToleranceDlg::getParameters( double& theMinFaceToler, + double& theMaxFaceToler, + double& theMinEdgeToler, + double& theMaxEdgeToler, + double& theMinVertexToler, + double& theMaxVertexToler ) { - GroupC1->LineEdit11->setText(""); - GroupC1->LineEdit12->setText(""); - GroupC1->LineEdit21->setText(""); - GroupC1->LineEdit22->setText(""); - GroupC1->LineEdit31->setText(""); - GroupC1->LineEdit32->setText(""); - - if(S.IsNull()) - return; - - Standard_Real T, TMF, TME, TMV, TmF, TmE, TmV; - Standard_Integer nbF, nbE, nbV; - bool m_isFace, m_isEdge, m_isVertex; - - TMF = TME = TMV = -RealLast(); - TmF = TmE = TmV = RealLast(); - nbF = nbE = nbV = 0; - m_isFace = m_isEdge = m_isVertex = false; - - try { - for(TopExp_Explorer ExF(S,TopAbs_FACE); ExF.More(); ExF.Next()) { - m_isFace = true; - TopoDS_Face Face=TopoDS::Face(ExF.Current()); - T=BRep_Tool::Tolerance(Face); - if(T>TMF) - TMF=T; - if(TTME) - TME=T; - if(T_is_nil() ) + return false; + else { + GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() ); + try { + anOper->GetTolerance( myObj, + theMinFaceToler, theMaxFaceToler, theMinEdgeToler, + theMaxEdgeToler, theMinVertexToler, theMaxVertexToler ); } - for(TopExp_Explorer ExV(S,TopAbs_VERTEX); ExV.More(); ExV.Next()) { - m_isVertex = true; - TopoDS_Vertex Vertex=TopoDS::Vertex(ExV.Current()); - T=BRep_Tool::Tolerance(Vertex); - if(T>TMV) - TMV=T; - if(TLineEdit11->setText(tr("%1").arg(TmF, 5, 'e', 8)); - GroupC1->LineEdit12->setText(tr("%1").arg(TMF, 5, 'e', 8)); - } - if(m_isEdge) { - GroupC1->LineEdit21->setText(tr("%1").arg(TmE, 5, 'e', 8)); - GroupC1->LineEdit22->setText(tr("%1").arg(TME, 5, 'e', 8)); - } - if(m_isVertex) { - GroupC1->LineEdit31->setText(tr("%1").arg(TmV, 5, 'e', 8)); - GroupC1->LineEdit32->setText(tr("%1").arg(TMV, 5, 'e', 8)); - } + return anOper->IsDone(); } - catch(Standard_Failure) - { - MESSAGE("Catch intercepted in CalculateMaxTolerance()"); - } - return; }