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.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : RepairGUI_ChangeOrientationDlg.cxx
25 // Author : Sergey KUUL
28 #include "RepairGUI_ChangeOrientationDlg.h"
30 #include "SalomeApp_Application.h"
31 #include "LightApp_SelectionMgr.h"
32 #include "SUIT_Session.h"
33 #include "SALOME_ListIteratorOfListIO.hxx"
35 #include "GEOMImpl_Types.hxx"
43 //=================================================================================
44 // class : RepairGUI_ChangeOrientationDlg()
45 // purpose : Constructs a RepairGUI_ChangeOrientationDlg which is a child of 'parent',
46 // with the name 'name' and widget flags set to 'f'.
47 // The dialog will by default be modeless, unless you set 'modal' to
48 // TRUE to construct a modal dialog.
49 //=================================================================================
50 RepairGUI_ChangeOrientationDlg::RepairGUI_ChangeOrientationDlg(GeometryGUI* theGeometryGUI,
51 QWidget* parent, const char* name,
52 bool modal, WFlags fl)
53 :GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, WStyle_Customize |
54 WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
56 //QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_SUPRESS_FACE")));
57 QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_CHANGE_ORIENTATION")));
58 QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT")));
60 setCaption(tr("GEOM_CHANGE_ORIENTATION_TITLE"));
62 /***************************************************************/
63 GroupConstructors->setTitle(tr("GEOM_CHANGE_ORIENTATION_TITLE"));
64 RadioButton1->setPixmap(image0);
65 RadioButton2->close(TRUE);
66 RadioButton3->close(TRUE);
68 GroupPoints = new DlgRef_1Sel1Check_QTD(this, "GroupPoints");
69 GroupPoints->GroupBox1->setTitle(tr("GEOM_CHANGE_ORIENTATION"));
70 GroupPoints->TextLabel1->setText(tr("GEOM_SELECTED_SHAPE"));
71 GroupPoints->CheckButton1->setText(tr("GEOM_CREATE_COPY"));
72 GroupPoints->PushButton1->setPixmap(image1);
73 // GroupPoints->LineEdit1->setReadOnly( true );
75 Layout1->addWidget(GroupPoints, 2, 0);
77 setHelpFileName("change_orientation.htm");
83 //=================================================================================
84 // function : ~RepairGUI_ChangeOrientationDlg()
85 // purpose : Destroys the object and frees any allocated resources
86 //=================================================================================
87 RepairGUI_ChangeOrientationDlg::~RepairGUI_ChangeOrientationDlg()
92 //=================================================================================
95 //=================================================================================
96 void RepairGUI_ChangeOrientationDlg::Init()
99 myEditCurrentArgument = GroupPoints->LineEdit1;
101 GroupPoints->CheckButton1->setChecked(true);
105 /* signals and slots connections */
106 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
107 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
109 connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
110 connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
112 connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool)));
114 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
115 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
117 initName( tr( "CHANGE_ORIENTATION_NEW_OBJ_NAME" ) );
121 //=================================================================================
122 // function : ClickOnOk()
123 // purpose : Same than click on apply but close this dialog.
124 //=================================================================================
125 void RepairGUI_ChangeOrientationDlg::ClickOnOk()
127 if ( ClickOnApply() )
132 //=================================================================================
133 // function : ClickOnApply()
135 //=================================================================================
136 bool RepairGUI_ChangeOrientationDlg::ClickOnApply()
138 // if ( !onAccept() )
139 if ( !onAccept(GroupPoints->CheckButton1->isChecked()) )
144 myEditCurrentArgument->setText("");
150 //=================================================================================
151 // function : SelectionIntoArgument()
152 // purpose : Called when selection as changed or other case
153 //=================================================================================
154 void RepairGUI_ChangeOrientationDlg::SelectionIntoArgument()
156 myEditCurrentArgument->setText("");
159 if(myEditCurrentArgument == GroupPoints->LineEdit1) {
160 if (IObjectCount() != 1) {
161 if (myEditCurrentArgument == GroupPoints->LineEdit1)
168 Standard_Boolean testResult = Standard_False;
169 GEOM::GEOM_Object_ptr aSelectedObject =
170 GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult );
175 if (myEditCurrentArgument == GroupPoints->LineEdit1) {
176 myObject = aSelectedObject;
180 myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) );
185 //=================================================================================
186 // function : SetEditCurrentArgument()
188 //=================================================================================
189 void RepairGUI_ChangeOrientationDlg::SetEditCurrentArgument()
191 QPushButton* send = (QPushButton*)sender();
193 if( send == GroupPoints->PushButton1 )
195 GroupPoints->LineEdit1->setFocus();
196 myEditCurrentArgument = GroupPoints->LineEdit1;
198 SelectionIntoArgument();
202 //=================================================================================
203 // function : LineEditReturnPressed()
205 //=================================================================================
206 void RepairGUI_ChangeOrientationDlg::LineEditReturnPressed()
208 QLineEdit* send = (QLineEdit*)sender();
209 if( send == GroupPoints->LineEdit1 ) {
210 myEditCurrentArgument = GroupPoints->LineEdit1;
211 GEOMBase_Skeleton::LineEditReturnPressed();
216 //=================================================================================
217 // function : ActivateThisDialog()
219 //=================================================================================
220 void RepairGUI_ChangeOrientationDlg::ActivateThisDialog()
222 GEOMBase_Skeleton::ActivateThisDialog();
223 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
224 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
229 //=================================================================================
230 // function : enterEvent()
231 // purpose : Mouse enter onto the dialog to activate it
232 //=================================================================================
233 void RepairGUI_ChangeOrientationDlg::enterEvent(QEvent* e)
235 if ( !GroupConstructors->isEnabled() )
236 ActivateThisDialog();
240 //=================================================================================
241 // function : closeEvent()
243 //=================================================================================
244 void RepairGUI_ChangeOrientationDlg::closeEvent(QCloseEvent* e)
246 //myGeomGUI->SetState( -1 );
247 GEOMBase_Skeleton::closeEvent( e );
251 //=================================================================================
252 // function : createOperation
254 //=================================================================================
255 GEOM::GEOM_IOperations_ptr RepairGUI_ChangeOrientationDlg::createOperation()
257 return getGeomEngine()->GetIHealingOperations( getStudyId() );
261 //=================================================================================
262 // function : isValid
264 //=================================================================================
265 bool RepairGUI_ChangeOrientationDlg::isValid( QString& msg )
271 //=================================================================================
272 // function : execute
274 //=================================================================================
275 bool RepairGUI_ChangeOrientationDlg::execute( ObjectList& objects )
277 bool toCreateCopy = GroupPoints->CheckButton1->isChecked();
279 GEOM::GEOM_Object_var anObj;
281 anObj = GEOM::GEOM_IHealingOperations::_narrow(getOperation())->ChangeOrientationCopy(myObject);
284 anObj = GEOM::GEOM_IHealingOperations::_narrow(getOperation())->ChangeOrientation(myObject);
287 if ( !anObj->_is_nil() )
288 objects.push_back( anObj._retn() );
294 //=================================================================================
295 // function : CreateCopyModeChanged()
297 //=================================================================================
298 void RepairGUI_ChangeOrientationDlg::CreateCopyModeChanged(bool isCreateCopy)
300 GroupBoxName->setEnabled(isCreateCopy);