1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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
22 // GEOM RepairGUI : GUI for Geometry component
23 // File : RepairGUI_RemoveExtraEdgesDlg.cxx
24 // Author : Michael Zorin
28 #include "RepairGUI_RemoveExtraEdgesDlg.h"
30 #include "SalomeApp_Application.h"
31 #include "LightApp_SelectionMgr.h"
32 #include "SUIT_Session.h"
34 #include "GEOMImpl_Types.hxx"
36 #include <TColStd_MapOfInteger.hxx>
39 #include <qcheckbox.h>
41 //=================================================================================
42 // class : RepairGUI_RemoveExtraEdgesDlg()
43 // purpose : Constructs a RepairGUI_RemoveExtraEdgesDlg which is a child of 'parent', with the
44 // name 'name' and widget flags set to 'f'.
45 // The dialog will by default be modeless, unless you set 'modal' to
46 // TRUE to construct a modal dialog.
47 //=================================================================================
48 RepairGUI_RemoveExtraEdgesDlg::RepairGUI_RemoveExtraEdgesDlg(GeometryGUI* theGeometryGUI, QWidget* parent,
49 const char* name, bool modal, WFlags fl)
50 :GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, WStyle_Customize |
51 WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
53 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
54 QPixmap image0(aResMgr->loadPixmap("GEOM",tr("ICON_DLG_REMOVE_EXTRA_EDGES")));
55 QPixmap image1(aResMgr->loadPixmap("GEOM",tr("ICON_SELECT")));
57 setCaption(tr("GEOM_REMOVE_EXTRA_EDGES_TITLE"));
59 /***************************************************************/
60 GroupConstructors->setTitle(tr("GEOM_REMOVE_EXTRA_EDGES_TITLE"));
61 RadioButton1->setPixmap(image0);
62 RadioButton2->close(TRUE);
63 RadioButton3->close(TRUE);
65 GroupPoints = new DlgRef_1Sel_QTD(this, "GroupPoints");
66 GroupPoints->GroupBox1->setTitle(tr("GEOM_REMOVE_EXTRA_EDGES"));
67 GroupPoints->TextLabel1->setText(tr("GEOM_SELECTED_SHAPE"));
68 GroupPoints->PushButton1->setPixmap(image1);
69 GroupPoints->LineEdit1->setReadOnly( true );
71 Layout1->addWidget(GroupPoints, 2, 0);
72 /***************************************************************/
74 setHelpFileName("remove_extra_edges_operation_page.html");
80 //=================================================================================
81 // function : ~RepairGUI_RemoveExtraEdgesDlg()
82 // purpose : Destroys the object and frees any allocated resources
83 //=================================================================================
84 RepairGUI_RemoveExtraEdgesDlg::~RepairGUI_RemoveExtraEdgesDlg()
89 //=================================================================================
92 //=================================================================================
93 void RepairGUI_RemoveExtraEdgesDlg::Init()
96 myEditCurrentArgument = GroupPoints->LineEdit1;
102 GroupBoxPublish->show();
104 /* signals and slots connections */
105 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
106 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
108 connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
109 connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
111 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
112 this, SLOT(SelectionIntoArgument()));
114 initName( tr( "REMOVE_EXTRA_EDGES_NEW_OBJ_NAME" ) );
118 //=================================================================================
119 // function : ClickOnOk()
120 // purpose : Same than click on apply but close this dialog.
121 //=================================================================================
122 void RepairGUI_RemoveExtraEdgesDlg::ClickOnOk()
124 if ( ClickOnApply() )
128 //=================================================================================
129 // function : ClickOnApply()
131 //=================================================================================
132 bool RepairGUI_RemoveExtraEdgesDlg::ClickOnApply()
139 myEditCurrentArgument->setText("");
140 myObject = GEOM::GEOM_Object::_nil();
150 //=================================================================================
151 // function : SelectionIntoArgument()
152 // purpose : Called when selection as changed or other case
153 // : used only by SelectButtonC1A1 (LineEditC1A1)
154 //=================================================================================
155 void RepairGUI_RemoveExtraEdgesDlg::SelectionIntoArgument()
157 myEditCurrentArgument->setText("");
160 if(myEditCurrentArgument == GroupPoints->LineEdit1) {
161 if (IObjectCount() != 1) {
162 if (myEditCurrentArgument == GroupPoints->LineEdit1)
169 Standard_Boolean testResult = Standard_False;
170 GEOM::GEOM_Object_ptr aSelectedObject =
171 GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult );
176 if (myEditCurrentArgument == GroupPoints->LineEdit1) {
177 myObject = aSelectedObject;
181 myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) );
184 //=================================================================================
185 // function : SetEditCurrentArgument()
187 //=================================================================================
188 void RepairGUI_RemoveExtraEdgesDlg::SetEditCurrentArgument()
190 if( sender() == GroupPoints->PushButton1 )
192 GroupPoints->LineEdit1->setFocus();
193 myEditCurrentArgument = GroupPoints->LineEdit1;
195 SelectionIntoArgument();
199 //=================================================================================
200 // function : LineEditReturnPressed()
202 //=================================================================================
203 void RepairGUI_RemoveExtraEdgesDlg::LineEditReturnPressed()
205 if( sender() == GroupPoints->LineEdit1 )
207 myEditCurrentArgument = GroupPoints->LineEdit1;
208 GEOMBase_Skeleton::LineEditReturnPressed();
213 //=================================================================================
214 // function : ActivateThisDialog()
216 //=================================================================================
217 void RepairGUI_RemoveExtraEdgesDlg::ActivateThisDialog()
219 GEOMBase_Skeleton::ActivateThisDialog();
220 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
221 this, SLOT(SelectionIntoArgument()));
227 //=================================================================================
228 // function : enterEvent()
229 // purpose : Mouse enter onto the dialog to activate it
230 //=================================================================================
231 void RepairGUI_RemoveExtraEdgesDlg::enterEvent(QEvent* e)
233 if ( !GroupConstructors->isEnabled() )
234 ActivateThisDialog();
238 //=================================================================================
239 // function : closeEvent()
241 //=================================================================================
242 void RepairGUI_RemoveExtraEdgesDlg::closeEvent(QCloseEvent* e)
244 GEOMBase_Skeleton::closeEvent( e );
247 //=================================================================================
248 // function : activateSelection
249 // purpose : activate selection of solids and compounds
250 //=================================================================================
251 void RepairGUI_RemoveExtraEdgesDlg::activateSelection()
253 TColStd_MapOfInteger aTypes;
254 aTypes.Add( GEOM_SOLID );
255 aTypes.Add( GEOM_COMPOUND );
256 globalSelection( aTypes );
259 //=================================================================================
260 // function : createOperation
262 //=================================================================================
263 GEOM::GEOM_IOperations_ptr RepairGUI_RemoveExtraEdgesDlg::createOperation()
265 return getGeomEngine()->GetIBlocksOperations( getStudyId() );
268 //=================================================================================
269 // function : isValid
271 //=================================================================================
272 bool RepairGUI_RemoveExtraEdgesDlg::isValid( QString& msg )
277 //=================================================================================
278 // function : execute
280 //=================================================================================
281 bool RepairGUI_RemoveExtraEdgesDlg::execute( ObjectList& objects )
283 GEOM::GEOM_Object_var anObj;
285 anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())->RemoveExtraEdges(myObject);
287 if ( !anObj->_is_nil() )
288 objects.push_back( anObj._retn() );
293 //=================================================================================
294 // function : restoreSubShapes
296 //=================================================================================
297 void RepairGUI_RemoveExtraEdgesDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
298 SALOMEDS::SObject_ptr theSObject)
300 if (CheckBoxRestoreSS->isChecked()) {
301 // empty list of arguments means that all arguments should be restored
302 getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(),
303 /*theFindMethod=*/GEOM::FSM_GetInPlace, // ? GetInPlaceByHistory
304 /*theInheritFirstArg=*/true);