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 GEOMGUI : GUI for Geometry component
23 // File : RepairGUI_ChangeOrientationDlg.cxx
24 // Author : Sergey KUUL
27 #include "RepairGUI_ChangeOrientationDlg.h"
29 #include "SalomeApp_Application.h"
30 #include "LightApp_SelectionMgr.h"
31 #include "SUIT_Session.h"
32 #include "SALOME_ListIteratorOfListIO.hxx"
34 #include "GEOMImpl_Types.hxx"
42 //=================================================================================
43 // class : RepairGUI_ChangeOrientationDlg()
44 // purpose : Constructs a RepairGUI_ChangeOrientationDlg which is a child of 'parent',
45 // with the name 'name' and widget flags set to 'f'.
46 // The dialog will by default be modeless, unless you set 'modal' to
47 // TRUE to construct a modal dialog.
48 //=================================================================================
49 RepairGUI_ChangeOrientationDlg::RepairGUI_ChangeOrientationDlg(GeometryGUI* theGeometryGUI,
50 QWidget* parent, const char* name,
51 bool modal, WFlags fl)
52 :GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, WStyle_Customize |
53 WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
55 //QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_SUPRESS_FACE")));
56 QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_CHANGE_ORIENTATION")));
57 QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT")));
59 setCaption(tr("GEOM_CHANGE_ORIENTATION_TITLE"));
61 /***************************************************************/
62 GroupConstructors->setTitle(tr("GEOM_CHANGE_ORIENTATION_TITLE"));
63 RadioButton1->setPixmap(image0);
64 RadioButton2->close(TRUE);
65 RadioButton3->close(TRUE);
67 GroupPoints = new DlgRef_1Sel1Check_QTD(this, "GroupPoints");
68 GroupPoints->GroupBox1->setTitle(tr("GEOM_CHANGE_ORIENTATION"));
69 GroupPoints->TextLabel1->setText(tr("GEOM_SELECTED_SHAPE"));
70 GroupPoints->CheckButton1->setText(tr("GEOM_CREATE_COPY"));
71 GroupPoints->PushButton1->setPixmap(image1);
72 // GroupPoints->LineEdit1->setReadOnly( true );
74 Layout1->addWidget(GroupPoints, 2, 0);
76 setHelpFileName("change_orientation_operation_page.html");
82 //=================================================================================
83 // function : ~RepairGUI_ChangeOrientationDlg()
84 // purpose : Destroys the object and frees any allocated resources
85 //=================================================================================
86 RepairGUI_ChangeOrientationDlg::~RepairGUI_ChangeOrientationDlg()
91 //=================================================================================
94 //=================================================================================
95 void RepairGUI_ChangeOrientationDlg::Init()
98 myEditCurrentArgument = GroupPoints->LineEdit1;
100 GroupPoints->CheckButton1->setChecked(true);
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(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool)));
113 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
114 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
116 initName( tr( "CHANGE_ORIENTATION_NEW_OBJ_NAME" ) );
120 //=================================================================================
121 // function : ClickOnOk()
122 // purpose : Same than click on apply but close this dialog.
123 //=================================================================================
124 void RepairGUI_ChangeOrientationDlg::ClickOnOk()
126 if ( ClickOnApply() )
131 //=================================================================================
132 // function : ClickOnApply()
134 //=================================================================================
135 bool RepairGUI_ChangeOrientationDlg::ClickOnApply()
137 // if ( !onAccept() )
138 if ( !onAccept(GroupPoints->CheckButton1->isChecked()) )
143 myEditCurrentArgument->setText("");
149 //=================================================================================
150 // function : SelectionIntoArgument()
151 // purpose : Called when selection as changed or other case
152 //=================================================================================
153 void RepairGUI_ChangeOrientationDlg::SelectionIntoArgument()
155 myEditCurrentArgument->setText("");
158 if(myEditCurrentArgument == GroupPoints->LineEdit1) {
159 if (IObjectCount() != 1) {
160 if (myEditCurrentArgument == GroupPoints->LineEdit1)
167 Standard_Boolean testResult = Standard_False;
168 GEOM::GEOM_Object_ptr aSelectedObject =
169 GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult );
174 if (myEditCurrentArgument == GroupPoints->LineEdit1) {
175 myObject = aSelectedObject;
179 myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) );
184 //=================================================================================
185 // function : SetEditCurrentArgument()
187 //=================================================================================
188 void RepairGUI_ChangeOrientationDlg::SetEditCurrentArgument()
190 QPushButton* send = (QPushButton*)sender();
192 if( send == GroupPoints->PushButton1 )
194 GroupPoints->LineEdit1->setFocus();
195 myEditCurrentArgument = GroupPoints->LineEdit1;
197 SelectionIntoArgument();
201 //=================================================================================
202 // function : LineEditReturnPressed()
204 //=================================================================================
205 void RepairGUI_ChangeOrientationDlg::LineEditReturnPressed()
207 QLineEdit* send = (QLineEdit*)sender();
208 if( send == GroupPoints->LineEdit1 ) {
209 myEditCurrentArgument = GroupPoints->LineEdit1;
210 GEOMBase_Skeleton::LineEditReturnPressed();
215 //=================================================================================
216 // function : ActivateThisDialog()
218 //=================================================================================
219 void RepairGUI_ChangeOrientationDlg::ActivateThisDialog()
221 GEOMBase_Skeleton::ActivateThisDialog();
222 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
223 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
228 //=================================================================================
229 // function : enterEvent()
230 // purpose : Mouse enter onto the dialog to activate it
231 //=================================================================================
232 void RepairGUI_ChangeOrientationDlg::enterEvent(QEvent* e)
234 if ( !GroupConstructors->isEnabled() )
235 ActivateThisDialog();
239 //=================================================================================
240 // function : closeEvent()
242 //=================================================================================
243 void RepairGUI_ChangeOrientationDlg::closeEvent(QCloseEvent* e)
245 //myGeomGUI->SetState( -1 );
246 GEOMBase_Skeleton::closeEvent( e );
250 //=================================================================================
251 // function : createOperation
253 //=================================================================================
254 GEOM::GEOM_IOperations_ptr RepairGUI_ChangeOrientationDlg::createOperation()
256 return getGeomEngine()->GetIHealingOperations( getStudyId() );
260 //=================================================================================
261 // function : isValid
263 //=================================================================================
264 bool RepairGUI_ChangeOrientationDlg::isValid( QString& msg )
270 //=================================================================================
271 // function : execute
273 //=================================================================================
274 bool RepairGUI_ChangeOrientationDlg::execute( ObjectList& objects )
276 bool toCreateCopy = GroupPoints->CheckButton1->isChecked();
278 GEOM::GEOM_Object_var anObj;
280 anObj = GEOM::GEOM_IHealingOperations::_narrow(getOperation())->ChangeOrientationCopy(myObject);
283 anObj = GEOM::GEOM_IHealingOperations::_narrow(getOperation())->ChangeOrientation(myObject);
286 if ( !anObj->_is_nil() )
287 objects.push_back( anObj._retn() );
293 //=================================================================================
294 // function : CreateCopyModeChanged()
296 //=================================================================================
297 void RepairGUI_ChangeOrientationDlg::CreateCopyModeChanged(bool isCreateCopy)
299 GroupBoxName->setEnabled(isCreateCopy);