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_CheckShapeDlg.cxx
25 // Author : Nicolas REJNERI
30 #include "MeasureGUI_CheckShapeDlg.h"
32 #include <BRepCheck_Analyzer.hxx>
34 #include <qtextedit.h>
36 //=================================================================================
37 // class : MeasureGUI_CheckShapeDlg()
38 // purpose : Constructs a MeasureGUI_CheckShapeDlg which is a child of 'parent', with the
39 // name 'name' and widget flags set to 'f'.
40 // The dialog will by default be modeless, unless you set 'modal' to
41 // TRUE to construct a modal dialog.
42 //=================================================================================
43 MeasureGUI_CheckShapeDlg::MeasureGUI_CheckShapeDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl)
44 :MeasureGUI_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
46 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_CHECKSHAPE")));
47 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")));
49 setCaption(tr("GEOM_CHECK_TITLE"));
51 /***************************************************************/
52 GroupConstructors->setTitle(tr("GEOM_CHECK_SHAPE"));
53 RadioButton1->setPixmap(image0);
55 GroupC1 = new MeasureGUI_1Sel1TextView_QTD(this, "GroupC1");
56 GroupC1->GroupBox1->setTitle(tr("GEOM_CHECK_INFOS"));
57 GroupC1->TextLabel1->setText(tr("GEOM_OBJECT"));
58 GroupC1->TextEdit1->setReadOnly(TRUE);
59 GroupC1->PushButton1->setPixmap(image1);
61 Layout1->addWidget(GroupC1, 1, 0);
62 /***************************************************************/
69 //=================================================================================
70 // function : ~MeasureGUI_CheckShapeDlg()
71 // purpose : Destroys the object and frees any allocated resources
72 //=================================================================================
73 MeasureGUI_CheckShapeDlg::~MeasureGUI_CheckShapeDlg()
75 // no need to delete child widgets, Qt does it all for us
79 //=================================================================================
82 //=================================================================================
83 void MeasureGUI_CheckShapeDlg::Init()
86 myEditCurrentArgument = GroupC1->LineEdit1;
88 /* signals and slots connections */
89 connect(GroupC1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
90 connect(GroupC1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
92 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
102 //=================================================================================
103 // function : SelectionIntoArgument()
104 // purpose : Called when selection as changed or other case
105 //=================================================================================
106 void MeasureGUI_CheckShapeDlg::SelectionIntoArgument()
108 myEditCurrentArgument->setText("");
109 SelectedName = ""; /* future the name of selection */
110 GroupC1->TextEdit1->setText("");
112 int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, SelectedName);
118 if(!myGeomBase->GetTopoFromSelection(mySelection, S))
124 myEditCurrentArgument->setText(SelectedName);
131 //=================================================================================
132 // function : SetEditCurrentArgument()
134 //=================================================================================
135 void MeasureGUI_CheckShapeDlg::SetEditCurrentArgument()
137 QPushButton* send = (QPushButton*)sender();
139 if(send == GroupC1->PushButton1) {
140 GroupC1->LineEdit1->setFocus();
141 myEditCurrentArgument = GroupC1->LineEdit1;
144 this->SelectionIntoArgument();
149 //=================================================================================
150 // function : LineEditReturnPressed()
152 //=================================================================================
153 void MeasureGUI_CheckShapeDlg::LineEditReturnPressed()
155 QLineEdit* send = (QLineEdit*)sender();
156 if(send == GroupC1->LineEdit1)
157 myEditCurrentArgument = GroupC1->LineEdit1;
161 MeasureGUI_Skeleton::LineEditReturnPressed();
166 //=================================================================================
167 // function : ActivateThisDialog()
169 //=================================================================================
170 void MeasureGUI_CheckShapeDlg::ActivateThisDialog()
172 MeasureGUI_Skeleton::ActivateThisDialog();
173 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
178 //=================================================================================
179 // function : enterEvent()
181 //=================================================================================
182 void MeasureGUI_CheckShapeDlg::enterEvent(QEvent* e)
184 if(GroupConstructors->isEnabled())
186 this->ActivateThisDialog();
191 //=================================================================================
192 // function : Check()
194 //=================================================================================
195 void MeasureGUI_CheckShapeDlg::Check(const TopoDS_Shape S)
201 BRepCheck_Analyzer ana(S,false);
203 GroupC1->TextEdit1->setText("This Shape seems to be valid.");
205 GroupC1->TextEdit1->setText("This Shape is not valid.");
207 catch(Standard_Failure) {
208 MESSAGE("Catch intercepted in Check()");