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
29 #include "MeasureGUI_CheckShapeDlg.h"
31 #include <BRepCheck_Analyzer.hxx>
33 #include <qtextedit.h>
35 #include "utilities.h"
39 //=================================================================================
40 // class : MeasureGUI_CheckShapeDlg()
41 // purpose : Constructs a MeasureGUI_CheckShapeDlg which is a child of 'parent', with the
42 // name 'name' and widget flags set to 'f'.
43 // The dialog will by default be modeless, unless you set 'modal' to
44 // TRUE to construct a modal dialog.
45 //=================================================================================
46 MeasureGUI_CheckShapeDlg::MeasureGUI_CheckShapeDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl)
47 :MeasureGUI_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
49 QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_CHECKSHAPE")));
50 QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")));
52 setCaption(tr("GEOM_CHECK_TITLE"));
54 /***************************************************************/
55 GroupConstructors->setTitle(tr("GEOM_CHECK_SHAPE"));
56 RadioButton1->setPixmap(image0);
58 GroupC1 = new MeasureGUI_1Sel1TextView_QTD(this, "GroupC1");
59 GroupC1->GroupBox1->setTitle(tr("GEOM_CHECK_INFOS"));
60 GroupC1->TextLabel1->setText(tr("GEOM_OBJECT"));
61 GroupC1->TextEdit1->setReadOnly(TRUE);
62 GroupC1->PushButton1->setPixmap(image1);
64 Layout1->addWidget(GroupC1, 1, 0);
65 /***************************************************************/
72 //=================================================================================
73 // function : ~MeasureGUI_CheckShapeDlg()
74 // purpose : Destroys the object and frees any allocated resources
75 //=================================================================================
76 MeasureGUI_CheckShapeDlg::~MeasureGUI_CheckShapeDlg()
78 // no need to delete child widgets, Qt does it all for us
82 //=================================================================================
85 //=================================================================================
86 void MeasureGUI_CheckShapeDlg::Init()
89 myEditCurrentArgument = GroupC1->LineEdit1;
91 /* signals and slots connections */
92 connect(GroupC1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
93 connect(GroupC1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
95 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
105 //=================================================================================
106 // function : SelectionIntoArgument()
107 // purpose : Called when selection as changed or other case
108 //=================================================================================
109 void MeasureGUI_CheckShapeDlg::SelectionIntoArgument()
111 myEditCurrentArgument->setText("");
112 SelectedName = ""; /* future the name of selection */
113 GroupC1->TextEdit1->setText("");
115 int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, SelectedName);
121 if(!myGeomBase->GetTopoFromSelection(mySelection, S))
127 myEditCurrentArgument->setText(SelectedName);
134 //=================================================================================
135 // function : SetEditCurrentArgument()
137 //=================================================================================
138 void MeasureGUI_CheckShapeDlg::SetEditCurrentArgument()
140 QPushButton* send = (QPushButton*)sender();
142 if(send == GroupC1->PushButton1) {
143 GroupC1->LineEdit1->setFocus();
144 myEditCurrentArgument = GroupC1->LineEdit1;
147 this->SelectionIntoArgument();
152 //=================================================================================
153 // function : LineEditReturnPressed()
155 //=================================================================================
156 void MeasureGUI_CheckShapeDlg::LineEditReturnPressed()
158 QLineEdit* send = (QLineEdit*)sender();
159 if(send == GroupC1->LineEdit1)
160 myEditCurrentArgument = GroupC1->LineEdit1;
164 MeasureGUI_Skeleton::LineEditReturnPressed();
169 //=================================================================================
170 // function : ActivateThisDialog()
172 //=================================================================================
173 void MeasureGUI_CheckShapeDlg::ActivateThisDialog()
175 MeasureGUI_Skeleton::ActivateThisDialog();
176 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
181 //=================================================================================
182 // function : enterEvent()
184 //=================================================================================
185 void MeasureGUI_CheckShapeDlg::enterEvent(QEvent* e)
187 if(GroupConstructors->isEnabled())
189 this->ActivateThisDialog();
194 //=================================================================================
195 // function : Check()
197 //=================================================================================
198 void MeasureGUI_CheckShapeDlg::Check(const TopoDS_Shape S)
204 BRepCheck_Analyzer ana(S,false);
206 GroupC1->TextEdit1->setText("This Shape seems to be valid.");
208 GroupC1->TextEdit1->setText("This Shape is not valid.");
210 catch(Standard_Failure) {
211 MESSAGE("Catch intercepted in Check()");